feat(profiles): DEFAULT stamps commons' O2 generated, V1 executed

Commons ratified V1 2026-08-02 and executed it at `54e0ec7`; verified
against their tree rather than taken on report. ingest-spec.md:217 now
defines `generated` as `{ by: process:okf-ingest, at: <ingested_at> }`,
unquoted, `at` repeating `ingested_at` verbatim. `generated: true` no
longer appears in the spec.

`DEFAULT` states commons' §5 layer, so its stamp is theirs to decide.
`DEFAULT.ownership` gains the actor; the four goldens this repo's plan
named in advance were regenerated by RUNNING the materializer, each on
its own case's `ingested-at.txt`. The v0.2 golden was untouched, as
predicted -- it has carried the O2 form since D5.

Not a migration onto OKF v0.2: `DEFAULT` stays v0.1 on every axis
upstream owns and still emits no `sources`. Commons' spec and the Google
version are independent axes, and comments that narrated them as one
were rewritten rather than left to mislead. README and CLAUDE.md said
the additive rule without that boundary, which would have told a
consumer their DEFAULT bytes can never move; both now state it.

V-A3 is amended, not dropped. `DEFAULT` must OWN the mapping it now
writes -- a profile refusing its own output fires the collision gate on
files its own previous run wrote -- while a mapping naming a foreign
actor, or §7's `human:` actor on curated content, stays unowned. That
half is what carried the safety and it is asserted directly.

§11's stamp-integrity condition moved with the value: the forgeable
stamp was `true` and is now the mapping naming the ingest actor. The
defence was never the value -- the §3 scan globs `ingest-*.md`, so a
Door C import is unreachable however well it forges. Second spoof test
added; both were hand-mutated (glob widened to `*.md`) to confirm they
can fail.

The characterization test derived its foreign-stamp fixture from the
literal `generated: true`, which V1 leaves without a referent -- a
silent no-op waiting to happen. It now derives the needle from the
profile and asserts the substitution occurred.

Door B is deliberately untouched: not the ingest-spec's, marker is
`generated` + `source_file`, disjoint from Door A's `ingest_manifest`,
and the divergence predates V1.

Nothing released or notified. The pilot set pins `v0.5.0a2`, not `main`,
so this is invisible to portfolio-optimiser's freeze and demo; the
consumer exposure report is owed at the release that carries this.

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:29:05 +02:00
commit 8318605e34
15 changed files with 280 additions and 50 deletions

View file

@ -84,6 +84,13 @@ def test_provenance_layer_on_every_generated_file(tmp_path: Path) -> None:
MUST fail when a generated file no longer carries the §7 layer.
Hand-mutation check 2026-07-16: dropping any of the five §7 keys from
_render_concept_file turns this test red.
`generated` is spelled out here rather than read from the profile, for the
same reason the frontmatter parser is: a seam that asks the library what it
should have written cannot catch the library writing the wrong thing. §7
fixes both sub-keys the actor is the constant `process:okf-ingest`, and
`at` repeats `ingested_at` verbatim so the expected value is derivable by
hand, which is what makes stating it independently possible at all.
"""
_, written = materialized_bundle(tmp_path)
assert written
@ -93,7 +100,7 @@ def test_provenance_layer_on_every_generated_file(tmp_path: Path) -> None:
assert frontmatter["source_query"]
assert frontmatter["ingested_at"] == INGESTED_AT
assert re.fullmatch(r"manifest@[0-9a-f]{16}", frontmatter["ingest_manifest"])
assert frontmatter["generated"] == "true"
assert frontmatter["generated"] == f"{{ by: process:okf-ingest, at: {INGESTED_AT} }}"
def test_every_generated_file_reachable_via_index_links(tmp_path: Path) -> None:

View file

@ -113,7 +113,7 @@ def test_file_source_concept_file_exact_bytes(file_setup: tuple[Path, Path]) ->
"source_query: orders.csv\n"
f"ingested_at: {INGESTED_AT}\n"
f"ingest_manifest: {stamp_of(manifest_path)}\n"
"generated: true\n"
f"generated: {{ by: process:okf-ingest, at: {INGESTED_AT} }}\n"
"---\n"
"\n"
"| a | b |\n"
@ -371,6 +371,43 @@ def test_a_door_c_import_survives_a_same_stem_materialize_run(
assert (bundle / "ingest-orders.md").is_file()
def test_a_door_c_import_forging_the_o2_stamp_survives_a_materialize_run(
file_setup: tuple[Path, Path],
) -> None:
"""The test above with the value V1 made forgeable. ingest-spec §11 lists
"Stamp integrity (curated writers)" as a red condition, and V1 changed WHICH
value satisfies it: the forgeable stamp used to be the literal `true`, and is
now the O2 mapping naming the ingest actor. The old test keeps exercising a
value `DEFAULT` still owns, so it did not stop testing anything but on its
own it would leave the current threat unexercised.
The defence is structural rather than a judgement about the value: the §3
scan globs `ingest-*.md`, so a `import-`-prefixed file is never a candidate
no matter how perfectly it forges the stamp. Door C writes external concepts
verbatim and cannot screen this, which is exactly why the namespace, not the
parse, has to be what holds.
"""
manifest_path, bundle = file_setup
bundle.mkdir()
imported = bundle / "import-external.md"
forged = (
"---\n"
"type: Concept\n"
"title: Imported Concept\n"
"provenance:\n"
f" generated: {{ by: process:okf-ingest, at: {INGESTED_AT} }}\n"
" ingest_manifest: manifest@deadbeef\n"
"---\n\nExternally imported body.\n"
)
imported.write_text(forged, encoding="utf-8")
materialize_bundle(manifest_path, bundle, INGESTED_AT)
assert imported.is_file()
assert imported.read_text(encoding="utf-8") == forged
assert (bundle / "ingest-orders.md").is_file()
def test_second_manifest_does_not_delete_first_manifests_stamped_file(tmp_path: Path) -> None:
# §10.2 per-manifest ownership: two manifests writing into ONE bundle each
# own only the files whose stamp names them by stem. Running manifest B

View file

@ -153,9 +153,17 @@ def test_a_v0_2_file_at_a_target_name_is_refused_not_overwritten(tmp_path: Path)
materialize_bundle(manifest_path, bundle, INGESTED_AT)
concept = bundle / "ingest-orders.md"
v0_2_bytes = concept.read_bytes().replace(
b"generated: true", f"generated: {V0_2_GENERATED}".encode()
)
# Substitute the stamp THIS profile wrote for a foreign one. The needle is
# derived from the profile rather than spelled out because it moved once
# already (V1 took `DEFAULT` off `generated: true`), and a stale literal
# here would make `replace` a silent no-op — leaving the file carrying our
# own stamp and the test passing for a reason it does not describe. The
# assertion below is the guard against that happening again.
own_stamp = f"generated: {DEFAULT.ownership.stamp(INGESTED_AT)}".encode()
original = concept.read_bytes()
assert own_stamp in original
v0_2_bytes = original.replace(own_stamp, f"generated: {V0_2_GENERATED}".encode())
assert v0_2_bytes != original
concept.write_bytes(v0_2_bytes)
with pytest.raises(MaterializationError) as excinfo:

View file

@ -136,8 +136,20 @@ def test_okf_latest_still_means_v0_1_until_ga() -> None:
# --- ownership ------------------------------------------------------------
def test_the_default_profile_still_stamps_the_v0_1_literal() -> None:
assert DEFAULT.ownership.stamp(INGESTED_AT) == "true"
def test_the_default_profile_stamps_the_form_commons_ratified() -> None:
"""V1, executed by commons 2026-08-09 (`54e0ec7`). `DEFAULT` states commons'
ingest-spec §5 layer, so the shape of its `generated` is theirs to decide
and they moved it off the v0.1 literal onto the O2 mapping. ingest-spec §7
defines the value as `{ by: process:okf-ingest, at: <ingested_at> }`,
unquoted, because frontmatter is parsed line-oriented and a quote would be a
character IN the value rather than syntax a parser strips.
`DEFAULT` and `OKF_V0_2` therefore agree on the stamp and on nothing else:
the profiles still differ in their index root frontmatter, their
type-conditional requirements and their `sources` derivation. The stamp
converging is the point of V1, not a sign the two profiles merged.
"""
assert DEFAULT.ownership.stamp(INGESTED_AT) == V0_2_STAMP
def test_the_v0_2_stamp_is_a_flow_mapping_whose_at_is_the_argument_exactly() -> None:
@ -170,14 +182,38 @@ def test_the_v0_2_predicate_also_accepts_the_v0_1_stamp(tmp_path: Path) -> None:
assert _is_ingest_owned(path, "manifest", profile=OKF_V0_2) is True
def test_the_default_predicate_still_refuses_the_v0_2_stamp(tmp_path: Path) -> None:
"""Recognition is one-way, which is what preserves V-A3. `DEFAULT` meeting a
v0.2 file refuses the run rather than replacing the file."""
def test_the_default_predicate_owns_the_stamp_v1_made_it_write(tmp_path: Path) -> None:
"""V-A3 as V1 leaves it. Before V1 this asserted the opposite — `DEFAULT`
refused the O2 mapping outright and that reading died the moment commons
made `DEFAULT` WRITE that mapping: a profile that will not own its own
output fires the §3 collision gate on the files its own previous run wrote.
The emitter and the predicate are coupled through `OwnershipPolicy`
precisely so they cannot part company here.
What V-A3 protected is unchanged and is asserted below: ownership binds the
ACTOR, not the shape. A mapping is owned when it names this profile's actor
and refused when it names any other.
"""
path = tmp_path / "ingest-orders.md"
path.write_bytes(_stamped_concept(V0_2_STAMP))
assert _is_ingest_owned(path, "manifest") is False
assert _is_ingest_owned(path, "manifest", profile=DEFAULT) is False
assert _is_ingest_owned(path, "manifest") is True
assert _is_ingest_owned(path, "manifest", profile=DEFAULT) is True
def test_the_default_predicate_refuses_a_foreign_actor(tmp_path: Path) -> None:
"""The half of V-A3 that survives V1 intact, and the one that carries the
safety: another implementation's bundle, and §7's `human:` actor on curated
content, both stay unowned under `DEFAULT`. Presence of the key proves
nothing upstream writes `generated` on hand-authored files too.
"""
foreign = tmp_path / "ingest-orders.md"
foreign.write_bytes(_stamped_concept(f"{{ by: process:some-other-tool, at: {INGESTED_AT} }}"))
curated = tmp_path / "ingest-products.md"
curated.write_bytes(_stamped_concept(f"{{ by: human:jsmith@acme, at: {INGESTED_AT} }}"))
assert _is_ingest_owned(foreign, "manifest", profile=DEFAULT) is False
assert _is_ingest_owned(curated, "manifest", profile=DEFAULT) is False
def test_a_foreign_v0_2_actor_is_never_ingest_owned(tmp_path: Path) -> None:
@ -249,10 +285,14 @@ def test_sources_follows_generated_in_the_emitted_block() -> None:
]
def test_the_default_profile_emits_neither_sources_nor_a_v0_2_generated() -> None:
"""V-A6 at the unit level: the seven-key v0.1 block, byte for byte. The
golden suite proves the same thing end to end; this one localizes a failure
to the renderer rather than to a fixture diff.
def test_the_default_profile_emits_no_sources_and_the_o2_generated() -> None:
"""V-A6 at the unit level, as V1 amends it: the seven-key block byte for
byte. `generated` now carries commons' O2 mapping, and `sources` — which is
upstream v0.2's, not commons' is still absent. That pairing is the whole
point of keeping the two contracts on separate axes.
The golden suite proves the same end to end; this one localizes a failure to
the renderer rather than to a fixture diff.
"""
rendered = _concept(FileSource(id="golden-catalogue", root="fixture"), profile=DEFAULT)
@ -264,11 +304,12 @@ def test_the_default_profile_emits_neither_sources_nor_a_v0_2_generated() -> Non
"source_query: orders.csv\n"
f"ingested_at: {INGESTED_AT}\n"
f"ingest_manifest: {STAMP}\n"
"generated: true\n"
f"generated: {{ by: process:okf-ingest, at: {INGESTED_AT} }}\n"
"---\n"
"\n"
"Body.\n"
)
assert "sources:" not in rendered
def test_the_http_credential_reference_never_reaches_the_frontmatter() -> None:

View file

@ -106,7 +106,9 @@ def test_default_run_is_unchanged_by_the_new_parameter(file_setup: tuple[Path, P
materialize_bundle(manifest_path, explicit_dir, INGESTED_AT, profile=DEFAULT)
assert (explicit_dir / "ingest-orders.md").read_bytes() == implicit
assert (explicit_dir / "index.md").read_bytes() == index_implicit
assert b"generated: true" in implicit
# Not redundant with the equality above: it pins WHICH profile the implicit
# run used. Without it the two calls could agree while both being wrong.
assert f"generated: {{ by: process:okf-ingest, at: {INGESTED_AT} }}".encode() in implicit
def test_profile_is_keyword_only(file_setup: tuple[Path, Path]) -> None: