Skip to content

refactor(runner): move Claude, Codex and Grok behind the provider adapter contract (#155) - #169

Merged
mergify[bot] merged 4 commits into
mainfrom
refactor/155-provider-adapter-contract
Oct 12, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
refactor/155-provider-adapter-contract

Conversation

@ericlitman

Copy link
Copy Markdown
Owner

Summary

Unit U1 of the model and provider registry (design, #103). Claude, Codex and Grok move behind one provider adapter contract and a typed registry. Behavior is unchanged except for the two changes the issue names.

 plugins/pstack/skills/poteto-mode/scripts/runner/
+├── registry/
+│   ├── contract.ts      # Lane and the ProviderAdapter contract
+│   ├── family.ts        # family entry and released-pair types
+│   ├── models.ts        # FAMILIES, ROLE_DEFAULTS, RELEASED_PAIRS
+│   ├── providers.ts     # ADAPTERS, the only provider list
+│   └── index.ts         # resolveModel, resolveLane, defaultDescriptor
+├── providers/{claude,codex,grok}.ts   # the old switch arms, with their tests
+├── providers/{shared,adapter-suite}.ts
-├── commands.ts, parse-output.ts, model-aliases.ts
 ├── run.ts               # orchestration only; no child-provider branch
 └── cli.ts               # validation through the registry
 .claude/skills/verify-open-pstack/features/recipes.ts
+  linked-worktree-writer case (Codex parent, claude:opus@max isolated-write in a linked worktree)

Intended behavior changes:

  • The resolver rejects an effort that a registered family or kept predecessor does not list, such as claude:opus@ultra. Before, cli.ts accepted any effort in the global list.
  • default is a valid effort, and every adapter omits its effort flag for it. No U1 family lists it yet.

Evidence

  • Receipt parity: 21 lanes run through main's pstack-runner (748a9bc) and this branch's, against the same fake CLIs. Only timestamps, elapsed time and the run directory were normalized. All 21 receipts, exit codes and stderr outputs were identical. The lanes covered:
    • Claude, Codex and Grok in both modes;
    • a Claude writer in a linked worktree, whose receipts carry the same denyWrite;
    • the kept gpt-5.6-sol@ultra and grok-4.6;
    • unregistered models;
    • preflight unauthenticated and missing model;
    • Grok cancellation, model failure, unavailable model and malformed output;
    • a missing CLI, same-provider, a stale revision and a bad mode.
  • Grok environment allowlist (Grok lanes inherit the parent's full environment, including secrets, now that they have a shell #141): the same 21 names and four prefixes, moved into providers/grok.ts.
  • Tests: 310 pass. Every deleted test's assertion has a new home, listed per test in the build record. Changed tests change only where the contract changes: the effort universe gains default, and argv fixtures that built same-provider lanes get a valid parent.
  • Live gate: pending on af6fd1b. This PR changes the verifier, so the run is from this candidate head with --self-test, --feature claude:runner --feature codex:runner, and --runner-route for codex:gpt-6.1-sol@max, codex:gpt-5.6-sol@max (kept predecessor), grok:grok-4.7@xhigh, grok:grok-4.5@high (unregistered, passed through) and claude:opus@max. From Claude that is four external lanes; from Codex it is three, plus the linked-worktree-writer case.

Merge Danger

Door: two-way

Blast Radius: runner

Every external lane goes through the new adapters. The parity run and the live run cover each provider. A sheet that names an effort its family does not list now fails validation instead of reaching the CLI.

Acceptance criteria

  • "Given today's valid Claude, Codex and Grok lanes and controlled timestamps, durations and paths, when the runner builds argv and receipts, then their serialization, field order and failure evidence are identical to main." Shown by the receipt parity run above.
  • "Two behavior changes are intended ..." Covered by registry.test.ts "rejects an effort that a registered family or kept predecessor does not list", cli.test.ts "rejects an effort the registered family does not list", and "accepts the default effort for an unregistered pair".
  • "Given an unregistered (provider, model) pair, when the runner runs it, then the pair passes to the CLI unchanged." Covered by registry.test.ts (grok:grok-4.5@high argv) and the live grok:grok-4.5@high lane.
  • "Given a versioned claude-opus-<revision> that the parent did not normalize, when the runner receives it, then it refuses with today's message." Covered by registry.test.ts and cli.test.ts (exit 64).
  • "run.ts contains no child-provider branch; the parent sandbox diagnostic stays. Outside providers/, only registry/providers.ts imports providers/*." Covered by registry.test.ts.
  • "Every released pair resolves to its recorded family." Covered by registry.test.ts "resolves every released pair to its recorded family".
  • "No implicit timeout, no weaker-model fallback, no model-execution retry. The Grok preflight keeps its one bounded retry." The retry and deadline tests in run.test.ts pass unchanged.
  • Live checks: see Evidence.

Gate results

My run on the committed head af6fd1b, every command with MASTRA_TELEMETRY_DISABLED=1:

Check Exit
bun install --frozen-lockfile (poteto-mode scripts) 0
bun run test 0 (310 pass, 0 fail)
bun run typecheck (strict) 0
Manifest JSON parse 0
bun install --frozen-lockfile --ignore-scripts (verifier) 0
PSTACK_STATIC_ONLY=1 bash tests/skill-collision-repro.sh (includes the verifier's tests and typecheck) 0
claude plugin validate plugins/pstack 0

Not verified

Closes #155

🤖 Generated with Claude Code

ericlitman and others added 3 commits October 12, 2026 10:47
Brings in REVIEW.md (#153) and the Reflect verifier fixes (#152, #166) before
this branch opens, since both PRs edit features/recipes.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Queue ready pull requests

Automatically queue non-draft pull requests targeting main after verify, Unfret, and live-gate pass on the head and every review thread is resolved.

  • #review-threads-unresolved = 0
  • -draft
  • check-success=Unfret
  • check-success=live-gate
  • check-success=verify

🟢 🚦 Auto-queue

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • -files~=^\.github/
  • base = main

@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: af6fd1b60a878f86f152cb0f66b1ba8b0bb76e07
  • Base SHA: 02d3943de078ed881e5d9253ce49c6ec54d01ba2
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: af6fd1b60a878f86f152cb0f66b1ba8b0bb76e07
  • Evidence-set SHA-256: b44beb10bccaa1a5476cef1f9d3434378e08da72d361c58e52b11ba7123709ad
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.6.1, candidate af6fd1b60a878f86f152cb0f66b1ba8b0bb76e07, tree 6eee6334b5673321324bf587601405eb021d63523c0ea3c3392c1fe857adc17b.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.6.1, candidate af6fd1b60a878f86f152cb0f66b1ba8b0bb76e07, tree 6eee6334b5673321324bf587601405eb021d63523c0ea3c3392c1fe857adc17b.
  • Observation (claude / runner): surface claude -p stream-json with the candidate plugin-dir; action recipe runner: route-1, route-2, route-3, route-4; result passed 20 assertions; ids retained privately; 20 assertions machine-checked; transcript SHA-256 3c7870805b2513082a169b0635b868e7baad6481bc30ab14e36c42256e00d523; artifact-set SHA-256 ba619e6b660057051d0370bc941700045688e0db17fcfe547a766dd80c33ed38.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 b7944b7d0dad94c742b890ad4f88944cdfea78bf9fb17c1afc19b535bfd82548; artifact-set SHA-256 6fc2349426b2de68fb8d3d3a2884eb097f0cae894b00ed2ca16512db6607c511.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1, route-2, route-3, linked-worktree-writer; result passed 20 assertions; ids retained privately; 20 assertions machine-checked; transcript SHA-256 2f5a23c05a21a968b2ccc63edd3ced32fdc8338017dd095951066d0e1f64c1bc; artifact-set SHA-256 e757b533aa6b7bc3f25720cf7b8235898a63bc8797e1c7414a5d27cd4fb5e4e3.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 ec1b97fdc4fbe6ee2f1ba149795868e1e88cd0fbf8b8a5d0295e1e4ec7fbf721; artifact-set SHA-256 f03b21c14402ac96680fd9cbd405daa86634c347035e3f9b06a740882412de68.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Moves Claude, Codex, and Grok behind ProviderAdapter and a typed model registry.

  • Claude, Codex, and Grok lanes use one shared runner contract.
  • Registered model families now allow only their listed efforts.
  • Codex-parent runner checks include a Claude writer in a linked worktree.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  CLI["cli.ts"] --> Resolve["resolveLane"]
  Resolve --> Registry["Families and adapters"]
  Resolve --> Lane["Validated Lane"]
  Lane --> Run["run.ts"]
  Run --> Git["Shared Git discovery when requested"]
  Run --> Preflight["Adapter preflight"]
  Preflight --> Launch["Adapter launch arguments"]
  Launch --> Child["Provider CLI"]
  Child --> Parse["Adapter parse and model match"]
  Parse --> Receipt["Output and receipt"]
Loading

Reviews (1) · Last reviewed commit: "Merge origin/main into refactor/155-prov..." · Reviewed by Greptile

@unfret-eal

unfret-eal Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

✅ Accepted risk

Accepted by ericlitman: GH-155 (authority 48fa77b)

🔴 High · Writer gate accepts a different runner revision

🟡 Medium · Glob-bearing TMPDIR makes the writer gate unpassable

🟡 Medium · Test helper splits fixture paths containing spaces

Details

Run: GET /unfret/run/panel:af6fd1b60a878f86f152cb0f66b1ba8b0bb76e07:1zf9j5RxWPW:wpSY1mg0vpw.

@unfret review · @unfret status · @unfret help

@unfret-eal unfret-eal Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 3 blocking findings
🔴 High · Writer gate accepts a different runner revision
🟡 Medium · Glob-bearing TMPDIR makes the writer gate unpassable
🟡 Medium · Test helper splits fixture paths containing spaces
Check

@ericlitman

Copy link
Copy Markdown
Owner Author

Waived on this head. Each blocking finding is real but not material in this repository's actual usage (REVIEW.md):

@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-12 18:07 UTC · Rule: default · triggered by merge protections
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-12 18:52 UTC · at d1894f75f480465613f2e97359696f39ea36b52e · merge

This pull request spent 45 minutes 12 seconds in the queue, including 44 minutes 57 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Oct 12, 2026
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: 8afc800aa90d63d544d33415d6bb009c4685cc25
  • Base SHA: 432a971e5b82ee7cf9df45ba0efe1313a089083e
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: 8afc800aa90d63d544d33415d6bb009c4685cc25
  • Evidence-set SHA-256: 6aa043d706f183c71892ccec3954cf5887e9f59237b77f22a6b036539c40b861
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.6.2, candidate 8afc800aa90d63d544d33415d6bb009c4685cc25, tree 5c61e3dda3fe5f8840cfde2e2de6c4961f912f1bdebe905e950c9e106b71d520.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.6.2, candidate 8afc800aa90d63d544d33415d6bb009c4685cc25, tree 5c61e3dda3fe5f8840cfde2e2de6c4961f912f1bdebe905e950c9e106b71d520.
  • Observation (claude / runner): surface claude -p stream-json with the candidate plugin-dir; action recipe runner: route-1, route-2, route-3, route-4; result passed 20 assertions; ids retained privately; 20 assertions machine-checked; transcript SHA-256 7bc492b578e7c1650a1eaeb7041d34eeaf09961aab2f7add0d27e6ace96f12d4; artifact-set SHA-256 18ddf96966cc71693c159aa44cc76f5c1bf8e89cfc0a1f45b5d3e4f17698f065.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 6921e97aed60717fa196af7c7a0bc9e520a104360ba709532e03ac7179afcbef; artifact-set SHA-256 49639a940c7b974eede42a919c0e7376ebb985587a17620e672617a4af3124f0.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1, route-2, route-3, linked-worktree-writer; result passed 20 assertions; ids retained privately; 20 assertions machine-checked; transcript SHA-256 b05777565e21f21ee33abf2cce1bd36cdd8a62216ec904f2b8d127201950d8a0; artifact-set SHA-256 f71eb3fd7441dcb2ba5c99e1312bf96287243a1ea6d7b502c66e79f76731cdb5.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 3763117c5c410659b625503dfc895f0ff8cb1493abfbaf37c8cbd0d02210437f; artifact-set SHA-256 03fef8c5b0956750e71a5aa4ca01d136f982fb55c63c78074825c78b966c6afd.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Claude, Codex and Grok behind the provider adapter contract (registry U1)

1 participant