Skip to content

test(gateway): isolate usage context database fixtures - #208304

Merged
vincentkoc merged 1 commit into
mainfrom
test-usage-owned-context-fixtures-20261129
Nov 30, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
test-usage-owned-context-fixtures-20261129

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Usage fixtures supply fixed temporary database paths even though the handler performs real context-history reads. Those reads can reach unrelated local files.

User Impact

No production behavior changes. The same 36 consumer cases exercise real context reads using owned temporary paths; all capacity and usage assertions remain.

Why This Change Was Made

The shared fixture allocates a unique temporary root and registers cleanup. The cache fixture reuses one path across its query closure. Preserve explicit real-database callbacks and the large usage suite unchanged.

Evidence

  • The eight unaffected source suites pass all 132 original cases. The original 36 consumer cases were not run against fixed unowned paths.
  • All 36 repaired consumer cases pass with real context reads; targeted format, lint, Gateway-method typecheck and diff checks pass.
  • All 168 source cases and assertions remain. No production changes; test and support setup grows by 9 lines.
  • Local ClawSweeper reviewed the complete committed range 501ee91..eb3f62b with no findings.
  • A separate Node 24.22.1 SQLite check compared two fixtures for the same agent. The original helper returned the same path for both. The corrected helper stored different values in two databases, reused each agent’s path within a fixture, and preserved explicit path callbacks. After the first cleanup callback ran, the second database was still readable. The second callback removed the last database. This passed with both the PR’s temporary-directory policy and the policy on main at 9389d991.

@vincentkoc vincentkoc self-assigned this Nov 29, 2026
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Nov 29, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 29, 2026
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR replaces fixed usage-fixture database paths with unique temporary roots that are cleaned up after each test.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is small and source-supported; runtime confidence rests on reported focused runs rather than independently inspected execution artifacts.
Proof confidence 🦐 gold shrimp (3/6) No user-visible production behavior changes; reported consumer runs support the fixture repair, but were not independently rerun and substantive hosted lanes are skipped.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers running usage tests can read unrelated databases through shared fixed temporary paths.
Reason: The small fixture repair improves isolation while preserving production behavior and existing behavioral assertions.

Merge readiness

✅ Ready for maintainer review

This PR is a useful, focused fixture-isolation repair with no actionable findings; it remains a maintainer-authored draft.

Reviewed head: eb3f62b73262242473fe1f0430648979b6dbc0c4

Before merge

None.

Findings

None.

Agent review details

How this fits together

Usage tests pass synthetic session rows and physical database targets into Gateway handlers, which perform real context-history reads before returning usage results.

flowchart LR
  A[Usage test cases] --> B[Shared fixture]
  B --> C[Owned temporary paths]
  B --> D[Gateway usage handler]
  C --> E[Context history reader]
  D --> E
  E --> F[Usage assertions]
Loading

Technical review

Best possible solution:

Retain this minimal repair using the existing temporary-directory owner and stable per-fixture paths.

Do we have a high-confidence way to reproduce the issue?

Source traces the fixed fixture paths into real context-history database reads; execution was intentionally excluded by the read-only review.

Is this the best way to solve the issue?

The patch fixes path ownership at fixture creation, preserves explicit real-database overrides, and keeps repeated cache queries on the same path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0b7647647bcf.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7ca4bad adds src/gateway/server-methods/usage.test-support.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7ca4bad3dfb6; files: src/gateway/server-methods/usage.test-support.ts)
  • Vincent Koc: Raw commit 9514f1d adds src/gateway/server-methods/usage.sessions-usage-cache.test.ts:348 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9514f1d04c97; files: src/gateway/server-methods/usage.sessions-usage-cache.test.ts)

PR surface

Tests +9. Total +9 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 12 3 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 12 3 +9

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 29, 2026, 7:57 AM ET / 12:57 UTC.

@Mattex-lab

Copy link
Copy Markdown

Closed as draft/NO-GO

@vincentkoc
vincentkoc marked this pull request as ready for review November 30, 2026 05:13
@vincentkoc
vincentkoc merged commit fcf0015 into main Nov 30, 2026
194 checks passed
@vincentkoc
vincentkoc deleted the test-usage-owned-context-fixtures-20261129 branch November 30, 2026 05:57
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 30, 2026
* commit 'c5c1dc278a6f789d739d70afe192c4d1e37058f5':
  fix(ci): include provider rejection text in PR tooling (#208891)
  feat: let plugins bring their own sidebar icon (#208885)
  docs: clarify node pairing and credentials on PostgreSQL gateways (#208850)
  fix(ui): show a confirmed subagent stop once in chat (#208533)
  fix(ui): keep collapsed work close to the reply in long chats (#207843)
  fix(update): finish failed recovery startup records (#208794)
  chore(ci): inventory media worker lifecycles (#208888)
  fix: use the same clock icon for Automations (#208539)
  improve(ci): reduce compiler round trips in database checks (#208878)
  fix(ci): preserve complete adaptive test observations (#208874)
  test(gateway): isolate usage context database fixtures (#208304)
  fix: avoid false worker cleanup failures (#208861)
  fix: let Git upgrade acceptance fetch its missing baseline (#208746)
  fix: isolate scheduled Processes reads in the Control UI config-change test (#208205)
  fix: make plugin hash worker tests independent of runner memory (#208860)
  fix(update): preserve serving state during candidate plugin maintenance (#208776)
  test(ui): preserve exact session keys in older chat links (#208873)
  docs(cli): say what bounds a yielded agent turn's subagent wait without --timeout (#208858)
vincentkoc added a commit that referenced this pull request Nov 30, 2026
* fix: restore managed worktrees from bare primary repositories

Managed worktrees created from a linked checkout record its primary repository. Resolve that registration during inspection, removal, and snapshot restore while keeping new checkout creation strict.

* Merge verified upstream CI repairs into managed worktree recovery

* commit 'c5c1dc278a6f789d739d70afe192c4d1e37058f5': (64 commits)
  fix(ci): include provider rejection text in PR tooling (#208891)
  feat: let plugins bring their own sidebar icon (#208885)
  docs: clarify node pairing and credentials on PostgreSQL gateways (#208850)
  fix(ui): show a confirmed subagent stop once in chat (#208533)
  fix(ui): keep collapsed work close to the reply in long chats (#207843)
  fix(update): finish failed recovery startup records (#208794)
  chore(ci): inventory media worker lifecycles (#208888)
  fix: use the same clock icon for Automations (#208539)
  improve(ci): reduce compiler round trips in database checks (#208878)
  fix(ci): preserve complete adaptive test observations (#208874)
  test(gateway): isolate usage context database fixtures (#208304)
  fix: avoid false worker cleanup failures (#208861)
  fix: let Git upgrade acceptance fetch its missing baseline (#208746)
  fix: isolate scheduled Processes reads in the Control UI config-change test (#208205)
  fix: make plugin hash worker tests independent of runner memory (#208860)
  fix(update): preserve serving state during candidate plugin maintenance (#208776)
  test(ui): preserve exact session keys in older chat links (#208873)
  docs(cli): say what bounds a yielded agent turn's subagent wait without --timeout (#208858)
  test(ui): keep real exports in the channel settings distribution mock (#208855)
  test(normalization): preserve inline code in quoted previews (#208857)
  ...

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants