Skip to content

Doctor mutation-scope repair - #283

Merged
davidabram merged 18 commits into
doctor-mutation-scopefrom
doctor-mutation-scope-fix
Sep 30, 2026
Merged

davidabram merged 18 commits into
doctor-mutation-scopefrom
doctor-mutation-scope-fix

Conversation

@davidabram

Copy link
Copy Markdown
Member

No description provided.

@davidabram
davidabram added this pull request to stack #240 September 20, 2026 19:27
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch 14 times, most recently from 390413f to 888f067 Compare September 21, 2026 21:33
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch 2 times, most recently from 66210be to eabd527 Compare September 29, 2026 12:10
davidabram and others added 13 commits September 29, 2026 21:50
Define the staged implementation plan for safely repairing blocked mutation-scope states through adapter-owned recovery protocols and positive owner evidence. The plan sequences formalization, shared process-owner extraction, adapter repairs, doctor orchestration, rendering, and cross-adapter validation while preserving fail-closed behavior.

Plan: doctor-mutation-scope-fix
Tasks: T01-T07

Co-authored-by: SCE <sce@crocoder.dev>
Move the large inline hook and setup test suites into focused sibling modules so production modules remain easier to navigate. Split Pi mutation-scope coverage by lifecycle, guard reconciliation, and runtime seams while preserving the existing behavioral coverage.

Co-authored-by: SCE <sce@crocoder.dev>
Split installation and prompting implementations from the setup module into dedicated files, keeping the orchestration module focused on shared setup state and APIs. Preserve existing setup behavior while making the service easier to navigate and maintain.
Split the monolithic hooks implementation into dedicated modules for runtime helpers, commit hooks, conversation traces, diff traces, and Claude transforms. Keep the public hook dispatch surface stable while isolating related helpers and tests.

Co-authored-by: SCE <sce@crocoder.dev>
Separate event parsing, lifecycle orchestration, and payload rendering for the Claude, Codex, and Pi adapters. This keeps adapter entry points small while preserving their existing behavior and makes each concern easier to test and evolve.

Co-authored-by: SCE <sce@crocoder.dev>
Prevent concurrent tool failures and cleanup errors from misattributing mutations by separating hook parsing, lifecycle dispatch, payload construction, and coverage.
Track per-call cleanup state, consume ambiguous intervals with recovery barriers, preserve sibling scopes, and fail closed until recovery succeeds.

Co-authored-by: SCE <sce@crocoder.dev>
Formalize the safe doctor-repair lifecycle and its safety invariants so concurrent hook activity, owner evidence, and interrupted recovery are checkable before implementation. Add executable Quint scenarios covering ordinary abandonment, dead-owner repair, stale diagnoses, retries, and non-resurrection.

Implements T01 of `doctor-mutation-scope-fix`.

Co-authored-by: SCE <sce@crocoder.dev>
Move ProcessOwner and conservative liveness checks into an adapter-neutral hooks module so other hook adapters can reuse positive process-death evidence. Repoint Pi mutation-scope imports and update the affected context and plan records while preserving behavior and persisted owner data.

Plan: doctor-mutation-scope-fix (T02)

Co-authored-by: SCE <sce@crocoder.dev>
Prevent orphaned OpenCode mutation-scope attempts from remaining permanently
blocked without positive owner-death evidence. Persist backward-compatible owner
metadata, re-prove dead owners under the adapter locks, and reuse the existing
recovery sequence while refusing live-owner and concurrent-race repairs. Leave
doctor wiring for T05.

Plan: doctor-mutation-scope-fix.md (T03)

Co-authored-by: SCE <sce@crocoder.dev>
Persist PendingAbandon before Claude cleanup seam calls so interrupted cleanup can be safely retried without confusing live attempts with established abandon intent. Add batch marking, lock-protected re-proofing, repair behavior, regression coverage, and the corresponding context updates.

Plan: doctor-mutation-scope-fix.md (T04)

Co-authored-by: SCE <sce@crocoder.dev>
Resolve the containing worktree before locating Git metadata so snapshots created from nested directories apply repository-level gitignore rules correctly. Add regression coverage to ensure ignored files under a nested directory stay out of captured trees.

Co-authored-by: SCE <sce@crocoder.dev>
Enable `sce doctor --fix` to repair blocked Claude and OpenCode Agent-tracing state only when adapter-owned repairability checks prove it safe. Dispatch repairs through the production mutation-scope seam and record success only after fresh health confirms healthy or recovering, while leaving manual-only states untouched.

Plan: doctor-mutation-scope-fix.md (T05)

Co-authored-by: SCE <sce@crocoder.dev>
Blocked mutation-scope health was reported as manual-only even when the owning adapter proved automatic recovery safe, and manual remediation was not rendered consistently across doctor surfaces.

Use adapter-owned repairability to select fixability, next action, and remediation; thread that text through human rows and fix results while preserving the existing JSON health-array schema. Add regressions for auto-fixable and manual-only states, including real state paths and no-delete guidance.

Plan: doctor-mutation-scope-fix.md (T06)

Co-authored-by: SCE <sce@crocoder.dev>
davidabram and others added 3 commits September 29, 2026 21:50
Ensure attempted mutation-scope targets have exactly one fix result, even when a repair ends in a manually recoverable Blocked or Invalid state. Link mutation-scope problems to their targets and exclude attempted targets from the generic manual-result path while preserving never-attempted and unrelated manual diagnostics.

Add aggregation regressions covering healthy, recovering, blocked, invalid, and never-attempted outcomes. Record the ownership correction in the doctor mutation-scope plan.

Plan: doctor-mutation-scope-fix (T06)

Co-authored-by: SCE <sce@crocoder.dev>
Exercise the full doctor diagnosis and fix pipeline with Claude and OpenCode states together, proving that an auto-fixable target is repaired while a manual-only target remains safely blocked. Document the corresponding Quint safety invariants and map them to the adapter regression tests.

Plan: doctor-mutation-scope-fix (T07)

Co-authored-by: SCE <sce@crocoder.dev>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from eabd527 to 58c0bff Compare September 29, 2026 19:50
davidabram and others added 2 commits September 30, 2026 19:10
The generated-trace refinement test ran `quint run --mbt` with 500 samples, which materializes every trace as ITF JSON in one Node process and peaks around 3.5 GB. Under `nix flake check` contention this intermittently failed with an opaque "Quint returned non-zero code."

Lower `max_samples` to 200 (~1.8 GB peak) and document that the bound is memory-driven, and that the pinned seed does not make traces reproducible because Quint's Rust backend samples across threads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Co-authored-by: SCE <sce@crocoder.dev>
Isolate doctor environment tests from the caller's HOME, make supervision-failure injection wait for actual output, and synchronize cancellation tests on shell readiness. Remove outdated MBT memory guidance now that the sample bound is 200.
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from 9a670e0 to 399073c Compare September 30, 2026 19:24
@davidabram
davidabram merged commit 19ea352 into main Sep 30, 2026
11 checks passed
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