fix(kanban): harden durable artifact handoff
This commit is contained in:
@@ -2392,6 +2392,56 @@ def test_complete_task_persists_scratch_artifacts_before_cleanup(kanban_home):
|
||||
assert str(persisted) != str(artifact)
|
||||
assert run is not None
|
||||
assert run.metadata["artifacts"] == [str(persisted)]
|
||||
with kb.connect() as conn:
|
||||
attachments = kb.list_attachments(conn, t)
|
||||
assert [(a.filename, a.stored_path) for a in attachments] == [
|
||||
("chart.png", str(persisted.resolve()))
|
||||
]
|
||||
|
||||
|
||||
def test_complete_task_rejects_missing_declared_scratch_artifact(kanban_home):
|
||||
"""A declared scratch deliverable must not disappear behind a false Done."""
|
||||
with kb.connect() as conn:
|
||||
t = kb.create_task(conn, title="missing report")
|
||||
task = kb.get_task(conn, t)
|
||||
ws = kb.resolve_workspace(task)
|
||||
kb.set_workspace_path(conn, t, ws)
|
||||
missing = ws / "report.md"
|
||||
|
||||
with pytest.raises(kb.ArtifactPreservationError, match="unavailable"):
|
||||
kb.complete_task(
|
||||
conn,
|
||||
t,
|
||||
result="report complete",
|
||||
metadata={"artifacts": [str(missing)]},
|
||||
)
|
||||
|
||||
assert kb.get_task(conn, t).status == "ready"
|
||||
assert kb.list_attachments(conn, t) == []
|
||||
assert ws.exists(), "failed completion must keep scratch available for retry"
|
||||
|
||||
|
||||
def test_complete_task_preserves_legacy_artifact_path_from_summary(kanban_home):
|
||||
"""Summary-only workers keep the file they tell the user was delivered."""
|
||||
with kb.connect() as conn:
|
||||
t = kb.create_task(conn, title="legacy report")
|
||||
task = kb.get_task(conn, t)
|
||||
ws = kb.resolve_workspace(task)
|
||||
kb.set_workspace_path(conn, t, ws)
|
||||
report = ws / "report.md"
|
||||
report.write_text("legacy deliverable", encoding="utf-8")
|
||||
|
||||
assert kb.complete_task(
|
||||
conn,
|
||||
t,
|
||||
summary=f"Task complete — delivered {report}",
|
||||
)
|
||||
run = kb.latest_run(conn, t)
|
||||
|
||||
persisted = Path(run.metadata["artifacts"][0])
|
||||
assert not ws.exists()
|
||||
assert persisted.read_text(encoding="utf-8") == "legacy deliverable"
|
||||
assert persisted.parent == kb.task_attachments_dir(t)
|
||||
|
||||
|
||||
def test_complete_task_leaves_non_scratch_artifact_paths_unchanged(
|
||||
|
||||
Reference in New Issue
Block a user