Skip to content

fix(api): apply the guest file view to checkpoint file routes - #538

Merged
markbang merged 2 commits into
mainfrom
fix/checkpoint-fs-visibility
Nov 20, 2026
Merged

markbang merged 2 commits into
mainfrom
fix/checkpoint-fs-visibility

Conversation

@markbang

@markbang markbang commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Reads of checkpoints committed before a .gitignore rule are filtered at read time against the current workspace .gitignore (test: reads of a checkpoint committed before a .gitignore rule are filtered by the current rule).

Checkpoint file routes (/checkpoints/:id/fs/{tree,file,diff,diff/file}) checked only checkpoint.view. The workspace file routes also apply the caller's file view, so filtered viewers were not held to the workspace .gitignore on checkpoint reads.

checkpoint FS route
  resolveCheckpointFsVisibility()        full | filtered | null (null -> 401/403)
    filtered + local sandbox             -> null (no server-side .gitignore)
  checkpoint-fs / checkpoint-diff helpers(visibility)
    filtered: skip precomputed + cached diffs
              hide paths matched by workspace .gitignore
              404 path_not_found for hidden file / directory
    full:     unchanged
  • resolveFileViewVisibility moves to permissions.ts so both file routes share it.
  • The .gitignore used is the workspace's current one, read per request (the same rule as the live view). A rule added later also hides already-checkpointed content.
  • Filtered diff responses are not cached and skip the save-time precomputed diffs, which hold unfiltered paths and url-delivered objects. Owner responses are unchanged.
  • Internal reads (sandbox preferences of a mod Space) pass visibility: "full" explicitly.

Evidence

  • Before: a filtered view of a checkpoint returned contents and metadata for a path matched by .gitignore.
    After: the same request returns 404 path_not_found, and the tree and diff summary omit the path. Full view returns the same results as before.
  • Regression tests in apps/api/tests/checkpoint-fs-visibility.integration.ts (real git repo, real .gitignore):
    • owner reads the ignored file via tree, file, diff, and diff/file
    • filtered viewer reads a non-ignored file
    • filtered viewer gets 404 / absent entries for the ignored file on every route, including after the rule is added
    • the guest-ignored test fails on main and passes here
  • node scripts/test/run.mjs ... tests/fs-pagination.integration.ts tests/checkpoint-fs-visibility.integration.ts: 8 tests pass.
  • src/checkpoint-diff.test.ts: 5 tests pass.
  • biome check on touched files: clean.
  • tsc --noEmit in apps/api: the same pre-existing errors as main in this environment (unbuilt workspace packages); none new.

Merge Danger

Door: two-way. Revert restores the previous behaviour; no data or schema change.

Blast Radius: checkpoint file and diff routes for non-owner viewers, plus the checkpoint-fs helpers' signature (all callers in this PR). Owner and full-view responses are unchanged. Filtered diffs are computed from git on each request instead of the cache, so guest diff latency rises slightly. Filtered access to checkpoints of local sandboxes is now denied (403), as the workspace routes already do.

Checkpoint file routes checked only checkpoint.view, so a guest could read
files that the workspace .gitignore hides, through checkpoints/:id/fs/*.

Resolve the caller's file view like the workspace routes and apply it in the
shared checkpoint helpers. A filtered view hides paths matched by the
workspace .gitignore, read per request, so a rule added later also hides
older checkpoints. Filtered views skip the precomputed and cached diffs,
which hold unfiltered paths. Filtered access on local sandboxes is denied,
because their .gitignore is not on this server.
A checkpoint committed before a .gitignore rule is filtered by the current workspace rule on every read, including after an owner read has populated the caches.
@markbang
markbang force-pushed the fix/checkpoint-fs-visibility branch from d53426e to 32c8807 Compare November 20, 2026 06:08
@markbang
markbang merged commit a870dbc into main Nov 20, 2026
4 checks passed
@markbang
markbang deleted the fix/checkpoint-fs-visibility branch November 20, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant