Skip to content

Commit ac851d5

Browse files
test: bind tc run evidence to reported task id (#114)
Assert that the route_decision and worker_result events from one tc run invocation carry the same task_id, and that it matches the identifier the CLI reported. The test omits --task-id so the value is the one tc run generated for itself, proving the persisted evidence belongs to the run the operator was shown rather than to an id supplied by the test. Test-only; no production behavior changed. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 021bed6 commit ac851d5

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎tests/test_tc_run_cli.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"""
1313

1414
import json
15+
import re
1516
from types import SimpleNamespace
1617
from unittest.mock import patch
1718

@@ -124,6 +125,28 @@ def test_local_success_exits_zero_and_records_governed_evidence(tmp_path, capsys
124125
assert "Success: task ran locally" in capsys.readouterr().out
125126

126127

128+
def test_route_and_worker_evidence_share_cli_reported_task_id(tmp_path, capsys):
129+
client = TriageClient(backend=RecordingBackend())
130+
# No --task-id, so the identifier is the one tc run generated for itself.
131+
# Reading it back out of the success line is what proves the persisted
132+
# evidence belongs to the run the operator was told about.
133+
args = _args("Summarize this text", ledger_dir=str(tmp_path))
134+
135+
tc_cli.tc_run(args, client=client)
136+
137+
reported = re.search(r"task_id=([^)]+)\)", capsys.readouterr().out)
138+
assert reported, "tc run must report the task_id it ran under."
139+
reported_task_id = reported.group(1)
140+
141+
events = _ledger_events(tmp_path / "ledger.jsonl")
142+
route_decision = next(e for e in events if e["event_type"] == "route_decision")
143+
worker_result = next(e for e in events if e["event_type"] == "worker_result")
144+
145+
assert route_decision["task_id"] == worker_result["task_id"]
146+
assert route_decision["task_id"] == reported_task_id
147+
assert worker_result["task_id"] == reported_task_id
148+
149+
127150
def test_tc_run_persists_metadata_without_prompt_or_data_content(tmp_path):
128151
prompt = "PROMPT_SENTINEL_ONLY_FOR_PRIVACY_TEST"
129152
data = "DATA_SENTINEL_ONLY_FOR_PRIVACY_TEST"

0 commit comments

Comments
 (0)