Repository navigation
Description
Epic: graph-2026-10-fundamentals Tier: judgment Execution: sequant_run Blocked by: #1504
Problem
The fix-seam audit (59 merged fixes, 28 days) found the one seam tested through mocks is subprocess: 3 of 4 subprocess defects were tested by mocking child_process, and two logic fixes used hand-typed fixtures of gh's output shape (#1229, #1214) — the failure "don't mock types you don't own" names: the fixture drifts, the test stays green, the code is wrong. 31 test files mock child_process; 6 of them fake gh inside the mock. GitHubProvider already owns 27 gh call sites, but 4 remain outside it: batch-executor.ts (gh issue view --json title,labels at :328 and --json body,labels at :388), chain-preflight.ts (gh issue view --json body,state,title at :207), merge-check/report.ts (gh pr comment at :314). All four are expressible through the existing PlatformProvider interface (fetchIssue, postPRComment).
Design: consumers take an optional provider?: PlatformProvider defaulting to new GitHubProvider() (D-D: no module-level test setter). FakeGitHubProvider implements the interface by replaying JSON fixtures under src/lib/workflow/platforms/__fixtures__/gh/, each produced by scripts/capture-gh-fixtures.ts, which runs the real gh and stamps command, capturedAt, exitCode, stdout, stderr (D-G). A fixture with exitCode != 0 makes the fake throw the same error class GitHubProvider throws, so the gh-exit-status seam the audit flagged (#1319, #1320, #1464, #1268) is testable without child_process.
Acceptance Criteria
- AC-1: No
ghspawn outside the provider. Evidence:grep -rlzE 'spawnSync\(\s*"gh"' src --include='*.ts' --exclude='*.test.ts' | grep -v 'platforms/github.ts' | wc -l | tr -d ' '→0 - AC-2: Captured fixtures exist and carry provenance. Evidence:
n=$(ls src/lib/workflow/platforms/__fixtures__/gh/*.json | wc -l | tr -d ' '); for f in src/lib/workflow/platforms/__fixtures__/gh/*.json; do jq -e '.command and .capturedAt and (.exitCode != null)' "$f" > /dev/null || echo "bad $f"; done; echo "fixtures=$n"→fixtures=≥ 4and nobadline - AC-3: The fake implements the whole interface and surfaces non-zero exits as the provider's error class. Evidence:
npx vitest run src/lib/workflow/platforms/fake-github.test.ts→≥ 4 passed, 0 failed(new file: everyPlatformProvidermethod resolves from a fixture; anexitCode: 1fixture throws the same class asGitHubProvider; an unknown command throws a fixture-missing error naming the capture script) - AC-4: No test fakes
ghthroughchild_process. Evidence:grep -rlE 'vi\.mock\(\s*["'"'"'](node:)?child_process' src scripts __tests__ 2>/dev/null | xargs grep -l '"gh"' | wc -l | tr -d ' '→0 - AC-5: The capture script exists and runs real
gh. Evidence:test -f scripts/capture-gh-fixtures.ts && grep -c 'spawnSync' scripts/capture-gh-fixtures.ts→≥ 1 - AC-6: Existing behaviour holds, including the integration test against real
gh. Evidence:npx vitest run src/lib/workflow/platforms/ src/lib/workflow/chain-preflight.test.ts src/lib/merge-check/→0 failed(must run against the real dependency:github.integration.test.tsstays unmocked) - AC-7: The baseline moves down with the PR. Evidence:
jq '.ghCallFilesOutsideProvider' scripts/qa/health-baseline.json→0 - AC-2, AC-3 and AC-5 are classified as gate tests by
isGateTestEvidence; the PR body carries aSEQUANT_MUTATIONrecord for each (delete one fixture → the fake's test for that method fails; restore).
Prior fixes / producers
- Prior fixes on the
ghexit-status seam: fix(#1312): GitHubProvider.postComment ignores gh's exit status, so a failed QA verdict post is silent #1319, fix(#1315): PlatformProvider has no error contract — postPRComment is still unchecked and the ready gate's report-post catch is empty (#1312 follow-up) #1320, fix(#1396): phase agents no longer receive claude.ai connectors #1464, fix(#1257): doctor warns on a missing GitHub remote and uncommitted core skills; dry run errors on a missing issue #1268 (fix-seam-audit.md). Four prior fixes, so this is a class: AC-1 and AC-4 state the outcome for every producer. - Producers of
ghcalls:platforms/github.ts(27 sites) plus the 4 named above.wizard.ts:41is acommandExists("gh")probe, not a call, and stays.
May touch
src/lib/workflow/platforms/{github.ts,platform-provider.ts,fake-github.ts (new),fake-github.test.ts (new),__fixtures__/gh/ (new)}, scripts/capture-gh-fixtures.ts (new), src/lib/workflow/batch-executor.ts (the two helpers at :328/:388 and their callers' optional parameter only), src/lib/workflow/chain-preflight.ts, src/lib/merge-check/report.ts, the 6 test files that fake gh, scripts/qa/health-baseline.json (I-4), CHANGELOG entry.
Non-Goals
- A
gitwrapper or fake (git is tested against real repos in 80 files). - Removing
child_processmocks that fake git, codex, opencode or claude (they are not the audited seam). - Any
PlatformProvidermethod beyond what the four call sites need. - No edits under
plugin/,.claude/skills/,templates/skills/(I-1).
Done when
A gh failure in a test is a fixture, not a shifted mock queue, and grep finds no gh spawn outside the provider.
Activity
admarble commentedon Oct 20, 2026
Runner context, 2026-10-20, before launch (fundamentals W2; stop-at-PR; judgment tier, all phases on Opus). main = 2e041f0.
Changed since filing:
batch-executor.tsgainednoteSuppressedcalls (feat(run): a dropped error leaves a trace — noteSuppressed() counts into the run log, batch-executor's 25 silent catches converted #1504, 10fe972) and the verdict attribution (feat(qa): the verdict comment names its reviewer — separate session, driver and model, author's driver and model beside it — and the docs namephases.qa.agentas the independence knob #1521).runIssueWithLoggingis 1072 lines; don't grow it.@deprecatedline inbatch-executor.tsand will likely merge first, so mergeorigin/mainbefore opening the PR.gh issue viewthroughGitHubProvider.fetchIssueCommentBodiesSync(resolveSpecRecommendationdefaults to a real provider). The fake this issue builds is the structural fix for that class. Say in the PR body whetherrun-orchestrator.test.tsandskills-preflight.test.ts(slow cases, cause unconfirmed) are the same leak.Safety for the fixture capture (AC-2, AC-5):
ghcalls (issue view,pr view,apiGETs) againstsequant-io/sequant.issue comment,pr create,pr merge,label,api -X POST/PATCH/DELETE), not even to capture a fixture. Hand-write fixtures for write paths from the documented response shape and mark them"provenance": "hand-written".#1505 (empty catches, including
platforms/github.ts) is held until this merges.For every phase, and the qa phase by name: run the full suite at most once, in the foreground, under
timeout, after a WIP commit. Each MCP-dispatched phase has a 30-minute wall. Prefer the targetednpx vitest run <files>for the ACs.CHANGELOG: add
[Unreleased]lines under the existing### Added/### Changedheadings, notchangelog.d/fragments, and never add a second heading of the same name.Lint: #1503 made
no-unused-vars,no-empty-object-typeandprefer-consterrors, and knip counts unused exports. Don't export what nothing imports.Health baseline: regenerate
scripts/qa/health-baseline.json(npx tsx scripts/qa/health-report.ts --write-baseline) only to record a metric that went down. Ifnpm run lint:healthreports a rise, restructure so it holds. Otherwise leave the baseline alone and name the rise in the PR body. Owner ruling: aproseGate.linesrise caused by tests in files that mentionSKILL.mdonly as a path may be absorbed, and must be said so.Freeze: nothing under
plugin/,.claude/skills/ortemplates/skills/.admarble commentedon Oct 20, 2026
Complexity: Complex (7 ACs, 8 directories)
AC Quality Check
lintAcceptanceCriteria: 7/7 pass. Every AC declaresEvidence:. I ran each command-shaped Evidence againstmain@ 2e041f0:3(batch-executor, chain-preflight, merge-check/report)__fixtures__/gh/6(system, state-utils, github, run, doctor, run-resume)3system.test.tshas"gh"only as thecommandExists("gh")/getInstallHint("gh")argument. That is thewhichprobe the issue exempts atwizard.ts:41, not a gh fake.get-issue-info.test.ts,dependency-markers.test.tsandgithub-gh-failure.test.tsfake gh output throughvi.mock("child_process")but never write the literal"gh", so the grep misses them.The first two of those test the consumers this issue rewires, and the third is the core of "a gh failure is a fixture". All three are converted below. The literal AC still holds.
health-report.ts:249scansscripts/too (/^(src|bin|scripts)\//). Ascripts/capture-gh-fixtures.tsthat callsspawnSync("gh"…)(which AC-5 requires) makesghCallFilesOutsideProvider= 1, not 0 (AC-7). See Open Question 1.Scope Assessment
Non-Goals: present (no git fake; non-gh child_process mocks stay; no extra PlatformProvider methods; no plugin/skills edits).
Verdict:⚠️ SCOPE_WARNING. One coherent change, but it converts a lot of tests. The quality loop is on.
Acceptance Criteria
AC-1: No
ghspawn outside the providerVerification: Integration Test (Evidence grep)
Scenario: Given the 4 sites → When rewired to provider methods → Then the grep prints
0Assumptions:
parseDependenciesstays sync. Its caller chain issortByDependencies→RunOrchestrator.resolveConfig(sync, static) →run.ts:104, andrun.tsis outside "May touch". So that site needs a sync provider method (Open Question 2).AC-2: Fixtures exist with provenance
Verification: Integration Test
Scenario: Given the capture script has run → Then ≥ 4 JSON files exist, each with
command,capturedAt,exitCode,stdout,stderrandprovenance("captured"|"hand-written")Assumptions: Write paths (
issue comment,issue edit --add/remove-label,pr create,pr comment) are hand-written per the runner comment and carry"provenance": "hand-written". Gate test: needs aSEQUANT_MUTATIONrecord.AC-3: Fake implements the whole interface; non-zero exit → provider's error class
Verification: Unit Test (⚠️ There is no provider error class today.
fake-github.test.ts)Scenario: Each of the 9
PlatformProvidermethods resolves from a fixture. AnexitCode: 1fixture rejects with theGitHubProvidererror class. An unknown argv throwsGhFixtureMissingError, whose message namesscripts/capture-gh-fixtures.ts.Assumptions:
runGhOrThrow(github.ts:111) throws a plainError, andfetchIssue(github.ts:987) throwsFailed to fetch issue Nwith stderr dropped. So this AC requires introducingGhCommandError extends Error { args, exitCode, signal, stderr }. Gate test: needs a mutation record.AC-4: No test fakes
ghthroughchild_processVerification: Integration Test (Evidence grep) + review of the 3 grep-invisible files
Scenario: The gh-faking parts of the 6 grep hits and the 3 grep-invisible files use
FakeGitHubProvider→ grep0AC-5: Capture script exists and runs real
ghVerification: Integration Test. Gate test, needs a mutation record.
Assumptions: Read-only calls only, against
sequant-io/sequant. The script refuses any argv whose verb is in a write denylist (comment,create,merge,edit,close,label,api -X/--methodother than GET), so a write cannot be captured by accident.AC-6: Existing behaviour holds;
github.integration.test.tsstays unmockedVerification: Integration Test
AC-7:
ghCallFilesOutsideProvider→ 0Verification: Integration Test. Regenerate the baseline (the metric goes down; that is allowed).
Implementation Plan
Phase 1: One gh seam inside GitHubProvider (github.ts)
type GhRunner = (args: string[], opts?: {input?: string; timeout?: number}) => GhRunResult, whereGhRunResultis{status, stdout, stderr, signal, error}. The default implementation is the onlyspawnSync("gh", …)in the file. Route all ~27spawnSync("gh")sites andexecSync("gh auth status")(:208) throughthis.run. The constructor takes{ run?: GhRunner }(constructor injection, not a module setter, which satisfies D-D).export class GhCommandError.runGhOrThrowthrows it.fetchIssuegoes through it too, so stderr survives. Without that,getIssueInfoloses fix(doctor/run):doctorandrun --dry-runreport success when nothing would work #1257notFoundand the fix(worktree): an existing branch for issue N is reused whatever the title — a gh blip or a retitle cuts feature/N-issue-n from main and QA reviews main #1487 reason when migrated. Sibling scan: the otherif (result.status !== 0) return null/[]sync helpers keep their tolerant contract. Do not widen to them (chore(lib): convert the remaining ~94 empty catches to noteSuppressed, forbid empty catch bodies by lint, show the count in sequant logs #1505 owns that file's catches next).fetchIssueSync(id): Issue(a GitHubProvider helper, not added toPlatformProvider).fetchIssuebecomesasyncaround it.Phase 2: Fixtures + fake (platforms/)
gh-fixtures.ts: fixture type, loader for__fixtures__/gh/*.json,fixtureRunner(fixtures)(exact-argv match; a"<*>"token matches any value, needed for--body), andGhFixtureMissingError. This module does not importgithub.ts, so tests canvi.mock("…/github.js")without a cycle.fake-github.ts:class FakeGitHubProvider extends GitHubProvider, which callssuper({ run: fixtureRunner([...defaults, ...extra]) }). Because it is the real class with a replay runner, every interface method and every sync helper uses the production parsing and throws the production error. That is what "same error class" means here.scripts/capture-gh-fixtures.ts: a list of read-only argv. It runs realghand writes{command, args, capturedAt, exitCode, stdout, stderr, provenance:"captured"}. Capture at least:issue view <n> --json number,title,body,labels,state;issue view <n> --json comments --jq …;pr view <n> --json state,mergedAt; one not-found (issue view 999999, exitCode 1); andauth status(exit code only, stdout/stderr scrubbed). Then hand-write the 5 write-path fixtures. Security: fixtures ship in a public repo, so capture only publicsequant-io/sequantdata and scrub token/host lines fromauth status.fake-github.test.ts: 9 interface methods + exitCode-1 →GhCommandError+ missing →GhFixtureMissingError.Phase 3: Rewire the 4 consumers (
provider?defaulting tonew GitHubProvider())getIssueInfo(n, provider?: PlatformProvider)usesfetchIssue. Not-found =err instanceof GhCommandError && ISSUE_NOT_FOUND_RE.test(err.stderr).parseDependencies(n, provider?: GitHubProvider)usesfetchIssueSync.sortByDependenciespasses it through as optional. Do not growrunIssueWithLogging.chain-preflight.ts:fetchPreflightIssue(n, provider)becomes async, andrunChainPreflight(order, provider?)awaits it. MapIssue.statelowercase → the existingstatestring comparisons (checkcomputePreflightWarningsfor"CLOSED"vs"closed").merge-check/report.ts:postReportToGitHub(report, provider?)becomes async overpostPRComment.index.ts:329awaits it. Keep the never-empty reason (fix(merge-check): combined-branch-test runs npm test/build without reinstalling deps after a lockfile change → false BLOCKED #803): use the error message, falling back toexit N.Phase 4: Convert tests (only the gh-faking parts)
github.test.ts,github-gh-failure.test.ts: constructFakeGitHubProvider/new GitHubProvider({run}). Failure cases become fixtures. Timeout and ENOENT are hand-written fixtures withsignal/error.get-issue-info.test.ts,dependency-markers.test.ts,merge-checkreport tests: pass a fake.run.test.ts,doctor.test.ts,state-utils.test.ts,run-resume.test.ts: their sources constructGitHubProviderinternally and are outside "May touch". Usevi.mock("…/platforms/github.js", async (orig) => ({...await orig(), GitHubProvider: <subclass of orig's class with fixtureRunner>})). That mocks a type we own, which is what the issue's principle allows. Remove thecmd === "gh"branches. Their child_process mocks for git and other tools stay (Non-Goal).system.test.ts: move thegetInstallHintcases (a pure table lookup) to a test without the child_process mock. ThecommandExistscases testwhichgenerically and use a non-gh name. Say in the PR body that this was a grep false positive, not a gh fake.Phase 5: Close-out
### Changedline, ADR, and a merge oforigin/main(PR chore(#1510): every @deprecated names its removal version — lint:deprecations in CI, CONTRIBUTING rule #1568 touchesbatch-executor.ts,health-baseline.jsonandCHANGELOG.md, so expect conflicts there). PR body: the 3 mutation records and the test(workflow): the #533 label-shortcut tests take ~850 ms with every phase mocked — one hit 5785 ms on CI and turned main red at da9c4fd49 #1560 leak answer forrun-orchestrator.test.ts/skills-preflight.test.ts.Design Review
platforms/github.tsowns every gh spawn. The fake lives beside it. Consumers only receive a provider.FakeGitHubProvider implements PlatformProvider(the issue's literal wording). It would cover only the 9 interface methods, but the 6 test files exercise sync helpers (fetchIssueCommentBodiesSync,listClosedIssuesSync,getPRMergeStatusSync,createPRCliSync…). It would also re-implement parsing, which brings back the hand-typed-shape drift this issue exists to remove. ADR required indocs/adr/(next NNNN).doctorandrun --dry-runreport success when nothing would work #1257/fix(worktree): an existing branch for issue N is reused whatever the title — a gh blip or a retitle cuts feature/N-issue-n from main and QA reviews main #1487 on the same lines. That is a class, and this plan fixes the class: one spawn site, one error type, with failures as fixtures. Not a divergence.sortByDependenciesasync?" Because it ripples into the syncresolveConfigandrun.ts. "Isn'tvi.mockof github.js the mock queue again?" No. It substitutes our own class, and the gh shape still comes from captured fixtures.GitHubProvider's default runner andcapture-gh-fixtures.ts. That is 2 producers, by design: the script records exactly what the runner sees. Parity: the script calls the runner with the same spawn options, or the same options are exported as a constant (the exec phase picks one and records it).fixtureRunneronly.GhCommandErrorconsumers:getIssueInfo,postReportToGitHub,postQaVerdictComment(already catchesError, unaffected).Feature Quality Planning
Standard checks pass. Notable:
auth status, and enforce the write denylist inside the script.doctorandrun --dry-runreport success when nothing would work #1257 not-found, fix(worktree): an existing branch for issue N is reused whatever the title — a gh blip or a retitle cuts feature/N-issue-n from main and QA reviews main #1487 reason and fix(merge-check): combined-branch-test runs npm test/build without reinstalling deps after a lockfile change → false BLOCKED #803 never-empty reason must survive the migration. Their existing tests are the guard.getIssueInfo,parseDependenciesand preflight had no timeout. Through the provider they get 15 s. This is an improvement. Note it in the CHANGELOG.GhRunner/GhRunResultonly if a test imports them.Derived ACs
getIssueInfowith a not-found fixture →notFound: true; with a 502 fixture →errorcontains gh's stderr (get-issue-info.test.ts)Open Questions
health-report.ts(aGH_CAPTURE_SCRIPTconstant next toGH_PROVIDER), so both ACs hold literally. Aconst GH = "gh"dodge would game the regex and should not be used. Impact if wrong: AC-7 reads 1, or the owner rewrites AC-5's evidence.parseDependenciestakes aGitHubProvider, not aPlatformProvider, because it needsfetchIssueSync. Recommendation: accept that. The alternative is asyncresolveConfig, which editsrun.ts. Impact: one consumer's parameter type differs from the issue's design sentence.deriveFixture(captured, mutateJson)helper that starts from a captured fixture and recordsderivedFrom, so the shape stays real. Purely invented stdout is not allowed.system.test.tsis a grep false positive (see AC-4). Recommendation: the split described in step 14, disclosed in the PR body.Recommended Workflow
Phases: exec → qa
Quality Loop: enabled
Reasoning: A complex refactor with SCOPE_WARNING across 8 directories. The new test file is the AC-3 deliverable, so testgen stubs add nothing. No UI.
Label Review
Current: graph-2026-10-fundamentals
Recommended: +
refactor,plannedReason: The title is a refactor, and it is a class fix across the provider seam.
admarble commentedon Oct 20, 2026
Runner note, 2026-10-20: the first run was killed by the MCP server's 30-minute no-progress watchdog during exec. Its work is committed on the branch through ea680c9 (provider runner seam, fixtures, fake, consumers rewired, ADR-0019, the capture-script probe and the failure fixtures), and the tree is clean.
For the re-run of exec:
The suite rule from the context comment still applies: run it once, in the foreground, under
timeout.admarble commentedon Oct 20, 2026
QA Verdict: AC_NOT_MET
AC coverage: 7/7 met
Gaps:
admarble commentedon Oct 21, 2026
Security Review: one gh provider, fake GitHub, captured fixtures (#1506)
PRs: #1570 (closed, superseded) → #1576
Domains: Data protection, Infrastructure (secrets)
Risk level: Medium, now remediated
Files reviewed: 35 fixtures,
scripts/capture-gh-fixtures.ts,platforms/github.ts,fake-github.ts, main's tree, and the repo's issue comments and PR bodiesThreat model
ghoutput, written verbatim into committed fixtures in a public repo; a capture script that runsghwith the maintainer's credentials; a runner seam that selects real or replayedgh.Findings
Medium (remediated)
__fixtures__/gh/pr-view-by-branch.jsonon refactor(#1506): every gh call goes through PlatformProvider; FakeGitHubProvider replays captured gh output so no test fakes gh through child_process #1570's branch).gh pr viewreturned a PR body ending in an attribution footer that linked the session, and the capture saved it verbatim. Gitleaks (claude-session-url) failed the commit.capture()now passes stdout and stderr throughredact(). It covers session links,cse_IDs, GitHub and Anthropic tokens, home paths and email addresses, using placeholders that can't match the Gitleaks rules. The fixture was re-captured.mainstill carry links; protectedmainis not rewritten.Low (remediated)
scripts/capture-gh-fixtures.ts).-XPOST,-fkey=v,-Fkey=v) and writing verbs such asrun,rerun,cancel,setandfork.--version, andapicalls with no method or body flag;api graphqlis refused.CAPTURESlist runs.Checked and passed
auth statusoutput is scrubbed.mainholds no real session link in tracked files.Checklist status
The manual Data Protection item is whether a session link is viewable without a login. A no-cookie request was challenged by Cloudflare, so it is unconfirmed.
Verdict
WARNINGS. Both findings are fixed in #1576, and both fixes are mutation-verified. The residual exposure is old commits on GitHub, which only GitHub support can purge.
🤖 Generated with Claude Code