fix(backfill): qualify short task ids with their workplan
A task id written as a bare "T01" is unique only inside its own workplan. Stored as a canonical identifier it makes every workplan's first task share one identity: 51 such ids were assigned to 148 rows on central before this was caught, found because identified rows outnumbered distinct identities. Short ids are now qualified as WORKPLAN-ID-T01. A short id in a file with no workplan id in frontmatter is left unidentified — an identity that is not unique is worse than none, which is the same rule the rest of this module already follows. The 136 affected rows on central have been cleared so the corrected backfill can reassign them; the backfill never overwrites an existing identity, so they had to be nulled rather than re-derived over. Refs STATE-WP-0083-T06 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
b1cf1a3d97
commit
7f41d42488
2 changed files with 62 additions and 1 deletions
|
|
@ -121,3 +121,41 @@ async def test_existing_identity_is_never_overwritten(tmp_path):
|
|||
rep = await bf.backfill_task_record_ids(_Session([row]), [root], dry_run=False)
|
||||
assert row.record_id == "OTHER-WP-0001-T09"
|
||||
assert rep.conflicts and rep.updated == 0
|
||||
|
||||
|
||||
def test_a_bare_task_id_is_qualified_by_its_workplan(tmp_path):
|
||||
"""`T01` is unique inside one workplan and meaningless outside it.
|
||||
|
||||
Stored raw, every workplan's first task shares one identity — 51 such ids
|
||||
were assigned to 148 rows on central before this was caught.
|
||||
"""
|
||||
root = _repo(tmp_path, "a", (
|
||||
"---\nid: LLM-WP-0001\ntype: workplan\n---\n\n"
|
||||
'```task\nid: T01\nstate_hub_task_id: "11111111-1111-5111-8111-111111111111"\n```\n'
|
||||
))
|
||||
pairs, _ = bf.collect_pairs([root])
|
||||
assert pairs == {"11111111-1111-5111-8111-111111111111": "LLM-WP-0001-T01"}
|
||||
|
||||
|
||||
def test_two_workplans_first_tasks_do_not_collide(tmp_path):
|
||||
a = _repo(tmp_path, "a", (
|
||||
"---\nid: A-WP-0001\ntype: workplan\n---\n\n"
|
||||
'```task\nid: T01\nstate_hub_task_id: "11111111-1111-5111-8111-111111111111"\n```\n'
|
||||
))
|
||||
b = _repo(tmp_path, "b", (
|
||||
"---\nid: B-WP-0001\ntype: workplan\n---\n\n"
|
||||
'```task\nid: T01\nstate_hub_task_id: "22222222-2222-5222-8222-222222222222"\n```\n'
|
||||
))
|
||||
pairs, rep = bf.collect_pairs([a, b])
|
||||
assert set(pairs.values()) == {"A-WP-0001-T01", "B-WP-0001-T01"}
|
||||
assert rep.conflicts == []
|
||||
|
||||
|
||||
def test_unqualifiable_short_id_gets_no_identity(tmp_path):
|
||||
"""No identity beats a non-unique one."""
|
||||
root = _repo(tmp_path, "a", (
|
||||
"id: not-frontmatter\n\n"
|
||||
'```task\nid: T01\nstate_hub_task_id: "11111111-1111-5111-8111-111111111111"\n```\n'
|
||||
))
|
||||
pairs, _ = bf.collect_pairs([root])
|
||||
assert pairs == {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue