- 5579
#[test] - 5580
fn a_channel_can_only_lower_autonomy_never_raise_it() { - 5581
let composed = ChannelPolicy::merge(&policy(Some("delegated")), &policy(Some("manual"))); - 5582
assert_eq!(composed.autonomy_ceiling.as_deref(), Some("manual")); - 5583
- 5584
// The narrower tier asking for MORE does not get it. - 5585
let composed = ChannelPolicy::merge(&policy(Some("manual")), &policy(Some("autonomous"))); - 5586
assert_eq!(composed.autonomy_ceiling.as_deref(), Some("manual")); - 5587
} - 5588
- 5589
#[test] - 5590
fn silence_on_one_tier_inherits_rather_than_permitting_everything() { - 5591
assert_eq!( - 5592
ChannelPolicy::merge(&policy(Some("assisted")), &policy(None)) - 5593
.autonomy_ceiling - 5594
.as_deref(), - 5595
Some("assisted") - 5596
); - 5597
assert_eq!( - 5598
ChannelPolicy::merge(&policy(None), &policy(Some("manual"))) - 5599
.autonomy_ceiling - 5600
.as_deref(), - 5601
Some("manual") - 5602
); - 5603
assert!( - 5604
ChannelPolicy::merge(&policy(None), &policy(None)) - 5605
.autonomy_ceiling - 5606
.is_none() - 5607
); - 5608
} - 5609
- 5610
/// An unparseable ceiling must not read as maximum delegation. - 5611
#[test] - 5612
fn an_unknown_ceiling_is_treated_as_assisted_not_autonomous() { - 5613
let composed = ChannelPolicy::merge(&policy(Some("banana")), &policy(Some("autonomous"))); - 5614
assert_eq!(composed.autonomy_ceiling.as_deref(), Some("banana")); - 5615
assert!(autonomy_rank("banana") < autonomy_rank("autonomous")); - 5616
} - 5617
- 5618
#[test] - 5619
fn plugin_resolved_allow_deny_network_matrix() { - 5620
let mut resolved = PluginResolved::default(); - 5621
assert!(resolved.is_enabled("test-plugin")); - 5622
assert!(!resolved.is_network_allowed("test-plugin")); - 5623
- 5624
// Enable network - 5625
resolved.network_allow = Some(vec!["test-plugin".into()]); - 5626
assert!(resolved.is_network_allowed("test-plugin")); - 5627
- 5628
// Global or channel deny takes priority - 5629
resolved.network_deny.push("test-plugin".into()); - 5630
assert!(!resolved.is_network_allowed("test-plugin")); - 5631
assert!(resolved.is_enabled("test-plugin")); - 5632
- 5633
// Disabling or denying plugin shuts it off completely - 5634
resolved.disabled.push("test-plugin".into()); - 5635
assert!(!resolved.is_enabled("test-plugin")); - 5636
assert!(!resolved.is_network_allowed("test-plugin")); - 5637
} - 5638
- 5639
#[test] - 5640
fn channel_policy_merges_plugin_network_and_allow_deny() { - 5641
let bot = ChannelPolicy { - 5642
plugins_allow: Some(vec!["test-plugin-a".into(), "test-plugin-b".into()]), - 5643
plugins_deny: vec!["untrusted-plugin".into()], - 5644
plugins_network_deny: vec!["test-plugin-b".into()], - 5645
..ChannelPolicy::default() - 5646
}; - 5647
let chat = ChannelPolicy { - 5648
plugins_allow: Some(vec!["test-plugin-a".into()]), - 5649
plugins_deny: vec!["banned-plugin".into()], - 5650
plugins_network_deny: vec!["test-plugin-a".into()], - 5651
..ChannelPolicy::default() - 5652
}; - 5653
let merged = ChannelPolicy::merge(&bot, &chat); - 5654
assert_eq!(merged.plugins_allow, Some(vec!["test-plugin-a".into()])); - 5655
assert!( - 5656
merged - 5657
.plugins_deny - 5658
.contains(&"untrusted-plugin".to_string()) - 5659
); - 5660
assert!(merged.plugins_deny.contains(&"banned-plugin".to_string())); - 5661
assert!( - 5662
merged - 5663
.plugins_network_deny - 5664
.contains(&"test-plugin-b".to_string()) - 5665
); - 5666
assert!( - 5667
merged - 5668
.plugins_network_deny - 5669
.contains(&"test-plugin-a".to_string()) - 5670
); - 5671
} - 5672
- 5673
/// The persisted TOML field was renamed from `subagents` to `workers`. - 5674
/// An existing `vak.toml` with the old key (and no `workers` key) must - 5675
/// still be honored rather than silently falling back to the default. - 5676
#[test] - 5677
fn legacy_subagents_key_is_honored_as_workers() { - 5678
let dir = tempfile::tempdir().unwrap(); - 5679
let path = project_path(dir.path()); - 5680
std::fs::create_dir_all(path.parent().unwrap()).unwrap(); - 5681
std::fs::write(&path, "subagents = false\n").unwrap(); - 5682
- 5683
let (fc, warnings) = parse_file(&path).unwrap(); - 5684
assert_eq!(fc.workers, Some(false)); - 5685
assert!( - 5686
warnings.is_empty(), - 5687
"legacy `subagents` key should not warn as unknown: {warnings:?}" - 5688
); - 5689
- 5690
let cfg = load_with_trust(dir.path(), true).unwrap(); - 5691
assert!(!cfg.workers); - 5692
} - 5693
} - 5694
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.