English
UI Facade: Web Enhancement (Decisions and Roadmap)
User feedback: cage does not feel good to use, and people want a UI. This document settles four things: the form-factor choice, interface coverage, the change-visualization policy, and how dual-end differences are expressed. The positioning is unchanged (web.md): the Web UI is another facade over the same core, and the frontend duplicates no rule semantics; the three disciplines — zero new dependencies, single binary, no node editor toolchain — all carry forward.
Measured Baseline (at the 2026-10-12 Decision; re-measured 2026-11-02)
- release exe 12.5 MiB (lto + strip + opt-level=z).
- editor page 55 KB (index.html 2.5 / app.js 43.2 / app.css 9.3 KB), embedded at compile time via
include_str!(web/mod.rs), so the single binary carries its own UI; the status page adds a second embedded pair (/status/app.js+/status/app.css). - the HTTP surface has grown past the original 6 routes (see
web.mdfor the W-series): it now serves the editor and status pages plus theapi/*surface (schema, validate, tables, table, upload, build, artifacts, artifact, snapshots, snapshot, diff, registry, status), bound to127.0.0.1only, no authentication (positioned as a local tool). - manifest hashing is two-tier:
table_hashesas a per-table blake3 row fingerprint → a per-target canonical fingerprint (sorted by(format, output_dir)) → a per-file hash → the rootcontent_hash;build_id = blake3(profile + schema_hash + source_hash + content_hash)(profile is part of the input). - incremental builds already consume this hash layer:
prev/cur table_hashescompared table by table + dependency-graph propagation decides the skip set (main.rs). cage difftoday: a flat comparison of theartifactsfrom two manifests (+/-/~+ counts + acontent_hashline); schema-level diff is handled separately bymigrate::diff_schemas.
Form Factor: Decision c (Enhance the Existing Web), Absorbing d, a / b Demoted to Alternatives
| Dimension | a) Tauri desktop shell | b) pure Rust GUI (egui/iced) | c) enhance cage web | d) polish the CLI only |
|---|---|---|---|---|
| Size | shell adds ~8–15 MB more (estimated, system WebView) | adds ~10–20 MB (estimated, GUI stack goes into the exe) | embedded strings + a thin JSON API, about ±0.3 MB, still ~11 MiB overall | unchanged |
| Distribution / packaging | NSIS/MSI or a portable exe; Linux cannot cross-build a Tauri exe, so packaging must move to a Windows runner, and the nightly zip layout would have to change | cross-building an MSVC exe on Linux needs a new toolchain (something like cargo-xwin), a large new CI surface | completely unchanged: same exe, same nightly zip + SHA256SUMS, install.sh/ps1 as-is | unchanged |
| cage-core reuse | in-process direct calls | in-process direct calls | in-process direct calls (the W2 exchange model already works) | direct calls |
| Escaping the terminal | desktop window | possible | the browser — and naturally cross-machine: cage web runs on a Linux server, opened from a Windows browser | not possible |
| Maintenance cost | high: a giant dependency tree (breaks zero new dependencies) + WebView2/webkit2gtk quirks on both ends + a packaging pipeline | high: rich data views (tables / trees / diffs) are all hand-rolled in immediate mode | lowest: vanilla JS with no build chain, reusing all of the existing W1–W4 assets | lowest, but it does not address the "want a UI" request |
What was decided: the UI form factor is direction c — enhance the existing cage web (a direct extension of the W2 local server + W3 editor page), plugging the already-existing data — manifest / artifacts / snapshot / registry / diff — into the facade; direction d is not a separate project but is absorbed as a discipline (see "Absorbing d"). The primary usage topology is a Linux server (running builds) + a Windows client (viewing results, editing data), and the artifact must still ship as an exe.
Why: ① topology fit — the browser is the only surface that spans "headless server + Windows desktop" at zero packaging cost, and a desktop shell cannot open a window on a server; ② releaseable — the artifact is still that one exe, and the nightly rolling channel carries it out as before (a daily build is a normal delivery surface), without touching the version-release red line and without adding a Windows packaging surface to CI; ③ highest reuse — the W1 exchange model, W2 local server, W3 editor, /api/schema, POST /api/validate, E1701/E1004 are all already in place; what is missing is only facade area, not foundations.
Alternatives: a) a Tauri shell (reuses the most UI assets, but at the cost of an entire packaging pipeline + a dependency-tree explosion, and it is useless in the server scenario); b) an egui/iced single-binary GUI (the dependency tree is somewhat more controllable, but all rich data views are hand-rolled — the largest amount of work — and it is equally a dead end on a headless server) — both are demoted to alternatives and are not implemented.
Boundaries: no game-logic framework (the red line is unchanged); no multi-user / remote-team collaboration (the web UI is a single-machine local tool); no standalone frontend build chain beyond the editor (the vanilla ES module discipline is unchanged, still embedded at compile time).
Sticking-point condition (the only reason to reopen a/b): a real usage scenario arises where you "must escape the browser" (a fully offline desktop environment, no browser available), or the UI grows so large that embedded strings become unmaintainable — then restart the form-factor evaluation.
Remote access policy (decided): keep binding to 127.0.0.1 only with no authentication — untouched. The server → Windows client remote scenario uses SSH port forwarding (documenting the usage is enough). --bind / LAN exposure must have authentication first (the registry already has the --auth-env precedent to follow); it is registered as a sticking-point condition and is not done this phase — exposing an unauthenticated local service onto a LAN is a security regression, and no exception is made for convenience.
Trusted-environment boundary (review P3-3, decided 2026-11-22): cage web stays a local-first, single-user workbench for a trusted environment — not a hosted multi-user management service. No accounts/login/roles, no remote administration, no secret management, no multi-user coordination between authors: the collaboration model is Git (schema files are the source of truth in the repo; merge conflicts are resolved by Git's own tooling, cage check is the shared arbiter), never the web server. The full record, including the enforced mechanism (loopback bind, Host/Origin gate, body caps, upload guards) and the re-evaluation condition, lives in the web facade's trusted-environment boundary decision. Centralized multi-planner collaboration (auth / permissions / review / conflict-merge / release flow) is only designed as a product if a real scenario demands it.
How d is absorbed (not a separate project): CLI readability was already a first-class citizen (E codes + location + hints), and it is absorbed as two disciplines: ① when a new UI endpoint lands, the same parameter semantics are reflected in the CLI output (the text surface and the UI share the same core function — the single-entry discipline, same as the validate_project precedent); ② any CLI output an increment touches is re-reviewed against the "errors are readable + summary is readable" standard. The one explicit deliverable: when U3 lands, the cage diff text output also gets the layered summary (see the change-visualization section).
Interface Coverage (P0 → P1 → P2)
Endpoint discipline: every new surface = one thin JSON endpoint + frontend wiring. Every endpoint is a direct call into an existing cage-core function, continuing the W2 exchange model; the server holds no state and reloads the on-disk state on every request (same as /api/schema). The frontend adds no build chain — it remains an extension of the docs/public/editor/ single page or a sibling static page, embedded at compile time.
P0 (First Batch, All Wiring of Existing Data)
- Project and build status: profile list, validation status (shares the
validate_projectsingle entry withcheck, so UI diagnostics and CI diagnostics never diverge), build freshness (current sourcetable_hashesvs the old values in the last manifest — the very numbers incremental builds already compare, telling the user directly "which tables changed and have not been rebuilt yet"), and the last build facts (profile, build_id, content_hash, target count). - Validation panel: a diagnostics table (code / severity / file-Sheet-cell location / hint), sourced from
POST /api/validate, and consumed in three places — LSP, CLI, and here — from the sameDiagnostics.
P1 (Second Batch)
- profile × target artifact browsing: a profile selector → target list → the
manifest.artifactstree (per-file hash / size / online preview / download); grouping byoutput_dirnaturally layers by profile (build/client/, build/server/). - schema editor completion: the existing W3 editor already mounts E1701/E1004 diagnostics; add the field-level
targetsbadge and the rest of the dual-end visibility expressions (see the dedicated section below).
P2 (Third Batch, Policy First, Landing with Each Increment)
- Snapshots: three actions — list (the historical snapshot directory), verify (the same core call as
snapshot --verify), and package. (implemented in U3) - registry entry browsing: lists of local and remote entries (the remote list has already landed), with version, dependency pin, and hash visible. (implemented in U3)
- diff and change visualization: the semantic layered diff (dedicated section below). (implemented in U3)
Change Visualization: No Merkle, a Semantic Layered Diff
What was decided: the semantic presentation of a diff has three layers, all data coming from the existing manifest, with zero format changes and zero hash redefinitions. The diff API returns:
json
{
"changed_tables": ["item", "stage"],
"affected_targets": ["json:build/client/data", "..."],
"files": { "added": [], "removed": [], "changed": [] },
"roots": { "content_hash": "…", "build_id": "…" }
}The UI collapses along three layers of table → target → file: which tables changed → which targets are affected → which files are touched. changed_tables = a table-by-table comparison of the two manifests' table_hashes; affected_targets = changed tables propagated through the dependency graph (the same logic as incremental builds); files = the existing run_diff's flat result hung under the corresponding subtree. The text surface is in sync: cage diff gains a layered summary output (table / target lines + a file list), sharing the same semantic diff function as the UI (single entry).
Why: today's cage diff is a flat file list, so "which part changed" has to be read out of the paths by the user. But table_hashes are already in hand per table, so semantic layering only needs one comparison + one dependency-graph propagation + one join — all display-layer work, touching no load-bearing structure.
Alternative (rejected): Merkle-ization — add interior node digests so diff walks the minimal subtrees that differ. Rejection reasons: ① the manifest root (content_hash / build_id) is a load-bearing wall — deterministic builds, registry version pins, snapshot verification, and incremental caching all hang on it, so redefining it = total cache invalidation + old pins breaking; ② in a local diff both manifests are already on disk and must be scanned O(manifest) anyway, so Merkle pruning saves no local work at all — its benefit only exists in a "pull only the changed subtree from a remote" incremental-sync scenario, which this repository does not have.
Boundaries: no versioned manifest format migration (no format change, so no migration); the semantic layer of diff answers only "where it changed", not "how the content changed" (a per-field value-level diff is a new capability surface, to be a separate project when needed — the schema level already has diff_schemas to follow).
Sticking-point condition (the only reason to reopen Merkle): reopen it if an incremental-sync need emerges where "a consumer pulls only the changed subtree from a remote registry / snapshot".
Expressing Dual-End Differences (profile × target × Field Visibility)
Factual basis: a profile determines the target list and output_dir (build/client/, build/server/); table-level and field-level targets (in the schema) cause filter_by_profile to strip fields from that profile's schema and from all artifacts (the example project's server-only field internal_note is exactly this); build_id inputs include profile.
Four UI expressions:
- Artifact ownership: the manifest carries profile and build_id, and the artifact browser groups by
output_dir+ a global profile badge — every view is labeled as "which end's artifact this is". - Field-visibility badges: whenever
field.targets/table.targetsis non-empty, render a badge in the editor and browsing views (internal_note→ "server only"); the data source is the schema itself, with no new state. (implemented in U2b) - profile-scoped view:
GET /api/schema?profile=returns a projected schema (a direct call to the off-the-shelffilter_by_profilefunction); stripped fields show "not visible in this profile" instead of disappearing — things that are hidden must be visibly hidden. (implemented in U2b) - Cross-end comparison (P2): pick a table → a client / server two-column matrix, with field rows in three states: "server only", "client only", "visible on both ends"; the artifacts side shows the same table side by side, and the extra fields on the server are the mirror image of the visibility stripping.
Roadmap
After each item lands, append a landing record to this section (the convention follows docs/design.md): the implemented surface, policy refinements, and acceptance method.
Planner Rule Interface (2026-10-20 user directive: design first, then build)
The directive: planners configuring rules without any interface hurts. Positioning per the "Rule Configuration Interface" block in todo: planners must be able to configure rules, run validation and read results without touching the CLI or files, reusing existing assets (Diagnostics locations → table/row/column anchoring; the error-code table → a readable panel; one parsing convention, never two). This section is the design decision taken before any implementation.
Entry shape (decided 2026-10-20): no new cage serve subcommand — everything lands in the existing single cage web service. Basis: shape decision c (above) already settled "enhance the existing cage web", and W5–W8 have already brought project-level validation (the validation face of /api/status ships code/severity/location/hint diagnostics JSON), builds, artifacts, diff and registry to the facade — a separate subcommand would fork the security boundary (loopback checks, bounded reads, the 8 MiB cap; the 2026-10-18 表一#2 hardening) and the docs surface. cage serve in the todo was the queuing seat's shorthand, not the user's own words.
P0 delta inventory (against the implemented surface, to avoid rebuilding):
| todo wording | Current state | Real delta |
|---|---|---|
| One-click validate | /api/status already runs full validate_project diagnostics | No new validation — presentation-layer work only |
| Diagnostics panel | The status page panel exists (code/severity/location/hint) | Filter controls (by code/severity) |
| Click to jump to table row/column | The editor's focusDiag only jumps to schema fields | A data table view (data rows are not displayed anywhere today) plus mapping diagnostic Source locations (file/Sheet/Row/Col) to highlighted cells |
| Upload or select files | The server reads only in-repo source_roots | Select first (an inventory of the repo's source files); upload later landed under a delegated security policy (2026-10-21, see the upload landing record below: only the registered source file, atomic replacement, rollback when validation refuses) |
Endpoint discipline unchanged: every new face = one thin JSON endpoint (GET /api/tables listing + GET /api/table?name= with paginated, truncated rows, calling the existing load-chain functions directly) + front-end wiring; the server stays stateless; vanilla ES module, zero build chain, compiled in at build time; validation stays single-entry (validate_project, the existing check / lsp / web same-source discipline).
Phasing:
- P0 data panel: table list → table view (pagination + row/column caps so a large table cannot blow up the browser) → diagnostics filters (code/severity) → click a diagnostic to jump and highlight the cell.
- P1 rule forms + one-click export: rule editing rides the existing W3 editor (form-ization = editor interaction work; saving goes through the existing
POST /api/schemachain, serialization stays cage's); export reuses the existingPOST /api/build+/api/artifactsdownloads (whether to also zip is decided at implementation time; artifact bytes are never recomputed). - P2 version compare + template library: compare reuses the existing
GET /api/difflayered JSON; the template library is a front-end static template dictionary generating schema fragments (numeric range / enum / foreign-key reference to start), saved through the same schema save chain — zero new server surface.
Acceptance: per endpoint, web/tests.rs unit tests + tests/web/ integration + a web-smoke step (the U-series convention); the table view gets pagination/truncation assertions; the diagnostic anchoring gets a bad-data → click → highlighted-coordinate assertion; the upload lands with refusal-and-rollback assertions.
Boundary: no multi-user/remote (remote access still goes through SSH port forwarding, per the decision above); uploads only under the delegated policy above (registered source file, whole-file replacement with validation rollback); no new rule execution logic — validation stays the validate_project single entry.
P0 landing record (2026-10-20): the data panel is implemented — GET /api/tables + GET /api/table (web/handlers.rs; row window paginated at 200, capped at 1000; the primary key taken from the schema definition); the status page's "Data" section (table list + sticky-thead table view + pager); the diagnostics panel's severity/error-code filters and click-to-jump row highlight (jumpToDiag). Tests: +2 web unit tests (32 green total) + 1 integration test (14 green) + web-smoke step 5 assertions folded in, full script run passing. Recorded in docs/web.md W9.
Upload landing record (2026-10-21, decided by delegation): the earlier deferral ("uploads wait for a security decision", 2026-10-20) is lifted under the standing delegation — pending decisions adopt the recommended option, get recorded, and stay vetoable. Five-point security policy, all implemented:
- Write-path scope: only the table's registered
source_file(resolve_upload_targetdouble-guards after canonicalization: inside the project root AND inside at least onesource_roots; symlink escapes refused too) — no arbitrary paths; - Overwrite: whole-file replacement with a front-end confirmation; the server lands bytes via tmp + rename (atomic, never a half-written file);
- Size cap: the existing 8 MiB request-body cap applies unchanged;
- Mapping and inference: none — file/table/column names are whatever the repo registered, uploaded bytes must parse under that file's format, and tables spanning several files are refused outright (their rows cannot be replaced by one file without orphaning rows);
- Validation and rollback: after the swap, the same full
validate_projectruns (check / lsp / web, one entry); errors or a load failure restore the original file before responding — a refused upload never leaves bytes on disk.
Endpoint POST /api/upload?name=NAME (raw-byte body), recorded in docs/web.md W12. Tests: +5 web unit tests (accept and land / bad data refused with byte-identical restore / unparseable refused / ghost and missing name / double path guard incl. symlink escape) + 1 integration end to end (replace, refusal rollback, no temp litter) + web-smoke step 5 (a real upload round trip).
P1 landing record (2026-10-20, decided by delegation):
- Rule form editing — inventory verdict: mostly already implemented. The W3 editor IS the rule form (19 field types, min/max/pattern/allowlist constraints, references for referential integrity / cross-table, expression rules), saving through the existing
POST /api/schemacanonical YAML chain (serialization stays with cage, the UI never writes files by hand). This round closed the one gap, "re-validate on change": an "immediate re-validation" toggle in the top bar (default on) plus a 700ms debounced silent re-validation (only refreshes the diagnostics panel, no toast; the manual "Validate" button is unchanged). - One-click export — decided: no new zip/packaging endpoint. Rationale: artifact bytes are never recomputed, zero new dependencies (a packager means either a crate or a hand-rolled protocol surface), and
/api/artifactalready serves hash-verified files. The landed form is an "Export all" button on the status page's artifact cards: it triggers the/api/artifactdownloads one by one (each file hash-checked individually); the browser may ask for "allow multiple downloads". Bulk distribution stays with thecage snapshotdirectory package (self-verifying, independently loadable) — not rebuilt in the web. - Tests: integration assertions (editor page carries the re-validation toggle and
scheduleAutoValidate; the status page export rides/api/artifact) +node --checkon both page scripts; web unit 32 green / integration 14 green unchanged (P1 adds zero server surface). Recorded in docs/web.md W10.
P2 landing record (2026-10-20, decided by delegation):
- Compare — inventory verdict: mostly already implemented. The product diff is W8's "Compare" section (live ↔ any snapshot, three-level collapsing, an exact-bytes verdict, same
GET /api/diffsource). This round adds the diagnostics diff: markers for what a second validation run in the same session added or removed (the summary shows "vs last: +n / -m gone"; new diagnostics carry a "new" badge; runs are compared only at the same profile+env+level, and a refused build swapping diagnostics in is covered too — exactly the "change data → build → what errors appeared" main path). Decided against storing historical diagnostics per snapshot (that means writing diagnostics into the snapshot package — new server surface plus a format change, no user directive; the historical product comparison is already W8's). - Template library — landed as a front-end static dictionary: the editor's field section gains a "add field from template" dropdown (numeric range Int+min/max / enum reference / foreign-key reference); a generated field draft flows through the existing setPathRoot → auto-revalidate → save chain, zero new server surface.
- Tests: integration assertions (the editor's
FIELD_TEMPLATESand the foreign-key template; the status page'smarkDiagDiffanddiag-new) +node --checkon both page scripts; P2 adds zero server surface. Recorded in docs/web.md W11. With this, all five planner-interface items have landed; upload followed the next day under the delegated policy (see the upload landing record above).