Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ doctrine edge cases those shapes must survive.
(`pkgs/fleet/crates/fleet/src/gh_metadata.rs`,
`pm_metadata_version_conformance_fixtures`), which runs every case
through `parse_metadata_block` and the stamp assembly round-trip.
Because the fleet Nix source closure is rooted at `pkgs/` and does
not contain this `doc/` tree, the test reads a byte-identical
vendored copy at
`pkgs/fleet/crates/fleet/tests/fixtures/pm-metadata-v1.json`
(issue #13617), and asserts the two copies are equal whenever this
design copy is present in the checkout. Edit the design copy here,
then re-copy it to the vendored path in the same change.
- **`atlas-metadata-v1.json`** — Atlas corpus metadata cases. Cases
marked `executable: true` carry a `stage_row` and are asserted by
the atlas-core conformance test
Expand Down
41 changes: 33 additions & 8 deletions pkgs/fleet/crates/fleet/src/gh_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2436,22 +2436,47 @@ mod tests {

// -- #9095 version conformance ------------------------------------
//
// Oracle: the hand-authored fixture set at
// Oracle: the hand-authored fixture set. The canonical copy lives
// under the schema v1 design folder at
// doc/2026-11-21T17-56-24Z_design_atlas_metadata_schema_v1/fixtures/
// pm-metadata-v1.json — every historical shape of the pm_meta v1
// block, with its recorded reader expectation. Each `ok` case must
// parse and preserve its declared keys through parse and through
// the stamp assembly round-trip; each `reject` case must fail
// closed. Doctrine-projection expectations in the fixture are the
// oracle for design §7 slice 2 and are not asserted here.
// pm-metadata-v1.json; the executable copy this test reads is
// vendored at tests/fixtures/pm-metadata-v1.json because the
// fleet nix source closure (pkgs/fleet/default.nix fleetSrc,
// rooted at pkgs/) does not contain repo-root doc/ — a
// CARGO_MANIFEST_DIR-anchored walk to the repo root breaks under
// the nix sandbox (code#13617). Where the design copy is present
// (normal checkouts) the test asserts both copies are byte-equal
// so the vendored copy cannot drift from the oracle; under the
// sandbox only the vendored copy is enforced, never skipped.
// Each `ok` case must parse and preserve its declared keys
// through parse and through the stamp assembly round-trip; each
// `reject` case must fail closed. Doctrine-projection
// expectations in the fixture are the oracle for design §7 slice
// 2 and are not asserted here.
#[test]
fn pm_metadata_version_conformance_fixtures() {
let path = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../../doc/2026-11-21T17-56-24Z_design_atlas_metadata_schema_v1/fixtures/pm-metadata-v1.json"
"/tests/fixtures/pm-metadata-v1.json"
);
let raw = std::fs::read_to_string(path)
.unwrap_or_else(|e| panic!("conformance fixture set unreadable at {path}: {e}"));
// Drift guard: the design-folder copy is the canonical
// oracle. It is absent from the nix source closure, so only
// compare when it exists; the conformance assertions below
// always run against the vendored copy.
let design_path = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../../doc/2026-11-21T17-56-24Z_design_atlas_metadata_schema_v1/fixtures/pm-metadata-v1.json"
);
if std::path::Path::new(design_path).exists() {
let design_raw = std::fs::read_to_string(design_path)
.unwrap_or_else(|e| panic!("design oracle unreadable at {design_path}: {e}"));
assert_eq!(
raw, design_raw,
"vendored fixture diverged from the design oracle; sync tests/fixtures/pm-metadata-v1.json from {design_path}"
);
}
let set: Value = serde_json::from_str(&raw).expect("fixture set is valid JSON");
let cases = set["cases"].as_array().expect("fixture set carries cases");
assert!(!cases.is_empty(), "fixture set must not be empty");
Expand Down
116 changes: 116 additions & 0 deletions pkgs/fleet/crates/fleet/tests/fixtures/pm-metadata-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"fixture_set": "pm-metadata-version-conformance",
"issue": "developing-today/code#9095",
"surface": "pm",
"version_key": "pm_meta",
"current_version": 1,
"source_design": "doc/2026-11-21T17-56-24Z_design_atlas_metadata_schema_v1/note.md",
"notes": "reader_parse / preserved_keys are the executable expectations asserted by the fleet crate conformance test (pkgs/fleet/crates/fleet/src/gh_metadata.rs). doctrine_projection, where present, is the recorded oracle for the projection behavior specified in design section 7 slice 2; it is not asserted against any current reader.",
"cases": [
{
"id": "pm-v1-canonical",
"historical_source": "PM hierarchy design section 12 canonical form, restated in the schema v1 design section 2.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 1,\n \"direct_parent\": null,\n \"links\": [],\n \"lineage\": {\n \"design\": null,\n \"roadmap_item\": null,\n \"priority\": null\n },\n \"provenance\": {},\n \"extras\": {}\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"direct_parent",
"links",
"lineage",
"provenance",
"extras"
]
},
{
"id": "pm-v1-legacy-links-only",
"historical_source": "Aggregator genealogy practice (pm-stack/aggregator/test/genealogy.test.ts): a links-only block written before extras/lineage injection existed. Absent extras reads as {} (design section 2); the reader must not synthesize and write it back.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\"pm_meta\":1,\"links\":[{\"target\":{\"repo\":\"developing-today/code\",\"number\":99},\"relation\":\"parent\",\"status\":\"historical\",\"since\":\"2026-11-02\",\"until\":\"2026-11-12\",\"reason\":\"split\"},{\"target\":{\"repo\":\"developing-today/code\",\"number\":98},\"relation\":\"parent\",\"status\":\"removed\"}]}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"links"
]
},
{
"id": "pm-v1-minimal-link",
"historical_source": "Aggregator epic-reparent practice (pm-stack/aggregator/test/epic-reparent.test.ts): a link carrying only relation and target; every other link field is optional.",
"body": "Issue text\n\n<!-- pm-metadata:start -->\n```json\n{\"pm_meta\":1,\"links\":[{\"relation\":\"blockedBy\",\"target\":{\"repo\":\"x/y\",\"number\":7}}]}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"links"
]
},
{
"id": "pm-v1-float-version",
"historical_source": "Version written as the JSON number 1.0 by non-Rust producers; both current readers accept it as version 1.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 1.0,\n \"links\": []\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"links"
]
},
{
"id": "pm-v1-unknown-keys",
"historical_source": "A v1 block carrying unlisted top-level keys written by a classifying agent. The current reader parses and preserves them verbatim.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 1,\n \"direct_parent\": null,\n \"links\": [],\n \"lineage\": {\n \"design\": null,\n \"roadmap_item\": null,\n \"priority\": null\n },\n \"provenance\": {},\n \"extras\": {},\n \"sprint\": \"2026-W47\",\n \"review\": {\"round\": 2, \"verdict\": \"accept\"}\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"direct_parent",
"links",
"lineage",
"provenance",
"extras",
"sprint",
"review"
],
"doctrine_projection": "The canonical PM form holds unknown keys in the extras object (design section 2). Relocation into extras is projection behavior (design section 7 slice 2), not a read error; until a projector lands, preservation in place is the conforming reader behavior."
},
{
"id": "pm-v1-populated-extras",
"historical_source": "A v1 block whose extras dictionary already carries relocated/unlisted data; extras content is preserved byte-for-byte semantically (same JSON value) through parse and re-stamp.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 1,\n \"links\": [],\n \"extras\": {\n \"legacy_tool\": \"metadata-sweeper\",\n \"confidence\": 0.75\n }\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"links",
"extras"
]
},
{
"id": "pm-v1-type-mismatch",
"historical_source": "Declared field links carrying an object instead of an array (a producer bug shape). The block parser gates on the version key only, so the block parses; the value is caller data, preserved as written by the stamp path.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 1,\n \"links\": {\"relation\": \"parent\", \"target\": {\"repo\": \"developing-today/code\", \"number\": 9060}}\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "ok",
"preserved_keys": [
"pm_meta",
"links"
],
"doctrine_projection": "Type-directed handling (design section 3.2): the mismatched value relocates to extras unchanged, the declared links view defaults to [], and the mismatch is reported - never an error, never a silent coercion. Projection behavior is design section 7 slice 2; no current reader projects, so this case's executable expectation is parse-and-preserve only."
},
{
"id": "pm-no-version",
"historical_source": "A fenced block without the version key is not a versioned Metadata object (doctrine rule 1: version always carried).",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"links\": []\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "reject",
"preserved_keys": []
},
{
"id": "pm-future-version",
"historical_source": "pm_meta 2 is newer than every published reader. Readers accept every prior version indefinitely; a version newer than the reader is refused fail-closed, never guessed at.",
"body": "Issue text.\n\n<!-- pm-metadata:start -->\n```json\n{\n \"pm_meta\": 2,\n \"links\": []\n}\n```\n<!-- pm-metadata:end -->\n",
"reader_parse": "reject",
"preserved_keys": []
},
{
"id": "pm-no-block",
"historical_source": "An ordinary issue body with no pm-metadata markers parses successfully with no block; absence of Metadata is not an error.",
"body": "Just an issue body, no metadata block.\n",
"reader_parse": "ok",
"block": "absent",
"preserved_keys": []
}
]
}