U4 substrate PR1: extract the git-evidence readers (19/19 bodies byte-identical, self-healing.ts -449) - #2489
Conversation
…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
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR extracts the git-evidence readers from the self-healing manager without changing their behavior.
Confidence Score: 5/5The 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.
|
| 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
Reviews (1): Last reviewed commit: "refactor(engine): extract the git-eviden..." | Re-trigger Greptile
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:
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 asyncmethods closing overthis.options, so nothing here is byte-identical in the strict sense. Three deviations were structurally unavoidable:private→protectedon the 14 methods and theoptionsfield — a subclass cannot call aprivatebase member. One token per declaration.SelfHealingManager["readCommitTaskOwnership"]→ the base class, since the original would be a circular import.self-healing.ts, so everything the bodies call has to live beside them.execAsyncandshellQuoteare imported back because call sites remain.The set is 14, not 13
foreignTipRejectionhad to come too, and it's what closes the cluster — it depends only onbaseHasExplicitTaskOwnershipandbranchHasNoUniqueDiff, both already in the set. Without it the extraction isn't self-contained andthis.optionsisn'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
thissemantics, so every call site staysthis.<method>(...)and every body is unchanged text.Two pre-existing collisions, preserved exactly
findAlreadyMergedTaskCommitsharing a name with the protected method; inside the class body the bare identifier resolves to the import.SelfHealingOptionsis declared inself-healing.ts, imported here type-only so it's erased at runtime and creates no module cycle.Measured line delta — not an estimate
self-healing.tsSame 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.tsunder 11k — but that is file-size reduction, not code reduction.Verification
464 passed across three engine suites with the single known pre-existing
archiveStaleDoneTasksfailure; tsc clean; lint clean; merge gate green (299 + 10 + 71).No changeset:
@fusion/engineis private.🤖 Generated with Claude Code