Skip to content

Doctor mutation-scope repair - #283

Open
davidabram wants to merge 16 commits into
doctor-mutation-scopefrom
doctor-mutation-scope-fix
Open

davidabram wants to merge 16 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
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch 2 times, most recently from d3b66ef to 4f7c0a3 Compare September 21, 2026 00:00
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch 3 times, most recently from ce2e9c0 to e604ff4 Compare September 21, 2026 10:34
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from e604ff4 to 17ba350 Compare September 21, 2026 11:33
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from dae85a0 to 9098de2 Compare September 21, 2026 12:28
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch 3 times, most recently from d0192d5 to 46012d3 Compare September 21, 2026 13:50
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from 46012d3 to a0276bf Compare September 21, 2026 15:15
davidabram and others added 2 commits September 21, 2026 17:16
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>
@davidabram
davidabram force-pushed the doctor-mutation-scope-fix branch from 8633dec to df003b0 Compare September 21, 2026 16:52
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
davidabram force-pushed the doctor-mutation-scope-fix branch from 84246f2 to 75c4065 Compare September 21, 2026 17:44
davidabram and others added 2 commits September 21, 2026 20:43
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 390413f to 888f067 Compare September 21, 2026 21:33
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