Skip to content

fix: plugin tools reject active callers that need prepared source facts - #196576

Merged
vincentkoc merged 1 commit into
mainfrom
fix/plugin-tool-authority-refresh
Nov 10, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/plugin-tool-authority-refresh

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #193687, #193707

What Problem This Solves

Fixes plugin tools rejecting an active caller when that caller's source-authority facts require preparation before the invocation guard can recheck them.

User Impact

Plugin operations can pass the existing caller-authority check after its source facts are prepared. Revoking the caller during an asynchronous operation still rejects the operation before its effect; successful and rejected invocations both release the prepared scope. No permission or public API changes are introduced. The patch does not create or inherit authority, change memory-audience eligibility or scheduled-job bindings, or enable any scheduled work.

Why This Change Was Made

Plugin invocation captured the caller's guard but did not enter the existing prepared source scope used by other host-tool paths. Wrap the invocation with that owner-level scope rather than weakening the guard or adding a Knowledge-specific exception.

This is distinct from the stale asynchronous callback context fixed in #193687 (Knowledge) and #193707 (Browser); both changes are already in this branch's base. The new regression proves the missing-preparation defect, but does not establish it as the cause of an earlier restart-sensitive Knowledge incident.

Evidence

  • Before the production change, both new regression cases failed with tool invocation authority is no longer active; the 16 existing plugin-context cases passed.
  • After the change, node scripts/run-vitest.mjs src/plugins/tool-factory-context.test.ts src/agents/agent-tool-source-execution-guard.test.ts src/config/sessions/session-source-authority.test.ts --maxWorkers=1 passed all 31 tests. The new cases exercise the registered plugin callback, preparation, an await, live revocation, effect suppression, and scope release.
  • Independent review passed 22 sibling tests in host-bound-tool.test.ts and context-engine-source-scope.test.ts, with no actionable findings. Fresh P0–P2 autoreview was clean via the supported Claude route after the standalone Codex route returned an authentication error.
  • Targeted type-aware lint, formatting, and git diff --check passed. The 64-line test allocation is scoped to the preparation/revocation regression; the shared budget is unchanged.
  • Candidate commit is GitHub-verified and has the exact independently reviewed source tree. Exact-head pnpm build:runtime and full pnpm build passed. Full build verified all 162 public SDK subpaths; it reported nonfatal UI asset-size budget overruns (CSS +7 bytes and boot gzip), not a clean size-budget check.
  • Token-authenticated isolated Gateway acceptance with real native Claude CLI and Knowledge passed: save, two subsequent warm-worker searches, real chat.abort while a test hook held the next save, then a separate authorized conversation confirmed zero forbidden records and one valid record. The deterministic hold is before the Knowledge implementation, not inside a storage transaction. This is not a native original-code counterfactual.
  • Final committed-range independent review adjudicated the P3 lifetime concern non-actionable using retained-operation owner inspection and a focused QR-owner proof. The original review finding remains retained; it is not described as a clean P3 rerun.
  • Independent native review accepted the strict authenticated Knowledge evidence at this exact head, including its native-Claude and pre-implementation-cancellation limits.
  • Raw-head CI validation is still running with failures under investigation. Matching failures have been compared with scheduled main run 42790739830 at the exact branch base; unmatched timeouts remain under focused reproduction. No blanket waiver or green CI is claimed.
  • Marked ready for review to obtain the required normal PR merge-ref CI evidence, which the raw-head manual run cannot provide. Native preparation completed at the same head with github_pending; required CI/security gates still block landing. No serving runtime has been changed.

Qualification follow-through

  • Normal PR CI verifies actual merge 7b1f1fb3e11b680948522455a21b7a392525d0b5 (main parent 8c9a5cf064ff3d7b653c92daff84ab1ca74d5eea, PR parent 0b9f9fd3617db718d0e2c808263a34ac10ac7a08). It is still running.
  • Focused Node replays passed the seven mention/sign-in cases and the selected cron-event and committed-overview cases. Passing replays are not represented as source fixes.
  • The real shared-worker compiler replay exceeded the local command memory limit twice, including a separate bounded-heap attempt. Its hosted timeout remains investigated, not passed.
  • Separate CodeQL-high and precise-scan jobs failed with explicit GitHub Actions installation API quota errors. They are not code findings or completed scan evidence; no workflow, permission, or credential change was made.

Run plugin invocation callbacks inside the existing prepared source scope so caller checks use prepared facts while live revocation and release remain enforced. Cover successful and revoked plugin callbacks at the invocation boundary.
@clawsweeper

clawsweeper Bot commented Nov 10, 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 agents Agent runtime and tooling size: S labels Nov 10, 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. P2 Normal backlog priority with limited blast radius. 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 Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR prepares caller source-authority facts around plugin tool execution using the existing source-scope owner.

Example: A registered plugin tool runs for session agent:main:probe with caller facts that require asynchronous preparation.

  • Before: The active caller is rejected with “tool invocation authority is no longer active.”
  • After: The prepared caller can proceed, while revocation during an await still prevents the final effect.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source review found no defect, but mocked final effects do not clear the authority-chain proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An active caller can have a plugin operation refused because its authority facts were not prepared before the guard checked them.
Reason: The maintainer-authored direction restores the existing invocation contract with a narrow shared-owner repair and no new setting or public API.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses a distinct source-preparation defect still present on main, and source review found no actionable introduced bug.

Priority: P2
Reviewed head: 0b9f9fd3617db718d0e2c808263a34ac10ac7a08

Before merge

  • Add real behavior proof - Authority-chain proof required: the registered-callback tests use synthetic receipt authority and a mocked effect; the authenticated isolated Knowledge-route check remains pending. Show a preparation-dependent authorized operation reaching actual I/O, a different unauthorized caller refused before that I/O, and revocation during an await preventing the effect. Provide redacted logs or terminal output, excluding IPs, API 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.
  • Resolve security review attention item - No reachable authorization bypass was found, but the changed authority path still needs final-effect isolation and revocation evidence.
  • Resolve merge risk - Before merge, the PR owner must establish that prepared caller facts cannot authorize a different or revoked caller’s final I/O; the supplied synthetic authority and mocked effect leave that boundary unverified.

Findings

None.

Tests

  • Missing end-to-end proof: Supply the pending production-route run showing preparation-dependent success and unauthorized or revoked caller rejection before real I/O.
Agent review details

How this fits together

Registered plugin callbacks receive the invoking caller’s captured receipt assertion; the session-source owner prepares its facts, plugin guards recheck authority, and scope cleanup releases those facts after execution.

flowchart LR
  A[Invoking caller] --> B[Plugin callback binding]
  B --> C[Capture caller assertion]
  C --> D[Prepare source scope]
  D --> E[Plugin final effect guard]
  E --> F[Plugin operation]
  F --> G[Release prepared scope]
Loading

Technical review

Best possible solution:

Keep caller capture unchanged and enter the existing prepared source scope around the registered invocation, preserving live final-effect checks and unconditional cleanup.

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

Source shows that main omits preparation before checking preparation-dependent caller assertions, and the author reports both new cases failing before the fix; no live reproduction was supplied or run during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete source repair: prepare the captured assertion through its existing owner rather than weaken the guard or add plugin-specific policy.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Complete caller-isolation and revocation proof (recommended)
    The PR owner should exercise prepared authority through the production plugin route, showing an allowed effect and rejection of a different or revoked caller before actual I/O.

Provenance checked

  • Per-invocation caller source guard keeps the original intent (08f4a19: The Skill Workshop plugin migration captured each invoking caller so v2 guards could reject revoked callers before writes.)

Testing

Proof path: in-process harness.

Security

Needs attention: No reachable authorization bypass was found, but the changed authority path still needs final-effect isolation and revocation evidence.

Evidence

What I checked:

PR surface

Source +3, Tests +64, Other +2. Total +69 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 70 1 +69

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression code Production +4/-1 lines; tests +64/-0 lines The production change reuses an existing owner; the test growth covers successful preparation and refusal after mid-call revocation.

Labels

Label changes:

  • add P2: This is a focused plugin invocation bug supported by current source and a targeted regression, without an established widespread live incident attributable to this defect.
  • add merge-risk: 🚨 security-boundary: The patch changes how captured caller authority is prepared and consumed before plugin effects; final-I/O isolation and revocation remain unproven.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a focused plugin invocation bug supported by current source and a targeted regression, without an established widespread live incident attributable to this defect.
  • merge-risk: 🚨 security-boundary: The patch changes how captured caller authority is prepared and consumed before plugin effects; final-I/O isolation and revocation remain unproven.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect proof for the nearest unauthorized caller and prove revocation invalidates prepared authority before I/O.

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 November 10, 2026, 5:02 AM ET / 10:02 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 10, 2026 10:37
@vincentkoc
vincentkoc merged commit 41b677a into main Nov 10, 2026
246 of 254 checks passed
@vincentkoc
vincentkoc deleted the fix/plugin-tool-authority-refresh branch November 10, 2026 11:07
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…96576)

Run plugin invocation callbacks inside the existing prepared source scope so caller checks use prepared facts while live revocation and release remain enforced. Cover successful and revoked plugin callbacks at the invocation boundary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

1 participant