feat(reconciliation): add evidence-derived run lifecycle command - #43
Conversation
📝 WalkthroughWalkthrough조정 실행을 Changes조정 실행 라이프사이클
매치 supersession 권한
CI 실행 환경
Estimated code review effort: 5 (Critical) | ~120 minutes Merge Risk: 🟡 Moderate · up to This change can permanently mark a reviewed reconciliation run as reconciled and publish that outcome. The command accepts actor identity without demonstrated binding to the authenticated caller, and the production database-role boundary is not established, creating a risk of misleading provenance or broader-than-intended tenant and evidence access; the transition hash also depends on a database trigger without validating the returned value. Merge should wait for these authority and integrity safeguards or explicit owner acceptance. Sequence Diagram(s)sequenceDiagram
participant Caller
participant reconcile_reconciliation_run
participant PostgreSQL
participant Outbox
Caller->>reconcile_reconciliation_run: reconcile command 제출
reconcile_reconciliation_run->>PostgreSQL: REPEATABLE READ 및 advisory lock 획득
reconcile_reconciliation_run->>PostgreSQL: review evidence와 bridge projection 검증
reconcile_reconciliation_run->>PostgreSQL: transition command 저장
PostgreSQL->>PostgreSQL: reconciled 상태 전이와 evidence freeze 검증
reconcile_reconciliation_run->>Outbox: reconciliation_run_reconciled 기록
reconcile_reconciliation_run-->>Caller: persisted receipt 반환
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 82.98% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 94 functions across 20 files. (11 skipped: 11 unsupported.) ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
@codex review Re-review exact head |
|
@coderabbitai review Please review exact head |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
head='48a1857449303e754a928b98828d114ce7ca1669'
parent='843f0e3bbe10f3bb989292b5bdf9eeee35b0316d'
git cat-file -e "${head}^{commit}"
git cat-file -e "${parent}^{commit}"
echo '== EXACT COMMITS AND RELATIONSHIP =='
git show -s --format='head=%H%nparents=%P%nsubject=%s' "$head"
git show -s --format='parent=%H%nsubject=%s' "$parent"
git merge-base --is-ancestor "$parent" "$head" && echo 'parent-is-ancestor=yes' || echo 'parent-is-ancestor=no'
echo '== CHANGED PATHS =='
git diff --name-status "$parent" "$head"
echo '== CURRENT-HEAD CANDIDATE PATHS =='
git ls-tree -r --name-only "$head" | rg \
'^(database/migrations/[0-9]{4}_.*reconciliation.*[.]sql|src/accounting_information_platform/reconciliation_(lifecycle|run)[.]py|tests/.*reconciliation.*(exception|lifecycle|postgres|authority).*[.]py)$' \
| sort
echo '== EXCEPTION-RESOLUTION LANDMARKS =='
git grep -n -I -E \
'reconciliation_exception_resolution_command_required|reconciliation_exception|resolution_status_code|transition_command|reconcile_reconciliation_run|outbox' \
"$head" -- database/migrations src tests || true
echo '== EXACT DIFF: RELEVANT AREAS =='
git diff --unified=45 "$parent" "$head" -- \
database/migrations \
src/accounting_information_platform/reconciliation_lifecycle.py \
src/accounting_information_platform/reconciliation_run.py \
tests \
| rg -n -C 12 \
'reconciliation_exception_resolution_command_required|reconciliation_exception|resolution_status_code|transition_command|reconcile_reconciliation_run|outbox|postgres' || trueLength of output: 158099 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='48a1857449303e754a928b98828d114ce7ca1669'
show() {
local path="$1" start="$2" end="$3"
printf '\n===== %s: Lines %s-%s =====\n' "$path" "$start" "$end"
git show "${head}:${path}" | nl -ba | sed -n "${start},${end}p"
}
echo '== MIGRATION 0019: IDENTITY, AUTHORITY, HASH, AND STATUS TRIGGERS =='
show database/migrations/0019_reconciliation_run_command_evidence.sql 300 680
echo '== MIGRATION 0019: EVIDENCE-MUTATION GUARD =='
show database/migrations/0019_reconciliation_run_command_evidence.sql 680 790
echo '== APPLICATION LIFECYCLE: REVIEW-STATE VALIDATION AND WRITE ORDER =='
show src/accounting_information_platform/reconciliation_lifecycle.py 35 250
show src/accounting_information_platform/reconciliation_lifecycle.py 285 365
echo '== POSTGRESQL DIRECT-TRANSITION REGRESSION: COMPLETE TEST CLASS =='
git show "${head}:tests/test_reconciliation_lifecycle_aggregate_membership_postgres.py" |
nl -ba |
sed -n '1,245p'
echo '== MIGRATION DISCOVERY AND 0019 INSTALLATION =='
ast-grep outline src/accounting_information_platform/persistence.py \
--items all --type function --match 'migration|foundation|schema' --view expanded
rg -n -C 8 \
'0019_reconciliation_run_command_evidence|migration.*path|glob\(|iterdir\(|sorted\(|apply_foundation' \
src/accounting_information_platform/persistence.py \
src/accounting_information_platform/migration_install.py \
tests/test_foundation_install_manifest_contract.py || trueLength of output: 1986 🏁 Script executed: #!/bin/bash
set -euo pipefail
head='48a1857449303e754a928b98828d114ce7ca1669'
show() {
local path="$1" start="$2" end="$3"
printf '\n===== %s: Lines %s-%s =====\n' "$path" "$start" "$end"
git show "${head}:${path}" |
awk -v start="$start" -v end="$end" \
'NR >= start && NR <= end { printf "%6d %s\n", NR, $0 }'
}
echo '== MIGRATION 0019: IDENTITY, AUTHORITY, HASH, AND STATUS TRIGGERS =='
show database/migrations/0019_reconciliation_run_command_evidence.sql 300 680
echo '== MIGRATION 0019: EVIDENCE-MUTATION GUARD =='
show database/migrations/0019_reconciliation_run_command_evidence.sql 680 790
echo '== APPLICATION LIFECYCLE: REVIEW-STATE VALIDATION AND WRITE ORDER =='
show src/accounting_information_platform/reconciliation_lifecycle.py 35 250
show src/accounting_information_platform/reconciliation_lifecycle.py 285 365
echo '== POSTGRESQL DIRECT-TRANSITION REGRESSION: COMPLETE TEST CLASS =='
git show "${head}:tests/test_reconciliation_lifecycle_aggregate_membership_postgres.py" |
awk '{ printf "%6d %s\n", NR, $0 }' |
sed -n '1,245p'
echo '== MIGRATION DISCOVERY AND 0019 INSTALLATION =='
ast-grep outline src/accounting_information_platform/persistence.py \
--items all --type function --match 'migration|foundation|schema' --view expanded || true
rg -n -C 8 \
'0019_reconciliation_run_command_evidence|migration.*path|glob\(|iterdir\(|sorted\(|apply_foundation' \
src/accounting_information_platform/persistence.py \
src/accounting_information_platform/migration_install.py \
tests/test_foundation_install_manifest_contract.py || trueLength of output: 99842
I used the existing exception-resolution authority learning during this review. I did not execute repository tests in this sandbox. Fresh exact-head PostgreSQL and CI evidence is still required before merge readiness. 🧠 Learnings usedYou are interacting with an AI system. |
|
Child-state correction: current maker-checker child is exact |
|
Migration-sequence repair finding from the Period Close child review Fresh stack inspection found that this PR introduces Treat this as a foundation prerequisite, not a close reason. Before #43 integrates, assign one unique monotonically ordered migration sequence to the #43-owned additions and update The duplicate is not merely cosmetic: filenames are operational migration identity in the checked-in chain, and downstream #52 already treats its own colliding reporting number as provisional pending reconciliation-stack integration. No current migration in this stack is an immutable AIP release, so the safe path remains owner repair -> descendant restack -> exact-head clean-install/upgrade/rollback evidence. |
Buyer outcome
Add the supported command that turns one reviewed reconciliation run into immutable
reconciledevidence. It is tenant-scoped and idempotent, derives eligibility and exact book-to-bank evidence from PostgreSQL-owned facts, persists one transition command and outbox event atomically, and cannot post/reverse journals, close periods, select chart accounts, or alter accounting policy.Exact current state — 2026-09-03
aced5dd96eb5b6ee055073be1def7c9a0c00a542;#29@f58fb3d468088c5bc0fb5a6a2c366b019dd23387;#47@7fab06bc6396ae756e7621f7a0c21c535d71a191;33747860737, queued/non-passing;#29 -> #43 -> #47.This branch adopted the protected-base change non-force and contains current parent ancestry. Predecessor checks/reviews are non-transferable.
Lifecycle authority
#43 owns shared reconciliation command identity, immutable
reconciliation_run_transition_command, database-enforcedreconciledtransition, exact replay from retained transition provenance, and atomicreconciliation_run_reconciledoutbox evidence. Its database snapshot authority reconstructs run/opening-command scope, retained statement balances/entries, assigned cash-book journal population, approved allocations, reviewed match/approval state and exception state; independently recomputes source capacities and exact book-to-bank arithmetic; and replaces caller-selected transition snapshot/population identities before transition hashing.Child #47 composes maker-checker exception-resolution authority without replacing this monetary authority. Current #47 owns a test-first P1 investigation of the raw database lifecycle path: a backend can have a
REPEATABLE READsnapshot established before the session-lock grant even though migration 0027 later proves both advisory locks are held. Commitbe68779...contains the realistic PostgreSQL stale-pre-lock snapshot RED; exact child7fab06bc...adds only test cleanup so an aborted RED transaction cannot mask the intended authority error while releasing its session lock. No production snapshot-freshness fix is claimed until this exact PostgreSQL RED executes and fails for the intended boundary.The supported Python lifecycle path already takes the tenant/run session advisory lock, commits, then opens a fresh
REPEATABLE READtransaction and reacquires the transaction lock. Any child repair must preserve that ordering and make the direct database authority boundary equally fail-closed rather than weakening database-owned snapshot/bridge controls.External boundary
Billing and settlement/payment systems remain foreign evidence producers and cannot write AIS tables or claim statutory posting. Keyverse remains behind a provider-neutral identity/PDP boundary. Context Graph Contracts, Enterprise Architecture Core, contextual-orchestrator and other CWL foundations remain sibling authorities; mutable sibling PR heads, direct source imports and cross-service SQL are not runtime authority.
Merge boundary
Keep Draft. #47 must first observe and repair its current PostgreSQL RED, then pass one unchanged exact-head PostgreSQL/100%-coverage/repository-docstring/SAST/security/dependency/package/SBOM/provenance/reviewer/ruleset evidence set and integrate normally into #43. The changed #43 must then reacquire every applicable gate before integrating into #29. Do not self-approve, bypass, force-push, destructively rebase, transfer predecessor evidence, tag or release while any gate is non-passing.