"version": 3,
"timestamp": "2026-03-23T04:35:25Z",
"hash": "sha256:00849a381798f3f2c75741676d02a37c6fd1e58205a031eca0b0a9132714d109",
"changes_summary": "\nv2 \u2192 v3 changes (3 targeted fixes per user directives):\n\n1. resolve-workflow flag \u2192 plan-state marker: Replaced the workflow_plan_resolved parameter on reconcile_plan() and sync_triage_needed() with a marker written to plan[\"refresh_state\"][\"workflow_plan_just_resolved\"] by resolve_workflow before calling reconcile. sync_triage_needed reads and clears the marker from plan state. Reconcile stays purely state-driven \u2014 no function parameters carry command context. Removed workflow_plan_resolved parameter from both function signatures.\n\n2. living_plan.py Pattern B \u2192 Pattern A: Eliminated Pattern B entirely. All 5 invalidation sites now use the same Pattern A (invalidate + conditional reconcile). Added implementation audit note for _reconcile_if_queue_drained redundancy in living_plan.py.\n\n3. Dropped pipeline-to-snapshot adapter: Removed Step 1's rewrite of _resolve_reconcile_display_phase. Both derivation functions stay as-is. Added equivalence test (Step 4) that verifies pipeline and snapshot produce the same display phase for a matrix of plan states. Updated Design Principle 3 to document the "two paths, one invariant" approach.\n",
"flags_addressed": [
"resolve-workflow-still-advances-pipeline-outside-reconcile",
"invalidation-sites-need-site-specific-reconcile-plumbing",
"pipeline-snapshot-adapter-is-not-equivalent"
],
"questions": [],
"success_criteria": [
"_set_lifecycle_phase is called from exactly ONE location: reconcile_plan() in pipeline.py (verified by grep)",
"refresh_state['lifecycle_phase'] is never written directly outside _set_lifecycle_phase, except for the one-shot migration in current_lifecycle_phase (verified by grep-based test)",
"resolve_workflow.py:_reconcile_if_queue_drained no longer contains any direct set_lifecycle_phase or inject_triage_stages call \u2014 it writes a plan-state marker and calls reconcile_plan()",
"reconcile_plan() has no command-context parameters \u2014 it derives all behavior from plan + state dicts",
"invalidate_postflight_scan (formerly clear_postflight_scan_completion) only clears the scan marker \u2014 no lifecycle_phase write",
"All 5 invalidation sites use Pattern A uniformly (invalidate + conditional reconcile)",
"Equivalence test verifies pipeline and snapshot derivation agree for a matrix of plan states",
"All existing tests pass with no behavioral changes",
"New test: resolving WORKFLOW_CREATE_PLAN_ID with open reviews produces mode='plan' with triage stages via plan-state marker + reconcile",
"New test: workflow_plan_just_resolved marker is cleared after consumption by sync_triage_needed",
"New test: skip/unskip/backlog/reopen/resolve produce correct lifecycle transitions via reconcile after invalidation",
"New test: grep-based enforcement that no production code writes lifecycle_phase outside _set_lifecycle_phase + migration"
],
"assumptions": [
"The two persisted modes (plan/execute) are sufficient. Enforcement via _ prefix + removing all callers is appropriate for an internal tool with no backward compat guarantees.",
"The one-shot data migration write in current_lifecycle_phase() is exempt from the single-writer rule \u2014 it fires once per legacy state file on first read, then persists.",
"ensure_active_triage_issue_ids belongs in engine/_plan/triage/ (pure plan/state manipulation), not in app/commands/. Moving it fixes the import direction violation.",
"Pipeline and snapshot derivation functions produce equivalent results because sync preconditions ensure the same items in both representations \u2014 this is validated by test, not structural unification.",
"Performance of adding reconcile_plan() calls to all 5 invalidation sites is acceptable \u2014 these are interactive CLI commands.",
"The workflow_plan_just_resolved marker in refresh_state is safe to persist transiently \u2014 sync_triage_needed clears it after consumption, so it never survives to a subsequent reconcile call."
],
"delta_from_previous_percent": 64.96
}
"passed": true,
"criteria_check": {
"count": 12,
"items": [
"_set_lifecycle_phase is called from exactly ONE location: reconcile_plan() in pipeline.py (verified by grep)",
"refresh_state['lifecycle_phase'] is never written directly outside _set_lifecycle_phase, except for the one-shot migration in current_lifecycle_phase (verified by grep-based test)",
"resolve_workflow.py:_reconcile_if_queue_drained no longer contains any direct set_lifecycle_phase or inject_triage_stages call \u2014 it writes a plan-state marker and calls reconcile_plan()",
"reconcile_plan() has no command-context parameters \u2014 it derives all behavior from plan + state dicts",
"invalidate_postflight_scan (formerly clear_postflight_scan_completion) only clears the scan marker \u2014 no lifecycle_phase write",
"All 5 invalidation sites use Pattern A uniformly (invalidate + conditional reconcile)",
"Equivalence test verifies pipeline and snapshot derivation agree for a matrix of plan states",
"All existing tests pass with no behavioral changes",
"New test: resolving WORKFLOW_CREATE_PLAN_ID with open reviews produces mode='plan' with triage stages via plan-state marker + reconcile",
"New test: workflow_plan_just_resolved marker is cleared after consumption by sync_triage_needed",
"New test: skip/unskip/backlog/reopen/resolve produce correct lifecycle transitions via reconcile after invalidation",
"New test: grep-based enforcement that no production code writes lifecycle_phase outside _set_lifecycle_phase + migration"
]
},
"preflight_results": {
"project_dir_exists": true,
"project_dir_writable": true,
"success_criteria_present": true,
"claude_available": true,
"codex_available": true
},
"unresolved_flags": [
{
"id": "invalidation-sites-need-site-specific-reconcile-plumbing",
"concern": "The plan still does not fully resolve living_plan.py. Pattern A fixes the stale-mode problem, but the writeup leaves the existing queue-drain reconcile/progression path as an implementation audit instead of specifying the new single flow.",
"category": "correctness",
"severity_hint": "likely-significant",
"evidence": "In the current repo, _reconcile_if_queue_drained() is not just a phase helper in practice; it is what drives the queue_drained branch that gates maybe_append_execution_drain() and maybe_append_entered_planning() in desloppify/app/commands/resolve/living_plan.py:137-164. v3 now adds an unconditional reconcile at the invalidation site but only says _reconcile_if_queue_drained 'may become redundant' and should be audited. That still leaves a real ambiguity: either you reconcile twice, or you remove the helper and risk changing when progression events fire.",
"raised_in": "critique_v3.json",
"status": "open",
"severity": "significant",
"verified": false,
"addressed_in": "plan_v3.md"
},
{
"id": "engine-triage-kickoff-boundary-is-underplanned",
"concern": "Scope creep: Step 2 understates the engine/app refactor required for engine-owned triage kickoff. The repository does not currently have engine-level helpers for the full kickoff path the plan wants sync_triage_needed() to perform.",
"category": "maintainability",
"severity_hint": "likely-significant",
"evidence": "sync_triage_needed() lives in desloppify/engine/_plan/sync/triage.py, but the full kickoff helper it wants to call, inject_triage_stages(), exists only in desloppify/app/commands/plan/triage/stage_queue.py:31. The helper the plan proposes moving, ensure_active_triage_issue_ids(), also currently depends on ensure_triage_meta() from desloppify/app/commands/plan/triage/plan_state_access.py:46. v3 only plans to move ensure_active_triage_issue_ids, not the rest of the command-layer machinery that functionally participates in kickoff, so the stated file/work breakdown is incomplete: either engine will import app code, or more helpers need to move/create engine equivalents than the plan currently admits.",
"raised_in": "critique_v3.json",
"status": "open",
"severity": "significant",
"verified": false
}
],
"recommendation": "PROCEED",
"rationale": "Both remaining flags are implementation-level concerns with clear, mechanical resolutions \u2014 not design issues that require plan revision.\n\nFlag 1 (living_plan.py double-reconcile): _reconcile_if_queue_drained already calls reconcile_plan() and exists primarily to gate progression events (maybe_append_execution_drain, maybe_append_entered_planning) on queue drain. With Pattern A added at the invalidation site, the implementation fix is: Pattern A's reconcile handles phase derivation; simplify _reconcile_if_queue_drained to just check live_planned_queue_empty(plan) for the progression gate and skip its own reconcile call if Pattern A already reconciled. This avoids double-reconcile while preserving progression event semantics. ~5 lines of change, no design ambiguity.\n\nFlag 2 (engine-triage-kickoff helpers): Verified the full dependency chain. inject_triage_stages depends on 3 trivial dict initializers (ensure_queue_order, ensure_skipped_map, clear_triage_stage_skips \u2014 each ~3 lines of plan.setdefault(...) or dict pops) plus two functions already in engine (TRIAGE_STAGE_IDS, normalize_queue_workflow_and_triage_prefix). ensure_active_triage_issue_ids depends on ensure_triage_meta (another ~3-line initializer) and coverage_open_ids (already in engine). Moving these to engine is ~30 lines of pure dict manipulation with no app-layer dependencies. The plan underestimates the helper count but the work is mechanical with zero design risk.\n\nScore trajectory 8.25 \u2192 6.0 \u2192 2.75 shows strong convergence. Five flags resolved across 3 iterations. The two remaining flags would not benefit from another plan revision \u2014 they're better resolved during implementation where the implementer can see the exact code.",
"signals_assessment": "Iteration 3. Score trajectory 8.25 \u2192 6.0 \u2192 2.75 (strong downward trend). Plan deltas: 83.2%, 65.0% (converging). Zero recurring critiques across iterations. Five flags resolved, 2 remaining \u2014 both are implementation-detail level (living_plan.py double-reconcile avoidance, engine helper migration scope). No scope creep in the core plan; the scope-creep flag on engine-triage-kickoff is about underestimating mechanical work, not expanding design scope. Preflight all green. All 12 success criteria are well-defined and testable.",
"warnings": [
"Scope creep detected: the plan appears to be expanding beyond the original idea or recorded user notes.",
"When implementing Step 3 for living_plan.py, avoid double-reconcile: if Pattern A's reconcile already ran (invalidation returned True), simplify _reconcile_if_queue_drained to only check live_planned_queue_empty for progression event gating, skipping its own reconcile_plan() call.",
"Step 2's engine migration is larger than listed: inject_triage_stages + ensure_active_triage_issue_ids + 4 trivial helpers (ensure_queue_order, ensure_skipped_map, clear_triage_stage_skips, ensure_triage_meta) all need to move from app/commands/plan/triage/ to engine/_plan/triage/. Total ~30 lines of dict manipulation.",
"The colorize import in stage_queue.py (line 7) is not used by inject_triage_stages \u2014 verify it can be dropped when moving the function to engine."
],
"override_forced": false,
"orchestrator_guidance": "Plan passed gate and preflight. Proceed to execute. Verify unresolved flags against the plan and project code before accepting. Scope creep detected; compare the current plan against the original idea.",
"robustness": "standard",
"signals": {
"iteration": 3,
"idea": "Make unintentional deviation from the lifecycle impossible. Current state: 2 modes (plan/execute) work, but there are 5 ways to deviate: 1) resolve_workflow.py:368 is a side-channel that directly calls inject_triage_stages + set_lifecycle_phase outside reconcile. 2) clear_postflight_scan_completion called from 4 scattered places with inconsistent aftermath handling. 3) Snapshot and reconcile have separate phase derivation paths that can disagree. 4) synthetic.py does its own phase checking. 5) Nothing prevents adding new phases via set_lifecycle_phase. Fix: single reconcile entry point, single derivation function, explicit state machine with typed transitions. The plan-mode pipeline (scan -> review -> score -> triage) should be enforced by the state machine, not by hoping sync preconditions happen to gate correctly.",
"significant_flags": 2,
"unresolved_flags": [
{
"id": "invalidation-sites-need-site-specific-reconcile-plumbing",
"concern": "The plan still does not fully resolve living_plan.py. Pattern A fixes the stale-mode problem, but the writeup leaves the existing queue-drain reconcile/progression path as an implementation audit instead of specifying the new single flow.",
"category": "correctness",
"severity": "significant",
"status": "open"
},
{
"id": "engine-triage-kickoff-boundary-is-underplanned",
"concern": "Scope creep: Step 2 understates the engine/app refactor required for engine-owned triage kickoff. The repository does not currently have engine-level helpers for the full kickoff path the plan wants sync_triage_needed() to perform.",
"category": "maintainability",
"severity": "significant",
"status": "open"
}
],
"resolved_flags": [
{
"id": "state-machine-not-actually-enforced",
"concern": "The plan does not actually make lifecycle deviation impossible. It explicitly rejects the requested explicit state machine / typed transitions and instead relies on a private rename of the setter, which is only a convention.",
"resolution": "\nv1 \u2192 v2 changes:\n\n1. Flag 1 (state-machine-not-enforced) \u2014 DOWNGRADED. _ prefix + eliminating all callers is sufficient for an internal tool. No formal state machine class. Justification added to Design Principles.\n\n2. Flag 2 (single-writer-exemption) \u2014 DOWNGRADED. One-shot data migration in current_lifecycle_phase() is a data fixup, not a control flow side-channel. Explicitly called out as exempt in Design Principles.\n\n3. Flag 3 (resolve-workflow side-channel) \u2014 FIXED. Investigation confirmed sync_triage_needed() does NOT cover the trigger (it uses hash-change detection, not workflow resolution). Fix: push the full triage kickoff logic INTO sync_triage_needed() via workflow_plan_resolved=True parameter. ensure_active_triage_issue_ids moves from app/ to engine/. resolve_workflow.py's entire special-case branch is deleted \u2014 it just calls reconcile_plan(..., workflow_plan_resolved=True).\n\n4. Flag 4 (scope-creep derivation) \u2014 FIXED. No new derive_display_phase in refresh_lifecycle.py. Instead: make snapshot.py's _derive_display_phase public, have pipeline.py translate its data and call it. Snapshot remains the single canonical owner.\n\n5. Flag 5 (invalidation sites) \u2014 ADDRESSED with site-specific handling. Pattern A (no existing reconcile: skip/unskip/backlog/reopen) adds conditional reconcile after invalidation. Pattern B (living_plan.py, already has reconcile) just calls invalidation before existing reconcile. Audit items documented for state freshness in skip.py.\n"
},
{
"id": "single-writer-exemption-for-read-migration",
"concern": "The plan's stated single-writer goal is internally inconsistent because it still allows a non-state-machine read path to write lifecycle state.",
"resolution": "\nv1 \u2192 v2 changes:\n\n1. Flag 1 (state-machine-not-enforced) \u2014 DOWNGRADED. _ prefix + eliminating all callers is sufficient for an internal tool. No formal state machine class. Justification added to Design Principles.\n\n2. Flag 2 (single-writer-exemption) \u2014 DOWNGRADED. One-shot data migration in current_lifecycle_phase() is a data fixup, not a control flow side-channel. Explicitly called out as exempt in Design Principles.\n\n3. Flag 3 (resolve-workflow side-channel) \u2014 FIXED. Investigation confirmed sync_triage_needed() does NOT cover the trigger (it uses hash-change detection, not workflow resolution). Fix: push the full triage kickoff logic INTO sync_triage_needed() via workflow_plan_resolved=True parameter. ensure_active_triage_issue_ids moves from app/ to engine/. resolve_workflow.py's entire special-case branch is deleted \u2014 it just calls reconcile_plan(..., workflow_plan_resolved=True).\n\n4. Flag 4 (scope-creep derivation) \u2014 FIXED. No new derive_display_phase in refresh_lifecycle.py. Instead: make snapshot.py's _derive_display_phase public, have pipeline.py translate its data and call it. Snapshot remains the single canonical owner.\n\n5. Flag 5 (invalidation sites) \u2014 ADDRESSED with site-specific handling. Pattern A (no existing reconcile: skip/unskip/backlog/reopen) adds conditional reconcile after invalidation. Pattern B (living_plan.py, already has reconcile) just calls invalidation before existing reconcile. Audit items documented for state freshness in skip.py.\n"
},
{
"id": "resolve-workflow-still-advances-pipeline-outside-reconcile",
"concern": "The plan still leaves reconcile driven by out-of-band command context. Replacing the manual branch with a workflow_plan_resolved parameter is not a real fix for the side-channel; it just moves the side-channel into the reconcile API.",
"resolution": "\nv2 \u2192 v3 changes (3 targeted fixes per user directives):\n\n1. resolve-workflow flag \u2192 plan-state marker: Replaced the workflow_plan_resolved parameter on reconcile_plan() and sync_triage_needed() with a marker written to plan[\"refresh_state\"][\"workflow_plan_just_resolved\"] by resolve_workflow before calling reconcile. sync_triage_needed reads and clears the marker from plan state. Reconcile stays purely state-driven \u2014 no function parameters carry command context. Removed workflow_plan_resolved parameter from both function signatures.\n\n2. living_plan.py Pattern B \u2192 Pattern A: Eliminated Pattern B entirely. All 5 invalidation sites now use the same Pattern A (invalidate + conditional reconcile). Added implementation audit note for _reconcile_if_queue_drained redundancy in living_plan.py.\n\n3. Dropped pipeline-to-snapshot adapter: Removed Step 1's rewrite of _resolve_reconcile_display_phase. Both derivation functions stay as-is. Added equivalence test (Step 4) that verifies pipeline and snapshot produce the same display phase for a matrix of plan states. Updated Design Principle 3 to document the "two paths, one invariant" approach.\n"
},
{
"id": "scope-creep-new-phase-derivation-layer",
"concern": "Scope creep: Step 1 adds a new shared phase-derivation layer in refresh_lifecycle.py instead of reusing the repository's existing canonical snapshot phase logic.",
"resolution": "\nv1 \u2192 v2 changes:\n\n1. Flag 1 (state-machine-not-enforced) \u2014 DOWNGRADED. _ prefix + eliminating all callers is sufficient for an internal tool. No formal state machine class. Justification added to Design Principles.\n\n2. Flag 2 (single-writer-exemption) \u2014 DOWNGRADED. One-shot data migration in current_lifecycle_phase() is a data fixup, not a control flow side-channel. Explicitly called out as exempt in Design Principles.\n\n3. Flag 3 (resolve-workflow side-channel) \u2014 FIXED. Investigation confirmed sync_triage_needed() does NOT cover the trigger (it uses hash-change detection, not workflow resolution). Fix: push the full triage kickoff logic INTO sync_triage_needed() via workflow_plan_resolved=True parameter. ensure_active_triage_issue_ids moves from app/ to engine/. resolve_workflow.py's entire special-case branch is deleted \u2014 it just calls reconcile_plan(..., workflow_plan_resolved=True).\n\n4. Flag 4 (scope-creep derivation) \u2014 FIXED. No new derive_display_phase in refresh_lifecycle.py. Instead: make snapshot.py's _derive_display_phase public, have pipeline.py translate its data and call it. Snapshot remains the single canonical owner.\n\n5. Flag 5 (invalidation sites) \u2014 ADDRESSED with site-specific handling. Pattern A (no existing reconcile: skip/unskip/backlog/reopen) adds conditional reconcile after invalidation. Pattern B (living_plan.py, already has reconcile) just calls invalidation before existing reconcile. Audit items documented for state freshness in skip.py.\n"
},
{
"id": "pipeline-snapshot-adapter-is-not-equivalent",
"concern": "The Step 1 adapter is still not a safe way to unify derivation. It assumes reconcile only runs at boundaries and that snapshot inputs can be reconstructed from queue prefixes, but the repository's actual snapshot logic is more nuanced than that.",
"resolution": "\nv2 \u2192 v3 changes (3 targeted fixes per user directives):\n\n1. resolve-workflow flag \u2192 plan-state marker: Replaced the workflow_plan_resolved parameter on reconcile_plan() and sync_triage_needed() with a marker written to plan[\"refresh_state\"][\"workflow_plan_just_resolved\"] by resolve_workflow before calling reconcile. sync_triage_needed reads and clears the marker from plan state. Reconcile stays purely state-driven \u2014 no function parameters carry command context. Removed workflow_plan_resolved parameter from both function signatures.\n\n2. living_plan.py Pattern B \u2192 Pattern A: Eliminated Pattern B entirely. All 5 invalidation sites now use the same Pattern A (invalidate + conditional reconcile). Added implementation audit note for _reconcile_if_queue_drained redundancy in living_plan.py.\n\n3. Dropped pipeline-to-snapshot adapter: Removed Step 1's rewrite of _resolve_reconcile_display_phase. Both derivation functions stay as-is. Added equivalence test (Step 4) that verifies pipeline and snapshot produce the same display phase for a matrix of plan states. Updated Design Principle 3 to document the "two paths, one invariant" approach.\n"
}
],
"weighted_score": 2.75,
"weighted_history": [
8.25,
6.0
],
"plan_delta_from_previous": 64.96,
"recurring_critiques": [],
"scope_creep_flags": [
"engine-triage-kickoff-boundary-is-underplanned"
],
"loop_summary": "Iteration 3. Weighted score trajectory: 8.25 -> 6.0 -> 2.75. Plan deltas: 83.2%, 65.0%. Recurring critiques: 0. Resolved flags: 5. Open significant flags: 2."
}
}