Skip to content

refactor: consolidate archived transcript reads - #117343

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-archive-reader-owner-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-archive-reader-owner-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold transcript reads were split across three filesystem readers plus facade-specific routing. The duplicated ownership made reset archive selection inconsistent: after SQLite returned no rows, the full-history path could still choose an obsolete live JSONL instead of the retained reset archive.

Why This Change Was Made

ArchivedTranscriptReader is now the single filesystem owner for full/recent/page/by-id/anchor reads across plain and compressed reset archives. It preserves DAG/leaf and reset-kept-tail projection, oversized-line placeholders, pagination metadata, path scoping, and SQLite-first precedence while deleting the separate index and anchor-reader modules.

The shared index is a bounded 256-entry LRU keyed by path plus (mtime,size), stores in-flight promises to deduplicate concurrent scans, and discards failed builds. Reset archive header validation is no longer cached independently of archive materialization, so same-path replacement cannot reuse a stale authorization decision.

No protocol, config, schema, dependency, plugin SDK, or public contract changes.

User Impact

History, pagination, anchor lookup, and usage behavior remain unchanged. Reset/archive fallback is more consistent, zero-sized recent reads return no messages while retaining the total, and the gateway carries 433 fewer production lines.

Production delta: +434 / -867 (net -433). Tests are counted separately: +150 / -37.

Evidence

  • Post-integration build: pnpm build passed on Blacksmith Testbox tbx_01kyyc9gdn1bagm1xbbdz000an (run).
  • Post-integration focused proof: 142 tests passed across archive compression, JSONL history, DAG/reset projection, SQLite cleanup race, reset/delete lifecycle, HTTP revocation, and reader-boundary suites on the same Testbox.
  • Full changed gate: pnpm check:changed passed all core/coreTests formatting, boundary, dead-export, typecheck, lint, storage, schema, and import-cycle checks on Testbox tbx_01kyy9cwn91ew9q1d83qc85b71 (run).
  • Additional lifecycle proof: 105 SQLite/reset/delete tests passed; focused and sibling archive/DAG suites passed before integration.
  • Independent autoreview: gpt-5.6-sol, xhigh, clean with no accepted/actionable findings (0.98 confidence).
  • Integrated once with current main, including refactor(memory): consolidate session transcript ingestion #117293 and refactor(agents): fold cache TTL pruning into prompt projection #117313; no subsequent main chasing.

ClawSweeper Rank-up Move

ClawSweeper optionally suggested another current-main refresh. This is intentionally skipped: exact head 180554426b94ea311135a1055eb64449d5c0105e already performed the coordinated one-time integration onto then-current main, followed by a clean full build and 142 post-integration archive, anchor, pagination, SQLite, reset/delete lifecycle, revocation, and reader-boundary tests. The subsequent base advance has an empty diff across all eight touched transcript-reader paths. Repeating the refresh would invalidate the exact-head CI and proof without exercising a changed owner surface.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 10:09
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:52 AM ET / 10:52 UTC.

ClawSweeper review

What this changes

This PR replaces separate gateway filesystem transcript index and anchor readers with one ArchivedTranscriptReader for archived history, pagination, message lookup, and anchor reads.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking correctness or security finding was identified. This is a coherent gateway ownership refactor with focused regression coverage and successful exact-head CI, but its protected maintainer label appropriately leaves the final merge decision to a human reviewer because it changes archived session-history fallback behavior.

Priority: P2
Reviewed head: 180554426b94ea311135a1055eb64449d5c0105e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-scoped ownership consolidation with strong targeted validation; remaining work is normal human review of session-history semantics, not a contributor repair.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR documents post-integration Testbox build and focused archive/anchor/pagination/reset lifecycle runs, and the supplied check context records successful real-behavior-proof checks for the exact head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR documents post-integration Testbox build and focused archive/anchor/pagination/reset lifecycle runs, and the supplied check context records successful real-behavior-proof checks for the exact head.
Evidence reviewed 6 items Canonical archive-read owner: The branch defines ArchivedTranscriptReader as the single owner of live JSONL and reset-archive reads, with active-path precedence, reset-archive-only selection, and archive materialization in one boundary.
SQLite-first fallback preserved: The gateway façade reads SQLite first; when it has no rows, each filesystem fallback explicitly requests resetArchiveOnly, preventing an obsolete active JSONL from winning after SQLite has already selected archive fallback.
Regression coverage: The added façade regression creates both an obsolete active JSONL and a retained reset archive, then asserts the SQLite-empty fallback returns the retained archive rather than the active file.
Findings None None.
Security None None.

How this fits together

Gateway history endpoints first read the SQLite transcript projection and use a JSONL reset archive only when no projected rows are available and fallback is allowed. The archive reader turns the selected transcript artifact into history pages, recent messages, message lookups, and anchor-centered pages returned to gateway clients.

flowchart LR
  A[Gateway history request] --> B[SQLite transcript projection]
  B --> C{Rows available?}
  C -->|yes| D[History or message response]
  C -->|no; archive fallback allowed| E[Archived transcript reader]
  E --> F[Reset archive selection and materialization]
  F --> D
Loading

Before merge

  • Resolve merge risk (P1) - The PR is cleanly mergeable but behind current main; the observed base advance does not touch the transcript-reader paths, so a rebase is not intrinsically required, but the final maintainer review should retain the merge-result check.
  • Resolve merge risk (P2) - Archive fallback, pagination, and anchor lookup affect which historical session context gateway clients receive; the protected maintainer label warrants an explicit human landing decision despite passing checks.
  • Complete next step (P2) - No mechanical repair is needed; the remaining action is the protected-label maintainer review and normal merge-result confirmation.
Agent review details

Security

None.

PR surface

Source -433, Tests +113. Total -320 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 6 434 867 -433
Tests 2 150 37 +113
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 584 904 -320

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: src/gateway/session-transcript-files.fs.ts, persistent cache schema: src/gateway/session-transcript-index.fs.ts, serialized state: src/gateway/session-transcript-anchor-reader.ts, serialized state: src/gateway/session-transcript-files.fs.ts, serialized state: src/gateway/session-transcript-index.fs.ts, serialized state: src/gateway/session-transcript-readers.test.ts, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land with current merge-result check (recommended)
    Accept the bounded session-history risk after a maintainer confirms GitHub's clean merge result, since the base advance has no transcript-reader-path overlap and the exact PR head already has focused proof.
  2. Refresh only on relevant drift
    Re-run the focused archive, anchor, pagination, and reset/delete lifecycle suites only if main changes the transcript-reader or session-projection boundary before landing.

Technical review

Best possible solution:

Land the single-reader consolidation after a maintainer confirms the clean merge result; keep SQLite-first selection and resetArchiveOnly fallback as the only archive-read path rather than restoring façade-specific filesystem readers.

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

Yes for the reported defect: the added current-branch regression constructs an empty SQLite-facing scope with both an obsolete active JSONL and reset archive, then proves archive-only fallback selects the retained archive. I did not execute it because this review checkout is read-only.

Is this the best way to solve the issue?

Yes: centralizing artifact selection, materialization, indexing, and archive-only policy in one reader is better than preserving three filesystem readers or adding more façade-level guards, because all callers now share the same SQLite-first/reset-archive invariant.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a88f3ffc9609.

Labels

Label justifications:

  • P2: The PR changes session-history fallback and context retrieval, but it is an internal refactor with bounded blast radius and successful focused validation.
  • merge-risk: 🚨 session-state: The changed archive, pagination, by-id, and anchor paths choose which transcript records are returned as session history.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR documents post-integration Testbox build and focused archive/anchor/pagination/reset lifecycle runs, and the supplied check context records successful real-behavior-proof checks for the exact head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR documents post-integration Testbox build and focused archive/anchor/pagination/reset lifecycle runs, and the supplied check context records successful real-behavior-proof checks for the exact head.

Evidence

What I checked:

  • Canonical archive-read owner: The branch defines ArchivedTranscriptReader as the single owner of live JSONL and reset-archive reads, with active-path precedence, reset-archive-only selection, and archive materialization in one boundary. (src/gateway/session-utils.fs.ts:429, 180554426b94)
  • SQLite-first fallback preserved: The gateway façade reads SQLite first; when it has no rows, each filesystem fallback explicitly requests resetArchiveOnly, preventing an obsolete active JSONL from winning after SQLite has already selected archive fallback. (src/gateway/session-transcript-readers.ts:283, 180554426b94)
  • Regression coverage: The added façade regression creates both an obsolete active JSONL and a retained reset archive, then asserts the SQLite-empty fallback returns the retained archive rather than the active file. (src/gateway/session-transcript-readers.test.ts:221, 180554426b94)
  • Prior behavior and provenance: The pre-refactor filesystem path already owned active-first/reset-archive selection in findExistingTranscriptHistoryPathAsync; blame attributes the adjacent anchor fallback implementation to Peter Steinberger in commit 02419ed1998feeaeaca21a92de7d23e805742f13. The PR centralizes that same decision instead of adding a competing fallback path. (src/gateway/session-utils.fs.ts:618, 02419ed1998f)
  • Current-main drift check: The base advanced from aa2a5c96f69a1be639c602649d4aa2e4de8da0a8 to current main a88f3ffc9609d6fc0b70e370160801dc66d8d14c only in Line, OpenRouter, session reconciliation, and UI paths; none overlap the eight transcript-reader files. The checkout is clean and the PR diff passes whitespace validation. (src/gateway/session-utils.fs.ts:429, a88f3ffc9609)
  • Release status: The PR head is not contained in latest release v2026.7.1; this remains an unmerged current-PR change rather than shipped behavior. (2d2ddc43d0dc)

Likely related people:

  • steipete: Peter Steinberger authored the existing nearby transcript fallback/anchor path attributed by blame to 02419ed199, authored this consolidation commit, and has the dominant local history share across the central reader files. (role: feature owner and recent area contributor; confidence: high; commits: 02419ed1998f, 180554426b94; files: src/gateway/session-utils.fs.ts, src/gateway/session-utils.fs-anchor.ts, src/gateway/session-transcript-readers.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-01T10:43:31.944Z sha 1805544 :: needs maintainer review before merge. :: none

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up move disposition:

  • Refresh exact current-main merge result and rerun focused coverage: intentionally skipped as a second refresh. This branch already performed the coordinated one-time rebase onto then-current main, followed by a green full pnpm build and 142 focused archive, anchor, pagination, SQLite, reset/delete lifecycle, revocation, and reader-boundary tests on Testbox. Exact-head CI is now fully green (81 pass, 41 skipped, 0 pending/fail). main advanced again only after the PR was ready; ClawSweeper's own path comparison found no overlap with the eight touched transcript-reader files. Repeating the rebase would invalidate the exact-head CI/proof without exercising a changed owner surface.

@steipete
steipete merged commit 4e47c4c into main Aug 1, 2026
264 of 278 checks passed
@steipete
steipete deleted the codex/goal100k-archive-reader-owner-0801-2d45 branch August 1, 2026 10:52
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant