Skip to content

fix(plugins): surface empty availability groups at plugin tool registration - #94110

Closed
Alix-007 wants to merge 3 commits into
openclaw:mainfrom
Alix-007:fix/surface-empty-availability-group-92361
Closed

Alix-007 wants to merge 3 commits into
openclaw:mainfrom
Alix-007:fix/surface-empty-availability-group-92361

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a plugin author registers a tool whose availability declares an empty anyOf / allOf group, the tool is silently dropped from the tool plan with zero feedback (#92361). capturePluginToolDescriptor did not preserve the tool's availability, so the existing empty-group unsupported-signal diagnostic was never evaluated — the author sees their tool simply vanish, with no log line pointing at the misconfiguration. Worse, before the fix the descriptor was even treated as visible despite being broken. This affects anyone authoring openclaw plugins, turning a trivial config typo into a silent, hard-to-diagnose disappearance.

Evidence

Live runtime proof drives the real production capturePluginToolDescriptor (the exact function resolvePluginTools() calls), then feeds the descriptor through the real buildToolPlan planner, crossing two boundaries: a real console.warn → process.stderr sink (captured back as bytes) and the visible-vs-hidden planner decision.

  • After fix (live terminal): empty-group warning emitted to stderr carrying demo/broken_tool (1 new line), descriptor retains availability: {"anyOf":[]}, planner hides the tool with the unsupported-signal "Empty availability anyOf group" diagnostic → RESULT: PASS.
  • Negative control (stash tool-descriptor-cache.ts back to pre-fix parent, re-run same proof): 0 stderr lines, availability dropped to undefined, tool reported visible with no diagnostics → RESULT: FAIL — the exact [Bug]: Tool availability evaluator silently ignores empty allOf/anyOf groups during expression normalization #92361 silent failure the fix removes.
  • Unit suites: vitest run src/plugins/tool-descriptor-cache.test.ts src/tools/planner.test.ts → 2 files, 15 tests passed (covers availability preservation, the empty-group warn, malformed non-contract fields ignored, and planner hiding the malformed descriptor).

Summary

When a plugin tool declares an empty allOf / anyOf availability group, the tool is silently hidden with zero feedback to the author (#92361). capturePluginToolDescriptor (src/plugins/tool-descriptor-cache.ts) did not preserve the tool's availability, so the empty-group unsupported-signal diagnostic was never evaluated or surfaced — the author has no idea why the tool vanished.

Changes

  • capturePluginToolDescriptor now preserves tool.availability on the descriptor.
  • At plugin tool registration, an empty allOf / anyOf group emits a warn (reusing the existing ToolAvailabilityDiagnostic "Empty availability anyOf/allOf group" message) carrying the pluginId + toolName, so authors get immediate feedback instead of a silently hidden tool.
  • +227/-1 across 5 files (2 are tests).

Real behavior proof

Behavior addressed: A plugin tool registered with an empty anyOf (or allOf) availability group used to vanish from the tool plan with no log line — the author got no signal at registration time. The fix preserves availability on the captured descriptor and emits a registration-time warn through the plugin context logger so the author is told exactly which pluginId/toolName is misconfigured.

Real environment tested: Node v22.22.0 + tsx 4.22.3 driving the real production capturePluginToolDescriptor (the exact function plugin tool registration calls at resolvePluginTools() in src/plugins/tools.ts, where logger: context.logger is now passed). The proof crosses two real boundaries: (1) a real console.warn-backed logger whose output lands on the real process.stderr log sink, captured back as bytes; (2) the real buildToolPlan (src/tools/planner.ts) deciding visible vs. hidden.

Exact steps or command run after this patch:

# worktree on PR head fork/fix/surface-empty-availability-group-92361
node --import tsx proof.mts

proof.mts builds a plugin tool with availability: { anyOf: [] }, taps process.stderr.write, calls capturePluginToolDescriptor({ pluginId: "demo", tool, optional: false, logger }), then feeds the resulting descriptor through buildToolPlan.

Evidence after fix (live terminal):

plugin tool availability diagnostic (demo/broken_tool): Empty availability anyOf group
===== PR #94110 real-runtime proof =====
[registration] new stderr lines captured: 1
[boundary-1 stderr] saw empty-group warning : true
[boundary-1 stderr] raw bytes              : "plugin tool availability diagnostic (demo/broken_tool): Empty availability anyOf group"
[descriptor] availability preserved        : {"anyOf":[]}
[boundary-2 planner] tool visible          : false
[boundary-2 planner] tool hidden           : true
[boundary-2 planner] hidden diagnostics    : [{"reason":"unsupported-signal","message":"Empty availability anyOf group"}]
=========================================
RESULT: PASS (warning surfaced + availability preserved + tool diagnosed)

Negative control (stash src/plugins/tool-descriptor-cache.ts back to its parent pre-fix state, re-run the same proof.mts):

[registration] new stderr lines captured: 0
[boundary-1 stderr] saw empty-group warning : false
[boundary-1 stderr] raw bytes              : ""
[descriptor] availability preserved        : undefined
[boundary-2 planner] tool visible          : true
[boundary-2 planner] tool hidden           : false
[boundary-2 planner] hidden diagnostics    : []
RESULT: FAIL

Pre-fix: stderr stays silent, availability is dropped (undefined), and the tool is even reported as visible — the exact #92361 silent-failure the fix removes. File restored afterward.

Observed result after fix: the empty-group warning is emitted to the real stderr sink carrying demo/broken_tool (one new line), the captured descriptor retains { "anyOf": [] }, and the planner now hides the tool with the unsupported-signal "Empty availability anyOf group" diagnostic instead of silently swallowing it. Unit suites confirm it too: vitest run src/plugins/tool-descriptor-cache.test.ts src/tools/planner.test.ts → 2 files, 15 tests passed.

What was not tested: end-to-end loading of a real on-disk plugin package through the full plugin loader/cache-write path (the proof drives the registration capture function directly with an in-memory tool); the allOf-variant message path (only the anyOf empty-group path is exercised at runtime here, though both share the same diagnostic code path and the allOf case is covered by the unit tests).

Scope

Fixes #92361. Focused implementation (preserve availability + registration-time warning). Competing PRs #92411 (XL, scattered) and #93962 (today, AI-assisted) are broader/less focused — barnacle lets the maintainer pick the best-fit version.

Real behavior proof

Behavior addressed: A plugin tool registered with an empty anyOf/allOf availability group used to disappear from the tool plan without any registration-time log signal. This patch preserves the availability descriptor and emits a plugin context warning naming the broken plugin/tool.

Real environment tested: Local Linux runtime with Node v22.22.0 and tsx 4.22.3, driving the real production capturePluginToolDescriptor function used by plugin registration and the real buildToolPlan planner. The proof crosses the real console.warn to process.stderr sink and the planner visible/hidden decision.

Exact steps or command run after this patch: In the PR head worktree fork/fix/surface-empty-availability-group-92361, ran node --import tsx proof.mts. The script builds a plugin tool with availability { anyOf: [] }, taps process.stderr.write, calls capturePluginToolDescriptor({ pluginId: "demo", tool, optional: false, logger }), then feeds the descriptor through buildToolPlan.

Evidence after fix: Live terminal capture from node --import tsx proof.mts:

plugin tool availability diagnostic (demo/broken_tool): Empty availability anyOf group
===== PR #94110 real-runtime proof =====
[registration] new stderr lines captured: 1
[boundary-1 stderr] saw empty-group warning : true
[boundary-1 stderr] raw bytes              : "plugin tool availability diagnostic (demo/broken_tool): Empty availability anyOf group"
[descriptor] availability preserved        : {"anyOf":[]}
[boundary-2 planner] tool visible          : false
[boundary-2 planner] tool hidden           : true
[boundary-2 planner] hidden diagnostics    : [{"reason":"unsupported-signal","message":"Empty availability anyOf group"}]
RESULT: PASS (warning surfaced + availability preserved + tool diagnosed)

Negative control terminal capture after restoring the parent pre-fix tool-descriptor-cache.ts showed zero stderr lines, availability undefined, tool visible true, and RESULT: FAIL.

Observed result after fix: The empty-group warning is emitted to the real stderr sink with demo/broken_tool, the captured descriptor retains {"anyOf":[]}, and the planner hides the tool with the unsupported-signal diagnostic "Empty availability anyOf group" instead of silently treating it as visible. The related vitest command passed 15 tests.

What was not tested: Full end-to-end loading of a real on-disk plugin package through the plugin loader/cache-write path was not run; the proof drives the registration capture function directly with an in-memory tool. The allOf runtime variant was not separately exercised in the live proof, though it shares the diagnostic path and is covered by unit tests.

@Alix-007
Alix-007 force-pushed the fix/surface-empty-availability-group-92361 branch from dd4e4ce to b185ab9 Compare June 19, 2026 13:13
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: this PR remains a viable, focused fix for the linked plugin tool availability diagnostic bug, and current main does not already preserve plugin-authored availability. The latest head addresses the prior cycle-recursion blocker, so the remaining decision is maintainer selection of exactly one overlapping implementation and acceptance of the compatibility change.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #92361
Summary: This PR is a candidate fix for the canonical empty availability-group diagnostic bug, with several active sibling implementations still open.

Members:

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

Canonical path: Close this PR as superseded by #92411.

So I’m closing this here and keeping the remaining discussion on #92411.

Review details

Best possible solution:

Close this PR as superseded by #92411.

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

Yes, by source inspection: current main drops plugin tool availability during descriptor capture while the evaluator already emits empty-group diagnostics when availability reaches it. The PR body also supplies terminal proof with a negative control, but I did not execute tests in this read-only review.

Is this the best way to solve the issue?

Yes, with maintainer acceptance of the compatibility change. The focused capture-time warning avoids adding a new planner callback API, and the latest cycle guard removes the prior crash blocker; the remaining question is which overlapping PR maintainers want as canonical.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff changes in-process TypeScript descriptor validation/logging and tests only.

AGENTS.md: found and applied where relevant.

What I checked:

  • linked superseding PR: fix(tools): reject malformed availability expressions #92411 (fix(tools): surface empty availability group diagnostics via onHiddenDiagnostic callback) is still open as the canonical replacement.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • shakkernerd: GitHub path history and git show identify c5224a3 as adding src/tools/availability.ts, planner.ts, types.ts, and related descriptor-planning files. (role: introduced planner surface; confidence: high; commits: c5224a341e79; files: src/tools/availability.ts, src/tools/planner.ts, src/tools/types.ts)
  • hansraj316: PR history shows 201b5f3 changed unsupported-signal propagation in anyOf availability, directly adjacent to this empty-group diagnostic behavior. (role: recent availability diagnostic contributor; confidence: medium; commits: 201b5f312f8a; files: src/tools/availability.ts, src/tools/availability.test.ts)
  • steipete: GitHub path history shows 1466878 introduced plugin tool descriptor caching and later commits touched plugin metadata documentation/utilities near the affected capture boundary. (role: descriptor-cache and plugin metadata contributor; confidence: high; commits: 1466878c36ff, f4d2748ca512; files: src/plugins/tool-descriptor-cache.ts, src/plugins/tools.ts, docs/plugins/building-plugins.md)
  • ly-wang19: Recent path history shows c1336b6 changed cached plugin tool candidate classification in src/plugins/tools.ts, adjacent to plugin tool materialization and descriptor caching. (role: recent adjacent plugin tools contributor; confidence: medium; commits: c1336b6b412b; files: src/plugins/tools.ts)

Codex review notes: model internal, reasoning high; reviewed against be2c4c65abd9.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 20, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — Added a Real behavior proof section: it drives the real capturePluginToolDescriptor with an empty availability anyOf group and reads back across the real console.warn→stderr sink and the real buildToolPlan — after the fix stderr emits the diagnostic and the tool is hidden, while a negative control on the pre-fix code is silent and wrongly marks the tool visible. Vitest (15 tests) passes.

@clawsweeper

clawsweeper Bot commented Jun 20, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Jun 20, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 21, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — Added the What Problem This Solves and Evidence headings the proof workflow expects (proof content unchanged, just restructured under the required sections). This should clear needs-pr-context.

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — Updated the PR body with a machine-readable ## Real behavior proof section using the exact field names required by the current proof policy. I verified the updated body locally against evaluateRealBehaviorProof and the latest GitHub Real behavior proof check is now passing.

@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 26, 2026
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jun 29, 2026
A plugin-supplied self-referential availability object (e.g. a.anyOf = [a])
made isToolAvailabilityExpression recurse until RangeError, crashing plugin
tool registration. Add a recursion-path WeakSet guard so a cycle is treated
as a non-expression instead of overflowing the stack. Adds a regression test.
@clawsweeper clawsweeper Bot added 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. 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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. labels Jun 30, 2026
@Alix-007

Alix-007 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added 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: 🦐 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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 1, 2026
@clawsweeper clawsweeper Bot closed this Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper autoclose is complete.

Reason: structured ClawSweeper close marker: close-required (sha=7027be9cbc99cc57460a50557690a9d735f79458)

Closed:

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

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Tool availability evaluator silently ignores empty allOf/anyOf groups during expression normalization

1 participant