Skip to content

fix(host-sweep): orphan-claim delete missed in tests (regression from #2183)#2209

Merged
gavrielc merged 4 commits intoqwibitai:mainfrom
cfis:fix/host-sweep-test-uses-in-memory-db
May 5, 2026
Merged

fix(host-sweep): orphan-claim delete missed in tests (regression from #2183)#2209
gavrielc merged 4 commits intoqwibitai:mainfrom
cfis:fix/host-sweep-test-uses-in-memory-db

Conversation

@cfis
Copy link
Copy Markdown
Contributor

@cfis cfis commented May 3, 2026

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill - adds a standalone tool (code files in .claude/skills/<name>/, no source changes)
  • Operational/container skill - adds a workflow or agent skill (SKILL.md only, no source changes)
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code
  • Documentation - docs, README, or CONTRIBUTING changes only

Description

#2183 added orphan-claim cleanup that reopens outbound.db by session path (openOutboundDbRw(session.agent_group_id, session.id)) so the delete runs against a writable handle even when callers pass a readonly one. That works for the production caller — there's a real on-disk session DB at the expected path.

The test wrapper _resetStuckProcessingRowsForTesting (added in #2151) is called with in-memory DBs that have no on-disk path. After #2183 the reopen creates a fresh empty file at <DATA_DIR>/v2-sessions/ag-test/sess-test/outbound.db, runs the delete against that, and leaves the in-memory outDb (which the test reads afterward) untouched. The two resetStuckProcessingRows — orphan claim cleanup tests assert getProcessingClaims(outDb).toEqual([]) after the call and fail on the row that's still there.

Fix

Drop the _…ForTesting wrapper, export resetStuckProcessingRows directly with an optional writableOutDb parameter:

  • When omitted (typical production path), the function reopens outbound.db RW by session path — existing behavior, existing safety guarantee.
  • When provided (tests, or any future caller that already holds a writable handle), the function uses it directly and skips the reopen.

The optional parameter has a real semantic meaning, not a "for tests" hack — a future caller who already has a writable handle can avoid the reopen too.

Verification

All 26 host test files / 246 tests pass; previously the two host-sweep tests were failing on every run.

$ pnpm test
 Test Files  26 passed (26)
      Tests  246 passed (246)

Public API

_resetStuckProcessingRowsForTesting is removed; resetStuckProcessingRows is now exported. No other in-repo callers besides the test.

@cfis cfis requested review from gabi-simons and gavrielc as code owners May 3, 2026 05:46
@github-actions github-actions Bot added follows-guidelines PR was created using the current contributing template PR: Fix Bug fix labels May 3, 2026
@cfis cfis force-pushed the fix/host-sweep-test-uses-in-memory-db branch from b84700f to df00e08 Compare May 3, 2026 05:50
@cfis cfis changed the title fix(host-sweep): test wrapper uses passed outDb for delete (regression from #2183) fix(host-sweep): orphan-claim delete missed in tests (regression from #2183) May 3, 2026
…ssed in tests

qwibitai#2183 added orphan-claim cleanup that reopens `outbound.db` by session
path (`openOutboundDbRw(session.agent_group_id, session.id)`) so the
delete runs against a writable handle even when callers pass a readonly
one. That works for the production caller — there's a real on-disk
session DB at the expected path.

The test wrapper `_resetStuckProcessingRowsForTesting` (introduced in
the same series, qwibitai#2151) is called with in-memory DBs that have no
on-disk path. The reopen creates a fresh empty file at
`<DATA_DIR>/v2-sessions/ag-test/sess-test/outbound.db`, runs the delete
against that, and leaves the in-memory `outDb` (which the test reads
afterward) untouched. The two `resetStuckProcessingRows — orphan claim
cleanup` tests assert `getProcessingClaims(outDb).toEqual([])` after
the call and fail on the row that's still there.

Fix: drop the `_…ForTesting` wrapper, export `resetStuckProcessingRows`
directly with an optional `writableOutDb` parameter. When omitted
(production), the function reopens `outbound.db` RW by session path —
existing behavior, existing safety guarantee. When provided (tests, or
any future caller that already holds a writable handle), the function
uses it directly and skips the reopen. The optional parameter has a
real meaning, not a "for tests" hack.

Public API surface change: `_resetStuckProcessingRowsForTesting` is
gone, `resetStuckProcessingRows` is now exported. No other callers
inside the repo besides the test.
The test wrapper forwards the in-memory outDb as the writable handle,
avoiding the filesystem reopen that fails in CI. The function stays
private — the optional writableOutDb param is an internal detail, not
a public API.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gavrielc gavrielc merged commit 24d719f into qwibitai:main May 5, 2026
1 check failed
@gavrielc
Copy link
Copy Markdown
Collaborator

gavrielc commented May 5, 2026

@cfis Thank you for the fix!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template PR: Fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants