- Rename 4 fixture manifests under _assembler/tests/fixtures/_manifests/
({code-implementer,cost-guardian,patent-compliance,researcher}.toml
-> kei-<name>.toml) via git mv. Copy updated top-level manifests into
fixtures so they stay byte-identical (fixtures mirror real manifests).
- Rename 4 snapshot files under _assembler/tests/snapshots/ to match
the new insta snapshot keys.
- Update snapshot bodies to reflect the kei- prefix in:
* frontmatter name field (name: kei-<n>)
* GENERATED comment (_manifests/kei-<n>.toml)
* handoff target lines
* === HEADER === REPORT header (uppercased name in output_format)
- Update test code (golden.rs, roundtrip.rs, validator_negative.rs,
determinism.rs) to use the new manifest filenames + snapshot keys.
Rust function names (e.g. golden_researcher) untouched — they are
internal identifiers, not manifest refs, and the word-boundary rule
(no "_" preceding match) correctly skipped them.
Verify:
cd _assembler && cargo test
-> 17 tests passed (0 + 3 + 4 + 2 + 2 + 6 across 6 test files)
-> Re-run produces no *.snap.new files (snapshots stable)
Regeneration path: because cargo-insta CLI is not installed on the
build host, the .snap.new files produced by the first (failing) test
run were accepted by renaming .snap.new -> .snap. Second cargo test
run passed cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
90 lines
3.2 KiB
Rust
90 lines
3.2 KiB
Rust
//! Roundtrip / data-preservation tests.
|
|
//!
|
|
//! The assembler projects the Manifest struct into a Markdown file.
|
|
//! We cannot re-parse a Markdown file back into a Manifest (the
|
|
//! projection is lossy: comments / blank lines / heading formatting),
|
|
//! but we CAN assert that every user-visible string from the manifest
|
|
//! appears verbatim in the generated output — i.e. no field is
|
|
//! silently dropped by a refactor.
|
|
|
|
mod common;
|
|
|
|
use common::{assemble_one, seed_tempdir};
|
|
use std::fs;
|
|
|
|
/// Every `domain_in` bullet, every `forbidden_domain` bullet, every
|
|
/// handoff target + trigger, and the agent name must appear in the
|
|
/// generated output. Covers the kei-code-implementer manifest which has
|
|
/// the richest field population.
|
|
#[test]
|
|
fn every_manifest_string_appears_in_output() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let out = assemble_one(&root, "kei-code-implementer");
|
|
|
|
// Parse the same manifest independently with toml crate so we
|
|
// can iterate its fields without reaching into the private
|
|
// Manifest struct from main.rs.
|
|
let toml_text =
|
|
fs::read_to_string(root.join("_manifests/kei-code-implementer.toml")).unwrap();
|
|
let parsed: toml::Value = toml::from_str(&toml_text).unwrap();
|
|
|
|
let name = parsed["name"].as_str().unwrap();
|
|
assert!(
|
|
out.contains(&format!("name: {name}")),
|
|
"frontmatter missing name"
|
|
);
|
|
|
|
let model = parsed["model"].as_str().unwrap();
|
|
assert!(
|
|
out.contains(&format!("model: {model}")),
|
|
"frontmatter missing model"
|
|
);
|
|
|
|
// Tools are joined with ", ".
|
|
let tools: Vec<&str> = parsed["tools"]
|
|
.as_array()
|
|
.unwrap()
|
|
.iter()
|
|
.map(|v| v.as_str().unwrap())
|
|
.collect();
|
|
let tools_line = format!("tools: {}", tools.join(", "));
|
|
assert!(
|
|
out.contains(&tools_line),
|
|
"frontmatter tools line missing or wrong order"
|
|
);
|
|
|
|
// domain_in bullets.
|
|
for item in parsed["domain_in"].as_array().unwrap() {
|
|
let s = item.as_str().unwrap();
|
|
assert!(out.contains(s), "domain_in entry missing: {s}");
|
|
}
|
|
|
|
// forbidden_domain bullets.
|
|
for item in parsed["forbidden_domain"].as_array().unwrap() {
|
|
let s = item.as_str().unwrap();
|
|
assert!(out.contains(s), "forbidden_domain entry missing: {s}");
|
|
}
|
|
|
|
// Handoffs: each target AND each trigger appears.
|
|
for h in parsed["handoff"].as_array().unwrap() {
|
|
let target = h["target"].as_str().unwrap();
|
|
let trigger = h["trigger"].as_str().unwrap();
|
|
assert!(out.contains(target), "handoff target missing: {target}");
|
|
assert!(out.contains(trigger), "handoff trigger missing: {trigger}");
|
|
}
|
|
}
|
|
|
|
/// Double-assembly determinism at the text level: parse + assemble
|
|
/// twice from the very same tempdir (not two separate tempdirs) —
|
|
/// catches any caching or mutable-global drift inside the binary.
|
|
#[test]
|
|
fn double_assembly_same_tempdir_identical() {
|
|
let (_tmp, root) = seed_tempdir();
|
|
let first = assemble_one(&root, "kei-patent-compliance");
|
|
let second = assemble_one(&root, "kei-patent-compliance");
|
|
assert_eq!(
|
|
first.as_bytes(),
|
|
second.as_bytes(),
|
|
"consecutive runs in same tempdir diverged"
|
|
);
|
|
}
|