Skip to content

fix: session creation fails through directory aliases - #158401

Merged
joshavant merged 1 commit into
mainfrom
codex/session-publication-owner-fanout
Sep 26, 2026
Merged

joshavant merged 1 commit into
mainfrom
codex/session-publication-owner-fanout

Conversation

@joshavant

@joshavant joshavant commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #155800

What Problem This Solves

Fixes session creation failing with Session creation publication owner is no longer current when the session database is reached through a directory alias, including macOS /tmp → /private/tmp.

User Impact

Sessions can finish asynchronous preparation, commit, and publication through an aliased database path while replaced, closed, and completed owners still reject. No configuration, schema, protocol, migration, or operator action changes.

The retained full live run on original head b3c31ec49720 was not green: 79 passed, 27 failed, 12 skipped. The targeted publication-owner failure disappeared from all 25 affected scenarios and the cumulative 118-scenario run. Residual failures and attribution limits are recorded below, separately from the rebased head’s successful CI.

Why This Change Was Made

The creation operation was still active and held the correct database identity, agent, and session key. Its source path used the caller's lexical locator, while prepared sharing facts selected SQLite's admitted filename. The exact-owner guard correctly rejected that mismatch. Publishing the subsequent header change under the lexical locator also invalidated the prepared facts.

Carry the already admitted filename through the existing worker snapshot, bind the creation owner to it, and reuse the existing active-creation custody predicate to publish its changes under that same path. Keep the original locator for writer-backend custody, file-identity validation, and reader revocation. Reopening the writer through another alias would compete with its existing backend owner.

This removes the lexical-path creation binding/publication paths. Ordinary non-creation publications retain their existing locator contract. The guard, stale-owner rejection, and receipt rules remain intact; no retries, timeouts, consumer guards, alternate owners, filesystem probes, QA special cases, or source-default overrides were added.

Production: +15/−12, net +3 lines across four files. Tests: +109/−3, net +106 lines in one existing suite. The publication refactor absorbs the custody predicate with zero net growth; three lines carry the missing admitted fact through the existing type/producer/consumer, avoiding a second path-resolution owner.

Evidence

Requested rebase

Rebased without conflicts onto 5be36d37cb73a4f9ddf23ed9ab4fe51a3797e25c, producing current head c04d502b8ba2862254b23e8318ea96549fa1aaad. Force-with-lease push verified. Range-diff preserves every repair hunk and test, including upstream’s new session-entry publication scope. No manual source/test changes or added commit were needed; LOC remains unchanged. All 11 retained summary/report/bisect files match their pre-rebase checksums.

Proportional current-head proof: all 10 focused owner/lifecycle/discovery/diagnostic test files passed across two sequential Vitest shards in 152.09s. The normal isolated mock runtime-tool-exec passed (1/1, 13.482s), exercising public sessions.create with two explicit non-main keys, tool-inventory reads, and subsequent turns. Its mock exec plans are diagnostic-only. Native QA cleanup completed and the separate CLI state root was removed. Sibling Codex’s exact-instance lifecycle contract was personally rechecked before the rebase verdict.

Exact-head CI passed: run 36209513075 completed with 127 successful jobs, 19 skipped, zero failures, including openclaw/ci-gate. All other exact-head workflows completed successfully or skipped; required aggregate CI/security checks passed. CI attached automatically to the Ready PR. No reruns, duplicate dispatch, repair commit, or additional re-review mention were needed.

Exact-head review: the automatic ClawSweeper review completed at 2026-09-26 01:52 UTC and pins c04d502b8ba2: Ready for maintainer review, no findings, security concerns, before-merge items, or requested rank-up work. The durable review link below now shows this current-head review. No actionable items or justified skips were needed.

Local check attribution: production types and all 25 core-test type graphs passed, as did formatting, ratchets, exports, dependency and boundary guards. The native changed-check command stopped at eslint(max-lines) in session-accessor.sqlite-entry-cache-publication.ts: 701 counted lines against 700. The unmodified file from base 5be36d37cb73a reproduces the identical 701-line failure under the same rule; this branch has zero net line growth in that file. This is a proven pre-existing base violation, left unchanged. All eight remaining storage/schema, media, sidecar, cycle, webhook, and auth checks passed when run separately after that stop. The local aggregate is not claimed green.

The affected-25 and full-118 results below are retained historical proof on b3c31ec497206236f9813e9416b935cb8ee243fe; those live campaigns were not rerun for this patch-preserving rebase.

Original behavioral proof

  • Frozen starting main: 4368865c48b5f86b3274350c76d5349b95381261. Tested behavioral head: b3c31ec497206236f9813e9416b935cb8ee243fe.
  • Pre-fix real entry point: unchanged runtime-tool-exec, normal mock-openai, isolated state/profile/Gateway: 0 passed, 1 failed with the exact guard error before model execution (15.162s).
  • Introduction: a focused owner-boundary harness using unedited historical creation-worker modules accepts at parent 0963fd5da97c12028b4df78c4515f1286b0cc835, rejects at ed81a70423faf3de9fb5fbda7a08f25831cdcb20, and rejects at frozen current main. This is historical boundary proof, not three historical full-Gateway runs. Shared-auth Doctor relocation predates the campaign baseline; it is not established as the cause.
  • Regression: the aliased-path test fails pre-fix at the exact guard. Real prepared sharing facts also expose the incomplete binding-only repair at the next commit boundary. Final tests retain the same creation operation across awaited preparation and header/commit/publication/registration, then reject ended, replaced, and closed owners.
  • Focused proof: 13 creation-worker tests plus 58 Gateway creation/collision/sharing/settlement, exact-read, and replacement-publication tests passed. Final isolated mock runtime-tool-exec passed.
  • Cost: pnpm test src/config/sessions/session-accessor.sqlite-creation-worker.test.ts --maxWorkers=1: 41.27s wall / 38.91s Vitest, including cold compiler refresh. Aliased positive case 3.16s; replacement/closure cases 0.82s/0.85s. Original-head Linux CI: all 13 passed; 32.16s summed reported test execution (excluding import/setup overhead), with 5.43s positive and 1.38s/1.31s stale controls. This existing worker suite exercises real SQLite admission, retained sharing facts, and publication that a cheaper mocked layer would bypass. No sleeps, polling, extra Gateway boots, or committed worker pinning.
  • Checks: native changed checks passed, including production types, all 25 core-test graphs, lint, formatting, exports, ratchets, storage/schema, dependencies, cycles, and auth guards. Ordinary autoreview of the completed publication behavior: scoped-clean, no actionable findings at its configured P0 threshold. The subsequent type-narrowing local is runtime-equivalent.
  • Original-head ClawSweeper: exactly one re-review mention was requested after b3c31ec49720 was pushed. Its review said Ready for maintainer review with no actionable items. The durable public review now contains the automatic review of rebased head c04d502b8ba2, described above.
  • Affected 25, live-frontier: 7 passed, 7 failed, 11 source-default fixture skips; zero publication-owner or prepared-facts continuation errors. Fixture skips occur after both real session creations. Remaining failures: missing live tool-call records for five tools, restart sentinel timeout, and two image deliveries instead of one.
  • Full 118, live-frontier, once on original head b3c31ec49720: 79 passed, 27 failed, 12 skipped, zero publication-owner errors. Default selection matches the previous 118 scenario titles; no model/runtime/fast overrides. Previous cumulative run: 75 passed, 43 failed.
  • Isolation: task-owned state and free-port Gateways only. Native cleanup completed; none of the 37 observed temporary roots or 33 recorded Gateway PIDs remain. The personal Gateway/state was not used.
Full-suite residual failures and attribution limits

Three scenarios passed in the retained previous run and failed here. Their cause is unresolved, not claimed unrelated or fixed: sender-scoped subagent tool inheritance returned a generic processing error; model-switch tool continuity missed kickoff continuity; heartbeat expected an existing config-owned monitor. Available scenario artifacts establish these assertions, not a branch-attributable root cause. No rerun or broader repair was used to turn them green.

The other 24 failing scenario titles also failed previously, although that alone does not prove identical causes:

Residual class Scenarios / observed failure
Live tool evidence (5) apply-patch, session_status, sessions_spawn, web_fetch, web_search: missing happy-path tool call
Runtime expectation (3) Codex harness no-meta-leak, long-context watchdog, Codex medium-game-plan: expected Codex runtime, default suite uses OpenClaw runtime
Delivery/progress timeouts (7) completion-handoff sender policy; approval resolver; secondary conversation isolation; config restart sentinel; bare-continue goal; thinking visibility; memory-flush recovery
Tool/ordering expectations (4) memory ranking lacked planned search; telemetry lacked expected ordered reads/write; cron creation lacked two native add calls; instruction-profile prompt evidence contained duplicate matching rows
Synthetic fixture reads (2) personal-redaction and secret-redaction scenarios did not reach their expected fake-secret read; this is not evidence of a secret leak
Image delivery (1) native image generation delivered two images instead of one
UI bootstrap (1) initial openclaw-app selector timed out after 360s, before text/image roundtrip; previous failure was later in the image roundtrip
Existing cron facts failure (1) model-created cron explicit authority: a first inbound row commit invalidates an in-flight missing-row chat.history read; controlled proof reproduces before the introducing commit, with and without an alias

A background SQLite database already belongs to another worker backend diagnostic is independently reported on unmodified main in PR #158120. This is corroborating baseline evidence, not a claim that every residual has that cause.

The cron attribution was traced separately after the cumulative run. Two isolated diagnostic runs captured the failing stack and its triggering first-row facts.kind=entry publication from the native entry writer. No creation operation is bound to that history read. A controlled real-writer harness then reproduced the same rejection on both 0963fd5da97c12028b4df78c4515f1286b0cc835 and original candidate b3c31ec49720, with canonical and aliased paths; fresh post-commit reads succeed in all four cells. History reports the invalidation as a retryable UNAVAILABLE response. This is distinct from the repaired creation-owner path mismatch. The task owner explicitly retained the one-root scope after reviewing this evidence; no history guard, retry handling, or QA assertion was changed.

Original-head CI residuals (b3c31ec)

Native scripts/pr ci-dispatch attached run 36197512406 to original head b3c31ec49720 because ordinary draft PR checks are skipped. No check, runner, or source-default override was added.

Completed: 203 successful jobs, 12 skipped, three failed test jobs plus the failed aggregate openclaw/ci-gate. The run is not green. The changed creation-owner suite, config/session job, Gateway-method job, and changed checks passed. No failure attributable to this branch was found; the three residuals below remain visible for maintainers.

  • Windows Node test 1: gateway-cron-process-identity.windows.test.ts timed out waiting for Gateway readiness after 60 seconds. Logs show slow startup/checkpoint/schema SQLite work. The test fails in instance.startGateway(), before connecting or creating its cron job/session; this does not exercise the repaired creation boundary. The underlying Windows startup delay is unresolved.
  • UI E2E shard 8: mobile-pairing.e2e.test.ts:481 timed out reopening the Pair a device dialog. This test installs a mocked Gateway and does not execute the changed SQLite owner code. The UI timeout remains unresolved.
  • Infra runtime shard 5: subagent-registry.test.ts:798, “retries a terminal completion deferred by restart drain,” expected its mocked announcement once but saw zero calls. This test mocks the session accessor, Gateway calls, and announcements; the failing restart-drain scheduling path does not create a session through the changed owner. Its scheduling failure remains unresolved; 1,934 sibling tests passed.

These original-run failures were inspected and classified without CI reruns or unrelated changes. The later explicit rebase request and its fresh CI result are recorded above.

Personally inspected sibling Codex contract and retained evidence

Sibling Codex at 39598ed17885970828acd42a6370131ed0190a98 was personally inspected before the implementation/verdict:

  • codex-rs/app-server-protocol/src/protocol/v2/thread.rs:48–130,188–225: thread/start parameters and response.
  • codex-rs/app-server/src/request_processors/thread_processor.rs:1125–1185,1313–1405,1470–1520: awaited preparation/start and failed-start metadata cleanup.
  • codex-rs/core/src/thread_manager.rs:2280–2365: await spawn and SessionConfigured, insert the exact thread instance, then notify readiness; :1349–1367 checks Arc::ptr_eq before removing the expected instance.

These contracts preserve exact-instance custody across async preparation. No Codex adapter/protocol change is needed for this pre-model OpenClaw failure.

Local evidence root: .artifacts/qa-e2e/session-publication-owner/ in the task checkout. Retained reproduction/introduction evidence: pre-fix/qa-suite-summary.json, pre-fix/qa-suite-report.md, bisect.log. Requested cumulative artifacts:

  • affected-25-b3c31ec49720/qa-suite-summary.json and qa-suite-report.md
  • full-118-b3c31ec49720/qa-suite-summary.json and qa-suite-report.md
  • rebase-c04d502b8ba2-mock/qa-suite-summary.json and qa-suite-report.md

Raw runtime logs, prompts, credentials, and agent transcripts are not published. Current GitHub searches found no suitable existing fix to reuse.

This PR is for maintainer review only; no merge, queue, or automerge is requested.

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 9:52 PM ET / September 26, 2026, 01:52 UTC (Revision 3).

ClawSweeper review

What this changes

The branch makes session creation use SQLite’s admitted database path for creation ownership and publication, and adds alias and stale-owner regression tests.

Regression provenance

Possible regression — suspected (failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Current main still has the reported directory-alias failure, and no merged fix supersedes this PR. The focused repair appears correct; this review found no actionable patch defect.

Priority: P2
Reviewed head: c04d502b8ba2862254b23e8318ea96549fa1aaad

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, source-supported repair has relevant worker regressions and reported Gateway proof, with no actionable defect found.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The COLLABORATOR author is exempt from the ordinary contributor proof gate. The captured body reports a pre-fix Gateway failure and after-fix session creation through the real Gateway with a mock provider, plus no owner error in the affected live scenarios; these observations concern the changed creation and publication owners, though the named behavioral head is older than this reviewed head. No stored-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 COLLABORATOR author is exempt from the ordinary contributor proof gate. The captured body reports a pre-fix Gateway failure and after-fix session creation through the real Gateway with a mock provider, plus no owner error in the affected live scenarios; these observations concern the changed creation and publication owners, though the named behavioral head is older than this reviewed head. No stored-data contract changes.
Evidence reviewed 9 items Current-main failure path: The current-main creation worker binds the publication owner to the caller’s lexical scope path, while SQLite admission records a separate filename. An aliased caller can therefore fail the exact-path owner check.
Admitted database identity: The database owner captures the SQLite filename and physical identity when the connection opens; the branch carries that existing fact into the creation snapshot.
Introduced owner binding: The proposed worker binds creation to the admitted database path while retaining the original scope path for reader currency and file-identity validation.
Findings None None.
Security None None.

How this fits together

The Gateway prepares a session from a SQLite read snapshot, then a worker commits its transcript and session row. Publication updates the prepared facts used by subsequent session operations.

flowchart LR
A[Session creation request] --> B[SQLite read worker]
B --> C[Admitted path and identity]
C --> D{Creation owner current?}
D -- Yes --> E[Session write worker]
E --> F[Publish row and sharing facts]
F --> G[Session available]
D -- No --> H[Reject stale creation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +106. Total +109 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 15 12 +3
Tests 1 109 3 +106
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 124 15 +109

Review metrics

Metric Value Why it matters
Production and test delta production net +3 lines; tests net +106 lines The small production change carries an admitted fact; the expanded existing suite exercises alias creation and stale-owner rejection.
Creation-worker test cost 13 cases; 41.27s local wall and 32.16s reported CI execution The PR records the cost of exercising SQLite admission and publication through the existing worker suite.

Technical review

Best possible solution:

Use the admitted SQLite path for creation custody and its publication event while preserving live checks against the caller’s original locator.

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

Yes, from source and the supplied pre-fix Gateway result: an aliased store locator differs from SQLite’s admitted filename and reaches the exact creation-owner rejection. This read-only review did not execute the flow.

Is this the best way to solve the issue?

Yes. Reusing the filename captured by SQLite admission is a narrow repair, and the original locator still controls identity and revocation checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Directory aliases can block session creation, but the evidence supports a bounded fix rather than a core-runtime emergency.
  • merge-risk: 🚨 session-state: Creation publication changes which database path identifies session-row events; matched-identity guards and stale-owner tests reduce that risk.
  • 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 COLLABORATOR author is exempt from the ordinary contributor proof gate. The captured body reports a pre-fix Gateway failure and after-fix session creation through the real Gateway with a mock provider, plus no owner error in the affected live scenarios; these observations concern the changed creation and publication owners, though the named behavioral head is older than this reviewed head. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • joshavant: 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 September 25, 2026, 6:52 PM ET / 22:52 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T23:33:43.240Z sha b3c31ec :: needs maintainer review before merge. :: none

@joshavant
joshavant marked this pull request as ready for review September 25, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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