A lifecycle audit table is the easiest artifact to fake and the hardest to verify. It looks like a decision log: old_state, new_state, changed_at. Hundreds of thousands of rows, and the comfortable implication that each one is a decision somebody made about a model.

This post takes one such table — ai_models_audit in a production football-prediction system, 347,283 rows written between 2026-08-15 and 2026-12-03 — and asks a narrower question than "is the audit complete": can this ledger explain the current state of the system? For 11,382 models the last row does match the table. For the rest it cannot, and the reasons are structural rather than accidental.

The overnight log of one model

Here is the tail of model_id = 24316, ordered newest first, on the morning this was measured:

changed_at old new app_name 2026-12-03 06:00:11.387224 active evolving (empty) 2026-12-03 05:47:59.129704 active BLOCKED_is_protected worker [guard:is_protected] 2026-12-03 05:47:59.129704 active eliminated soccerdream_worker 2026-12-03 05:42:14.838527 active BLOCKED_is_protected worker [guard:is_protected] 2026-12-03 05:42:14.838527 active eliminated soccerdream_worker 2026-12-03 05:36:25.409435 active BLOCKED_is_protected worker [guard:is_protected] 2026-12-03 05:36:25.409435 active eliminated soccerdream_worker 

Every row has the same old_state, which is the first tell. active -> eliminated followed immediately by active -> BLOCKED_is_protected at the identical timestamp means the write never landed: the second row is the refusal, and the next attempt still starts from active. The row seven minutes later, active -> evolving with an empty app_name, is a different writer resetting the field.

Over its lifetime this model accumulated 1,119 rows of active -> eliminated and 1,130 rows of active -> BLOCKED_is_protected, starting 2026-09-29. It is currently evolving. In the preceding 24 hours it produced 97 rows across 6 distinct hours — 2,249 rows of a retry loop, faithfully recorded.

Four counts that describe "the models" and cannot all be right

Quantity Value
Rows in ai_models_audit 347,283
Distinct model_id in the ledger 20,227
Rows in ai_models 11,412
Distinct model_id in ai_predictions 4,037

The gap between the first two and the third is not rounding. 8,845 ledger model ids have no row in ai_models at all — 24,329 rows of history for models that were hard-deleted. Going the other way, 16,614 ledger models never produced a single prediction (70,024 rows). A table that reads as "the history of our models" is largely a history of models that no longer exist or never shipped a single analysis. Any "transitions per model" chart computed from it divides by 20,227 rather than by the roster.

77% of the ledger is two columns arguing with each other

Counted as pairs, it is not a lifecycle story:

SELECT old_lifecycle, new_lifecycle, count(*) AS rows, count(DISTINCT model_id) AS models FROM ai_models_audit WHERE old_lifecycle IS NOT NULL GROUP BY 1, 2 ORDER BY rows DESC LIMIT 6; 
old_lifecycle | new_lifecycle | rows | models active | evolving | 136,655 | 11,667 evolving | active | 131,805 | 11,164 active | eliminated | 19,645 | 8,581 active | demoted | 18,082 | 7,122 demoted | active | 11,728 | 1,899 active | BLOCKED_is_.. | 8,598 | 90 

The first two rows are 268,460 of 347,283 lines — 77.30% — and they are not decisions. ai_models carries both status and lifecycle_status, and active in one column corresponds to evolving in the other. Each writer syncs its column from the other's, the sync fires the trigger, and the trigger records a rename as a lifecycle event.

The churn rate confirms it: between consecutive rows of the same model the median gap is 304 minutes, the 5th percentile is 0 minutes, and 18,103 gaps (5.54%) are under 60 seconds. A state machine that flips twice within a minute, tens of thousands of times, is not deciding anything.

Who wrote the rows

app_name looks like attribution. It is application_name, which any client may set and many do not:

app_name rows share
(empty) 166,559 47.96%
application sessions 163,197 46.99%
... [guard:...] 12,496 3.60%
psql 5,031 1.45%

Nearly half the ledger has no author, and the 1.45% that says psql is not one statement per row: 875 models moved in a single minute on 2026-09-21 22:26, 793 on 2026-08-23 01:27. 8,710 distinct seconds contain two or more rows, and those seconds hold 345,116 rows — 99.38% of the ledger. Almost nothing here was written one model at a time by a process reasoning about that model.

The ledger records attempts, not commits

The cleanest evidence is that the ledger contains states the table cannot hold. ai_models.lifecycle_status has 11 distinct values. The ledger has 16, and the five extra ones are written 12,498 times:

SELECT new_lifecycle, count(*) AS rows, count(DISTINCT model_id) AS models FROM ai_models_audit WHERE new_lifecycle LIKE 'BLOCKED%' GROUP BY 1 ORDER BY rows DESC; 
BLOCKED_is_protected | 9,362 | 100 BLOCKED_eliminated | 1,972 | 297 BLOCKED_demoted | 1,013 | 221 BLOCKED_retired | 151 | 10 

These are refusal markers written into a column named new_lifecycle. There is no result column, no applied boolean, and therefore no way to tell "the write happened" from "the write was rejected" except by inference from the old_state of the next row. The median interval from a BLOCKED_* row to the next row on the same model is 12 minutes; 7 refusal rows have no following row at all, so for those models the ledger's final statement is a state that was never entered.

Only 6 of 11,382 models disagree with the table — 0.05%, which sounds excellent until you read them: all six end on a BLOCKED_* value. The ledger is not wrong about the destination. It is ambiguous about whether a row happened.

The retry loop is the mechanism, not a bug in it

Elimination is attempted every cycle, a guard refuses it, the refusal is logged, the state is reset. Aggregated over 30 days: 6,670 rows attempt -> eliminated across 787 models, and 17 models attempt it at least 10 times each while still not being eliminated, together accounting for 5,503 rows.

Top of the list, all currently evolving: model 24316 (1,155 attempts, last at 2026-12-03 05:47), 25954 (1,103), 23461 (1,002), 24108 (1,000), 25949 (771). Five models account for 5,031 audit rows — 1.4% of the table — describing a decision the system kept making and kept refusing.

The idle cleaner mostly undoes itself

ai_models_idle_log is a one-row-per-run summary of a periodic sweep. It is the audit of the audit, and it reports the opposite of its name:

Field Total across 1,813 runs
tier1_demoted 82
tier2_deleted 0
tier3_archived 0
revived 11,195

The sweeper revived 136 times more models than it demoted, and never deleted or archived one. 723 of 1,813 runs contained at least one revival. The stated cadence is every two hours; the observed median interval between runs is 60 minutes, with 3 gaps above 4 hours and a maximum of 154 hours.

Protection explains part of it. 149 models carry is_protected = true and hold 7,811 of 52,027 predictions (15.0%). The flag is not absolute: 5 protected models are currently eliminated, so the guard that wrote BLOCKED_is_protected 9,362 times has leaked at least five times.

The human-readable log is 0.79% of the machine-readable one

A second table, model_evolution_log, carries a change_description text column and has 2,755 rows against the ledger's 347,283. Rows typed state_transition: 5. Two upgrade rows record accuracy_before = accuracy_after, a change with no change in it. The narrative record is a rounding error next to the trigger record, and the trigger record cannot say who decided or whether the decision stuck.

Four rules that would have prevented this

  1. Separate intent from outcome. attempted_state, applied boolean, refusal_reason. A ledger without a result column can be read but never reconciled.
  2. Constrain target values to the enum. A CHECK (new_lifecycle IN (...)) rejects all 12,498 phantom rows at write time and turns the loop into an error instead of 9,362 lines of prose.
  3. Suppress no-ops and duplicates. If old_state = new_state, do not write; if a transition repeats within the sweep interval, increment a retry counter instead of appending an event. That removes 77% of the volume.
  4. Make the author non-nullable. application_name is client-controlled and empty 47.96% of the time; a NOT NULL author set via SET LOCAL distinguishes "a bulk update moved 875 models" from "something moved 875 models".

A verification pass fits in CI: replay the ledger in timestamp order, apply only rows whose target is a valid state, and compare the reconstruction against the table.

import psycopg2 VALID = {"evolving","active","demoted","eliminated","retiring","archived", "hibernating","pending_retrain","retraining","incubating","validating"} con = psycopg2.connect("postgresql://user:pw@127.0.0.1:5433/app") cur = con.cursor() cur.execute("""SELECT model_id, new_lifecycle FROM ai_models_audit ORDER BY model_id, changed_at, id""") replayed, rejected = {}, 0 for model_id, new_state in cur.fetchall(): if new_state not in VALID: # refusal marker, not a state rejected += 1 continue replayed[model_id] = new_state cur.execute("SELECT id, lifecycle_status FROM ai_models") drift = [(i, s, replayed.get(i)) for i, s in cur.fetchall() if replayed.get(i) != s] print("replayed:", len(replayed), "rejected rows:", rejected) print("drift:", len(drift), drift[:5]) 

On this dataset it rejects 12,498 rows and reconstructs 11,382 models; the six terminal mismatches were found by running it once.

What this means for reproducibility

An audit log is only as good as the question it can answer. For "did anything touch this model", a trigger log suffices, and this one answers it 347,283 times. For "what decided this model's fate", it answers nothing: 77% is a naming disagreement, 48% has no author, 99.38% arrived in bursts, and the decisive-looking rows are refusals. The fix is not more logging but fewer, typed, attributable rows — one per decision, with the outcome stored as a value instead of implied by what came next.

Analytics and research content. Not betting advice. 18+

本内容仅供数据分析与研究参考,不构成任何决策建议。