Skip to content

fix(planner): harness fixes F1–F6#32

Open
alfieprojectsdev wants to merge 6 commits into
solatis:mainfrom
alfieprojectsdev:feat/planner-harness-fixes
Open

fix(planner): harness fixes F1–F6#32
alfieprojectsdev wants to merge 6 commits into
solatis:mainfrom
alfieprojectsdev:feat/planner-harness-fixes

Conversation

@alfieprojectsdev

Copy link
Copy Markdown

No description provided.

alfieprojectsdev and others added 6 commits June 20, 2026 15:11
Step 1 self-generated a state dir via tempfile.mkdtemp() in /tmp and
ignored an explicit --state-dir. A session-limit restart wiped /tmp and
destroyed an in-progress plan one step before the final write.

- Add default_state_root() / create_state_dir() in shared/resources.py:
  step 1 now honors an explicit --state-dir (resumable) and otherwise
  mints a fresh persistent dir under <project>/.claude/planner-state/
  (git-ignored), never /tmp.
- Make step 1 resume-safe: it no longer clobbers an existing plan.json,
  so re-running it against a populated state dir preserves prior work.
- Add tests/test_state_dir.py guarding the persistent-dir + resume
  contract end-to-end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
QR fix mode said "fix these findings", so the fixer patched only the
QR-named instances. The next verify pass then re-surfaced sibling
instances of the same class (temporal comments, fragmented requirements,
mis-scoped comments) -- 3+ fix<->verify iterations per class.

- Add shared/fix_mode.py: CLASS_SWEEP_DIRECTIVE reframes findings as
  examples of a class to sweep entirely, plus temporal_scan_gate().
  Wired into all five *_qr_fix.py prompt builders (plan + exec twins).
- Add a deterministic temporal scanner to shared/temporal_detection.py
  (scan_text / scan_plan_docs) scoped to the doc/comment surface and
  excluding decision reasoning (avoids false-firing on "chose").
- Add `temporal-scan` CLI command: exits non-zero while any hit remains,
  so the plan-phase fixer cannot report PASS with siblings present.
- Fix a latent bug: exec_implement_qr_fix / exec_docs_qr_fix had
  get_step_guidance(step) but used module_path/kwargs -> they crashed on
  every real dispatch. Signature corrected to match the plan-phase twins.
- Add tests/test_temporal_sweep.py.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Plan-phase QR applied implementation-grade checks: it FAILed a correct
plan because the working tree wasn't migrated yet ("context still shows
pre-change state") and because @@ offsets weren't git-apply-clean --
neither is appropriate for a planning artifact whose hunks nobody applies.

- Add PLAN_INTENT_FIDELITY_NOTE in qr_verify_base.py and lead every
  plan-code verify check with it.
- Reframe the CONTEXT LINE and DIFF FORMAT checks in plan_code_qr_verify:
  context lines must match the CURRENT (un-migrated) file (the diff anchors
  to real content); @@ line numbers and git-apply-cleanliness are advisory
  and reserved for the exec/impl phase. FAIL only when the diff
  mis-describes the change (wrong file/transform/context).
- Reframe the plan_code_qr_decompose STEP_1/STEP_2 prompts the same way,
  listing offset/apply-cleanliness as explicit non-failures.
- Extend tests/test_qr_verify_routing.py with intent-fidelity cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code changes were stored as hand-authored unified diffs, so the LLM had to
compute `@@ -A,B +C,D` line arithmetic by hand -- a recurring off-by-1/2
hunk source (a sub-case of the F2 whack-a-mole it can never fully win).

- Add shared/diffgen.py: build_unified_diff(file, old_snippet, new_snippet,
  file_text) computes the hunk headers via difflib. With the current file
  available the diff anchors to real line numbers; otherwise it is
  snippet-relative (offsets advisory per F3). The LLM never writes a @@ line.
- Add old_snippet/new_snippet to the CodeChange schema (source of truth).
- set-change CLI gains --old-snippet/--new-snippet: the tool reads the file
  and stores a computed diff; mutually exclusive with --diff.
- plan_code_execute step 3 now leads with the snippet workflow and demotes
  hand-authored --diff to a discouraged fallback.
- Add tests/test_diffgen.py (unit + set-change CLI integration).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fix<->verify loops had no per-item iteration cap; only a human deciding
"override / accept advisory" broke them, so a single stubborn item could
loop indefinitely.

- Track per-item fail_count (cli/qr.py update-item increments it on FAIL).
- Add classify_item_convergence / convergence_partition in shared/qr/utils:
  after QR_CONVERGENCE_CAP (default 2) FAILs on the same item, a MUST item
  -> "escalate", a SHOULD/COULD item -> "auto_accept".
- has_qr_failures and routing.detect_qr_state are now convergence-aware:
  auto-accepted and already-accepted items no longer route back into fix
  mode; MUST items past the cap still block (and escalate).
- record_auto_accepts marks SHOULD/COULD items accepted-with-rationale;
  the qr_route_step records and logs them before routing.
- build_gate_output gains an escalation path: when a MUST item is past the
  cap it renders ONE human-decision gate (keep fixing vs override-accept)
  instead of silently re-looping.
- Add `accept-item` CLI command to record an override with a rationale.
- Add tests/test_convergence.py.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The architect emitted planning_context in a richer shape than the schema
(constraints as dicts not strings; rejected_alternatives missing the
required rejection_reason/decision_ref) -> raw pydantic errors that blocked
a downstream --step N until hand-coerced.

- Add validate_planning_context() in shared/schema.py: runs on the RAW dict
  (works even when a full Plan.model_validate would crash) and returns
  targeted, self-correctable messages.
- Add `validate-planning-context` CLI command surfacing those errors and
  exiting non-zero.
- Wire it into the architect execute step 6 and plan_design_qr_fix step 3
  so shape drift is caught and self-corrected in the architect step, never
  blocking a later step with a traceback. Also fixes a latent literal
  "{state_dir}" (missing f-string) in the qr-fix validate command.
- Add tests/test_planning_context_shape.py.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant