- 1119
#[test] - 1120
fn a_legacy_session_with_no_baseline_is_not_drifted() { - 1121
let runtime = RuntimeSections::default(); - 1122
let current = resolve( - 1123
&[LayerInput::new(PromptLayer::Seed, None, seed_content())], - 1124
&runtime, - 1125
); - 1126
assert!(drift(&[], ¤t.descriptors).is_none()); - 1127
} - 1128
- 1129
#[test] - 1130
fn drift_names_what_changed() { - 1131
let runtime = RuntimeSections::default(); - 1132
let frozen = resolve( - 1133
&[ - 1134
LayerInput::new(PromptLayer::Seed, None, seed_content()), - 1135
LayerInput::new( - 1136
PromptLayer::Workspace, - 1137
Some("p".into()), - 1138
LayerContent { - 1139
identity: Some("You are Kavi.".into()), - 1140
guardrails: vec!["never touch infra/".into()], - 1141
..Default::default() - 1142
}, - 1143
), - 1144
], - 1145
&runtime, - 1146
); - 1147
assert!( - 1148
drift(&frozen.descriptors, &frozen.descriptors).is_none(), - 1149
"an unchanged workspace must not report drift" - 1150
); - 1151
- 1152
let now = resolve( - 1153
&[ - 1154
LayerInput::new(PromptLayer::Seed, None, seed_content()), - 1155
LayerInput::new( - 1156
PromptLayer::Workspace, - 1157
Some("p".into()), - 1158
LayerContent { - 1159
// identity edited, guardrail dropped - 1160
identity: Some("You are Meera.".into()), - 1161
..Default::default() - 1162
}, - 1163
), - 1164
LayerInput::new( - 1165
PromptLayer::Chat, - 1166
Some("chat:t:1".into()), - 1167
LayerContent { - 1168
guardrails: vec!["answer briefly".into()], - 1169
..Default::default() - 1170
}, - 1171
), - 1172
], - 1173
&runtime, - 1174
); - 1175
let d = drift(&frozen.descriptors, &now.descriptors).expect("drift"); - 1176
assert_eq!(d.changed.len(), 1, "{:?}", d.changed); - 1177
assert_eq!(d.changed[0].1.block, "identity"); - 1178
assert!(d.added.iter().any(|a| a.layer == "chat")); - 1179
assert!(d.removed.iter().any(|r| r.layer == "workspace")); - 1180
let lines = d.lines().join("\n"); - 1181
assert!(lines.contains("~ identity"), "{lines}"); - 1182
assert!(lines.contains("+ guardrails"), "{lines}"); - 1183
} - 1184
- 1185
#[test] - 1186
fn fingerprint_changes_when_a_layer_changes() { - 1187
let runtime = RuntimeSections::default(); - 1188
let base = resolve( - 1189
&[LayerInput::new(PromptLayer::Seed, None, seed_content())], - 1190
&runtime, - 1191
); - 1192
let edited = resolve( - 1193
&[ - 1194
LayerInput::new(PromptLayer::Seed, None, seed_content()), - 1195
LayerInput::new( - 1196
PromptLayer::Workspace, - 1197
None, - 1198
LayerContent { - 1199
guardrails: vec!["one more".into()], - 1200
..Default::default() - 1201
}, - 1202
), - 1203
], - 1204
&runtime, - 1205
); - 1206
assert_ne!(base.fingerprint(), edited.fingerprint()); - 1207
} - 1208
- 1209
#[test] - 1210
fn epistemic_stance_and_temporal_land_in_the_tail_not_the_prefix() { - 1211
let runtime = RuntimeSections { - 1212
epistemic_stance: "\nEpistemic stance: analytical\n- Scrutinize claims objectively. Separate verified facts from inferences.".into(), - 1213
temporal: "\nTemporal context: current UTC instant 2026-09-19T00:00:00Z.".into(), - 1214
..Default::default() - 1215
}; - 1216
let out = resolve( - 1217
&[LayerInput::new(PromptLayer::Seed, None, seed_content())], - 1218
&runtime, - 1219
); - 1220
assert!(!out.text.contains("Epistemic stance: analytical")); - 1221
assert!(!out.text.contains("Scrutinize claims objectively")); - 1222
assert!(!out.text.contains("Temporal context")); - 1223
assert!(out.tail.contains("Epistemic stance: analytical")); - 1224
assert!(out.tail.contains("Scrutinize claims objectively")); - 1225
assert!(out.tail.contains("Temporal context")); - 1226
assert!( - 1227
out.tail - 1228
.contains("Still call the matching `emit_*_card` tool") - 1229
); - 1230
} - 1231
- 1232
#[test] - 1233
fn tail_is_empty_when_runtime_supplies_neither_stance_nor_temporal() { - 1234
let runtime = RuntimeSections::default(); - 1235
let out = resolve( - 1236
&[LayerInput::new(PromptLayer::Seed, None, seed_content())], - 1237
&runtime, - 1238
); - 1239
assert!(out.tail.is_empty()); - 1240
} - 1241
- 1242
/// Two resolutions built from otherwise-identical layers but different - 1243
/// per-turn runtime content differ only in `tail`; the prefix a - 1244
/// provider would cache stays byte-identical. - 1245
#[test] - 1246
fn resolutions_differ_only_in_tail() { - 1247
let layers = [LayerInput::new(PromptLayer::Seed, None, seed_content())]; - 1248
let a = resolve( - 1249
&layers, - 1250
&RuntimeSections { - 1251
epistemic_stance: "\nEpistemic stance: analytical\n- x".into(), - 1252
temporal: "\nTemporal context: instant A.".into(), - 1253
..Default::default() - 1254
}, - 1255
); - 1256
let b = resolve( - 1257
&layers, - 1258
&RuntimeSections { - 1259
epistemic_stance: "\nEpistemic stance: operational\n- y".into(), - 1260
temporal: "\nTemporal context: instant B.".into(), - 1261
..Default::default() - 1262
}, - 1263
); - 1264
assert_eq!(a.text, b.text); - 1265
assert_ne!(a.tail, b.tail); - 1266
} - 1267
} - 1268
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.