Keep the audit journal of each reconciler pass in its report

The driver now stores the audit events a pass writes to stderr next to
its JSON report, and the apply check requires one
audit.attachment_discarded reason=reconcile for every injected stale
intent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
Artyom
2026-10-30 09:09:15 +03:00
co-authored by Claude Opus 5.5
parent 21937f920f
commit 61dcb6bf13
+8 -3
View File
@@ -78,7 +78,8 @@ def reconcile(*flags, env=None):
if code not in (0, 1) or not out.strip():
raise SystemExit(f"reconciler failed ({code}):\n{err[-800:]}")
report = json.loads(out)
report.update(exit_code=code, wall_seconds=wall)
audit = [json.loads(line) for line in err.splitlines() if '"audit.' in line]
report.update(exit_code=code, wall_seconds=wall, audit=audit)
return report
@@ -192,11 +193,15 @@ def faults(c, check, pre):
)
first = reconcile("--apply", "--deep", *FLAGS)
save("apply-1.json", first)
discarded = sorted(e["attachment_id"] for e in first["audit"] if e["reason"] == "reconcile")
check(
"apply исправляет ровно найденное dry-run",
pick(first["fixed"], FIXABLE) == pick(dry["found"], FIXABLE) and not first["errors"],
"apply исправляет ровно найденное dry-run, удаление намерений — в журнале аудита",
pick(first["fixed"], FIXABLE) == pick(dry["found"], FIXABLE)
and not first["errors"]
and discarded == sorted(injected["pending_stale"]),
dry_run=pick(dry["found"], FIXABLE),
fixed=pick(first["fixed"], FIXABLE),
audit_discarded=len(discarded),
)
second = reconcile("--apply", "--deep", *FLAGS)
save("apply-2.json", second)