Skip to content

fix: sync contract wrappers into stage-behavior expectedTools#25

Merged
m62624 merged 2 commits into
mainfrom
hotfix/contract-tool-gating
Jun 15, 2026
Merged

fix: sync contract wrappers into stage-behavior expectedTools#25
m62624 merged 2 commits into
mainfrom
hotfix/contract-tool-gating

Conversation

@m62624

@m62624 m62624 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

No description provided.

m62624 and others added 2 commits June 15, 2026 18:51
Task 3 added the artifact fill-tools to the guard policy
(STEP_ALLOWED_TOOLS) but not to the parallel expectedTools allowlist in
stage-behavior.ts, so checkPlannerStageBehaviorWrapperTool blocked them
with "Stage behavior does not list <tool> as expected at <stage>/<step>".
For discovery/plan/summary the model could fall back to a built-in write,
but for tdd.md — where edit/write is blocked — it was a hard deadlock.

Add each fill-tool to expectedTools at exactly the steps where the guard
policy already allows it: planner_discovery_submit (scan_project_structure,
handle_change_request), planner_plan_submit (draft_plan, handle_change_request),
planner_tdd_submit (every execution step that writes tdd.md),
planner_summary_submit (write_final_summary). artifactBehavior gains an
optional extraTools param for draft_plan.

Add a regression test asserting every fill-tool is permitted by BOTH the
guard policy and the stage-behavior gate at each of its steps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…iant

A general gating invariant (new tool-gating-invariant.test.ts) revealed
that the guard policy and stage-behavior expectedTools had drifted for
contract helpers too — not only the new fill-tools. The guard allowed
these at steps where the behavior gate blocked them, so the model hit
"Stage behavior does not list <tool>" if it tried:

- planning/draft_plan, planning/split_tasks: planner_contract_route/read
- finalize/verify_plan_branch, finalize/write_final_summary: planner_contract_route/read
- done/present_result, done/await_user_acceptance: planner_contract_decide

These are read-only/decision helpers (non-deadlocking, the model can
proceed without them) but the instructions explicitly tell it to route
and read contracts there, so the behavior gate was the side that was
wrong. Add the missing tools to expectedTools. Debug wrappers were
already consistent across both gates.

The invariant test now asserts that at every step, every guard-allowed
wrapper also passes the behavior gate. Document the dual-allowlist
requirement in src/runtime/AGENTS.md so future tool changes update both.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix label Jun 15, 2026
@m62624 m62624 merged commit 12b09cf into main Jun 15, 2026
2 checks passed
@m62624 m62624 deleted the hotfix/contract-tool-gating branch June 15, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant