Skip to content

self-healing: merged-but-unfinished tasks never finalized on a renamed board (fifteenth sweep) - #2897

Merged
gsxdsm merged 1 commit into
mainfrom
shq25
Jul 31, 2026
Merged

self-healing: merged-but-unfinished tasks never finalized on a renamed board (fifteenth sweep)#2897
gsxdsm merged 1 commit into
mainfrom
shq25

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

recoverMergedReviewTasks finalizes a task whose merge is confirmed but which never reached the complete lane. Two literal reads meant that on a renamed board it was never found, so a card whose commit is already on the base branch sat in review or hold indefinitely — merged work the board still shows as unfinished.

The two redundant guards convert, they don't get deleted

Both t.column === … checks were redundant while the query pinned the column. Under a resolved read they become the per-card verdict. Deleting them would have silently widened the sweep — the same trap called out in #2891.

Carries the two shapes review established earlier in this series

Both were review findings on earlier PRs in this series, applied here up front rather than waiting to be caught again.

Revert results

Each applied alone and the file re-run:

conversion reverted →
the resolved reads fails — the card is never listed
the per-card review verdict fails — the renamed review lane does not match

Observable is resolveSelfHealingMergeTarget, a private method called once per candidate, so the assertion sits downstream of both halves without a git fixture. A non-vacuous companion (merge-confirmed card in the wip lane → untouched) rules out a read that returns everything.

Verification

pnpm test:gate 161 + 487 + 13 + 71, plus self-healing.test.ts 412; tsc engine clean; pnpm lint, check:changesets, census --strict clean, each run explicitly.

… board (fifteenth sweep)

recoverMergedReviewTasks finalizes a task whose merge is CONFIRMED but which never
reached the complete lane. Two literal reads meant that on a renamed board it was
never found, so a card whose work is already on the base branch sat in review or
hold indefinitely — merged work the board still shows as unfinished.

The two `t.column === …` checks were REDUNDANT while the query pinned the column.
Under a resolved read they become the per-card verdict, so they convert rather than
being deleted.

Carries the two shapes earlier review established on this series:
  - NARROW WHEN THE CARD CAN ANSWER, BROAD WHEN IT CANNOT (#2891). resolveWorkflowIr
    ForTask SUBSTITUTES the built-in IR rather than failing, so an unreadable
    selection would otherwise reject the very card the project query just admitted
    from a renamed lane; it falls back to the project sets instead.
  - Deduped across the buckets (#2879), so a dual-role column cannot finalize one
    card twice.

Reverts measured, each alone:
  - literal reads restored -> fails, the card is never listed
  - verdict back to `t.column === "in-review"` -> fails, the renamed review lane
    does not match

Fusion-Task-Id: KB-SELF-HEALING-QUERIES
@coderabbitai

coderabbitai Bot commented Jul 30, 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: 9 minutes

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: 3cd51164-f3ce-4b4f-8323-91ca0b620b8f

📥 Commits

Reviewing files that changed from the base of the PR and between 995b52d and 6fcb040.

📒 Files selected for processing (5)
  • .changeset/self-healing-merged-review-query.md
  • packages/engine/src/__tests__/self-healing-query-filter-blindness.test.ts
  • packages/engine/src/self-healing.ts
  • scripts/lib/lifecycle-column-census-baseline.json
  • scripts/lib/sql-column-literals-baseline.json

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 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes merged-task recovery workflow-column-aware.

  • Queries resolved review and hold columns instead of literal in-review and todo columns.
  • Applies task-specific workflow lane checks with project-level fallback when workflow resolution is unavailable.
  • Deduplicates candidates that appear in multiple role buckets.
  • Adds regression coverage for renamed review and WIP lanes and updates census baselines and release metadata.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The recovery sweep broadens only its initial lookup, restores task-specific lane scoping before acting, deduplicates overlapping role buckets, and retains the existing merge-confirmation and processing guards.

Important Files Changed

Filename Overview
packages/engine/src/self-healing.ts Replaces literal recovery queries with resolved project and per-task workflow lanes while preserving eligibility checks and deduplicating candidates.
packages/engine/src/tests/self-healing-query-filter-blindness.test.ts Adds downstream regression coverage proving renamed review lanes are recovered while renamed WIP lanes remain excluded.
.changeset/self-healing-merged-review-query.md Adds a correctly scoped patch changeset describing the operator-visible recovery fix.
scripts/lib/lifecycle-column-census-baseline.json Updates lifecycle-column literal counts after removing two hardcoded queries.
scripts/lib/sql-column-literals-baseline.json Refreshes the generated SQL-column literal census baseline.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Resolve project review and hold columns] --> B[Query tasks in each resolved column]
  B --> C[Deduplicate each query bucket by task ID]
  C --> D[Resolve task-specific workflow lanes]
  D --> E{Task is in its review or hold lane?}
  E -- No --> F[Ignore task]
  E -- Yes --> G{Merge confirmed and processing allowed?}
  G -- No --> F
  G -- Yes --> H[Resolve merge target and verify reachability]
  H --> I[Finalize task into resolved complete lane]
Loading

Reviews (1): Last reviewed commit: "fix(engine): merged-but-unfinished tasks..." | Re-trigger Greptile

@gsxdsm
gsxdsm merged commit a453912 into main Jul 31, 2026
7 checks passed
@gsxdsm
gsxdsm deleted the shq25 branch July 31, 2026 00:22
gsxdsm added a commit that referenced this pull request Jul 31, 2026
…olds 23 PRs) (#2944)

**Consolidation of 23 open PRs into one.** Every one shared a single
root cause and mostly touched a single file; 23 CI runs for that was
indefensible.

Folds and supersedes: #2867 #2869 #2876 #2879 #2883 #2891 #2899 #2901
#2902 #2905 #2906 #2914 #2916 #2918 #2919 #2920 #2922 #2927 #2929 #2932
#2934 #2937 #2939.
(#2865, #2882, #2897, #2909, #2912 already merged and are not
re-folded.)

## The root cause

A self-healing sweep selects its work with `listTasks({ column:
"in-review" })`. On a board whose lanes are renamed that returns
**nothing**, so the sweep never runs — no error, no log line, no failed
task. Several sweeps had already had their *predicates* converted to
resolved lanes, which dropped a census count and changed nothing,
because the query above the loop had already returned an empty list.

**26 sweeps converted.** Each one: read the project's columns for the
role, then decide each card against **its own** workflow, with the
legacy ids unioned so a board mid-rename is never skipped.

## What each sweep stops silently failing to do

| | |
| --- | --- |
| stale merger status | one finished card held the **merge queue** for
everything behind it |
| stale `blockedBy` / completed-task release | dependents stayed blocked
on work that had already finished — the board stops moving |
| workspace partial lands | a task left with **some repos merged and
some not** |
| mid-merge retry stamp | the card stalled *and* the operator's manual
Retry was gated by the same stamp |
| in-progress limbo / no-progress failures | dead cards held a work slot
forever |
| partial-progress retry | real work parked failed with its **retry
budget unspent** |
| orphaned-execution signal | visibility only — the one signal pointing
at an orphan went silent |
| zero-commit audit | went **half-blind**: the error arm kept working,
the lane arm did not |

Plus: ghost review cards, transient merge failures, misclassified
failures, branch misbinding, missing-worktree failures,
merged-but-unfinished finalization, done-metadata repair, self-owned
branch conflicts, orphan-only scope violations, post-done wedges, idle
assigned agents, PR-conflict worktree ownership, and orphaned workspace
worktrees.

## Two defects the conversion itself introduced, both caught and fixed

1. **Missed pairs.** Widening a read without converting the guards
beneath it is *worse than not converting*: the sweep starts admitting
renamed-board cards and then mis-decides every one. Review caught a
second guard on a re-read row; the audit that triggered found **five
more**, one of which gates the `reviewProof` triple-proof — a renamed
review card would have been moved backward with the safety check
silently skipped. Column guards 86 → 81.
2. **Duplicate processing.** The literal reads were disjoint by
construction; resolved reads are not, so a column carrying two role
flags put one card in two buckets — duplicate moves, duplicate audit
rows, inflated counts.

Both now have ratchets.
`self-healing-converted-sweeps-have-no-literal-lane-guards.test.ts`
**derives** its sweep list (a sweep counts as converted when its body
calls `resolveProjectColumnsForRoles`), so it cannot go stale, and it
carries two positive controls because a broken regex finds no offenders
and a broken derivation iterates nothing — an empty loop registers no
tests and reads green.

## Deliberately unchanged

- 22 `moveTask` destinations carrying `recoveryRehome: true` —
`moves.ts` exempts these so a card stranded in an undeclared column
stays rescuable.
- One literal in `clearStaleBlockedBy`'s log-dedup closure (allowed by
name in the ratchet, with the reason).
- `surfaceInReviewStalls` — hot list-read path, needs a batched
prefetch; that is a performance design decision, not a conversion.
- `scheduler.ts` and `replan-target.ts` — built on
`resolveTaskWorkflowIrSync`, which returns the default IR for every task
in production. Converting there produces inert code.

## The fold itself is worth one note

All 23 branches appended to the **same test file at the same anchor**,
so every automatic strategy — git 3-way, `merge-file --union`, and three
hand-written resolvers — interleaved them mid-block. Two attempts
committed conflict markers before I caught it. The file is therefore
**reconstructed**: head authored once, body assembled as the union of
each branch's own intact top-level segments keyed by test title, with
the nested `already-merged hard blocker` describe appended whole
(flattening it orphaned its helper). Verified by *parsing after every
step* rather than trusting the merge — which is how each interleaving
was caught.

## Verification

`pnpm test:gate` 161 + 487 + 13 + 71. Scoped suites 592 passed
(self-healing, the blindness suite at 68 cases, the ratchet, and the
notification suite). `tsc` engine clean; `pnpm lint`,
`check:changesets`, `lifecycle-column-census --strict` and
`check-sql-column-literals` all clean, each run explicitly.

Each folded conversion was individually revert-proven on its original
branch — the read reverted alone, and the per-card verdict reverted
alone — and those measurements are recorded in the commit messages
carried into this branch.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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