test: harden v0.8.3 plan-mode trust-boundary tests + fix nested marker tracking
Merged
AN
6mo ago+109+109+012345678901234567890123456789-120-120-012345678901234567890123456789
What does this PR do?
Fast-follow hardening from the v0.8.3 multi-model code review (GPT 5.4 + Gemini 3.1 Pro + Kimi K2.5 + MiniMax M2.7 + Claude). All reviewers' verdict on the shipped v0.8.3 was ship — would not have blocked; these are the non-blocking items they surfaced.
- Fix nested-marker tracking (
processor.ts). The v0.8.3 marker fix wrapped the reworded plan-no-tool warning in an inner// altimate_changeblock nested inside the outer plan-refusal block.script/upstream/analyze.tsfindMarkers(lines 499–520) uses a singleopenBlockwith no nesting stack, so the innerstartclobbered the outer block and itsendwas dropped — the outer block fell out of marker tracking. It passed the strict CI gate (hunk-based) and the count balance, so it never failed the release, but it degraded upstream-bridge accuracy. The warning text is already inside the outer block, so removing the inner markers keeps the strict gate green (pure deletion) and restores correct tracking. (Gemini; verified againstanalyze.ts.) - Harden the behavioral trust-boundary tests. Replaced
session: {} as anywith a structurally valid{ slug, time: { created } }and added an explicitFlag.OPENCODE_EXPERIMENTAL_PLAN_MODE === falseprecondition, so a future flag flip fails loudly instead of throwing an opaqueTypeErrorinSession.plan(and silently dropping the intended coverage). (Consensus of all 5 reviewers; Gemini rated MAJOR.) - Add an end-to-end SINK test. The existing tests proved the intermediate
trustedReminderParts; this drives the result through the realsystem-array hoist andMessageV2.toModelMessages, asserting attacker text never reachessystemand the hoisted reminder is not duplicated into the user role. (GPT.) - Make the wording-fix guards concept/synonym-tolerant (keeping the load-bearing negative
too thin to act onguard) so legitimate copy improvements don't break the suite. (MiniMax.) - Rename a mislabeled source-regex test — it asserts the
InsertRemindersResulttype alias, not runtime behaviour. (MiniMax.) - Revert the
plan.txtstart-marker description edit — plan.txt is imported raw into the LLM prompt, so the added words were model-visible; the prose already documents the escape hatch. (Gemini.)
Type of change
- Bug fix (non-breaking change which fixes an issue)
- Test improvement
Issue for this PR
Closes #898
How did you verify your code works?
bun test test/session/plan-layer-e2e.test.ts test/skill/release-v0.8.3-adversarial.test.ts test/session/processor.test.ts test/session/system.test.ts test/provider/family.test.ts— 192 pass, 0 fail (incl. the new end-to-end sink test and flag preconditions).bun test test/session/ test/skill/ test/provider/— 1619 pass, 0 fail.bun run typecheck— clean.bun run script/upstream/analyze.ts --markers --base origin/main --strict— All custom code properly marked (confirms the nested-marker removal keeps the gate green and the outer block is no longer clobbered).- Verified the nesting is gone:
processor.tsnow has a single outer block (345→411), no inner markers.
Checklist
- My code follows the style guidelines of this project
- I have performed a self-review of my own code
- I have commented my code, particularly in hard-to-understand areas
- I have made corresponding changes to the documentation (n/a — test/tooling only)
- My changes generate no new warnings
- I have added tests that prove my fix is effective
- New and existing unit tests pass locally with my changes
Summary by cubic
Hardened v0.8.3 plan‑mode trust boundary and added end‑to‑end sink coverage, while fixing nested marker tracking in processor.ts to restore accurate upstream markers. Also reverted the model‑visible plan.txt marker description to keep the prompt unchanged. Closes #898.
-
Bug Fixes
- Removed nested inner
// altimate_changemarkers around the plan‑no‑tool warning soscript/upstream/analyze.tscorrectly tracks the outer block. - Reverted
plan.txtstart‑marker description since the file is imported raw into the LLM prompt.
- Removed nested inner
-
Test Improvements
- Added an end‑to‑end sink test to ensure attacker text never reaches
systemand reminders aren’t duplicated into the user role. - Replaced
session: {} as anywith a valid{ slug, time: { created } }and added aFlag.OPENCODE_EXPERIMENTAL_PLAN_MODE === falseprecondition to fail loudly on future flips. - Made wording‑fix guards concept/synonym‑tolerant and renamed the source‑regex test to reflect it asserts the
InsertRemindersResulttype alias.
- Added an end‑to‑end sink test to ensure attacker text never reaches
Summary by CodeRabbit
-
Tests
- Expanded safety and trust-boundary test coverage for plan-layer functionality, including edge cases and adversarial scenarios.
-
Chores
- Removed internal directive comments and cleaned up code organization.
- Updated prompt configuration to streamline internal directives.