Skip to content

feat(wasm): typed tool response, guest migration, and dispatch-error cleanup - #7711

Merged
henrypark133 merged 44 commits into
mainfrom
fix/7627-dispatch-error-cleanup
Aug 21, 2026
Merged

henrypark133 merged 44 commits into
mainfrom
fix/7627-dispatch-error-cleanup

Conversation

@henrypark133

@henrypark133 henrypark133 commented Aug 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Final PR of the capability-response-normalization stack (#7627), on top of #7692. This supersedes #7703, which was closed and folded in here — it added a 0.3.0 compatibility shim that this work deletes, so keeping them separate would have shipped an add-then-remove churn that never protected a released component. Combined, the net diff simply has no shim.

Two things happen here, both internal:

1 — WASM tools speak a typed contract instead of stringly errors. The tool response was output: string? / error: string?, and all six bundled tools packed structured JSON inside the error string for the host to parse back out. It becomes near:agent@0.4.0:

variant response { success(string), failure(guest-failure) }
record guest-failure { kind: error-kind, code: option<string>,
                       message: option<string>, retry-after-ms: option<u64> }
enum error-kind { auth-required, input, output-too-large,
                  executor, network-denied, client, operation-failed }

All six guests (github, slack, google docs/drive/sheets/slides) migrated, committed binaries rebuilt from source, digests re-recorded through the canonical freshness script. Previously-unclassified plain-string error paths in the Google packages now carry closed error kinds with bounded messages. A wrong-shape component now fails instantiation loudly instead of decoding to something plausible.

2 — The failure taxonomy collapses. DispatchError::{Mcp, Script, Wasm, FirstParty} carried no distinct semantics — every consumer folded them into the same shape. Provider rejection is now uniformly DispatchError::Rejected with runtime as metadata; DispatchErrorLane and its classifier are deleted; ~90 construction/match sites updated; a new architecture test pins the retired names at zero. DispatchError::provider_rejected is the single construction site. The 0.3.0 fallback, its frozen WIT, and the legacy string decoder are removed.

Security-relevant items in here

  • Debug redaction: folding the variants together silently started printing untrusted failure detail through {:?}, which the retired FirstParty variant deliberately omitted. Redacted on both DispatchError and CapabilityInvocationError, pinned by leak tests.
  • Failure-label trust boundary: runtime_dispatch_error used model_visible_cause.or(safe_summary), so a vendor cause silently displaced the host-authored summary the chat failure card renders. Precedence is now explicit and tested — host summary, then validated provider text, then the kind's fixed sentence.
  • Scrub gap: LeakDetector's GitHub-token pattern required 36 trailing characters, letting shorter credential-shaped values through unredacted. Floor lowered to 16, with regression coverage; the guest-message bound also rose 256 → 2048 so real provider explanations survive to the model (verified against the 4096 downstream ceilings).

Deliberately not done

Deriving setup_needed from unresolved auth gates (the gate store has no extension/caller-scoped query, and chat's in-turn rendering vs Settings' projection are structurally different mechanisms — that's the connection-state work, #5416). Moving HTTP status decoding host-side so extensions stop hand-rolling it is the natural next PR, scoped separately rather than folded in here.

Test Strategy

  • Integration: reborn_integration_auth_gate 18/18, including the provider-context test driven end to end through rebuilt artifacts.
  • Crate: github_wasm_runtime_contract 67/67 against real committed binaries (the credential-leak test stayed unweakened and now covers the short-token/non-401 case); host_runtime_services_contract 119/119; host_runtime_contract 35/35; ironclaw_wasm, ironclaw_capabilities, ironclaw_host_api, ironclaw_extension_contracts, ironclaw_extension_host all green; ironclaw_architecture_tests green including the new retired-vocabulary pin. cargo check --workspace --tests clean — added to the gate after it caught a cross-crate exhaustiveness break the targeted gates missed.
  • E2E: Not applicable: the wire contract and vocabulary changes are fully exercised at the crate/integration tiers against real rebuilt artifacts; no user-visible surface changes.

Clippy -D warnings clean on all touched crates including the guest packages; fmt clean; check-wasm-artifact-freshness.py OK (6 packages). Known-unrelated: two trace_commons tests requiring live network egress, which fail on clean main.

Compatibility / rollback

No persisted schema change — DispatchError was never a durable wire format. All six committed artifacts move to 0.4.0 together and match their sources by digest. Revert restores the 0.3.0 world cleanly; #7686 and #7692 stand alone.

🤖 Generated with Claude Code

@github-actions github-actions Bot added size: XL 500+ changed lines risk: low Changes to docs, tests, or low-risk modules contributor: core 20+ merged PRs labels Aug 17, 2026

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review (multi-agent)

Intent: Retire the four lane-named DispatchError variants into uniform Rejected and delete the 0.3.0 legacy WASM fallback, preserving model-visible failure strings.

Stats: 5 findings (from 6 raw, 5 after dedup) across 5 files. Reviewers run: security, bugs, performance, tests, conventions, local-patterns, maintainability, approach. Reviewers failed: none. Body-only: 1

Bugs, performance, and approach returned zero findings; the bugs reviewer verified the fold preserves failure_kind()/event_kind() exactly, attempt: None is not dropped accounting (retired variants never carried it), and the legacy deletion has zero dangling references.

Security

  1. High Folding FirstParty into Rejected drops first-party detail redaction from Debug (ironclaw_host_api/src/dispatch.rs:632-645, confidence 70) (no diff position — body only) — the retired variant's Debug omitted detail; the Rejected arm prints it unredacted, and DispatchFailureDetail::Diagnostic{text} carries raw never-log content (bounded raw HTTP bodies). Mirror fix needed in CapabilityInvocationError::Dispatch's Debug.

Maintainability / Conventions

  1. Medium Six copies of the same Rejected/ProviderDiagnostic construction across four crates (confidence 75) — recreates one level down exactly the multi-site hand-sync DispatchErrorLane existed to prevent; add one constructor on DispatchError in the owning crate. Also flagged by: conventions/Medium.

Tests

  1. Medium safe_summary's code-less branch is exercised but never asserted (ironclaw_capabilities/src/error.rs:313, confidence 75) — the unprefixed-raw-message path backing the behavior-preservation claim has no assertion.

Conventions

  1. Low Ratchet comment says 112 → 111 but two entries were removed; baseline is 110 (confidence 70).

Local Patterns

  1. Low dispatch.rs splits ironclaw_host_api imports into two use blocks, unlike every sibling (confidence 60).

@railway-app

railway-app Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the ironclaw-pr-7711 environment in ironclaw-ci-preview

Service Status Web Updated (UTC)
ironclaw ✅ Success (View Logs) Web Aug 21, 2026 at 5:10 am

@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added structured, categorized error reporting across extensions and runtime integrations.
    • Updated WASM tools to return typed success or failure results with stable error codes and bounded messages.
    • Improved authentication, provider rejection, and network failure details.
  • Bug Fixes

    • Sensitive credentials, paths, and diagnostic content are more consistently redacted.
    • Unsupported WASM contract versions now fail clearly during startup.
    • Improved failure tracking and invocation state handling.
  • Documentation

    • Updated WASM contract and error-handling documentation for the latest behavior.

Walkthrough

This PR replaces legacy dispatch and tool failure variants with structured rejected errors, boxed authorization requirements, trusted host summaries, and redacted diagnostics. It upgrades the WASM tool ABI from 0.3.0 to 0.4.1 and migrates extension APIs to typed guest failures.

Changes

Typed failure and WASM ABI migration

Layer / File(s) Summary
Failure contracts and vocabulary cleanup
crates/contracts/..., crates/app/ironclaw_architecture_tests/..., crates/kernel/ironclaw_capabilities/src/error.rs
ToolError and DispatchError now use structured rejection data. Legacy variants and dispatch-lane classification are removed. Debug output redacts sensitive diagnostics.
Dispatch runtime mapping
crates/kernel/ironclaw_capabilities/..., crates/kernel/ironclaw_host_runtime/..., crates/extensions/ironclaw_extension_host/...
Runtime, extension, capability, and lifecycle paths use unified rejected errors. Resolver and registry paths preserve typed diagnostics and assign trusted runtime provenance.
WASM contract and runtime
crates/lanes/ironclaw_wasm/..., crates/kernel/ironclaw_host_runtime/src/services/wasm_execution.rs, crates/lanes/ironclaw_wasm/wit/tool.wit
The WIT contract advances to 0.4.1 with typed success/failure responses and HTTP failures. WASM execution consumes typed outcomes, classifies failures, scrubs diagnostics, and rejects unsupported contract versions.
Extension error adoption
crates/extensions/packages/*/wasm-src/..., crates/extensions/packages/telegram/...
GitHub, Google, Slack, and Telegram paths now use structured failures or rejected tool errors with stable kinds, codes, bounded messages, and provider diagnostics.
Validation and migration support
crates/lanes/ironclaw_wasm/tests/..., crates/kernel/ironclaw_host_runtime/tests/..., docs/..., scripts/ci/wasm-src-digests.toml
Fixtures, contract tests, documentation, architecture checks, leak detection, and WASM source digests are updated for the new contracts.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟡 Moderate · up to 61984

This PR changes how bundled tool failures are typed and surfaced. At the current head, untrusted provider text can still become the highest-precedence user-visible summary, and some rejection paths may lose retry metadata; related test and reproducibility issues further reduce confidence in the migration. These are bounded but concrete merge-readiness risks requiring fixes or explicit owner acceptance.

Suggested reviewers: benkurrek

Sequence Diagram(s)

sequenceDiagram
  participant ExtensionGuest
  participant WasmRuntime
  participant DispatchError
  participant CapabilityResolver
  participant InvocationStore
  ExtensionGuest->>WasmRuntime: Return WitToolOutcome::Success or Failure
  WasmRuntime->>DispatchError: Classify typed guest failure
  DispatchError->>CapabilityResolver: Return Rejected or AuthRequired
  CapabilityResolver->>InvocationStore: Persist terminal failure state
  InvocationStore-->>CapabilityResolver: Return persisted invocation status
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes and testing, but it omits required template sections such as Change Type, Linked Issue, Security Impact, and Blast Radius. Add all required template sections, including Change Type, Linked Issue, Validation, Security Impact, trust-boundary checklist, Database Impact, Blast Radius, Rollback Plan, and Review Follow-Through.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits style and accurately summarizes the typed WASM response and dispatch-error changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ironloopai

ironloopai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🧭 IronLoop Run · Review

This comment updates in place as the Run moves through its stages.

🟥 Final result · Could not complete

🟨 Queued → 🟦 Working → 🟥 Could not complete

Automatic trigger · failed after 2s

IronLoop could not read the required GitHub data for this Run.

Failure details

  • Failure ID: 52194743-eb03-41b2-9ba5-9d433cd6b8e6
Run details

Run: 6be88dc8-5f41-4214-9616-33bbb03d04d3
Base: fix/7627-wasm-typed-response at c124793
Head: fix/7627-dispatch-error-cleanup at 299c772
Created: 2026-08-17 15:31 UTC
Updated: 2026-08-17 15:31 UTC

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 299c7721fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@henrypark133

Copy link
Copy Markdown
Collaborator Author

All 5 review findings addressed in b710b27: the Rejected/Dispatch Debug arms now redact detail like diagnostic, pinned by two leak tests; DispatchError::provider_rejected centralizes the six duplicate constructions into the owning crate; the code-less safe_summary branch is asserted; ratchet comment and import split corrected. Full gate green (workspace check, auth-gate 18/18, wasm contract 66/66, architecture suite, clippy -D warnings).

@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 17, 2026 16:04 Destroyed

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review (multi-agent)

Intent: Retire lane-named DispatchError variants in favor of a uniform Rejected variant and remove the legacy WASM 0.3.0 tool-response fallback, as final cleanup of the capability-response-normalization plan.

Stats: 4 findings (from 5 raw, 4 after dedup) across 4 files. Reviewers run: security, bugs, performance, tests, conventions, local-patterns, maintainability, approach. Reviewers failed: none. Body-only: 1

Bugs

  1. High FirstParty-lane dispatch error fold silently drops safe_summary when a vendor cause is also present (crates/kernel/ironclaw_capabilities/src/registry.rs:207-215, confidence 85) — anchor: crates/kernel/ironclaw_capabilities/src/registry.rs:213-214
    Pre-PR, runtime_dispatch_error's DispatchErrorLane::FirstParty arm carried safe_summary (fixed, host-authored, never vendor payload) and model_visible_cause (untrusted vendor text) on two distinct channels. The fold collapses both into let cause = model_visible_cause.or(safe_summary) fed to DispatchError::provider_rejected, so whenever a caller supplies both fields, model_visible_cause wins outright and safe_summary is discarded -- there is no channel left carrying it. Reachable in production: Telegram's manifest declares runtime.kind = "first_party", and mapping::failed_because (crates/extensions/packages/telegram/src/linked/mapping.rs:85-91, also runtime.rs:657-676 for FLOOD_WAIT) deliberately sets both fields -- safe_summary as a fixed canonical string, model_visible_cause as vendor-derived retry-after prose. The doc comment there states the split is load-bearing: safe_summary must never interpolate vendor text. After this fold, the canonical safe_summary is silently replaced by raw vendor cause whenever both are supplied, breaking the PR's own stated constraint that model-visible failure strings are unchanged. The same pattern exists in crates/extensions/ironclaw_extension_host/src/resolver.rs's dispatch_error_for_kind (lines 171-183).

Tests

  1. Low classify_instantiation_error's non-version passthrough branch lost its direct unit test (crates/lanes/ironclaw_wasm/src/runtime.rs:302-310, confidence 55) (candidate — validate claim) — anchor: crates/lanes/ironclaw_wasm/src/runtime.rs:302
    This PR deletes legacy_retry_gate_tests, which directly unit-tested classify_instantiation_error for a non-version-mismatch message. classify_instantiation_error remains with the same two-branch shape (wrap-with-contract-hint vs pass-through). Remaining coverage exercises the wrap branch and asserts only the error variant for the passthrough case, not that the message text is left unmodified. A regression that always appended the unsupported-contract suffix would not be caught.

Maintainability

  1. Medium Hand-rolled 15-variant Debug impl duplicates the enum just to redact 2 fields (crates/kernel/ironclaw_capabilities/src/error.rs:131-256, confidence 75) — anchor: crates/kernel/ironclaw_capabilities/src/error.rs:131
    This PR drops #[derive(Debug, Error)] from CapabilityInvocationError and replaces it with a 126-line manual fmt::Debug that re-lists every field of all 15 variants, even though only two variants carry anything sensitive. Every future variant needs a matching arm added here too, with nothing enforcing it. The same leak is prevented elsewhere by making the field's type self-redact instead: ProviderDiagnostic (crates/contracts/ironclaw_host_api/src/dispatch.rs:79-82) implements Debug once, on itself, so any struct embedding it stays safe automatically.

Local Patterns

  1. Medium Slack WASM doc comment cites StructuredWasmGuestErrorKind, deleted by this PR (crates/extensions/packages/slack/wasm-src/src/api.rs:105-108, confidence 70) (candidate — validate claim) (no diff position — body only) — anchor: crates/extensions/packages/slack/wasm-src/src/api.rs:107
    This doc comment tells callers the finite kind vocabulary it maps to comes from StructuredWasmGuestErrorKind at crates/kernel/ironclaw_host_runtime/src/services/wasm_execution.rs:333-343. This PR's second commit (chore(wasm): remove the 0.3.0 legacy tool-response fallback) deletes that exact type. The comment now points a future reader at a nonexistent type and stale line numbers; the real finite kind vocabulary the host now parses is WitErrorKind via the typed WitGuestFailure path. Not caught by the new reborn_retired_dispatch_error_lanes architecture gate because this file is a WASM guest crate outside the gate's scan roots.
    Also flagged by: conventions/Low

@henrypark133
henrypark133 force-pushed the fix/7627-wasm-typed-response branch from c124793 to 6f873ef Compare August 17, 2026 20:45
@henrypark133
henrypark133 force-pushed the fix/7627-dispatch-error-cleanup branch from b710b27 to dc30e22 Compare August 17, 2026 20:45
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 17, 2026 20:45 Destroyed
@henrypark133
henrypark133 changed the base branch from fix/7627-wasm-typed-response to fix/7627-provider-response-normalization August 17, 2026 20:45
@github-actions github-actions Bot added the scope: docs Documentation label Aug 17, 2026
@henrypark133 henrypark133 changed the title refactor(contracts): retire lane-named dispatch errors and the legacy WASM fallback feat(wasm): typed tool response, guest migration, and dispatch-error cleanup Aug 17, 2026
@henrypark133

Copy link
Copy Markdown
Collaborator Author

Approach / soundness review

I reviewed the full three-PR narrative and the live stack as an end-to-end capability-failure normalization, rather than as a fix for the credential-state symptom in #7627.

Verdict: keep the overall architecture, but pivot one contract boundary before calling the cleanup converged.

The sequence itself is sound:

  1. one response processor for fresh, approval-resume, and auth-resume execution;
  2. typed, bounded ProviderDiagnostic data instead of string-sniffing;
  3. typed WIT producer failures feeding a lane-neutral DispatchError taxonomy.

I do not see a cleaner alternative based on lane-local normalization or one universal error DTO. Lane-local normalization would recreate the divergence this stack removes. A universal DTO would incorrectly collapse authorization/authentication/approval control flow into execution failure handling. Those stages need to remain distinct.

The remaining design fork is one level above DispatchError: ToolError now has both Failed and Rejected. They carry the same eventual semantics in different shapes, and both are converted into DispatchError::Rejected through near-duplicate helpers in the capability registry and extension resolver. The reverse lane-adapter mapping also downgrades every non-auth/non-rejected dispatch error to Client, losing its original failure kind.

I recommend finishing the normalization with one shared neutral execution-failure payload, owned by ironclaw_host_api, containing:

  • stable DispatchFailureKind;
  • typed untrusted provider diagnostic;
  • a distinct host-authored public summary;
  • structured failure detail.

Then carry that same payload through the pipeline:

ToolError::Failure(payload)
  -> DispatchError::Rejected { runtime, failure: payload }
  -> CapabilityInvocationError::Dispatch(payload)
  -> one host-runtime projection
       public summary = host summary or fixed kind sentence
       model diagnostic = scrubbed/fenced provider diagnostic
       durable category = stable failure kind

AuthRequired should remain separate because it carries gate obligations and resumes through a different state transition. Runtime should be stamped by the trusted binding/dispatcher rather than supplied by a tool adapter.

This shape would delete, rather than propagate:

  • the ToolError::Failed / ToolError::Rejected parallel representations;
  • runtime_dispatch_error and dispatch_error_for_kind conversion helpers;
  • raw model_visible_cause strings at the tool boundary;
  • repeated five-field reconstruction across contracts;
  • early construction of a public safe_summary, which is what made the provider-prose leak possible.

For the public label, the dedicated channel is necessary: the existing SafeSummary validator only proves content shape, not host provenance. However, the host-summary value should preferably reuse SafeSummary validation (or a small host-authored wrapper around it) instead of remaining Option<Box<String>> until the final loop validation.

One additional constraint for the pending redaction follow-up: keep selective Debug redaction, but do not remove nested error causes from unrelated CapabilityInvocationError Display/source chains. Sanitization belongs at the public/model boundary; the server-side cause must remain available.

So this is not a request to redo the WIT migration or response processor. It is a request to carry the newly typed failure as one value through the canonical pipeline, instead of maintaining two tool-error shapes and repeatedly unpacking/repacking their fields.

henrypark133 added a commit that referenced this pull request Aug 18, 2026
- preserve host summaries separately from vendor diagnostics
- stamp runtime provenance from trusted bindings
- retain routing failure kinds across the tool ABI
- correct the centralized processor caller count
henrypark133 added a commit that referenced this pull request Aug 18, 2026
- document near:agent@0.4.0 as the sole supported tool ABI
- remove references to the deleted 0.3.0 fallback and WIT file
- align the living WASM contract with runtime behavior
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 18, 2026 23:10 Destroyed
henrypark133 added a commit that referenced this pull request Aug 18, 2026
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 18, 2026 23:14 Destroyed
@henrypark133

henrypark133 commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

PR shepherd status — restacked on current main

Stack replayed bottom-up onto main@28315166 with exact force-with-lease guards:

Convergence fixes retained:

  • branch-local and merged-stack architecture ceilings were re-measured independently;
  • stale migrated RuntimeCapabilityOutcome::Unknown coverage was removed from refactor(runtime): centralize capability outcome processing #7686;
  • current-main invocation-state coverage uses the converged DispatchError::Rejected taxonomy;
  • the Slack guest-source guidance changed only with its rebuilt checked-in WASM and refreshed digest;
  • the recorded-QA fired-routine assertion now waits, within its existing deadline, for accepted work to persist its finalized assistant reply. Production trigger semantics and the recorded fixture are unchanged.

Verification:

Review state:

No PR was merged.

henrypark133 added a commit that referenced this pull request Aug 19, 2026
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 19, 2026 01:50 Destroyed
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 19, 2026 01:51 Destroyed
@henrypark133
henrypark133 force-pushed the fix/7627-provider-response-normalization branch from d387cbb to eec906a Compare August 19, 2026 03:50
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 20, 2026 19:53 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added risk: low Changes to docs, tests, or low-risk modules and removed risk: medium Business logic, config, or moderate-risk modules labels Aug 20, 2026
@henrypark133

Copy link
Copy Markdown
Collaborator Author
Axis Score (0-100) Verdict
System Placement 40/100 Contracts remain in their owning crates, but an extension package constructs a host-authored trust value.
System Trajectory 95/100 The canonical guest → WASM → host-runtime → dispatcher path is preserved and carried through all six guests.
Structural Discipline 40/100 The retired taxonomy is removed, but the new WASM rejection builder duplicates the existing runtime-lane builder.
Execution Integrity 40/100 Real component-boundary coverage is present, but useful debug-detail assertions were deleted and the delivered version contradicts the claim ledger.
Composite 50/100 review effort 5/5

Higher is better. 85+ clean · ~60 one loose end · ≤40 a critical defect caps the axis.

Recommendation: wrong approach — reimplement as a host-owned failure trust boundary that keeps package outputs untrusted, stamps HostSummary in the generic extension host or host runtime, and routes WASM through the existing dispatch_error_for_runtime path.

Validated strengths

  • Placement: The normalized dispatch vocabulary, canonical dispatcher, and WASM execution mechanics remain in their owning layers. Evidence: ironclaw_host_api, ironclaw_capabilities, and ironclaw_wasm continue to own those boundaries.

  • Trajectory: The ABI migration is carried through guest sources, host mapping, committed artifacts, documentation, and freshness validation. Evidence: the six affected guests use one WIT version and check-wasm-artifact-freshness.py reports six packages checked.

  • Structural: Runtime failures are consolidated into the existing DispatchError::Rejected shape. Evidence: the retired Mcp, Script, Wasm, and FirstParty variants are removed while Rejected remains the shared payload.

  • Structural: The WASM ABI replaces stringly response errors with typed failure variants. Evidence: tool.wit, generated host decoding, and guest sources use matching response, error-kind, and guest-failure shapes.

  • Execution: Typed failure behavior is tested across the real component boundary. Evidence: wit_tool_runtime_contract.rs:408-447 executes components and checks all seven failure discriminants, codes, and messages.

  • Execution: Committed WASM artifacts are freshness-checked against their source trees. Evidence: wasm artifact freshness: OK (6 package(s) checked).

  • Execution: Short GitHub-token redaction is covered while preserving HTTP status context. Evidence: leak_detector.rs:647-649,1404-1432 lowers the floor to 16 characters and verifies token removal with HTTP 403 retained.

Findings

Critical — System Placement SP4

An extension package constructs DispatchFailureDetail::HostSummary, and the generic extension host forwards it without host stamping. The package-to-host boundary must keep package outputs untrusted; HostSummary is later given precedence in CapabilityInvocationError mapping.

Evidence: crates/extensions/packages/telegram/src/linked/mapping.rs:74-115 constructs the value; crates/extensions/ironclaw_extension_host/src/resolver.rs:144-156 forwards it; crates/kernel/ironclaw_capabilities/src/error.rs:328-344 prioritizes it. The host-owned stamping pattern already exists in crates/kernel/ironclaw_host_runtime/src/services/runtime_adapters.rs:47-80.

Critical — Structural Discipline SD3

The new WASM-specific rejection builder duplicates the canonical runtime-lane rejection builder.

Evidence: crates/kernel/ironclaw_host_runtime/src/services/wasm_execution.rs:40-46 and runtime_adapters.rs:1242-1256 both call DispatchError::provider_rejected with runtime, kind, cause, and no detail; the new helper only fixes the runtime to WASM.

Critical — Execution Integrity EI5

The change deletes assertions that preserved useful non-secret InvalidInput debug detail while broadening Rejected debug redaction, without replacement coverage.

Evidence: the deleted hunk in crates/contracts/ironclaw_host_api/tests/host_api_contract.rs:1937 removed assertions for /title and string; crates/contracts/ironclaw_host_api/src/dispatch.rs:685-691 now redacts every Rejected.detail.

Normal — Execution Integrity EI1

The delivered artifact migration uses version 0.4.1 rather than the claim ledger’s 0.4.0.

Evidence: tool.wit, ironclaw_wasm/src/config.rs, all six guest sources, and all six committed artifacts consistently report near:agent@0.4.1; freshness still passes.

flowchart LR
  subgraph Built["As built"]
    P["Telegram package"] -->|"constructs HostSummary"| R["Extension resolver"]
    R -->|"forwards unchanged"| M["Capability error mapping"]
    M -->|"summary wins"| U["User/model-visible label"]
  end
  subgraph Expected["Canonical boundary"]
    P2["Extension package"] -->|"untrusted provider output"| H["Generic extension host / host runtime"]
    H -->|"validate and stamp host summary"| M2["Capability error mapping"]
    M2 --> U2["User/model-visible label"]
  end
Loading

Sketch, not a patch:

extension package
  -> untrusted failure payload
generic extension host / host runtime
  -> host-owned validation and HostSummary stamping
existing dispatch_error_for_runtime
  -> DispatchError::Rejected
capability error projection
  -> host summary, then validated provider diagnostic, then fixed-kind fallback

Claim verdicts

  • C1 fulfilled: tool.wit defines typed success/failure responses, all six guests return them, and runtime.rs decodes them directly.
  • C2 fulfilled: instantiation errors propagate, and the WASM integration test rejects unsupported components before preparation.
  • C3 fulfilled: the retired failure-vocabulary architecture test finds no live production references and consumers use Rejected.
  • C4 fulfilled: DispatchError and CapabilityInvocationError redact diagnostic detail, with leak tests asserting sensitive values are absent.
  • C5 fulfilled: CapabilityInvocationError applies host-summary, provider-diagnostic, then fixed-kind fallback precedence with dedicated tests.
  • C6 fulfilled: LeakDetector lowers the GitHub-token floor to 16 and WASM provider messages are bounded to 2048 bytes with regression coverage.
  • C7 fulfilled: the diff adds no setup-state derivation or gate-store production path.
  • C8 partial: all six sources and artifacts are fresh, but the delivered contract version is 0.4.1 rather than the claimed 0.4.0.
  • C9 fulfilled: DispatchError has no durable serialization or migration change and the diff adds no persistence schema.
  • C10 fulfilled: product, UI, and transport contracts are unchanged; failures are normalized through the existing typed dispatch surfaces.

Copilot AI review requested due to automatic review settings August 20, 2026 23:57
@railway-app
railway-app Bot temporarily deployed to ironclaw-ci-preview / ironclaw-pr-7711 August 20, 2026 23:57 Destroyed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@henrypark133 henrypark133 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review (multi-agent)

Intent: Normalize WASM tool responses into a typed 0.4.0 contract, consolidate dispatch failures, remove the legacy 0.3.0 shim, and close related redaction gaps.

Stats: 5 findings (from 5 raw, 5 after filter, 5 after dedup) across 4 files. Reviewers run: correctness, security, performance, design, coverage. Reviewers failed: none. Body-only: 0

coverage

  1. Medium Google WASM failure paths lack real-artifact coverage (crates/lanes/ironclaw_wasm/src/runtime.rs:147-152, confidence 82) — anchor: crates/lanes/ironclaw_wasm/src/runtime.rs:147
    The typed failure decoding path is exercised with synthetic WAT and real GitHub/Slack artifacts, but the independently migrated Google Docs, Sheets, and Slides guests are only covered through successful host-runtime calls. A package-specific error-construction or WIT binding regression could therefore pass all current tests while returning the wrong error kind, code, or message.
    Fix: Add tests::host_runtime_services_maps_google_docs_sheets_and_slides_wasm_401_to_auth_required covering each committed artifact through invoke_capability and asserting the typed failure reaches the auth gate.

design

  1. Medium Published ABI does not match the declared 0.4.0 contract (crates/lanes/ironclaw_wasm/wit/tool.wit:1-1, confidence 100) — anchor: crates/lanes/ironclaw_wasm/wit/tool.wit:1
    The implementation publishes near:agent@0.4.1, while the PR contract and intent state 0.4.0 and include a different guest-failure shape with retry-after-ms. A guest built against the stated 0.4.0 contract will fail instantiation, and the compatibility/rollback story is inaccurate.
    Fix: Choose one ABI version and schema, then align the WIT, version constant, artifacts, documentation, tests, and PR compatibility statement.

mechanical

  1. High Production unwrap/expect introduced (crates/substrates/ironclaw_safety/src/leak_detector.rs:649-649, confidence 90) — anchor: regex: Regex::new(r"gh[pousr][A-Za-z0-9]{16,}").unwrap(), // safety: hardcoded literal
    Added production Rust line calls unwrap/expect: regex: Regex::new(r"gh[pousr][A-Za-z0-9]{16,}").unwrap(), // safety: hardcoded literal
    Fix: Propagate the error with context instead of panicking.

performance

  1. Medium Bound guest failure text before returning it to the host (crates/lanes/ironclaw_wasm/src/runtime.rs:38-40, confidence 91) — anchor: crates/lanes/ironclaw_wasm/src/runtime.rs:38
    The previous runtime bounded guest-authored error strings to 4096 bytes, but this change only redacts them. A component can now return code or message up to its execution memory limit; the full value is scanned, retained in WitToolExecution, and only bounded later in host-runtime dispatch. Concurrent failing executions can therefore amplify transient allocations and diagnostic scanning substantially.
    Fix: UTF-8-safely truncate each scrubbed guest failure field at the WASM boundary before constructing WitToolExecution.

security

  1. Medium Redact raw input from unified rejection debug output (crates/extensions/ironclaw_extension_host/src/resolver.rs:146-160, confidence 82) — anchor: crates/contracts/ironclaw_host_api/src/dispatch.rs:694
    The new unified ToolError::Rejected path forwards DispatchFailureDetail::InvalidInput into DispatchError::Rejected. Its Debug implementation prints the entire issue list, including DispatchInputIssue.received, which may contain attacker-controlled tool input or secrets. The retired lane-specific error variants omitted these details from debug output, so this consolidation can leak raw input whenever the error is logged with {:?}.
    Fix: Implement a redacted Debug view for InvalidInput that omits received (and any other raw input fields), or omit the detail from DispatchError debug output entirely.

}

/// Coarse host-owned categories. Provider-specific detail belongs in
/// `code`, so adding an extension does not widen this enum.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium — Published ABI does not match the declared 0.4.0 contract.

The implementation publishes near:agent@0.4.1, while the PR contract and intent state 0.4.0 and include a different guest-failure shape with retry-after-ms. A guest built against the stated 0.4.0 contract will fail instantiation, and the compatibility/rollback story is inaccurate.

Fix: Choose one ABI version and schema, then align the WIT, version constant, artifacts, documentation, tests, and PR compatibility statement.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation, WIT files, generated bindings, fixtures, and compatibility docs are consistently on near:agent@0.4.1. The PR description still has two stale 0.4.0 references; this shepherd run is not authorized to edit the PR body, so I am leaving this thread open for that author-side wording update.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/kernel/ironclaw_capabilities/src/error.rs (1)

312-366: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a test for HostSummary with a populated nested detail.

Tier-1 tests (rejected_host_summary_wins_over_vendor_diagnostic) only cover HostSummary { detail: None }. No test drives HostSummary { summary, detail: Some(Box::new(DispatchFailureDetail::InvalidInput { .. })) } through this From<DispatchError> impl to confirm the Box unwraps correctly into CapabilityInvocationError::Dispatch.detail. This is new logic in this PR, not a pre-existing gap.

As per coding guidelines: "For new or changed production-wired behavior, add a caller-level test at the nearest meaningful seam; completed-status-only tests are insufficient."

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@crates/kernel/ironclaw_capabilities/src/error.rs` around lines 312 - 366, The
From<DispatchError> conversion for HostSummary must be covered when detail is
Some(Box::new(DispatchFailureDetail::InvalidInput { .. })). Extend or add a
caller-level test near rejected_host_summary_wins_over_vendor_diagnostic to
verify the host summary still wins and the boxed nested detail is unwrapped into
CapabilityInvocationError::Dispatch.detail.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Outside diff comments:
In `@crates/kernel/ironclaw_capabilities/src/error.rs`:
- Around line 312-366: The From<DispatchError> conversion for HostSummary must
be covered when detail is Some(Box::new(DispatchFailureDetail::InvalidInput { ..
})). Extend or add a caller-level test near
rejected_host_summary_wins_over_vendor_diagnostic to verify the host summary
still wins and the boxed nested detail is unwrapped into
CapabilityInvocationError::Dispatch.detail.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a51494d-64aa-489c-8eb8-22f1ca421d53

📥 Commits

Reviewing files that changed from the base of the PR and between a6e4838 and 9fb70f3.

⛔ Files ignored due to path filters (6)
  • crates/extensions/packages/github/wasm/github_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
  • crates/extensions/packages/google-docs/wasm/google_docs_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
  • crates/extensions/packages/google-drive/wasm/google_drive_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
  • crates/extensions/packages/google-sheets/wasm/google_sheets_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
  • crates/extensions/packages/google-slides/wasm/google_slides_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
  • crates/extensions/packages/slack/wasm/slack_user_tool.wasm is excluded by !**/*.wasm, !**/*.wasm
📒 Files selected for processing (35)
  • crates/contracts/ironclaw_extension_contracts/src/tool_adapter.rs
  • crates/contracts/ironclaw_host_api/src/dispatch.rs
  • crates/contracts/ironclaw_host_api/src/messaging.rs
  • crates/extensions/ironclaw_extension_host/src/generic_host.rs
  • crates/extensions/ironclaw_extension_host/src/resolver.rs
  • crates/extensions/packages/github/wasm-src/src/request.rs
  • crates/extensions/packages/google-docs/wasm-src/src/api.rs
  • crates/extensions/packages/google-drive/wasm-src/src/api.rs
  • crates/extensions/packages/google-sheets/wasm-src/src/api.rs
  • crates/extensions/packages/google-slides/wasm-src/src/api.rs
  • crates/extensions/packages/slack/wasm-src/src/api.rs
  • crates/extensions/packages/telegram/src/linked/conformance.rs
  • crates/extensions/packages/telegram/src/linked/mapping.rs
  • crates/extensions/packages/telegram/src/linked/mapping/tests.rs
  • crates/extensions/packages/telegram/src/linked/ops/mod.rs
  • crates/extensions/packages/telegram/src/linked/ops/tests.rs
  • crates/extensions/packages/telegram/src/linked/tools.rs
  • crates/kernel/ironclaw_capabilities/src/error.rs
  • crates/kernel/ironclaw_host_runtime/src/production.rs
  • crates/kernel/ironclaw_host_runtime/src/services/runtime_adapters.rs
  • crates/kernel/ironclaw_host_runtime/src/services/tests/mcp_runtime_adapter.rs
  • crates/kernel/ironclaw_host_runtime/src/services/wasm_diagnostics.rs
  • crates/kernel/ironclaw_host_runtime/src/services/wasm_execution.rs
  • crates/kernel/ironclaw_host_runtime/tests/extension_v2_lifecycle_e2e.rs
  • crates/kernel/ironclaw_host_runtime/tests/github_wasm_runtime_contract.rs
  • crates/lanes/ironclaw_wasm/README.md
  • crates/lanes/ironclaw_wasm/src/error.rs
  • crates/lanes/ironclaw_wasm/src/host.rs
  • crates/lanes/ironclaw_wasm/src/runtime.rs
  • crates/lanes/ironclaw_wasm/src/store.rs
  • crates/lanes/ironclaw_wasm/tests/wasm_dispatch_integration.rs
  • crates/lanes/ironclaw_wasm/tests/wasm_http_adapter_contract.rs
  • docs/internal/reborn/contracts/wasm.md
  • docs/internal/superpowers/specs/2026-07-27-standardized-messaging-framework-design.md
  • scripts/ci/wasm-src-digests.toml
💤 Files with no reviewable changes (4)
  • crates/extensions/packages/google-sheets/wasm-src/src/api.rs
  • crates/extensions/packages/google-docs/wasm-src/src/api.rs
  • crates/extensions/packages/google-drive/wasm-src/src/api.rs
  • crates/extensions/packages/google-slides/wasm-src/src/api.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@henrypark133

Copy link
Copy Markdown
Collaborator Author
Axis Score (0-100) Verdict
System Placement 40/100 The extension boundary forwards an untrusted control-plane failure classification into neutral dispatch.
System Trajectory 95/100 The typed ABI and normalized rejection path follow the existing cross-layer trajectory without adding hops or orchestration special cases.
Structural Discipline 40/100 The change consolidates the main taxonomy but leaves a critical near-duplicate guest normalization shape across four packages.
Execution Integrity 95/100 The replacement is complete, failures remain explicit, and caller-level tests cover the changed seams.
Composite 50/100 review effort 5/5

Higher is better. 85+ clean · ~60 one loose end · ≤40 a critical defect caps the axis.

Recommendation: wrong approach — reimplement as an extension-host resolver that normalizes untrusted tool failures into host-owned runtime categories, with guest error normalization moved to one reachable shared WASM support seam.

Validated strengths

  • The typed response ABI is placed in ironclaw_wasm, decoded once at the host-runtime execution boundary, and exercised through the real generated WIT/component contract. Evidence: crates/lanes/ironclaw_wasm/wit/tool.wit:138-182, crates/lanes/ironclaw_wasm/src/runtime.rs:133-148, crates/lanes/ironclaw_wasm/tests/wit_tool_runtime_contract.rs:403-445.
  • Lane-named dispatch variants are retired in favor of one DispatchError::Rejected shape with runtime metadata, and construction is centralized through provider_rejected. Evidence: crates/contracts/ironclaw_host_api/src/dispatch.rs:556-608, crates/kernel/ironclaw_host_runtime/src/services/runtime_adapters.rs, crates/extensions/ironclaw_extension_host/src/resolver.rs.
  • The six committed guest artifacts, source digests, and typed contract agree; the canonical freshness check covers all six packages. Evidence: scripts/ci/wasm-src-digests.toml:6-19 and check-wasm-artifact-freshness.py reported six packages OK.
  • Fresh, approval-resume, and auth-resume dispatch failures share one response processor while preserving durable terminalization obligations, with public host-runtime regression coverage. Evidence: crates/kernel/ironclaw_host_runtime/src/capability_response_processor.rs:115-137, crates/kernel/ironclaw_host_runtime/tests/host_runtime_contract.rs:567-571, 1061-1232.

Findings

CRITICAL — placement SP4

An extension-facing rejected error can carry a control-plane DispatchFailureKind, and the active resolver forwards that untrusted classification into the neutral dispatch result without normalization.

Evidence: crates/contracts/ironclaw_extension_contracts/src/tool_adapter.rs:80-88 accepts UnknownCapability, UnknownProvider, RuntimeMismatch, MissingRuntimeBackend, UnsupportedRuntime, and AuthRequired; crates/extensions/ironclaw_extension_host/src/resolver.rs:146-160 copies kind unchanged while only replacing runtime provenance; DispatchError::failure_kind in crates/contracts/ironclaw_host_api/src/dispatch.rs:715-727 treats it as authoritative. The host contract assigns these control-plane categories to dispatch/routing rather than extension/provider runtime failures.

flowchart LR
  A[Untrusted extension ToolError::Rejected
kind: control-plane or runtime] --> B[SnapshotToolResolver
copies kind, replaces runtime]
  B --> C[Neutral DispatchError
failure_kind trusts copied kind]
  C --> D[Routing / gate / model behavior]

  E[Untrusted extension failure] --> F[Extension-host resolver boundary
validate provider/runtime shape]
  F --> G[Host-owned DispatchFailureKind
control-plane categories minted by host]
  G --> D
Loading

CRITICAL — structural SD3

The PR duplicates the same guest error-normalization helpers across four Google WASM packages and alongside the existing GitHub bounded-message helper instead of extending one shared helper seam.

Evidence: crates/extensions/packages/google-docs/wasm-src/src/api.rs:17-49, google-drive/wasm-src/src/api.rs:26-57, google-sheets/wasm-src/src/api.rs:17-49, and google-slides/wasm-src/src/api.rs:17-49 repeat bounded_message, transport_failure, and serialization_failure; crates/extensions/packages/github/wasm-src/src/request.rs:79-95 already contains the same bounded-message behavior. The package workspaces explain why the seam is not currently reachable, but the added ponytail comments record the ceiling rather than removing the near-duplicate.

Sketch of the right shape

Keep the resolver as the sole extension-to-neutral-dispatch boundary. Let extension-facing errors carry provider/runtime diagnostics only; have the resolver validate and mint host-owned control-plane categories. Put the repeated guest message/error constructors in one reachable WASM support crate or shared package seam, then make all six guests delegate to it.

Claim verdicts

  • C1 fulfilled — tool.wit defines typed success/failure cases and all six guests plus host runtime decode them.
  • C2 fulfilled — all six source/binary pairs and digest entries agree; freshness reports six packages OK.
  • C3 fulfilled — lane-named dispatch variants and the legacy stringly path are removed.
  • C4 fulfilled — provider failures converge on DispatchError::Rejected with runtime metadata.
  • C5 fulfilled — diagnostics/detail text is redacted and leak tests preserve safe fields.
  • C6 partial — summary/detail precedence is explicit and tested, but the resolver still trusts extension-supplied DispatchFailureKind.
  • C7 fulfilled — fresh, approval-resume, and auth-resume dispatch failures terminalize durable invocation state.
  • C8 fulfilled — no persistence schema change; co-versioned ABI/artifact changes can be reverted together.
  • C9 fulfilled — WIT, WASM integration, and public host-runtime seams cover the changed wire and vocabulary behavior; no product browser surface changed.

No validated rule-revisit notes. No N/A axes; system surface is sufficient.

Bound and redact untrusted diagnostic payloads at their trust boundaries.

Narrow extension tool failures to runtime kinds and add regression coverage.

Preserve nested failure detail and typed retry metadata.
Emit the closed provider diagnostic code instead of an extension-minted host summary so the hardened resolver can map the canonical messaging failure.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@henrypark133

henrypark133 commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

PR shepherd status for 6b0e45e0c:

  • Fixed and resolved: ToolError ratchet scoping, with malformed-source sabotage coverage.
  • Fixed and resolved: Google Docs/Sheets/Slides auth-required assertions now pin requester extension and provider scopes.
  • Local verification: focused host-runtime contract test passed; full ironclaw_architecture_tests passed; formatting and diff checks passed.
  • CI: running on the new head.
  • Remaining manual metadata item: update the PR description’s two stale 0.4.0 references to 0.4.1 (the implementation and repository artifacts are already consistently 0.4.1).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
crates/kernel/ironclaw_capabilities/src/registry.rs (1)

178-190: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not accept host-authored detail from an extension adapter.

Lines 178-190 forward HostSummary and HostRemediation from ToolError unchanged. CapabilityInvocationError::from(DispatchError) gives HostSummary highest precedence. An extension can therefore supply a validated but false host-owned public label.

Strip these variants at this boundary. Keep provider diagnostics and permitted structured detail. Update lines 473-533 to assert that adapter-provided host detail is discarded. The resolver already applies this boundary rule.

As per coding guidelines, “Treat every listener, route, product adapter, runtime lane, container, and external service as untrusted until a typed boundary establishes otherwise.”

Also applies to: 473-533

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@crates/kernel/ironclaw_capabilities/src/registry.rs` around lines 178 - 190,
Update the ToolError::Rejected to DispatchError::Rejected conversion so
extension-supplied host-owned detail fields are discarded rather than forwarded.
Preserve runtime provenance, rejection kind, provider diagnostics, and permitted
structured detail. Extend the existing
CapabilityInvocationError::from(DispatchError) assertions around the adapter
boundary to verify HostSummary and HostRemediation supplied by adapters are
absent, while the resolver’s boundary behavior remains unchanged.

Source: Coding guidelines

tests/integration/support/harness/profiles/extension.rs (1)

1415-1422: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not create HostSummary from arbitrary error text.

acme_tool_error receives external egress errors at Line 1384 and vendor-derived fields at Line 1589. SafeSummary::new validates text shape, but it does not establish trusted provenance. This sends untrusted text through the higher-precedence host-summary channel.

Use DispatchFailureDetail::Diagnostic for dynamic causes. Construct HostSummary only from fixed host-authored text.

Proposed fix
-fn acme_tool_error(kind: RuntimeDispatchErrorKind, host_summary: String) -> ToolError {
+fn acme_tool_error(kind: RuntimeDispatchErrorKind, cause: String) -> ToolError {
     ToolError::Rejected {
         kind,
         diagnostic: None,
-        detail: Some(DispatchFailureDetail::HostSummary {
-            summary: SafeSummary::new(host_summary).unwrap(),
-            detail: None,
+        detail: Some(DispatchFailureDetail::Diagnostic {
+            text: cause,
         }),
     }
 }

As per coding guidelines, “Treat every … external service as untrusted until a typed boundary establishes otherwise.” As per path instructions, HostSummary must not carry untrusted external text.

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@tests/integration/support/harness/profiles/extension.rs` around lines 1415 -
1422, Update acme_tool_error so the dynamic host_summary input is emitted
through DispatchFailureDetail::Diagnostic rather than
DispatchFailureDetail::HostSummary; reserve HostSummary for fixed, host-authored
text and preserve the existing error kind and detail behavior.

Sources: Coding guidelines, Path instructions

crates/extensions/ironclaw_extension_host/src/generic_host.rs (1)

663-673: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a caller-level regression test for reservation rejection.

No test exercises SettlingToolAdapter::invoke with a failing ResourceGovernor::reserve. Add one that asserts ToolError::Rejected { kind: RuntimeDispatchErrorKind::Resource, diagnostic: None, detail: None } and confirms the inner adapter is not invoked. This follows the “Test through the caller” invariant in CLAUDE.md/AGENTS.md.

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@crates/extensions/ironclaw_extension_host/src/generic_host.rs` around lines
663 - 673, Add a caller-level regression test for SettlingToolAdapter::invoke
using a ResourceGovernor whose reserve call fails; assert the result is
ToolError::Rejected with Resource kind and no diagnostic or detail, and verify
the wrapped inner adapter is not invoked. Follow the existing test conventions
and caller-level testing guidance.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Inline comments:
In
`@crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs`:
- Around line 189-213: Update
extension_tool_errors_cannot_mint_control_plane_failure_kinds to first extract
the pub enum ToolError declaration, then inspect the Rejected variant within
that declaration rather than the first Rejected block in the file. Add a
malformed-source fixture that changes ToolError::Rejected’s kind field to
DispatchFailureKind and verifies the architecture gate rejects it.

In `@crates/kernel/ironclaw_host_runtime/tests/github_wasm_runtime_contract.rs`:
- Around line 1016-1021: Extend the assertions in the credential requirement
checks around gate.credential_requirements to validate each returned
requirement’s requester_extension and provider_scopes against the expected
package_id and required_scope values from the table row, while preserving the
existing count and provider assertions.

---

Outside diff comments:
In `@crates/extensions/ironclaw_extension_host/src/generic_host.rs`:
- Around line 663-673: Add a caller-level regression test for
SettlingToolAdapter::invoke using a ResourceGovernor whose reserve call fails;
assert the result is ToolError::Rejected with Resource kind and no diagnostic or
detail, and verify the wrapped inner adapter is not invoked. Follow the existing
test conventions and caller-level testing guidance.

In `@crates/kernel/ironclaw_capabilities/src/registry.rs`:
- Around line 178-190: Update the ToolError::Rejected to DispatchError::Rejected
conversion so extension-supplied host-owned detail fields are discarded rather
than forwarded. Preserve runtime provenance, rejection kind, provider
diagnostics, and permitted structured detail. Extend the existing
CapabilityInvocationError::from(DispatchError) assertions around the adapter
boundary to verify HostSummary and HostRemediation supplied by adapters are
absent, while the resolver’s boundary behavior remains unchanged.

In `@tests/integration/support/harness/profiles/extension.rs`:
- Around line 1415-1422: Update acme_tool_error so the dynamic host_summary
input is emitted through DispatchFailureDetail::Diagnostic rather than
DispatchFailureDetail::HostSummary; reserve HostSummary for fixed, host-authored
text and preserve the existing error kind and detail behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a319344c-e315-4ed6-8ad7-840d88929bc5

📥 Commits

Reviewing files that changed from the base of the PR and between 9fb70f3 and 612f552.

📒 Files selected for processing (22)
  • crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs
  • crates/contracts/ironclaw_extension_contracts/src/tool_adapter.rs
  • crates/contracts/ironclaw_host_api/src/dispatch.rs
  • crates/extensions/ironclaw_extension_host/src/generic_host.rs
  • crates/extensions/ironclaw_extension_host/src/resolver.rs
  • crates/extensions/ironclaw_extension_host/tests/lifecycle_contract.rs
  • crates/extensions/packages/telegram/src/linked/conformance.rs
  • crates/extensions/packages/telegram/src/linked/mapping.rs
  • crates/extensions/packages/telegram/src/linked/mapping/tests.rs
  • crates/extensions/packages/telegram/src/linked/ops/mod.rs
  • crates/extensions/packages/telegram/src/linked/tools.rs
  • crates/extensions/packages/telegram/src/linked/tools/tests.rs
  • crates/kernel/ironclaw_capabilities/src/error.rs
  • crates/kernel/ironclaw_capabilities/src/registry.rs
  • crates/kernel/ironclaw_host_runtime/src/services/extension_tool_binder.rs
  • crates/kernel/ironclaw_host_runtime/src/services/tests/extension_tool_binder.rs
  • crates/kernel/ironclaw_host_runtime/tests/github_wasm_runtime_contract.rs
  • crates/lanes/ironclaw_wasm/README.md
  • crates/lanes/ironclaw_wasm/src/runtime.rs
  • docs/internal/reborn/contracts/wasm.md
  • tests/integration/support/harness/profiles/device_link.rs
  • tests/integration/support/harness/profiles/extension.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

lloydmak99
lloydmak99 previously approved these changes Aug 21, 2026

@lloydmak99 lloydmak99 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typed WASM response migration and dispatch-error cleanup look coherent, with trust-boundary handling and sensitive-value redaction preserved. No blocking findings.

Checks: WASM artifact freshness and git diff --check passed; all required GitHub CI checks passed; targeted Rust tests and cargo fmt --check could not run locally because the required toolchain/linker was unavailable.

Scope the ToolError architecture ratchet and prove it with a malformed-source sabotage fixture.

Pin Google auth-required extension identity and provider scopes in the runtime contract test.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs (1)

189-197: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Bound the search to the ToolError enum body.

Lines 191-197 search the entire remainder of the file after pub enum ToolError. If ToolError loses its Rejected variant and a later enum contains Rejected { kind: RuntimeDispatchErrorKind }, this check still passes.

Extract the balanced ToolError enum body before locating Rejected. Add a sabotage fixture with no ToolError::Rejected and a valid later Rejected variant. The fixture must fail.

As per path instructions, architecture gates must fail closed and every new gate must be sabotage-tested.

Also applies to: 223-237

🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In
`@crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs`
around lines 189 - 197, Update assert_tool_error_rejected_uses_runtime_kind to
extract only the balanced body of pub enum ToolError before searching for
Rejected, so later enums cannot satisfy the check. Add a sabotage fixture
removing ToolError::Rejected while retaining a later valid Rejected variant, and
assert that this architecture gate fails closed.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Outside diff comments:
In
`@crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs`:
- Around line 189-197: Update assert_tool_error_rejected_uses_runtime_kind to
extract only the balanced body of pub enum ToolError before searching for
Rejected, so later enums cannot satisfy the check. Add a sabotage fixture
removing ToolError::Rejected while retaining a later valid Rejected variant, and
assert that this architecture gate fails closed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3c81afe8-2c46-4cfe-94f3-f0fabaf5152f

📥 Commits

Reviewing files that changed from the base of the PR and between 612f552 and 6b0e45e.

📒 Files selected for processing (2)
  • crates/app/ironclaw_architecture_tests/tests/reborn_retired_failure_vocabulary.rs
  • crates/kernel/ironclaw_host_runtime/tests/github_wasm_runtime_contract.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

lloydmak99
lloydmak99 previously approved these changes Aug 21, 2026

@lloydmak99 lloydmak99 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typed WASM tool contract (near:agent@0.4.1), six-guest migration, and dispatch-error taxonomy collapse are sound and well-tested. Prior trust-boundary feedback is addressed at head 612f5527e: extension packages can no longer mint HostSummary (resolver strips host-summary variants and mints only from a closed standard-messaging code set), ToolError::Rejected.kind is narrowed to RuntimeDispatchErrorKind with an architecture ratchet pinning it, Debug redaction covers both error types, and guest failure text is bounded (4096 B, UTF-8-safe) at the sandbox boundary.

Non-blocking follow-ups:

  • crates/lanes/ironclaw_wasm/src/host.rs:544 — ResponseBodyLimitExceeded collapses into WasmHostError::Failed and surfaces at store.rs:223 as OperationFailed rather than the new OutputTooLarge category, so oversized provider responses are misreported and the agent loop allows an identical retry. Worth routing to HttpErrorKind::OutputTooLarge with a distinct host error on a follow-up; not state-corrupting, so non-blocking.

Checks run: cargo test for ironclaw_wasm (17/17), ironclaw_safety (309/309, incl. short-token regression), ironclaw_capabilities (unit + dispatch contracts), ironclaw_architecture_tests retired-vocabulary + control-plane ratchets (8/8), and ironclaw_host_runtime github wasm contract (68/68 against real artifacts); check-wasm-artifact-freshness.py OK for 6 packages; CI fully green on the exact head (all Reborn buckets, integration, WebUI E2E, fmt/clippy, WASM WIT Compatibility, CodeRabbit).

Remove the stale DispatchFailureKind import left after ToolError switched to RuntimeDispatchErrorKind.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/extensions/ironclaw_extension_host/tests/lifecycle_contract.rs (1)

705-705: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the rejection classification.

The changed RuntimeDispatchErrorKind::Client value is not asserted. The later DispatchError::Rejected match ignores kind, so the test passes if the resolver drops or changes the classification.

Assert error.failure_kind() is DispatchFailureKind::Runtime(RuntimeDispatchErrorKind::Client) before matching the diagnostic.

As per path instructions: “Test through the caller” and verify typed contract evidence.

Suggested assertion
     let error = resolved
         .adapter
         .dispatch_json(...)
         .await
         .unwrap_err();

+    assert_eq!(
+        error.failure_kind(),
+        ironclaw_host_api::dispatch::DispatchFailureKind::Runtime(
+            RuntimeDispatchErrorKind::Client,
+        ),
+    );
🤖 Prompt for AI Agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

In `@crates/extensions/ironclaw_extension_host/tests/lifecycle_contract.rs` at
line 705, Update the lifecycle contract test to assert error.failure_kind()
equals DispatchFailureKind::Runtime(RuntimeDispatchErrorKind::Client) before
matching the DispatchError::Rejected diagnostic, ensuring the caller preserves
the client rejection classification.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.

Outside diff comments:
In `@crates/extensions/ironclaw_extension_host/tests/lifecycle_contract.rs`:
- Line 705: Update the lifecycle contract test to assert error.failure_kind()
equals DispatchFailureKind::Runtime(RuntimeDispatchErrorKind::Client) before
matching the DispatchError::Rejected diagnostic, ensuring the caller preserves
the client rejection classification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5313b9ef-1846-4cb3-acd9-9d59c478c62b

📥 Commits

Reviewing files that changed from the base of the PR and between 6b0e45e and 619847e.

📒 Files selected for processing (1)
  • crates/extensions/ironclaw_extension_host/tests/lifecycle_contract.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@lloydmak99 lloydmak99 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typed WASM response migration and dispatch-error cleanup look coherent, with the trust-boundary and diagnostic-redaction concerns resolved. No blocking findings.

Checks: git diff --check and WASM artifact freshness passed; key CI checks (Clippy, formatting, WIT compatibility, deterministic checks) passed, while local Rust tests could not run because linker cc was unavailable and several CI test jobs remained pending.

This branch was successfully deployed

No deployments
ironclaw-ci-preview / ironclaw-pr-7711 — 619847e8 Deployed Aug 21, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: core 20+ merged PRs risk: low Changes to docs, tests, or low-risk modules scope: ci CI/CD workflows scope: dependencies Dependency updates scope: docs Documentation scope: sandbox Docker sandbox size: XL 500+ changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants