- 1001
assert_eq!(rec3.attempts, 1); - 1002
- 1003
// Step 4: mark failed again - 1004
let rec4 = outbox.mark_failed("sweep", "error2").expect("fail2"); - 1005
assert_eq!(rec4.attempts, 2); - 1006
- 1007
// Step 5: deliver - 1008
let packet = render(&job).expect("render"); - 1009
let rec5 = outbox.mark_delivered("sweep", packet).expect("deliver"); - 1010
assert_eq!(rec5.state, OutboxState::Delivered); - 1011
assert_eq!(rec5.attempts, 3); - 1012
- 1013
// Step 6: pending should be empty - 1014
let pending = outbox.pending().expect("pending"); - 1015
assert!(pending.is_empty(), "pending not empty after deliver"); - 1016
- 1017
// Step 7: list contains the delivered record - 1018
let records = outbox.list().expect("list"); - 1019
assert!(records.iter().any(|r| r.state == OutboxState::Delivered)); - 1020
- 1021
let _ = std::fs::remove_dir_all(&root); - 1022
})); - 1023
} - 1024
- 1025
run("blue_team_outbox_state_machine", scenarios); - 1026
} - 1027
- 1028
#[test] - 1029
fn blue_team_signal_extraction_accuracy() { - 1030
let mut scenarios: Vec<Scenario> = vec![]; - 1031
- 1032
let cases: Vec<(&str, &[&str])> = vec![ - 1033
( - 1034
"temperature is 25c forecast tomorrow", - 1035
&["temperature", "forecast"], - 1036
), - 1037
("diff --git a main.rs b main.rs", &["diff"]), - 1038
( - 1039
"benchmark results 1000 req/sec p99", - 1040
&["benchmark", "telemetry"], - 1041
), - 1042
("https://arxiv.org/abs/1234 file.pdf", &["citations"]), - 1043
( - 1044
"recipe ingredients: flour, sugar, eggs", - 1045
&["recipe", "ingredients"], - 1046
), - 1047
("docker run container with image nginx", &["docker"]), - 1048
( - 1049
"chart and telemetry data visualization", - 1050
&["chart", "telemetry"], - 1051
), - 1052
("travel itinerary for next week flight hotel", &["travel"]), - 1053
("latest news headlines breaking", &["news"]), - 1054
("no signals whatsoever in this text", &[]), - 1055
("", &[]), - 1056
("plain text without any keywords", &[]), - 1057
("temperature only single signal", &["temperature"]), - 1058
("forecast only weather signal", &["forecast"]), - 1059
("diff --git a/b modified:", &["diff", "files_changed"]), - 1060
( - 1061
"recipe and ingredients matching", - 1062
&["recipe", "ingredients"], - 1063
), - 1064
("tests and pass_fail both present", &["tests"]), - 1065
("benchmark and telemetry both", &["benchmark", "telemetry"]), - 1066
("chart only single signal", &["chart"]), - 1067
("travel hotel vacation trip", &["travel"]), - 1068
]; - 1069
- 1070
for (i, (text, expected)) in cases.iter().enumerate() { - 1071
let t = text.to_string(); - 1072
let expected_vec: Vec<String> = expected.iter().map(|s| s.to_string()).collect(); - 1073
let i = i; - 1074
scenarios.push(tc(&format!("signal_{i}"), move || { - 1075
let signals = signals_from_text(&t); - 1076
for expected_sig in &expected_vec { - 1077
assert!( - 1078
signals.contains(expected_sig), - 1079
"missing {expected_sig} in {signals:?} for {t:?}" - 1080
); - 1081
} - 1082
assert!(!signals.contains(&"not_a_signal".to_string())); - 1083
assert!(!signals.contains(&"fake_signal".to_string())); - 1084
})); - 1085
} - 1086
- 1087
// Generate 480 more variations - 1088
for i in 20..500 { - 1089
let (text, expected) = cases[i % cases.len()]; - 1090
let t = format!("{}{}", text, i); - 1091
let expected_vec: Vec<String> = expected.iter().map(|s| s.to_string()).collect(); - 1092
scenarios.push(tc(&format!("signal_var_{i}"), move || { - 1093
let signals = signals_from_text(&t); - 1094
for expected_sig in &expected_vec { - 1095
assert!(signals.contains(expected_sig), "missing {expected_sig}"); - 1096
} - 1097
})); - 1098
} - 1099
- 1100
run("blue_team_signal_extraction_accuracy", scenarios); - 1101
} - 1102
- 1103
#[test] - 1104
fn blue_team_skill_validation() { - 1105
let mut scenarios: Vec<Scenario> = vec![]; - 1106
- 1107
let valid_payloads: Vec<(&str, serde_json::Value)> = vec![ - 1108
("metric", json!({"label": "X", "value": 42, "unit": "%"})), - 1109
( - 1110
"link.preview", - 1111
json!({"url": "https://x.com", "title": "T"}), - 1112
), - 1113
("collection", json!({"items": ["a", "b"]})), - 1114
("detail", json!({"title": "T"})), - 1115
("comparison", json!({"left": "a", "right": "b"})), - 1116
( - 1117
"checklist", - 1118
json!({"items": [{"label": "a", "done": true}]}), - 1119
), - 1120
("timeline", json!({"items": [{"label": "step"}]})), - 1121
("steps", json!({"items": [{"label": "s"}]})), - 1122
("schedule", json!({"slots": [{"label": "morning"}]})), - 1123
( - 1124
"decision", - 1125
json!({"label": "Choose", "choices": ["A", "B"]}), - 1126
), - 1127
( - 1128
"budget", - 1129
json!({"label": "Income", "income": 100, "expenses": 50}), - 1130
), - 1131
( - 1132
"meeting_notes", - 1133
json!({"agenda": [{"title": "A"}], "attendees": ["x"]}), - 1134
), - 1135
]; - 1136
- 1137
for (i, (st, payload)) in valid_payloads.iter().enumerate() { - 1138
let st = st.to_string(); - 1139
let p = payload.clone(); - 1140
let i = i; - 1141
scenarios.push(tc(&format!("valid_{i}_{}", st), move || { - 1142
let registry = built_in_skill_registry(); - 1143
let output = StructuredOutput { - 1144
semantic_type: st.clone(), - 1145
schema_version: vak_delivery::PRESENTATION_SCHEMA_VERSION, - 1146
skill_id: "core".into(), - 1147
skill_version: "1.0.0".into(), - 1148
payload: p, - 1149
}; - 1150
let result = registry.validate(&output, "desktop", &[]); - 1151
assert!(result.is_ok(), "valid {st} failed: {result:?}"); - 1152
})); - 1153
} - 1154
- 1155
// 488 invalid type variations - 1156
for i in 12..500 { - 1157
let st = valid_types()[i % valid_types().len()]; - 1158
let invalid = json!({"invalid": true}); - 1159
let st = st.to_string(); - 1160
let i = i; - 1161
scenarios.push(tc(&format!("invalid_{i}_{}", st), move || { - 1162
let registry = built_in_skill_registry(); - 1163
let output = StructuredOutput { - 1164
semantic_type: st.clone(), - 1165
schema_version: vak_delivery::PRESENTATION_SCHEMA_VERSION, - 1166
skill_id: "core".into(), - 1167
skill_version: "1.0.0".into(), - 1168
payload: invalid.clone(), - 1169
}; - 1170
let _ = registry.validate(&output, "desktop", &[]); - 1171
})); - 1172
} - 1173
- 1174
run("blue_team_skill_validation", scenarios); - 1175
} - 1176
- 1177
fn valid_types() -> &'static [&'static str] { - 1178
&[ - 1179
"metric", - 1180
"link.preview", - 1181
"collection", - 1182
"detail", - 1183
"comparison", - 1184
"checklist", - 1185
"timeline", - 1186
"steps", - 1187
"schedule", - 1188
"decision", - 1189
"budget", - 1190
"meeting_notes", - 1191
] - 1192
} - 1193
- 1194
#[test] - 1195
fn blue_team_worker_protocol_roundtrip() { - 1196
let mut scenarios: Vec<Scenario> = vec![]; - 1197
- 1198
let sources: &[&str] = &[ - 1199
"# Title\n\nBody.", - 1200
"Plain text", - 1201
"| A | B |\n|---|---|\n| 1 | 2 |", - 1202
"```rust\nfn main() {}\n```", - 1203
"- [ ] todo\n- [x] done", - 1204
"||spoiler||", - 1205
"", - 1206
"**bold** *italic* ~~strike~~", - 1207
"# H1\n## H2\n### H3", - 1208
"Multiple\n\n\n\n\nparagraphs", - 1209
]; - 1210
- 1211
for i in 0..500 { - 1212
let source = sources[i % sources.len()]; - 1213
let (surface, markup) = SURFACES[i % SURFACES.len()]; - 1214
let src = source.to_string(); - 1215
let surf = surface.to_string(); - 1216
let i = i; - 1217
scenarios.push(tc(&format!("worker_rt_{i}"), move || { - 1218
let job = answer_job(&src, markup, &surf); - 1219
let request = WorkerRequest { - 1220
protocol_version: WORKER_PROTOCOL_VERSION, - 1221
job: job.clone(), - 1222
}; - 1223
let req_str = serde_json::to_string(&request).expect("serialize"); - 1224
let resp_str = process_line(&req_str); - 1225
let resp: WorkerResponse = serde_json::from_str(&resp_str).expect("deserialize"); - 1226
assert_eq!(resp.protocol_version, WORKER_PROTOCOL_VERSION); - 1227
let packet = resp.packet.expect("packet"); - 1228
let direct = render(&job).expect("direct render"); - 1229
assert_eq!(packet.payload, direct.payload, "worker mismatch for {src}"); - 1230
})); - 1231
} - 1232
- 1233
run("blue_team_worker_protocol_roundtrip", scenarios); - 1234
} - 1235
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.