Skip to content

test(editor): isolate prefix bleed in the batched model sweep, drop a dead export - #18240

Merged
nwparker merged 1 commit into
mainfrom
readyB/close-prefix-bleed-test-gap
Sep 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
readyB/close-prefix-bleed-test-gap

Conversation

@nwparker

@nwparker nwparker commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​71 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​67
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

A test that looked like it was guarding against a whole class of bug turned out to be structurally unable to see it. This adds a test that can, records two invariants that a future "cleanup" would silently break, and deletes an export #18144 left behind with a false justification attached.

Follow-up to #18144, found during readiness review. No production behaviour change except the removal of an unused export.

1. The parity test cannot see prefix bleed

closed-editor-tab-disposal.test.ts proves the batched sweep disposes exactly what the pre-batch per-tab sweep disposed, by running both over the same fixture. That is a good test, but it is blind to prefix bleed — the bug where closing tab-1 also disposes tab-10's models.

buildScenario closes tab-0…tab-99, so tab-10 is in the closed batch too. A bleeding predicate would dispose tab-10's models, but the per-tab oracle disposes them as well via tab-10's own prefix. The two agree, and disposedPaths(batched) === disposedPaths(perTab) still passes.

Verified rather than assumed. Replacing the boundary probe in isOwnedByPathPrefix with a naive startsWith over the prefix set:

Tests  1 failed | 5 passed (6)   <- only the new test fails

All five pre-existing tests in that file stayed green under a predicate that disposes the wrong tab's models.

The new test closes tab-1 while leaving tab-10 open, and goes through the batched disposeClosedEditorTabs entry point on purpose — that is where the owned prefixes become a Set probed at the URI's own : boundaries against shortestPrefixLength/longestPrefixLength, which is a different predicate from the pre-batch per-prefix startsWith.

Scope correction

diff-monaco-model-disposal.test.ts does already cover prefix bleed, for the encoded-colon sibling shape (foo vs foo:bar) — both of its prefix tests fail under the same mutation. So this was never entirely uncovered. What was missing is coverage at the batched entry point, with a multi-prefix Set, in the realistic tab-1 vs tab-10 shape.

2. boundary + 1 is load-bearing

hasPaneScopeOwner advances by one character, not two. In a ::: run the second :: starts one character after the first, and it can be the only boundary an owner ends at — owner a: against key a:::b. Advancing by + 2 steps over it and silently leaks the entry.

That reads like an off-by-one waiting to be tidied up, so it now has both a comment and a test that fails under the + 2 version:

× matches an owner that ends at the second `::` of a `:::` run
AssertionError: expected [ 'a:::b', 'a::b', 'ab:::c' ] to deeply equal [ 'a::b', 'ab:::c' ]

This also gives deletePaneScopedCacheEntries direct unit coverage (owner-extension, batch sweep, empty batch), which it did not have — it was only exercised through sweepClosedPdfViewPositions and the disposal hook.

3. Dead export with a false justification

#18144's description says disposeUnattachedMonacoModelsByPathPrefix was "kept as a one-element wrapper for its other callers". It has no other callers — after that PR the only two call sites are in its own test file. Removed, and both call sites now use the plural form directly.

4. Why startedAt: 0 is load-bearing

Not part of the #18144 change, but the same review turned up a landmine worth writing down where someone will actually see it.

buildTitleDerivedAgentRow stamps updatedAt, stateStartedAt, and observation.revision/observedAt from args.now. Those look freshness-dependent, and a reader could reasonably conclude a title-derived row's bucket decays with the clock. It does not — solely because the row carries startedAt: 0, which makes dashboardRowBucketProjection set isTitleDerived and short-circuit unseen.

Every dashboard bucket cache keys its invalidation on the freshness boundary in isExplicitAgentStatusFresh alone. Give title-derived rows a real timestamp and all of them start serving stale counts, with no test failing at the point of the change. That is now a comment on the line.

Verification

  • 504 test files / 3926 tests pass across editor/, sidebar/, dashboard/
  • pnpm tc clean, oxlint clean, oxfmt --check clean
  • Both new tests confirmed fail-first by mutating the implementation, then restored

… dead export

Readiness-review follow-ups to #18144.

The parity test in closed-editor-tab-disposal.test.ts cannot see prefix bleed:
buildScenario closes tab-0..tab-99, so tab-10 is in the closed batch too and the
per-tab oracle disposes its models via tab-10's own prefix. Batched and oracle
agree and the assertion passes even with a bleeding predicate. Verified by
mutation: replacing the boundary probe with a naive startsWith leaves all five
of that file's tests green.

