Skip to content

fix(gateway): let delegated OpenClaw changes work from CLI-backend agents - #138596

Open
shad0wca7 wants to merge 31 commits into
openclaw:mainfrom
shad0wca7:fix/delegated-openclaw-cli-harness-authority
Open

shad0wca7 wants to merge 31 commits into
openclaw:mainfrom
shad0wca7:fix/delegated-openclaw-cli-harness-authority

Conversation

@shad0wca7

@shad0wca7 shad0wca7 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #136036, #137017

What Problem This Solves

Delegated openclaw.chat calls from CLI/subprocess and worker harnesses failed with delegated OpenClaw approval requires an active run authority. Fully in-process agents retained the ambient caller identity, but harness tool calls crossed the Gateway WebSocket boundary, where that process-local identity is intentionally unavailable.

User Impact

CLI and worker-harness delegated calls retain their signed source ownership and approval guard, including when optional wire delegation metadata is absent. Existing run, tool-abort and worker-lifetime fencing remains fail-closed.

Why This Change Was Made

Root cause

The approval gate only consulted the process-local Gateway tool caller identity. OpenClaw already has a host-minted, HMAC-signed agentRuntimeIdentityToken for trusted cross-process calls, including the exact admitted run authority and worker turn claim, but openclaw.chat was not included in that transport.

The first revision attempted to mint replacement authority from the delegated session id. Review identified that as unsafe. The signed-identity revision then exposed two narrower defects:

  • Distinct calls in one source run receive distinct tool-bound lease claim ids. Approval reconciliation compared those claim ids, so a later call retired the original pending decision even though its exact lease was still live.
  • The wire fallback retained the generic 30-second request timeout although delegated human interaction is budgeted for 900 seconds and the approval owner can wait 600 seconds before staging/application completes.

Design

This revision carries the existing source-run authority instead of synthesizing or transferring it:

  • openclaw.chat is eligible for the signed agent-runtime identity token.
  • The host binds the exact tool abort signal into the delegated run authority before signing it.
  • Explicit host-prepared Full Access is transported only for openclaw.chat; model-authored parameters cannot create it.
  • On Gateway arrival, signed agent/runtime/session/routing facts establish delegation even when the optional wire field is omitted; model-supplied metadata cannot override or opt out of that binding.
  • Ambient in-process identity remains authoritative when present. Wire calls use the verified signed runtime identity.
  • Pending-approval reconciliation first validates the original exact application lease, then compares both callers' active canonical source owner plus local/worker kind and exact worker turn claim. It never replaces the authority stored on the pending record.
  • The delegated wire call uses the existing 900-second human-interaction budget. The generic Gateway default remains 30 seconds, and the Codex owner retains its separate 30-second completion grace.
  • Run release/replacement, original tool abort, Gateway replacement, worker-claim loss, and delegated-session replacement still fail closed.

No new configuration keys, SQLite surfaces, dependencies or retries are introduced. The existing transient signed-identity token carries an optional host-prepared Full Access fact. Existing canonical owner and human-wait helpers were sufficient.

Security properties

  • No authority is derived from a session id or model-authored delegation fields.
  • The signed identity can only be minted by the host holding the local runtime-token secret.
  • Full Access is a host-prepared restrict-only fact; omission never bypasses approval.
  • Reuse grants observation of an existing pending decision only after its original exact application lease is revalidated.
  • The original record retains its exact lease, signals, and application predicate. Closing a later sibling lease cannot transfer or cancel that authority; closing the original lease still blocks application.
  • Worker authority remains bound to the canonical placement/turn claim.

Evidence

  • Published head cea0acc7028934a9609bb656a14cb21a3496db94 integrates GitHub-confirmed current-main conflicts against pinned upstream 3260d7b41a8c2404b8b3dc800240573dfb1cc7e1. Preserves upstream compact delegate-test layout and PR timeout/permission/session-continuation contracts. Production authority changes merged without manual conflict; removed a now-unused moved import and compacted a local parameter name to satisfy changed-file lint. Validation passed: 91 focused authority/identity/delegate tests across five suites (55.731s wrapper), production core types and all three affected test-type shards, changed-file type-aware lint, formatting, pinned-main diff check, line-cap and assertion-safety ratchets. The newly integrated cron fixture needed a true-or-undefined permission normalization in its test transport only; its affected integration suite and Gateway-method types pass after that correction. Fresh independent scoped review of the frozen production tree found no actionable P0/P1; retained for the final one-line test-adapter correction. No fresh real delayed-human transport proof, replacement-head hosted verdict, or maintainer signed-carrier acceptance is claimed.

  • Prior published head fad89b4b638381fbb5e964c5d0cade97d01b0afc reconciles a GitHub-confirmed approval-test conflict onto pinned upstream d1618ccd0b276f985711ff297b1b87a77bdad35d. Upstream removed a redundant ambient-only parameter case; the later maintained cross-lease wire/ambient approval coverage remains intact. Seventeen patches replay identically; the first differs only in its upstream conflict context. Prior independent review is retained for this mechanical delta, not claimed as fresh review. All 10 local gates passed: 99 tests across five focused suites (56.058s wrapper), production core types, all three affected test-type shards (agents-root, agents-other and Gateway-methods), changed-source type-aware lint, formatting, diff, line-cap and assertion-safety checks. The initial lint attempt could not load the newly required eslint-plugin-solid; refreshing the isolated installation from the unchanged frozen lockfile resolved it without source or lockfile workarounds. No replacement-head hosted verdict or fresh live-runtime result is claimed. Real delayed-human-decision proof and area-owner signed-carrier acceptance remain outstanding.

  • Prior published head db8ec1bb286e5b9bd9a77a7fcaea911869673b9a addresses revision 24’s test-quality feedback: removed the synthetic delayed-decision mock test and unused fake-timer cleanup. The retained relay test verifies the requested 900-second budget and returned approval outcome. All 15 delegate-tool tests passed (pnpm test src/agents/tools/openclaw-delegate-tool.test.ts --maxWorkers=1, 8.655s wrapper / 6.67s Vitest); affected agents-other test types, type-aware changed-file lint, formatting, diff check, line-cap and assertion-safety gates passed. Production sources are byte-unchanged from the prior validated head, whose exact-head hosted CI was observed SUCCESS at 07:13 UTC and durable revision 24 found no production defect. Those prior-head results are historical. That prior head’s hosted CI was observed SUCCESS at 2026-10-08 17:53 UTC; durable ClawSweeper revision 25 reviewed that head and reports no actionable findings, with area-owner acceptance still outstanding. No fresh independent production review or live run is claimed for this test-only deletion.

  • A real human decision after 30 seconds remains unverified by the historical CLI evidence. The removed synthetic timeout test did not establish that transport behavior; the historical timeout RED/GREEN results below are synthetic test evidence only.

  • Prior published 4cde0ad5c4cd3cbe31b96320f8a7e01954e2d74b reconciled a confirmed import conflict onto pinned upstream 2f1f73ccb2224bbe7d961b4c0d3b29cfdd51e7f8. The maintained hosted-routing suite retains the delegated signed-identity case and drops an obsolete Workshop approval import removed upstream. All other patches replay unchanged; delegated authority, method-scoped Full Access and exact approval-lease intent remain unchanged. Fresh validation of the source committed as 4cde0ad5c4cd3cbe31b96320f8a7e01954e2d74b: 103 authority tests across five focused suites passed (50.477s wrapper); production core types and all three affected test-type shards (agents-root, agents-other and Gateway-methods) passed. Changed-source type-aware lint, formatting, diff, line-cap and assertion-safety gates passed. Prior independent scoped review is retained for the mechanically reconciled delta, not claimed as a fresh review. Prior 27-test URL-boundary proof is retained for the unchanged canonicalizer. No fresh live-runtime proof or replacement-head hosted CI result is claimed. Assigned-reviewer acceptance of the signed Full Access carrier remains outstanding.

Tested head: cea0acc7028934a9609bb656a14cb21a3496db94 (base 3260d7b41a8c2404b8b3dc800240573dfb1cc7e1).

  • Resolved current-main conflicts without changing delegated authority intent. Migrated the one PR-specific signed Full Access wire/lifetime case into the maintained hosted-routing suite; the retired baseline suite remains deleted. Preserved current-main admitted identity reconstruction and inherited permission schema.
  • Omitted-delegation RED/GREEN regression: the real openclaw.chat handler test failed before the repair, choosing connection ownership instead of signed source ownership. The parameterized regression checks both omitted and spoofed wire metadata, signed session ownership, and delegated-only operator approval. Both regression variants pass after the repair.
  • Prior published c6ab9511e93f586626135c67633e5240db04ea32 validation: 107 tests across five focused suites passed (36.14s wrapper); production core types, type-aware changed-file lint, formatting, diff check, line-cap ratchet and assertion safety passed. Fresh independent review: the sole P1 concerned the old index version; the reviewer explicitly recognized this working-tree repair as addressing it and reported no other concrete P0/P1 defect. The corrected index was verified and committed. Affected Gateway-method test types: passed (exit 0).
  • Prior published head bd1287586199249975f6a268ccbf2553686ad3f0 had successful exact-head hosted CI; those are not current-candidate CI results. The earlier 27 core-test compiler shards passed with the documented aggregate-wrapper exit-124 limitation. Current validation reruns affected proof rather than claiming those prior results as fresh full coverage.
  • Historical RED/GREEN timeout evidence: test-only 06648dac970 failed at the generic 30-second timeout (red runtime job); 537130294ac2e1360700ab2f094df4b8e9a8b05d passed 241 files / 5,013 tests (green runtime job). These are not current-head CI results.
  • The earlier real CLI proof below is historical transport evidence, not a fresh live run of this rebased candidate. No serving runtime was changed for this reconciliation. Hosted CI for prior head db8ec1bb286e5b9bd9a77a7fcaea911869673b9a was observed SUCCESS at 2026-10-08 17:53 UTC; security-owner/maintainer acceptance remains an external gate.

Earlier real CLI harness proof

Verified against a locally built Gateway through the real openclaw agent Codex app-server path:

  1. Active Full Access succeeds: an admitted finance-worker Codex turn invoked the openclaw tool over the Gateway WebSocket and changed update.checkOnStart from true to false. The terminal receipt recorded exactly one successful openclaw tool call. An independent CLI read observed false; the test then restored and schema-validated true.
  2. Source abort fails closed after dispatch: a second admitted CLI turn emitted the openclaw tool call, then received SIGINT through the CLI's same-connection abort path. The persisted tool result was OpenClaw dynamic tool call aborted. and an independent CLI read remained true.

Observer-cancellation ownership

Proposal-failure retirement belongs to the caller that installed the pending approval. A later same-source observer whose distinct lease closes fails its own live-authority check without clearing or force-denying the original owner's still-live approval. Original-owner cancellation remains fail-closed. The current focused approval-authority suite includes this order-sensitive regression.

@clawsweeper

clawsweeper Bot commented Sep 4, 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 size: XS labels Sep 4, 2026
@clawsweeper clawsweeper Bot added 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. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR carries signed caller authority into delegated OpenClaw requests, preserves approval ownership across sibling calls, and extends the request timeout.

Example: A Gateway-admitted CLI agent with Full Access requests update.checkOnStart=false.

  • Before: The delegated request fails because process-local caller authority is unavailable across the WebSocket boundary.
  • After: The signed source authority permits the change while source cancellation still prevents application.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent bug fix with no identified patch defect and successful reviewed-head CI; real behavior evidence covers the original transport failure but only part of the final changed behavior.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: CLI-backed agents cannot complete delegated OpenClaw changes despite having a valid admitted run and effective permission policy.
Reason: The change restores the documented delegation contract without adding user configuration, a competing executor, or a new approval owner.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR addresses a current delegation bug with meaningful unique work, and no actionable patch defect was found.

Priority: P1
Reviewed head: cea0acc7028934a9609bb656a14cb21a3496db94

Before merge

  • Add real behavior proof - Historical openclaw agent/Codex WebSocket evidence demonstrates Full Access application and source-abort non-application, supported by signing and lease probes; the changed 900-second request budget still lacks a real delayed-human transport result, as the author acknowledges. Provide redacted terminal output, logs, or a recording showing a decision after 30 seconds, the returned outcome, and persisted readback; redact IPs, keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Complete next step - Resolve GitHub's confirmed merge conflict while preserving the signed source authority and original approval lease, then validate the affected resolution.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a real CLI/WebSocket delegated approval whose human decision occurs after 30 seconds and whose final reply agrees with persisted readback; the retained timeout probe uses synthetic transport.
Agent review details

How this fits together

The regular-agent OpenClaw tool sends requests through Gateway transport to the system agent, whose approval owner validates source authority before applying persistent operations.

flowchart LR
  A[Admitted agent run] --> B[OpenClaw delegate tool]
  B --> C[Signed Gateway transport]
  C --> D[System agent handler]
  D --> E[Approval owner]
  E --> F[Guarded persistent operation]
  F --> G[Application outcome]
Loading

Technical review

Best possible solution:

Carry the existing admitted authority through transport while retaining the original approval lease and the existing persistent-effect guard.

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

Current-main source shows both the omitted signed-transport method and ambient-only receiver rejection; historical CLI evidence and the independent baseline controls support that path, without a new execution during this review.

Is this the best way to solve the issue?

The patch restores documented behavior through existing transport, run-authority, approval, and execution owners; the schema and URL extractions preserve their existing responsibilities and avoid duplicate implementations.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Signed runtime transport keeps the original intent (cee2aca: Carry agent caller identity across Gateway calls so server-side operations enforce the caller's scope.)
  • Delegated approval authority keeps the original intent (cd35859: Deliver delegated approvals through the canonical channel approval owner while rejecting stale, aborted, replaced, and restarted sources.)
  • Full Access and exact proposal execution keeps the original intent (6187bd6: Apply the requesting run's prepared effective policy to the exact proposal through the existing one-use executor and persistent-effect fence.)
  • Human decision lifetime keeps the original intent (644e14a: Keep the requesting tool open through the decision and actual application outcome without holding system-agent serialization.)
  • Gateway URL and token schema extraction keeps the original intent (717a30a: The PR records line-cap-driven extraction; inspected hunks preserve URL restrictions and wire validation apart from the intended optional permission fact.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6187bd6 adds src/agents/tools/openclaw-delegate-tool.ts:74 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6187bd6faff7; files: src/agents/tools/openclaw-delegate-tool.ts)
  • Josh Avant: Raw commit cee2aca adds src/agents/tools/gateway.ts:286 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cee2aca40912; files: src/agents/tools/gateway.ts)
  • Ayaan Zaidi: Raw commit cd35859 adds src/gateway/server-methods/system-agent-approval.ts:69 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd358597cf49; files: src/gateway/server-methods/system-agent-approval.ts)

PR surface

Source +103, Tests +388, Other -1. Total +490 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 350 247 +103
Tests 5 429 41 +388
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 13 779 289 +490

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The current authority transport gap breaks delegated administrative requests from CLI and subprocess agents.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (29 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-07T18:02:39.667Z sha 079bf7ce44e4403424f58845d743e4baa5032e4b :: blocked before merge. :: none
  • reviewed 2026-10-07T20:34:46.038Z sha 9e708a0a2a76eb486c88143f2cdfaa7f9e77cacf :: blocked before merge. :: none
  • reviewed 2026-10-08T07:08:27.865Z sha 4cde0ad5c4cd3cbe31b96320f8a7e01954e2d74b :: blocked before merge. :: none
  • reviewed 2026-10-08T07:28:32.574Z sha db8ec1bb286e5b9bd9a77a7fcaea911869673b9a :: blocked before merge. :: none
  • reviewed 2026-10-08T18:04:17.441Z sha db8ec1bb286e5b9bd9a77a7fcaea911869673b9a :: blocked before merge. :: none
  • reviewed 2026-10-10T05:14:27.978Z sha 5871aa5306c4c78600784a568952e659f4634df5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T12:18:32.189Z sha fad89b4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-18T02:06:31.099Z sha cea0acc :: needs real behavior proof before merge. :: none

Reviewed October 17, 2026, 10:16 PM ET / October 18, 2026, 02:16 UTC (Revision 30).

@shad0wca7
shad0wca7 force-pushed the fix/delegated-openclaw-cli-harness-authority branch from 8259e81 to fddb1ff Compare September 5, 2026 00:11
@shad0wca7
shad0wca7 requested a review from a team as a code owner September 5, 2026 00:11
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M and removed size: XS labels Sep 5, 2026
@shad0wca7

Copy link
Copy Markdown
Contributor Author

Reworked this revision around the existing host-minted signed runtime identity; it no longer derives any authority from the delegated session.

The three P1s are addressed:

  1. Source-run lifetime: openclaw.chat now carries the exact admitted delegated authority, bound to the requesting tool abort signal, and revalidates it before the persistent effect.
  2. Full Access: only the host-prepared literal true capability is signed for this method; omission remains approval-required.
  3. Same-session reuse: no replacement authority is minted, and the exact pending approval is reused across ambient/wire calls.

I also made signed runtime ownership override model-supplied delegation metadata. The focused suite is 107/107, the repository changed-files gate and build pass, and the effect-phase matrix covers active application plus run/tool/Gateway/worker/session closure before I/O.

I am finishing the redacted real harness mutation proof after correcting an unrelated stale generated-chunk reference in the local build; I will update this comment with that result before requesting re-review.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 5, 2026
@shad0wca7
shad0wca7 force-pushed the fix/delegated-openclaw-cli-harness-authority branch from fddb1ff to eeb58f4 Compare September 5, 2026 00:36
@shad0wca7

Copy link
Copy Markdown
Contributor Author

Real CLI harness proof is now complete on revised head eeb58f4250f.

  • Active source: a Gateway-admitted finance-worker Codex app-server turn made exactly one openclaw tool call and changed update.checkOnStart from true to false; an independent CLI read observed false. The test restored and schema-validated true afterward.
  • Aborted source: a second admitted CLI turn persisted the openclaw tool-call boundary, then received SIGINT through the CLI's same-connection abort path. Its tool result is OpenClaw dynamic tool call aborted. and an independent read remained true, so the persistent effect did not occur.

The PR body now records this redacted real transport evidence. Deterministic effect-phase tests additionally cover run release/replacement, tool abort, Gateway replacement, worker-claim loss, session replacement, and same-session pending-approval reuse. Exact-head CI is rerunning after the metadata-only commit-message correction.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 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:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 5, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Sep 5, 2026
@shad0wca7

Copy link
Copy Markdown
Contributor Author

Addressed both P1s on 342d4cfa828.

  • Approval reuse now validates the pending record's original exact lease first, then compares the active canonical source owner, runtime kind, and exact worker turn. The record is never rebound. Real child leases with different AbortSignals cover wire→wire and ambient→wire reuse; closing the later lease still permits the original, while closing the original still blocks application.
  • Delegated openclaw.chat now carries the existing 900-second human-interaction budget through in-process and wire dispatch. The generic 30-second default and Codex's separate completion grace are unchanged. A fake-timer guarded decision at 30,001 ms covers the regression.

Proof: pre-fix timeout failure; exact-head runtime shard: 241 files / 5,013 tests; prod types, test types, and format/lint pass. Direct Codex inspection at d05e6d5 confirms the dynamic handler and app-server request path add no competing 30-second deadline.

Production delta versus the reviewed head: net +10; tests: net +112.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 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:

…y line cap

Move the Zod payload schema for agent runtime identity tokens into a sibling
agent-runtime-identity-token.schema.ts. The token module keeps minting,
signing, verification, and live-authority binding; the schema module only
proves wire shape.

The moved block is unchanged apart from export keywords and one dropped
type assertion: ChannelId admits any plugin-provided string, so the
normalized currentChannelProvider needs no `as ChannelId` narrowing. That
retires the file's only grandfathered assertion, so its assertion-safety
baseline entry shrinks away.

Brings agent-runtime-identity-token.ts from 706 to 550 counted lines
(cap 700) without touching the cap.
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

Main's openclaw#196984 gate requires callerIdentity?.assertAutoApproveChangesCurrent
before a delegated change may be applied automatically. Wire (CLI-backend)
callers cross a process boundary and only carry trustedAgentRuntime, so
automatic application was structurally unreachable for them.

The preparing host now registers the live policy closure in a server-owned
handoff map and the signed runtime identity token carries only an opaque
correlation id. The target Gateway redeems it only when the id is bound to the
same agent, session, operational run instance and delegated authority claim the
token verified, and only for a signed full-permission grant; a missing or
unbound handoff still routes the change to a human. The id is never authority
and openclaw#196984's rechecks and closure fences are unchanged.

Tests: wire Full Access lifecycle suite (active/run/tool/gateway/worker/session)
now asserts the revalidated contract; fixtures attach the policy assertion and
supply delegationExecAuthority where automatic authority is expected.
@shad0wca7

shad0wca7 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged current main (210458b3d43) and reconciled with the #196984 delegation-authority gate. This resolves the conflict and restores the PR's premise: delegated changes from CLI-backend agents.

What was wrong. Main now applies a delegated change automatically only when signedFullPermission && callerIdentity?.assertAutoApproveChangesCurrent. A wire (CLI-backend) caller has no in-process callerIdentity, so automatic application was structurally unreachable for it, and the six wire Full Access lifecycle cases could only pass by approving a path that cannot assert current policy. Main's exclusion is deliberate — this PR should not undo it.

Fix (small, additive). The preparing host registers the live policy closure in a server-owned handoff map (src/gateway/agent-runtime-automatic-change-policy.ts), and the signed runtime-identity token carries only an opaque correlation id. The target Gateway redeems it only when the id is bound to the same agent, session, operational-run instance and delegated-authority claim the token verified, and only for a signed full-permission grant. A missing or unbound handoff still routes the change to a human; the id is never authority and nothing widens permission on its own. #196984's assertAutoApproveChangesCurrent recheck and all six closure fences are unchanged.

Tests and gates. The six wire Full Access lifecycle cases (active/run/tool/gateway/worker/session) now assert the revalidated contract; fixtures attach the policy assertion and supply delegationExecAuthority where automatic authority is expected, with a case asserting that an unestablished exec authority is not automatic. Local: 88 focused tests green, changed-file lint clean, line-cap ratchet and git diff --check clean, formatter applied, core type check green. The test-type check is still running; I'll report that result before asking for review.

Reviewable in isolation: the new module plus three wire-path touch points (agents/tools/gateway.ts, agent-runtime-identity-token.ts/.schema.ts) and the approval-authority test contract. Naming and placement are easy to adjust if you'd rather the assertion live beside the existing execution-lineage handoff.

# Conflicts:
#	src/gateway/server-methods/system-agent-approval.ts
…proval

An in-process caller identity is admitted by this gateway, so it keeps the
existing "restricted only when explicitly denied" posture. Requiring the
explicit signed flag there made Full Access delegated chat proposals fall
back to the operator prompt, which stalls flows that never expect one.

The signed wire identity is not admitted locally, so it still needs the
explicit Full Access grant before the current-policy assertion applies.
@shad0wca7

Copy link
Copy Markdown
Contributor Author

Two follow-ups since the last update, both on the current head (45af3aec8b5).

Test-type check. Clean — the gateway-methods test types compile against the new identity field, so the harness change does not need further type work.

Auto-approval boundary, tightened in the right place only. The current-policy assertion now requires an explicitly signed Full Access grant for a wire identity (the CLI-backend path, which is not admitted by the target Gateway), while an in-process caller keeps the existing "restricted only when explicitly denied" posture. Requiring the explicit flag on both sides made ordinary delegated chat proposals fall back to the operator prompt; the three approval/delegation suites are green again (approval lifecycle, approval authority, delegate tool). Net effect for this PR: nothing widens, and the wire path still cannot apply a change without redeeming a host-owned current-policy closure.

shad0wca7 and others added 3 commits November 17, 2026 11:31
…w-cli-harness-authority

# Conflicts:
#	src/agents/tools/openclaw-delegate-tool.test.ts
Adopt main's apply-time contract (an approved apply finishes; only
cancellation or session replacement fences it) and keep the wire
automatic-change policy assertion at decision time.
@shad0wca7

Copy link
Copy Markdown
Contributor Author

Wire-path current-policy hook, on `9b6bef57fac`.

The delegated Full Access path now takes its authorization from a server-owned assertion instead of trusting the signed grant alone: when a signed CLI-backend grant arrives, the Gateway asks the current policy whether the delegation still authorizes the change. If the assertion succeeds, the change applies automatically as before; if it throws `DelegatedChangeApprovalRequiredError`, the request becomes a human approval whose description carries the refusal reason; if no assertion is attached, Full Access still requires human approval.

Why this shape: it keeps every guarantee from #196984 / `b8980ca9a0` intact — nothing is loosened, and the granted authority is revalidated against live policy rather than the state at signing time. Upstream's approved-apply-finishes callback is preserved, so the apply path and its fencing are unchanged.

Tests: `src/gateway/server-methods/system-agent-approval-authority.test.ts` now covers the three wire outcomes above, plus handoff-ledger behaviour (exact-owner redemption, mismatch consumes the id, run-instance disagreement throws, revoke drops the closure). Legacy apply-fencing cases were replaced by upstream's lifecycle cases. Locally: 17/17 in the authority suite, oxfmt and oxlint clean on the changed files, line-cap ratchet OK.

One note so the red gate is not misread: the CI workflows on this head are waiting on fork-run approval, so `ci-gate` has not executed any jobs yet. Nothing here is a failing-test signal.

Also folded in a merge of current main (`c48837347f4`), which is what removes the conflict.

Kit and others added 4 commits November 19, 2026 15:27
…rent main

Upstream openclaw#201998 removed forceDenyIfRuntimeAuthorityClosed; keep the pending-object ownership guard and retire foreign proposals via their own owner. Tag the wire Full Access fixtures' delegated authority as local, matching AgentRuntimeDelegatedAuthority's current discriminated union.
Resolve system-agent openclaw.chat conflict by keeping main's approval-signal capture alongside the delegated-runtime identity handoff (inputParams + trustedAgentRuntime).
Resolve the identity-token conflict on upstream zod schemas and normalization helpers, retaining explicit signed Full Access and the server-owned current-policy assertion handoff and refusal path. Remove the superseded extracted schema module. Preserve openclaw#196984 effective-authority gates and initialization abort fencing.

Validation: 132 focused tests including the six wire lifecycle cases; gateway-methods types; targeted formatting and lint; diff check; line-cap ratchet against pinned upstream 39c3099.
…w-cli-harness-authority

# Conflicts:
#	src/agents/tools/openclaw-delegate-tool.test.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawtributor-review Clawtributor pull request awaiting prioritized maintainer review clawtributors PR from a clawtributor gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants