Skip to content
Merged
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
17 changes: 16 additions & 1 deletion atom/compass/spec/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
by name. A transfer that declares no stack at all is refused too: the evidence
that these constants move with the compute stack is the whole reason a transfer
is allowed to be cheap, and a transfer that does not say what it was measured
against cannot be checked by anyone, ever.
against cannot be checked by anyone, ever. A document saved from a merge of
transfers from one spec reads back as such a transfer, since a merge keeps a
transfer's pin out of what it writes, so its refusal names that merge rather
than its author.

A stack mismatch on the running machine is the one finding that is not fatal by
default. The numbers are still measurements, taken on a stack that has since
Expand Down Expand Up @@ -358,6 +361,18 @@ def _transfers(resolved: Mapping[str, Any], merged: Merge):
for component in PINNED
if f"{PINNED_BLOCK}.{component}" in fragment.values
}
if not declared and "provenance.fragments" in fragment.values:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (principle 8, "Every claim carries its measurement"). "provenance.fragments" in fragment.values is also true for a fragment that states provenance.fragments: []. The schema accepts that value, and such a fragment gets the new wording, "its provenance names the fragments an earlier merge built it from", even though its provenance names none.

Measured on node 18 (xiaobizh_n18_cpu, merged stamp tree af99b9eb6), probe P7: a first-hand transferred-from:mi300x-8gpu fragment with no pin and fragments=[], merged with tier0, tier1 and links, is refused PINNED_STACK with the new text. At the tip it gets the first-hand text.

merge never writes an empty list, because _provenance adds every fragment's own source. So an empty list is always hand-written, and the author omitted the pin. if not declared and fragment.values.get("provenance.fragments"): is the same length and sends that case back to the first-hand wording. The verdict does not change either way.

The non-empty hand-written case (probe P5) also gets the new text. I accept that as honest: the document claims its own merge history, no field can tell it apart from a real merge output, and the PR body says so.

yield SpecRefusal(
Rule.PINNED_STACK,
f"{fragment.stanza()} carried constants over from "
f"{fragment.transferred_from!r}, and its provenance names the "
"fragments an earlier merge built it from; a merge keeps a "
"transfer's source stack pin out of the document it writes, so "
"this one cannot say which stack they were measured against",
"merge the fragments it was built from in its place, since a "

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking suggestion (principle 6, "A declined answer with a named reason is a result"). The remedy says to merge "the fragments it was built from" but does not name them. fragment.values["provenance.fragments"] already holds the names, so the refusal could list them.

This matters most for a document saved twice. Probe P9 (merge a pinned transfer, save it as t0.yaml, merge that alone, save it as t1.yaml) gives provenance.fragments == ('tier2', 't0.yaml'). Only tier2 carries a pin. If you follow the remedy literally with both names, t0.yaml is refused again with the same wording, and it takes a second round to converge (probe_extra, below). Naming the list would at least show the reader which names are candidates.

I checked the remedy's other sentences against the code, and they are true:

  • merge.py:285 skips device.software_pinned_to.* for any fragment with transferred_from.
  • fields.py:127-129 are the only pin fields in the schema.
  • So the source fragment is the only place the pin survives.

"transfer states its source's stack pin there and nowhere else",
)
continue
if not declared:
yield SpecRefusal(
Rule.PINNED_STACK,
Expand Down
21 changes: 21 additions & 0 deletions tests/compass/test_spec_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,27 @@ def test_a_transfer_that_names_no_stack_at_all_is_refused():
assert "without saying which stack" in checked.refusals[0].what


def test_a_saved_transfer_merged_again_names_the_merge_that_dropped_its_pin():
# The transfer is pinned to this stack; the merge that wrote the saved
# document kept that pin out, so no author omitted it. The first-hand
# transfer with no pin is the control, and its text does not change.
carried = copy.deepcopy(TIER2)
carried["device"]["software_pinned_to"] = dict(STACK)
transfer = fragment("tier2", carried, method="transferred-from:mi300x-8gpu")
saved = Fragment.from_mapping(merge([transfer]).document, "t.yaml")
again = validate(merge([saved] + fragments()[:2] + [fragment("links", LINKS)]))
assert [refusal.rule for refusal in again.refusals] == [Rule.PINNED_STACK]
assert "fragments an earlier merge built it from" in again.refusals[0].what
assert "merge the fragments it was built from" in again.refusals[0].remedy
bare = fragment("tier2", TIER2, method="transferred-from:mi300x-8gpu")
first_hand = validate(merge(fragments()[:2] + [bare, fragment("links", LINKS)]))
assert first_hand.refusals[0].what == (
"'tier2' (machine 'mi355x-8gpu-2node', transferred-from:mi300x-8gpu, "
"by a person on 2026-09-18) carried constants over from 'mi300x-8gpu' "
"without saying which stack they were measured against"
)


def test_a_transfer_from_a_spec_pinned_to_this_stack_validates():
carried = dict(copy.deepcopy(TIER2))
carried["device"]["software_pinned_to"] = dict(STACK)
Expand Down