Skip to content

chore(sqlite): classify worker-owned history queries - #174574

Merged
steipete merged 1 commit into
mainfrom
dbasync/t1trace-history
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/t1trace-history

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The SQLite inventory counts several history queries as possible Gateway main-thread work even though their actual callers already run in workers. Record operation-scoped reachability evidence instead of exempting whole mixed modules. This changes inventory classification only: no runtime SQL, public API, schema, persistence, or security checks change.

Reachability audit

All 32 assigned call expressions were traced. T1 change is 32 → 17: 14 worker-only sites become W, and one existing worker/offline deletion site becomes T3.

File under src/config/sessions/ Before T1 After T1 Resolution
session-accessor.sqlite-history-interval.ts 8 0 W: history ID, lookup, and anchor readers are worker-owned
session-accessor.sqlite-history-projection.ts 3 2 W: active coordinate; retain shared builder and boundary shape
session-accessor.sqlite-history.ts 2 2 Retain released synchronous memory SDK readers
session-accessor.sqlite-participant-projection.ts 1 1 Retain shared entry decoding/native source-authority path
session-accessor.sqlite-pending-inputs.ts 8 7 T3: entry deletion; retain completion and native append kernels
session-accessor.sqlite-reset-window.ts 9 4 W: closed intervals, lookup probe, accounting, optional oversized probe
session-history.ts 1 1 Retain released synchronous memory SDK readers

Worker evidence: session-transcript.worker.ts constructs the readonly history reader; session-history-read-operation.worker.ts owns the prepared anchor callback. The native catalog-title reader invokes only page reads, without an expected anchor. Transcript stats also run in session-actor-context-stats.worker.ts. The bounded-tail oversized check is not requested by its native title/Doctor callers. Pending-input deletion belongs to the existing deleteSessionEntryRows worker/maintenance/offline-reset chain and receives the same T3 classification as its parent.

Twelve retained sites have released synchronous SDK callers: loadArchivedSessions, loadMemorySessionMetadata, resolveMemorySessionTargets, readSessionTranscriptCatalogTitle, synchronous SessionManager context methods, and UserTurnTranscriptRecorder.completeProcessing. Their contracts were verified in stable v2026.10.4; removal belongs to the SDK migration owner.

Five further sites remain shared native debt: participant decoding and four pending-input append/read/consume sites. A concrete bundled route is the hook-block recorder in gateWorkerTurnInput, whose plain assertion becomes opaque native source authority and selects native transcript persistence. That route directly establishes the keyed lookup; it does not establish that every consume/source query runs for that message. A complete cutover needs the transcript authority/preparation owner and its native callback contract, so these are not hidden as worker-only or deprecated-only. This is not a claim that the callback is a security check.

Measurement and removed checks

Metric Result
Assigned static T1 calls 32 → 17 (independent base census plus candidate CI census)
Warmed all-thread statements / requests Not remeasured; runtime path unchanged
Warmed MAIN statements Not remeasured; runtime path unchanged
Subsystem statement/request delta No executable change; no performance saving claimed

No checks were removed, and no new accepted race or stale-read edge case is introduced. No runtime read/write class was removed, so lost-update/stale-read regression tests and the SQL harness are not applicable. No schema, SDK surface, update, Doctor, plugin-loading, or service-lifecycle changes.

Evidence

  • Local changed-file formatting, type-aware script lint, and git diff --check.
  • Focused inventory suites: pnpm test test/scripts/check-database-worker-ratchet.test.ts test/scripts/database-worker-compat.test.ts --maxWorkers=1 — 2 files / 99 tests passed.
  • Knip export scan ran locally because PR CI did not select it. It reports 16 unique unused exports in untouched files; every path/symbol matches scheduled main job 117157269800 verbatim. Recorded in the campaign red-main inbox; using the authorized inherited-static-failure exception.
  • Codex autoreview: scoped-clean at P0–P2, one round.
  • Baseline inventory confirms 224 repository-wide T1 calls and 32 assigned calls. CI confirms 209 T1 calls under the candidate registry; the ratchet uses that registry for both source refs and reports no growth. The generated snapshot landed in chore: classify worker and maintenance SQL call sites #174581 (bc18ffb3c37bc0fbe4685b32517a012ae29a50db). All ten history rows were verified against this lane’s independently generated snapshot: identical tier, count, operation, and evidence fields; 17 assigned T1 calls remain. The redundant documentation follow-up docs(sqlite): refresh history worker inventory #174664 was closed.
  • CI run 38953504922 passed all test and static-check jobs on 2e6aa0af495: types, lint, source contracts, architecture checks and database ratchets. The PR context check initially rejected custom section headings; this body now uses its required problem/evidence headings.
  • Author simplification: use existing operation-scoped registry; no new classification mechanism or whole-module exemption. Production/test LOC: 0/0. Inventory metadata: +110 lines. Generated documentation is complete via chore: classify worker and maintenance SQL call sites #174581. A final Codex review of this lane’s generated document found no actionable P0–P2 issues; the owner generator, formatting, whitespace, and tier arithmetic checks passed.

Trace history operations independently of their mixed modules. Keep released synchronous SDK and native transcript authority paths visible as T1 while classifying existing worker and offline deletion kernels.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T19:18:01.449149Z 2e6aa0a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e6aa0af49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Match lexical operation paths, not moving line numbers or whole mixed modules.
const reviewedOperations = new Map([
[
"src/config/sessions/session-accessor.sqlite-history-interval.ts",

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.

P1 Badge Regenerate the committed worker inventory

Regenerate docs/reference/database-schemas/worker-access-inventory.md with this classification change. The committed artifact still reports 224 T1 calls and lists these newly classified operations as T1; because --check renders from this map and compares the result byte-for-byte with that file, pnpm db:worker-inventory:check will exit nonzero for this commit.

AGENTS.md reference: scripts/AGENTS.md:L15-L15

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 329bb3d into main Oct 16, 2026
132 of 134 checks passed
@steipete
steipete deleted the dbasync/t1trace-history branch October 16, 2026 19:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
Trace 32 history-area SQL call sites by their real callers. Classify 14 already-worker-only calls and one worker/offline deletion call; retain 17 shared native or released SDK sites with evidence. Static T1 inventory falls from 224 to 209 repository-wide, with no runtime behavior or query-count change.

Validated by focused inventory tests (99 passed), Codex autoreview, and PR CI. Knip findings match scheduled main exactly and are recorded as inherited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant