Skip to content

refactor: separate steering delivery from policy preparation - #181994

Merged
joshavant merged 1 commit into
mainfrom
refactor/steering-join-preparation
Oct 24, 2026
Merged

joshavant merged 1 commit into
mainfrom
refactor/steering-join-preparation

Conversation

@joshavant

@joshavant joshavant commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #181768

What Problem This Solves

The retained-recovery-claim repair leaves steering delivery checks hidden inside tool-policy preparation and mixes recovery observations with execution settings, making binding lifetime and final admission difficult to review.

User Impact

No intended user-visible behavior change. Same-requester steering, collaborative steering, refusal/followup behavior, queue ordering, and legacy plugin compatibility retain their existing contracts. No configuration, storage, or migration changes are required.

Why This Change Was Made

The message-join coordinator now explicitly composes delivery eligibility, execution settings, and caller policy. Settings and recovery observations remain attached to the exact selected policy binding, preserving the existing capture points and invalidation lifecycle across replies and native attempts. Generic policy preparation no longer prepares delivery as a side effect.

Final submission still checks cancellation, the captured owner/backend, policy, settings, and delivery eligibility. The retained-predecessor exception stays limited to same-requester human continuation. Existing fallback warnings retain the specific typed rejection message without changing public fallback reasons.

This is the separately requested architectural followup to the merged repair. It does not establish the cause of the historical production incident, whose admission/rejection observations were not retained.

Evidence

Validated head: 1fb7cfea1e6f4b0eac13e9203d9a2c80541982e7. Focused validation and both live-model native proof cases are complete.

  • Fresh independent diff review completed with no actionable P0–P2 findings, including a second pass after the receiver-preserving lint repair.
  • On one isolated AWS lease, all 159 baseline tests passed across eight commands. The candidate passed those eight files (164 tests) and four focused consumer commands, for 191 passing tests total. After the receiver-preserving callback repair, both affected suites reran successfully (48 tests). Complete source manifests verified before and after execution; the tested staged tree exactly matches the committed tree. No Testbox or shared Gateway was used.
  • Existing boundary matrices are extended for failed binding cleanup, equivalent-policy attempt replacement, absent versus explicitly empty recovery capture, and delivery invalidation at final submission.
  • Negative control confirmed the final-admission test detects removal of the delivery descriptor: the isolated mutant accepted the input and failed the unchanged rejection assertion. The candidate rejects before the delivery sink. The mutant source was restored and reverified (47.550 seconds command wall).
  • Core production and all 29 selected test type graphs passed, as did formatting, targeted lint after repair, and the remaining applicable static guards. Two inherited failures remain: the deprecated-API guard reports an untouched performance script, and the three dead-export scans report 6/18/15 entries. Exact-baseline replay produced identical findings with zero candidate-only entries; no unrelated repairs are included.
  • Two fresh live-model cases used the rendered Control UI and isolated Gateway on the exact committed source, with the existing fixture preparing recovery state through its owner. An unchanged predecessor claim allowed the correction into the original native task; a replacement claim produced reply-owner-ended and followup-queued, left the original task without the correction/effect, and consumed the correction once in a separately correlated subsequent task. Both harmless file effects had successful native tool results. Gateway run IDs, native threads/calls, direct task start/end records, claim checkpoints and actual effects were reconciled; transcript persistence and model claims were not treated as consumption proof.
  • Serving source/runtime hashes stayed unchanged. The observed managed native binary was Codex 0.162.1, verified by executable hash and actual version command. Each cell preserved its authenticated browser connection and used queue.mode: steer with allowCollaborativeSteering: false; all eight exported screenshots were inspected. The replacement followup repeated the fixture's old barrier command and got exit 1 before its successful effect; that separate fixture/model outcome is retained in the evidence, not described as a clean tool run. Replacement occurred before correction preparation; focused tests cover later invalidation. These constructed cases do not establish the historical incident's cause.
Scope, test costs, and LoC churn

Candidate versus merged base 3de0f0007f6951bf283041c90ae415984f48d1d8:

Scope Files Added Deleted Churn Net
Production 16 382 306 688 +76
Tests 5 193 47 240 +146
Total 21 575 353 928 +222

Each command used pnpm test <file> --maxWorkers=1. Measured wall seconds for the five changed test files:

Test file Baseline Candidate
session-controller.message-join.test.ts 49.456 50.601
session-controller.message-join.handoff.test.ts 37.583 37.839
tool-authority.runtime.admission.test.ts 50.150 50.003
tool-authority.runtime.continuation.test.ts 36.181 36.330
agent-runner-fallback-steering.test.ts 55.969 56.060

The eight matched commands totaled 393.024 seconds on baseline and 394.413 on the candidate. The four additional caller checks took 221.697 seconds; candidate total 616.110 seconds. The final receiver-fix replay took 39.734 seconds for message join and 37.583 for authority admission; lint, core types, formatting and whitespace also passed. These include wrapper/setup/compilation and are not a controlled runtime benchmark. CI timing is pending.

The runtime build took 123.382 seconds and browser preparation 18.194 seconds. Live case wall times were 56.269 seconds (unchanged claim) and 60.779 seconds (replacement). Summing each native thread's final cumulative usage gives 212,691 total tokens, including 157,626 cached input tokens; this is recorded usage, not a billing estimate. No new live suite is added to per-PR CI.

No new persistent state, public snapshot field, authority manager, or per-tool authority layer is added.

@clawsweeper

clawsweeper Bot commented Oct 23, 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 gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 23, 2026
@joshavant
joshavant marked this pull request as ready for review October 23, 2026 23:00
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 1fb7cfea1e6f4b0eac13e9203d9a2c80541982e7
  • Maintainer: @joshavant
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/cli-runner/tool-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/harness/tool-authority.runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR separates steering delivery eligibility from policy preparation while retaining observations on the exact selected policy binding.

Example: Alice sends “change the current work” while her active execution retains an unchanged predecessor recovery claim.

  • Before: The correction joins the active execution through delivery checks embedded in policy preparation.
  • After: The correction still joins the active execution, with the message-join coordinator explicitly composing delivery, settings, and policy checks.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent ownership separation with meaningful boundary coverage and no actionable correctness finding.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored behavior-preserving refactor is outside the ordinary contributor proof gate; exact-head live cases are reported in the body, while independently inspected execution evidence consists of passing CI and production-boundary suites.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No new user-visible defect is claimed; delivery checks hidden in policy preparation make steering ownership and final admission harder to review.
Reason: The maintainer-authored direction clarifies an existing sensitive boundary while preserving requester, fallback, queue, and legacy-plugin contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it is a maintainer-authored architectural followup that preserves the steering contract, and no actionable introduced defect was found.

Priority: P3
Reviewed head: 1fb7cfea1e6f4b0eac13e9203d9a2c80541982e7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The body reports exact-head Control UI/Gateway/native cases, but their runtime records and screenshots are not linked for independent inspection; the linked predecessor evidence exercises the earlier repair.
Agent review details

How this fits together

Gateway and channel messages enter session-controller steering admission, which checks the captured execution and current caller policy before delivering input to the active backend or preserving followup custody.

flowchart LR
 A[Incoming correction] --> B[Message join coordinator]
 C[Selected policy binding] --> B
 D[Delivery eligibility] --> B
 E[Execution settings] --> B
 B --> F[Final admission]
 F --> G[Active backend]
 B --> H[Followup queue]
Loading

Technical review

Best possible solution:

Keep delivery and settings composition in the existing message-join coordinator while binding historical observations and live checks to the exact policy snapshot.

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

This PR preserves behavior after the merged retained-claim repair and does not claim to reproduce or diagnose the historical production incident.

Is this the best way to solve the issue?

The separation is coherent: existing owners retain policy and delivery decisions, the coordinator composes them, and the small observation module preserves the original capture points without a parallel authority manager.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Recovery-claim observations keeps the original intent (3de0f00: Allow compatible human steering beside an unchanged predecessor claim without clearing or replacing retained delivery custody.)
  • Execution selection and continuation composition keeps the original intent (f83b7ad: Keep admitted execution settings and policy ownership fixed while current incoming caller facts are prepared and checked.)
  • Prepared caller reads and final authority keeps the original intent (9cbcd21: Prepare worker-backed policy reads while preserving captured sources, caller authority, steering order, and final enqueue checks.)
  • Requester identity and collaboration keeps the original intent (fd2a6ca: Preserve the authenticated requester and current applicable permissions while keeping cross-person human steering opt-in.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Paul Bohm: Raw commit f83b7ad adds src/sessions/session-controller.execution-selection.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f83b7ade15f3; files: src/sessions/session-controller.execution-selection.ts)
  • Peter Steinberger: Raw commit 9cbcd21 adds src/auto-reply/reply/steering-delivery-preparation.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9cbcd2108052; files: src/auto-reply/reply/steering-delivery-preparation.ts)

PR surface

Source +76, Tests +146. Total +222 across 21 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 16 382 306 +76
Tests 5 193 47 +146
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 575 353 +222

Review metrics

Metric Value Why it matters
Production versus test changes Production +382/-306; tests +193/-47 Most production churn migrates the existing preparation contract; the net growth makes binding selection explicit and extends distinct lifecycle and final-admission coverage.

Labels

Label changes:

  • add P3: This is an internal ownership refactor with no intended user-visible behavior change.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is an internal ownership refactor with no intended user-visible behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 23, 2026, 7:16 PM ET / 23:16 UTC.

@joshavant
joshavant merged commit f04709b into main Oct 24, 2026
224 of 225 checks passed
@joshavant
joshavant deleted the refactor/steering-join-preparation branch October 24, 2026 01:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: L 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