From 23782d94f8ee34f445b60cdd1196f91edd1da75e Mon Sep 17 00:00:00 2001 From: "minimal-foundry[bot]" <327719912+minimal-foundry[bot]@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:54:49 +0000 Subject: [PATCH 1/2] feat(minimal): list store reference authorities in min box spec (T61) Each store row in min box spec now prints the upstream authorities that the matching [secret-store-rules] rule registers. A reference with no matching rule says so. --- crates/minimal/src/cmd/box_spec.rs | 91 ++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/crates/minimal/src/cmd/box_spec.rs b/crates/minimal/src/cmd/box_spec.rs index a56c07f3a4..6a000398db 100644 --- a/crates/minimal/src/cmd/box_spec.rs +++ b/crates/minimal/src/cmd/box_spec.rs @@ -14,7 +14,7 @@ use std::path::{Path, PathBuf}; use anyhow::Context as _; use boxes::core::bep::{ ActivationRefused, ActivationSpec, BepRefusal, BepSettings, BepWarning, HostFacts, Quic443, - SecretGrant, SecretGrants, Steering, refusals, + SecretGrant, SecretGrants, Steering, StoreReference, StoreRules, refusals, }; use crate::{BoxSpecArgs, GlobalArgs}; @@ -35,6 +35,9 @@ pub(crate) struct SpecInputs<'a> { pub acknowledged: bool, /// The GitHub module's upstream hosts. pub github_hosts: &'a [&'a str], + /// The client's `[secret-store-rules]`, merged and with refused rules + /// left out. + pub store_rules: &'a StoreRules, } /// Writes the `min box spec` rows for `inputs`. @@ -113,9 +116,20 @@ pub(crate) fn render(inputs: &SpecInputs<'_>, out: &mut dyn std::io::Write) -> a } } for scope in grant.scopes.iter().filter(|s| !s.starts_with("github:")) { - // No store has registered hosts yet (the `[secret-store-rules]` - // slice adds them). - writeln!(out, "store {scope} {name} no hosts registered")?; + // BEP-038, BEP-063: the authorities the matching rule registers + // are the upstream the store handle carries. + match StoreReference::parse(name, scope).rule(inputs.store_rules) { + Some(rule) if !rule.upstream.is_empty() => writeln!( + out, + "store {scope} {name} upstream {}", + rule.upstream.join(", ") + )?, + Some(_) => writeln!(out, "store {scope} {name} no upstream registered")?, + None => writeln!( + out, + "store {scope} {name} no rule in [secret-store-rules] in config.toml" + )?, + } } } @@ -190,6 +204,14 @@ pub(crate) fn cmd_box_spec(global: &GlobalArgs, args: BoxSpecArgs) -> anyhow::Re ) }); let acknowledged = crate::config::full_breadth_acknowledged(global)?; + let store_rules = if boxes::core::bep::store_references(&secrets) + .next() + .is_some() + { + crate::config::read_client_config_and_store_rules(global)?.1 + } else { + StoreRules::new() + }; let root = root_fingerprint(identity_path().as_deref()); tracing::debug!( project = %project.display(), @@ -210,6 +232,7 @@ pub(crate) fn cmd_box_spec(global: &GlobalArgs, args: BoxSpecArgs) -> anyhow::Re secrets: &secrets, acknowledged, github_hosts: &github_hosts, + store_rules: &store_rules, }, &mut stdout, )?; @@ -258,12 +281,68 @@ mod tests { secrets, acknowledged, github_hosts: HOSTS, + store_rules: &StoreRules::new(), }, &mut out, )?; Ok(String::from_utf8(out).expect("utf-8")) } + /// BEP-038, BEP-063: a store reference prints the authorities its + /// matching rule registers, and only a rule for the same store matches. + #[test] + fn box_spec_lists_store_references_with_their_authorities() { + let secrets = SecretGrants::from([("CLAUDE".to_string(), grant(&["keychain:claude"]))]); + let rule = |store: &str| boxes::core::bep::StoreRuleConfig { + store: Some(store.to_string()), + upstream: vec![ + "api.anthropic.com".into(), + "console.anthropic.com:8443".into(), + ], + header: Some("x-api-key".into()), + prefix: None, + basic_auth: None, + action: None, + }; + let render_with = |rules: &StoreRules| { + let mut out = Vec::new(); + render( + &SpecInputs { + root_fingerprint: Some("abc123"), + bep: &proxy_env(), + quic443: None, + secrets: &secrets, + acknowledged: false, + github_hosts: HOSTS, + store_rules: rules, + }, + &mut out, + ) + .expect("renders"); + String::from_utf8(out).expect("utf-8") + }; + + let rules = StoreRules::from([("claude".to_string(), rule("keychain"))]); + let text = render_with(&rules); + assert!( + text.contains( + "store keychain:claude CLAUDE upstream api.anthropic.com, \ + console.anthropic.com:8443\n" + ), + "{text}" + ); + + // A rule for another store does not match the reference. + let other = StoreRules::from([("claude".to_string(), rule("vault"))]); + let text = render_with(&other); + assert!( + text.contains( + "store keychain:claude CLAUDE no rule in [secret-store-rules] in config.toml\n" + ), + "{text}" + ); + } + /// BEP-038: the root fingerprint, the upstream hosts per grant, the /// steering mode and each store reference. #[test] @@ -278,7 +357,7 @@ mod tests { "root CA certificate SHA256:abc123\n\ grant github:user-token full GH_TOKEN hosts github.com, api.github.com, \ uploads.github.com, codeload.github.com\n\ - store keychain:npm NPM_TOKEN no hosts registered\n\ + store keychain:npm NPM_TOKEN no rule in [secret-store-rules] in config.toml\n\ steering proxy_env\n\ quic443 allowed (HTTP/3 bypasses the proxy)\n" ); @@ -295,6 +374,7 @@ mod tests { secrets: &secrets, acknowledged: false, github_hosts: HOSTS, + store_rules: &StoreRules::new(), }, &mut out, ) @@ -358,6 +438,7 @@ mod tests { secrets: &secrets, acknowledged: false, github_hosts: HOSTS, + store_rules: &StoreRules::new(), }, &mut out, ) From da8169260e6a42568be4a6f6e09ee4b4c4ca3ff2 Mon Sep 17 00:00:00 2001 From: "minimal-foundry[bot]" <327719912+minimal-foundry[bot]@users.noreply.github.com> Date: Sun, 25 Oct 2026 17:07:36 +0000 Subject: [PATCH 2/2] fix(minimal): show a deny store rule as denied in min box spec A rule with action = "deny" can keep an upstream. The row printed that upstream, so it implied the box can redeem the reference. The row now says the rule denies the reference and lists no authorities. --- crates/minimal/src/cmd/box_spec.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/minimal/src/cmd/box_spec.rs b/crates/minimal/src/cmd/box_spec.rs index 6a000398db..e43ee2ef02 100644 --- a/crates/minimal/src/cmd/box_spec.rs +++ b/crates/minimal/src/cmd/box_spec.rs @@ -14,7 +14,7 @@ use std::path::{Path, PathBuf}; use anyhow::Context as _; use boxes::core::bep::{ ActivationRefused, ActivationSpec, BepRefusal, BepSettings, BepWarning, HostFacts, Quic443, - SecretGrant, SecretGrants, Steering, StoreReference, StoreRules, refusals, + SecretGrant, SecretGrants, Steering, StoreAction, StoreReference, StoreRules, refusals, }; use crate::{BoxSpecArgs, GlobalArgs}; @@ -118,7 +118,13 @@ pub(crate) fn render(inputs: &SpecInputs<'_>, out: &mut dyn std::io::Write) -> a for scope in grant.scopes.iter().filter(|s| !s.starts_with("github:")) { // BEP-038, BEP-063: the authorities the matching rule registers // are the upstream the store handle carries. + // A deny rule never redeems the reference, whatever upstream it + // keeps, so the row says it is denied and lists no authorities. match StoreReference::parse(name, scope).rule(inputs.store_rules) { + Some(rule) if rule.action == Some(StoreAction::Deny) => writeln!( + out, + "store {scope} {name} denied by its rule in [secret-store-rules] in config.toml" + )?, Some(rule) if !rule.upstream.is_empty() => writeln!( out, "store {scope} {name} upstream {}", @@ -341,6 +347,19 @@ mod tests { ), "{text}" ); + + // A deny rule lists no authorities, even when it keeps an upstream. + let mut denied = rule("keychain"); + denied.action = Some(StoreAction::Deny); + let text = render_with(&StoreRules::from([("claude".to_string(), denied)])); + assert!( + text.contains( + "store keychain:claude CLAUDE denied by its rule in [secret-store-rules] in \ + config.toml\n" + ), + "{text}" + ); + assert!(!text.contains("api.anthropic.com"), "{text}"); } /// BEP-038: the root fingerprint, the upstream hosts per grant, the