Skip to content

fix(gateway): preserve raw external session aliases - #83368

Closed
stainlu wants to merge 10 commits into
openclaw:mainfrom
stainlu:fix/session-raw-external-alias
Closed

stainlu wants to merge 10 commits into
openclaw:mainfrom
stainlu:fix/session-raw-external-alias

Conversation

@stainlu

@stainlu stainlu commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #63005.

Behavior addressed

External raw session keys such as conversation:pair:... and opaque provider keys such as Signal:Group:<mixed-case-id> should survive gateway session-key canonicalization. Any follow-up mutation should keep the raw key and the visible agent:<id>: canonical key pointing at the same session entry instead of splitting history or plugin-owned state.

Root cause

migrateAndPruneGatewaySessionStoreKey canonicalized raw external keys before preserving the raw-key store entry as an alias of the canonical agent key. The first fix preserved that raw alias, but some write paths still replaced, mutated, or deleted only one key.

The later review findings exposed the remaining gaps:

  • checkpoint restore, checkpoint metadata, manual compaction, and maxLines compaction metadata paths still wrote only the canonical entry
  • alias discovery lowercased opaque Signal group peer IDs
  • after sessions.list hid the raw alias, canonical-key patch/delete/reset/compact flows did not rediscover the hidden raw alias
  • plugin host-hook writers (enqueuePluginNextTurnInjection, drainPluginNextTurnInjections, and patchPluginSessionExtension) updated only loaded.storeKey, leaving hidden raw aliases with stale plugin state

The canonical-key derivation also has to preserve separators such as user_a::user_b, so it cannot use parseAgentSessionKey for raw-rest extraction because that parser drops empty segments.

Fix

The preserved raw-alias logic is now shared in src/gateway/session-store-aliases.ts, with alias-aware write, sync, and delete helpers.

Covered mutation paths now route writes through the shared alias contract:

  • sessions.patch
  • sessions.delete
  • sessions.reset
  • agent writeback
  • node-event store touches
  • resolver sync
  • sessions.compaction.restore
  • compaction checkpoint metadata persistence
  • sessions.compact manual metadata updates
  • sessions.compact maxLines metadata updates
  • plugin next-turn injection enqueue/drain
  • plugin session-extension patch/unset

Preserved raw aliases stay internal-only for lookup continuity: sessions.list filtering/search/count collapses a raw+canonical alias pair into one visible canonical session row.

Canonical visible keys now rediscover an existing hidden raw alias by stripping the agent:<id>: prefix while preserving the rest of the key exactly. Canonical-only sessions do not grow a new raw alias.

Opaque Signal group peer IDs are preserved when deriving raw aliases, so mixed-case group IDs do not create lowercased duplicate logical session rows.

Real Behavior Proof

Behavior or issue addressed: Raw external session aliases are preserved during canonicalization, stay synchronized across direct session mutations, compaction/checkpoint lifecycle writes, canonical visible-key follow-ups, and plugin host-hook writes, while keeping only one visible canonical row in list/search/count.

Real environment tested: Source checkout on PR head 1cde6d4a5d222273ed4c9c69b5d6e4ac402282c9, base f07c87405c3094feceaaf2f0f19a2e765a25e78d, Node 22, repo dependencies installed.

Exact steps or command run after this patch:

node --import tsx /private/tmp/pr83368-proof.ts

Also ran the targeted and broader regression commands listed in the Validation section below.

Evidence after fix:

{
  "primaryKey": "agent:main:conversation:pair:user_a::user_b:space:space_123",
  "preservedAliasKeys": [
    "conversation:pair:user_a::user_b:space:space_123"
  ],
  "afterWrite": {
    "canonicalSessionId": "sess-write",
    "rawSessionId": "sess-write",
    "rawSendPolicy": "deny",
    "sameEntry": true
  },
  "visible": {
    "listKeys": [
      "agent:main:conversation:pair:user_a::user_b:space:space_123"
    ],
    "listCount": 1,
    "listTotalCount": 1,
    "searchKeys": [
      "agent:main:conversation:pair:user_a::user_b:space:space_123"
    ],
    "searchCount": 1,
    "searchTotalCount": 1
  },
  "deleted": true,
  "afterDelete": {
    "canonicalSessionId": null,
    "rawSessionId": null
  },
  "canonicalVisibleKeyFlow": {
    "listedKeys": [
      "agent:main:conversation:pair:user_a::user_b:space:space_123"
    ],
    "afterWrite": {
      "visibleKey": "agent:main:conversation:pair:user_a::user_b:space:space_123",
      "primaryKey": "agent:main:conversation:pair:user_a::user_b:space:space_123",
      "preservedAliasKeys": [
        "conversation:pair:user_a::user_b:space:space_123"
      ],
      "canonicalSessionId": "sess-visible-write",
      "rawSessionId": "sess-visible-write",
      "rawSendPolicy": "deny",
      "sameEntry": true
    },
    "deleted": true,
    "afterDelete": {
      "canonicalSessionId": null,
      "rawSessionId": null
    }
  }
}

The command printed local stale-plugin config warnings for multica; they are unrelated to this PR and did not affect the session-store proof.

Observed result after fix: The raw alias and canonical key share the same written entry after replacement, including patched sendPolicy; list and search return one visible canonical row with totalCount: 1; delete removes both keys. Starting from the visible canonical list key also rediscovers the hidden raw alias, writes both aliases, and deletes both aliases. The plugin regressions show canonical-key plugin next-turn enqueue/drain and session-extension patch/unset update or clear the hidden raw alias too.

What was not tested: No full live external chat-channel round trip was run. No screenshots are attached because this is backend session-store behavior with no visual UI surface.

Regression Coverage

  • src/gateway/session-utils.test.ts covers raw/canonical alias collapse, mixed-case Signal opaque-ID preservation, canonical-key rediscovery, and canonical-only no-new-raw-alias behavior.
  • src/gateway/server.sessions.store-rpc.test.ts covers list-to-patch/list-to-delete using the visible canonical key while the hidden raw alias follows.
  • src/gateway/server.sessions.reset-cleanup.test.ts covers reset alias synchronization.
  • src/gateway/session-compaction-checkpoints.test.ts covers checkpoint metadata persistence to both aliases.
  • src/gateway/server.sessions.compaction.test.ts covers checkpoint restore, manual compaction metadata, and maxLines compaction metadata alias sync.
  • src/plugins/contracts/host-hooks.contract.test.ts covers canonical-key plugin next-turn injection enqueue and drain syncing the hidden raw alias.
  • src/plugins/contracts/session-entry-projection.contract.test.ts covers canonical-key plugin session-extension patch and unset syncing the hidden raw alias and promoted slot.

Validation

Ran on head 1cde6d4a5d222273ed4c9c69b5d6e4ac402282c9:

node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
Test Files  6 passed (6)
Tests       347 passed (347)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
Test Files  17 passed (17)
Tests       650 passed (650)
node scripts/run-oxlint.mjs src/gateway/session-store-aliases.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/plugins/host-hook-state.ts
Found 0 warnings and 0 errors.
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/session-store-aliases.ts src/gateway/session-utils.ts src/plugins/host-hook-state.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
All matched files use the correct format.
git diff --check

pnpm docs:list was run before editing. Broad Testbox changed gate was not run because the blacksmith CLI is not installed in this environment; local validation was kept to targeted gateway/plugin proof and GitHub CI is running on the pushed head.

Screenshots

No screenshots apply because this is backend session-store alias synchronization, not a visual UI surface.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S proof: supplied External PR includes structured after-fix real behavior proof. labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 1, 2026, 5:38 AM ET / 09:38 UTC.

Summary
The PR preserves raw external gateway session aliases and synchronizes them with canonical agent-prefixed session keys across gateway, compaction, resolver, node-event, and plugin host-hook mutation paths.

PR surface: Source +377, Tests +918. Total +1295 across 19 files.

Reproducibility: yes. at source level. Current main canonicalizes structured non-agent raw keys into agent-scoped keys and still prunes noncanonical target store keys, matching the linked session-split report.

Review metrics: 1 noteworthy metric.

  • Persisted Session Identity Contract: 1 alias-retention behavior changed. The PR changes how raw and canonical session keys are retained and synchronized, so maintainers need upgrade/session-state proof after conflict repair.

Stored data model
Persistent data-model change detected: serialized state: src/gateway/server-methods/sessions.ts, serialized state: src/gateway/server.sessions.compaction.test.ts, serialized state: src/gateway/server.sessions.reset-cleanup.test.ts, serialized state: src/gateway/server.sessions.store-rpc.test.ts, serialized state: src/gateway/session-compaction-checkpoints.test.ts, serialized state: src/gateway/session-compaction-checkpoints.ts, and 15 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #86743
Summary: The open refreshed issue tracks the remaining raw/canonical external session-key split, and this PR is a candidate implementation for it.

Members:

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

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Port the alias contract through src/config/sessions/session-accessor.ts and rerun the targeted gateway/plugin/accessor validation.

Risk before merge

  • [P1] The branch is currently conflicting, so the merge result still needs a focused repair rather than ordinary merge review.
  • [P1] The diff changes persisted raw/canonical session alias behavior; an incomplete repair could split, stale, or mis-associate gateway and plugin session state.
  • [P1] The current-head terminal proof is strong, but the repaired merge result still needs fresh targeted proof against current main.

Maintainer options:

  1. Repair Through Session Accessor (recommended)
    Port the raw-alias preservation contract into src/config/sessions/session-accessor.ts and keep the migrated gateway/plugin callers on accessor helpers.
  2. Use A Replacement Only With Matching Proof
    A replacement PR can supersede this branch only if it covers the same writer paths and supplies equivalent current-main real behavior proof.
  3. Pause If Storage Direction Changes
    If maintainers do not want preserved raw aliases in the accessor contract, pause this branch and decide the permanent session-storage model first.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main; move raw external alias preservation into `src/config/sessions/session-accessor.ts`; keep gateway and plugin writers on the session-accessor boundary; preserve regressions for list/search/count, patch/delete/reset, compaction/checkpoint, resolver, node-event, and plugin host-hook writes; rerun the targeted gateway/plugin tests, session-accessor boundary guard, oxlint, oxfmt, and `git diff --check`.

Next step before merge

  • [P2] The remaining blocker is a concrete rebase/repair: move the alias preservation contract into the current session accessor and preserve the branch's existing coverage.

Security
Cleared: No concrete security or supply-chain concern was found; the diff is TypeScript session-store logic and tests with no dependency, workflow, secret, or downloaded-code changes.

Review findings

  • [P2] Move alias writes behind the session accessor — src/gateway/session-store-aliases.ts:109-137
Review details

Best possible solution:

Move raw external alias preservation into src/config/sessions/session-accessor.ts, keep gateway and plugin mutation paths on that storage boundary, and preserve the PR's broad alias regression coverage before landing.

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

Yes at source level. Current main canonicalizes structured non-agent raw keys into agent-scoped keys and still prunes noncanonical target store keys, matching the linked session-split report.

Is this the best way to solve the issue?

No in the current branch shape. The raw-alias behavior is the right direction, but current main moved migrated session writes behind src/config/sessions/session-accessor.ts, so the alias contract should land there instead of as a parallel gateway writer helper.

Full review comments:

  • [P2] Move alias writes behind the session accessor — src/gateway/session-store-aliases.ts:109-137
    Current main made src/config/sessions/session-accessor.ts the storage boundary for migrated session writes and added a guard for those files. This new gateway helper keeps raw-alias synchronization outside that boundary, so conflict repair should move the alias contract into the accessor and keep callers on that path.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR targets a real gateway session-continuity bug with limited blast radius to integrations using stable raw external session keys.
  • merge-risk: 🚨 session-state: The diff changes persisted raw/canonical session alias behavior and can split or stale session state if repaired incorrectly.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body supplies terminal real behavior proof with after-fix JSON output and targeted regression commands on the PR head; fresh proof is still needed after the required conflict repair.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies terminal real behavior proof with after-fix JSON output and targeted regression commands on the PR head; fresh proof is still needed after the required conflict repair.
Evidence reviewed

PR surface:

Source +377, Tests +918. Total +1295 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 10 438 61 +377
Tests 9 919 1 +918
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 1357 62 +1295

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/config/sessions/session-accessor.test.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts.
  • [P1] node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts.
  • [P1] node scripts/check-session-accessor-boundary.mjs.
  • [P1] node scripts/run-oxlint.mjs src/config/sessions/session-accessor.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/plugins/host-hook-state.ts.
  • [P1] ./node_modules/.bin/oxfmt --check --threads=1 src/config/sessions/session-accessor.ts src/gateway/session-utils.ts src/plugins/host-hook-state.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts.

What I checked:

  • Repository policy read: Root and scoped gateway/plugin AGENTS.md files were read fully; their deep-review, gateway hot-path, plugin-boundary, and session-state compatibility guidance apply to this PR. (AGENTS.md:1, cf2efbe5d515)
  • PR is currently conflicting: Live GitHub reports the PR as open, non-draft, mergeable: CONFLICTING, and mergeStateStatus: DIRTY on head 1cde6d4a5d222273ed4c9c69b5d6e4ac402282c9. (1cde6d4a5d22)
  • Current main canonicalizes raw keys: Current main still wraps non-agent raw session keys as agent:<id>:<normalized>, creating the raw/canonical identity pair involved in the linked bug. (src/gateway/session-store-key.ts:21, cf2efbe5d515)
  • Current main prunes aliases: migrateAndPruneGatewaySessionStoreKey promotes the canonical entry and calls pruneLegacyStoreKeys on target store keys, so current main has not implemented raw external alias preservation. (src/gateway/session-utils.ts:1105, cf2efbe5d515)
  • Current main accessor boundary: canonicalizeSessionEntryAliases now owns alias promotion/pruning under src/config/sessions/session-accessor.ts, so the durable storage behavior belongs at the accessor layer. (src/config/sessions/session-accessor.ts:1026, cf2efbe5d515)
  • Current main plugin callers use accessor: Plugin host-hook writes now call updateResolvedSessionEntry from session-accessor.ts, which is the path this PR's plugin alias behavior needs to preserve after repair. (src/plugins/host-hook-state.ts:5, cf2efbe5d515)

Likely related people:

  • steipete: Authored multi-agent routing and main-session alias canonicalization commits that established the raw/canonical gateway session-key boundary. (role: feature-history owner; confidence: high; commits: dbfa316d19d5, 987773374821; files: src/gateway/session-store-key.ts, src/gateway/session-utils.ts)
  • jalehman: Recently routed session status and boot session mapping through session-accessor.ts, the current storage boundary this PR must preserve. (role: recent session storage contributor; confidence: high; commits: b58e6e0734f2, acc2a0ee7297; files: src/config/sessions/session-accessor.ts, src/config/sessions/store.ts)
  • Takhoffman: Authored the freshest duplicate-row behavior in session loads, which shares the same alias-selection invariant as this PR. (role: adjacent session-store contributor; confidence: medium; commits: f48571bec6f2; files: src/gateway/session-utils.ts)
  • 100yenadmin: Authored plugin session-extension slot projection work touching the plugin host-hook session state that this PR also updates. (role: adjacent plugin session-state contributor; confidence: medium; commits: cb3853587576; files: src/plugins/host-hook-state.ts, src/plugins/contracts/session-entry-projection.contract.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels May 18, 2026
@stainlu

stainlu commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Addressing the ClawSweeper rank-up move:

Wait for required CI on the PR head before merge.

Current PR-head checks are complete on d94f20dea6a9dcecc66f017b93e76e5ab0774daf:

88 SUCCESS
28 SKIPPED
1 NEUTRAL (CodeQL)
0 PENDING
0 FAILED

No code change needed for this comment; this is a CI/proof follow-up on the same one-commit branch.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 18, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@stainlu
stainlu force-pushed the fix/session-raw-external-alias branch from d94f20d to 87ecc78 Compare May 18, 2026 09:21
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. labels May 18, 2026
@stainlu

stainlu commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current upstream/main and refreshed exact-head proof.

Current head: 87ecc789b95a4aeab08c89fa86d7c4eacc607cf7
Base checked: 3b5d30b5fdfd2d9e1e2f1c97242444467dce53c0

After rebase:

node scripts/run-vitest.mjs src/gateway/session-utils.test.ts
Test Files  3 passed (3)
Tests       264 passed (264)

Also clean:

git diff --check upstream/main...HEAD
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/session-utils.ts src/gateway/session-utils.test.ts

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 18, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
@stainlu

stainlu commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR description with a ## Real behavior proof section and direct terminal output from the rebased head.

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels May 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 19, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 19, 2026
@stainlu

stainlu commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated #83368 for the remaining compact metadata alias gap and rebased onto current upstream/main.

Current head: e84309c86300aa9fc28edf8fb698e6133d4ff948
Base checked: f07c87405c3094feceaaf2f0f19a2e765a25e78d

What changed since the last push:

  • Rebased onto current upstream/main.
  • Carried preservedAliasKeys through sessions.compact after the initial migration.
  • Routed manual compaction metadata updates through the alias-aware store writer.
  • Routed maxLines compaction metadata updates through the alias-aware store writer.
  • Added raw+canonical regressions for manual compaction and maxLines compaction alias synchronization.
  • Refreshed the PR body with current-head behavior proof and validation.

Validation on the rebased head:

node scripts/run-vitest.mjs src/gateway/server.sessions.compaction.test.ts src/gateway/session-compaction-checkpoints.test.ts
Test Files  4 passed (4)
Tests       30 passed (30)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
Test Files  15 passed (15)
Tests       576 passed (576)
node scripts/run-oxlint.mjs src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/server.sessions.compaction.test.ts
Found 0 warnings and 0 errors.
git diff --check upstream/main...HEAD
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
All matched files use the correct format.

No screenshots apply here because the changed behavior is backend session-store alias synchronization, not a visual UI surface.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@stainlu

stainlu commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated #83368 for the latest ClawSweeper Signal opaque-ID finding.

Current head: 75b35bb408bda9559bcc31d8126ccfe3e4471d03
Base checked: f07c87405c3094feceaaf2f0f19a2e765a25e78d

What changed since the last push:

  • Preserved raw external aliases now use normalizeSessionKeyPreservingOpaquePeerIds instead of folding opaque peer IDs to lowercase.
  • Preserved alias discovery and legacy-key pruning now compare with the same opaque-preserving normalization.
  • Added a mixed-case Signal group regression proving write/delete alias sync, folded-alias pruning, and one visible canonical sessions.list row.
  • Refreshed the PR body with current-head behavior proof and validation.

Validation on the rebased head:

node scripts/run-vitest.mjs src/gateway/session-utils.test.ts
Test Files  3 passed (3)
Tests       273 passed (273)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
Test Files  15 passed (15)
Tests       579 passed (579)
node scripts/run-oxlint.mjs src/gateway/session-utils.ts src/gateway/session-utils.test.ts src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/server.sessions.compaction.test.ts
Found 0 warnings and 0 errors.
git diff --check upstream/main...HEAD
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/session-utils.ts src/gateway/session-utils.test.ts src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
All matched files use the correct format.

No screenshots apply here because the changed behavior is backend session-store alias synchronization, not a visual UI surface.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@stainlu

stainlu commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Updated #83368 for the latest canonical-key alias discovery finding.

Current head: 66e484de1d7aaa392a9c334116b350aa5e4435aa
Base checked: f07c87405c3094feceaaf2f0f19a2e765a25e78d

What changed since the last push:

  • Canonical visible keys now rediscover existing hidden raw aliases, so list-to-patch/list-to-delete flows update or remove both aliases.
  • The canonical-key derivation preserves separators such as user_a::user_b; it no longer depends on parseAgentSessionKey for this raw-rest extraction.
  • Canonical-only external session keys do not create new raw aliases.
  • Added unit regressions for canonical-key rediscovery and no-new-raw-alias behavior.
  • Extended the RPC regression to call sessions.list, use the returned canonical key for sessions.patch, then use the same visible key for sessions.delete, verifying the hidden raw alias follows both operations.
  • Refreshed the PR body with current-head behavior proof and validation.

Validation on the rebased head:

node scripts/run-vitest.mjs src/gateway/session-utils.test.ts
Test Files  3 passed (3)
Tests       279 passed (279)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server.sessions.compaction.test.ts src/gateway/session-compaction-checkpoints.test.ts
Test Files  9 passed (9)
Tests       318 passed (318)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
Test Files  15 passed (15)
Tests       585 passed (585)
node scripts/run-oxlint.mjs src/gateway/session-utils.ts src/gateway/session-utils.test.ts src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/server.sessions.compaction.test.ts src/gateway/server.sessions.store-rpc.test.ts
Found 0 warnings and 0 errors.
git diff --check
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/session-utils.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server-methods/sessions.ts src/gateway/session-compaction-checkpoints.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts
All matched files use the correct format.

No screenshots apply here because the changed behavior is backend session-store alias synchronization, not a visual UI surface.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@clawsweeper

clawsweeper Bot commented May 20, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@stainlu

stainlu commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Updated #83368 for ClawSweeper's plugin host-hook alias finding.

Current head: 1cde6d4a5d222273ed4c9c69b5d6e4ac402282c9
Base checked: f07c87405c3094feceaaf2f0f19a2e765a25e78d

What changed since the last push:

  • Moved the raw-alias sync helpers into src/gateway/session-store-aliases.ts so gateway session methods and plugin host hooks use the same alias contract.
  • enqueuePluginNextTurnInjection, drainPluginNextTurnInjections, and patchPluginSessionExtension now discover preserved raw aliases from canonical visible keys and sync them after mutation.
  • Added plugin regressions proving canonical-key next-turn enqueue/drain updates and clears the hidden raw alias.
  • Added plugin session-extension projection regression proving canonical-key patch/unset updates and clears the hidden raw alias and promoted slot.
  • Refreshed the PR body with current-head proof and validation. No screenshots apply because this is backend session-store behavior.

Validation on the pushed head:

node --import tsx /private/tmp/pr83368-proof.ts
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
Test Files  6 passed (6)
Tests       347 passed (347)
node scripts/run-vitest.mjs src/gateway/session-utils.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/gateway/server-methods/agent.test.ts src/gateway/server-node-events.test.ts src/gateway/sessions-resolve.test.ts src/gateway/session-compaction-checkpoints.test.ts src/gateway/server.sessions.compaction.test.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
Test Files  17 passed (17)
Tests       650 passed (650)
node scripts/run-oxlint.mjs src/gateway/session-store-aliases.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/plugins/host-hook-state.ts
Found 0 warnings and 0 errors.
./node_modules/.bin/oxfmt --check --threads=1 src/gateway/session-store-aliases.ts src/gateway/session-utils.ts src/plugins/host-hook-state.ts src/plugins/contracts/host-hooks.contract.test.ts src/plugins/contracts/session-entry-projection.contract.test.ts
All matched files use the correct format.
git diff --check

@clawsweeper re-review

@stainlu

stainlu commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Proof fields restored and the Real behavior proof workflow is now green on head 1cde6d4a5d222273ed4c9c69b5d6e4ac402282c9.

Run: https://github.com/openclaw/openclaw/actions/runs/26216255589

@clawsweeper re-review

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

gateway Gateway runtime merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: external raw session keys can split after sessions_send / nested agent canonicalization

1 participant