fix(projection): a re-keyed record is new, not a renamed file
The ad-hoc requalification changed 30 identifiers while deliberately keeping the filenames, per canon. The matcher's path fallback therefore matched every old row to its new record and updated it in place — so the files said CUST-WP-ADHOC-2026-08-25 while the hub still said adhoc-2026-08-25, with the row's UUID still encoding the old identifier. Exactly the file/hub identity divergence ADR-007 exists to prevent. Path matching cannot distinguish a re-key from a rename when the path does not change. Identity can: a derived row is UUIDv5 over the record id, so a changed id is a different record — the old row retires and the new one is created. Rows predating derived identity carry v4 UUIDs, where the identifier is a label rather than the identity; those keep path matching, so rename detection still works where it is the right answer. The unmatched old row keeps its own slug as key, so it lands in `stale` and becomes a retirement candidate rather than disappearing from the outcome. 720 pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 2583210@bnt-lap001 Assistant-Session: f2bff2d5-e9b2-4338-92ca-10282a927006
This commit is contained in:
parent
4f68c5609f
commit
b2efadf254
2 changed files with 71 additions and 0 deletions
|
|
@ -684,3 +684,44 @@ class TestForgeCredential:
|
|||
monkeypatch.setattr(fp.subprocess, "run", fake_run)
|
||||
assert fp._run_git("status") == "ok"
|
||||
assert "GIT_CONFIG_COUNT" not in seen["env"]
|
||||
|
||||
|
||||
class TestRekeyIsNotRename:
|
||||
"""A changed identifier is a new record, not a moved file.
|
||||
|
||||
The ad-hoc requalification (CUST-WP-0066) keeps the filename by design, so
|
||||
for those records a re-key never changes the path. Matching on path there
|
||||
cannot distinguish the two cases, and choosing rename updates a row whose
|
||||
UUID still encodes the old identifier — leaving the file and the hub
|
||||
disagreeing about what the record is called.
|
||||
"""
|
||||
|
||||
class _Row:
|
||||
def __init__(self, id, slug, path):
|
||||
self.id = id
|
||||
self.slug = slug
|
||||
self.backing_relative_path = path
|
||||
self.projection_retired_at = None
|
||||
self.status = "finished"
|
||||
|
||||
def test_a_derived_row_is_not_matched_by_path(self):
|
||||
"""uuid5 means identity is a function of the identifier."""
|
||||
import uuid as _u
|
||||
old = self._Row(
|
||||
_u.UUID(fp.derived_record_uuid("ADHOC-2026-08-25")),
|
||||
"adhoc-2026-08-25",
|
||||
"workplans/ADHOC-2026-08-25.md",
|
||||
)
|
||||
assert fp._identity_is_derived(old)
|
||||
|
||||
def test_a_legacy_row_keeps_path_matching(self):
|
||||
"""v4 rows predate derived identity; there the identifier is a label."""
|
||||
import uuid as _u
|
||||
legacy = self._Row(_u.uuid4(), "repo-wp-0001", "workplans/REPO-WP-0001.md")
|
||||
assert not fp._identity_is_derived(legacy)
|
||||
|
||||
def test_the_two_uuids_actually_differ(self):
|
||||
"""Guards the premise: if they were equal the distinction is moot."""
|
||||
assert fp.derived_record_uuid("ADHOC-2026-08-25") != fp.derived_record_uuid(
|
||||
"CUST-WP-ADHOC-2026-08-25"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue