fix: bind reconciliation approval to database snapshot - #31
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…onservation' into fix/reconciliation-approval-snapshot
de479ca
into
fix/reconciliation-multi-match-conservation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac72e686f6
ℹ️ 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".
| SELECT 1 | ||
| FROM accounting_core.reconciliation_match AS reviewed_match | ||
| WHERE reviewed_match.match_status_code <> 'proposed' |
There was a problem hiding this comment.
Run the upgrade guard with all-tenant visibility
When 0016 is applied by an unbound, non-BYPASSRLS migration owner, this query sees no rows because reconciliation_match already has forced RLS and current_tenant_account_id() only resolves runtime-role bindings. The migration therefore succeeds despite legacy terminal matches lacking approval evidence, leaving precisely the unbound history the guard claims to reject. Fresh evidence in this revision is that the new upgrade guard performs an ordinary RLS-filtered query rather than using controlled all-tenant migration visibility.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| IF TG_OP = 'UPDATE' | ||
| AND OLD.match_status_code IN ('approved', 'rejected') THEN |
There was a problem hiding this comment.
Keep superseded matches terminal and immutable
After an approved or rejected match is changed to superseded, later updates bypass this branch because it only recognizes approved and rejected as old terminal states. A caller can consequently rewrite the preserved approved_at, move the match back to proposed, or reactivate an approved match using its old immutable approval row and snapshot, defeating supersession as the explicit historical-retirement path.
Useful? React with 👍 / 👎.
Summary
Authority boundary
This slice records reconciliation review evidence only. It does not select chart-account identifiers, post/reverse journals, close periods, or issue accounting receipts.
Dependency
Stacked on PR #29 and its current head
fb8223bd82d51ed5337feae4c0dfa114ce964971onfix/reconciliation-multi-match-conservation.Verification
git diff --check: clean.Review response
The approval snapshot is computed and overwritten by PostgreSQL trigger logic under a shared transaction advisory lock. Candidate identity and terminal approval time are immutable after review evidence exists; allocation lock triggers run before migration 0015 conservation checks. Existing unbound terminal history fails the migration closed.