Skip to content

U4 substrate PR1: extract the git-evidence readers (19/19 bodies byte-identical, self-healing.ts -449) - #2489

Merged
gsxdsm merged 1 commit into
mainfrom
feature/u4-substrate-git-evidence
Jul 28, 2026
Merged

U4 substrate PR1: extract the git-evidence readers (19/19 bodies byte-identical, self-healing.ts -449)#2489
gsxdsm merged 1 commit into
mainfrom
feature/u4-substrate-git-evidence

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Based on main. PR1 of the substrate decomposition — deliberately small and boring.

Mechanical proof (the point of this PR)

Every moved body diffed against its pre-move text:

BLOCK                            KIND     DIFF-vs-ORIGINAL
  LandedTaskCommit               iface    EMPTY
  commitOwnedByTask              helper   EMPTY
  escapeRegex                    helper   EMPTY
  shellQuote                     helper   EMPTY
  parseShortstat                 helper   EMPTY
  findLandedTaskCommit           method   EMPTY
  findAlreadyMergedTaskCommit    method   EMPTY
  refreshRemoteBaseRef           method   EMPTY
  readCommitTaskOwnership        method   EMPTY
  branchHasNoUniqueDiff          method   EMPTY
  baseHasExplicitTaskOwnership   method   EMPTY
  foreignTipRejection            method   EMPTY
  branchTipForeignOwnership      method   EMPTY
  isCommitReachableFromBranch    method   EMPTY
  findWorktreePathForBranch      method   EMPTY
  repoBranchExists               method   EMPTY
  readShortstatForSha            method   EMPTY
  readLandedFilesForSha          method   EMPTY
  isBranchTipMisboundToTask      method   EMPTY

RESULT: 19/19 BYTE-IDENTICAL modulo the enumerated deviations; 0 differ.

No condition reordered, no signature changed, no rename, no inlining, no "while I am here" cleanup.

The premise needed correcting — the cheap lesson this cut was meant to buy

The brief described 13 pure functions. They are 13 private async methods closing over this.options, so nothing here is byte-identical in the strict sense. Three deviations were structurally unavoidable:

  1. privateprotected on the 14 methods and the options field — a subclass cannot call a private base member. One token per declaration.
  2. Two type annotations rewritten: SelfHealingManager["readCommitTaskOwnership"] → the base class, since the original would be a circular import.
  3. Four module-level helpers moved along and re-exported. Forced by direction — the new module must not import self-healing.ts, so everything the bodies call has to live beside them. execAsync and shellQuote are imported back because call sites remain.

The set is 14, not 13

foreignTipRejection had to come too, and it's what closes the cluster — it depends only on baseHasExplicitTaskOwnership and branchHasNoUniqueDiff, both already in the set. Without it the extraction isn't self-contained and this.options isn't the only external dependency.

Base class, not free functions — deliberately

Converting to free functions would change all 14 signatures: a behavior-adjacent edit riding inside a file move, which is exactly the combination that hid the last four safeguard regressions. An abstract base keeps this semantics, so every call site stays this.<method>(...) and every body is unchanged text.

Two pre-existing collisions, preserved exactly

  • The detector module already exports a free findAlreadyMergedTaskCommit sharing a name with the protected method; inside the class body the bare identifier resolves to the import.
  • SelfHealingOptions is declared in self-healing.ts, imported here type-only so it's erased at runtime and creates no module cycle.

Measured line delta — not an estimate

lines
self-healing.ts 13,394 → 12,945 = −449
new module +527 (454 moved verbatim, 73 scaffold)
NET +78

Same shape as every consolidation in this program: the target file shrinks, the total grows slightly. At −449 for the first and safest cut, the remaining substrate cuts plausibly take self-healing.ts under 11k — but that is file-size reduction, not code reduction.

Verification

464 passed across three engine suites with the single known pre-existing archiveStaleDoneTasks failure; tsc clean; lint clean; merge gate green (299 + 10 + 71).

No changeset: @fusion/engine is private.

🤖 Generated with Claude Code

…g.ts (U4 decomposition, PR1)

PURE RELOCATION. 19 blocks moved to `self-healing-git-evidence.ts`: the 14
git-evidence readers, four module-level helpers they need, and the
`LandedTaskCommit` interface.

MECHANICAL PROOF, which is the point of this PR: every moved body was diffed
against its pre-move text. 19/19 are BYTE-IDENTICAL modulo the three deviations
enumerated below. No condition reordered, no signature changed, no rename, no
inlining, no "while I am here" cleanup.

THE PREMISE NEEDED CORRECTING, and this is the cheap lesson the first cut was
supposed to buy. The brief described 13 pure functions; they are 13 `private
async` METHODS closing over `this.options`, so no extraction is byte-identical in
the strict sense. Three deviations were structurally unavoidable:

  1. `private` -> `protected` on the 14 methods and the `options` field, because a
     subclass cannot call a `private` base member. One token per declaration.
  2. Two `SelfHealingManager["readCommitTaskOwnership"]` type annotations rewritten
     to name the base class; the original would be a circular import.
  3. Four module-level helpers moved with the methods and re-exported. This was
     forced by direction: the new module must not import self-healing.ts, so
     everything the bodies call has to live beside them. `execAsync` and
     `shellQuote` are imported back because call sites remain behind.

THE SET IS 14, NOT 13. `foreignTipRejection` had to come too, and it is what
CLOSES the cluster — it depends only on `baseHasExplicitTaskOwnership` and
`branchHasNoUniqueDiff`, both already in the set. Without it the extraction is not
self-contained and `this.options` would not be the only external dependency.

A BASE CLASS RATHER THAN FREE FUNCTIONS, deliberately. Converting these to free
functions would change all 14 signatures — a behavior-adjacent edit riding inside
a file move, which is exactly the combination that hid the last four safeguard
regressions. An abstract base keeps `this` semantics so every call site stays
`this.<method>(...)` and every body is unchanged text.

Two collisions worth knowing about, both PRE-EXISTING and preserved exactly: the
detector module already exports a FREE `findAlreadyMergedTaskCommit` that shares
its name with the protected method, and inside the class body the bare identifier
resolves to the import. And `SelfHealingOptions` is declared in self-healing.ts,
imported here TYPE-ONLY so it is erased at runtime and creates no module cycle.

MEASURED LINE DELTA, not an estimate:

  self-healing.ts   13,394 -> 12,945   = -449
  new module                           = +527   (454 moved verbatim, 73 scaffold)
  NET                                  = +78

Same shape as every other consolidation in this program: the target file shrinks,
the total grows slightly. At -449 for the first and safest cut, the remaining
substrate cuts plausibly take self-healing.ts under 11k, but the operator should
read that as file-size reduction rather than code reduction.

Verified: 464 passed across three engine suites with the single known
PRE-EXISTING `archiveStaleDoneTasks` failure, tsc clean, lint clean, merge gate
green (299+10+71).

Fusion-Task-Id: KB-U4
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@gsxdsm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c4c1b0b-ba51-4ed8-87fd-4c2f76610441

📥 Commits

Reviewing files that changed from the base of the PR and between 4819c26 and 4297254.

📒 Files selected for processing (2)
  • packages/engine/src/self-healing-git-evidence.ts
  • packages/engine/src/self-healing.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/u4-substrate-git-evidence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extracts the git-evidence readers from the self-healing manager without changing their behavior.

  • Adds SelfHealingGitEvidence, an abstract base class containing the relocated git and task-ownership readers.
  • Moves and re-exports the associated helpers and evidence types.
  • Updates SelfHealingManager to inherit the extracted implementation while preserving its constructor and call sites.

Confidence Score: 5/5

The PR appears safe to merge with no concrete behavioral, build, or security regressions identified.

The extracted methods retain their existing behavior, inherited call sites resolve correctly, the constructor initializes the new base class, and the reverse dependency is type-only and therefore absent at runtime.

Important Files Changed

Filename Overview
packages/engine/src/self-healing-git-evidence.ts Introduces the abstract git-evidence base class and relocates the existing readers and helpers without an identified behavioral regression.
packages/engine/src/self-healing.ts Replaces local git-evidence implementations with inheritance from the extracted base while retaining compatible construction and method resolution.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class SelfHealingGitEvidence {
        <<abstract>>
        #options: SelfHealingOptions
        #findLandedTaskCommit()
        #findAlreadyMergedTaskCommit()
        #branchTipForeignOwnership()
        #isBranchTipMisboundToTask()
    }
    class SelfHealingManager {
        -store: TaskStore
        #options: SelfHealingOptions
    }
    SelfHealingGitEvidence <|-- SelfHealingManager
    SelfHealingGitEvidence ..> AlreadyMergedDetector : delegates
    SelfHealingGitEvidence ..> Git : reads evidence
Loading

Reviews (1): Last reviewed commit: "refactor(engine): extract the git-eviden..." | Re-trigger Greptile

@gsxdsm
gsxdsm merged commit 387e836 into main Jul 28, 2026
7 checks passed
@gsxdsm
gsxdsm deleted the feature/u4-substrate-git-evidence branch July 28, 2026 03:15
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