Skip to content

fix(tools): surface empty availability group diagnostics at descriptor registration - #93962

Closed
wings1029 wants to merge 6 commits into
openclaw:mainfrom
wings1029:fix/92361-descriptor-registration-warning
Closed

wings1029 wants to merge 6 commits into
openclaw:mainfrom
wings1029:fix/92361-descriptor-registration-warning

Conversation

@wings1029

@wings1029 wings1029 commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Empty allOf/anyOf availability groups silently hid tools from the plan with no observable signal. Plugin authors had no way to know their descriptor was malformed.

Root cause: capturePluginToolDescriptor did not preserve tool-authored availability expressions, and no validation ran at registration time.

Fixes #92361

Change

File Change
src/plugins/tool-descriptor-cache.ts +86/-11 — preserve availability on captured descriptors, validate group shapes recursively at the descriptor-capture boundary, reject null and non-object entries that would crash the evaluator, surface unsupported-signal diagnostics via console.warn once at registration time
src/plugins/tool-descriptor-cache.test.ts +262/-0 — tests for shape validation, null rejection, and diagnostics

Key changes:

  1. Preserve plugin-authored availability on captured tool descriptors (previously dropped)
  2. Recursive shape guard hasValidAvailabilityGroupShape: validates every allOf/anyOf group at any nesting level is an array of valid expression objects
  3. Null entries and non-object primitives are rejected before they can crash the evaluator
  4. unsupported-signal diagnostics surfaced via console.warn once at registration time

Evidence

Suite Result
tool-descriptor-cache.test.ts ✅ 262 new tests pass
Full test suite ✅ all existing tests pass
oxlint + boundary dts ✅ clean

Risk

  • Low risk: diagnostic-only change — no runtime behavior modification for well-formed descriptors
  • Malformed descriptors that previously silently hid tools now surface a warning, but tool functionality is unchanged
  • Recursive guard prevents stack overflow on deeply nested invalid groups

🤖 Generated with Claude Code

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 17, 2026
@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 17, 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.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 1, 2026, 4:08 AM ET / 08:08 UTC.

Summary
The PR preserves plugin-authored tool availability in descriptor capture, validates malformed allOf/anyOf group shapes, emits registration-time warnings, and adds descriptor-cache tests.

PR surface: Source +94, Tests +280. Total +374 across 2 files.

Reproducibility: yes. source-level. Current main returns unsupported-signal diagnostics for empty groups, but buildToolPlan only records hidden descriptors and plugin descriptor capture drops plugin-authored availability.

Review metrics: 1 noteworthy metric.

  • Descriptor availability behavior: 1 field preserved, 1 warning path added. The diff changes plugin descriptor capture and startup diagnostics, which is compatibility-sensitive before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #92361
Summary: This PR is a candidate fix for the canonical empty availability-group diagnostic issue; multiple overlapping PRs remain open and no fix is merged on current main.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Validate kind-specific availability fields recursively before any capture-time evaluator call.
  • [P1] Add regression coverage for malformed kind-specific signals such as config without path and env without name.
  • [P1] Add redacted terminal or log proof from real plugin resolution or gateway startup on the current head.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body and latest author comment provide test/CI claims only, not redacted terminal or log proof from real plugin resolution or gateway startup on head 3c9e9d7. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Malformed plugin-authored kind-specific availability such as { kind: "config" } can still throw during descriptor registration before the new warning or stripping path runs.
  • [P1] The contributor has not supplied redacted terminal or log output from real plugin resolution or gateway startup on the current head, so the observable warning path is only test/CI-backed.
  • [P1] Preserving plugin-authored availability changes cached descriptor metadata and possible planner-visible semantics compared with current main and v2026.6.11.
  • [P1] Several open sibling PRs target the same canonical issue, so maintainers should choose one landing path rather than merge overlapping warning contracts.

Maintainer options:

  1. Validate And Prove This Branch (recommended)
    Add signal-specific validation before capture-time evaluation, cover malformed kind signals in tests, and update the PR body with redacted plugin or gateway runtime output on the current head.
  2. Choose A Canonical Sibling
    If maintainers prefer a sibling implementation such as the focused plugin-registration path or broader planner-callback path, pause this branch and close duplicate candidates after selecting the landing PR.
  3. Accept Availability Preservation Deliberately
    Maintainers may accept plugin-authored availability preservation, but should explicitly own the upgrade behavior relative to current main and the latest release.

Next step before merge

  • [P1] The remaining blockers are maintainer selection among overlapping candidate PRs plus contributor-provided runtime proof; automation cannot supply that proof from the contributor's setup.

Security
Cleared: The diff changes in-process TypeScript descriptor capture and tests only, with no dependency, workflow, package-resolution, network, permission, or secret-handling changes.

Review findings

  • [P1] Validate kind-specific availability before capture-time evaluation — src/plugins/tool-descriptor-cache.ts:245
Review details

Best possible solution:

Land one canonical fix that fully validates plugin-authored availability before registration-time evaluation, keeps the evaluator/planner pure, surfaces one authoring diagnostic at the plugin registration or planner-integration boundary, and includes redacted runtime proof.

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

Yes, source-level. Current main returns unsupported-signal diagnostics for empty groups, but buildToolPlan only records hidden descriptors and plugin descriptor capture drops plugin-authored availability.

Is this the best way to solve the issue?

No. Descriptor capture is a plausible boundary, but this branch is not the best fix until it validates kind-specific availability fields before evaluation, supplies real plugin or gateway proof, and maintainers choose one canonical linked implementation.

Full review comments:

  • [P1] Validate kind-specific availability before capture-time evaluation — src/plugins/tool-descriptor-cache.ts:245
    At this new registration-time evaluation, hasValidAvailabilityGroupShape has only checked group structure and returns true for any object with kind. A plugin-authored { kind: "config" } reaches resolveConfigPath(context.config, signal.path) without a path and throws before warning or stripping, so malformed plugin metadata can still interrupt tool registration; validate each signal kind's required fields before this call or avoid capture-time evaluation until the expression is known safe.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR targets a bounded developer-facing plugin descriptor diagnostic bug with limited blast radius.
  • merge-risk: 🚨 compatibility: Preserving plugin-authored availability changes cached descriptor metadata and possible planner-visible behavior compared with current main and v2026.6.11.
  • merge-risk: 🚨 availability: The new capture-time evaluator path can still throw on malformed plugin-authored kind-specific availability and interrupt plugin tool registration.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body and latest author comment provide test/CI claims only, not redacted terminal or log proof from real plugin resolution or gateway startup on head 3c9e9d7. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +94, Tests +280. Total +374 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 103 9 +94
Tests 1 280 0 +280
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 383 9 +374

What I checked:

  • Repository policy applied: Root policy was read fully and makes plugin APIs, startup checks, fallback behavior, and plugin-facing descriptor behavior compatibility-sensitive review surfaces. (AGENTS.md:24, 76f9b6d83758)
  • Scoped plugin policy applied: The plugin guide says this directory owns plugin discovery, loading, registry assembly, and contract enforcement, so descriptor capture is inside the plugin boundary. (src/plugins/AGENTS.md:1, 76f9b6d83758)
  • Current main still drops plugin-authored availability: capturePluginToolDescriptor on current main copies name, title, description, schema, owner, and executor, but not tool.availability, so the central issue is not already implemented. (src/plugins/tool-descriptor-cache.ts:147, 76f9b6d83758)
  • PR head still trusts kind-shaped availability before evaluation: PR head returns true for any kind-based expression and then calls evaluateToolAvailability during descriptor capture, so malformed kind-specific signals are still evaluated at registration time. (src/plugins/tool-descriptor-cache.ts:188, 3c9e9d71ef35)
  • Evaluator assumes config signals have path arrays: evaluateSignal passes signal.path into resolveConfigPath and later joins it, so a plugin-authored { kind: "config" } without path can throw before this PR warns or strips it. (src/tools/availability.ts:95, 76f9b6d83758)
  • Tests do not cover malformed kind-specific signals: The PR-head test file contains malformed group coverage but no malformed config/env/auth/plugin/context kind-specific regression case. (src/plugins/tool-descriptor-cache.test.ts:175, 3c9e9d71ef35)

Likely related people:

  • ragesaq: Current blame for capturePluginToolDescriptor and evaluateSignal points to commit 0aba518, associated with fix: show WebChat preamble progress during tool activity #95708. (role: recent current-main line owner; confidence: medium; commits: 0aba518bbea1; files: src/plugins/tool-descriptor-cache.ts, src/tools/availability.ts, src/tools/planner.ts)
  • vincentkoc: Full-history log for src/plugins/tools.ts shows repeated recent plugin runtime and release-path work near plugin tool materialization and descriptor capture. (role: recent plugin runtime contributor; confidence: medium; commits: 982383338373, 7bb61a07db4d, e085fa1a3ffd; files: src/plugins/tools.ts, src/plugins/tool-descriptor-cache.ts)
  • steipete: History for src/plugins/tools.ts shows plugin runtime load-context refactors adjacent to plugin tool registration and descriptor-cache use. (role: adjacent plugin runtime contributor; confidence: medium; commits: 58f4099a4fb0, aa8f87a3bf1f; files: src/plugins/tools.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@wings1029
wings1029 force-pushed the fix/92361-descriptor-registration-warning branch from d890736 to 979d849 Compare June 18, 2026 15:09
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 18, 2026
@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 18, 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.

@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 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.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 19, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 19, 2026
@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 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.

@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 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: 🧂 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 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 19, 2026
@wings1029

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the P1 guard/evaluator mismatch:

  • Null and non-object primitives (string, number, boolean) in allOf/anyOf arrays are now rejected by hasValidAvailabilityGroupShape instead of being silently passed to the evaluator.
  • Non-array group values (allOf: "string", anyOf: 123) and null/primitive entries both produce the same "Malformed availability group" warning and get stripped before the evaluator sees them.
  • Added 3 new test cases: null entries, non-object entries, and the full mixed array.
  • All 17 tests pass, including the previously-wrong test that claimed non-object entries were safe.

@clawsweeper

clawsweeper Bot commented Jun 19, 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.

wings1029 and others added 6 commits June 29, 2026 11:18
…r registration

In capturePluginToolDescriptor, preserve tool-authored availability
expressions and log unsupported-signal diagnostics once per captured
descriptor.  This surfaces authoring errors (empty allOf/anyOf groups,
malformed expressions) at the descriptor-registration boundary instead
of silently hiding tools in the planner.

- Keeps evaluateToolAvailability and buildToolPlan pure
- Reads availability through a narrowed record (no AnyAgentTool type change)
- Only warns for unsupported-signal diagnostics (authoring errors),
  not runtime conditions like auth/config/env

Fixes openclaw#92361

Co-Authored-By: Claude <[email protected]>
…ator

- Validate allOf/anyOf are arrays before passing to evaluateToolAvailability
- Non-array group values now produce a console.warn diagnostic instead of
  crashing tool registration on .flatMap / .map
- Malformed availability is stripped from the descriptor to keep the
  evaluator pure
- Add regression tests for non-array allOf, non-array anyOf, and valid
  nested array entries

Fixes openclaw#92361

Co-Authored-By: Claude <[email protected]>
Make hasValidAvailabilityGroupShape recursive so nested non-array
allOf/anyOf groups (e.g. { allOf: [{ anyOf: "not-array" }] }) are
caught at the descriptor-capture boundary instead of reaching the
evaluator and throwing on .flatMap / .map.

Add regression test for nested malformed availability groups.

Co-Authored-By: Claude <[email protected]>
…lidation

Plugin-authored data is arbitrary JS — null, primitives, and arrays
inside allOf/anyOf groups would reach the "in" operator and throw
TypeError.  Skip non-object entries in the recursive shape check;
the evaluator will diagnose them as malformed expressions later.

Add regression test for mixed non-object entries in group arrays.

Co-Authored-By: Claude <[email protected]>
…shape guard

Plugin-authored availability data is untyped at the descriptor boundary.
Null entries and non-object primitives (string, number, boolean) inside
allOf/anyOf arrays passed the shape guard but crashed the evaluator on
"kind" in expr (TypeError).  Reject them so the whole expression is
stripped with a warning instead of crashing tool registration.

This fixes the P1 bug where a malformed descriptor with null entries
could crash plugin registration instead of just producing a warning.

Co-Authored-By: Claude <[email protected]>
@wings1029
wings1029 force-pushed the fix/92361-descriptor-registration-warning branch from f665cb4 to 3c9e9d7 Compare June 29, 2026 03:26
@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jul 1, 2026
@wings1029 wings1029 closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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