Skip to content

improve: avoid session-list rereads when model metadata changes - #157129

Merged
steipete merged 1 commit into
mainfrom
codex/catalog-row-facts
Sep 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/catalog-row-facts

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Refreshing model metadata makes busy session lists reread unchanged database rows before they can display the new model information.

User Impact

Model-catalog changes update session presentation with less database work. Real session, transcript, configuration, and store changes still require fresh facts. Schema, persisted data, permissions, Doctor, and update behavior are unchanged; no operator action is required.

Why This Change Was Made

The resident row owner now retains its complete accepted database snapshot for catalog-only rematerialization. It reuses the existing entry and ACP objects by reference, retaining a small snapshot envelope and optional transcript watermark. Cold archives retain no complete snapshot, and materialized archives keep the existing bounded cache.

Data publications revoke retained facts. Transcript updates also fence in-flight worker replies immediately, even while presentation refreshes are coalesced. Catalog renewal keeps its existing display ordering and validity checks.

Evidence

  • A regression through the registered sessions.list handler and real synthetic SQLite state fails before the fix: changing model limits rereads both unchanged rows. Afterward, limits and current activity-summary state update with zero additional row-fact/ACP worker reads and no host queries to the affected tables.

  • A real stored update held across catalog renewal is read once and appears with the new model limits. Forced fact invalidation still reacquires rows.

  • The existing transcript-window regression exposed a stale retained snapshot; it now proves immediate revocation and rejects a paused worker reply after another transcript append, while refresh coalescing remains intact.

  • 94 distinct focused tests pass. The final 40-case rerun covers catalog RPCs, accepted-facts lifecycle, and transcript/backfill behavior after the transcript fix; wall time was 87.887 seconds across three files with --maxWorkers=1. Broader sibling proof took 134.147 seconds across nine files. These totals include worker compilation and test setup, not only test bodies.

  • Independent managed review found no actionable P0–P2 issues. This is boundary proof of avoided reads, not a measured production latency improvement. Full changed checks passed (2,053.755 s wall, including production types, all 25 test type graphs, lint, dead exports, and storage/runtime guards). Exact-head hosted CI completed successfully: 125 jobs succeeded, 17 were skipped, and none failed.

  • Required per-file single-worker cost (pnpm test <file> --maxWorkers=1): sessions-list-config.test.ts 28.415 s wall (baseline with the regression: 40.662 s, expected unnecessary-read failure; new case 1.643 s); session-row-projection.accepted-facts.test.ts 116.274 s wall, 24 passing cases, 109.33 s Vitest duration (new case 2.030 s); session-row-projection.backfill.test.ts 54.567 s wall, 14 passing cases, 50.45 s Vitest duration (extended transcript/catalog race 1.796 s). The latter two measured fresh caches under concurrent checks, so compiler/import and host-load costs dominate and are not production latency measurements. Hosted CI ran the registered catalog regression in 1.095 s and its identity-scope sibling in 0.779 s; the containing Gateway-methods job passed in 665 s, including setup and unrelated cases. Individual CI timings for the two projection files are not yet available.

@clawsweeper

clawsweeper Bot commented Sep 24, 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. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 07:45
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 3:52 AM ET / 07:52 UTC.

ClawSweeper review

What this changes

The Gateway session-list projection retains accepted SQLite row facts so model-catalog updates can refresh displayed rows without rereading unchanged data, with documentation and regression tests.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main still rereads session facts after a model-catalog change. This PR addresses that work in the existing Gateway projection, and the reviewed changes show no concrete correctness defect.

Priority: P2
Reviewed head: 6a56e94c7ffbdcc60be0d4433862a12e40a1c74e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused boundary coverage and no identified correctness defect; the remaining validation gap is per-file test-cost reporting.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored contributor proof gate does not apply. The PR reports a before/after registered session-list check using synthetic SQLite and real worker reads; this read-only review inspected that test but did not execute it. No persisted data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored contributor proof gate does not apply. The PR reports a before/after registered session-list check using synthetic SQLite and real worker reads; this read-only review inspected that test but did not execute it. No persisted data contract changes.
Evidence reviewed 7 items Current main behavior: The fetched main revision increments the database revision when a replacement catalog changes and has no retained database-facts field, so the proposed optimization is not already on main.
Introduced retention boundary: The introduced patch retains accepted facts on resident rows, reuses them for catalog-only invalidation, and clears them on data invalidation and archive demotion.
Worker reply fence: The existing read owner accepts a worker reply only when global and per-row fact revisions still match; transcript notifications now advance the per-row revision immediately.
Findings None None.
Security None None.

How this fits together

Gateway session-list requests use a resident row projection fed by session storage and model metadata. The projection prepares row facts and returns current session presentation to clients.

flowchart LR
A[Model catalog update] --> C[Resident row projection]
B[Stored session changes] --> D[Invalidate retained facts]
D --> E[SQLite read worker]
E --> C
C --> F[Session list presentation]
F --> G[Gateway response]
Loading

Before merge

  • Resolve merge risk (P1) - The PR reports only aggregate test wall time; per-file cost and the scoped Gateway before/after benchmark remain unreported, leaving the recurring CI cost unquantified.
  • Complete next step (P2) - Add per-file single-worker wall times for the changed tests and a before/after benchmark for the affected Gateway test file; add CI seconds when those runs complete.
Agent review details

Security

None.

PR surface

Source +15, Tests +214, Docs +8. Total +237 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 24 9 +15
Tests 3 215 1 +214
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 247 10 +237

Review metrics

Metric Value Why it matters
Production and test delta production +24/-9 lines; tests +215/-1 lines The production growth is a small retained-facts lifecycle change; most added code exercises its read and invalidation behavior.
Reported focused run 87.887 seconds across 3 test files The aggregate cannot establish each changed file's recurring CI cost.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep catalog-only reuse in the resident projection, with committed storage and transcript publications revoking retained facts and archived rows remaining bounded.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep catalog-only reuse in the resident projection, with committed storage and transcript publications revoking retained facts and archived rows remaining bounded.

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

Yes. Current main advances the database revision on catalog replacement, and the added registered-handler test gives a focused SQLite read-count path; this review did not run it.

Is this the best way to solve the issue?

Yes. Reusing accepted facts in the existing projection, with its revision fences and publication invalidations, is a narrow way to remove the redundant reads.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Avoiding repeated database reads is a useful, bounded session-list performance improvement without evidence of an urgent user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored contributor proof gate does not apply. The PR reports a before/after registered session-list check using synthetic SQLite and real worker reads; this read-only review inspected that test but did not execute it. No persisted data contract changes.

Label justifications:

  • P2: Avoiding repeated database reads is a useful, bounded session-list performance improvement without evidence of an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored contributor proof gate does not apply. The PR reports a before/after registered session-list check using synthetic SQLite and real worker reads; this read-only review inspected that test but did not execute it. No persisted data contract changes.

Evidence

What I checked:

  • Current main behavior: The fetched main revision increments the database revision when a replacement catalog changes and has no retained database-facts field, so the proposed optimization is not already on main. (src/gateway/session-row-projection.ts:115, ffb17b275480)
  • Introduced retention boundary: The introduced patch retains accepted facts on resident rows, reuses them for catalog-only invalidation, and clears them on data invalidation and archive demotion. (src/gateway/session-row-projection-archive.ts:117, 6a56e94c7ffb)
  • Worker reply fence: The existing read owner accepts a worker reply only when global and per-row fact revisions still match; transcript notifications now advance the per-row revision immediately. (src/gateway/session-row-projection-read.ts:166, 6a56e94c7ffb)
  • Registered handler regression: The added test calls the registered session-list path with synthetic SQLite state, checks changed model limits and unchanged activity summaries, and counts worker and host reads. The PR body reports a before-fix failure and after-fix pass; this read-only review did not execute the test. (src/gateway/server-methods/sessions-list-config.test.ts:36, 6a56e94c7ffb)
  • Transcript regression: The expanded test checks that a transcript update during a paused worker read causes fresh facts to be read, including inside the coalesced refresh window. (src/gateway/session-row-projection.backfill.test.ts:117, 6a56e94c7ffb)
  • Test-cost policy: Repository policy requests single-worker wall time for each changed test file and a before/after benchmark of the affected Gateway test file. The PR body gives an aggregate 87.887-second run across three files, so the per-file cost remains unreported. (AGENTS.md:89, 6a56e94c7ffb)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Report single-worker wall time for each changed test file and the affected Gateway test file's before/after benchmark; add CI seconds when available.

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.

@steipete
steipete merged commit bebb6a4 into main Sep 24, 2026
289 of 290 checks passed
@steipete
steipete deleted the codex/catalog-row-facts branch September 24, 2026 08:13
@steipete

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

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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