Reject replay after post-correction authority drift

This commit is contained in:
2026-10-07 08:38:35 +00:00
parent e6ca9a7ff9
commit 3db086a7fd
2 changed files with 25 additions and 5 deletions
@@ -694,7 +694,7 @@ def close_asset_snapshot(basis_date: str = "", source_note: str = "", memo: str
except (TypeError, json.JSONDecodeError):
stored_fingerprint = {"authority": existing_run["request_fingerprint"], "request": ""}
latest_basis_run = conn.execute(
"SELECT id, correction_of_run_id FROM asset_snapshot_runs WHERE basis_date=? ORDER BY rowid DESC LIMIT 1",
"SELECT id, correction_of_run_id, request_fingerprint FROM asset_snapshot_runs WHERE basis_date=? ORDER BY rowid DESC LIMIT 1",
(basis,),
).fetchone()
run_in_correction_chain = False
@@ -714,9 +714,16 @@ def close_asset_snapshot(basis_date: str = "", source_note: str = "", memo: str
if parent_id
else None
)
try:
latest_authority_fingerprint = json.loads(
latest_basis_run["request_fingerprint"]
).get("authority") if latest_basis_run else None
except (TypeError, json.JSONDecodeError, AttributeError):
latest_authority_fingerprint = None
immutable_replay_run = bool(
run_in_correction_chain
and latest_basis_run
and latest_authority_fingerprint == authority_fingerprint
and (
latest_basis_run["id"] != existing_run["id"]
or existing_run["correction_of_run_id"]