fix(projection): qualify bare task ids before deriving their identity
Retiring llm-connect's five legacy rows failed on `duplicate key value violates
unique constraint "tasks_pkey"`, and the cause is that a bare `T01` is not an
identifier: it is unique within its workplan, not in the fleet. Unqualified,
uuid5("T01") is the same UUID for every workplan in the fleet that has one —
llm-connect's 91 task blocks derive 49 distinct UUIDs, so creating its
workplans inserts the same task primary key repeatedly in one flush.
Tasks are now qualified with their owning workplan before derivation, which is
the rule `task_record_id_backfill.qualify_task_id` already applies to stored
ids; the two must agree or the backfill and the projection disagree about what
a task is called. Already-qualified ids are untouched.
The create path's comment claimed it was "safe only because nothing exists to
mis-match against: this workplan is new to the hub". That was true of other
workplans and false within one: the collision was among the tasks it was
inserting itself.
The failed pass rolled back cleanly — llm-connect's five legacy rows are still
live and progress events are intact.
742 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
034eda9287
commit
b43a1e5728
2 changed files with 58 additions and 4 deletions
|
|
@ -845,3 +845,45 @@ class TestUuidMatchWins:
|
|||
uuid_at = src.index("want_by_uuid.get(str(row.id))")
|
||||
rekey_at = src.index("_identity_is_derived(row) or _slug_is_identifier")
|
||||
assert uuid_at < rekey_at, "UUID match must precede the re-key heuristics"
|
||||
|
||||
|
||||
class TestTaskIdentityIsQualified:
|
||||
"""A bare `T01` is unique within its workplan, not in the fleet.
|
||||
|
||||
Unqualified, `uuid5("T01")` is the same UUID for every workplan that has a
|
||||
T01 — llm-connect's 91 task blocks derive 49 distinct UUIDs, and creating
|
||||
its workplans dies on `duplicate key value violates unique constraint
|
||||
"tasks_pkey"`.
|
||||
"""
|
||||
|
||||
BODY = """
|
||||
```task
|
||||
id: T01
|
||||
status: done
|
||||
```
|
||||
|
||||
```task
|
||||
id: T02
|
||||
status: todo
|
||||
```
|
||||
"""
|
||||
|
||||
def test_short_ids_are_qualified_by_their_workplan(self):
|
||||
a = fp._parse_tasks(self.BODY, "LLM-WP-0001")
|
||||
b = fp._parse_tasks(self.BODY, "LLM-WP-0002")
|
||||
assert [t.record_id for t in a] == ["LLM-WP-0001-T01", "LLM-WP-0001-T02"]
|
||||
assert {t.uuid for t in a}.isdisjoint({t.uuid for t in b})
|
||||
|
||||
def test_an_already_qualified_id_is_left_alone(self):
|
||||
body = "```task\nid: LLM-WP-0009-T03\nstatus: todo\n```"
|
||||
assert fp._parse_tasks(body, "LLM-WP-0001")[0].record_id == "LLM-WP-0009-T03"
|
||||
|
||||
def test_it_agrees_with_the_backfill(self):
|
||||
"""Both must apply the same rule or they disagree on a task's name."""
|
||||
from api.services.task_record_id_backfill import qualify_task_id
|
||||
got = fp._parse_tasks(self.BODY, "LLM-WP-0001")[0].record_id
|
||||
assert got == qualify_task_id("T01", "LLM-WP-0001")
|
||||
|
||||
def test_uuid_follows_the_qualified_id(self):
|
||||
t = fp._parse_tasks(self.BODY, "LLM-WP-0001")[0]
|
||||
assert t.uuid == fp.derived_record_uuid("LLM-WP-0001-T01")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue