1use sim_cookbook::fnv1a64_hex;
4
5#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct SelfHostingScenario {
8 pub id: &'static str,
10 pub title: &'static str,
12 pub runner_mode: &'static str,
14 pub live_model: bool,
16 pub network: bool,
18 pub evidence: &'static [&'static str],
20 pub roles: &'static [&'static str],
22 pub cassette_events: &'static [&'static str],
24 pub cassette_hash: &'static str,
26}
27
28pub fn self_hosting_scenarios() -> Vec<SelfHostingScenario> {
30 vec![
31 SelfHostingScenario {
32 id: "atelier-radar-standard-crate",
33 title: "Retrieval Radar standard crate",
34 runner_mode: "fake",
35 live_model: false,
36 network: false,
37 evidence: &["radar", "ranked-hints", "confidence"],
38 roles: &["cartographer"],
39 cassette_events: &[
40 "fake-runner:load-index:sim-kernel",
41 "radar-query:standard-crate-operations",
42 "rank:hints:3",
43 "explain:confidence:0.91",
44 ],
45 cassette_hash: "fnv1a64:7f9f5b6c744aa528",
46 },
47 SelfHostingScenario {
48 id: "atelier-runtime-operation",
49 title: "Runtime operation edit loop",
50 runner_mode: "fake",
51 live_model: false,
52 network: false,
53 evidence: &[
54 "runtime-operation",
55 "rustdoc",
56 "codec-prism",
57 "generated-docs",
58 "validation",
59 "pin-plan",
60 ],
61 roles: &["editor", "validator", "docs-agent", "pin-agent"],
62 cassette_events: &[
63 "fake-runner:open-runtime-op-descriptor",
64 "editor:add-operation:sample-op",
65 "codec-prism:lisp-json-roundtrip",
66 "validate:meta-check",
67 "pin-plan:sim-runtime",
68 ],
69 cassette_hash: "fnv1a64:8a3282f3c7ef34b2",
70 },
71 SelfHostingScenario {
72 id: "atelier-codec-roundtrip",
73 title: "Codec round-trip fixture",
74 runner_mode: "fake",
75 live_model: false,
76 network: false,
77 evidence: &["codec-prism", "roundtrip", "semantic-id", "simdoc"],
78 roles: &["editor", "validator"],
79 cassette_events: &[
80 "fake-runner:load-codec-fixture",
81 "codec-prism:lisp-json-algol-roundtrip",
82 "assert:semantic-id-stable",
83 "docs:simdoc-check",
84 ],
85 cassette_hash: "fnv1a64:32be093d6f32315a",
86 },
87 SelfHostingScenario {
88 id: "atelier-guideline-firewall",
89 title: "Guideline Firewall bad fixture",
90 runner_mode: "fake",
91 live_model: false,
92 network: false,
93 evidence: &["guideline-firewall", "rule-evidence", "refused-capability"],
94 roles: &["guard", "reviewer"],
95 cassette_events: &[
96 "fake-runner:load-bad-fixture",
97 "guard:present-tense-public-docs",
98 "refuse:EditRepo(sim-web)",
99 "evidence:past-tense-wording",
100 ],
101 cassette_hash: "fnv1a64:768ad342812bdd9a",
102 },
103 SelfHostingScenario {
104 id: "atelier-change-capsule",
105 title: "Multi-agent Change Capsule",
106 runner_mode: "cassette",
107 live_model: false,
108 network: false,
109 evidence: &[
110 "change-capsule",
111 "validation",
112 "docs",
113 "pin-plan",
114 "human-gate",
115 "replay-hash",
116 ],
117 roles: &[
118 "cartographer",
119 "editor",
120 "guard",
121 "validator",
122 "docs-agent",
123 "pin-agent",
124 "reviewer",
125 "human-gate",
126 ],
127 cassette_events: &[
128 "cassette-runner:cartographer-scope",
129 "fake-runner:editor-patch",
130 "fake-runner:guard-approve",
131 "process:validator-pass",
132 "process:docs-agent-pass",
133 "fake-runner:pin-agent-plan",
134 "fake-runner:reviewer-summary",
135 "human-gate:approved",
136 "replay:hash-match",
137 ],
138 cassette_hash: "fnv1a64:5ec7c4222478f8f1",
139 },
140 ]
141}
142
143pub fn validate_self_hosting_scenarios(scenarios: &[SelfHostingScenario]) -> Vec<String> {
145 let mut failures = Vec::new();
146 for scenario in scenarios {
147 if scenario.runner_mode != "fake" && scenario.runner_mode != "cassette" {
148 failures.push(format!("{} uses unsupported runner", scenario.id));
149 }
150 if scenario.live_model {
151 failures.push(format!("{} uses a live model", scenario.id));
152 }
153 if scenario.network {
154 failures.push(format!("{} uses network access", scenario.id));
155 }
156 if scenario.evidence.is_empty() {
157 failures.push(format!("{} has no evidence", scenario.id));
158 }
159 let actual_hash = cassette_content_hash(scenario.cassette_events);
160 if actual_hash != scenario.cassette_hash {
161 failures.push(format!(
162 "{} cassette hash mismatch: expected {}, got {}",
163 scenario.id, scenario.cassette_hash, actual_hash
164 ));
165 }
166 }
167 failures
168}
169
170pub fn cassette_content_hash(events: &[&str]) -> String {
172 let mut bytes = Vec::new();
173 for event in events {
174 bytes.extend_from_slice(event.as_bytes());
175 }
176 format!("fnv1a64:{}", fnv1a64_hex(&bytes))
177}