Repository navigation
fix(sessions): identify refused transcript appends safely - #130997
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 4:53 AM ET / 08:53 UTC. ClawSweeper reviewWhat this changesThe PR makes refused synchronous SQLite transcript appends return redacted typed outcomes and carries those outcomes into session-manager errors. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessThe prior Result-envelope finding is fixed, and the PR remains necessary because current main still returns raw identities for event refusals and drops message-refusal detail. The introduced shared commit-edge check redacts both refusal forms and preserves the cause through session-manager errors. Priority: P2 Review scores
Verification
How this fits togetherSQLite transcript writes persist agent-session events and messages. Session managers and gateway callers use those outcomes to preserve transcript state and provide operator diagnostics. flowchart LR
A[Agent or gateway append] --> B[Session manager]
B --> C[SQLite transcript writer]
C --> D{Session row and writer claim match?}
D -->|yes| E[Persist transcript entry]
D -->|no| F[Redacted refusal]
F --> G[Operator-visible error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +15, Tests +74, Other 0. Total +89 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Land the unified typed-refusal owner change once the exact-head required checks and normal maintainer review complete. Do we have a high-confidence way to reproduce the issue? Yes, by source: current main’s synchronous event path returns raw identity fields and its message path returns undefined on the same refusal predicate; the linked focused tests exercise missing and rebound rows. Is this the best way to solve the issue? Yes. A single commit-edge predicate is the narrowest maintainable owner-boundary repair because it keeps event and message refusal classification and redaction identical. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1e42dbc945f2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
d49b361 to
3e504d8
Compare
3e504d8 to
e00284e
Compare
e00284e to
c9af0b2
Compare
c9af0b2 to
99282da
Compare
|
Thanks @qingminglong! Proof: At
Example
|
Refused SQLite transcript appends now return one stable hash-only typed outcome across event, message, and stale-writer paths. This keeps compaction diagnostics identifiable without exposing session identities or losing refusal classification. Co-authored-by: qingminlong <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #130916
What Problem This Solves
Refused synchronous transcript appends had two unsafe outcomes. Event appends exposed raw session identities through their structured cause. Message appends returned
undefined, which lost the refusal type and made a session rebound look like a generic storage failure.Why This Change Was Made
The SQLite transcript-write owner now uses one commit-edge ownership check for event and message appends. Both paths return the existing
Resultshape with asession-reboundorsession-entry-missingrefusal. The refusal contains stable hashes for the agent, session key, expected session, and actual session instead of raw identifiers.SessionManagerpreserves that safe refusal as the error cause. It no longer infers a refusal after the owner has dropped the reason.This also removes two old type assertions from the shared owner path. Identity hashing runs only after a refusal, so successful append cost is unchanged.
User Impact
Operators can identify and correlate a refused event or message append without exposing channel peers, session identifiers, newlines, or terminal control characters. This also holds when a stale owned-writer claim rejects the append. Compaction keeps classifying the outcome as
transcript_persistence_failed.Evidence
Live red and green proof
69913572f4a84a79de1004a3a91fa87ced9cb95d.e00284e318f1987b5d79e0134a80a9caa149ed88.SessionTranscriptWriterClaimReboundErrorbut exposed the raw session key and lost the safe cause.c9af0b263c9367f3a64d1777183e567f2c5c6f4b.okarm and checks the returned stored message.99282da3d2a60de485f3111f1583135082deb296.session-rebound, contained the expected stable hashes, exposed no raw identities or control characters, preserved the named writer-claim error and rebound row, wrote no transcript event, and the reentrant direct-append consumer passed.Tests and checks
Hosted CI owns the full type-check and build. No local type-check or full build ran on this host.
Change size
+15net lines.+74net lines.The production growth is the internal message
Resultcutover, two caller unwraps, and the typed cause accepted by the existing writer-claim error. The shared owner predicate replaces the duplicated event and message validation branches.Codex sibling contract
Direct source inspection at OpenAI Codex
6478a751fde8884b2fdc76486fe23175a8e795d4confirms that native Codex rollout persistence is separate. Its recorder queues canonical items and retains failed writes for retry incodex-rs/rollout/src/recorder.rs, while the core session calls that native owner incodex-rs/core/src/session/mod.rs. This PR changes only OpenClaw SQLite transcript refusal outcomes.