From 813c1d77c0b91981e565a2209dd867ee64fd71f9 Mon Sep 17 00:00:00 2001 From: jobordu Date: Fri, 27 Mar 2026 12:50:36 +0000 Subject: [PATCH 1/5] feat(quick-362): wire debug routing (Loop 1 + task classification + debug_context injection) into execute-phase.md --- core/workflows/execute-phase.md | 94 +++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/core/workflows/execute-phase.md b/core/workflows/execute-phase.md index 08f37f8972..864c218567 100644 --- a/core/workflows/execute-phase.md +++ b/core/workflows/execute-phase.md @@ -101,6 +101,89 @@ node ~/.claude/nf/bin/gsd-tools.cjs activity-set \ - Bad: "Executing terrain generation plan" - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground." +1.5. **Classify plan type and debug routing (ROUTE-02, ROUTE-03):** + + For each plan, classify its objective and optionally route through `/nf:debug` before execution. + + **1.5a. Classify plan type via Haiku subagent:** + + Spawn a Haiku subagent to classify the plan's objective: + + ``` + Task( + subagent_type="general-purpose", + model="haiku", + description="Classify plan type for debug routing", + prompt=" + You are classifying a development plan into exactly one category. + + ## Plan Objective + {plan_objective_text from tag} + + ## Categories + - bug_fix: The plan fixes a bug, error, regression, crash, or broken behavior. + - feature: The plan adds new functionality or capability. + - refactor: The plan reorganizes, renames, cleans up, or simplifies existing code without changing behavior. + + Respond with ONLY a JSON object: + { + \"type\": \"bug_fix\" | \"feature\" | \"refactor\", + \"confidence\": 0.0-1.0 + } + " + ) + ``` + + Parse response as JSON. Store as `$PLAN_CLASSIFICATION`. + + **Fail-open:** If Haiku is unavailable or JSON parse fails, use `{ "type": "feature", "confidence": 0.0 }`. + + Log: `"Plan classification: ${PLAN_CLASSIFICATION.type} (confidence: ${PLAN_CLASSIFICATION.confidence})"` + + **1.5b. Debug routing:** + + **Skip if:** `$PLAN_CLASSIFICATION.type` is NOT `bug_fix`, OR `$PLAN_CLASSIFICATION.confidence` < 0.7. + + If skipped, log: `"Debug routing: skipped (type: ${PLAN_CLASSIFICATION.type}, confidence: ${PLAN_CLASSIFICATION.confidence})"` + Set `$DEBUG_CONSTRAINTS = null`, `$DEBUG_FORMAL_VERDICT = null`, `$DEBUG_REPRODUCING_MODEL = null`. + + **If routing:** + + 1. Log: `"Debug routing: bug_fix detected (confidence: ${PLAN_CLASSIFICATION.confidence}) — routing through /nf:debug"` + + 2. Spawn `/nf:debug` as a Task subagent: + + ``` + Task( + prompt=" + Run /nf:debug with the following failure context. + + ## Plan Objective (from phase plan) + {plan_objective_text} + + ## Instructions + - Run the full debug pipeline (Steps A through A.8: collect context, discovery, reproduction, refinement, constraint extraction) + - Return the debug output including: + - \$CONSTRAINTS (extracted constraints from Loop 1, if any) + - \$FORMAL_VERDICT (pass/fail/skip from formal model checking, if any) + - \$REPRODUCING_MODEL (path to reproducing formal model, if any) + - If any step fails or produces no output, continue with remaining steps (fail-open) + - Do NOT fix the bug — only diagnose and extract constraints. The executor will apply the fix. + ", + subagent_type="general-purpose", + description="Debug routing for plan {plan_number}: {plan_objective_summary}" + ) + ``` + + 3. Parse debug output. Extract and store: + - `$DEBUG_CONSTRAINTS` — constraints from Loop 1 refinement (may be empty) + - `$DEBUG_FORMAL_VERDICT` — formal model check result (may be "skipped") + - `$DEBUG_REPRODUCING_MODEL` — path to reproducing model (may be null) + + 4. Log: `"Debug routing complete. Constraints: ${DEBUG_CONSTRAINTS ? 'found' : 'none'}, Verdict: ${DEBUG_FORMAL_VERDICT || 'skipped'}"` + + **Fail-open:** If the debug subagent errors or times out, log a warning and proceed without debug context. Set all debug vars to null. + 2. **Spawn executor agents:** Pass paths only — executors read files themselves with their fresh 200k context. @@ -167,6 +250,17 @@ node ~/.claude/nf/bin/gsd-tools.cjs activity-set \ 6. If step 2 found NO intersections: skip Loop 2 entirely (GATE-03) — silent, no log + ${DEBUG_CONSTRAINTS || DEBUG_FORMAL_VERDICT || DEBUG_REPRODUCING_MODEL ? + ` + This plan was routed through /nf:debug before execution. Use the following debug output as supplementary context for your implementation: + + ${DEBUG_CONSTRAINTS ? '**Constraints from formal model refinement:**\n' + DEBUG_CONSTRAINTS : ''} + ${DEBUG_FORMAL_VERDICT ? '**Formal verdict:** ' + DEBUG_FORMAL_VERDICT : ''} + ${DEBUG_REPRODUCING_MODEL ? '**Reproducing model:** ' + DEBUG_REPRODUCING_MODEL : ''} + + These constraints inform the fix but do not gate it. If constraints conflict with the plan, follow the plan. + ` : ''} + - [ ] All tasks executed - [ ] Each task committed individually From aa2c44d94a646c5bd91855ef4d5bc26eb7cb29c9 Mon Sep 17 00:00:00 2001 From: jobordu Date: Fri, 27 Mar 2026 12:51:18 +0000 Subject: [PATCH 2/5] docs(quick-362): wire debug routing into execute-phase.md --- .planning/STATE.md | 3 +- .../362-PLAN.md | 58 +++++++++++++++++++ .../scope-contract.json | 23 ++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 .planning/quick/362-wire-debug-routing-into-execute-phase-md/362-PLAN.md create mode 100644 .planning/quick/362-wire-debug-routing-into-execute-phase-md/scope-contract.json diff --git a/.planning/STATE.md b/.planning/STATE.md index b1809eeee2..419199923c 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -12,7 +12,7 @@ See: .planning/PROJECT.md (updated 2026-03-25) Phase: 53 of 53 (Skill Deprecation) — COMPLETED Plan: 53-01 of 1 — COMPLETED Status: All phases complete — /nf:model-driven-fix deprecated, all consumers rewired to /nf:debug -Last activity: 2026-03-26 - Completed quick task 361: Add automation-first bias to verify-work and execute-phase workflows +Last activity: 2026-03-27 - Completed quick task 362: Wire debug routing into execute-phase.md Progress: [██████████] 100% (Phase 50 done; Phase 51 done; Phase 52 done; Phase 53 done) @@ -79,6 +79,7 @@ None yet. | 359 | Close gap: allow formal_artifacts create when scope-scan empty | 2026-03-26 | afdea71c | Verified | [359-close-the-gap-when-formal-scope-scan-fin](./quick/359-close-the-gap-when-formal-scope-scan-fin/) | | 360 | Add risk-based adaptive quorum fan-out: risk classifier, adaptive dispatch, audit logging | 2026-03-26 | 8e27fe35 | Verified | [360-add-risk-based-adaptive-quorum-fan-out-r](./quick/360-add-risk-based-adaptive-quorum-fan-out-r/) | | 361 | Add automation-first bias to verify-work and execute-phase workflows | 2026-03-26 | afbeac9e | Verified | [361-add-automation-first-bias-to-verify-work](./quick/361-add-automation-first-bias-to-verify-work/) | +| 362 | Wire debug routing (Loop 1 + task classification + debug_context injection) into execute-phase.md | 2026-03-27 | 813c1d77 | Pending | [362-wire-debug-routing-into-execute-phase-md](./quick/362-wire-debug-routing-into-execute-phase-md/) | ### Blockers/Concerns diff --git a/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-PLAN.md b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-PLAN.md new file mode 100644 index 0000000000..a414820e21 --- /dev/null +++ b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-PLAN.md @@ -0,0 +1,58 @@ +--- +task_id: 362 +description: "Wire debug routing (Loop 1 + task classification + autoresearch-refine + debug_context injection) into execute-phase.md" +formal_artifacts: none +--- + +# Plan: Wire Debug Routing into execute-phase.md + +## Objective + +Add per-plan task classification and debug routing to `execute-phase.md` so that bug-fix plans get routed through `/nf:debug` (Loop 1 autoresearch-refine) before execution, with constraints injected into executor prompts — matching the `quick.md` Step 5.8 pattern. + +## Must-Haves + +1. Per-plan Haiku task classification (bug_fix/feature/refactor) in the execute_waves step, before spawning each executor +2. Debug routing: bug_fix plans (confidence >= 0.7) dispatched through `/nf:debug` before executor spawn +3. Debug context injection: `` block conditionally injected into executor prompt with constraints, verdict, and reproducing model +4. Fail-open: all new logic skips silently on Haiku unavailability, debug errors, or missing modules +5. Sync repo source → installed copy after edit + +## Tasks + +### Task 1: Add per-plan task classification to execute_waves step + +In `core/workflows/execute-phase.md`, inside ``, add a classification sub-step BEFORE spawning executor agents (before item 2 "Spawn executor agents"). For each plan in the wave: + +1. Read the plan's `` text +2. Spawn Haiku subagent to classify the plan objective as bug_fix/feature/refactor (same prompt as quick.md Step 2.7 sub-step 1.5) +3. Store `$PLAN_CLASSIFICATION` per plan +4. Fail-open: default to `{ type: "feature", confidence: 0.0 }` if Haiku unavailable + +### Task 2: Add debug routing step between classification and executor spawn + +Add a new sub-step after classification, before executor spawn: + +1. **Skip if:** `$PLAN_CLASSIFICATION.type` is NOT `bug_fix`, OR confidence < 0.7 +2. **If routing:** Spawn `/nf:debug` as Task subagent with the plan objective as failure context (same pattern as quick.md Step 5.8 item 2) +3. Parse debug output → extract `$DEBUG_CONSTRAINTS`, `$DEBUG_FORMAL_VERDICT`, `$DEBUG_REPRODUCING_MODEL` +4. Fail-open: on error, set all debug vars to null and continue + +### Task 3: Inject debug_context block into executor prompt + +Modify the executor Task spawn (item 2 in execute_waves) to conditionally include a `` block after the `` section: + +``` +${DEBUG_CONSTRAINTS || DEBUG_FORMAL_VERDICT || DEBUG_REPRODUCING_MODEL ? +` +This plan was routed through /nf:debug before execution... +` : ''} +``` + +Same template as quick.md lines 877-886. + +### Task 4: Sync to installed copy + +```bash +cp core/workflows/execute-phase.md ~/.claude/nf/workflows/execute-phase.md +``` diff --git a/.planning/quick/362-wire-debug-routing-into-execute-phase-md/scope-contract.json b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/scope-contract.json new file mode 100644 index 0000000000..ae408b8377 --- /dev/null +++ b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/scope-contract.json @@ -0,0 +1,23 @@ +{ + "nf/quick-362-wire-debug-routing-into-execute-phase-md": { + "task_id": 362, + "task_description": "Wire debug routing (Loop 1 + task classification + autoresearch-refine + debug_context injection) into execute-phase.md — matching the quick.md Step 5.8 pattern", + "approach": "Add phase-level task classification and debug routing to execute-phase.md's plan execution loop, dispatching bug-fix phases through /nf:debug before execution and injecting formal constraints into executor prompts, matching the quick.md Step 5.8 pattern.", + "out_of_scope": [ + "Rewriting the /nf:debug skill itself — only phase-level routing and constraint injection are in scope", + "Cross-phase bug-fix dependencies — phase classification is per-plan, not per-milestone", + "Modifying quick.md — only execute-phase.md is in scope" + ], + "classification": { + "type": "feature", + "confidence": 0.85, + "routed_through_debug": false + }, + "risk_level": "high", + "risk_reason": "Workflow file modification (execute-phase.md) — guardrail-protected", + "branches_affected": ["nf/quick-362-wire-debug-routing-into-execute-phase-md"], + "created_at": "2026-03-27T12:46:04.416Z", + "planner_model": "inherit", + "created_by": "quick-orchestrator" + } +} From 339f888044244ad46724b74493b0f0fbee736a19 Mon Sep 17 00:00:00 2001 From: jobordu Date: Fri, 27 Mar 2026 12:52:02 +0000 Subject: [PATCH 3/5] docs(quick-362): update verification status to Verified --- .planning/STATE.md | 2 +- .../362-VERIFICATION.md | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .planning/quick/362-wire-debug-routing-into-execute-phase-md/362-VERIFICATION.md diff --git a/.planning/STATE.md b/.planning/STATE.md index 419199923c..ede0d00f19 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -79,7 +79,7 @@ None yet. | 359 | Close gap: allow formal_artifacts create when scope-scan empty | 2026-03-26 | afdea71c | Verified | [359-close-the-gap-when-formal-scope-scan-fin](./quick/359-close-the-gap-when-formal-scope-scan-fin/) | | 360 | Add risk-based adaptive quorum fan-out: risk classifier, adaptive dispatch, audit logging | 2026-03-26 | 8e27fe35 | Verified | [360-add-risk-based-adaptive-quorum-fan-out-r](./quick/360-add-risk-based-adaptive-quorum-fan-out-r/) | | 361 | Add automation-first bias to verify-work and execute-phase workflows | 2026-03-26 | afbeac9e | Verified | [361-add-automation-first-bias-to-verify-work](./quick/361-add-automation-first-bias-to-verify-work/) | -| 362 | Wire debug routing (Loop 1 + task classification + debug_context injection) into execute-phase.md | 2026-03-27 | 813c1d77 | Pending | [362-wire-debug-routing-into-execute-phase-md](./quick/362-wire-debug-routing-into-execute-phase-md/) | +| 362 | Wire debug routing (Loop 1 + task classification + debug_context injection) into execute-phase.md | 2026-03-27 | 813c1d77 | Verified | [362-wire-debug-routing-into-execute-phase-md](./quick/362-wire-debug-routing-into-execute-phase-md/) | ### Blockers/Concerns diff --git a/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-VERIFICATION.md b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-VERIFICATION.md new file mode 100644 index 0000000000..0364e6ee77 --- /dev/null +++ b/.planning/quick/362-wire-debug-routing-into-execute-phase-md/362-VERIFICATION.md @@ -0,0 +1,22 @@ +# Verification: Quick Task 362 + +## Must-Haves + +| # | Requirement | Status | Evidence | +|---|---|---|---| +| 1 | Per-plan Haiku task classification before executor spawn | PASS | Step 1.5a at line 108 — Haiku classifies plan objective as bug_fix/feature/refactor | +| 2 | Debug routing for bug_fix plans (confidence >= 0.7) | PASS | Step 1.5b at line 145 — spawns /nf:debug before executor | +| 3 | debug_context block injected into executor prompt | PASS | Lines 253-262 — conditional block with constraints, verdict, reproducing model | +| 4 | Fail-open on all new logic | PASS | Line 139 (classification fallback), line 148 (debug vars null on skip), line 185 (debug error → null + continue) | +| 5 | Sync repo source → installed copy | PASS | `cp core/workflows/execute-phase.md ~/.claude/nf/workflows/execute-phase.md` — verified via diff | + +## Pattern Match with quick.md + +| Element | quick.md | execute-phase.md | Match | +|---|---|---|---| +| Classification | Step 2.7 sub-step 1.5 | Step 1.5a | Yes — same Haiku prompt, same JSON schema | +| Debug routing | Step 5.8 | Step 1.5b | Yes — same skip condition, same /nf:debug prompt | +| Debug context injection | Lines 877-886 | Lines 253-262 | Yes — same template | +| Fail-open | Fallback to feature/0.0 | Fallback to feature/0.0 | Yes | + +## Status: Verified From 72bbe22dd81d1bc825f2ff3d6b8a1c0c14c30d2d Mon Sep 17 00:00:00 2001 From: jobordu Date: Fri, 27 Mar 2026 13:50:50 +0000 Subject: [PATCH 4/5] feat(quick-363): push Loop 2 + debug_context into execute-plan.md Pattern A spawn prompt --- core/workflows/execute-plan.md | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/core/workflows/execute-plan.md b/core/workflows/execute-plan.md index 367d7be3cc..e6c70edfef 100644 --- a/core/workflows/execute-plan.md +++ b/core/workflows/execute-plan.md @@ -118,7 +118,47 @@ grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md Pattern D is selected ONLY when: (1) no checkpoints found AND (2) --parallel flag is present. Otherwise, existing A/B/C routing applies unchanged. -**Pattern A:** init_agent_tracking → spawn Task(subagent_type="nf-executor", model=executor_model, description="Execute plan {plan_number}: {phase_number}-{phase_name}") with prompt: execute plan at [path], autonomous, all tasks + SUMMARY + commit, follow deviation/auth rules, report: plan name, tasks, SUMMARY path, commit hash → track agent_id → wait → update tracking → report. +**Pattern A:** init_agent_tracking → spawn Task with the following prompt → track agent_id → wait → update tracking → report. + +``` +Task( + subagent_type="nf-executor", + model=executor_model, + description="Execute plan {plan_number}: {phase_number}-{phase_name}", + prompt=" + Execute plan at {plan_path}. Autonomous mode: all tasks + SUMMARY + commit. + Follow deviation/auth rules. Report: plan name, tasks, SUMMARY path, commit hash. + + + **Formal coverage auto-detection (hybrid A+B):** Before each atomic commit: + 1. Get changed files: CHANGED=$(git diff --name-only HEAD 2>/dev/null | tr '\n' ',') + 2. If CHANGED is non-empty, run: node bin/formal-coverage-intersect.cjs --files \"$CHANGED\" 2>/dev/null + 3. If exit code is 0 (intersections found) OR the plan declares `formal_artifacts: update`: + - Run: node bin/run-formal-verify.cjs 2>&1 + - If exit 0: log 'Formal coverage verified: models OK' + - If exit 1: log 'WARNING: Formal model drift detected' (do NOT block commit -- fail-open) + 4. If formal-coverage-intersect.cjs is not found or errors: skip silently (fail-open) + 5. **Loop 2 simulation gate (GATE-02, GATE-03, GATE-04):** If step 2 found intersections (exit code 0): + a. Run Loop 2 via `simulateSolutionLoop` from `$HOME/.claude/nf-bin/solution-simulation-loop.cjs` with: + - `fixIdea`: description of code changes in current diff + - `bugDescription`: plan objective or task description + - `maxIterations`: 10, `formalism`: 'tla' + - `onTweakFix` callback (GATE-05): reads `iterationContext.verdict` to identify failing gates. Returns `null` if all pass or stuck. Otherwise returns refinement string. + Store result with fields: `converged`, `iterations`, `escalationReason`, `bestGatesPassing`, `tsvPath`. + b. Route on result: + - **converged === true:** Log 'Loop 2: CONVERGED'. Continue to commit. + - **converged === false (fail-open, default):** Log 'WARNING: Loop 2 did not converge'. Continue to commit. + - **converged === false AND plan frontmatter `strict_simulation: true`:** Log 'BLOCKED'. Do NOT commit. + c. If solution-simulation-loop.cjs is not found or throws: skip silently (fail-open) + 6. If step 2 found NO intersections: skip Loop 2 entirely — silent, no log + + + ${PARENT_DEBUG_CONTEXT || ''} + " +) +``` + +**PARENT_DEBUG_CONTEXT passthrough:** When the parent nf-executor (spawned by execute-phase.md) received a `` block in its own prompt, it MUST forward that block verbatim as `${PARENT_DEBUG_CONTEXT}` in the Pattern A child's prompt. If no debug_context was received, this evaluates to empty string (no block injected). **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, create SUMMARY, commit. See segment_execution. From 8ea208550c0d307d072d57b24ae027fe31b0afe9 Mon Sep 17 00:00:00 2001 From: jobordu Date: Fri, 27 Mar 2026 13:51:39 +0000 Subject: [PATCH 5/5] docs(quick-363): complete plan, verification, and state update --- .planning/STATE.md | 3 +- .../363-PLAN.md | 43 +++++++++++++++++++ .../363-VERIFICATION.md | 26 +++++++++++ .../scope-contract.json | 23 ++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .planning/quick/363-push-loop-2-and-debug-context-into-execu/363-PLAN.md create mode 100644 .planning/quick/363-push-loop-2-and-debug-context-into-execu/363-VERIFICATION.md create mode 100644 .planning/quick/363-push-loop-2-and-debug-context-into-execu/scope-contract.json diff --git a/.planning/STATE.md b/.planning/STATE.md index ede0d00f19..55f4be9b43 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -12,7 +12,7 @@ See: .planning/PROJECT.md (updated 2026-03-25) Phase: 53 of 53 (Skill Deprecation) — COMPLETED Plan: 53-01 of 1 — COMPLETED Status: All phases complete — /nf:model-driven-fix deprecated, all consumers rewired to /nf:debug -Last activity: 2026-03-27 - Completed quick task 362: Wire debug routing into execute-phase.md +Last activity: 2026-03-27 - Completed quick task 363: Push Loop 2 + debug_context into execute-plan.md Pattern A Progress: [██████████] 100% (Phase 50 done; Phase 51 done; Phase 52 done; Phase 53 done) @@ -80,6 +80,7 @@ None yet. | 360 | Add risk-based adaptive quorum fan-out: risk classifier, adaptive dispatch, audit logging | 2026-03-26 | 8e27fe35 | Verified | [360-add-risk-based-adaptive-quorum-fan-out-r](./quick/360-add-risk-based-adaptive-quorum-fan-out-r/) | | 361 | Add automation-first bias to verify-work and execute-phase workflows | 2026-03-26 | afbeac9e | Verified | [361-add-automation-first-bias-to-verify-work](./quick/361-add-automation-first-bias-to-verify-work/) | | 362 | Wire debug routing (Loop 1 + task classification + debug_context injection) into execute-phase.md | 2026-03-27 | 813c1d77 | Verified | [362-wire-debug-routing-into-execute-phase-md](./quick/362-wire-debug-routing-into-execute-phase-md/) | +| 363 | Push Loop 2 + debug_context into execute-plan.md Pattern A spawn prompt | 2026-03-27 | 72bbe22d | Verified | [363-push-loop-2-and-debug-context-into-execu](./quick/363-push-loop-2-and-debug-context-into-execu/) | ### Blockers/Concerns diff --git a/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-PLAN.md b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-PLAN.md new file mode 100644 index 0000000000..59f0beab96 --- /dev/null +++ b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-PLAN.md @@ -0,0 +1,43 @@ +--- +task_id: 363 +description: "Push Loop 2 and debug_context into execute-plan.md Pattern A spawn prompt" +formal_artifacts: none +--- + +# Plan: Push Loop 2 + debug_context into Pattern A + +## Objective + +Expand the Pattern A spawn prompt in `execute-plan.md` to include `` (Loop 2) and `` blocks, so the nested child nf-executor inherits both verification loops when committing. + +## Must-Haves + +1. Pattern A spawn prompt includes `` block with Loop 2 (solution-simulation-loop) +2. Pattern A spawn prompt includes conditional `` passthrough from parent context +3. Pattern B confirmed safe (orchestrator commits, not subagent) — no changes needed +4. Fail-open preserved on all new blocks +5. Sync repo source → installed copy + +## Analysis + +- **Pattern A** (line 121): Currently a one-liner prose description. Expand to include formal blocks in the prompt specification. +- **Pattern B** (line 123): Segment subagents do NOT commit — orchestrator (main context) commits. Orchestrator has Loop 2. **No change needed.** +- **Pattern C** (line 125): Executes in main context. Has Loop 2. **No change needed.** +- **Pattern D** (lines 130+): Worktree executors with minimal prompts. Opt-in only (--parallel flag). **Defer to separate task.** + +## Tasks + +### Task 1: Expand Pattern A spawn description to include formal blocks + +Replace the Pattern A one-liner at line 121 with an expanded prompt specification that includes: +1. The existing instructions (execute plan, autonomous, all tasks, SUMMARY, commit, deviation/auth rules) +2. `` block (same as execute-phase.md lines 217-251) +3. `` passthrough: `${PARENT_DEBUG_CONTEXT || ''}` — the parent executor passes any debug_context it received from the orchestrator + +Note: The parent nf-executor (spawned by execute-phase.md) receives `$DEBUG_CONSTRAINTS`, `$DEBUG_FORMAL_VERDICT`, `$DEBUG_REPRODUCING_MODEL` from the orchestrator's debug routing. When spawning the Pattern A child, the parent must forward these as a `` block in the child's prompt. + +### Task 2: Sync to installed copy + +```bash +cp core/workflows/execute-plan.md ~/.claude/nf/workflows/execute-plan.md +``` diff --git a/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-VERIFICATION.md b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-VERIFICATION.md new file mode 100644 index 0000000000..5f277348ab --- /dev/null +++ b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/363-VERIFICATION.md @@ -0,0 +1,26 @@ +# Verification: Quick Task 363 + +## Must-Haves + +| # | Requirement | Status | Evidence | +|---|---|---|---| +| 1 | Pattern A includes formal_coverage_auto_detection (Loop 2) | PASS | Lines 132-154 — full block with simulateSolutionLoop, gates, fail-open | +| 2 | Pattern A includes debug_context passthrough | PASS | Line 156 — `${PARENT_DEBUG_CONTEXT || ''}` + line 161 passthrough docs | +| 3 | Pattern B confirmed safe (orchestrator commits) | PASS | Line 123 — "Autonomous segments: NO SUMMARY/commit", orchestrator does final commit | +| 4 | Fail-open preserved | PASS | Lines 140, 152, 153 — skip silently on errors/missing modules | +| 5 | Sync repo → installed copy | PASS | `cp` verified via diff | + +## End-to-End Trace + +``` +User runs /nf:execute-phase + → execute-phase.md Step 1.5: Classify plan → route bug_fix through /nf:debug (Loop 1) + → execute-phase.md Step 2: Spawn nf-executor with + + → nf-executor reads execute-plan.md + → Pattern C: executes in main context → has Loop 2 + debug_context ✓ + → Pattern A: spawns child nf-executor with Loop 2 + debug_context passthrough ✓ (NEW) + → Pattern B: segment subagents don't commit, orchestrator commits with Loop 2 ✓ + → Pattern D: worktree executors — no loops (opt-in only, deferred) +``` + +## Status: Verified diff --git a/.planning/quick/363-push-loop-2-and-debug-context-into-execu/scope-contract.json b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/scope-contract.json new file mode 100644 index 0000000000..c21f6abe0c --- /dev/null +++ b/.planning/quick/363-push-loop-2-and-debug-context-into-execu/scope-contract.json @@ -0,0 +1,23 @@ +{ + "nf/quick-362-wire-debug-routing-into-execute-phase-md": { + "task_id": 363, + "task_description": "Push Loop 2 (formal_coverage_auto_detection + solution-simulation-loop) and debug_context into execute-plan.md Pattern A spawn prompt", + "approach": "Inject formal_coverage_auto_detection, solution-simulation-loop, and debug_context constraint blocks into the Pattern A nf-executor spawn prompt in execute-plan.md so nested child executors inherit both verification loops.", + "out_of_scope": [ + "Implementation of Loop modules (already exist)", + "Changes to Pattern B, C, or D routing", + "Loop 1 debug routing integration (already handled at orchestrator level)" + ], + "classification": { + "type": "feature", + "confidence": 0.85, + "routed_through_debug": false + }, + "risk_level": "high", + "risk_reason": "Workflow file modification (execute-plan.md) — guardrail-protected", + "branches_affected": ["nf/quick-362-wire-debug-routing-into-execute-phase-md"], + "created_at": "2026-03-27T13:46:18.360Z", + "planner_model": "inherit", + "created_by": "quick-orchestrator" + } +}