Skip to content

Infra failure handling: an analyzer that cannot run never reports clean #113

In review

Description

@Aqil-Ahmad

Files:

  • packages/core/src/analyzers/analyzer.ts
  • packages/daemon/src/scheduler/run-pipeline.ts and scheduler/index.ts
  • packages/daemon/src/check.ts, and the CLI's status / check rendering if a pair's state is shown wrongly
  • their tests, under packages/core/test/ and packages/daemon/test/
  • docs/architecture.md (the data-flow invariant on infra failures)
  • plan_docs/milestones/m3-sandbox-typecheck-build.md
  • plan_docs/log.md

Prerequisite. None beyond dev: the sandbox runner (#86), toolchain detection (#87), the typecheck runner (#88) and the baseline differ (#93) are merged. This does not need the attribution engine (#94).

What. The rule is in analyzer.ts and in CLAUDE.md: an analyzer that cannot run returns infra-failure, an infra failure is never shown to a user as a conflict, and an analyzer that cannot run must never report clean. Today the rule is honoured where it was written — the textual analyzer, the typecheck registry's outcomes, the baseline differ's unavailable — but the pipeline around analyzers does not enforce it, and the analyzers that are about to join (typecheck, build) will lean on it. Make it a property of the pipeline, not a convention each analyzer has to remember, for each environmental failure M3 names: Docker down, image missing, toolchain unknown, a timeout, and dependencies unavailable because the lockfile changed.

Acceptance.

  • Each named failure is infra-failure, with a remedy, and never a Finding:

    • Docker not running or not reachable (SANDBOX_UNAVAILABLE);
    • the sandbox image missing (SANDBOX_UNAVAILABLE, as the runner reports no such image);
    • the toolchain not one Interlock handles (TOOLCHAIN_UNSUPPORTED);
    • dependencies unavailable: a clean merge whose slot is null because its dependency files differ from the installed tree, for an analyzer that needs the slot.

    Each has a test that drives it through runPipeline, not only through the analyzer, and asserts no Finding is written, no open Finding is resolved, and the run is recorded failed with the component and the redacted diagnostic.

  • A thrown infrastructure error is an infra failure. An analyzer that throws an InterlockError with infra: true from analyze is recorded as infra-failure for that analyzer, the same as one that returned it. A throw that is not infrastructure — a bug — still fails the run loudly and is never turned into infra-failure or clean.

  • A timeout never reads as clean. A timeout verdict is neither cached (the store already refuses it) nor treated as having judged the content: the pair is not marked analysed at that content, so it is run again rather than left looking finished, and nothing a user sees calls it clean. Today a run with a timeout verdict finishes complete and its content key goes into analysedAt; check whether that leaves the pair unretried until a branch moves, and fix it if so, with a test.

  • What the user sees. interlock check A B and interlock status show a pair whose last run could not judge it as "could not check" with the reason and the remedy — never as clean, never as a conflict. A test per surface.

  • Retries. An infra failure backs off and retries, as land already does; a test shows a failure that clears (Docker comes back) leads to a real verdict without a branch moving.

  • No analyzer has to remember the rule. A test analyzer that returns clean with a null slot on a clean merge, for a kind that needs one, is caught by the pipeline rather than trusted — or the contract makes that impossible to express. Choose one and record why.

Constraints.

  • When a check is unsure, it says nothing — and nothing is not clean. The direction of every ambiguity here is toward infra-failure, never toward clean.
  • Environmental failures are never Findings (CLAUDE.md). None of this adds a Finding kind or rule.
  • Models are wire formats. AnalyzerVerdict and AnalyzerResult already carry infra-failure, timeout and a redacted diagnostic. A new field means a store migration and needs a reason in the log.
  • Redaction. A diagnostic carries paths and tool output; it goes through the existing redaction before it is stored or printed.
  • Hard rule 5. No test is weakened to make room.

Approach

Where the rule lives. Read the loop in run-pipeline.ts that runs each analyzer: an infra-failure outcome already ends the run as failed, but a throw from analyze is not caught there, and a timeout outcome is pushed onto ran like a verdict. Decide the one place the pipeline turns an analyzer's result into "judged" or "not judged", and make every path go through it.

The slot. AnalyzerContext.slot is null for a conflicted merge and for a pair whose dependencies differ from the installed tree. An analyzer that needs real files and is handed null on a clean merge cannot run. Say so in the contract (a needsSlot-style declaration, or a helper every slot analyzer calls), so the next analyzer cannot get it wrong by returning clean.

The surfaces. Follow an infra failure from land in scheduler/index.ts to what check and status render. check.ts already throws ANALYZER_INFRA_FAILURE for a run that failed; check what status shows for a pair whose newest run failed, and whether a pair that last ran clean and then failed shows its old clean result.

Cases to cover:

  • each of the four named failures, through runPipeline;
  • a thrown infra error, and a thrown bug;
  • a timeout, and that the pair is run again;
  • a failure that clears on retry;
  • an open Finding from an earlier run, followed by an infra failure: the Finding stays open, neither resolved nor duplicated.

Method

  • Read first. Read CLAUDE.md and follow it. Then read:
    • packages/core/src/analyzers/analyzer.ts, textual.ts, and the outcome kinds in typecheck.ts and baseline.ts;
    • packages/daemon/src/scheduler/run-pipeline.ts, the analyzer loop, reconcileFindings and the verdict cache;
    • packages/daemon/src/scheduler/index.ts, land and backOff;
    • packages/daemon/src/check.ts;
    • packages/shared/src/models/speculative-run.ts and packages/shared/src/errors.ts.
  • Load the skill: .claude/skills/interlock-git before writing tests that build repositories.
  • Expand the task first. Rewrite the "Infra failure handling" task in plan_docs/milestones/m3-sandbox-typecheck-build.md to the depth of m1-watcher-and-git-core.md. Record the rewrite in the log.
  • Branch and commits. Branch off dev, named infraFailures. Single-line commit subjects, no body, no Co-Authored-By or session trailers. Don't push.
  • Test isolation. Docker being down is produced with an injected runner or a DOCKER_HOST pointing nowhere, never by stopping the developer's Docker. Fixture repositories in temp directories, cleaned up in afterEach.
  • Mutation-test the judged / not-judged decision, the timeout path and the slot rule, with a disposable harness that refuses a dirty tree, applies one mutation at a time and restores with git checkout --. A survivor that would let an unrun analyzer read as clean is a missing test, never an equivalent.
  • Coverage floors in vitest.config.ts only go up. pnpm verify green, plus pnpm test:untouched.
  • Docs and log. Comments explain why, never what. Tick the task in the same change. One log line per decision. A CHANGELOG entry if check or status output changes.
  • Expect review rounds. Verify each finding against the code, and record what you rejected and why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions