Skip to content

fix(history): keep canonical transcript owners distinct - #164512

Merged
steipete merged 2 commits into
mainfrom
fix/lg-config-transcript-binding
Oct 4, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/lg-config-transcript-binding

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Anchored history requests could pass the transcript-owner check when the stored owner was literal global or unknown and the requested owner was agent:research:global or agent:research:unknown. Scoping both sides as legacy aliases collapsed distinct stored conversations.

User Impact

History now preserves canonical literal owners and compares the resolved owner with the selected canonical key. Matching reads still succeed; mismatched ownership returns INVALID_REQUEST. Existing retained legacy-key resolution remains supported, including padded aliases. Persisted formats and update behavior are unchanged; no migration is required.

Why This Change Was Made

The fix uses the existing alias resolver only where appropriate and preserves the missing-binding refusal. The regression covers both sentinel names, correct and incorrect anchors, a missing binding, and retained legacy keys. The original global-versus-main case moves into the focused ownership test so the existing handler file stays below its growth cap.

Production +10 / -7 / net +3. This PR contains no Doctor retained-node migration, lifecycle/snapshot extension, or dependency on #163592. The retained-node runtime handling stays in place.

Evidence

Candidate: f57186bd379a06abc07945207e6ae18498419b30; base: 82adb7a49d36e844e4ea1989bc5d865abac916f0. Codex autoreview is clean through P2, including exact classification of padded legacy keys. Formatting and git diff --check pass.

On Hetzner lease cbx_b2c1c013d4d4, baseline run run_bed524967d5d8711a34ab7173a9db159 reproduced the wrong-owner response on clean main with the new regression (43.470 s). The retained legacy-key control passed in the same run. The original run remains failed as expected, with no retry or relaxed assertion.

Native run run_f3bce8134207521d36cbedfa1d8ff42f passed the behavioral checks at production-equivalent parent 1f00cf7aeae5ce7053777d45504fb1b9b99d3703:

Test file Cases Wall seconds
src/gateway/server-methods/chat-history-ownership.test.ts 4 51.070
src/gateway/server-methods/chat-history-handler.test.ts 33 59.800
src/gateway/server-methods/chat-history-retained-sharing.test.ts 2 34.790

These tests use real SQLite admission/history workers and the registered handlers; a mocked helper cannot establish the owner and retained-data contract. They do not boot a Gateway per case. Wall cost includes worker artifact preparation. Targeted lint and the line-cap ratchet passed. Production accounting uses every GitHub file page (3 files). The only subsequent change adds two constant-tuple annotations to the test data. It fixes three noUncheckedIndexedAccess type errors reported by prior CI 37205481093, without changing production code, test values, or assertions. Fresh native run run_fa6cac006b87430a8cc28848423bf000 passed the exact failing test/tsconfig/tsconfig.core.test.gateway-methods.json graph and test lint at the final head. Both reviews are clean through P2. Final-head hosted CI 37206404598 passed: 421 seconds elapsed and 6,049 summed job-seconds including setup. The earlier CI failure remains attributed to its original head. Merged as 0e728fb660c08611443d060a956efb66155df1a1, verified on origin/main. No local build or test ran.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: XL labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 9:36 AM ET / 13:36 UTC (Revision 12).

ClawSweeper review

What this changes

The PR keeps literal global and unknown transcript owners distinct from agent-qualified conversations and adds history-read regressions while preserving legacy aliases.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main, and no introduced correctness defect was found. The updated evidence addresses the previous review’s candidate-validation request; ordinary CI gates still apply.

Priority: P2
Reviewed head: 1f00cf7aeae5ce7053777d45504fb1b9b99d3703

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful boundary regressions and recorded candidate validation; no blocking patch finding remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Recorded exact-head native handler suites exercise real SQLite bindings, reject wrong conversation targets, preserve matching and legacy reads, and retain sharing-revocation coverage; no unresolved introduced authority gap was found. 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 repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Recorded exact-head native handler suites exercise real SQLite bindings, reject wrong conversation targets, preserve matching and legacy reads, and retain sharing-revocation coverage; no unresolved introduced authority gap was found. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head diff changes only the transcript-owner comparison and its tests. Base-only workflow, policy, and memory changes are outside this PR’s introduced delta.
Current main still collapses distinct owners: Fetched main still scopes both the stored transcript key and selected canonical key as legacy aliases. Consequently, literal global or unknown can compare equal to its agent-qualified counterpart. This PR preserves literal stored owners and compares against the already-selected canonical key.
Canonical identity and legacy alias contracts: Session-store canonicalization preserves literal global and unknown. The existing legacy resolver trims and agent-scopes aliases; preserving only exact stored sentinel bytes therefore retains padded legacy aliases without changing that shared resolver.
Findings None None.
Security None None.

How this fits together

Gateway history requests select a conversation and read its transcript through SQLite workers. Transcript ownership and current sharing permissions determine whether the requested messages can be returned.

flowchart TD
  A[History request and message anchor] --> B[Select canonical conversation]
  B --> C[Read stored transcript owner]
  C --> D[Compare distinct conversation identities]
  D -->|Mismatch or missing binding| E[Reject request]
  D -->|Match| F[Read history and recheck sharing]
  F --> G[Return authorized messages]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +159. Total +162 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 10 7 +3
Tests 2 203 44 +159
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 213 51 +162

Review metrics

None.

Technical review

Best possible solution:

Keep transcript ownership checks aligned with canonical conversation identity while retaining supported legacy aliases and current sharing revalidation.

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

Yes, source establishes the path: request an anchored transcript under the agent-qualified counterpart of its literal global or unknown owner. Current main scopes both identities to the same value; the PR records a failing baseline regression.

Is this the best way to solve the issue?

Yes, the patch narrowly fixes the owning comparison, preserves the shared alias resolver, and checks matching, mismatched, missing, and retained-history cases.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 390b413d462e.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded anchored-history identity mismatch without changing stored formats or configuration.
  • 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 repository state identifies a MEMBER author, so ordinary external-contributor proof is exempt. Recorded exact-head native handler suites exercise real SQLite bindings, reject wrong conversation targets, preserve matching and legacy reads, and retain sharing-revocation coverage; no unresolved introduced authority gap was found. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes only the transcript-owner comparison and its tests. Base-only workflow, policy, and memory changes are outside this PR’s introduced delta. (src/gateway/server-methods/chat-history-handler.ts:145, 1f00cf7aeae5)
  • Current main still collapses distinct owners: Fetched main still scopes both the stored transcript key and selected canonical key as legacy aliases. Consequently, literal global or unknown can compare equal to its agent-qualified counterpart. This PR preserves literal stored owners and compares against the already-selected canonical key. (src/gateway/server-methods/chat-history-handler.ts:145, 390b413d462e)
  • Canonical identity and legacy alias contracts: Session-store canonicalization preserves literal global and unknown. The existing legacy resolver trims and agent-scopes aliases; preserving only exact stored sentinel bytes therefore retains padded legacy aliases without changing that shared resolver. (src/gateway/session-store-key.ts:34, 1f00cf7aeae5)
  • Owner-boundary regressions: The new suite invokes registered history handlers with real transcript storage. It checks both directions of sentinel-versus-qualified mismatch, matching message contents, missing bindings, and retained aliases including padded sentinel names. The previous global-versus-main regression is retained in the new suite. (src/gateway/server-methods/chat-history-ownership.test.ts:19, 1f00cf7aeae5)
  • Authority and final publication: The changed comparison rejects mismatched transcript targets before message reads. Existing sharing preparation revalidates current session identity and caller permissions before publication; sibling tests cover denied private reads, deleted retained sessions, and caller scope loss during startup work. The patch adds no persisted authority or alternate authorization owner. (src/gateway/server-methods/chat-history-session-read.ts:159, 1f00cf7aeae5)
  • Updated candidate validation and review continuity: The captured PR body records baseline failure run run_bed524967d5d8711a34ab7173a9db159 and exact-head candidate run run_f3bce8134207521d36cbedfa1d8ff42f: ownership 4 cases in 51.070 seconds, handler 33 in 59.800 seconds, and retained sharing 2 in 34.790 seconds. It explains real SQLite worker preparation costs. These are contributor-recorded results, not executions performed by this reviewer, and address the previous completed review’s concrete request. Captured sourceRevision: c854dc4506829ea37aaba591f804d16a35322f74382ca1e5530792378da66ebe. (1f00cf7aeae5)

Likely related people:

  • steipete: 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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-04T00:14:29.459Z sha 794ea2d :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T02:01:58.463Z sha c01d3a4da4eb07be310a4c0275b6ae95c42bc8d1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T02:31:44.252Z sha 13db9da4967dc18eb32f886408a840b175e79269 :: needs real behavior proof before merge. :: [P2] Update the orchestration assertion to require maintenance authority
  • reviewed 2026-10-04T03:05:31.849Z sha 57b336154c64bfd0676669f236f6c232dcde2a85 :: needs real behavior proof before merge. :: [P2] Update the orchestration assertion to require maintenance authority
  • reviewed 2026-10-04T03:34:57.094Z sha 091c63b264c3e055a3ca5df877c3e2ef7fdf5d27 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T04:02:36.077Z sha fef576b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T04:59:00.774Z sha c8f6ac7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T13:29:14.905Z sha 1f00cf7 :: needs changes before merge. :: none

@steipete
steipete force-pushed the fix/lg-config-transcript-binding branch from c8f6ac7 to 1f00cf7 Compare October 4, 2026 13:22
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed docs Improvements or additions to documentation commands Command implementations size: XL labels Oct 4, 2026
@steipete steipete changed the title fix(history): repair retained transcript ownership through Doctor fix(history): keep canonical transcript owners distinct Oct 4, 2026
@steipete
steipete marked this pull request as ready for review October 4, 2026 13:23
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 4, 2026
@steipete
steipete enabled auto-merge (squash) October 4, 2026 13:31
@steipete
steipete disabled auto-merge October 4, 2026 13:34
@steipete
steipete enabled auto-merge (squash) October 4, 2026 13:43
@steipete
steipete merged commit 0e728fb into main Oct 4, 2026
120 checks passed
@steipete
steipete deleted the fix/lg-config-transcript-binding branch October 4, 2026 13:47
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
)

* fix(history): keep canonical transcript owners distinct

* test(history): preserve ownership case tuple types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant