Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/extensions/ironclaw_extension_support/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
a package, add its directory under `packages/` and its module here, and put it
in the `PACKAGES` table — the catalog is derived from that table, not from a
directory scan.
- **One package module is deliberately not in `PACKAGES`: `nearai`.** Its
shipped `[mcp].server` is a placeholder the host rewrites from the operator's
LLM-admin bootstrap configuration, and a `fn() -> PackageBundle` cannot
produce that value. Its embeds still live here, with every other package's;
the patch lives with the endpoint authority in `ironclaw_extension_host`,
which calls `packages::nearai::nearai_bundle()`. Read that module's header
before assuming the omission is an oversight — it is the documented shape.
- Rebuilding a WASM guest: `./scripts/build-wasm-extensions.sh --first-party`,
then `python3 scripts/ci/check-wasm-artifact-freshness.py --update`. The
freshness gate fails if you edit `wasm-src/` and do not do both.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use ironclaw_host_api::capability::EffectKind;
mod github;
mod gmail;
mod gsuite;
pub mod nearai;
mod notion;
mod slack;
mod telegram;
Expand Down
132 changes: 132 additions & 0 deletions crates/extensions/ironclaw_extension_support/src/packages/nearai.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//! NEAR AI MCP package — hosted MCP tools over the NEAR AI cloud endpoint,
//! API-key credential, host-mediated egress. Assets: one tool's input/output
//! JSON schemas and its prompt doc (no bundled WASM; dispatched via MCP). The
//! asset directory is `nearai-mcp/` while the in-package schema/prompt paths use
//! `nearai/` — the same asymmetry `notion.rs` carries.
//!
//! ## Why this package is not in [`super::PACKAGES`]
//!
//! Every other inventory entry is a `fn() -> PackageBundle`: the bundle is a
//! pure function of the embedded bytes, so the binary can hand the whole
//! inventory to composition without knowing what is in it. NEAR AI is the one
//! package whose shipped manifest is **incomplete on its own** — its
//! `[mcp].server` is a placeholder that the host rewrites from the operator's
//! LLM-admin bootstrap configuration before the manifest is ever parsed. A
//! config-free builder cannot produce that value, and putting the unpatched
//! manifest in the inventory would mean the binary hands composition a manifest
//! pointing at the placeholder endpoint.
//!
//! So the *embeds* live here, with every other package's embeds and under the
//! specificity gate's sanctioned-crate exemption, and the *patch* stays with the
//! endpoint authority in `ironclaw_extension_host`. [`nearai_bundle`] is the
//! seam: it returns the same [`PackageBundle`] shape as the inventory entries,
//! carrying the manifest as shipped, and the caller replaces `manifest_toml`
//! (which is a [`Cow`] precisely so an owned, patched manifest is representable)
//! and the `manifest.toml` asset with the patched text.

use std::borrow::Cow;

use super::{PackageAsset, PackageBundle, bytes_asset};

/// Extension id declared by the package manifest. The asset directory is
/// `nearai-mcp/`; the id is `nearai`.
pub const NEARAI_ID: &str = "nearai";

/// In-package path of the manifest asset, which the caller re-writes with the
/// endpoint-patched text.
pub const NEARAI_MANIFEST_ASSET_PATH: &str = "manifest.toml";

const MANIFEST: &str = include_str!("../../../packages/nearai-mcp/manifest.toml");

/// The NEAR AI package as shipped, with the manifest's placeholder `[mcp].server`
/// still in place.
///
/// Callers that dispatch NEAR AI tools **must** replace `manifest_toml` and the
/// [`NEARAI_MANIFEST_ASSET_PATH`] asset with an endpoint-patched manifest; see
/// the module docs for why that patch cannot happen here.
pub fn nearai_bundle() -> PackageBundle {
PackageBundle {
id: NEARAI_ID,
display_name: "NEAR AI",
manifest_toml: Cow::Borrowed(MANIFEST),
assets: assets(),
onboarding: None,
trust_effects: None,
}
}

fn assets() -> Vec<PackageAsset> {
macro_rules! nearai_schema_asset {
($path:literal) => {
bytes_asset(
concat!("schemas/nearai/", $path),
include_bytes!(concat!(
"../../../packages/nearai-mcp/schemas/nearai/",
$path
)),
)
};
}
macro_rules! nearai_prompt_asset {
($path:literal) => {
bytes_asset(
concat!("prompts/nearai/", $path),
include_bytes!(concat!(
"../../../packages/nearai-mcp/prompts/nearai/",
$path
)),
)
};
}

vec![
bytes_asset(NEARAI_MANIFEST_ASSET_PATH, MANIFEST.as_bytes()),
nearai_schema_asset!("web_search.input.v1.json"),
nearai_schema_asset!("web_search.output.v1.json"),
nearai_prompt_asset!("web_search.md"),
]
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn shipped_bundle_carries_the_manifest_and_every_asset() {
let bundle = nearai_bundle();
assert_eq!(bundle.id, NEARAI_ID);
assert_eq!(bundle.manifest_toml.as_ref(), MANIFEST);

let paths = bundle
.assets
.iter()
.map(|asset| asset.path.as_str())
.collect::<Vec<_>>();
assert_eq!(
paths,
vec![
"manifest.toml",
"schemas/nearai/web_search.input.v1.json",
"schemas/nearai/web_search.output.v1.json",
"prompts/nearai/web_search.md",
]
);
}

#[test]
fn shipped_manifest_declares_the_placeholder_server_the_host_patches() {
// The reason this package is not a `PACKAGES` entry: the shipped
// `[mcp].server` is not the endpoint any deployment talks to — the host
// rewrites it. If this assertion fails because the key was renamed or
// dropped, the module docs above and the patch in
// `ironclaw_extension_host::available_extensions` are both wrong.
assert!(
MANIFEST.contains("[mcp]"),
"shipped manifest must declare an [mcp] table for the host to patch"
);
assert!(
MANIFEST.contains("server = "),
"shipped manifest must declare [mcp].server for the host to overwrite"
);
}
}
44 changes: 15 additions & 29 deletions crates/ironclaw_architecture/tests/reborn_dependency_boundaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4167,16 +4167,23 @@ struct LayerMatrixException {
/// live tree it is turn *admission* (a `TurnCoordinator` handle and
/// `submit_turn` call), not vocabulary, so `loop_contracts` cannot dissolve it
/// — its entry now records that and points at WS5.
const WS0_LAYER_MATRIX_EXCEPTION_BASELINE: usize = 10;
///
/// **10 → 6 (WS2, `ironclaw_extensions` re-layered `loops` → `substrates`).**
/// Four entries — `host_runtime`, `capabilities`, `mcp` and `scripts` reaching
/// `ironclaw_extensions` — were all the same edge under four names: a
/// kernel/runtimes-tier crate consuming the registry's manifest DTOs. None was
/// waived and none of those edges was deleted; the *registry* moved down to
/// `substrates`, where every layer above may legally reach it (PROPOSAL §6.8.1:
/// "Layer substrates legalizes `capabilities → extensions` and
/// `host_runtime → extensions`" — it legalizes `mcp` and `scripts` too, which
/// that entry undercounts). The one edge that blocked the move,
/// `extensions → trust` (kernel), is also gone rather than waived:
/// `TrustPolicyInput` is requested-trust *vocabulary* and now lives beside
/// `PackageIdentity` in `ironclaw_host_api::trust`, which is §6.8.1's own
/// prescription ("`trust`-vocabulary via `host_api`").
const WS0_LAYER_MATRIX_EXCEPTION_BASELINE: usize = 6;

const LAYER_MATRIX_EXCEPTIONS: &[LayerMatrixException] = &[
LayerMatrixException {
crate_name: "ironclaw_host_runtime",
dependency_name: "ironclaw_extensions",
introduced: "2026-07-09",
removes_in: "W7",
reason: "host_runtime still owns extension-hosting wiring until kernel consolidation moves only the execution perimeter into kernel",
},
LayerMatrixException {
crate_name: "ironclaw_host_runtime",
dependency_name: "ironclaw_extension_support",
Expand All @@ -4191,13 +4198,6 @@ const LAYER_MATRIX_EXCEPTIONS: &[LayerMatrixException] = &[
removes_in: "W7",
reason: "host_runtime still owns first-party skill management tools and skill URL install limits; remove when kernel consolidation or a dedicated skill-host extraction moves that execution surface out of host_runtime",
},
LayerMatrixException {
crate_name: "ironclaw_capabilities",
dependency_name: "ironclaw_extensions",
introduced: "2026-07-09",
removes_in: "W7",
reason: "capability hosting still reaches the extension surface until the kernel perimeter is consolidated",
},
LayerMatrixException {
crate_name: "ironclaw_processes",
dependency_name: "ironclaw_resources",
Expand All @@ -4212,27 +4212,13 @@ const LAYER_MATRIX_EXCEPTIONS: &[LayerMatrixException] = &[
removes_in: "WS5",
reason: "re-verified during WS1.2: this is NOT turn-DTO naming and loop_contracts does not dissolve it. InboundTurnService holds Arc<dyn TurnCoordinator> and calls submit_turn(SubmitTurnRequest), and trusted_trigger classifies TurnError/AdmissionRejectionReason - turn ADMISSION authority, not vocabulary. It clears when the inbound submit orchestration moves to the product tier (PROPOSAL 6.4.2 lists conversations deps as filesystem/host_api/safety/triggers with turn vocabulary via host_api)",
},
LayerMatrixException {
crate_name: "ironclaw_mcp",
dependency_name: "ironclaw_extensions",
introduced: "2026-07-09",
removes_in: "W7",
reason: "MCP runtime still consumes ExtensionPackage and ExtensionRuntime manifest DTOs; remove when extension runtime descriptors move to a neutral contract or runtime lanes are folded behind the extension-host boundary",
},
LayerMatrixException {
crate_name: "ironclaw_mcp",
dependency_name: "ironclaw_resources",
introduced: "2026-07-09",
removes_in: "W7",
reason: "MCP runtime support still depends on resource contracts currently classed with kernel behavior",
},
LayerMatrixException {
crate_name: "ironclaw_scripts",
dependency_name: "ironclaw_extensions",
introduced: "2026-07-09",
removes_in: "W7",
reason: "script runtime still consumes ExtensionPackage and ExtensionRuntime manifest DTOs; remove when extension runtime descriptors move to a neutral contract or runtime lanes are folded behind the extension-host boundary",
},
LayerMatrixException {
crate_name: "ironclaw_scripts",
dependency_name: "ironclaw_resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,14 @@ const ALLOWLIST: &[(&str, &str)] = &[
// lane-4: nearai-slice — the last catalog package (nearai_mcp) is still
// patched from LLM-admin bootstrap config; it now lives with the generic
// available-extension catalog in ironclaw_extension_host.
(
"crates/ironclaw_extension_host/src/available_extensions.rs",
"nearai-mcp",
),
//
// The `nearai-mcp` *asset-directory* carve-out for this file is gone (WS2
// include_str kills): the package's embeds moved to the inventory module
// `ironclaw_extension_support::packages::nearai`, which is a sanctioned
// scan-exempt crate, so this file no longer names the directory. The
// `nearai_mcp` / `nearaimcp` entries below stay — the endpoint patch and
// the `nearai_mcp` module it reads are still here, by §6.8.2 (the fork is
// what prevents an `extension_host -> operator` upward edge).
(
"crates/ironclaw_extension_host/src/available_extensions.rs",
"nearai_mcp",
Expand Down
2 changes: 1 addition & 1 deletion crates/ironclaw_capabilities/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4026,7 +4026,7 @@ output_schema_ref = "schemas/echo/say.output.v1.json"
impl TrustPolicy for StaticTrustPolicy {
fn evaluate(
&self,
_input: &ironclaw_trust::TrustPolicyInput,
_input: &ironclaw_host_api::trust::TrustPolicyInput,
) -> Result<TrustDecision, ironclaw_trust::TrustError> {
use ironclaw_trust::{AuthorityCeiling, EffectiveTrustClass, TrustProvenance};
Ok(TrustDecision {
Expand Down
3 changes: 2 additions & 1 deletion crates/ironclaw_capabilities/src/trust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

use ironclaw_extensions::{ExtensionPackage, ExtensionRegistry};
use ironclaw_host_api::ids::CapabilityId;
use ironclaw_trust::{TrustDecision, TrustPolicy, TrustPolicyInput};
use ironclaw_host_api::trust::TrustPolicyInput;
use ironclaw_trust::{TrustDecision, TrustPolicy};
use tracing::debug;

/// Why trust classification refused to produce a `TrustDecision`.
Expand Down
4 changes: 2 additions & 2 deletions crates/ironclaw_capabilities/tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use ironclaw_host_api::runtime_policy::{
ApprovalPolicy, AuditMode, DeploymentMode, FilesystemBackendKind, NetworkMode,
ProcessBackendKind, RuntimeProfile, SecretMode,
};
use ironclaw_host_api::trust::TrustPolicyInput;
use ironclaw_host_api::{
action::{Action, NetworkPolicy},
approval::{ApprovalRequest, InvocationFingerprint},
Expand All @@ -42,8 +43,7 @@ use ironclaw_host_api::{
scope::{ExecutionContext, Principal},
};
use ironclaw_trust::{
AuthorityCeiling, EffectiveTrustClass, TrustDecision, TrustError, TrustPolicy,
TrustPolicyInput, TrustProvenance,
AuthorityCeiling, EffectiveTrustClass, TrustDecision, TrustError, TrustPolicy, TrustProvenance,
};
use serde_json::json;

Expand Down
4 changes: 1 addition & 3 deletions crates/ironclaw_extension_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ layer = "products"
# Lightweight in-crate test fakes (fixtures, scripted adapters) reused by
# downstream integration tests. Zero-byte in production.
test-support = [
"dep:ironclaw_extension_support",
"ironclaw_auth/test-support",
"ironclaw_filesystem/test-support",
"ironclaw_host_api/test-support",
Expand Down Expand Up @@ -49,7 +48,7 @@ ironclaw_product_contracts = { path = "../ironclaw_product_contracts", version =
ironclaw_extension_contracts = { path = "../ironclaw_extension_contracts", version = "0.1.0" }
ironclaw_host_ingress = { path = "../ironclaw_host_ingress" }
ironclaw_extensions = { path = "../ironclaw_extensions" }
ironclaw_extension_support = { path = "../extensions/ironclaw_extension_support", optional = true }
ironclaw_extension_support = { path = "../extensions/ironclaw_extension_support" }
ironclaw_host_runtime = { path = "../ironclaw_host_runtime" }
ironclaw_llm = { path = "../ironclaw_llm", default-features = false }
ironclaw_loop_host = { path = "../ironclaw_loop_host" }
Expand Down Expand Up @@ -96,7 +95,6 @@ proptest = "1"
ironclaw_auth = { path = "../ironclaw_auth", features = ["test-support"] }
ironclaw_authorization = { path = "../ironclaw_authorization" }
ironclaw_filesystem = { path = "../ironclaw_filesystem", features = ["test-support"] }
ironclaw_extension_support = { path = "../extensions/ironclaw_extension_support" }
ironclaw_host_api = { path = "../ironclaw_host_api", features = ["test-support"] }
ironclaw_host_runtime = { path = "../ironclaw_host_runtime", features = ["test-support"] }
ironclaw_outbound = { path = "../ironclaw_outbound", features = ["test-support"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/ironclaw_extension_host/src/active_publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl ActiveExtensionPublisher {

pub fn extension_trust_policy_input(
package: &ExtensionPackage,
) -> Result<ironclaw_trust::TrustPolicyInput, ProductOperationFailure> {
) -> Result<ironclaw_host_api::trust::TrustPolicyInput, ProductOperationFailure> {
package
.trust_policy_input(
package.trust_policy_source().map_err(map_extension_error)?,
Expand Down
39 changes: 31 additions & 8 deletions crates/ironclaw_extension_host/src/available_extension_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,23 +851,46 @@ setup_url = "{expected_url}"
assert_eq!(reloaded.source, ManifestSource::InstalledLocal);
}

/// A v3 manifest asserting first-party trust. Inline rather than an
/// `include_str!` of `packages/github/manifest.toml`: the only property
/// this test needs is `trust = "first_party_requested"` on a v3 manifest,
/// and reaching into a shipped product package for a fixture coupled the
/// test to 200 lines it does not own (WS2 §11.2.7 cross-package reach-ins).
const FIRST_PARTY_TRUST_CLAIM_FIXTURE: &str = r#"
schema_version = "reborn.extension_manifest.v3"
id = "veridian"
name = "Veridian"
version = "0.1.0"
description = "fixture: an imported manifest claiming first-party trust"
trust = "first_party_requested"

[runtime]
kind = "wasm"
module = "wasm/veridian_tool.wasm"

[[tools]]
id = "veridian.echo"
description = "Echoes input"
default_permission = "ask"
visibility = "model"
input_schema_ref = "schemas/veridian/echo.input.v1.json"
"#;

#[test]
fn imported_extension_package_rejects_first_party_trust_claims() {
let error = imported_extension_package(
vec![(
"manifest.toml".to_string(),
include_str!("../../extensions/packages/github/manifest.toml")
.as_bytes()
.to_vec(),
FIRST_PARTY_TRUST_CLAIM_FIXTURE.as_bytes().to_vec(),
)],
&[],
)
.expect_err("first-party trust claims must be rejected");
// The bundled github manifest is v3, so the rejection comes from the
// v3 reader's source/trust gate ("trust `FirstPartyRequested` is not
// allowed for this manifest source"); the v2 wording is "not allowed
// to assert trust". Pin the shared semantic: the error names trust
// and ties the rejection to the manifest source.
// The fixture is v3, so the rejection comes from the v3 reader's
// source/trust gate ("trust `FirstPartyRequested` is not allowed for
// this manifest source"); the v2 wording is "not allowed to assert
// trust". Pin the shared semantic: the error names trust and ties the
// rejection to the manifest source.
let message = format!("{error}");
assert!(
message.contains("trust") && message.contains("not allowed for this manifest source"),
Expand Down
Loading
Loading