- 445
/// instances (docs/design/34-channel-onboarding.md Phase 2). Default 8. - 446
pub core_pool_max: Option<usize>, - 447
/// Idle duration (seconds) after which a pooled non-default-workspace - 448
/// `Core` is evicted. Default 1800 (30 minutes). - 449
pub core_pool_idle_secs: Option<u64>, - 450
/// Days a `pending` allowlist entry may sit unreviewed before - 451
/// `vak doctor` flags it and `--repair` auto-denies it - 452
/// (docs/design/34-channel-onboarding.md). Default 7. - 453
pub pending_expiry_days: Option<u64>, - 454
} - 455
- 456
#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)] - 457
pub struct RateLimitSettings { - 458
/// Max requests per window for `POST /gateway/inbound`. - 459
pub inbound_per_min: Option<u32>, - 460
/// Max requests per window for `POST /sessions`. - 461
pub sessions_per_min: Option<u32>, - 462
/// Max requests per window for `POST /sessions/{id}/run`. - 463
pub runs_per_min: Option<u32>, - 464
/// Max requests per window for all other POST endpoints. - 465
pub other_post_per_min: Option<u32>, - 466
/// Window duration in seconds. - 467
pub window_secs: Option<u64>, - 468
} - 469
- 470
#[derive(Debug, Clone, Deserialize, Default)] - 471
#[serde(default)] - 472
pub struct OutboundSettings { - 473
/// Named webhook delivery targets: `[gateway.outbound.webhooks.<name>]`. - 474
/// Target strings use `webhook:<name>`. - 475
pub webhooks: std::collections::BTreeMap<String, WebhookTarget>, - 476
} - 477
- 478
#[derive(Debug, Clone, Deserialize)] - 479
pub struct WebhookTarget { - 480
pub url: String, - 481
/// Name of an env var holding a bearer token attached to each - 482
/// delivery. The value is resolved at delivery time and never stored - 483
/// in config; a configured-but-missing token fails the delivery - 484
/// closed instead of posting unauthenticated. - 485
pub token_env: Option<String>, - 486
} - 487
- 488
#[derive(Debug, Clone, Deserialize, Default)] - 489
#[serde(default)] - 490
pub struct UiSettings { - 491
pub theme: Option<String>, - 492
pub bell: Option<bool>, - 493
/// Keymap overrides: `"Ctrl-P" = "command-palette"` or - 494
/// `"running|Tab" = "queue"`. - 495
pub keymap: std::collections::BTreeMap<String, String>, - 496
/// `"emacs"` (default) or `"vim"`. - 497
pub composer: Option<String>, - 498
/// Opt-in OSC52 clipboard copy. Never automatic: an explicit user - 499
/// action (Alt-Y / `/copy`) is required even when enabled. - 500
pub osc52: Option<bool>, - 501
#[serde(default)] - 502
pub accessibility: Option<AccessibilitySettings>, - 503
/// Custom theme definitions: `[ui.themes.<name>]` with color keys - 504
/// (`accent`, `dim`, ...) mapped to `#rrggbb` or named colors. Held as - 505
/// raw TOML values so a stray non-string entry warns instead of making - 506
/// the whole config unparseable. - 507
#[serde(default)] - 508
pub themes: std::collections::BTreeMap<String, std::collections::BTreeMap<String, toml::Value>>, - 509
} - 510
- 511
#[derive(Debug, Clone, Deserialize, Default)] - 512
pub struct AccessibilitySettings { - 513
pub plain: Option<bool>, - 514
pub reduced_motion: Option<bool>, - 515
pub screen_reader: Option<bool>, - 516
} - 517
- 518
#[derive(Debug, Clone, Deserialize, Default)] - 519
pub struct StopPolicySettings { - 520
pub enabled: Option<bool>, - 521
pub marker_gate: Option<bool>, - 522
pub verify_gate: Option<bool>, - 523
pub max_blocks: Option<u32>, - 524
} - 525
- 526
/// Spend admission (docs/design/15-reliability.md). Absent prices are UNKNOWN: - 527
/// unpriced models bypass USD math rather than guessing at zero. - 528
#[derive(Debug, Clone, Deserialize, Default)] - 529
#[serde(default)] - 530
pub struct GoalSettings { - 531
pub handoff_reset: Option<bool>, - 532
pub max_audit_blocks: Option<u32>, - 533
} - 534
- 535
#[derive(Debug, Clone, Deserialize, Default)] - 536
#[serde(default)] - 537
pub struct WorkSettings { - 538
pub enabled: Option<bool>, - 539
pub default_mode: Option<String>, - 540
pub max_items: Option<usize>, - 541
pub max_revisions: Option<u32>, - 542
pub max_parallel: Option<usize>, - 543
pub confirmation: Option<String>, - 544
} - 545
- 546
#[derive(Debug, Clone, Deserialize, Default)] - 547
#[serde(default)] - 548
pub struct FinopsSettings { - 549
pub max_run_usd: Option<f64>, - 550
pub max_day_usd: Option<f64>, - 551
/// Exact model id → (input USD/MTok, output USD/MTok). Overrides the - 552
/// built-in heuristic table; estimates stay labeled as estimates. - 553
pub price_overrides: std::collections::BTreeMap<String, PriceEntry>, - 554
} - 555
- 556
/// Capacity-probe cost control (docs/design/68-context-engine.md §1 "Cost - 557
/// control for hosted models"). Local models are always probed in full - 558
/// regardless of this setting; it governs hosted models only. - 559
#[derive(Debug, Clone, Deserialize, Default)] - 560
#[serde(default)] - 561
pub struct ProbeSettings { - 562
/// "none" (default) starts a hosted profile's instruction horizon at - 563
/// its declared window with low confidence, tightened only by - 564
/// feedback; "full" opts in to running the horizon ladder against - 565
/// hosted models too. - 566
pub hosted: Option<String>, - 567
} - 568
- 569
/// Resolved capacity-probe policy. - 570
#[derive(Debug, Clone, PartialEq, Eq)] - 571
pub struct ProbeResolved { - 572
pub hosted: String, - 573
} - 574
- 575
/// Per-provider tuning sections. One field per provider that has knobs - 576
/// beyond credentials/base-url; a provider with nothing to tune has none. - 577
#[derive(Debug, Clone, Deserialize, Default)] - 578
#[serde(default)] - 579
pub struct ProvidersSettings { - 580
pub ollama: OllamaSettings, - 581
pub anthropic: AnthropicSettings, - 582
} - 583
- 584
/// Anthropic provider tuning (docs/design/68-context-engine.md §11 - 585
/// "Anthropic" row, the API's "Fast Mode" quick reference). - 586
#[derive(Debug, Clone, Deserialize, Default, PartialEq, Eq)] - 587
#[serde(default)] - 588
pub struct AnthropicSettings { - 589
/// Opt-in fast-mode research preview: `speed: "fast"` plus the - 590
/// `anthropic-beta: fast-mode-2026-02-01` header, sent only for a model - 591
/// whose discovered capabilities confirm support. Premium pricing and a - 592
/// separate rate-limit bucket, so this defaults to off (`None` resolves - 593
/// to `false`). - 594
pub fast_mode: Option<bool>, - 595
} - 596
- 597
/// Native Ollama provider tuning (docs/design/68-context-engine.md §8): the - 598
/// OpenAI-compatible path silently ignores both of these, so the native - 599
/// `/api/chat` adapter needs them threaded from config. - 600
#[derive(Debug, Clone, Deserialize, Default, PartialEq, Eq)] - 601
#[serde(default)] - 602
pub struct OllamaSettings { - 603
/// Go-style duration string ("10m", "24h", "0"). Sent on every request - 604
/// so the runner does not evict the model under the default 5-minute - 605
/// idle unload. - 606
pub keep_alive: Option<String>, - 607
/// `options.num_ctx`. Must be >= 1024 when set; omitted entirely when - 608
/// `None` so the server's own modelfile default applies. - 609
pub num_ctx: Option<u64>, - 610
} - 611
- 612
impl OllamaSettings { - 613
pub fn validate(&self) -> Result<(), String> { - 614
if let Some(ka) = &self.keep_alive - 615
&& !is_go_duration(ka) - 616
{ - 617
return Err(format!( - 618
"providers.ollama.keep_alive '{ka}' is not a valid Go-style \ - 619
duration (e.g. \"10m\", \"24h\", \"0\")" - 620
)); - 621
} - 622
if let Some(n) = self.num_ctx - 623
&& n < 1024 - 624
{ - 625
return Err("providers.ollama.num_ctx must be >= 1024 when set".into()); - 626
} - 627
Ok(()) - 628
} - 629
} - 630
- 631
/// Minimal Go `time.ParseDuration` shape check: `"0"`, or one or more - 632
/// `<number><unit>` pairs with no separators, units restricted to the ones - 633
/// Ollama's own duration parsing accepts. - 634
fn is_go_duration(s: &str) -> bool { - 635
let s = s.trim(); - 636
if s == "0" { - 637
return true; - 638
} - 639
let mut chars = s.chars().peekable(); - 640
let mut matched_any = false; - 641
while chars.peek().is_some() { - 642
let mut num = String::new(); - 643
while let Some(&c) = chars.peek() { - 644
if c.is_ascii_digit() || c == '.' { - 645
num.push(c); - 646
chars.next(); - 647
} else { - 648
break; - 649
} - 650
} - 651
if num.is_empty() || num == "." { - 652
return false; - 653
} - 654
let mut unit = String::new(); - 655
while let Some(&c) = chars.peek() { - 656
if c.is_alphabetic() || c == '\u{00b5}' { - 657
unit.push(c); - 658
chars.next(); - 659
} else { - 660
break; - 661
} - 662
} - 663
if !matches!( - 664
unit.as_str(), - 665
"ns" | "us" | "\u{00b5}s" | "ms" | "s" | "m" | "h" - 666
) { - 667
return false; - 668
} - 669
matched_any = true; - 670
} - 671
matched_any - 672
} - 673
- 674
/// Frozen-ladder routing preferences (docs/design/15-reliability.md + Phase R). - 675
/// NOT privileged: choosing how to order discovered candidates grants no - 676
/// execution power. - 677
#[derive(Debug, Clone, Deserialize, Default)] - 678
#[serde(default)] - 679
pub struct RouteSettings { - 680
/// "auto" (default) derives utility/balanced/quality-critical from - 681
/// request demand; explicit "utility" | "balanced" | - 682
/// "quality-critical" overrides the derivation. - 683
pub objective: Option<String>, - 684
/// Explicit cross-model fallback allowlist. Model ids here become - 685
/// candidate legs WHEN warm discovery shows a configured key can - 686
/// reach them; empty keeps the legacy same-model-only ladder. - 687
pub fallback_models: Vec<String>, - 688
/// Total ladder length cap INCLUDING the primary leg (default 4). - 689
pub max_fallbacks: Option<usize>, - 690
/// Caller-declared frontier-tier model-id substrings promoted under - 691
/// balanced/quality-critical objectives. Routing knowledge stays - 692
/// operator-supplied, never baked into source (invariant 9). - 693
pub quality_hints: Vec<String>, - 694
/// Model-id substrings that mark a leg as able to serve non-text input - 695
/// (images, audio, …). A vision turn is served only by matching legs; - 696
/// with no hints declared every leg is assumed capable, because a - 697
/// restriction the operator did not state is not ours to invent - 698
/// (docs/design/47-commitment-kernel.md, invariant 10). - 699
pub modality_hints: Vec<String>, - 700
} - 701
- 702
/// Intent kernel (docs/design/47-commitment-kernel.md). - 703
/// - 704
/// PARTLY PRIVILEGED. Most of this section only ever narrows what a turn may - 705
/// do, and a repository choosing to give itself fewer tools is harmless. Two - 706
/// keys are different and are stripped for an untrusted project by - 707
/// `load_with_trust`: - 708
/// - 709
/// * `autonomy` — `delegated` and `autonomous` suppress approval gates the - 710
/// agent would otherwise raise. That is execution power, and a cloned - 711
/// repository must not be able to grant it to itself. - 712
/// * `escalate = "cloud"` — spends the user's credentials on a classification - 713
/// dispatch before the run they actually asked for. - 714
#[derive(Debug, Clone, Deserialize, Default)] - 715
#[serde(default)] - 716
pub struct IntentSettings { - 717
/// Master switch. `false` resolves every turn to the general engagement, - 718
/// which is vak's behaviour before the kernel existed. Default true. - 719
pub enabled: Option<bool>, - 720
/// Confidence at or above which a reading may narrow capability. - 721
pub accept_confidence: Option<f64>, - 722
/// Confidence at or above which a reading may raise risk posture but not - 723
/// remove tools. - 724
pub provisional_confidence: Option<f64>, - 725
/// Allow progressive disclosure of the capability packet. Default true. - 726
pub slice_capabilities: Option<bool>, - 727
/// Allow stakes to raise the approval floor. Default true. - 728
pub posture: Option<bool>, - 729
/// How far the cascade may escalate: "none" | "local" | "cloud". - 730
pub escalate: Option<String>, - 731
/// Model for the classification tier: `model`, or `provider/model`. - 732
/// Local escalation runs it on `ollama`; cloud on the effective - 733
/// provider unless a provider is named. Empty uses the effective route. - 734
pub classify_model: Option<String>, - 735
/// Hard ceiling on one classification dispatch. - 736
pub max_classify_usd: Option<f64>, - 737
/// Watchdog on one classification dispatch, in seconds (default 10). - 738
/// A classifier that overruns it is abandoned and the free-tier reading - 739
/// stands; the run never waits on it. - 740
pub classify_timeout_secs: Option<u64>, - 741
/// Standing delegation: "manual" | "assisted" | "delegated" | "autonomous". - 742
pub autonomy: Option<String>, - 743
pub evidence_max_age_secs: Option<i64>, - 744
} - 745
- 746
/// Durable commitments (docs/design/47-commitment-kernel.md). NOT privileged: - 747
/// every key here bounds long-running work rather than enabling it. - 748
#[derive(Debug, Clone, Deserialize, Default)] - 749
#[serde(default)] - 750
pub struct CommitmentSettings { - 751
/// Open durable commitments for session-or-longer work. Default true. - 752
pub enabled: Option<bool>, - 753
/// Lifetime spend cap per commitment. None inherits the FinOps caps only. - 754
pub lifetime_budget_usd: Option<f64>, - 755
/// Consecutive stalled episodes before the stall breaker trips. - 756
pub stall_limit: Option<u32>, - 757
/// Surface a commitment for human review after this long untouched. - 758
pub review_every_hours: Option<u32>, - 759
/// Default relevance window. A commitment past it closes `expired` - 760
/// explicitly rather than lingering. - 761
pub default_ttl_days: Option<u32>, - 762
} - 763
- 764
/// Scheduled-task behavior (docs/design/29-personal-os.md P2). NOT - 765
/// privileged: catch-up only widens when an already-configured task may run. - 766
#[derive(Debug, Clone, Deserialize, Default)] - 767
#[serde(default)] - 768
pub struct AutomationSettings { - 769
/// Run tasks that missed their schedule while the app was shut down. - 770
/// Default true. - 771
pub catch_up_missed: Option<bool>, - 772
} - 773
- 774
/// Opt-in update awareness (docs/design/29-personal-os.md P3). A `None` - 775
/// url disables update checks entirely; checks never auto-install. - 776
#[derive(Debug, Clone, Deserialize, Default)] - 777
#[serde(default)] - 778
pub struct UpdateSettings { - 779
/// Version-manifest URL polled for update banners. Default: none - 780
/// (update checks fully disabled). - 781
pub url: Option<String>, - 782
/// Hours between update checks (default 24). - 783
pub interval_hours: Option<u64>, - 784
} - 785
- 786
/// Master switches for optional built-in tool registration. - 787
#[derive(Debug, Clone, Deserialize, Default)] - 788
#[serde(default)] - 789
pub struct ToolsSettings { - 790
/// Register the bounded webfetch tool. Default true; network access is - 791
/// still permission-classified per request. - 792
pub web_fetch: Option<bool>, - 793
/// Register the headless-browser DOM render tool (`browse`). Default - 794
/// true; requires a locally installed Chromium-family browser and is - 795
/// still permission-classified per request. - 796
pub browse: Option<bool>, - 797
} - 798
- 799
/// Proactive heartbeat (docs/design/29-personal-os.md P7). NOT privileged: - 800
/// it spends this server's own configured credentials on a bounded review - 801
/// turn, never grants new execution power. - 802
#[derive(Debug, Clone, Deserialize, Default)] - 803
#[serde(default)] - 804
pub struct HeartbeatSettings { - 805
pub enabled: Option<bool>, - 806
/// Seconds between review turns (default 1800, minimum 300). - 807
pub interval_secs: Option<u64>, - 808
/// Model pin ("model" or "provider/model"); default keeps the - 809
/// provider's current model. - 810
pub model: Option<String>, - 811
/// Local-time quiet window "HH:MM-HH:MM" during which cycles skip. - 812
/// Wraps midnight ("22:00-07:00"). - 813
pub quiet_hours: Option<String>, - 814
/// Maximum findings reported per beat (default 3). - 815
pub max_findings: Option<usize>, - 816
} - 817
- 818
/// Feed pipeline settings. Read-only and workspace-scoped. - 819
#[derive(Debug, Clone, Deserialize, Default)] - 820
#[serde(default)] - 821
pub struct FeedSettings { - 822
/// Enable the feed pipeline. Default false. - 823
pub enabled: Option<bool>, - 824
/// Path to feeds.toml config file. None = auto-detect. - 825
pub config_path: Option<String>, - 826
/// Path to the DuckDB database file. None = auto-detect. - 827
pub db_path: Option<String>, - 828
/// Default check interval for sources (e.g. "30m", "1h"). - 829
pub default_check_interval: Option<String>, - 830
/// Maximum items to keep per feed. - 831
pub max_items_per_feed: Option<u32>, - 832
/// Days to keep dedup hashes. - 833
pub dedup_window_days: Option<u32>, - 834
} - 835
- 836
/// Resolved feed pipeline settings. - 837
#[derive(Debug, Clone)] - 838
pub struct FeedResolved { - 839
pub enabled: bool, - 840
pub config_path: Option<String>, - 841
pub db_path: Option<String>, - 842
pub default_check_interval: String, - 843
pub max_items_per_feed: u32, - 844
pub dedup_window_days: u32, - 845
} - 846
- 847
#[derive(Debug, Clone, Deserialize, PartialEq)] - 848
pub struct PriceEntry { - 849
pub input: f64, - 850
pub output: f64, - 851
} - 852
- 853
#[derive(Debug, Clone, Deserialize, Default)] - 854
pub struct McpConfig { - 855
#[serde(default)] - 856
pub servers: std::collections::BTreeMap<String, McpServerConfig>, - 857
} - 858
- 859
#[derive(Debug, Clone, Serialize, Deserialize)] - 860
pub struct McpServerConfig { - 861
pub command: String, - 862
#[serde(default)] - 863
pub args: Vec<String>, - 864
#[serde(default)] - 865
pub env: std::collections::BTreeMap<String, String>, - 866
/// Allow outbound network for this MCP server. Privileged (mcp.servers - 867
/// is stripped from untrusted projects). - 868
#[serde(default)] - 869
pub network: bool, - 870
/// What this server is for, in its own words: `serves = ["live-data"]`. - 871
/// - 872
/// Optional, and deliberately so. It decides whether a call to this - 873
/// server counts as retrieval that an answer must be grounded in; an - 874
/// empty list means *undeclared*, and the server inherits the `mcp` - 875
/// broker's web/live-data claim. It never hides the server from a turn. - 876
/// The alternative, guessing a domain from the server's tool names, - 877
/// would put a keyword table back in the harness and reintroduce the - 878
/// coupling this field exists to remove. - 879
/// - 880
/// Skipped when empty so the config file and the management API keep - 881
/// exactly the shape they had before this field existed — a server that - 882
/// declares nothing should look no different from one written last year. - 883
#[serde(default, skip_serializing_if = "Vec::is_empty")] - 884
pub serves: Vec<String>, - 885
} - 886
- 887
/// Project-layer switches for severing one inherited capability category. - 888
/// Missing means inherit. User-layer values are accepted but only become - 889
/// meaningful when a narrower layer is merged over them. - 890
#[derive(Debug, Clone, Deserialize, Default)] - 891
#[serde(default)] - 892
pub struct CapabilityInheritanceSettings { - 893
pub inherit_mcp: Option<bool>, - 894
pub inherit_hooks: Option<bool>, - 895
pub inherit_skills: Option<bool>, - 896
pub inherit_commands: Option<bool>, - 897
pub inherit_plugins: Option<bool>, - 898
} - 899
- 900
#[derive(Debug, Clone)] - 901
pub struct CapabilityInheritanceResolved { - 902
pub inherit_mcp: bool, - 903
pub inherit_hooks: bool, - 904
pub inherit_skills: bool, - 905
pub inherit_commands: bool, - 906
pub inherit_plugins: bool, - 907
} - 908
- 909
/// Global and workspace settings governing capability plugins. - 910
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq, Eq)] - 911
#[serde(default)] - 912
pub struct PluginSettings { - 913
/// Explicitly enabled plugin names. - 914
pub enabled: Vec<String>, - 915
/// Explicitly disabled plugin names. - 916
pub disabled: Vec<String>, - 917
/// Optional allowlist of permitted plugin names. If specified, only matching plugins may be enabled. - 918
pub allow: Option<Vec<String>>, - 919
/// Denylist of forbidden plugin names. Deny always takes precedence over allow. - 920
pub deny: Vec<String>, - 921
/// Plugins permitted outbound network access. Privileged. - 922
pub network_allow: Option<Vec<String>>, - 923
/// Plugins forbidden outbound network access. Precedence: an entry - 924
/// here always beats `network_allow` (channel `plugins_network_deny` - 925
/// layers on top of both and can only take egress away). - 926
pub network_deny: Vec<String>, - 927
} - 928
- 929
/// Resolved plugin policy across global and workspace layers. - 930
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)] - 931
pub struct PluginResolved { - 932
pub enabled: Vec<String>, - 933
pub disabled: Vec<String>, - 934
pub allow: Option<Vec<String>>, - 935
pub deny: Vec<String>, - 936
pub network_allow: Option<Vec<String>>, - 937
pub network_deny: Vec<String>, - 938
} - 939
- 940
impl PluginResolved { - 941
pub fn is_enabled(&self, name: &str) -> bool { - 942
// Deny always wins - 943
if self.deny.iter().any(|d| d == name || d == "*") { - 944
return false; - 945
} - 946
if self.disabled.iter().any(|d| d == name) { - 947
return false; - 948
} - 949
if let Some(allow) = &self.allow { - 950
return allow.iter().any(|a| a == name || a == "*"); - 951
} - 952
if !self.enabled.is_empty() { - 953
return self.enabled.iter().any(|e| e == name || e == "*"); - 954
} - 955
true - 956
} - 957
- 958
pub fn is_network_allowed(&self, name: &str) -> bool { - 959
if !self.is_enabled(name) { - 960
return false; - 961
} - 962
if self.network_deny.iter().any(|d| d == name || d == "*") { - 963
return false; - 964
} - 965
if let Some(allow) = &self.network_allow { - 966
return allow.iter().any(|a| a == name || a == "*"); - 967
} - 968
false - 969
} - 970
} - 971
- 972
/// Restrictive capability overlay for a gateway channel. `None` means inherit - 973
/// the workspace policy; `Some([])` means deny everything in that category. - 974
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - 975
#[serde(default)] - 976
pub struct ChannelPolicy { - 977
pub tools_allow: Option<Vec<String>>, - 978
pub tools_deny: Vec<String>, - 979
pub mcp_allow: Option<Vec<String>>, - 980
pub mcp_deny: Vec<String>, - 981
pub skills_allow: Option<Vec<String>>, - 982
pub skills_deny: Vec<String>, - 983
pub hooks_allow: Option<Vec<String>>, - 984
pub hooks_deny: Vec<String>, - 985
/// Server-name patterns (matched the same way as `mcp_allow`/`mcp_deny`) - 986
/// for which this channel forces outbound network off, even when the - 987
/// server's own `McpServerConfig.network` is `true`. Restrictive only — - 988
/// there is deliberately no matching "network_allow": a channel can - 989
/// only take network access away from a server it can already reach, - 990
/// never grant it to one the server config itself denies. - 991
pub mcp_network_deny: Vec<String>, - 992
/// Plugin-name patterns for which this channel forces outbound network off. - 993
pub plugins_network_deny: Vec<String>, - 994
/// Optional allowlist of plugin names permitted on this channel. - 995
pub plugins_allow: Option<Vec<String>>, - 996
/// Denylist of plugin names forbidden on this channel. - 997
pub plugins_deny: Vec<String>, - 998
/// Autonomy ceiling for this channel (docs/design/47-commitment-kernel.md). - 999
/// - 1000
/// **Restrictive only**, like everything else on this type: a channel may - 1001
/// cap delegation below what the workspace granted, never raise it. That - 1002
/// asymmetry is the point — a Telegram chat should be able to say "propose - 1003
/// only, in here", and must never be able to say "act freely" on a - 1004
/// workspace whose operator did not. - 1005
/// - 1006
/// `None` inherits. Values: `manual` | `assisted` | `delegated` | - 1007
/// `autonomous`. - 1008
pub autonomy_ceiling: Option<String>, - 1009
} - 1010
- 1011
/// Rank an autonomy name, mirroring `vak_intent::Autonomy::rank`. - 1012
/// - 1013
/// Duplicated rather than imported because `vak-config` deliberately does not - 1014
/// depend on the intent kernel; the ranking is asserted equal by a test in - 1015
/// `vak-core`, which sees both. - 1016
fn autonomy_rank(name: &str) -> u8 { - 1017
match name { - 1018
"manual" => 0, - 1019
"assisted" => 1, - 1020
"delegated" => 2, - 1021
"autonomous" => 3, - 1022
_ => 1, - 1023
} - 1024
} - 1025
- 1026
impl ChannelPolicy { - 1027
/// The least-delegated of two autonomy ceilings. `None` on either side - 1028
/// means "says nothing", not "allows everything". - 1029
pub fn cap_autonomy(lower: Option<&str>, higher: Option<&str>) -> Option<String> { - 1030
match (lower, higher) { - 1031
(None, None) => None, - 1032
(Some(one), None) | (None, Some(one)) => Some(one.to_string()), - 1033
(Some(a), Some(b)) => Some( - 1034
if autonomy_rank(b) < autonomy_rank(a) { - 1035
b - 1036
} else { - 1037
a - 1038
} - 1039
.to_string(), - 1040
), - 1041
} - 1042
} - 1043
- 1044
/// Fold a lower tier (e.g. bot) and a higher tier (e.g. chat) into the - 1045
/// single effective policy applied at dispatch. Restrictive-only: an - 1046
/// `_allow` list from the higher tier wins outright when present (it is - 1047
/// itself already capped against whatever it's allowed to name), a - 1048
/// missing `_allow` falls back to the lower tier's, and `_deny` lists - 1049
/// concatenate across tiers since denies only ever remove, never add, - 1050
/// access. `lower` is the more permissive default (bot), `higher` is - 1051
/// the more specific override (chat). - 1052
pub fn merge(lower: &ChannelPolicy, higher: &ChannelPolicy) -> ChannelPolicy { - 1053
fn merge_allow( - 1054
lower: &Option<Vec<String>>, - 1055
higher: &Option<Vec<String>>, - 1056
) -> Option<Vec<String>> { - 1057
higher.clone().or_else(|| lower.clone()) - 1058
} - 1059
fn merge_deny(lower: &[String], higher: &[String]) -> Vec<String> { - 1060
let mut out = lower.to_vec(); - 1061
for item in higher { - 1062
if !out.contains(item) { - 1063
out.push(item.clone()); - 1064
} - 1065
} - 1066
out - 1067
} - 1068
ChannelPolicy { - 1069
tools_allow: merge_allow(&lower.tools_allow, &higher.tools_allow), - 1070
tools_deny: merge_deny(&lower.tools_deny, &higher.tools_deny), - 1071
mcp_allow: merge_allow(&lower.mcp_allow, &higher.mcp_allow), - 1072
mcp_deny: merge_deny(&lower.mcp_deny, &higher.mcp_deny), - 1073
skills_allow: merge_allow(&lower.skills_allow, &higher.skills_allow), - 1074
skills_deny: merge_deny(&lower.skills_deny, &higher.skills_deny), - 1075
hooks_allow: merge_allow(&lower.hooks_allow, &higher.hooks_allow), - 1076
hooks_deny: merge_deny(&lower.hooks_deny, &higher.hooks_deny), - 1077
mcp_network_deny: merge_deny(&lower.mcp_network_deny, &higher.mcp_network_deny), - 1078
plugins_network_deny: merge_deny( - 1079
&lower.plugins_network_deny, - 1080
&higher.plugins_network_deny, - 1081
), - 1082
plugins_allow: merge_allow(&lower.plugins_allow, &higher.plugins_allow), - 1083
plugins_deny: merge_deny(&lower.plugins_deny, &higher.plugins_deny), - 1084
autonomy_ceiling: Self::cap_autonomy( - 1085
lower.autonomy_ceiling.as_deref(), - 1086
higher.autonomy_ceiling.as_deref(), - 1087
), - 1088
} - 1089
} - 1090
} - 1091
- 1092
/// Optional spoken voice + persona for a bot/chat, resolved through the - 1093
/// same bot→chat inheritance idiom as `route`/`permission_mode` (see - 1094
/// `GatewayState::core_for_entry` in vak-server::gateway). `None` on a - 1095
/// field means "no override for that piece"; the whole `VoiceConfig` being - 1096
/// `None` on the entity means "inherit the parent tier's voice entirely". - 1097
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)] - 1098
pub struct VoiceConfig { - 1099
/// Provider override for voice operations at this scope. - 1100
#[serde(default, skip_serializing_if = "Option::is_none")] - 1101
pub provider: Option<String>, - 1102
/// Live API prebuilt voice name, e.g. "Kore", "Puck", "Zephyr". - 1103
#[serde(default, skip_serializing_if = "Option::is_none")] - 1104
pub voice_name: Option<String>, - 1105
/// Provider model override for transcription at this scope. - 1106
#[serde(default, skip_serializing_if = "Option::is_none")] - 1107
pub transcription_model: Option<String>, - 1108
/// Provider model override for synthesis at this scope. - 1109
#[serde(default, skip_serializing_if = "Option::is_none")] - 1110
pub synthesis_model: Option<String>, - 1111
/// **Deprecated** (docs/design/45-prompt-layers.md): the bot/chat - 1112
/// `identity` prompt block is the persona now, so a bot's spoken and - 1113
/// written selves cannot drift apart. Still read as a fallback when no - 1114
/// prompt tier sets an identity, and still honoured as an explicit - 1115
/// per-request override, so existing configs keep working. New writes - 1116
/// should set the `identity` block instead. - 1117
#[serde(default, skip_serializing_if = "Option::is_none")] - 1118
pub persona: Option<String>, - 1119
} - 1120
- 1121
impl VoiceConfig { - 1122
/// Overlay a narrower scope onto its parent. Missing fields inherit. - 1123
pub fn overlay(parent: Option<&Self>, child: &Self) -> Self { - 1124
Self { - 1125
provider: child - 1126
.provider - 1127
.clone() - 1128
.or_else(|| parent.and_then(|v| v.provider.clone())), - 1129
voice_name: child - 1130
.voice_name - 1131
.clone() - 1132
.or_else(|| parent.and_then(|v| v.voice_name.clone())), - 1133
transcription_model: child - 1134
.transcription_model - 1135
.clone() - 1136
.or_else(|| parent.and_then(|v| v.transcription_model.clone())), - 1137
synthesis_model: child - 1138
.synthesis_model - 1139
.clone() - 1140
.or_else(|| parent.and_then(|v| v.synthesis_model.clone())), - 1141
persona: child - 1142
.persona - 1143
.clone() - 1144
.or_else(|| parent.and_then(|v| v.persona.clone())), - 1145
} - 1146
} - 1147
} - 1148
- 1149
// Note: the `Bot` entity itself (id/surface/label/token_env/policy/ - 1150
// permission_mode/route/workspace) lives in `vak-server::gateway` next to - 1151
// `AllowlistEntry` and `AllowlistRoute`, since it needs `AllowlistRoute` and - 1152
// vak-config must not depend on vak-server. It reuses `ChannelPolicy::merge` - 1153
// and `PermissionMode::capped_by` from here for its slot in the bot → chat → - 1154
// workspace resolution chain. - 1155
- 1156
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] - 1157
pub struct HookConfig { - 1158
pub event: String, - 1159
#[serde(rename = "match")] - 1160
pub matcher: Option<String>, - 1161
pub command: String, - 1162
pub timeout_ms: Option<u64>, - 1163
/// Missing in an existing `config.toml` means enabled — this field was - 1164
/// added after `[[hooks]]` shipped without one, and every hook written - 1165
/// before it must keep firing. - 1166
#[serde(default = "default_hook_config_enabled")] - 1167
pub enabled: bool, - 1168
#[serde(default)] - 1169
pub failure_mode: Option<String>, - 1170
} - 1171
- 1172
/// Add the built-in disabled automation templates to the Shared layer once. - 1173
/// Existing operator hooks are preserved byte-for-byte in the same atomic - 1174
/// rewrite used by every other persisted configuration mutation. - 1175
pub fn seed_global_hooks_if_empty(hooks: &[HookConfig]) -> Result<bool, ConfigError> { - 1176
let path = global_path().ok_or_else(|| ConfigError::Write { - 1177
path: PathBuf::from("<shared>"), - 1178
source: std::io::Error::other("shared workspace unavailable"), - 1179
})?; - 1180
update_config_file(&path, |document| { - 1181
if document - 1182
.get("hooks") - 1183
.and_then(toml::Value::as_array) - 1184
.is_some_and(|existing| !existing.is_empty()) - 1185
{ - 1186
return Ok(false); - 1187
} - 1188
document.insert("hooks".into(), encode_hooks(&path, hooks)?); - 1189
Ok(true) - 1190
}) - 1191
} - 1192
- 1193
/// Replace the `[[hooks]]` list in the configuration file at `path`, - 1194
/// leaving every other key alone. A disabled hook is written with - 1195
/// `enabled = false`, never dropped (invariant 21). - 1196
pub fn persist_hooks(path: &Path, hooks: &[HookConfig]) -> Result<(), ConfigError> { - 1197
update_config_file(path, |document| { - 1198
document.insert("hooks".into(), encode_hooks(path, hooks)?); - 1199
Ok(()) - 1200
}) - 1201
} - 1202
- 1203
fn encode_hooks(path: &Path, hooks: &[HookConfig]) -> Result<toml::Value, ConfigError> { - 1204
hooks - 1205
.iter() - 1206
.map(toml::Value::try_from) - 1207
.collect::<Result<Vec<_>, _>>() - 1208
.map(toml::Value::Array) - 1209
.map_err(|error| ConfigError::Write { - 1210
path: path.to_path_buf(), - 1211
source: std::io::Error::other(error.to_string()), - 1212
}) - 1213
} - 1214
- 1215
/// Seed the default execution plugin policy into the given config file's - 1216
/// `[plugins] network_allow` table if unconfigured. - 1217
pub fn seed_plugins_network_allow_if_empty(path: &Path) -> Result<bool, ConfigError> { - 1218
update_config_file(path, |document| { - 1219
let plugins = child_table(document, "plugins", path)?; - 1220
if plugins.contains_key("network_allow") { - 1221
return Ok(false); - 1222
} - 1223
plugins.insert("network_allow".into(), toml::Value::Array(Vec::new())); - 1224
Ok(true) - 1225
}) - 1226
} - 1227
- 1228
/// Seed the Shared layer's `[plugins] network_allow` table once if unconfigured. - 1229
pub fn seed_global_plugins_network_allow_if_empty() -> Result<bool, ConfigError> { - 1230
let path = global_path().ok_or_else(|| ConfigError::Write { - 1231
path: PathBuf::from("<shared>"), - 1232
source: std::io::Error::other("shared workspace unavailable"), - 1233
})?; - 1234
seed_plugins_network_allow_if_empty(&path) - 1235
} - 1236
- 1237
/// Remove a plugin name from `[plugins] network_allow` in the config at `path`. - 1238
/// Called during retired-plugin cleanup so the allowlist stays consistent - 1239
/// with the on-disk plugin store. Silently succeeds if the entry, or the - 1240
/// file, was not present. - 1241
pub fn prune_plugins_network_allow(path: &Path, plugin_name: &str) -> Result<bool, ConfigError> { - 1242
update_config_file(path, |document| { - 1243
let Some(allow) = document - 1244
.get_mut("plugins") - 1245
.and_then(toml::Value::as_table_mut) - 1246
.and_then(|plugins| plugins.get_mut("network_allow")) - 1247
.and_then(toml::Value::as_array_mut) - 1248
else { - 1249
return Ok(false); - 1250
}; - 1251
let before = allow.len(); - 1252
allow.retain(|name| name.as_str() != Some(plugin_name)); - 1253
Ok(allow.len() != before) - 1254
}) - 1255
} - 1256
- 1257
fn default_hook_config_enabled() -> bool { - 1258
true - 1259
} - 1260
- 1261
#[derive(Debug, Clone)] - 1262
pub struct Config { - 1263
pub provider: String, - 1264
pub model: String, - 1265
pub max_tokens: u32, - 1266
pub max_turns: usize, - 1267
pub permission_mode: PermissionMode, - 1268
pub approval_mode: ApprovalMode, - 1269
pub anthropic_base_url: Option<String>, - 1270
pub allow: Vec<String>, - 1271
pub ask: Vec<String>, - 1272
pub deny: Vec<String>, - 1273
pub workers: bool, - 1274
pub hooks: Vec<HookConfig>, - 1275
pub max_retries: u32, - 1276
pub retry_base_backoff_ms: u64, - 1277
pub request_timeout_secs: u64, - 1278
pub run_retry_attempts: u32, - 1279
pub run_retry_base_backoff_ms: u64, - 1280
pub circuit_breaker_threshold: u32, - 1281
pub circuit_breaker_cooldown_secs: u64, - 1282
pub context_window: u64, - 1283
pub mcp: McpConfig, - 1284
pub capabilities: CapabilityInheritanceResolved, - 1285
pub ui: UiResolved, - 1286
pub stop_policy: StopPolicyResolved, - 1287
pub gateway: GatewayResolved, - 1288
pub memory: MemoryResolved, - 1289
pub sandbox: SandboxResolved, - 1290
pub finops: FinopsResolved, - 1291
pub goal: GoalResolved, - 1292
pub work: WorkResolved, - 1293
pub route: RouteResolved, - 1294
pub probe: ProbeResolved, - 1295
pub intent: IntentResolved, - 1296
pub commitment: CommitmentResolved, - 1297
pub automation: AutomationResolved, - 1298
pub update: UpdateResolved, - 1299
pub tools: ToolsResolved, - 1300
pub heartbeat: HeartbeatResolved, - 1301
pub feeds: FeedResolved, - 1302
pub server: ServerResolved, - 1303
pub plugins: PluginResolved, - 1304
pub voice: VoiceSettings, - 1305
pub ollama: OllamaResolved, - 1306
pub anthropic: AnthropicResolved, - 1307
pub warnings: Vec<String>, - 1308
} - 1309
- 1310
/// Resolved heartbeat policy (docs/design/29-personal-os.md P7). - 1311
#[derive(Debug, Clone, PartialEq, Eq)] - 1312
pub struct HeartbeatResolved { - 1313
pub enabled: bool, - 1314
pub interval_secs: u64, - 1315
/// Model pin; None keeps the provider's current model. - 1316
pub model: Option<String>, - 1317
/// Parsed quiet window; None means cycles may fire any time. - 1318
pub quiet_hours: Option<QuietWindow>, - 1319
pub max_findings: usize, - 1320
} - 1321
- 1322
/// Local-time quiet window parsed from "HH:MM-HH:MM". `start_min` is - 1323
/// inclusive, `end_min` exclusive, and the window may wrap midnight. - 1324
#[derive(Debug, Clone, Copy, PartialEq, Eq)] - 1325
pub struct QuietWindow { - 1326
pub start_min: u32, - 1327
pub end_min: u32, - 1328
} - 1329
- 1330
impl QuietWindow { - 1331
/// Parses "HH:MM-HH:MM". A zero-length window is rejected as - 1332
/// meaningless rather than treated as empty or full-day. - 1333
pub fn parse(s: &str) -> Option<Self> { - 1334
let (a, b) = s.split_once('-')?; - 1335
let start_min = parse_hhmm(a.trim())?; - 1336
let end_min = parse_hhmm(b.trim())?; - 1337
if start_min == end_min { - 1338
return None; - 1339
} - 1340
Some(QuietWindow { start_min, end_min }) - 1341
} - 1342
- 1343
/// True when `minutes_from_midnight` falls inside the window. The - 1344
/// start bound is inclusive, the end exclusive. - 1345
pub fn contains(&self, minutes_from_midnight: u32) -> bool { - 1346
let t = minutes_from_midnight % (24 * 60); - 1347
if self.start_min < self.end_min { - 1348
t >= self.start_min && t < self.end_min - 1349
} else { - 1350
t >= self.start_min || t < self.end_min - 1351
} - 1352
} - 1353
} - 1354
- 1355
fn parse_hhmm(s: &str) -> Option<u32> { - 1356
let (h, m) = s.split_once(':')?; - 1357
let h: u32 = h.trim().parse().ok()?; - 1358
let m: u32 = m.trim().parse().ok()?; - 1359
if h > 23 || m > 59 { - 1360
return None; - 1361
} - 1362
Some(h * 60 + m) - 1363
} - 1364
- 1365
/// Resolved goal-mode policy (docs/design/42-managed-work-contracts.md). - 1366
#[derive(Debug, Clone, PartialEq, Eq)] - 1367
pub struct GoalResolved { - 1368
/// Reset-with-handoff rescue on still-over contexts. - 1369
pub handoff_reset: bool, - 1370
/// Audit blocks per goal before degrading to Unverified. - 1371
pub max_audit_blocks: u32, - 1372
} - 1373
- 1374
#[derive(Debug, Clone, PartialEq, Eq)] - 1375
pub struct WorkResolved { - 1376
pub enabled: bool, - 1377
pub default_mode: String, - 1378
pub max_items: usize, - 1379
pub max_revisions: u32, - 1380
pub max_parallel: usize, - 1381
pub confirmation: String, - 1382
} - 1383
- 1384
/// Resolved spend-admission policy (docs/design/15-reliability.md). - 1385
#[derive(Debug, Clone, Default, PartialEq)] - 1386
pub struct FinopsResolved { - 1387
pub max_run_usd: Option<f64>, - 1388
pub max_day_usd: Option<f64>, - 1389
pub price_overrides: std::collections::BTreeMap<String, PriceEntry>, - 1390
} - 1391
- 1392
/// Resolved routing policy (Phase R). - 1393
#[derive(Debug, Clone, PartialEq, Eq)] - 1394
pub struct RouteResolved { - 1395
/// "auto" | "utility" | "balanced" | "quality-critical". - 1396
pub objective: String, - 1397
/// Cross-model fallback allowlist (exact model ids). - 1398
pub fallback_models: Vec<String>, - 1399
/// Total ladder length cap including the primary leg. - 1400
pub max_fallbacks: usize, - 1401
/// Frontier-tier model-id substrings (lowercased for matching). - 1402
pub quality_hints: Vec<String>, - 1403
/// Model-id substrings that can serve non-text modalities (lowercased). - 1404
pub modality_hints: Vec<String>, - 1405
} - 1406
- 1407
/// Resolved intent-kernel policy. - 1408
#[derive(Debug, Clone, PartialEq)] - 1409
pub struct IntentResolved { - 1410
pub enabled: bool, - 1411
pub accept_confidence: f64, - 1412
pub provisional_confidence: f64, - 1413
pub slice_capabilities: bool, - 1414
pub posture: bool, - 1415
/// "none" | "local" | "cloud". - 1416
pub escalate: String, - 1417
pub classify_model: Option<String>, - 1418
pub max_classify_usd: f64, - 1419
pub classify_timeout_secs: u64, - 1420
/// Standing delegation for this workspace. - 1421
pub autonomy: String, - 1422
pub evidence_max_age_secs: i64, - 1423
} - 1424
- 1425
/// Resolved durable-commitment policy. - 1426
#[derive(Debug, Clone, PartialEq)] - 1427
pub struct CommitmentResolved { - 1428
pub enabled: bool, - 1429
pub lifetime_budget_usd: Option<f64>, - 1430
pub stall_limit: u32, - 1431
pub review_every_hours: Option<u32>, - 1432
pub default_ttl_days: Option<u32>, - 1433
} - 1434
- 1435
#[derive(Debug, Clone, PartialEq, Eq)] - 1436
pub struct UiResolved { - 1437
/// Built-in theme name, or any name defined in `ui.themes`; unknown - 1438
/// values normalize to "dark". - 1439
pub theme: String, - 1440
pub bell: bool, - 1441
/// Keymap overrides merged project-over-user. - 1442
pub keymap: std::collections::BTreeMap<String, String>, - 1443
pub composer: String, - 1444
pub osc52: bool,
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.