Skip to content

fix: preserve Draft audience when forking from a message - #186820

Merged
shakkernerd merged 1 commit into
mainfrom
draft-message-cut
Oct 28, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
draft-message-cut

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #186773

What Problem This Solves

Fork from here on a user message in a local Draft conversation currently creates a Shared conversation. The caller selects a message boundary, not a broader audience, but the copied prefix becomes available under the Shared policy. The original conversation remains Draft, so its access restrictions do not protect the new copy.

This change covers message-cut forking through sessions.fork. Whole-conversation copying and externally owned harness forks have separate owners.

User Impact

When Draft creation is enabled, a local message fork stays Draft from its first committed row. The prefix ends before the selected user request, and the selected request and supported attachments return to the new composer unsent. The source and its history remain intact.

If Draft creation is disabled, the operation returns a policy error explaining that the user can continue in the existing conversation or ask an administrator to enable Drafts. A policy change during preparation also refuses the new copy; it never silently substitutes Shared. Existing Draft conversation work, Shared-source forks, workspace rules, and rewind/branch-switch behavior retain their contracts. There is no new configuration option, public request field, or schema.

Why This Change Was Made

The local message-cut planner creates a new identity from selection, creation and workspace metadata, but omits Draft audience. Both SQLite and memory storage install that planned entry, which then resolves to the Shared default.

The planner now carries Draft from the actual source row when creating a fork. The Gateway applies the existing visibility-creation policy against current committed configuration. Its private assertion runs through the existing transaction acceptance points, including the memory actor's final authority check after asynchronous observers. A refused candidate rolls back, and the existing repository-fork cleanup retains responsibility for an unclaimed workspace.

Evidence

The current-source regression used the real Gateway handler and actual SQLite and memory stores. Before the correction, the two Draft cases each reported expected draft, received shared; the other 32 cases passed. The existing storage matrix also checks the exact copied prefix, source preservation, child identity, and workspace behavior. Additional cases exercise initially disabled policy and disabling at final acceptance for both backends, checking that refused operations leave storage unchanged.

Focused validation passed across 12 related native test files (156 cases), affected production/test types, changed-file formatting and lint, and the enforced per-file line cap. The refreshed storage/handler batch passed 64 cases in 137.42 seconds; this includes the real worker and memory lifecycles. The accepted-base test counter reports 6,301,602 lines against the existing 6,310,000 ceiling.

On the exact candidate build, a real guest created a Draft source, received a useful planning answer, and used Fork from here on the selected user request. The new conversation was Draft on its first row, with only the earlier readiness exchange in history; the exact selected text and image returned unsent. Sending that input produced a useful answer. The original identity, audience, last run and workspace metadata stayed unchanged. An unrelated guest could open neither original nor copy, while the Shared-source control remained readable with a disabled composer.

With session.sharing.drafts: false, the existing Draft retained its staged text and image, accepted another ordinary turn and remained the same Draft. A subsequent message fork returned SESSION_VISIBILITY_DISABLED, preserved the current conversation and unsent note, and created no destination. A Shared-source fork still succeeded. Native SQLite and memory cases cover initial refusal and policy changes during preparation; the live UI scenario uses durable local storage.

Hosted CI completed successfully on this head. One storage diagnostic test failed in the first attempt, did not reproduce in the unchanged-base replay, and passed in the single diagnostic CI retry with the same pinned runtime and test group. No code-fix or inherited-failure claim is made for that transient result.

The retained baseline copied only a neutral readiness exchange; it proves an audience change, not useful post-Draft content or file exposure. The candidate adds an image and useful continuation to that baseline. Latest stable already has the same Draft visibility representation and creation-policy contract; this patch introduces no migration or old-row reader change. No live latest-stable upgrade was run. Independent review is clean; the exact-head automated reassessment reports Platinum readiness and no findings.

Visual evidence

Open preview

Before After
Before: copied neutral readiness exchange is readable by another guest After: another guest sees Session not found for the Draft copy

Owner uses Fork from here; selected text and image remain unsent

fork-action-cued.mp4

Visual verification

  • Baseline: 9a5581b
  • Exact head: a334bd753a2bba08e63d56a17b5d3b60b20660ad
  • Scenario: An unrelated guest opens a message-cut copy of another guest's Draft. The focused candidate recording shows the owner selecting Fork from here and receiving selected text and an image unsent.
  • Runtime/build: 2026.10.8-a334bd753a2b-2026-10-28T14-32-08.912Z; boot 6e931165-0877-4885-830c-d38a395de986; Chrome 156.0.8078.49
  • First committed copy audience: Draft; creator owner; no active run
  • Selected input: 587 characters and PNG SHA-256 109e1300a145eab08caf576fb2d514a943eb49a20f2821741c167e26bb2a373f returned exactly, unsent
  • Foreign read: Source and copy denied; Shared control readable
  • Draft creation disabled: Existing Draft continues; new Draft fork refuses with SESSION_VISIBILITY_DISABLED; Shared fork succeeds
  • Real guest UI and provider responses on the exact candidate build
  • Scoped native metadata verifies audience, identity, no active writes and original preservation
  • SQLite and memory tests cover initially and late-disabled policy
  • Baseline copied only the neutral readiness pair; useful source request stayed unsent and answer was excluded
  • Candidate adds an image and useful continuation beyond the retained baseline; no claim that baseline exposed useful post-Draft content
  • Model display label redacted; synthetic fixture data; original recordings retained during active work

Existing Draft continuation succeeded while new Draft creation was disabled; the next fork was refused and the pending note remained unsent:

Disabled Draft fork refusal with preserved pending note

@clawsweeper

clawsweeper Bot commented Oct 28, 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 size: S labels Oct 28, 2026
@shakkernerd shakkernerd self-assigned this Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Message-level forks preserve Draft audience and refuse creation when current policy disables Drafts.

Example: A guest selects Fork from here in a Draft conversation.

  • Before: The copied prefix becomes Shared and another guest can read it.
  • After: The copy remains Draft; disabling Draft creation refuses the fork without changing the source.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused producer fix with shipped-flow evidence, meaningful storage-boundary regressions, and no open correctness finding.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Exact-head Control UI evidence records creator continuation and foreign-guest denial, supported by inspected before/after screenshots and real handler/store regressions for policy revocation before SQLite commit and memory installation; the previous authority-proof gap is resolved.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Fork from here exposes copied Draft history under Shared audience without an audience-selection action.
Reason: The maintainer-authored direction restores the documented Draft workflow while preserving explicit Shared behavior and existing Draft continuation.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current audience-inheritance bug through the existing storage owners; no actionable patch defect remains.

Priority: P1
Reviewed head: a334bd753a2bba08e63d56a17b5d3b60b20660ad

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI sends sessions.fork with a selected message; the Gateway authorizes creation, the shared planner selects history and audience, and SQLite or memory storage installs the child before recipient-filtered publication.

flowchart TD
  A[Message menu] --> B[Gateway fork handler]
  B --> C[Current creation policy]
  C --> D[Shared message cut planner]
  D --> E[SQLite or memory commit]
  E --> F[Recipient filtered history and events]
Loading

Technical review

Best possible solution:

Preserve Draft in the shared planner and enforce current creation policy at the existing commit boundaries.

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

Current-main source omits Draft on fresh message-cut children, whose reader default is Shared; the linked report supplies matching SQLite, memory, and browser observations.

Is this the best way to solve the issue?

The patch fixes the producer, reuses the existing visibility-policy resolver, and covers both storage owners without introducing another persistence or authorization path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main defect and focused repair: Fetched main builds a fresh fork entry without Draft visibility; the introduced planner hunk preserves Draft from the authoritative source row while retaining the existing prefix and creator machinery. (src/config/sessions/session-message-cut-plan.ts:167, a334bd753a2b)
  • Final acceptance checks: SQLite validates the actual candidate through its existing commit admission; memory captures candidate visibility and rechecks authority after the asynchronous observer, immediately before installation. Added handler/store cases cover initially disabled and late-disabled policy for both backends. (src/gateway/server-methods/sessions-rewind.storage.test.ts:700, a334bd753a2b)
  • Live behavior and media: Inspected downloaded before/after screenshots show another guest reading the baseline prefix and receiving Session not found for the candidate copy. The exact-head report records creator continuation, returned unsent text/image, committed Draft metadata, disabled-policy refusal, and an unchanged Shared control. Video preparation failed with ffprobe ENOENT and browser fallback returned Cache miss; these reviewer infrastructure limits do not invalidate the available evidence. (a334bd753a2b)
  • Existing recipient authority: History and event readers consume committed visibility and current creator/access facts; event projection revalidates each recipient before using an audience cache. The existing source-participation regression also rejects revoked access without child or transcript writes. (src/gateway/session-event-projection.ts:212, a334bd753a2b)
  • Verified no-migration case: Latest stable already supports the same visibility field, Shared fallback, Draft creation switch, and creator-based Draft policy. This patch stamps only newly created children and does not rewrite existing rows, settings, schemas, or readers; the previous upgrade request is resolved by this verified no-migration case. No live latest-stable upgrade was run. (src/gateway/session-sharing-policy.ts:58, dc2523e5a5c7)
  • Exact-head gates: GitHub reports clean mergeability and successful ci-gate, dependency-review, and security-sensitive-review statuses for the reviewed head; both check pages contain no unsuccessful active check. (a334bd753a2b)

Likely related people:

  • Peter Steinberger: Raw commit 268ff00 adds src/config/sessions/session-message-cut-plan.ts:166 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 268ff00f668a; files: src/config/sessions/session-message-cut-plan.ts)
  • Shakker: Raw commit a3b58db adds src/gateway/server-methods/sessions-fork-runtime-guard.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a3b58db53bfa; files: src/gateway/server-methods/sessions-fork-runtime-guard.ts)

PR surface

Source +60, Tests +68, Docs 0. Total +128 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 79 19 +60
Tests 1 72 4 +68
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 152 24 +128

Root-cause cluster

Relationship: same_root_cause
Canonical: #186773
Summary: This PR repairs the reported message-cut audience omission; whole-conversation copying has a separate creation owner.

Members:

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The current message-fork workflow silently broadens the audience of copied Draft history.
  • merge-risk: 🚨 security-boundary: Persisted audience selection affects which guests receive copied history; the inspected commit guards and recipient policy reveal no concrete regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-28T14:57:33.102Z sha a334bd7 :: needs real behavior proof before merge. :: none

Reviewed October 28, 2026, 1:17 PM ET / 17:17 UTC (Revision 2).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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: 🧂 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@shakkernerd
shakkernerd merged commit 72db2aa into main Oct 28, 2026
314 of 316 checks passed
@shakkernerd
shakkernerd deleted the draft-message-cut branch October 28, 2026 17:35
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Fork from here preserves Draft audience and refuses new Draft copies when Draft creation is disabled.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
Preserve Draft audience from the first committed row of local message-cut forks and refuse new Draft copies when Draft creation is disabled, including policy changes during preparation.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

Fork from here creates Shared conversations from Draft sources

1 participant