Resume mapping: treat a valid no-code-change.json as implement-complete evidence #308

Open
opened 2026-09-05 18:35:50 +00:00 by david · 0 comments
Owner

Summary

Teach resume that a valid no-code-change.json means the implement stage completed, so after a fatal comment-post failure the run resumes at review — never re-running the implement LLM — and the short-circuit re-fires to (re)post or skip per the marker (ADR-021 §7).

Background

Depends on: #306

The no-code-change path never writes implementation.diff and never creates a Pi-Loop-Stage: 1 commit, so today's resume machinery falls back to artifact detection and would resume at implement — re-invoking the LLM unnecessarily. The fix mirrors the existing isMrStageComplete pattern: treat the no-code-change artifact as implement-complete evidence.

A fatal comment failure writes error.json and no mr-result.json, which already marks the run incomplete (src/run/services/findIncompleteRun.tsno change needed).

Expected resume trace after this change: fatal comment failure → error.json written → resume detects implement complete via no-code-change.json; review/remediate/docs/mr artifacts absent → resume at review (the first stage after implement); pipeline logic skips implement via defaultSkippedImplementResult (which re-reads the artifact) → short-circuit re-fires → marker check: absent → post; present → skip → ok: true.

Implementation Details

  • In src/run/services/determineResumeStage.ts:

    1. Add isImplementStageComplete(runDir): boolean — mirroring isMrStageComplete: returns true when implementation.diff is valid or no-code-change.json is present and valid (a readNoCodeChangeSignal-style check). A valid artifact means implement finished with its no-code verdict — there is nothing to re-run.
    2. Use it for the implement entry wherever the map/isArtifactValid is consulted: in determineResumeStartStage (iterate past implement when its diff is missing but the artifact is valid) and in the allArtifactsValid pre-check inside determineResumeStageWithGit.
    3. No git-trailer involvement: the no-code-change path makes no commit, so findLastStageCommit(IMPLEMENT_STAGE) stays absent and the resume result carries lastStageCommitSha: undefined (working tree trusted as-is — it is clean by construction on this path).
  • src/run/services/findIncompleteRun.ts: no change.

Acceptance Criteria

  • determineResumeStartStage with implementation.diff absent + no-code-change.json valid → resumes at review, not implement.
  • The same fixture through determineResumeStageWithGit (no stage commits) → { resumeFromStage: 'review', lastStageCommitSha: undefined }.
  • Regression: normal implement runs (diff present, no artifact) still resume per the existing map.
  • A malformed no-code-change.json does NOT count as implement-complete (still resumes at implement).
  • Tests added in src/run/services/determineResumeStage.test.ts; all existing resume tests still pass.

Test Plan

  • Unit tests per above; then npm test and npm run lint.
## Summary Teach resume that a valid `no-code-change.json` means the implement stage completed, so after a fatal comment-post failure the run resumes at `review` — never re-running the implement LLM — and the short-circuit re-fires to (re)post or skip per the marker (ADR-021 §7). ## Background **Depends on:** #306 The no-code-change path never writes `implementation.diff` and never creates a `Pi-Loop-Stage: 1` commit, so today's resume machinery falls back to artifact detection and would resume at `implement` — re-invoking the LLM unnecessarily. The fix mirrors the existing `isMrStageComplete` pattern: treat the no-code-change artifact as implement-complete evidence. A fatal comment failure writes `error.json` and no `mr-result.json`, which already marks the run incomplete (`src/run/services/findIncompleteRun.ts` — **no change needed**). **Expected resume trace after this change:** fatal comment failure → `error.json` written → resume detects implement complete via `no-code-change.json`; review/remediate/docs/mr artifacts absent → resume at `review` (the first stage after implement); pipeline logic skips implement via `defaultSkippedImplementResult` (which re-reads the artifact) → short-circuit re-fires → marker check: absent → post; present → skip → `ok: true`. ## Implementation Details - In `src/run/services/determineResumeStage.ts`: 1. Add `isImplementStageComplete(runDir): boolean` — mirroring `isMrStageComplete`: returns `true` when `implementation.diff` is valid **or** `no-code-change.json` is present and valid (a `readNoCodeChangeSignal`-style check). A valid artifact means implement finished with its no-code verdict — there is nothing to re-run. 2. Use it for the `implement` entry wherever the map/`isArtifactValid` is consulted: in `determineResumeStartStage` (iterate past `implement` when its diff is missing but the artifact is valid) and in the `allArtifactsValid` pre-check inside `determineResumeStageWithGit`. 3. No git-trailer involvement: the no-code-change path makes no commit, so `findLastStageCommit(IMPLEMENT_STAGE)` stays absent and the resume result carries `lastStageCommitSha: undefined` (working tree trusted as-is — it is clean by construction on this path). - `src/run/services/findIncompleteRun.ts`: no change. ## Acceptance Criteria - [ ] `determineResumeStartStage` with `implementation.diff` absent + `no-code-change.json` valid → resumes at `review`, not `implement`. - [ ] The same fixture through `determineResumeStageWithGit` (no stage commits) → `{ resumeFromStage: 'review', lastStageCommitSha: undefined }`. - [ ] Regression: normal implement runs (diff present, no artifact) still resume per the existing map. - [ ] A malformed `no-code-change.json` does NOT count as implement-complete (still resumes at `implement`). - [ ] Tests added in `src/run/services/determineResumeStage.test.ts`; all existing resume tests still pass. ## Test Plan - Unit tests per above; then `npm test` and `npm run lint`.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-loop#308
No description provided.