Skip to content

chore(infra): record why AuditEvents is not time-partitioned - #522

Merged
mforce merged 3 commits into
mainfrom
chore/505-audit-events-partition-decision
Aug 13, 2026
Merged

chore(infra): record why AuditEvents is not time-partitioned#522
mforce merged 3 commits into
mainfrom
chore/505-audit-events-partition-decision

Conversation

@mforce

@mforce mforce commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #505.

Test plan

  • Documentation-only change, no behavioral impact — no tests applicable (per this repo's TDD skill: pure doc changes are out of scope for the RED/GREEN cycle).
  • Local pi (deepseek-v4-flash) review pass for internal consistency + factual accuracy of the Postgres partitioning claims.

Parks the #494 review's partitioning question as a decision record instead
of leaving it to be re-litigated: the dominant provenance read carries no
date predicate, so monthly partitioning would strictly worsen that query's
index lookup, add a new INSERT-fails failure mode inside the same
transaction as the audited mutation (#93), and drag in a migration + schema
regen + sim-harness pass for a table nowhere near needing it (~20 MB/year
at 100 flocks). If it ever bites, partition by AccountId instead, once
genuinely multi-tenant.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa19cb0306

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +42 to +43
1. **Archive or roll up** rows older than the retention the farm actually
needs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve provenance when archiving audit rows

This recommendation is unsafe as written because GetProvenanceAsync derives CreatedBy* exclusively from the original *.Create event and derives MadeOfficialAtUtc from the promotion event. If a retention job archives or rolls up those old rows while the corresponding flock, grade, expense, or order remains visible, its page will silently lose provenance even if newer audit rows remain. Specify that archival must keep these events queryable (or persist equivalent provenance) rather than simply removing or aggregating rows from AuditEvents.

AGENTS.md reference: AGENTS.md:L53-L53

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 95ef998: the archival bullet now names the actual hazard (GetProvenanceAsync reads CreatedBy*/MadeOfficialAtUtc straight from the original *.Create/promotion events for as long as the record stays visible) and says any archival design must keep those source events queryable, not just drop/roll up by age.

mforce added 2 commits August 12, 2026 19:21
)

Local pi review: "strictly worse, forever" overstated the cost — a
partitioned scan reads the same total data, so the degradation is
per-partition constant-factor overhead (planner cost, tuple routing), not
a data-read increase. The decision doc's own wording ("getting worse every
month") was already precise; only the AGENTS.md compressed bullet needed
the fix, kept consistent with it.
…rovenance

codex review of #522: "archive or roll up" as a future mitigation was
underspecified enough to be unsafe — GetProvenanceAsync reads CreatedBy*/
MadeOfficialAtUtc straight from the original audit events for as long as
the record stays visible, so archiving by age alone could silently blank
a still-visible record's History column. Now says so explicitly.
@mforce

mforce commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

@codex addressed in 95ef998 — see thread reply above.

@chatgpt-codex-connector

Copy link
Copy Markdown

The reviewer’s concern is already fully addressed in commit 95ef998. The decision record now:

No additional changes were necessary, so I did not create another commit or pull request.

Checks

  • git show --format=fuller --no-ext-diff HEAD -- docs/decisions/505-audit-events-no-time-partition.md
  • git diff --check HEAD^..HEAD
  • git status --porcelain (working tree clean)
  • ⚠️ git diff --check 851033b2e986b95aed8bfeb580c9446130b639e6..HEAD (the PR base commit is unavailable in the local checkout)

View task →

@mforce
mforce merged commit 0a8e581 into main Aug 13, 2026
9 checks passed
@mforce
mforce deleted the chore/505-audit-events-partition-decision branch August 13, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(infra): do not partition AuditEvents by time — record why, and what to do instead

1 participant