[PR #5365] [MERGED] test(sqlite): keep incomplete cleanup primary over late cancellation #6898

Closed
opened 2026-11-01 21:43:54 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5365
Author: @vishal-tambi
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @morluto

Base: main ← Head: fix/5286-sqlite-late-cancellation


📝 Commits (1)

  • 374b1ce test(sqlite): keep incomplete cleanup primary over late cancellation

📊 Changes

1 file changed (+13 additions, -3 deletions)

View changed files

📝 tests/boundary/sqlite/sqliteDatabaseProvider.test.ts (+13 -3)

📄 Description

Summary

Closes #5286 together with 100671427, which is already on main.

100671427 ("fix(sqlite): retain primary outcomes through cleanup retries") added the behavior this PR originally proposed. It returns AnalysisCancelledError with the caller's exact reason and the completed inspection as partial Evidence when the caller aborts during final snapshot-root cleanup. I rebased onto main and dropped this PR's provider change, because main already has the same check and the same completedSqliteEvidence helper.

What's left is the regression coverage that main doesn't have yet. #5286 also requires that incomplete cleanup keeps priority over a late cancellation, and no main test checks that combination.

Problem and expected behavior

docs/tool-design.md#own-the-lifecycle says to preserve an existing primary failure and let incomplete cleanup keep its own classification. On main, a cleanup failure returns before the late-cancellation check, so the behavior is correct. But the only tests that abort during final root cleanup are ones where cleanup succeeds. A change that let a late abort win over a failed root cleanup would pass the whole suite, and the caller would lose the cleanup error and its retry owner.

Expected: the caller aborts during close() and root removal is denied. The result is ProviderCleanupError carrying the completed Evidence, and the root stays retained until provider.close() retries it.

Change and scope

Test-only. tests/boundary/sqlite/sqliteDatabaseProvider.test.ts, in main's existing preserves completed native-worker observations across %s cases:

  • New cancelled cleanup-failure case: aborts with the explicit reason object inside the acquired root's close(), then denies removal. It expects ProviderCleanupError (cleanupIncomplete: true), the completed partial Evidence, a retained root, and successful removal on provider.close().
  • late-cancellation now also asserts that the private root was removed.
  • cleanup-failure is unchanged, plus a check that it is a ProviderCleanupError and that no abort happened.

Scope decision: not applicable. This is test coverage inside the existing SQLite provider boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: SqliteDatabaseProvider.#inspect, final snapshot-root cleanup. Tests only.
  • Contribution scope fit and linked maintainer decision: not applicable. No runtime change.
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. The test asserts the existing partial Evidence.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged. The test asserts that incomplete cleanup keeps ProviderCleanupError priority and its retry owner.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

The tested SQLite inspection reads the selected database and launches an owned worker. This PR changes no runtime code.

Evidence and regression coverage

  • Tests added or updated: the three preserves completed native-worker observations across %s cases above. They use the real SQLite worker and row_limit: 1.
  • Why the new case is needed: I temporarily changed the provider so a late abort replaced a failed root cleanup (returning AnalysisCancelledError before return cleaned). Only cancelled cleanup-failure failed: expected Error: Analysis operation was cancelled … to be an instance of ProviderCleanupError. main's existing late-cancellation and cleanup-failure cases both still passed. The provider was then restored to main.
  • User-visible CLI/MCP output (if applicable): not applicable.
  • Remaining proof gaps: macOS and Linux weren't run, and neither was the full CI suite.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

All on Windows 11 with Node 24.18.0 and npm 11.16.0, on main at 8e3bf56e1 plus this commit. I ran only the suite this change affects.

  • npm run test:focused -- tests/boundary/sqlite/sqliteDatabaseProvider.test.ts: 26 passed, 2 skipped. Both skips are process.platform !== "win32" cases.
  • node scripts/run-exact-tests.mjs tests/boundary/sqlite/sqliteDatabaseProvider.test.ts --reporter=verbose -t "native-worker observations":
    • with main's provider: all 3 cases passed;
    • with the temporary regression described above: 1 failed (cancelled cleanup-failure), 2 passed.
  • check:fast (typecheck and lint): passed as the pre-push hook.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real SQLite worker on Windows only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: test-only change. The test's private roots are created under its own temporary workspace and removed.

Author readiness

Human owner: @vishal-tambi

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5365 **Author:** [@vishal-tambi](https://github.com/vishal-tambi) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/5286-sqlite-late-cancellation` --- ### 📝 Commits (1) - [`374b1ce`](https://github.com/morluto/rea/commit/374b1cee65230feddf512e529cca7ff2129c1c1e) test(sqlite): keep incomplete cleanup primary over late cancellation ### 📊 Changes **1 file changed** (+13 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tests/boundary/sqlite/sqliteDatabaseProvider.test.ts` (+13 -3) </details> ### 📄 Description ## Summary Closes #5286 together with 100671427, which is already on `main`. 100671427 ("fix(sqlite): retain primary outcomes through cleanup retries") added the behavior this PR originally proposed. It returns `AnalysisCancelledError` with the caller's exact reason and the completed inspection as partial Evidence when the caller aborts during final snapshot-root cleanup. I rebased onto `main` and dropped this PR's provider change, because `main` already has the same check and the same `completedSqliteEvidence` helper. What's left is the regression coverage that `main` doesn't have yet. #5286 also requires that incomplete cleanup keeps priority over a late cancellation, and no `main` test checks that combination. ## Problem and expected behavior [`docs/tool-design.md#own-the-lifecycle`](https://github.com/morluto/rea/blob/main/docs/tool-design.md#own-the-lifecycle) says to preserve an existing primary failure and let incomplete cleanup keep its own classification. On `main`, a cleanup failure returns before the late-cancellation check, so the behavior is correct. But the only tests that abort during final root cleanup are ones where cleanup succeeds. A change that let a late abort win over a failed root cleanup would pass the whole suite, and the caller would lose the cleanup error and its retry owner. Expected: the caller aborts during `close()` and root removal is denied. The result is `ProviderCleanupError` carrying the completed Evidence, and the root stays retained until `provider.close()` retries it. ## Change and scope Test-only. `tests/boundary/sqlite/sqliteDatabaseProvider.test.ts`, in `main`'s existing `preserves completed native-worker observations across %s` cases: - New `cancelled cleanup-failure` case: aborts with the explicit reason object inside the acquired root's `close()`, then denies removal. It expects `ProviderCleanupError` (`cleanupIncomplete: true`), the completed partial Evidence, a retained root, and successful removal on `provider.close()`. - `late-cancellation` now also asserts that the private root was removed. - `cleanup-failure` is unchanged, plus a check that it is a `ProviderCleanupError` and that no abort happened. Scope decision: not applicable. This is test coverage inside the existing SQLite provider boundary. ## Contract and boundary impact - Semantic owner and earliest changed stage: `SqliteDatabaseProvider.#inspect`, final snapshot-root cleanup. Tests only. - Contribution scope fit and linked maintainer decision: not applicable. No runtime change. - CLI and MCP/tool-catalog contract: unchanged. - Provider, bridge, target-format, or platform compatibility: unchanged. - Evidence, artifact, provenance, or reconstruction contract: unchanged. The test asserts the existing partial Evidence. - Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged. The test asserts that incomplete cleanup keeps `ProviderCleanupError` priority and its retry owner. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [x] Launch or attach to a process. - [x] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. - [x] Contact network services. - [x] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [x] Not sure yet; investigation or maintainer guidance needed. The tested SQLite inspection reads the selected database and launches an owned worker. This PR changes no runtime code. ## Evidence and regression coverage - Tests added or updated: the three `preserves completed native-worker observations across %s` cases above. They use the real SQLite worker and `row_limit: 1`. - Why the new case is needed: I temporarily changed the provider so a late abort replaced a failed root cleanup (returning `AnalysisCancelledError` before `return cleaned`). Only `cancelled cleanup-failure` failed: `expected Error: Analysis operation was cancelled … to be an instance of ProviderCleanupError`. `main`'s existing `late-cancellation` and `cleanup-failure` cases both still passed. The provider was then restored to `main`. - User-visible CLI/MCP output (if applicable): not applicable. - Remaining proof gaps: macOS and Linux weren't run, and neither was the full CI suite. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed All on Windows 11 with Node 24.18.0 and npm 11.16.0, on `main` at 8e3bf56e1 plus this commit. I ran only the suite this change affects. - `npm run test:focused -- tests/boundary/sqlite/sqliteDatabaseProvider.test.ts`: 26 passed, 2 skipped. Both skips are `process.platform !== "win32"` cases. - `node scripts/run-exact-tests.mjs tests/boundary/sqlite/sqliteDatabaseProvider.test.ts --reporter=verbose -t "native-worker observations"`: - with `main`'s provider: all 3 cases passed; - with the temporary regression described above: 1 failed (`cancelled cleanup-failure`), 2 passed. - `check:fast` (typecheck and lint): passed as the pre-push hook. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: real SQLite worker on Windows only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: test-only change. The test's private roots are created under its own temporary workspace and removed. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @vishal-tambi - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:43:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6898
No description provided.