test: [de-fork S2] execution-route matrix + sentinel tests
Closed
AN
1mo ago+599+599+012345678901234567890123456789-0-0-0123456789
PINEAPPLE
Summary
Stage S2 of the de-fork spike: the authoritative map of every tool-execution dispatcher (where a resolved tool's .execute() actually runs), so stage S3's HardPolicy knows every chokepoint it must cover. Analysis + executable sentinel tests only — zero product-code change.
Deliverables:
docs/internal/defork-route-matrix.md— ingress surfaces vs execution dispatchers (D1–D8), each classifiedactive/latent/out-of-scopewith file:line evidence.packages/opencode/test/altimate/defork/route-sentinels.test.ts— an executable sentinel per active route, driving a harmless tool through the real dispatch code and asserting execution reaches the documented line.
Key findings (these shape S3's HardPolicy)
SessionTools.resolve(D3/D4) is latent — zero production callers at HEAD (a guard test flips if that changes), so it isn't a current bypass.- The real bypass is BatchTool inner dispatch (
tool/batch.ts:104) — it skipsPlugin.triggerand source-stamping. - All active dispatchers live in 3 files (
session/prompt.ts,tool/batch.ts,session/tools.ts) → S3's ≤3-file audited-patch budget is feasible. - Flags a pre-existing security gap (out of this spike's scope): the server-v2
shellHTTP route has only a session-existence check, no permission gate.
Test Plan
bun test test/altimate/defork/route-sentinels.test.ts: 9 pass / 0 fail (verified in the primary dev worktree).
Checklist
- Tests added/updated
- Documentation updated (route matrix)
- CHANGELOG updated — N/A (internal analysis + tests)
Closes #1011
Summary by cubic
Maps all tool-execution dispatchers and adds sentinel tests to pin and exercise each route; commits the S2 spec and clarifies MCP checks and the BatchTool permission bypass. Adds an explicit coverage contract and expands latent-guard scanning; no product code changes. Closes #1011.
- Highlights
- Docs:
docs/internal/defork-route-matrix.mdupdated with a precise “Coverage contract” (D1/D5 have real-execution sentinels; D2/D6 use documented transitive/citation coverage), plus out-of-scope entries and the v1+v2shellroute gap (tracked in #1019); committeddocs/internal/2026-07-18-defork-spike-spec.md. - Tests:
packages/opencode/test/altimate/defork/route-sentinels.test.ts(9 passing) with line- and arg-agnostic chokepoint pins; latent guard now scans the entiresrctree including.tsxforSessionTools.resolve(callers; D1 and D5 exercise real dispatch. - Clarifications: D2/D4
PermissionNext.askis deny-capable with wildcard patterns; D5BatchToolinner dispatch is a real permission bypass; D6 direct task dispatch is ungated today (bypassAgentCheck=true). All active dispatchers remain insession/prompt.ts,tool/batch.ts,session/tools.ts.
- Docs:
Summary by CodeRabbit
-
Documentation
- Added an internal “S2 de-fork” execution-route and reachability matrix documenting dispatcher expectations, gating/plugin behavior, and noted bypass/coverage gaps.
- Added the “De-fork Spike” build spec (rev 4) describing staging gates and replay/diff constraints.
-
Tests
- Added route-sentinel tests covering direct tool dispatch, latent-call-site guards, mocked-layer resolution, batch inner-tool dispatch behavior, and task/tool metadata handling.
- Added structural and citation checks to ensure existing real-execution and metadata-preservation behavior.