Skip to content

fix(sessions): preserve transcript idempotency keys - #125221

Closed
PollyBot13 wants to merge 1 commit into
openclaw:mainfrom
PollyBot13:fix/transcript-idempotency-key
Closed

PollyBot13 wants to merge 1 commit into
openclaw:mainfrom
PollyBot13:fix/transcript-idempotency-key

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #125214

What Problem This Solves

Transcript storage redacts secret-shaped substrings before persistence. When a generated idempotency key matches that detector, the durable replay identity is mutated and exact replay/deduplication can fail.

Why This Change Was Made

This candidate keeps persisted transcript event JSON redacted while carrying the original key to the existing SQLite identity owner during the append transaction. Single-message, atomic-batch, and Gateway-injected assistant retries then use that identity index for replay lookup.

The branch is deliberately draft after exact-head adversarial review found that the apparently narrow design crosses two Critical contracts:

  • retaining an exact secret-shaped caller key in SQLite conflicts with the intended redaction-at-rest boundary;
  • one globally unique raw-key identity cannot safely distinguish a user event and an assistant event that reuse the same key.

A robust repair likely needs a separately typed one-way identity field plus a database migration. That is a broader persistence contract and should not be invented in contributor polish without a domain maintainer choosing the seam.

User Impact

If the final design is accepted, exact retries whose idempotency keys resemble secrets will deduplicate correctly without exposing the key in transcript event JSON. This draft is not ready to merge until the identity-at-rest and role-scoping contracts are resolved.

Evidence

Exact rebased head: 9774b240630168e1103a0ff4c6956583d916556e

  • Focused transcript idempotency/redaction regression: 5/5 passed.
  • Focused Gateway chat.inject regression: 4/4 passed.
  • pnpm check:changed passed on the rebased candidate.
  • git diff --check passed.
  • Clean-context adversarial review identified the two unresolved Critical design issues above; they are intentionally not hidden behind green tests.

Owner Acceptance Card

  • Intent: preserve deterministic replay when an idempotency key is transformed by transcript redaction.
  • Assurance / blast radius: Critical; transcript persistence, secret handling, and replay identity.
  • Strongest evidence: real SQLite regressions cover user, assistant, and atomic-batch replay paths on the rebased head.
  • Known falsifier: a secret-shaped key is recoverable from SQLite at rest, or a shared user/assistant key causes the assistant replay lookup to miss.
  • Rollback: revert the candidate; no schema migration is present in this draft.
  • Remaining human decision: choose whether exact raw identity metadata is acceptable at rest or sponsor a schema-separated one-way identity design with explicit role scoping and migration behavior.

AI-assisted: yes. Codex rebased, tested, and adversarially reviewed the candidate. The draft status is intentional pending a domain-competent maintainer decision on the dangerous boundary.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Aug 17, 2026
@PollyBot13

Copy link
Copy Markdown
Contributor Author

Pre-release note: exact beta.3 release head 4dcfeeae708798200d6ad6f3c635db5d5fd045d5 reproduces #125214. Please include or backport this focused fix before Tuesday if review and CI pass.

@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 18, 2026, 5:32 PM ET / 21:32 UTC.

ClawSweeper review

What this changes

The draft carries an idempotency key captured before transcript redaction into SQLite replay indexing so retries can deduplicate without retaining that key in transcript event JSON.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 8 items remain

Keep open. Current main still lacks a pre-redaction durable replay identity, but this draft cannot merge because it stores caller-controlled secret-shaped keys verbatim in SQLite and uses a uniqueness domain that cannot distinguish user and assistant messages.

Priority: P1
Reviewed head: 9774b240630168e1103a0ff4c6956583d916556e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused behavior evidence is useful, but the intentionally draft patch retains two unresolved persistent-identity blockers.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR supplies focused after-fix SQLite and Gateway regression results; the blocker is the unresolved durable identity contract rather than missing behavior proof.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR supplies focused after-fix SQLite and Gateway regression results; the blocker is the unresolved durable identity contract rather than missing behavior proof.
Evidence reviewed 5 items Current main lacks the proposed identity override: Current main derives transcript identity from the already-redacted event; the PR introduces the separate pre-redaction indexed-key override, so the linked replay bug is not already fixed on main.
Raw secret-shaped key is intentionally retained at rest: The PR overrides the redacted event identity with the original key, and its new SQLite regression asserts that a caller-supplied sk-… key is readable from message_idempotency_key.
Existing durable key scope has no role dimension: The current schema permits only one non-null identity per session and raw key, so a user and assistant message sharing a key cannot both be indexed for role-specific replay.
Findings 2 actionable findings [P1] Do not persist caller keys verbatim in SQLite
[P1] Scope replay identity by message role
Security Needs attention Raw caller idempotency keys become durable SQLite data: The proposed indexed-key override reaches the transcript identity row unchanged, allowing secret-shaped caller values to remain readable at rest.

Live Verification

Command: node scripts/run-vitest.mjs src/config/sessions/session-accessor.idempotency-redaction.test.ts

Result: FAIL (partial) — step 2 expect_output SQLite transcript idempotency redaction: expected terminal output was not visible within 30 seconds: "SQLite transcript idempotency redaction"

node scripts/run-vitest.mjs src/config/sessions/session-accessor.idempotency-redaction.test.ts
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125221-1CxLzy/target$ node scripts/run-vitest.mjs src/config/sessions/session-accessor.idempotency-redaction.te
st.ts
node scripts/run-vitest.mjs src/config/sessions/session-accessor.idempotency-redaction.test.ts
[test] starting test/vitest/vitest.runtime-config.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-125221-1CxLzy/target

 ✓  runtime-config  src/config/sessions/session-accessor.idempotency-redaction.test.ts (4 tests) 582ms
     ✓ keeps 'credential-like UUID' identity outside redacted event JSON  397ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  21:33:19
   Duration  8.05s (transform 5.81s, setup 59ms, import 7.08s, tests 582ms, environment 0ms)

[test] passed 1 Vitest shard in 13.83s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125221-1CxLzy/target$ node scripts/run-vitest.mjs src/config/sessions/session-accessor.idempotency-redaction.te
st.ts
[test] starting test/vitest/vitest.runtime-config.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-125221-1CxLzy/target

 ✓  runtime-config  src/config/sessions/session-accessor.idempotency-redaction.test.ts (4 tests) 556ms
     ✓ keeps 'credential-like UUID' identity outside redacted event JSON  354ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  21:33:34
   Duration  3.97s (transform 1.87s, setup 29ms, import 3.18s, tests 556ms, environment 0ms)

[test] passed 1 Vitest shard in 9.69s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125221-1CxLzy/target$


















Assertions:

  • FAIL expect_output: SQLite transcript idempotency redaction

How this fits together

Session and Gateway transcript writes redact message data before storing events, while a SQLite identity index supports replay and deduplication. The index feeds session recovery and injected assistant-message retries.

flowchart LR
  A[Incoming transcript message] --> B[Redact stored event]
  A --> C[Derive replay identity]
  B --> D[SQLite transcript event]
  C --> E[SQLite identity index]
  E --> F[Replay and deduplication lookup]
  D --> G[Session and Gateway recovery]
Loading

Decision needed

Question Recommendation
Should transcript replay use a migrated one-way, role-scoped identity field, or is retaining raw caller idempotency keys in SQLite an accepted durable-storage contract? Adopt a one-way role-scoped identity: Define and migrate a non-reversible replay identity that separates user and assistant replay domains.

Why: This selects a persistent secret-handling and identity-scoping boundary that implementation tests cannot decide safely.

Before merge

  • Do not persist caller keys verbatim in SQLite (P1) - The new override replaces the redacted message identity with the original caller key, which the existing insert stores in message_idempotency_key. The added regression explicitly proves an sk-… value remains readable from SQLite, defeating the at-rest redaction boundary; use an owner-approved one-way replay identity instead.
  • Scope replay identity by message role (P1) - This feeds the raw key into an index unique only on session and key. If a user message claims a key first, scan-assistant rejects that user row, the assistant is appended without an index, and its next retry appends again. Encode role in the durable identity and add the user-then-assistant collision regression.
  • Resolve security concern: Raw caller idempotency keys become durable SQLite data - The proposed indexed-key override reaches the transcript identity row unchanged, allowing secret-shaped caller values to remain readable at rest.
  • Resolve merge risk (P1) - Merging would retain caller-controlled secret-shaped values verbatim in the agent SQLite database.
  • Resolve merge risk (P1) - The session-and-key-only unique index makes an assistant retry unindexable when a user message already used the same key, permitting duplicate assistant events.
  • Resolve merge risk (P1) - The bug fix adds net +18 production lines to durable identity handling; the accepted design should replace raw-key pass-through with one canonical scoped identity path.
  • Complete next step (P2) - A domain owner must choose the durable replay-identity and migration contract before any repair can safely proceed.

Findings

  • [P1] Do not persist caller keys verbatim in SQLite — src/config/sessions/session-accessor.sqlite-transcript-store.ts:83-84
  • [P1] Scope replay identity by message role — src/config/sessions/session-accessor.sqlite-transcript-message-append.ts:112-116
  • [high] Raw caller idempotency keys become durable SQLite data — src/config/sessions/session-accessor.sqlite-transcript-store.ts:83
Agent review details

Security

Needs attention: The patch introduces durable storage of caller-controlled secret-shaped values outside the redacted transcript event JSON.

PR surface

Source +18, Tests +217, Other 0. Total +235 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 52 34 +18
Tests 2 217 0 +217
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 270 35 +235

Review metrics

Metric Value Why it matters
Production versus test LOC production +52/-34, tests +217/-0, baseline +1/-1 The net production growth changes a durable identity path while its required storage contract remains unresolved.

Stored data model

Persistent data-model change detected: serialized state: src/config/sessions/session-accessor.idempotency-redaction.test.ts, serialized state: src/config/sessions/session-accessor.sqlite-read.ts, serialized state: src/config/sessions/session-accessor.sqlite-transcript-message-append.ts, serialized state: src/config/sessions/session-accessor.sqlite-transcript-store.ts, serialized state: src/config/sessions/session-accessor.transcript-turn.ts, serialized state: src/gateway/server-methods/chat.inject.parentid.test.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #125214
Summary: This PR is an explicit candidate fix for the open transcript redaction/idempotency issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Implement a safe durable replay identity (recommended)
    Block this draft until a one-way role-scoped identity and upgrade path are selected and verified.
  2. Pause the draft
    Keep the PR in draft if maintainers do not want to establish a new persistent replay contract now.

Technical review

Best possible solution:

Adopt an owner-approved one-way, role-scoped replay identity with an explicit SQLite migration and replace the raw-key pass-through with that canonical durable contract.

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

Yes—source inspection provides deterministic inputs: persist a secret-shaped key, or append a user then an assistant message with the same key in one session; this read-only review did not execute contributor code.

Is this the best way to solve the issue?

No. The patch repairs redaction-induced identity drift but violates the at-rest redaction boundary and does not scope replay identity by message role.

Full review comments:

  • [P1] Do not persist caller keys verbatim in SQLite — src/config/sessions/session-accessor.sqlite-transcript-store.ts:83-84
    The new override replaces the redacted message identity with the original caller key, which the existing insert stores in message_idempotency_key. The added regression explicitly proves an sk-… value remains readable from SQLite, defeating the at-rest redaction boundary; use an owner-approved one-way replay identity instead.
    Confidence: 0.99
  • [P1] Scope replay identity by message role — src/config/sessions/session-accessor.sqlite-transcript-message-append.ts:112-116
    This feeds the raw key into an index unique only on session and key. If a user message claims a key first, scan-assistant rejects that user row, the assistant is appended without an index, and its next retry appends again. Encode role in the durable identity and add the user-then-assistant collision regression.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: Transcript replay and Gateway-injected assistant retries can duplicate or fail to deduplicate persistent session events.
  • merge-risk: 🚨 compatibility: The draft changes persisted SQLite identity contents without an approved migration or upgrade contract.
  • merge-risk: 🚨 session-state: The affected index determines whether transcript retries resolve to an existing message or append another event.
  • merge-risk: 🚨 security-boundary: The new override persists caller-controlled secret-shaped values outside the redacted transcript event JSON.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit 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 supplies focused after-fix SQLite and Gateway regression results; the blocker is the unresolved durable identity contract rather than missing behavior proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies focused after-fix SQLite and Gateway regression results; the blocker is the unresolved durable identity contract rather than missing behavior proof.

Evidence

Security concerns:

  • [high] Raw caller idempotency keys become durable SQLite data — src/config/sessions/session-accessor.sqlite-transcript-store.ts:83
    The proposed indexed-key override reaches the transcript identity row unchanged, allowing secret-shaped caller values to remain readable at rest.
    Confidence: 0.99

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame assigns the transcript identity schema and idempotency lookup surface to the same recent commit. (role: recent transcript-storage contributor; confidence: high; commits: 0684f50136e7; files: src/config/sessions/session-accessor.sqlite-transcript-store.ts, src/state/openclaw-agent-schema.sql)
  • Josh Lehman: Feature history shows repeated work on the same SQLite transcript storage area, though the exact index lines are attributed to Peter Steinberger. (role: adjacent session-history contributor; confidence: medium; commits: 453444636ccf; files: src/config/sessions/session-accessor.sqlite-transcript-store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain owner direction on one-way at-rest identity and user/assistant scoping.
  • Add a cross-role collision regression after the durable contract is selected.

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-08-17T13:10:31.262Z sha 8b56448d9ced885d240a300c0aff01c34c5b4263 :: found issues before merge. :: [P1] Keep secret redaction for caller-supplied idempotency keys
  • reviewed 2026-08-17T14:13:05.414Z sha 9e69636b6d1b6c6c0e85052616d716680a3c903b :: needs changes before merge. :: [P1] Route assistant replay through the identity index
  • reviewed 2026-08-17T14:33:00.120Z sha 9e69636b6d1b6c6c0e85052616d716680a3c903b :: needs changes before merge. :: [P1] Route assistant replay through the identity index
  • reviewed 2026-08-17T14:54:11.715Z sha 0ffd6489ea10740fba924dfc16aa718cf7fafe32 :: needs changes before merge. :: [P1] Preserve the raw key across atomic transcript batches
  • reviewed 2026-08-17T15:11:29.777Z sha 9b3a8afb7fc4765f95cd2d5355d753f40689e8f0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T15:49:55.372Z sha 0c17f90d4c955b97e3d51e0f3a8db8145ceeeb8f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T21:59:51.522Z sha 5043b1d3be3cf1d8ad407b4755f5bf6c2ba12dd7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-18T20:49:46.275Z sha 9774b24 :: found issues before merge. :: [P1] Do not persist caller keys verbatim in SQLite | [P1] Scope replay identity by message role

@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 17, 2026
@PollyBot13
PollyBot13 force-pushed the fix/transcript-idempotency-key branch from 8b56448 to 9e69636 Compare August 17, 2026 14:04
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed agents Agent runtime and tooling size: XS labels Aug 17, 2026
@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 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.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 17, 2026
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@PollyBot13
PollyBot13 force-pushed the fix/transcript-idempotency-key branch from 9b3a8af to 0c17f90 Compare August 17, 2026 15:37
@PollyBot13

Copy link
Copy Markdown
Contributor Author

Exact-head CI classification after the test-type repair: the four remaining failed jobs all died during runner setup while downloading pinned actions from codeload (429, with one transient 502). None checked out or executed branch code. The former author-owned TypeScript error is fixed; its exact stripe and focused SQLite regression pass locally. Maintainer rerun required once codeload recovers.

@PollyBot13
PollyBot13 force-pushed the fix/transcript-idempotency-key branch from 0c17f90 to 5043b1d Compare August 17, 2026 21:52
@PollyBot13

PollyBot13 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main (0b75ea3). Patch scope is unchanged. Validation: focused idempotency/redaction and chat.inject parent-id suites 8/8 pass; diff check clean.

@clawsweeper

clawsweeper Bot commented Aug 17, 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:

@PollyBot13
PollyBot13 force-pushed the fix/transcript-idempotency-key branch from 5043b1d to 9774b24 Compare August 18, 2026 20:41
@PollyBot13
PollyBot13 marked this pull request as draft August 18, 2026 20:41
@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased exact head 9774b240630168e1103a0ff4c6956583d916556e is now intentionally draft. Clean-context review found unresolved Critical privacy-at-rest and user/assistant role-scoping contracts; the PR body now states both and requests maintainer direction rather than claiming merge readiness.

@clawsweeper

clawsweeper Bot commented Aug 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 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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 18, 2026
@PollyBot13

Copy link
Copy Markdown
Contributor Author

Design decision requested for durable transcript idempotency

The current draft restores replay lookup by carrying the pre-redaction idempotencyKey into SQLite. Exact-head review found two blockers:

  • caller-controlled secret-shaped values become readable at rest;
  • the unique (session_id, key) domain cannot distinguish user and assistant messages.

I also traced existing consumers. The persisted key is used for restart-recovery turn matching, pre-persisted-turn reconciliation, session-manager deduplication, and transcript mirroring. The specific UUID/fc- false positive occurs once per 256 applicable UUIDs on average, reaching roughly 50% cumulative probability after 177 IDs.

Option 1 — Treat the root key as non-secret protocol metadata

  • Exempt only the root message idempotencyKey from generic redaction.
  • Continue redacting nested fields and message/tool content.
  • Add message role to the durable uniqueness domain.
  • Existing recovery readers can continue using the original value.

Changes: narrow redactor exception, role-aware schema/index migration, collision regression, and an exact restart-recovery regression.

Tradeoff: arbitrary caller-supplied keys remain readable in transcript storage. This is appropriate only if the contract explicitly says an idempotency key must never contain a secret.

Option 2 — Store a role-scoped SHA-256 identity

  • Keep transcript JSON redacted.
  • Store a domain-separated digest of (role, rawKey).
  • Change replay and deduplication lookups to hash the supplied candidate.
  • Refactor readers that currently compare keys in loaded transcript messages to use the identity index and event sequence instead.

Changes: new digest field/helper, role-aware lookup path, schema migration/backfill or mixed legacy support, recovery/mirror/session-manager refactoring, and expanded regressions.

Tradeoff: the original key cannot be reconstructed. Plain SHA-256 also permits verification of guessed low-entropy keys, although generated UUID/run identifiers have high entropy.

Option 3 — Store a role-scoped HMAC identity

This has the same application changes as Option 2, but uses a stable installation secret.

Additional changes: secret custody, key identifier/versioning, backup/restore and rotation behavior, and fail-closed handling when the key is missing.

Tradeoff: materially stronger than plain hashing only if the HMAC secret is protected separately from the agent database. It introduces substantially more lifecycle machinery.

Option 4 — Introduce a dedicated internal turn/replay identity

  • Persist a generated non-secret internal identity for transcript and recovery ownership.
  • Treat caller idempotencyKey only as an ingress deduplication input, optionally represented by a digest.
  • Move restart recovery and transcript relationships to the internal identity.

Changes: broader producer/consumer contract migration across transcript persistence, recovery, mirroring, anchors, and tests.

Tradeoff: largest change, but cleanly separates caller data from durable protocol identity.

Recommendation

If root idempotency keys are contractually non-secret, Option 1 is the smallest complete repair. If arbitrary caller values must remain confidential at rest, the current draft should not merge; I would prefer Option 4, or Option 2 if every relevant consumer can be reduced to candidate equality lookup. I would use Option 3 only if OpenClaw already has an acceptable separately protected key-lifecycle owner.

Could a session/Gateway owner choose which privacy contract is intended? Once selected, I can reshape the draft and add the missing cross-role and exact restart-recovery coverage.

@PollyBot13

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #126245, which merged the canonical transcript-identity/redaction fix into main. This draft's storage model and assertions no longer match the adopted contract; any remaining user/assistant role-collision concern should be raised separately with a current-main reproduction.

@PollyBot13 PollyBot13 closed this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

Transcript redaction can corrupt restart-recovery idempotency keys

1 participant