Adds a test through the batched disposeClosedEditorTabs entry point with a
still-OPEN tab-10 alongside a closed tab-1, which does fail under that mutation.

Also records the `boundary + 1` advance in hasPaneScopeOwner as load-bearing for
`:::` runs, with a test that fails under a `+ 2` "tidy-up", and removes
disposeUnattachedMonacoModelsByPathPrefix, which #18144 left with zero production
callers and a comment claiming it was kept for callers that do not exist.

Finally, documents why title-derived rows carry `startedAt: 0`, which is the sole
reason their `now` stamps cannot move a dashboard bucket.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 425b883c-46ce-4d8c-b970-927a15bc9177

📥 Commits

Reviewing files that changed from the base of the PR and between 698584f and b2f2537.

📒 Files selected for processing (6)
  • src/renderer/src/components/editor/closed-editor-tab-cache-sweep.test.ts
  • src/renderer/src/components/editor/closed-editor-tab-cache-sweep.ts
  • src/renderer/src/components/editor/closed-editor-tab-disposal.test.ts
  • src/renderer/src/components/editor/diff-monaco-model-disposal.test.ts
  • src/renderer/src/components/editor/diff-monaco-model-disposal.ts
  • src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/editor/diff-monaco-model-disposal.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Added boundary-focused tests for deletePaneScopedCacheEntries, including prefix extensions, ::: runs, batched owners, and empty batches. Added a disposal regression test for open tab identifiers that extend closed identifiers. Updated tests to use disposeUnattachedMonacoModelsByPathPrefixes. Documented the boundary scan increment and the startedAt: 0 contract for title-derived rows.

Merge Risk: ⚪ Minimal · up to b2f25

This change strengthens editor cleanup regression coverage and removes an unused export without changing runtime behavior, dependencies, or deployment architecture. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and explains the changes, rationale, tests, and verification. However, it does not provide the required linked issue in the Fixes # field, does not include the required V… Add the required linked issue, state N/A with a reason under Visual Proof because there is no UI or interaction change, and complete or explicitly mark the remaining required template sections and checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: regression coverage for prefix bleed in the batched model sweep and removal of an unused export.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and explains the changes, rationale, tests, and verification. However, it does not provide the required linked issue in the Fixes # field, does not include the required Visual Proof section with an explicit N/A statement, and omits several template sections and checklist confirmations.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Test-only hardening follow-up to #18144; the sole production change is removing a dead export.

  • closed-editor-tab-cache-sweep.test.ts — adds direct unit coverage for deletePaneScopedCacheEntries (owner-extension, :::-run boundary, multi-owner batch, empty batch).
  • closed-editor-tab-cache-sweep.ts — documents why the boundary + 1 advance (not + 2) is load-bearing.
  • closed-editor-tab-disposal.test.ts — adds a prefix-bleed isolation test at the batched disposeClosedEditorTabs entry point: closes tab-1 while tab-10 stays open.
  • diff-monaco-model-disposal.ts / .test.ts — removes the dead disposeUnattachedMonacoModelsByPathPrefix export and points the two test call sites at the plural form.
  • worktree-title-derived-agent-rows.ts — documents why startedAt: 0 is load-bearing, not a placeholder.

Both new tests use exact toEqual assertions and are claimed (and verify-ably) fail-first against their target mutations — naive startsWith prefix bleed and the + 2 advance. The startedAt === 0 → isTitleDerived → unseen short-circuit is confirmed by dashboard-row-bucket.ts; the removed export has zero remaining references.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit efe3305 into main Sep 2, 2026
29 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… dead export (stablyai#18240)

Readiness-review follow-ups to stablyai#18144.

The parity test in closed-editor-tab-disposal.test.ts cannot see prefix bleed:
buildScenario closes tab-0..tab-99, so tab-10 is in the closed batch too and the
per-tab oracle disposes its models via tab-10's own prefix. Batched and oracle
agree and the assertion passes even with a bleeding predicate. Verified by
mutation: replacing the boundary probe with a naive startsWith leaves all five
of that file's tests green.

Adds a test through the batched disposeClosedEditorTabs entry point with a
still-OPEN tab-10 alongside a closed tab-1, which does fail under that mutation.

Also records the `boundary + 1` advance in hasPaneScopeOwner as load-bearing for
`:::` runs, with a test that fails under a `+ 2` "tidy-up", and removes
disposeUnattachedMonacoModelsByPathPrefix, which stablyai#18144 left with zero production
callers and a comment claiming it was kept for callers that do not exist.

Finally, documents why title-derived rows carry `startedAt: 0`, which is the sole
reason their `now` stamps cannot move a dashboard bucket.
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