Skip to content

fix(sessions): archive and read sessions through state path aliases - #181554

Merged
steipete merged 1 commit into
mainfrom
pgprep/pgfix-archivealias
Oct 23, 2026
Merged

steipete merged 1 commit into
mainfrom
pgprep/pgfix-archivealias

Conversation

@steipete

@steipete steipete commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes cron.remove, session deletion/archive, and retained cron history failing when the state directory is reached through a symlink or another filesystem alias.

User Impact

SQLite and PostgreSQL users can archive sessions and read retained history with an aliased state directory. No configuration changes or migration are required.

Why This Change Was Made

Like #181472, this fixes producer handoffs while preserving strict database-owner checks. Deletion planning already admits a canonical native owner, but the archive session was captured earlier with the logical alias. The lifecycle now creates that session after planning and passes its held native location. Retained-history selection separately captures the row owner's physical read source for comparison with publication facts; row lookup still uses its logical locator.

The sibling archive-read, archive-publication, context-worker, and pending-input guards remain strict. Their producers already use physical identities or consistently captured paths. No identity/receipt contract, schema, fallback, or freshness probe is added.

Evidence

  • Real pnpm openclaw gateway run on baseline 78121db97708, using a symlinked state directory and actual model turns: cron execution and ordinary chat succeed, then cron.remove and sessions.delete fail with SQLite archive request changed its captured database owner on both SQLite and PostgreSQL 17. Traces show the logical alias captured by the archive session versus the canonical native location from planning.
  • New lowest-real-boundary regression: archive/delete plus archived run-history read, and retained-history publication, both RED on baseline and all four cells GREEN with this change across SQLite and PostgreSQL. The test is appended to the database-worker conformance registration beside fix(sessions): allow first chat through symlinked state paths #181472's alias regression.
  • Existing archive-session, lifecycle-admission, retained-sharing, and cron-history suites: 36 tests pass. Core and infra-test typechecks, targeted lint, format, and diff checks pass.
  • Independent Codex review: no actionable P0–P2 findings. Simplification pass retained only the two producer fixes; production delta +64/-49, regression +144 lines.

Final-head real Gateway verification passes on SQLite and PostgreSQL 17: exact-marker retained cron history, cron removal, session archival and archived history, and session deletion producing the transcript archive. An extra generic history request after deletion is rejected identically through alias and canonical paths because deletion removes its live session binding; archived-run readback is covered through the archive owner by the committed regression. All three final-head PostgreSQL conformance shards executed and passed (1,126 tests passed; 37 configured skips). Logs were inspected, including all four new alias cases in shard 2.

CI 39936588151 completed with one confirmed inherited root failure: checks-node-compact-small-3, in the agents watch-discovery test. Baseline 7a1d72c44102 already registers the absent attempt-prompt-submit.steering.test.ts; baseline and candidate have identical 423-entry agents lists. The focused candidate test and baseline filesystem discovery both reproduce it. This PR’s added src/infra registration is excluded by the failing test’s agents filter. The CI aggregate is red only because of that inherited failure; landing uses the explicitly authorized native exception.

Sibling owner audit
Guard Producer guarantee
Archive-session captured owner Existing deletion planning admits the execution; its held native location now supplies the archive session.
Archive-read owner checks Archive discovery selects physical identity and birthtime through assertSessionStoreReadCandidate.
Archive publication Native database plans are checked against the admitted native location, then translated to the captured session path.
History worker captured absence The transcript reader supplies its canonical selected source and matching expected identity; the guard rejects an absent store appearing later.
Pending-input history, source, withdrawal captureSessionStoreReadTarget maps canonical candidate paths to captured physical identities; reads and writes retain identity and birthtime checks.
Retained-history publication Selection now captures the row owner's physical read source and compares it to the sharing owner's physical source.

Planning remains protected by its existing admission and held execution. Warm/native-maintenance paths, final transaction guards, and receipt settlement keep their existing ownership and lifetime.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 23, 2026 10:05
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 23, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T10:09:47.843209Z 7a649de Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@steipete
steipete merged commit 55477ab into main Oct 23, 2026
236 of 242 checks passed
@steipete
steipete deleted the pgprep/pgfix-archivealias branch October 23, 2026 10:31
@steipete

Copy link
Copy Markdown
Contributor Author

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

RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…181554)

(cherry picked from commit 55477ab)

Release adaptation: reproduced on stable (deleting an archived session through a symlinked state dir failed with "SQLite archive request changed its captured database owner"). Stable opens the archive session before reclamation and planning, so those now run first and the archive session and deletions use the admitted physical path; the metadata-only fast path does not exist on stable. The conformance test needs main-only mixed-engine fixtures; the archive case is ported as src/config/sessions/session-archive-alias.test.ts.
RomneyDa added a commit that referenced this pull request Oct 26, 2026
Release adaptation: compress the canRepairRuntime call (platform defaults to
process.platform, which the stable Doctor already reads), drop the redundant
identity-loss throw in session deletion (missing file identity keeps the
prepared scope), and register the stale-operator-source recovery case from a
test-support module so the line-cap ratchet stays flat.
tideclaw-bot added a commit that referenced this pull request Nov 4, 2026
Adapt 12 audited database fixes and eight large-conversation reader groups.
Stream archive materialization with bounded buffers, preserving full history.

Original sources:
#187496 8b38db5
#181554 55477ab
#179057 ff5b71a
#180414 2f2dc1e
#182444 a64daf7
#183410 fa9ca88
#175091 ca07b1b
#179089 a6f4826
#182446 84806d0
#157151 5cc6f4a
#174249 a09c26b
#172028 70856fb
#172970 dd9cdee
#177937 1bb6763
#182091 38bf89c
#190182 33e7baf
#189284 3d4fc94
#188450 3c8bd4d
#188483 b195f61
#190690 c51d733

Proof: 454 distinct tests in initial lane; 11 relevant repair tests.
Final integrated lint/type/format pass pending.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant