Skip to content

fix(bay): keep lifecycle history visible beyond 10,000 records - #1362

Merged
steipete merged 2 commits into
mainfrom
codex/lifecycle-bay-scan-20260902
Sep 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/lifecycle-bay-scan-20260902

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #1180

What Problem This Solves

Resolves a problem where OpenClaw Bay's durable lifecycle board becomes unavailable once accumulated history exceeds 10,000 records, even while the active queue is healthy. The production endpoint returned unknown / over_cap with null inventory, lanes, and sample at 2026-09-02T21:20:53Z on deployment ff071968ca4e3fa62c364f9642e10a03c2fda025.

Why This Change Was Made

SQLite supplies complete inventory counts while the existing validator/reducer streams every selected historical row in one synchronous transaction. Only 24 candidate cards per lane survive, and current revisions are resolved for the final 24-card sample. Worker and browser counts accept safe integers. Invalid historical facts still make the whole projection unavailable; reads never prune or rewrite history.

The public route caches its sanitized response through Cloudflare's native Cache API for up to 20 seconds, scoped by origin and the normalized verified-public repository set. Hits preserve generated_at; expiry never exceeds the remaining 60-second freshness allowance. Cache failures use a fresh read, and failed refreshes never resurrect an expired success. Clients still receive Cache-Control: no-store.

Maintainer disposition of the scan-cost P2: the response cache addresses repeated viewer amplification. We explicitly accept the remaining O(history) work per cache miss and its cost on the shared queue Durable Object to preserve complete totals and full historical validation without another stored summary or duplicated validator. Per-data-center caching, eviction, and simultaneous misses do not provide a hard global request budget or constant scan cost.

User Impact

Maintainers retain complete lifecycle counts and a small public card sample as history grows. Earlier revisions and rare terminal/acknowledgement lanes remain represented. Repeated views reuse a recent observation, with up to 20 seconds of cache delay. Queue behavior and GitHub mutation authority are unchanged.

OpenClaw Bay Impact

This fixes the durable lifecycle Kanban API and browser consumer. Native Worker proof covers inventory, historical validation, and response caching. Real Chrome captures separately show the same synthetic input rejected by the old renderer and displayed with all six lanes, counts, and 24 cards by the current renderer. The final renderer and assets are byte-identical to the captured candidate.

Before:

Bay before the lifecycle inventory fix

After:

Bay after the lifecycle inventory fix

Documentation Impact

Updated the active docs/openclaw-bay-demo.md observer guide with streaming validation, bounded samples, linear miss cost, 20-second per-data-center caching, and the unchanged 60-second freshness contract. ClawSweeper maintainers own it; production projectors/renderer remain authoritative. Its verification metadata points to this PR's exact revision and proof. Validation, sampling, public projection, and freshness changes require corresponding guide updates.

Evidence

Final head ea9853f2a67980b488c0ee2cc61440fef6cd81d4, tree de4fa470c9388d236bca3e4b1ce3d01f21eadb9d. Managed Codex P0 reviews of the staged candidate and complete committed branch against ff071968ca4e3fa62c364f9642e10a03c2fda025 passed with no actionable findings. Six focused lifecycle-route tests passed, including reuse, expiry/scoping, malformed/stale cache, remaining-age TTL, and cache failure controls. Repair/dashboard builds, targeted lint, pinned formatting, and documentation checks passed; the existing native SQLite regression also passed.

The previous green CI and hosted review applied to ee6d9f, not this cache follow-up. The current head and body require fresh hosted review and a successful full pnpm run check before landing; neither is claimed complete here.

Real Behavior Proof

Executed production worker.fetch, the inherited lifecycle Durable Object reader, SQLite, and native Cache API on local macOS arm64, Node 24.20.0, Wrangler 4.107.0, and workerd 1.20260701.1. The command was node native-proof.mjs CANDIDATE WRANGLER FRESH_OUTPUT. The 2026-09-02T21:59–22:00Z run tested staged tree de4fa470…, subsequently committed unchanged as the final head above. All 1,344 tracked contents/modes and the index matched before/after; source-manifest SHA-256 is 95e9928921739393e1928d20662bcce0ce414eda5afea01562dd7409e66284b8.

The fixture seeded 10,001 primary-scope rows plus three secondary-scope rows through the production store. Sixteen public HTTP observations required six inherited lifecycle reads, excluding the separately recorded empty seeding barrier. The primary response contained 10,001 records / 10,000 target revisions / 9,999 targets, all six lanes, and 24 sanitized cards. Immediate and ignored-query repeats retained identical bodies/timestamps without another read. Different scope/origin required their own reads; equivalent normalized repository sets reused entries. Every response was client no-store.

After corrupting an old row outside the sample, the immediate request retained the cached success. Following a real 21.512-second wait, the owner returned unknown / malformed; its repeat cached that unknown response. After restoration and another 21.513-second wait, complete counts/lanes/cards returned with a new timestamp. Every public GET preserved row/byte/DML counters; only the two explicit corruption/restore writes changed storage. The process group stopped, its listener refused connections, and its runtime directory was removed.

The earlier uncached baseline/candidate proof at ee6d9f remains applicable to the unchanged reader: baseline unknown / over_cap, complete candidate inventory, older-current-revision handling, malformed/missing-fact rejection, and restoration on the same instance. Observed 10,001-row reads were approximately 55–85ms on misses and 4–6ms on hits, locally. Two 100,001-row stress attempts were inconclusive during fixture setup/state observation, before any production lifecycle API read; they provide no reader performance or capacity evidence.

Cache proof SHA-256 identifiers:

driver:  c4013cb1fffdb861b2151a2f62b7cf97e8e4a54d559590359f7e7914a919b972
fixture: 20b34f75e335655fa7bf49e411cb04fb48af5588edd8b6fd51da6aff954b4f13
result:  f445acbe8f7e50478e31052b5cb765572276577e5bcbb541343c804cf4a860f7

Retained evidence includes exact HTTP responses, reader counters, native runtime identity, source manifests, and cleanup receipts. Limits: controlled local native proof, not production deployment, multi-data-center behavior, or an OS-level network sandbox. No real credentials, GitHub writes, model inference, or natural backlog convergence were involved. Chrome used separate synthetic presentation fixtures, not replayed native HTTP traces; captures were inspected for sensitive content. Cache rejection and remaining-age caps were tested separately in focused unit tests.

Replace the 10,000-record history cap and JavaScript identity sets with SQL inventory counts and a streaming validation pass. Keep only the bounded lane samples, then resolve current revisions for the public 24-card sample in the same read transaction.

Preserve fail-closed malformed-history handling and read-only durable facts. Accept safe integer inventory counts through the Worker and browser, and document the remaining linear validation cost. Cover growth beyond 10,000 records, earlier revisions across fences, rare lanes, and corrupt historical rows.

Verified paired native workerd behavior and synthetic Chrome rendering. The full current-head CI gate remains required before landing.
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 6:10 PM ET / 22:10 UTC.

ClawSweeper review

What this changes

The PR removes Bay’s 10,000-record lifecycle cap, streams and validates historical lifecycle rows with bounded samples, and briefly caches the sanitized public response.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this current, meaningful PR fixes Bay’s known 10,000-record failure and is not on current main. The previous scan-cost finding is addressed by a short-lived cache and an explicit acceptance of the remaining full-history cache-miss cost.

Priority: P2
Reviewed head: ea9853f2a67980b488c0ee2cc61440fef6cd81d4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered reliability fix with strong real-path proof; the documented cold-read availability tradeoff remains a maintainer-visible merge risk.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied exact-head terminal proof exercises the changed production Worker fetch path through the Durable Object lifecycle reader, SQLite, and native Cache API: a 10,001-row fixture returned complete inventory and lanes, repeated requests reused the snapshot, expiry exposed old-row corruption fail-closed, and restoration recovered the response.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied exact-head terminal proof exercises the changed production Worker fetch path through the Durable Object lifecycle reader, SQLite, and native Cache API: a 10,001-row fixture returned complete inventory and lanes, repeated requests reused the snapshot, expiry exposed old-row corruption fail-closed, and restoration recovered the response.
Evidence reviewed 5 items Streaming lifecycle implementation: The introduced reader counts selected records in SQL, validates every selected projection in one synchronous transaction, retains only lane samples, and resolves current revisions only for the final sample.
Scoped cache implementation: The public route keys cache entries by request origin and normalized verified repository scope, preserves the 60-second freshness limit, and falls back to a fresh lifecycle read when cache access fails.
Focused regression coverage: The added lifecycle test seeds 10,001 allowed rows, checks all six lanes and bounded revision lookups, and verifies malformed historical rows fail closed without writes.
Findings None None.
Security None None.

How this fits together

OpenClaw Bay reads lifecycle history from the queue Durable Object and exposes aggregate counts plus a small sanitized sample through a public Worker endpoint. The browser validates that endpoint before rendering the read-only lifecycle board.

flowchart LR
  History[Lifecycle history]
  Reader[Durable Object reader]
  Validation[Validation and lane reducer]
  Snapshot[Sanitized lifecycle snapshot]
  Cache[Short-lived edge cache]
  Api[Public Bay API]
  Browser[Bay board]
  History --> Reader --> Validation --> Snapshot --> Cache --> Api --> Browser
Loading

Before merge

  • Resolve merge risk (P1) - Cold cache misses still parse and validate the full selected lifecycle history in one synchronous Durable Object transaction; substantially larger histories or simultaneous cache misses can still make Bay unavailable.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Runtime and regression coverage runtime +175/-144; tests +450/-31; docs +20/-4 The net runtime growth is small relative to focused coverage for over-10,000-row lifecycle reads, fail-closed validation, and cache behavior.

Root-cause cluster

Relationship: canonical
Canonical: #1362
Summary: This PR is the canonical fix for lifecycle inventory becoming unavailable after retained history exceeds the former cap.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented cold-read cost (recommended)
    Land with the explicit acceptance that a cache miss validates complete selected history and may become unavailable at much larger scale.
  2. Pause for a bounded projection design
    Keep the PR open only if maintainers no longer accept full-history validation and want a separately designed bounded aggregate or projection.

Technical review

Best possible solution:

Retain the complete, fail-closed lifecycle projection with the scoped short-lived cache, while monitoring cold-read cost and revisiting the storage design if the accepted full-history scan exceeds Durable Object limits.

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

Yes, at high confidence: the prior capped reader and the supplied native proof establish the over-10,000-row failure path, while the current branch exercises the repaired Worker and Durable Object route.

Is this the best way to solve the issue?

Yes. The implementation removes the incorrect history-size cap while preserving fail-closed validation and bounded retained samples; the remaining cold-read availability tradeoff is explicitly documented and accepted in the PR body.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Bay observability reliability repair with limited user-facing blast radius.
  • merge-risk: 🚨 availability: Each cold cache miss intentionally performs full-history validation in a synchronous Durable Object read.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The supplied exact-head terminal proof exercises the changed production Worker fetch path through the Durable Object lifecycle reader, SQLite, and native Cache API: a 10,001-row fixture returned complete inventory and lanes, repeated requests reused the snapshot, expiry exposed old-row corruption fail-closed, and restoration recovered the response.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head terminal proof exercises the changed production Worker fetch path through the Durable Object lifecycle reader, SQLite, and native Cache API: a 10,001-row fixture returned complete inventory and lanes, repeated requests reused the snapshot, expiry exposed old-row corruption fail-closed, and restoration recovered the response.

Evidence

What I checked:

  • Streaming lifecycle implementation: The introduced reader counts selected records in SQL, validates every selected projection in one synchronous transaction, retains only lane samples, and resolves current revisions only for the final sample. (dashboard/exact-review-lifecycle.ts:891, ea9853f2a679)
  • Scoped cache implementation: The public route keys cache entries by request origin and normalized verified repository scope, preserves the 60-second freshness limit, and falls back to a fresh lifecycle read when cache access fails. (dashboard/worker.ts:5397, ea9853f2a679)
  • Focused regression coverage: The added lifecycle test seeds 10,001 allowed rows, checks all six lanes and bounded revision lookups, and verifies malformed historical rows fail closed without writes. (test/exact-review-lifecycle-bay.test.ts:9, ea9853f2a679)
  • Feature history: Recent lifecycle/Bay history includes Martin Cleary’s merged lifecycle projection work, while the branch’s two commits build the current fix and cache follow-up on top of the current main baseline. (dashboard/exact-review-lifecycle.ts:859, 91a2bf645327)
  • Current-head behavior proof: The PR body reports a native Worker, Durable Object, SQLite, and Cache API run at the exact final head: 10,001 lifecycle rows remained complete, cache reuse/expiry respected freshness, an old corrupt row failed closed after expiry, and restoration recovered the complete snapshot. (ea9853f2a679)

Likely related people:

  • Martin Cleary: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-02T21:35:25.896Z sha ee6d9f5 :: blocked before merge. :: [P2] Bound lifecycle work before serving the public route

Cache sanitized lifecycle responses for up to 20 seconds, scoped by origin
and the verified public repository set. Preserve the original observation
time and remaining 60-second freshness allowance, and read the current
owner when cache entries expire or the cache fails.

This reduces repeated history scans from public refreshes without adding
stored aggregates or another recovery path. Native workerd proof covers
snapshot reuse, scope isolation, real expiry, historical corruption, and
recovery on the unchanged lifecycle reader.
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer disposition: accepted the remaining full-history cost on cache misses, including the possibility of unavailability at substantially greater scale. The scoped native cache reduces repeated viewer work while preserving the existing validator and complete totals; it is not a global work budget.

The current review explicitly considers the former P2 addressed and reports no code or security findings. This records the owner decision already present in the PR body. No further author change is requested for that tradeoff. Current-head CI passed, and the native Worker/cache proof is accepted. Proceeding with the reviewed ea9853f2a67980b488c0ee2cc61440fef6cd81d4.

@steipete steipete added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@steipete
steipete merged commit f9cd78c into main Sep 2, 2026
17 of 20 checks passed
@steipete
steipete deleted the codex/lifecycle-bay-scan-20260902 branch September 2, 2026 22:14
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Post-merge production verification passed for f9cd78c20c9d47151877ae88b050a589a301a274. The normal dashboard deployment and smoke test and post-merge CI succeeded. The public health endpoint reports this exact deployment revision.

Before deployment, the public lifecycle endpoint returned unknown / over_cap with no inventory. At 2026-09-02T22:17:20.138Z, the deployed reader returned complete: 149,502 lifecycle records, 95,501 target revisions, and 23,801 unique targets, with all six lane totals and a bounded sample of 24 cards. This is direct production evidence beyond the separately documented 10,001-row native fixture.

The first observed request took 7.184 seconds. A subsequent request took 0.311 seconds and returned exactly the same body and generation timestamp; both responses were HTTP 200 with Cache-Control: no-store. These are request observations, not a latency guarantee or a measurement of Durable Object CPU. Cache misses still scan full history; the native response cache bounds repeated reads within its documented per-location scope and short lifetime.

Verification used public GET requests. The separate post-deploy Chrome inspection was inconclusive because the browser inspection connection timed out. The synthetic before/after browser proof and native runtime proof recorded in the PR remain the completed UI and runtime checks.

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

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant