test(profiles): pin the re-run promise V1 was published under

The V1 commit told nine repos, in README, CHANGELOG, the plan and two
coord messages, that upgrading across it costs a consumer a re-run and
nothing more. Nothing exercised that end to end.

What was covered: `owns()` returning True for the legacy literal at the
unit level. What was not: the consumer's actual path -- materializing
into a directory that ALREADY holds pre-V1 `DEFAULT` output. The golden
suite cannot see it, because it materializes into a fresh directory
every time.

`test_second_v0_2_run_into_the_same_directory_succeeds` is the same
shape for `OKF_V0_2`, and its comment already said why one byte-compared
run cannot catch this. V1 made `DEFAULT` change its stamp exactly as D2
made `OKF_V0_2` change its own; no equivalent test followed it until now.

The legacy bundle is derived from a real run rather than hand-authored,
so every byte except the stamp is what an earlier version actually
wrote, and two assertions guard the derivation against silently becoming
a no-op the next time the stamp moves.

Hand-mutated to confirm it can fail: making `owns()` return the legacy
literal only for an actor-less profile turns it red with
`collision_unstamped` -- which is precisely the consumer-visible failure
the promise rules out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VwcjUXbKySLbEG5WqTNkta
This commit is contained in:
Kjell Tore Guttormsen 2026-08-09 12:39:23 +02:00
commit 345684b810

View file

@ -144,6 +144,43 @@ def test_second_v0_2_run_into_the_same_directory_succeeds(
assert (bundle / "index.md").read_bytes() == first_index
def test_a_pre_v1_default_bundle_re_runs_in_place(file_setup: tuple[Path, Path]) -> None:
"""The promise V1 was published under, end to end: upgrading across it costs
a consumer a re-run and nothing more.
The test above is the same shape for `OKF_V0_2`, and its reasoning applies
here verbatim V1 made `DEFAULT` change its stamp value exactly as D2 made
`OKF_V0_2` change its own. What one-way recognition has to buy is this: a
bundle written by a PRE-V1 version carries `generated: true`, and the
upgraded library must replace those files rather than fire
`collision_unstamped` on output it wrote itself one version ago. Recognition
is asserted at the unit level too, but only a second run into an OCCUPIED
directory shows the consumer's actual path — the golden suite materializes
into a fresh directory every time and cannot see this.
The legacy bundle is DERIVED from a real run rather than hand-authored, so
every byte except the stamp is genuinely what an earlier version wrote. The
two assertions before the mutation keep that derivation from quietly
becoming a no-op if the stamp moves again.
"""
manifest_path, bundle = file_setup
materialize_bundle(manifest_path, bundle, INGESTED_AT)
concept = bundle / "ingest-orders.md"
current = concept.read_bytes()
index_before = (bundle / "index.md").read_bytes()
new_stamp = f"generated: {DEFAULT.ownership.stamp(INGESTED_AT)}".encode()
assert new_stamp in current
legacy = current.replace(new_stamp, b"generated: true")
assert legacy != current
concept.write_bytes(legacy)
materialize_bundle(manifest_path, bundle, INGESTED_AT)
assert concept.read_bytes() == current
assert (bundle / "index.md").read_bytes() == index_before
# --- the paths/index half of the profile reaches disk ---