Skip to content

fix(sessions): avoid blocking completion recovery on archive metadata - #160238

Merged
steipete merged 1 commit into
mainfrom
codex/archive-metadata-preflight-20260928
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/archive-metadata-preflight-20260928

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #149506

What Problem This Solves

Completed-child answer recovery still reads archive registration and physical store ownership synchronously on the Gateway thread before scanning an archived transcript.

User Impact

Durable archive preflight now runs in the existing history worker. Missing and empty archives still skip archive-reader startup. Positive reads retain their original physical database and logical session through discovery, metadata reads, integrity verification, and cleanup. Stored data, schemas, retention, and update behavior are unchanged. Incognito preflight continues through its existing process-owned native owner.

Why This Change Was Made

The async facade captures filesystem candidates and identities before its first wait, then reuses the canonical archive selector in the history worker. The final archive reader receives that same identity. A same-content database replacement cannot become the lookup's source, and a result held after real metadata acknowledgement cannot escape owner retirement. The existing empty-archive behavior is preserved.

Evidence

  • Causal host-SQL regression: the original facade produced 6 API calls for a pre-archive store and 54 for each cold shared-store positive lookup; the corresponding fixed windows produce 0. Counts cover prepare, exec, get, all, run, and iterate, excluding fixture setup and cleanup.
  • Both changed owning files pass in full: 8 tests covering empty/missing stores, shared physical-main/logical-ops ownership, source replacement, retirement, hash/header corruption, archive pages, multiline and oversized content, and incognito no-disk behavior. With one worker, archive-read test time was 22.308s and transcript-match test time was 1.807s; combined command wall time was 44.542s.
  • The original registered sessions.send yield/resume regression passes with no archive-reader dispatch: 1.912s test time, 31.443s command wall time.
  • node scripts/check-changed.mjs --base 45b00bdd13c17000884d362f6aaef3a5a7de32ea passes, including core plus all 25 test type graphs, lint, export checks, and runtime import-cycle checks. pnpm build passes. Independent review found no actionable P0–P2 findings.

Runtime and build proof used an independent Linux/Node 24.19 checkout with a frozen pnpm 12.5.1 installation and source hashes verified between phases. A local Mac Gateway attempt stalled before fixtures; the isolated Linux run completed without changing test timeouts.

Exact-head CI attempt 1 failed four existing daemon retained-custody cases. The original 18-file CI group reproduces exactly those four failures on its unchanged main baseline (c136ec63146424aafdbeccd48d2f4f9c59fbaa22): 876 passed, 4 failed, 29 skipped. The failure inputs are identical in the tested merge. Fail-fast cancelled sibling coverage; the subsequent missing-proof upload failure is explicitly retained in the native evidence packet: its producer was skipped and neither declared output existed. The maintained native route revalidates this cancellation qualification, security, and required reviews before admission. CI is not green, and no cancelled coverage is claimed as passing.

Move durable archive registration and source discovery into the existing
history worker. Capture source custody before waiting, preserve the empty
archive fast path, and keep incognito preflight with its native owner.

Cover source replacement, owner retirement, archive integrity, and the
registered requester yield/resume flow without changing stored data.
@clawsweeper

clawsweeper Bot commented Sep 28, 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 size: M labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 07:16
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 5:39 AM ET / 09:39 UTC (Revision 3).

ClawSweeper review

What this changes

Moves durable archive discovery and registration checks into the session history worker, binds the final read to the selected database, and adds regression coverage.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open. Current main still reads archive metadata synchronously during completed-child answer recovery. This PR addresses that path, and the review found no discrete patch defect.

Priority: P2
Reviewed head: 65dc00ed8b589624e72ec1a28ffd63c53d570358

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Real worker and database boundary evidence is strong, and the patch has no identified correctness defect; native CI admission remains outstanding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports an independent Linux/Node run of the production archive accessor with real SQLite history and archive workers: empty and positive lookups completed, host SQL calls fell to zero, and injected replacement and retirement cases rejected stale results. No stored-data contract changes, so migration compatibility proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports an independent Linux/Node run of the production archive accessor with real SQLite history and archive workers: empty and positive lookups completed, host SQL calls fell to zero, and injected replacement and retirement cases rejected stale results. No stored-data contract changes, so migration compatibility proof is not applicable.
Evidence reviewed 8 items Current main still blocks on metadata: The fetched main revision calls the synchronous database reader and archive-list query before dispatching the archive worker.
Introduced worker handoff: The PR captures candidate database identities before waiting, sends durable archive presence reads through the history worker, and rechecks identity and owner state before returning a result. The verified test merge retains this introduced change against its pinned main parent.
Archive and authority checks: The worker checks the captured file identity around metadata reads; the final archive reader checks the opened database identity, logical agent and session, and archive hash.
Findings None None.
Security None None.

How this fits together

When a child agent finishes, OpenClaw may recover its final answer from an archived transcript. The session archive accessor selects the agent database, checks for an archive, and passes the read result back to completion handling.

flowchart LR
 A[Child completion] --> B[Archive lookup]
 B --> C[Store selection]
 C --> D{History worker finds archive?}
 D -- No --> E[No archived answer]
 D -- Yes --> F[Archive reader]
 F --> G[Parent answer]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI admission remains incomplete: the native landing workflow must verify the reported pinned-base daemon failures and the cancelled proof-upload qualification before merging.
  • Complete next step (P2) - Have the native landing workflow verify the inherited daemon failures and cancelled proof-upload qualification before merge.
Agent review details

Security

None.

PR surface

Source +201, Tests +148, Docs +8. Total +357 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 236 35 +201
Tests 2 155 7 +148
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 399 42 +357

Review metrics

Metric Value Why it matters
Host SQL calls 6 or 54 before → 0 after, as reported The measured calls directly target the Gateway-thread work this PR removes.
LOC by role production +236/-35; tests +155/-7 Production growth supports worker handoff and identity checks; the added tests exercise the affected boundary.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the worker-owned archive preflight once native admission accepts the inherited CI failure, preserving the incognito owner and physical database identity checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the worker-owned archive preflight once native admission accepts the inherited CI failure, preserving the incognito owner and physical database identity checks.

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

Yes, at source level: current main synchronously queries archive registration in the completed-child lookup, and the PR reports measured host SQL calls before and after the change. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes. The patch uses the existing history worker and archive selector, preserves process-owned incognito reads, and checks database identity and retirement before using a result.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded responsiveness and completion-recovery improvement with no demonstrated broad outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports an independent Linux/Node run of the production archive accessor with real SQLite history and archive workers: empty and positive lookups completed, host SQL calls fell to zero, and injected replacement and retirement cases rejected stale results. No stored-data contract changes, so migration compatibility proof is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports an independent Linux/Node run of the production archive accessor with real SQLite history and archive workers: empty and positive lookups completed, host SQL calls fell to zero, and injected replacement and retirement cases rejected stale results. No stored-data contract changes, so migration compatibility proof is not applicable.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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 (2 earlier review cycles)
  • reviewed 2026-09-28T07:23:55.216Z sha 65dc00e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T08:07:24.442Z sha 65dc00e :: blocked before merge. :: none

@steipete
steipete merged commit da51d9e into main Sep 28, 2026
177 of 301 checks passed
@steipete
steipete deleted the codex/archive-metadata-preflight-20260928 branch September 28, 2026 10:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…openclaw#160238)

Move durable archive registration and source discovery into the existing
history worker. Capture source custody before waiting, preserve the empty
archive fast path, and keep incognito preflight with its native owner.

Cover source replacement, owner retirement, archive integrity, and the
registered requester yield/resume flow without changing stored data.
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 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: 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