Skip to content

test(drivers): conformance suite every agent driver must pass — commit in sandbox, network, typed error mapping, env injection, structured outcome #1096

Closed

Description

@admarble

Blocked by: — Tier: judgment Doc: guard plan 2026-09-18 (16-bug classification; #497 epic)

Why

The Codex driver shipped 2026-09-15/16 and its first real run found three gaps in a row: the sandbox excluded .git so no phase could commit (#1076), network was off so no phase could reach gh (#1079), and a usage-limit failure was typed unknown so --auto-wait and the billing skip never engaged (#1087). None was a Codex-specific surprise. They are the contract the Claude driver already satisfies implicitly, and nothing states that contract as tests a new driver has to pass before it ships.

Change

src/lib/workflow/drivers/__tests__/driver-conformance.test.ts, a describe.each over every registered driver, with driver-specific probes behind one adapter. Zero-cost where the vendor allows it (codex sandbox with the driver's exact config; the Claude driver's fixture transcripts), model calls only where unavoidable and skipped in CI when the key is absent.

Contract:

  1. Commit: inside the driver's default sandbox, in a git worktree, git add and git commit succeed.
  2. Network: gh api rate_limit succeeds from inside the sandbox when the run needs the platform.
  3. Errors: a quota-exhausted message maps to BillingError with the reset time in metadata; a transient throttle maps to RateLimitError (retryable); anything else maps to SequantError with the driver's code. Fixture text per driver.
  4. Env: the phase sees SEQUANT_ORCHESTRATOR, SEQUANT_WORKTREE, SEQUANT_PHASE, SEQUANT_ISSUE (the same set for every driver).
  5. Outcome: the driver returns the structured outcome shape (verdict, structuredError, tokensUsed) with tokensUsed > 0 on a completed turn.
  6. Skill load: the driver loads the project-scope /exec skill (the spike(opencode): does opencode run --command <phase> load the sequant skill? (#862 P0 precondition, resolves OQ-8/OQ-9) #992 gate generalized).

Adding a driver without a conformance adapter fails the suite.

Release-graph plan — guard-2026-09 (2026-09-20)

Graph: guard-2026-09 Tier: judgment Wave: 2
May touch: src/lib/workflow/drivers/__tests__/driver-conformance.test.ts, src/lib/workflow/drivers/__fixtures__/ (per-driver error texts incl. the verbatim #1087 run-2 message), src/lib/workflow/drivers/index.ts (adapter registration only; the DRIVERS map is the enumeration source), a docs/ driver-authoring page, CHANGELOG.md; not codex.ts (#1087 owns the mapping in wave 3)

The npm run build && npm test AC is verified by the runner from a clean shell after the PR opens (PLAN I-1); the agent runs only the test files its ACs name. Mutation markers use failedTest starting with the test file path (I-4). AC-3's BillingError case is expected to fail until #1087 lands: mark it it.fails (or todo with the issue number) so the suite stays green, and say so in the PR body — #1087 flips it. Sandbox probes run the real codex sandbox / real gh (I-6); skip with a named reason when the binary or key is absent. Wave 2 for suite hygiene after #1086; no hard edge.

Acceptance criteria

  • AC-1: the suite enumerates drivers from the registry, not a hand-written list; an unregistered adapter or a registered driver without an adapter fails — Verify: npx vitest run src/lib/workflow/drivers/__tests__/driver-conformance.test.ts → green. Mutation-verified per CLAUDE.md §Testing: register a stub driver with no adapter → the suite fails naming it; restore.
  • AC-2: the Codex commit probe runs at $0 under codex sandbox with sandbox_mode="workspace-write" and the driver's writable roots, and passes — Verify: -t "codex commit" → green (skipped with a named reason when codex is not installed).
  • AC-3: the Codex error-mapping cases pass for the three fixture messages, including the bug(codex): usage-limit turn failures classified 'unknown' — quality loop re-runs into the same quota, --auto-wait can't engage #1087 usage-limit text — Verify: -t "codex errors" → green. Mutation-verified: remove the usage-limit branch → the BillingError case fails; restore.
  • AC-4: the Claude driver passes the same six contract items — Verify: -t "claude-code" → green.
  • AC-5: the opencode driver passes or each skipped item names the tracking issue in the skip reason — Verify: -t "opencode" → green with skips listed.
  • AC-6: docs/ driver-authoring page lists the six contract items and points at the suite — Verify: grep -c "driver-conformance" docs/**/*.md ≥ 1.
  • AC-7: npm run build && npm test green.

Not in scope

Fixing #1087 itself; this issue's AC-3 lands the test, #1087 lands the mapping. Order them accordingly when planning.

Activity

  1. added
    enhancement
    multi-agent
    on Sep 19, 2026
  2. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    Runner context — guard-2026-09 launch, 2026-09-20. Base: origin/main at da9ed6e8 (2.16.0 plus the plan docs). These rules override the exec skill's defaults for this run:

    • No full npm test in the worktree. Run only the test files this issue's ACs name. The runner runs the full suite once per PR from a clean shell. Under sequant run the suite is not hermetic against SEQUANT_* (bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086), so a full run shows red files you did not cause.
    • A named test file red before your change: re-run it as env -u SEQUANT_ORCHESTRATOR -u SEQUANT_WORKTREE -u SEQUANT_PHASE -u SEQUANT_ISSUE -u SEQUANT_RELAY -u SEQUANT_RELAY_FRAME npx vitest run <file>. If it is still red, the PR body names the issue number and the base-vs-head result for that test.
    • Mutation marker (gate-test ACs): <!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"<what you deleted>","failedTest":"<test file path> > <describe> > <case>"} --> in the PR body. failedTest MUST start with the test file path, or the qa classifier reports it Failed. Commit before mutating.
    • 30-minute no-progress wall per phase. Commit a WIP checkpoint before any long command; every command foreground, with timeout.
    • Commits: single-line git commit -m "...", no Co-Authored-By. Never rebase or force-push after pushing. One AC per line in the PR body, ids AC-N only.
    • Stop at the PR. Do not merge.

    Issue-specific: Judgment tier. codex 0.154.0 is on PATH (~/.local/state/fnm_multishells/.../bin/codex), so AC-2 runs the real sandbox probe; if the sandbox is unavailable, skip with a named reason, never a mock. AC-3's BillingError case is expected to fail until #1087 lands: mark it it.fails with the issue number in the name. Registry-driven enumeration only; no hand-written driver list.

  3. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (7 ACs, 3 directories)

    AC Quality Check

    lintAcceptanceCriteria: 7/7 passed, 0 flagged. Every AC carries a runnable — Verify: command.

    One parser note, not a defect in the ACs: all 7 resolve to verificationMethod: "manual" because the ACs use prose — Verify: <cmd> rather than the house Evidence: clause, so AC.evidence is unset and the declared-evidence channel (#938) is dark. Harmless here — the deliverable is the test file, so testgen is skipped regardless — but it means /qa's gate-test classifier will read these as manual unless the mutation markers carry the weight. The two mutation-verified ACs (AC-1, AC-3) must ship SEQUANT_MUTATION markers with failedTest starting with the test file path, or §6i floors the verdict.


    Scope Assessment

    Non-Goals: Present in the issue as ## Not in scope — but parseNonGoals only matches Non-Goals / Out of Scope, so the assessor reports "not found". The boundary is real and stated; the warning is a heading-vocabulary miss in src/lib/scope/analyzer.ts:293. Not worth fixing inside this issue.

    Metric Value Status
    Feature count 3 ❌
    AC items 7 ⚠️
    Directory spread 4 ⚠️

    Verdict: ❌ SCOPE_SPLIT_RECOMMENDED — override to proceed as one issue. The red comes from keyword clustering that mislabels AC-6 as "auth" and AC-1/AC-7 as "ui"; the actual deliverable is one test file, one fixtures dir, one additive export, one docs page. Splitting a conformance contract into per-driver issues would defeat its purpose — the point is one describe.each no driver can dodge. The red verdict does auto-enable the quality loop, which is kept.


    Acceptance Criteria

    AC-1: Suite enumerates drivers from the registry, not a hand-written list

    Verification: Unit Test — npx vitest run src/lib/workflow/drivers/__tests__/driver-conformance.test.ts
    Scenario: Given DRIVERS holds claude-code, aider, opencode, codex → When the suite builds its describe.each from the registry → Then each name is matched to a conformance adapter, and a name with no adapter (or an adapter with no registered name) fails naming it.
    Assumptions: ⚠️ DRIVERS is module-private today (src/lib/workflow/drivers/index.ts:26) — nothing exports it or its keys. Registry-driven enumeration needs one additive export (listDriverNames()). Reading Object.keys out of getDriver("nope")'s error string is possible and rejected: it couples the suite to a message format.
    Mutation: register a stub driver in DRIVERS with no adapter → confirm the "every registered driver has an adapter" case fails naming stub → restore. Manual edit, per CLAUDE.md §Testing — no in-test registry mutation needed.

    AC-2: Codex commit probe runs at $0 under codex sandbox and passes

    Verification: Integration Test — -t "codex commit"
    Scenario: Given a real temp repo + git worktree → When codex sandbox runs git add + git commit with the driver's own sandbox_workspace_write.writable_roots → Then both succeed and git log shows the commit.
    Assumptions: Verified live during planning on codex-cli 0.154.0: without the writable root, git add fails with the exact #1076 text (Unable to create '…/.git/index.lock': Operation not permitted); with it, add + commit both succeed. So the probe is discriminating, not a tautology. Two cautions: (a) assert on repo state (git log), never on an exit code read through a pipe — a pipe eats it; (b) darwin uses seatbelt, Linux CI uses landlock — skip with a named reason when codex sandbox is unavailable, never a mock.

    AC-3: Codex error-mapping cases pass for three fixture messages

    Verification: Unit Test — -t "codex errors"
    Scenario: Given the verbatim #1087 usage-limit text, a transient-throttle text, and an unrecognized failure → When the driver classifies each → Then BillingError (reset time in metadata), RateLimitError (retryable), SequantError with the driver's code.
    Assumptions: codex.ts maps everything to SequantError/SubprocessError today — no BillingError/RateLimitError branch exists. Per the issue's scope line, codex.ts is not touched here. The BillingError case ships as it.fails("… until #1087 lands") so the suite stays green; #1087 flips it.
    Mutation: remove the usage-limit branch → the BillingError case fails → restore. ⚠️ An it.fails case cannot be mutation-verified in the usual direction — record this honestly in the PR body rather than fabricating a marker.

    AC-4: Claude driver passes the same six contract items

    Verification: Unit Test — -t "claude-code" (SDK mocked via the existing vi.mock("@anthropic-ai/claude-agent-sdk") pattern in claude-code.test.ts)
    Scenario: Given fixture message streams → When the driver runs each contract item → Then commit (no sandbox: direct git in a temp worktree), env forwarding, typed errors, outcome shape and skill resolution all pass.
    Assumptions: ⚠️ AgentPhaseResult has no verdict and no tokensUsed field. verdict is parsed later in phase-executor.ts:1036; token totals live in modelUsage (ModelUsageEntry). Item 5 must therefore assert the shape the driver boundary actually owns — { success, output, structuredError?, modelUsage } — with tokensUsed derived as inputTokens + outputTokens by a helper, matching token-utils.ts:181. Do not add a tokensUsed field to the interface to satisfy the AC's wording.

    AC-5: opencode driver passes, or each skipped item names its tracking issue

    Verification: Unit Test — -t "opencode", green with skips listed
    Scenario: Given the recorded __fixtures__/opencode-run-qa.ndjson → When the six items run → Then each either passes or skips with a reason naming an issue.
    Assumptions: ⚠️ opencode accumulates costUsd only and never sets modelUsage (opencode.ts:161,243) — item 5's tokensUsed > 0 cannot pass, and no tracking issue exists for it (searched: #862/#992/#996/#997/#1075 all miss it). One must be filed before this AC can be satisfied as written. Skill-load (item 6) is already covered by skillLoaded and passes.

    AC-6: docs/ driver-authoring page lists the six contract items and points at the suite

    Verification: Manual Test (grep) — grep -c "driver-conformance" docs/**/*.md ≥ 1
    Scenario: Given the new page → When the grep runs → Then at least one file reports a non-zero count.
    Assumptions: Place the page at docs/guides/writing-an-agent-driver.md — a second-level path, so the literal AC command matches under both zsh (recursive **) and bash (docs/*/*.md); a top-level docs/*.md would fail the literal command in bash. Do not create a new docs/ subdirectory (the landing site publishes new subdirs automatically). Do not edit docs/features/codex-agent-backend.md — the in-flight docs/2.16-release-notes branch already modifies it. Note grep -c over multiple files prints file:count lines; record grep -rl "driver-conformance" docs/ | wc -l alongside it as the unambiguous form.

    AC-7: npm run build && npm test green

    Verification: Integration Test — run by the runner from a clean shell after the PR opens (PLAN I-1).
    Assumptions: The agent runs only the test files its ACs name. Under sequant run the suite is not hermetic against SEQUANT_* (#1086), so an in-worktree full run shows red files the change did not cause.


    Implementation Plan

    Phase 1: Registry enumeration + adapter shape

    1. src/lib/workflow/drivers/index.ts — add export function listDriverNames(): string[] { return Object.keys(DRIVERS); }. Additive only; DRIVERS stays private and stays the single enumeration source.
    2. __tests__/driver-conformance.test.ts — define the adapter interface and an ADAPTERS record keyed by driver name. Two guard cases run before describe.each: every registry name has an adapter; every adapter name is in the registry. This pair is what AC-1's mutation trips.
    3. Skip discipline, machine-checked. Every skip reason must match structural: <why> (the driver has no such concept — aider has no sandbox, no skill resolution) or gap: #NNNN <what> (the driver should support it and doesn't). A dedicated case asserts every recorded skip reason matches one of the two forms — this is what makes AC-5's "names the tracking issue" enforceable instead of a convention.

    Phase 2: Contract items behind the adapter

    1. Items 1–2 (commit, network): adapter exposes sandbox?.wrap(cmd, cwd). codex wraps with real codex sandbox + the driver's own buildCodexArgs overrides; the other three declare sandbox: null → structural: skip. Network item runs gh api rate_limit (no quota cost); skip with a named reason when gh is absent or unauthenticated.
    2. Item 3 (errors): per-driver fixture texts in __fixtures__/ — codex gets the verbatim bug(codex): usage-limit turn failures classified 'unknown' — quality loop re-runs into the same quota, --auto-wait can't engage #1087 run-2 usage-limit message; claude-code reuses the BillingError/RateLimitError/ApiError paths already exercised in claude-code.test.ts.
    3. Item 4 (env): given a config carrying all four SEQUANT_* vars, assert each driver forwards them to its child env. Sites: claude-code.ts:141, opencode.ts:553, codex.ts:560, aider.ts:57. Note opencode additively redirects XDG_CONFIG_HOME — assert a superset, not byte equality.
    4. Item 5 (outcome): assert { success, output, structuredError?, modelUsage } and a derived tokensUsed > 0. opencode and aider skip as gap: #NNNN.
    5. Item 6 (skill load): resolvesSkills drivers only. opencode asserts skillLoaded from its NDJSON fixture; codex from __fixtures__/codex-exec-skill-hook.jsonl; aider structural: skip.

    Phase 3: Docs + timing

    1. docs/guides/writing-an-agent-driver.md — the six items, the adapter contract, the two skip forms, and "adding a driver without an adapter fails the suite". Add a CHANGELOG.md entry.
    2. ⚠️ Per-test timeouts. The AC-named path has no .integration. segment, so the file lands in the unit vitest project with a 5 s timeout (fix(test): tsx-spawning integration tests blow vitest's 5s default — phase-registry should use the prebuilt dist like its five siblings #842). The real codex sandbox and gh probes will exceed that under full-suite load. Pass an explicit timeout as it's third argument on every subprocess case — vitest.config.ts is outside this issue's "may touch" set, so don't move the file into the integration project.

    Design Review

    1. Where does this logic belong? In the test tree, next to the drivers. The only source change is a one-line additive export in index.ts — the contract is expressed as tests, not as a runtime base class, because a base class a driver can override proves nothing.
    2. Simplest correct approach? One describe.each over listDriverNames(), one adapter record, per-item probes that either run or skip with a typed reason. Rejected: a ConformanceTestSuite abstract class per driver (four files to keep in sync); rejected: a lint rule asserting adapter presence (a test already fails louder).
    3. What existing pattern does this follow? codex.sandbox.integration.test.ts (real git repos, real worktrees, no mocks for the thing under test) and claude-code.test.ts (SDK mocked at the module edge, fixture streams driven through the real driver loop).
    4. What would a senior reviewer challenge? "Aider has no ACs — is it in or out?" It is in, unavoidably: AC-1 enumerates from the registry and aider is registered. Its adapter is mostly structural: skips (no sandbox, no skill resolution, no structuredError, no modelUsage), which is the honest answer and exactly what the skip-form check is for. Second challenge: "is the codex sandbox probe measuring anything?" — answered by the live planning probe recorded under AC-2, which fails without the writable root and passes with it.

    Feature Quality Planning

    • Two gaps have no tracking issue and AC-5 requires one. opencode never populates modelUsage (only costUsd); aider populates neither modelUsage nor structuredError. Nothing open covers either. One follow-up issue — "drivers: opencode and aider report no token usage and no typed errors, so conformance items 3 and 5 skip" — can back both skip reasons. Recommend filing it as step 0 of exec so the skip strings can name a real number.
    • it.fails is invisible to a green suite. AC-3's BillingError case passes the run by failing. Name the issue in the test title (#1087) so a reader of the output sees why, and state it in the PR body — a future reader who deletes it will not notice.
    • CI: codex and gh will both be absent or unauthenticated in some environments. Every skip there is structural:-adjacent but environmental — use a third form (unavailable: <binary>) rather than stretching structural:, so a missing binary is never mistaken for a driver that legitimately lacks the capability.

    Derived ACs

    Source Derived AC Priority
    Skip discipline A case asserts every skip reason matches structural: / gap: #NNNN / unavailable: High
    Registry completeness aider has an adapter; its skips are typed, not absent High
    Timeouts Every subprocess case passes an explicit per-test timeout Medium

    Conflict Risk Analysis

    No file overlap. All feature worktrees (#1053, #1070, #1086, #1095, #1104, #1106) sit at base da9ed6e8 with no diff. docs/2.16-release-notes touches docs/features/codex-agent-backend.md and src/lib/settings.ts — avoided by placing the new page in docs/guides/.

    Dependencies: #1087 owns the codex BillingError mapping (AC-3 lands the test, #1087 flips it.fails). #1086 (SEQUANT_* hermeticity) affects only how AC-7 is run, not what this change contains.


    Open Questions

    1. Is export function listDriverNames() within "index.ts: adapter registration only"? — Recommendation: yes, it is the minimal additive export that makes registry-driven enumeration possible at all. Impact if wrong: the suite has to scrape getDriver's error message, which couples AC-1 to a string format.
    2. File the opencode/aider gap issue now, or write gap: #TBD? — Recommendation: file it first; a #TBD skip reason passes the format check while naming nothing. Impact if wrong: one extra issue.
    3. Does the sandbox probe belong in the unit project at all? — Recommendation: keep the AC-named path and set per-test timeouts, so AC-1's literal command stays true. Impact if wrong: a 5 s flake under load, visible immediately.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: enabled
    Reasoning: No prior /assess comment on this issue. testgen is skipped deliberately: the deliverable is the test file, so generated stubs would collide with it, and all 7 ACs resolve to manual with no declared Evidence: clause. Quality loop is enabled because the scope assessment returned SCOPE_SPLIT_RECOMMENDED, and because two ACs are mutation-gated — a first pass that records a malformed failedTest needs a second.


    Label Review

    Current: enhancement, multi-agent
    Recommended: add nothing; optionally no-browser-test (no UI surface — makes the skip explicit rather than inferred)
    Reason: No .tsx/.jsx anywhere in the change. multi-agent already reflects the cross-driver scope.
    Quality Loop: auto-enabled by the red scope verdict, and kept — see Reasoning above.

  4. added
    planned
    on Sep 20, 2026
  5. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    Runner note for the qa phase (2026-09-20). Do not run the full npm test in the worktree: under seven concurrent phase agents it exceeds the 30-minute no-progress wall and the phase is killed (this happened to the first qa run of this issue). The runner runs the full suite once per PR from a clean shell and records the result on the PR. Verify each AC by its own command, run only the test files the ACs name, and read the PR body's mutation marker with parseMutationMarkers. The PR is already open; do not push or rebase.

  6. admarble commented on Sep 20, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 0/2 met

    Gaps:

  7. added 4 commits that reference this issue on Sep 20, 2026
  8. added a commit that references this issue on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmulti-agentplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions