Skip to content

[Spec 1951] Read-only PR check for architects: codev check pr | deploy | worktree - #1958

Merged
waleedkadous merged 104 commits into
mainfrom
builder/spir-1951
Nov 25, 2026
Merged

waleedkadous merged 104 commits into
mainfrom
builder/spir-1951

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

codev check is a read-only command group:

  • codev check pr <N> collects what an architect reads before recommending a merge. It reports:
    • the exact head and live base, and the PR's state;
    • the forge's mergeability;
    • a trial merge that moves no ref;
    • CI on the code, found past any porch-only commits on the head;
    • attribution lines, watched files, the linked issue, the size, and the files a person still has to read.
  • codev check deploy <N>… says whether merged PRs reached the deploy branch and, if a deploy workflow is configured, its latest green run.
  • codev check worktree <id|path> says whether removing a builder's worktree and branch would lose data.

Each prints a summary a person can read in ten seconds, a --json report (schema: 1), and exit 0 (clear), 1 (needs attention) or 2 (the command failed). They never merge, push, comment or delete.

Closes #1951

For the owner to accept: when configuration is validated

  • The spec says config values are validated "before any subprocess runs" (Success Criteria, Input validation; the plan repeats it).
  • The code first runs two local, read-only git calls: git rev-parse --show-toplevel and git worktree list --porcelain.
  • Why: configuration is read from the main checkout, and from a builder worktree only git can name it (findWorkspaceRoot() returns the worktree itself). Neither call takes a configuration value. No config value reaches any subprocess, forge call or network call before it is validated.
  • The alternative, not taken: finding the main checkout without git, by parsing .git and commondir by hand, would reimplement git's discovery and could disagree with it.
  • How it was found: Codex, in the PR review. Before that, a third call (the origin check) also ran first, and the test said only "before any forge call". It now runs after validation. The pr, deploy and worktree config-error tests record every spawn and assert exactly the two calls.
  • The approved spec and plan text are unchanged. It is yours to accept.

How read-only is enforced

  • One runner. commands/check/runner.ts is the only module allowed to spawn. Every git argv must fit a closed per-subcommand grammar. Diff-family commands are forced to --no-ext-diff --no-textconv, and the only fetch allowed is ref-neutral, by SHA. The only forge concepts allowed are pr-view, pr-search, commit-checks and workflow-runs. Anything else is refused before it is spawned (exit 2). An audited-imports test keeps child_process and the forge dispatcher inside runner.ts.
  • Stub executables. The tests put stub git and gh first on PATH. Each stub keeps its own grammar and records every argv, and any write form fails the test.
  • Real repositories. Snapshot tests compare refs, HEAD, the index bytes, FETCH_HEAD and status before and after each command. The runs include a conflicting trial merge and a fetch of missing objects. The only writes are object-store additions.

Changes

  • Forge (Phase 1):
  • Core (Phase 2): the runner, allow-list, input validation, roots taken from git, check.* settings, the report and its renderer, and the git plumbing.
  • check pr (Phases 3–4): eleven checks, an end-of-run re-read of the head and base, and the porch-only walk.
  • check deploy (Phase 5): merged, on-branch, deploy-run and merge-checks.
  • check worktree (Phase 6): uncommitted, commits, remote, pr and ignored. New shared modules agent-farm/lib/keep-list.ts and builder-scaffold.ts are used by afx cleanup as well.
  • afx cleanup:
    • Its informational dirty notice uses the shared scaffold rule (owner decision main-36), so a worktree holding only spawn's files is no longer reported dirty.
    • It reads git status -z, so quoted paths are judged correctly.
    • It recognises spawn's symlinks, hard links and unchanged copies.
    • Nothing that decides what cleanup removes changed.
  • Docs, in both trees (Phase 7):
    • The architect role runs codev check pr before choosing review depth and before a merge word, check deploy after merges, and check worktree before afx cleanup.
    • risk-triage.md Step 1 starts from codev check pr. Fixed in place: it named gh pr diff --stat, a flag that does not exist.
    • Also updated: workflow-reference.md, overview.md, the codev.md reference (with real samples and the shipped JSON), forge.md, the codev skill in all four copies (hashes regenerated), the forge skill, and arch.md §9.
  • Review phase:
    • Three cleanup suites now mock execFile in the four-argument form the dirty notice calls. Before, it always read "Unable to check status".
    • Two hang tests survive machine load.
    • The retrospective is written, and seven lessons are routed to the cold tier.
  • PR review, round 1 (d5bc0b227):
    • check pr's end-of-run pr-view compares the base branch, state and draft flag as well as the head. A PR closed, merged, marked draft or retargeted during the run needs attention, with a line naming what changed.
    • When the head moved, the forge line names the head its answer is about.
    • The origin check runs after config validation (see above).
    • Worktree paths are parsed verbatim; not with -z, which needs git 2.36.
    • codev.md says attribution patterns run without a time limit.

