lawsynth/crates/lawsynth-plugin-host/tests/registry_integration.rs
caelum0x 29fe90834c feat(P8/P9/P10): plugin marketplace, model governance, hosted-platform tenancy
Implementing the next-phase boundary specs as real, tested code:

P8 Plugin marketplace (specs/plugin-marketplace) — .lsplugin packages (checksum
manifest + package hash), mirrorable TSV registry, honest keyed-HMAC signing
(documented as symmetric MAC, not public-key), capability grants enforced at a
single seam (declared AND granted), non-destructive install; CLI plugin
pack/install/list/verify/remove/registry. pack->sign->install->verify->tamper-
fails demonstrated.

P9 Governance (specs/model-governance) — model cards (Rust render_model_card +
SDK Study.model_card orchestrating explain/validate/backtest/ensemble, honest
'Not measured' omissions), content-addressed lineage with verify_reproducible(),
tamper-evident hash-chained audit log (content ordinals, no clock). Added
Study.validate() holdout.

P10 Hosted platform (specs/hosted-platform) — per-tenant isolation tests on every
resource + FIXED a real artifact cross-tenant download leak (owner check);
per-tenant quota -> 429 + append-only metering log + GET /v1/usage; honest HMAC
SSO seam at the gateway (tenant token exchange, rejects forged/cross-tenant).

Rust workspace green (60 plugin/report tests); API 153 pass native-absent (+22);
gateway 14 (+7); SDK governance 16.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-18 01:27:37 +03:00

21 lines
970 B
Rust

use lawsynth_plugin_api::{Capability, CapabilitySet, PluginManifest};
use lawsynth_plugin_host::{HostConfig, PermissionPolicy, PermissionSet, PluginRegistry};
#[test]
fn registry_requires_host_enablement_and_explicit_grants() {
let manifest = PluginManifest::parse("id = adapter\nversion = 1.0.0\nkind = wasi\nentrypoint = adapter.wasm\ncapabilities = data.adapter\n").unwrap();
let mut registry = PluginRegistry::default();
assert!(registry.register(&HostConfig::default(), manifest.clone()).is_err());
let config = HostConfig {
enabled: true,
policy: PermissionPolicy {
allowed: PermissionSet(CapabilitySet::new([Capability::DataAdapter])),
allow_trusted_native: false,
},
maximum_limits: Default::default(),
};
registry.register(&config, manifest).unwrap();
assert_eq!(registry.len(), 1);
assert!(registry.get("adapter").unwrap().permissions.allows(Capability::DataAdapter));
}