Files
pipelines/docs/stage-file-diffs.md
T
alan 87016ef5dc Engine: check stages, harness-agnostic delivery, read-only enforcement, complete captures
- New `type=check` stage: the server runs a `commands` block (sh -c, per
  command_timeout, workspace env) and routes on pass/fail; per-command status,
  exit code, duration and bounded output are recorded and the failing output is
  the handoff. With delivery=true it is the landing gate (commit leftovers,
  merge moved main, checks in a fresh candidate worktree, fast-forward main).
  Parser/registry, lint (silent guards), format docs, CLI inspect, app graph and
  run detail rendering.
- delivery=true is accepted on every harness (and on check stages).
- permissions.shell on claude stages maps to Bash(cmd) / Bash(prefix:*) rules
  instead of a bare Bash allow; stages without edit that change the workspace
  fail the visit with the changed files listed (allow_workspace_changes=true
  opts out; artifacts, public and harness state dirs are ignored).
- File-change capture: symlinks compared by target, untouched protected files no
  longer make captures partial, untracked caches/dependency/build output left
  out, lockfiles listed without patch, huge files compared by metadata, raised
  patch/line limits. Outcome repair follow-ups are logged and counted on the
  step (control.outcome_repairs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 12:52:16 +00:00

6.7 KiB

Retained stage file changes

Each newly executed stage visit compares a read-only snapshot of its run directory immediately before execution with a snapshot after execution/cleanup. The server stores the observed changes and unified patches in SQLite alongside the finished step, atomically. Later stages, edits and server restarts do not replace that evidence. Existing historical steps have no retroactive capture.

On Run → Details, select a recorded visit with n/p. Its File changes section is expanded by default: added lines are green, removed lines red, and hunk headers accented. d focuses/toggles the diff; ordinary scrolling handles long patches. Tab still switches only Details ↔ Graph. pipelines inspect RUN_ID --json includes the same evidence under each step's file_changes field.

Scope and limitations

  • This compares stage-start contents, not HEAD or the index. Pre-existing dirty content is the baseline. Changes are retained separately for repeated visits.
  • In a Git working tree, capture includes tracked and nonignored untracked files within the run directory. Previously captured files remain eligible after an index/ignore change. Git is only read, never used to stage or revert. Outside Git, capture walks regular files in the run directory.
  • In Git, the stage-start snapshot keeps text only for files that are dirty or untracked at start (git status); a clean tracked file keeps just its hash and index blob id. If it changes, its start content is read back from that blob (git cat-file --batch) and used only when its SHA-256 matches what was read from disk at start. A commit, reset or index change by the stage therefore does not move the baseline, and the text budget is no longer spent alphabetically on files that never change. A blob that cannot be verified (filters, line-ending conversion, assume-unchanged) is listed with no_patch_reason: "baseline".
  • Added/deleted files and permission changes are recorded. Renames appear as deletion/addition. Binary changes retain metadata, not binary contents.
  • Common credential/environment/key/database paths and secrets/ are protected: never opened or listed. They are fingerprinted by metadata (size, mtime, mode) only, so an untouched .env no longer makes a capture partial; a change to one makes the visit partial (counted in skipped). This is a path-based precaution, not secret-content scanning; ordinary source patches may contain sensitive text and become part of retained history.
  • Tool output is not stage work: untracked files below cache and dependency directories (node_modules/, .git/, __pycache__/, .venv/, .mypy_cache/, .pytest_cache/, .ruff_cache/, .next/, .dart_tool/, .gradle/, ...), untracked *.pyc, and untracked files below build/, dist/, out/, target/ or coverage/ where Git tracks nothing are left out of the inventory entirely. Outside Git the cache directories are not walked.
  • Symlinks are compared by their target (never followed) and listed with no_patch_reason: "symlink"; a path through a symlinked directory is skipped.
  • Limits: 20,000 inventoried entries, 1 MiB per file and 32 MiB per snapshot of retained text, five seconds per snapshot, 20,000 combined lines per textual comparison, 128 KiB per patch and 512 KiB serialized file evidence per visit. Files over 256 MiB are compared by size, mtime and mode (no_patch_reason: "large"). Unreadable, omitted or truncated evidence is explicitly flagged partial.
  • Over-budget content degrades to a listing, not silence: a text file over 1 MiB, or beyond the 32 MiB snapshot budget, is still compared by SHA-256 and a change is listed with no_patch: true (and truncated) but no patch. In a Git working tree, a path the snapshot could not compare at all (above 256 MiB, unreadable, or past the time/file limit) is listed the same way when its git status --porcelain entry changed during the visit; a path dirty with the same status before and after cannot be proven changed and stays in skipped. Git is only read (--no-optional-locks); protected and excluded paths are never listed.
  • Each content change without a (complete) patch carries no_patch_reason: binary, symlink, large, generated (lockfiles such as go.sum or package-lock.json, *.min.js, source maps, files below a cache directory), file_size (text over 1 MiB), budget (32 MiB snapshot text budget), lines (over 20,000 combined lines), evidence_size (per-visit retained evidence limit), git_status (seen only in Git status) or baseline. binary, symlink, large and generated changes are listed completely and stay complete; the others make the visit partial.
  • pipelines inspect RUN_ID --json carries a top-level warnings list (also printed to stderr) naming every visit whose capture was partial or unavailable.
  • Failed/canceled stages still retain changes when execution returns. Unconfirmed agent cleanup is flagged partial. A server/process crash cannot guarantee an after-snapshot; recovered steps without capture say “not recorded.”
  • Capture is not a transactional filesystem snapshot: concurrent manual edits, other processes or other runs may appear in the diff. Changes outside the run directory, ignored new files, and edits reverted before capture are not observed. The view describes observed changes, not proof of exclusive model authorship.
  • Capture failure does not change the pipeline's declared outcome or permissions.

Snapshots are transient server memory. The database retains patches/metadata, not full copies of every workspace file. No new model calls are used for capture.

Server skip fallback

A non-human stage that declares a skipped edge (typically a UI reviewer) is completed by the server without a model call, and routed along skipped, only when every earlier visit of the run recorded a complete capture with no changed files and no image artifact. The step's verdict reason begins "Server fallback skip (no model run):" and has reason_source: fallback.

Everything else runs the stage's model, which may still choose skipped itself:

  • any recorded file change, whatever its path or extension (no repository layout or "non-UI" extension list is assumed: Go TUIs, Flutter .dart, Kotlin, Swift, templates, strings and config files can all be rendered surface);
  • any partial or unavailable capture, or a visit with no capture (a crash, a historical row, a human decision during which the workspace was unobserved, or a checkpoint-retry prefix);
  • auto_skip=false in the stage's configs.

A wrong run costs one model call; a wrong skip would ship an unreviewed change, so absent or partial evidence is never read as "nothing changed".