Testing

  • Full local run, the local evidence (owner ruling main-39 retired ci-first). After merging main's worker cap (PR Fix #1956: cap packages/codev vitest at 3 workers (singleFork was dead since Vitest 4) #1965), on the final head 30853b1fe, npm test -- --exclude='**/e2e/**' from packages/codev: 440 files passed and 14 skipped; 9,286 tests passed and 116 skipped; exit 0. Wall time 363 s; one-minute load 18.4 at the start, peak 27.7. Main then moved (Spec 1940), and codev check pr 1958 found a conflict in lessons-learned.md before the gate; the forge agreed. After merging main (5d802799f), a second full run: 449 files passed and 14 skipped; 9,885 tests passed and 116 skipped; exit 0; 342 s; load 11.0 at the start, peak 39.0.

  • Test scenarios 1–28a each have at least one test. Targeted local run after the PR review fixes: 1028/1028 in 36 files. An earlier run's one failure was a load-sensitive hang test of this PR's own, fixed in 017f0baea.

  • Locally: the build, the type-check on the source and on the check tests, and the tmp-residue check. Governance doc tests: 153/153.

  • Live runs, with no ref changed:

    • codev check pr 1958 at a head four porch-only commits above the code: 7.3 s.
    • codev check pr 1640 (44 files): CONFLICTING, DIRTY, agreeing with a 15-file trial-merge conflict: 7.6 s.
    • An attribution hit on Fix #1641: default the claude consult lane to the 1M context window #1657 from a scratch clone.
    • check deploy with and without a deploy workflow.
    • check worktree on four builders.

    The architect repeated runs of each command from the main checkout.

  • Windows:

    • 45484244459 on 1a6eb69dd, after the PR review round 1 fixes (full suites plus commands/check): green, and GitHub was 8/8 there;
    • 45486141662 on the merged head e9baeeec0: green. GitHub is 8/8 on e9baeeec0 and on the final head 5bede631e;
    • 45491525057 on 41fb24c3e, after merging main with Spec 1940: green;
    • the final head 7b2e06b8a adds only a merge of main with PR [Bugfix #1853] porch: save failed check output to a log, print its last lines #1964 (porch code, the porch skill's four copies, and the hash file, which regenerates identically) plus a thread-log line. No Windows run was dispatched for it (no platform code; architect). GitHub is 8/8 on it, and codev check pr 1958 reads CLEAR there (trial merge clean into main @ 88bc5e9).
    • after the owner's approval, main was merged twice more: the Cockpit PR [Spec 1963] VS Code alternative layout: Codev Cockpit #1971 (overlap only arch.md and lessons-learned.md, auto-merged) and PR Fix #1978: a workspace runs while it has an open terminal, not while it has a map slot #1980 (overlap only the hash file, which regenerates identically). Local set on 06462ce91: build, both type-checks, governance, doc and skill tests 131/131, commands/check 784/784, 1951's agent-farm tests 31/31. Main changed windows.yml, so one Windows run on the final head 275f01461: 45521351185, green (unit tests, CLI tests, targeted commands/check, install verification, both probes). GitHub 8/8 on 275f01461.
    • 45478428811 on cbd70ecd8 passed, and GitHub's 8 checks on cbd70ecd8 were green;
    • 45471312317 and 45465468867 were green;
    • 45462452355 failed 9 fixture-side tests (8.3 short names), fixed in f93aa60e1.
  • Under owner ruling main-38 ("ci-first"), the builder never ran the full suite locally. GitHub's 8/8 run stood in for porch's local tests check at each phase head. Every skip is listed at the end.

Spec

codev/specs/1951-read-only-pr-check-for-archite.md

Review

codev/reviews/1951-read-only-pr-check-for-archite.md

Commits no reviewer has seen (look at these specifically)

Porch force-advanced two phases at the three-iteration ceiling, so CMAP never reviewed their round-3 fixes:

  • Phase 2 (readonly_core). Confined to commands/check/ test helpers, plus a one-line guard in git-facts.ts.

    • aa7e34f58:
      • The stub git's ls-remote accepts only origin, then HEAD or refs/… names.
      • The stub refuses path and URL arguments to revision-taking subcommands, which closes an implicit --no-index diff of files outside the repository.
      • ls-files and status take no arguments, and for-each-ref takes refs/ patterns only.
      • A one-line liveTip branch-name guard.
    • c42251ec5: the ext:: refusal case no longer uses a /tmp path.
  • Phase 6 (check_worktree).

    • a1ccc442b: spawn's native-Windows link fallbacks count as scaffold. That is a hard link of the main checkout's file, or a copy whose bytes still equal it; a changed copy is data.
    • Phase 7's first commit, f93aa60e1, moved this rule into agent-farm/lib/builder-scaffold.ts. At the architect's request, the Phase 7 reviewers reviewed it, and both approved in iteration 2.
  • PR review, round 1. d5bc0b227 (the fixes) and 1a6eb69dd (review file, rebuttal) were made after the PR-phase consultation. Porch ran no second round. The architect had Codex review d5bc0b227: one finding (normalised state words, so OPENED → OPEN is not flagged), rejected by the architect because those are two spellings of one state, and one run reads one forge. 1a6eb69dd is documents only.

The review-phase commits 017f0baea and cbd70ecd8 were reviewed by the PR-phase consultation (Claude APPROVE; Codex's two issues are fixed in d5bc0b227).


Local tests check skipped once, under owner ruling main-32.

  • Phase 1 (forge_read_concepts), head bb2ad2710.

  • Porch's local tests check failed under machine load (tests: one run of the packages/codev unit suite takes an 18-core Mac from load 8 to 59, and its own spawn-heavy tests then time out #1956). The failing tests were unrelated to this change and each passed alone, and the builder's own full run passed.

  • The architect confirmed GitHub's run on this PR at bb2ad2710 was 8/8 green.

  • porch.checks.tests.skip was set in the worktree's own .codev/config.local.json for a single porch done and removed in the same command. It was never committed. The build check still ran and passed.

  • Phase 2 (readonly_core), head 9081d4367.

    • One porch done at load 9.5. Its tests check failed on four unrelated, spawn-heavy files: agy-auth-cache, windows-console-spawn-guard, pir-1233-session-launch-loop and bugfix-1267-launch-loop. Porch's output did not name them (porch done truncates failing check output; the failing test is never named #1853); vitest's results cache did.
    • Run alone in one invocation, all four passed.
    • The architect confirmed GitHub's run at 9081d4367 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.
  • Phase 3 (check_pr_mechanics), head 5bef2f503, under owner ruling main-38 ("ci-first": no local full suite until tests: one run of the packages/codev unit suite takes an 18-core Mac from load 8 to 59, and its own spawn-heavy tests then time out #1956 is fixed).

    • No local full-suite run and no plain porch done. Locally: the targeted tests (551/551 in 14 files), the build and the type-check.
    • The architect confirmed GitHub's run at 5bef2f503 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.
  • Phase 4 (check_pr_forge), head 410d5ec14, under the same ruling main-38.

    • No local full-suite run and no plain porch done. Locally: the targeted tests (644/644 in 17 files), the build, and the type-check on the source and on the check tests.

    • The architect confirmed GitHub's run at 410d5ec14 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.

    • Review iteration 1 fixes, head e1cece6f6: targeted tests 664/664, build. The architect confirmed GitHub's run at e1cece6f6 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.

  • Phase 5 (check_deploy), head 53f7e6522, under the same ruling main-38.

    • No local full-suite run and no plain porch done. Locally: the targeted tests (719/719 in 19 files), the build, and the type-check on the source and on the check tests.
    • The architect confirmed GitHub's run at 53f7e6522 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.
  • Phase 6 (check_worktree), head b6f7d4d74, under the same ruling main-38.

    • No local full-suite run and no plain porch done. Locally: the targeted tests (906/906 in 29 files), the build, and the type-check on the source and on the check tests.

    • The architect confirmed GitHub's run at b6f7d4d74 was 8/8 green. The skip was then applied once, in the same way, and the build check passed.

    • Review iteration 1 fixes, head dd21e15ce: targeted tests 910/910, build. The architect confirmed GitHub's run at dd21e15ce was 8/8 green. The skip was then applied once, in the same way, and the build check passed.

    • Iteration 2, head 95ae544b5: this commit is porch's status file only; the code is unchanged since dd21e15ce. The architect confirmed GitHub's run at 95ae544b5 was 8/8 green. The skip was applied once more, and the build check passed.

    • Review iteration 2 fixes, head a56bf9a37: targeted tests 925/925 (24 files), build. The architect confirmed GitHub's run at a56bf9a37 was 8/8 green. The skip was applied once for the rebuttal's porch done, then once more for iteration 3's porch done at 8a66ff91a (porch's status file only; the architect's standing word covers this). The build check passed both times.

    • Review iteration 3 fixes, head a1ccc442b: targeted tests 926/926 (24 files), build. The architect confirmed GitHub's run at a1ccc442b was 8/8 green. The skip was applied once for the rebuttal's porch done, and the build check passed. Porch then force-advanced to Phase 7.

  • Phase 7 (docs_guidance), head 827eed9d4, under the same ruling main-38. The architect confirmed it still stands; retiring it is part of open decision main-39.

    • No local full-suite run and no plain porch done. Locally: the targeted tests (977/977 in 32 files), the doc-integrity tests (158/158) and other doc-reading tests (147/147), the build, the type-check on the source and on the check tests, and the tmp-residue check.
    • GitHub was 8/8 green at f93aa60e1 and at 827eed9d4, and the Windows run at f93aa60e1 was green. The architect confirmed the run at 827eed9d4. The skip was then applied once, in the same way, and the build check passed (porch commit d92a07d70).
    • Review iteration 1 fix, head 0c02478dd: cleanup reads git status with -z. Locally: targeted tests 989/989 (33 files), both type-checks, build, tmp-residue. GitHub was 8/8 green at 0c02478dd, and Windows run 45471312317 was green. The architect confirmed both. The skip was applied once for the rebuttal's porch done, then once more for iteration 2's porch done at 32d7a57db (porch's status file only; the architect's standing word covers this). The build check passed both times.
  • Review phase, head cbd70ecd8, under the same ruling main-38.

    • No local full-suite run. Locally: the targeted tests (989/990 in 33 files). The one failure was this PR's own load-sensitive hang test, fixed in 017f0baea (77/77 after the fix). Also the governance doc tests and imports audit (153/153), both type-checks, the build and the tmp-residue check.
    • The architect confirmed GitHub's run at cbd70ecd8 was 8/8 green, and Windows run 45478428811 passed.
    • On the architect's word the skip was set once, in the same way, for porch done (porch commit d97668c21). The review phase's checks turned out to be pr_exists and the two review headings, with no tests check, so the skip changed nothing. config.local.json was restored, and cmp showed it identical.
  • Ci-first retired (owner ruling main-39, 2026-11-24). The rebuttal's porch done ran the ordinary way at load 17.8, after merging origin/main (e9baeeec0), with no skip. Its checks (pr_exists and the two review headings) passed, and porch requested the pr gate (30853b1fe).

… PR mechanics

- pr-view gains optional headRefOid, isDraft, mergeable, mergeStateStatus,
  mergeCommit, mergedAt, reviewDecision (github, gitlab, gitea)
- new read concepts commit-checks and workflow-runs: github implements them,
  gitlab and gitea disable them explicitly (no silent fall-through to gh)
- dispatcher: timeoutMs option and a timedOut flag on ForgeCommandError
- gitlab pr-view now captures before piping (#1645) and declares
  forge-executable: glab (#1455); it also maps body/baseRefName/headRefName
- forge.md documents the concepts and fields
…ab empty-output guard and body default, paginate legacy statuses
… settings, report core and git plumbing

- allow-list.ts: closed per-subcommand git grammar; diff/log/show forced to
  --no-ext-diff --no-textconv; ref-neutral fetch only; four read forge concepts
- runner.ts: the only subprocess path; argv spawn, GIT_TERMINAL_PROMPT=0,
  ls-remote/fetch and forge calls bounded, with its own deadline race
- validate.ts, roots.ts (roots from git), settings.ts (check.* with key+file on error)
- report.ts (schema 1, verdict, exit codes, check.skip, summarizeRuns), render.ts
- git-facts.ts: live tips, ensureCommits, ancestry, :(top,glob) pathspec filters
- test helpers: fixture repos with state snapshot, stub git/gh PATH recorders
- audited-imports test keeps child_process and the forge dispatcher in runner.ts
…check reference

- Architect role (both trees): run `codev check pr` before choosing review depth (mechanics;
  consult --type integration reviews content), again before a merge word with its verdict
  line in the PRFT Testing paragraph; new "Closing the loop": `codev check deploy` after
  merges, `codev check worktree` before afx cleanup. REMOVABLE means no data would be lost,
  not that the builder is finished.
- risk-triage Step 1 and the workflow reference (both trees) start from `codev check pr`.
  Fixed in place: `gh pr diff --stat` does not exist; Step 1 now names
  `gh pr view --json additions,deletions,changedFiles` and `gh pr diff --name-only`, and the
  worked examples use `git diff --stat origin/main...origin/<branch>`.
- codev.md (both trees): the three subcommands with samples pasted from real runs, statuses,
  exit codes, check ids, configuration (check.* and cleanup.keepIgnored, `:(glob)`
  pathspecs), forges, the only writes (object-store additions), the trust boundary (a
  project's own concept overrides, the user's merge drivers), and the JSON reports as
  shipped: nullable pr.baseTip and worktree.baseRef/baseTip, commits.unsafe,
  ignored.links/scaffold, what `regenerable` counts, spawn's entries as scaffold, links
  among keep-list files, checks.lastCodeCommit null, head.relation, forge.reviewDecision,
  linked-issue.references.
- overview.md rows (both trees); the codev skill in four copies (hashes regenerated); the
  forge skill gains commit-checks and workflow-runs; arch.md Core Components §9.
- Thread log: Phase 7.
…eads git status with -z

- cleanup's hasUncommittedChanges read `git status --porcelain` line by line, so git quoted a
  path holding a space, a quote or a non-ASCII letter, linkAt could not read it, and a
  spawn-made entry with such a name counted as dirty (codex; claude note 3). It now runs
  `git status --porcelain -z --untracked-files=all` through execFile (windowsHide), not the
  shared run(), which trims stdout and would drop the first entry's leading status space.
  A rename's source path is dropped, so a rename counts once.
- Tests: a hard link and an unchanged copy at paths git would quote are not counted (fails with
  the old parsing); pinned the safe direction: a lone ' M' first entry, a quoted untracked
  name and a staged rename are each counted once, and a failing git status is still
  "Unable to check status" (dirty).
- codev.md (both trees): an identical copy is scaffold whoever made it; nothing is lost while
  the main checkout holds the file (claude note 1).
- Rebuttal and thread log.
…y notice's real path; hang tests survive load

- cleanup's dirty notice calls execFile(cmd, args, options, cb), but three cleanup suites mocked
  the 3-argument form, so the options object was called as the callback and the notice always
  read "Unable to check status" (claude, Phase 7 iter2 note 2; architect order). The mocks now
  take both forms:
  - air-1950-cleanup-keep-ignored: git status answers from the test; a new case asserts the
    notice reads "1 uncommitted file(s)", not "Unable to check status".
  - air-1950-cleanup-keep-ignored-e2e: git status runs for real in the fixture repository; the
    case asserts the notice counts notes.md.
  - spec-1658-cleanup-worktree-removal: records 'ps' only for ps.
  Both new assertions fail with the old mocks put back (checked).
- check-deploy / check-pr-forge hang tests: the 1 s limit bounds every call of the run, so at
  load ~31 an earlier call timed out first (1 failure in a targeted run, passes alone). The
  limit is 5 s; the stub still sleeps 60 s.
… routed to the cold tier

- codev/reviews/1951-read-only-pr-check-for-archite.md: spec compliance, live runs (check pr 1958 at a
  four-commit porch tail, 1640, earlier phases), deviations per phase, commits no reviewer has seen,
  per-round consultation dispositions with the allow-list/stub tightening table, flaky tests.
- lessons-learned.md (cold): callback-mock arity; three-layer read-only proof; per-run timeouts under
  load; realpathSync.native on Windows; git status -z parsing; porch review-round order.
- pr.ts: one comment on checkCi's own check.skip test (claude, Phase 4 iter2 note 5).
- Thread log: review phase.
@waleedkadous
waleedkadous marked this pull request as ready for review November 24, 2026 20:13
… the PR as it is at the end; config validated before any git call but discovery

- check pr re-reads pr-view at the end and now compares the base branch, the state and the
  draft flag as well as the head (codex). A change needs attention, the line naming what
  changed and asking for a re-run: `state changed during check (OPEN → CLOSED)`, `… (OPEN →
  OPEN (draft))` even with `state` skipped, `base branch changed during check (main →
  release)` on the trial merge.
- forge: when the first read was UNKNOWN and the head moved, the re-read's answer says which
  head it is about, `(for the new head <sha>)` (claude note 1).
- The origin check runs after the configuration is validated, in all three commands, so the
  only subprocesses before validation are the two that find the main checkout, where the
  configuration lives: rev-parse --show-toplevel and worktree list --porcelain (codex; option
  (a), architect). The pr, deploy and worktree config-error tests record every spawn and
  assert exactly those two. The spec's "before any subprocess" wording is unchanged; the
  review records the difference for the owner.
- parseWorktreeList takes a path verbatim (a trailing space survives) and reads CRLF like LF.
  Not -z: that needs git 2.36, and the commands run on older git (claude note 3; architect).
- codev.md (both trees): check.attribution patterns are trusted and run without a time limit
  (claude note 2).
- Each new test fails with its change taken out (checked).
…ded for the owner

- Review file: the config-validation order under Deviations in plain words (what the spec says,
  what the code does, why; the approved spec and plan text unchanged, for the owner to accept at
  the pr gate); PR review round 1 under Consultation Feedback; d5bc0b2 under Commits No
  Reviewer Has Seen; the input-validation and no-race criteria qualified.
- Rebuttal 1951-review-iter1-rebuttals.md.
- lessons-learned.md (cold, Process): re-read spec criteria when a plan revision changes their
  premise; record the conflict, do not retitle the test.
- Thread log.
… run on the final head

- Review file: the architect-run Codex review of d5bc0b2 (one finding, rejected by the
  architect, with the reason); the full local run after ci-first's retirement (440 files,
  9,286 tests passed, 363 s, load 18.4 → 27.7).
- Thread log.
# Conflicts:
#	codev/resources/lessons-learned.md
…ll local run on the merged head

- Live runs: codev check pr 1958 found a lessons-learned.md conflict with main (Spec 1940)
  before the gate, the forge agreeing; merged main as 5d80279.
- Second full local run on 5d80279: 449 files, 9,885 tests passed, 342 s.
- Thread log.
@waleedkadous
waleedkadous merged commit 6cb29ec into main Nov 25, 2026
8 checks passed
waleedkadous added a commit that referenced this pull request Nov 25, 2026
waleedkadous added a commit that referenced this pull request Nov 25, 2026
waleedkadous added a commit that referenced this pull request Nov 25, 2026
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.

Read-only PR check for architects: merge readiness, deploy status, and whether a builder worktree can be removed

1 participant