ops: bound allowance_log growth; correct stale README claims (audit L4+L5)
allowance_log: the sweep and every report-mode run used to append a row per member per run (~500/day measured). The insert is now an upsert per (member, cycle, decision) — a re-derived decision updates the row's evidence and timestamp; a decision CHANGE still gets its own row. No index or migration; the latest-decision readers are unaffected; history is not rewritten. README: scheduler runs 3x/day (0 3,11,19 UTC), not nightly-3am; the sweep's auth is the ADMIN_TOKEN X-Admin-Token header, not WEBHOOK_TOKEN; the retired free/member/supporter tier budgets replaced by the actual single MEMBER_BUDGET model; the unread OPENCOLLECTIVE_WEBHOOK_SECRET env row removed.
This commit is contained in:
1 parent
1127b41ba3
commit
00f60f1374
2 files changed
+34
-16
No files matched your search
+19
-4
@@ -5026,11 +5026,26 @@ async def reconcile_allowances(send: bool = False) -> dict:
|
||||
await revoke_member_litellm_access(email)
|
||||
await listmonk_sync(email, subscribe=False)
|
||||
|
||||
conn.execute(
|
||||
"INSERT INTO allowance_log (email, cycle, decision, evidence, anchor_day)"
|
||||
" VALUES (?, ?, ?, ?, ?)",
|
||||
(email, cycle_key, decision, evidence, anchor_day),
|
||||
# L4 (audit 2026-11-05): one row per (member, cycle, decision) — the
|
||||
# same decision re-derived on a later run UPDATES that row's evidence
|
||||
# and timestamp instead of appending a duplicate. The sweep runs 3x/day
|
||||
# and report-mode runs also write here; without this the table grew
|
||||
# ~500 rows/day (measured 2026-11-05: 1741 -> 2257). A decision CHANGE
|
||||
# within a cycle still gets its own row, so the "latest decision per
|
||||
# member" readers are unaffected and no history is rewritten.
|
||||
cur = conn.execute(
|
||||
"UPDATE allowance_log SET evidence = ?, anchor_day = ?, "
|
||||
"decided_at = datetime('now') "
|
||||
"WHERE id = (SELECT id FROM allowance_log WHERE email = ? AND cycle = ? "
|
||||
"AND decision = ? ORDER BY id DESC LIMIT 1)",
|
||||
(evidence, anchor_day, email, cycle_key, decision),
|
||||
)
|
||||
if cur.rowcount == 0:
|
||||
conn.execute(
|
||||
"INSERT INTO allowance_log (email, cycle, decision, evidence, anchor_day)"
|
||||
" VALUES (?, ?, ?, ?, ?)",
|
||||
(email, cycle_key, decision, evidence, anchor_day),
|
||||
)
|
||||
conn.commit()
|
||||
decisions.append({"email": email, "slug": oc_slug, "anchor_day": anchor_day,
|
||||
"cycle": cycle_key, "decision": decision, "evidence": evidence})
|
||||
|
||||
Reference in new issue
Block a user