Skip to content

fix(gateway): preserve stored session addresses across main alias changes - #156109

Merged
vincentkoc merged 3 commits into
mainfrom
bug-session-main-address-repro-20260923
Sep 23, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
bug-session-main-address-repro-20260923

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes cold Gateway initialization failing when a main-session alias change leaves a valid session at its old stored address.

User Impact

Gateway can initialize and keep stored session identity and ACP metadata after main-session alias changes. Existing literal parents retain their model, navigation, and filter relationships across warm and archived views. Public request aliases still follow the current configuration, and historical missing-parent inheritance remains compatible.

A deleted literal parent can still rebind through the shipped missing-parent alias fallback. Distinguishing a formerly literal reference from a historical alias-only reference needs an explicit owner/upgrade decision; that pre-existing ambiguity remains a named follow-up.

Why This Change Was Made

Canonical storage already preserves qualified addresses, but Gateway consumers interpreted those stored addresses again as request aliases. Federation could reject a valid row, and sibling ACP/model/display readers could look up a different session.

One shared lineage selector now chooses an existing literal parent before the current alias. Model inheritance and global display/filter lineage consume the same captured selection after federation completes its inventory. Resident publications converge warm and cold parent indexes and both parents’ child links when a literal parent appears or disappears, without warming archives or acquiring new database facts. Prepared and unprepared ACP reads retain the selected literal address.

The existing absent-parent fallback, removed-default-owner resolution, raw global/unknown physical-store ownership, private dispatcher, and per-sender navigation stay intact. Read/admission failures propagate rather than triggering alias fallback. Captured fallback values and misses remain separate from literal-presence evidence.

Production: +209 net lines; tests: +440 net lines. The added production code owns shared address selection and cold metadata/index convergence, with topology seeding and cold updates placed in their existing record/archive owners. No schema, request-alias default, process cache, polling, or migration changes.

Evidence

  • Original real-writer regression: literal ACP metadata and dynamic request-alias controls passed, then cold Gateway projection initialization failed at federation with SessionCanonicalKeyMigrationRequiredError. Startup awaits this initialization; this was not a separate full-server run. One selected failure, 12 intentional filtered cases, no suite/unhandled/timeout error, and joined child. This proves the original federation failure only.
  • Measured baseline 445a7dad: 75 baseline cases across five full files passed. Candidate 53c92aa5 / tree 28db9d65: 147 cases across ten full files passed, plus Gateway-root, agents-sessions, and core types. Coverage includes both ACP paths, literal/current-parent collisions, missing-parent compatibility, cross-agent private parents, exact-read errors, and parent-filter selection before cold child materialization.
  • Reviewed source 0c3fb250 / tree b9d20d28: 46 cases across the full Worker (13), archived (8), and federation (25) files passed after the reviewed owner extraction and lexical renames. Gateway-root and core types, typed lint on all 19 changed paths, native line-cap ratchet, formatting, and final source guards passed. All eight command children exited zero, with no signal and joined cleanup; no test skips, suite errors, unhandled errors, or timeouts. The unchanged agents-sessions type result carries through the reviewed lexical rename; the earlier 147-case execution remains attributed to its original tree.
  • Current signed head 80dad67d / tree 50dec83d only makes the unused parent selector module-private and completes two usage fixtures with identity source-key resolvers. Independent review confirmed no production behavior or assertion changes; the prior runtime proof remains attributed to 0c3fb250. Exact-head CI 35810999211 passed on merge a354c415 (base 71802788 plus this head); all 21 PR file blobs match. The corrected full usage suites passed 38 cases (11 owner-attribution, 27 usage), with no skipped or failed cases in either file. Dependency/export checking, Gateway-methods types, owning lint, formatting, architecture, and the aggregate CI gate passed.
  • Fresh AutoReview is scoped-clean at P1. Independent runtime/storage reviews verified the stored-address owner boundary, current lookup API, replacement-publication ordering, and final extraction without new reads, cache, or archive materialization.

Full-file test-command costs, in seconds (cases / seconds):

File Base 445a7dad Candidate 53c92aa5 Reviewed 0c3fb250
Worker reads 12 / 33.289 13 / 31.165 13 / 36.997
Archived rows 7 / 22.119 8 / 26.408 8 / 28.899
Private rows 2 / 16.754 3 / 18.988 Carried source review
Store lookup 28 / 46.621 28 / 38.438 Carried source review
Session resolve 26 / 21.999 26 / 21.401 Carried source review
Federation Not measured 25 / 39.074 25 / 41.437

The four earlier owner-sibling files passed 44 cases in one 68.258-second command. These are validation costs with different case counts, not a product latency or CPU-speedup claim. Hosted CI finished with 128 successful jobs, 17 intentionally skipped jobs, and no failures. The durable ClawSweeper review covers 80dad67d, finds no actionable issue or remaining rank-up move, and confirms the shared owner repair as the best fix.

@vincentkoc vincentkoc self-assigned this Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 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 complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@vincentkoc
vincentkoc marked this pull request as ready for review September 23, 2026 02:27
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 11:12 PM ET / September 23, 2026, 03:12 UTC (Revision 2).

ClawSweeper review

What this changes

Preserves stored session addresses and runtime metadata after main-session alias changes, and keeps parent relationships consistent across active and archived session views.

Merge readiness

✅ Ready for maintainer review

This remains a useful Gateway fix: current main still reinterprets stored addresses during federation. No actionable introduced defect was found, and the earlier storage repair does not supersede this work.

Priority: P1
Reviewed head: 80dad67d2a1867965190000c9befb50f36a05edd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its recorded boundary runs exercise real session/ACP writers and cold projection initialization, with archived and private-session cases; this review inspected their source and attribution without rerunning them. No stored-data contract changes require migration proof.
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 PR is exempt from the external-contributor proof gate. Its recorded boundary runs exercise real session/ACP writers and cold projection initialization, with archived and private-session cases; this review inspected their source and attribution without rerunning them. No stored-data contract changes require migration proof.
Evidence reviewed 9 items Pinned introduction reviewed: Reviewed the merge-base-to-head production and test hunks. Endpoint drift was excluded from PR ownership. The supplied test merge is stale relative to the pinned base, so its contents were not used to claim what merging would remove.
Current main still needs the repair: Federation on fetched main resolves persisted qualified keys without preserveQualifiedAddress and throws when the resolved alias differs from the stored key. The central federation, model-source, key-selection, and record modules are unchanged from the pinned merge base.
Latest release check: The same rejecting federation path is present in v2026.9.5. Its source was inspected through GitHub after the local release blob was unavailable.
Findings None None.
Security None None.

How this fits together

The Gateway combines stored sessions into an in-memory view used by session lists, model selection, and session events. This change separates stored identities from configurable request aliases when building and refreshing that view.

flowchart TD
  A[Stored session rows] --> C[Gateway session inventory]
  B[Current alias configuration] --> D[Literal parent or missing-parent fallback]
  C --> D
  D --> E[Model and runtime metadata]
  D --> F[Active and archived relationships]
  E --> G[Session lists and events]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +209, Tests +440. Total +649 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 12 336 127 +209
Tests 9 443 3 +440
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 779 130 +649

Review metrics

Metric Value Why it matters
Production versus regression coverage production +209 net lines; tests/support +440 net lines Production growth is explained by shared lineage selection and cold-index convergence within existing owners.

Technical review

Best possible solution:

Keep stored-address selection with the shared lineage owner while preserving dynamic request aliases and the existing missing-parent compatibility fallback.

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

Yes, from source: retain a qualified main session, change its alias configuration, and initialize the Gateway projection; current main's federation rejects the stored key. No runtime execution was performed in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing stored-address contract and one lineage selector repairs the consumer mismatch without rewriting stored sessions or changing request routing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 516e330fdf63.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Valid stored sessions can prevent cold Gateway initialization after an alias change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 PR is exempt from the external-contributor proof gate. Its recorded boundary runs exercise real session/ACP writers and cold projection initialization, with archived and private-session cases; this review inspected their source and attribution without rerunning them. No stored-data contract changes require migration proof.

Evidence

What I checked:

  • Pinned introduction reviewed: Reviewed the merge-base-to-head production and test hunks. Endpoint drift was excluded from PR ownership. The supplied test merge is stale relative to the pinned base, so its contents were not used to claim what merging would remove. (80dad67d2a18)
  • Current main still needs the repair: Federation on fetched main resolves persisted qualified keys without preserveQualifiedAddress and throws when the resolved alias differs from the stored key. The central federation, model-source, key-selection, and record modules are unchanged from the pinned merge base. (src/config/sessions/combined-store-gateway.ts:604, 516e330fdf63)
  • Latest release check: The same rejecting federation path is present in v2026.9.5. Its source was inspected through GitHub after the local release blob was unavailable. (src/config/sessions/combined-store-gateway.ts, ec9c1a13db89)
  • Shared selection and lifecycle behavior: The shared selector checks literal existence before alias fallback, does not reinterpret incognito misses, and propagates read errors. Federation completes its inventory before selection; resident publications update cold lineage and both parents' indexes without materializing archived rows. (src/gateway/session-store-key.ts:226, 80dad67d2a18)
  • Regression and compatibility coverage: Reviewed regressions write actual session and ACP metadata, change the alias configuration, then exercise cold projection initialization and listing. Additional cases cover literal/current-parent collisions, parent removal and reappearance, cold parent filtering, removed-default-owner fallback, private parents, and exact-read failures. These are source-inspected tests; this review did not execute them. (src/gateway/session-row-projection.worker-read.test.ts:475, 80dad67d2a18)
  • Validation identity and review continuity: The captured body attributes 46 passing boundary cases to 0c3fb25 and 38 usage cases to the final head. GitHub's final-commit patch confirms only two fixture resolvers and removal of an unused export. The previous completed review covers this same head and retains no findings or rank-up moves. Older execution and merge-CI evidence remain attributed to their recorded revisions. (src/gateway/session-row-projection-record.ts:420, 80dad67d2a18)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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-23T02:50:47.960Z sha 80dad67 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc merged commit ff27365 into main Sep 23, 2026
213 of 214 checks passed
@vincentkoc
vincentkoc deleted the bug-session-main-address-repro-20260923 branch September 23, 2026 03:19
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…nges (openclaw#156109)

* fix(gateway): preserve stored session addresses across main alias changes

* refactor(gateway): keep lineage updates with row owners

* fix(gateway): complete stored-source usage fixtures

Co-authored-by: Vincent Koc <[email protected]>
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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