Repository navigation
chore(sqlite): classify worker-owned history queries - #174574
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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", |
There was a problem hiding this comment.
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 👍 / 👎.
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.
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.
src/config/sessions/session-accessor.sqlite-history-interval.tssession-accessor.sqlite-history-projection.tssession-accessor.sqlite-history.tssession-accessor.sqlite-participant-projection.tssession-accessor.sqlite-pending-inputs.tssession-accessor.sqlite-reset-window.tssession-history.tsWorker evidence:
session-transcript.worker.tsconstructs the readonly history reader;session-history-read-operation.worker.tsowns the prepared anchor callback. The native catalog-title reader invokes only page reads, without an expected anchor. Transcript stats also run insession-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 existingdeleteSessionEntryRowsworker/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, synchronousSessionManagercontext methods, andUserTurnTranscriptRecorder.completeProcessing. Their contracts were verified in stablev2026.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
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
git diff --check.pnpm test test/scripts/check-database-worker-ratchet.test.ts test/scripts/database-worker-compat.test.ts --maxWorkers=1— 2 files / 99 tests passed.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.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.