Skip to content

fix(gl): scope account-ledger reads to one accounting book - #57

Draft
seonghobae wants to merge 9 commits into
developfrom
fix/account-ledger-book-scope
Draft

fix(gl): scope account-ledger reads to one accounting book#57
seonghobae wants to merge 9 commits into
developfrom
fix/account-ledger-book-scope

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

RED-only General Ledger repair lane

Fixes #56. Period Close #53 is referenced only for the shared persistence.py single-writer boundary; it is not this PR's implementation issue.

Protected parent/current base: develop@239008c4edc7d305c97704c5102b593c6622b36f.
Current exact head: 89b8bcaa6ae3268554171abfebd2a9b65b8cab80.
State: open / Draft / mergeable / intentionally RED.

Buyer/control defect

GET /account-ledgers / lookup_account_ledger currently binds tenant + legal entity + chart-account code (+ optional period) but not an accounting book, while PostgreSQL population/totals omit general_journal.accounting_book_id. Chart-account codes are book-scoped, so statutory and management books under one legal entity may legitimately reuse 110100; current reads can combine their immutable journal lines and totals into one buyer-visible ledger.

Real PostgreSQL evidence already proves the defect: exact 7b22dde45af55d6402cfc99be3c95751b6b622ce, Accounting Foundation 34303435636, returned statutory period_debit_total = 50000.000000 instead of the statutory-only 25000 in a same-legal-entity/two-book/same-account-code scenario.

Admission is also fail-closed: the library must accept one explicit canonical book_reference and reject empty/non-canonical identity before persistence; HTTP must reject a missing book, conflicting book_reference / accounting_book_reference aliases, and repeated canonical keys carrying distinct values instead of selecting first/last arbitrarily. Identical duplicate values may normalize to one logical identity. accounting_book_reference is an HTTP alias only; it is not the canonical library parameter.

TDD lineage

  • b052715d... failed before the accounting assertion because the fixture called .hex on a string tenant id. 7b22dde... repaired only that fixture and then reached the valid PostgreSQL RED: 461 tests / 1 failure, 50000.000000 vs 25000; same-head dependency/SAST/security GREEN.
  • aca6723... added missing-book HTTP RED. 64e467f... repaired touched fixture docstrings only. 0c32d88... added explicit-book library RED. bb032c3... made ADR 0019 code-current while preserving the historical Accepted contract and keeping the book-scope amendment Proposed.
  • 2126d67... added the pre-persistence empty-book RED. f078d58... added real-HTTP conflicting-alias RED. Current 89b8bcaa... adds parameter-pollution RED: repeated canonical book_reference keys with different values must return 400.
  • Two GitHub Code Quality findings proposed renaming RED calls to accounting_book_reference. Exact source disproved both: current lookup_account_ledger has no book parameter at all. Both threads were answered and resolved. Current unresolved inline review-thread count: 0.

Current exact-head evidence — 89b8bcaa...

Accounting Foundation 34331096008 is terminal FAILURE. Exact-head security 102399604235, SAST 102399604423, and dependency diff 102399604432 are terminal GREEN. Accounting job 102399604522 passed container initialization, exact checkout, reproducible timestamp setup, pinned Python and hash-locked dependencies, then failed at Run behavior and repository tests. Coverage/denominator enforcement, repository contracts, compile/import, reproducible package, SBOM/provenance continuation were skipped after behavior RED. Integrated-head attestations were skipped because this is not protected integration.

Standalone SAST 34331096110 and Security 34331096129 are terminal GREEN. Required CodeQL PR 34331096131 is terminal FAILURE at the central required-workflow compatibility boundary, not a leaf source-analysis result: Python receiver 102400983266 and Actions receiver 102400983324 failed terminal enforcement by 08:58:56Z, while the same-run authoritative dispatch job 102402891472 did not start until 09:06:59Z and then succeeded. That exact downstream canary was handed to canonical .github#2040 in comment 5599403046; do not rerun historical CodeQL or manufacture leaf status.

This head is not whole-head GREEN.

Source-writer boundary

Prior Codex handoff terminated on usage limits with no source delta. Prior /opencode handoff 5598678587 also produced no descendant and is explicitly retired.

The single active source writer is successor /opencode handoff 5599374088, scoped only to src/accounting_information_platform/accept.py and src/accounting_information_platform/http_api.py. It must add canonical library book_reference, fail closed before PostgresPostingLedger on missing/empty/non-canonical identity, normalize the HTTP alias, reject conflicting aliases and repeated same-key distinct values, and update only directly affected call sites/tests. It must not edit persistence.py, migrations, #53 source, or shared #37 docs.

The intended admission partial GREEN deliberately leaves the real PostgreSQL two-book population/totals RED (50000.000000 vs 25000) intact.

Planned causal GREEN

  1. Admission slice: make library/HTTP book identity GREEN without touching SQL.
  2. Persistence slice only after fix(close): freeze hard-close trial balance evidence #53 ownership is safely reconciled: resolve exactly one active accounting book under tenant/legal entity; constrain both paged line population and full-scope totals by the same general_journal.accounting_book_id; compose optional period inside the same book scope; preserve exact Decimal and immutable facts; valid empty book returns exact zeros; unknown/cross-entity book fails closed; cursor continuation cannot cross books.
  3. Keep ADR 0019 amendment Proposed until one unchanged complete source head is hosted GREEN and normally reaches protected integration.

src/accounting_information_platform/persistence.py remains concurrently mutable in Period Close #53. If #53 produces an ordinary descendant first, read and preserve that intervening delta before the GL persistence repair. No force-push, destructive rebase, source copy, synthetic status, no-op queue churn, self-approval, premature merge, tag, version, or release.

Shared CHANGELOG.md, docs/doctoring/STANDARD_TRACEABILITY.md, and docs/product-technical-gap-baseline.md remain #37's canonical single-writer surfaces and are post-integration handoff only.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 85c93ab9-a0c7-47e6-a6a8-3ed115fa9280

📥 Commits

Reviewing files that changed from the base of the PR and between aca6723 and bb032c3.

📒 Files selected for processing (2)
  • docs/adr/0019-http-account-ledger-inquiry.md
  • tests/test_postgres_account_ledger_book_scope_red.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

ADR 0019가 장부 범위 조회 계약을 문서화했습니다. PostgreSQL RED 테스트가 명시적 장부 조회, 누락된 book_reference 오류, sibling 장부 데이터 제외를 검증합니다.

Changes

원장 장부 범위 검증

Layer / File(s) Summary
장부 범위 계약 문서화
docs/adr/0019-http-account-ledger-inquiry.md
기존 무범위 조회를 역사적 계약으로 기록하고, 라이브러리와 HTTP 조회에 명시적 장부 참조를 요구하는 제안과 장부별 합계·페이지 범위를 정의합니다.
PostgreSQL 원장 범위 회귀 검증
tests/test_postgres_account_ledger_book_scope_red.py
PostgreSQL에 관리 장부와 계정 데이터를 생성합니다. 라이브러리 조회의 지정 장부 범위, HTTP 조회의 book_reference 필수 오류, sibling 장부 제외를 검증합니다. 모듈 직접 실행 진입점도 추가합니다.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to bb032

This change documents and tests the required accounting-book scoping behavior for account-ledger reads. It introduces no production behavior change, and the RED cases intentionally capture the existing cross-book leakage for follow-up implementation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning [56]의 PostgreSQL 회귀 테스트, 명시적 book_reference 요구, HTTP 400 검증, ADR 갱신은 반영되었습니다. 그러나 lookup_account_ledger, _get_account_ledger, PostgresPostingLedger.load_account_ledger의 실제 장부 해석과 `accounting_b… [56]의 최소 인과 수리를 구현하십시오. 라이브러리와 HTTP 경계에서 book_reference를 요구하고, 요청된 법인 아래에서 정확한 장부를 해석한 뒤, 원장 라인 조회와 전체 합계 조회 모두에 accounting_book_id 조건을 적용하십시오. 빈 장부, 잘못된 장부와 교차 법인 장부, 기간 필터, 페이지네이션, 정확한 Decimal 값을 검증하는 GREEN 테스트와 필요한 증거를 추가하십시오. `persi…
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed 변경은 회계장부 범위 결함에 대한 PostgreSQL 회귀 테스트와 ADR 0019 갱신으로 한정됩니다. 테스트 보조 로직과 ADR 내용은 [56]의 요구사항에 직접 연결됩니다. [53]이 소유한 persistence.py에는 경쟁 변경이 없습니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. (1 skipped: 1 …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 회계장부 기준으로 계정 원장 조회 범위를 제한하는 변경을 정확히 설명합니다. 테스트와 ADR 중심의 변경이라는 세부 내용은 포함하지 않지만, PR의 핵심 목적과 직접 관련됩니다.
Full details: Linked Issues check

Explanation

[56]의 PostgreSQL 회귀 테스트, 명시적 book_reference 요구, HTTP 400 검증, ADR 갱신은 반영되었습니다. 그러나 lookup_account_ledger, _get_account_ledger, PostgresPostingLedger.load_account_ledger의 실제 장부 해석과 accounting_book_id SQL 제한은 구현되지 않았습니다. 빈 장부, 잘못된 장부, 교차 법인 장부, 장부 간 페이지 경계도 아직 생산 코드에서 보장되지 않습니다. [53]의 persistence.py 단일 작성자 제약은 위반하지 않았습니다.

Resolution

[56]의 최소 인과 수리를 구현하십시오. 라이브러리와 HTTP 경계에서 book_reference를 요구하고, 요청된 법인 아래에서 정확한 장부를 해석한 뒤, 원장 라인 조회와 전체 합계 조회 모두에 accounting_book_id 조건을 적용하십시오. 빈 장부, 잘못된 장부와 교차 법인 장부, 기간 필터, 페이지네이션, 정확한 Decimal 값을 검증하는 GREEN 테스트와 필요한 증거를 추가하십시오. persistence.py 변경은 [53]의 현재 변경과 정상적으로 재조정하십시오.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/account-ledger-book-scope

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Hosted precursor failure was verified on exact b052715dcb4ff8a879665101c01ef887e0653e22 in Accounting Foundation 34302807663 / Accounting job 102313165962: 461 tests ran and the new GL scenario errored before the intended cross-book assertion because tenant_id is a string fixture and _seed_management_book() called .hex on it (AttributeError: 'str' object has no attribute 'hex'). This is not accepted as the accounting RED.

I repaired only that fixture identity on ordinary descendant 7b22dde45af55d6402cfc99be3c95751b6b622ce: the management-book suffix now derives deterministically from str(tenant_id).replace('-', '')[:8]. No production/API/SQL/ADR authority changed. Fresh exact-head workflows are queued; keep Draft and do not begin the production book-scope change until a hosted run reaches the actual cross-book ledger assertion. If another setup prerequisite fails first, repair only that prerequisite and rerun.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head bb032c3e850e8e044874a57d65718996136106b0, especially the new public-library book-identity RED and ADR 0019's historical-Accepted / Proposed-amendment boundary. This remains a Draft RED lane; do not treat failing behavior tests as a merge recommendation and do not suggest a competing persistence.py edit while #53 owns that mutable surface.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

@seonghobae I will review the current head. I will focus on the public-library book-identity RED and the ADR 0019 boundary. I will treat the failing RED tests as expected Draft evidence. I will not recommend a competing src/accounting_information_platform/persistence.py change while #53 owns that surface.


✏️ Learnings added
Learnt from: seonghobae
URL: https://github.com/ContextualWisdomLab/accounting-information-platform/pull/57

Timestamp: 2026-09-09T05:09:19.120Z
Learning: For the Accounting Information Platform book-scope work, pull request `#57` is a Draft RED lane. Failing behavior tests are expected regression evidence and are not merge recommendations. Pull request `#53` owns the mutable `src/accounting_information_platform/persistence.py` surface, so reviews of `#57` must not recommend competing changes to that file.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

seonghobae commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Retired source handoff. It produced no observed descendant from 2126d67a2e5f3c141e46621bf674d1e664239d16 and has no reaction/acknowledgement. Do not execute this stale instruction. A fresh exact-head single-writer invocation supersedes it; any executor that already loaded this comment must re-read the live branch and yield if the admission delta is already present. No force-push/rebase.

Comment thread tests/test_postgres_account_ledger_book_scope_red.py
Comment thread tests/test_account_ledger_book_admission_red.py

seonghobae commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Retired source handoff on 2026-09-09 after a fresh live check: PR #57 is still exact 2126d67a2e5f3c141e46621bf674d1e664239d16, this comment has no reaction/acknowledgement, and no admission descendant materialized. Do not execute this stale /opencode instruction. A fresh exact-head Codex continuation supersedes only this execution handoff, not the RED contract or source history. Any executor that already loaded it must re-read the live branch and yield if the admission delta is present. No force-push/rebase; persistence.py remains outside this admission slice.

Copy link
Copy Markdown
Contributor Author

@codex address that feedback

Continue PR #57 as the single active source writer for the admission slice only. Re-read the live PR before writing. Expected head is 2126d67a2e5f3c141e46621bf674d1e664239d16; if an ordinary descendant already exists, adopt it and apply only the still-missing delta. Never force-push or rebase.

Implement only the non-overlapping General Ledger admission repair proven by the checked-in REDs. Allowed production files: src/accounting_information_platform/accept.py and src/accounting_information_platform/http_api.py. Do not edit src/accounting_information_platform/persistence.py; Period Close #53 still owns that mutable surface. Do not edit #37-owned shared CHANGELOG.md, docs/doctoring/STANDARD_TRACEABILITY.md, or docs/product-technical-gap-baseline.md.

Required behavior:

  • Add canonical required book_reference to public lookup_account_ledger(...).
  • Reject missing/empty/non-canonical book identity with AccountingValidationError before constructing or using PostgresPostingLedger; preserve the current tenant/entity/account/period/page/cursor validation and read-only behavior.
  • GET /account-ledgers must require one book identity. Accept book_reference; accounting_book_reference may be accepted only as an equivalent HTTP alias. If both are supplied and differ, fail closed with HTTP 400 rather than choosing one. Normalize the selected HTTP value to canonical library book_reference.
  • Update directly affected tests/call sites only as necessary to pass the new public admission contract, using the real book reference already present in their fixtures. Do not invent a default/statutory-book inference.
  • Keep the real PostgreSQL two-book population/totals regression intentionally RED because the SQL book scope belongs to the later persistence slice.

Validation sequence: run the focused admission tests first (tests/test_account_ledger_book_admission_red.py plus the missing-book HTTP/library cases in tests/test_postgres_account_ledger_book_scope_red.py and directly affected HTTP/unit tests). Admission REDs should turn GREEN while the cross-book 50000.000000 vs 25000 PostgreSQL assertion remains the expected sole book-population defect. Then run applicable repository tests for the touched non-persistence slice. Commit/push only an ordinary descendant. Report exact tests and any remaining RED; do not claim whole-PR GREEN, merge readiness, or touch the central CodeQL gate.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard.

seonghobae commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

RETIRED 2026-09-09 after fresh exact-head verification: this handoff produced no source descendant and no acknowledgement while 89b8bcaa6ae3268554171abfebd2a9b65b8cab80 completed its Accounting Foundation run. It is no longer an active writer. Preserve all RED tests and ADR evidence already on the branch; a successor single-writer handoff owns any further admission-slice source work.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exact-head admission review on 89b8bcaa6ae3268554171abfebd2a9b65b8cab80: the existing alias-conflict RED is necessary but not sufficient for an authoritative accounting-book query boundary. Current _first_query(fields, name) returns values[0], so a request carrying book_reference=A&book_reference=B can silently choose one of two distinct accounting scopes after parse_qs has retained both values. For a financial ledger query this is an ambiguity/control defect, not a harmless HTTP parsing detail; upstream proxies/clients must not be able to change effective book scope by parameter-collapse convention.

The ordinary child on this head adds the realistic HTTP/PostgreSQL RED and requires 400 with book_reference named when a repeated canonical key has distinct values. Identical repetition need not fail merely for duplication. Keep the repair in the non-persistence admission slice: inspect the complete value lists for canonical and alias spellings before _first_query, establish one logical book identity, normalize to library book_reference, and only then enter lookup_account_ledger. Do not touch persistence.py or weaken the existing two-book 50000.000000 vs 25000 RED.

This is a COMMENT review, not approval or GREEN. Current exact-head workflows are queued and the active source writer must ordinary-adopt this descendant before producing the minimal admission repair.

Copy link
Copy Markdown
Contributor Author

/opencode

Own PR #57 as the single active source writer for the non-persistence General Ledger admission slice only. The prior handoff 5598678587 is explicitly retired and produced no source descendant. Fresh live head is 89b8bcaa6ae3268554171abfebd2a9b65b8cab80; re-read it before writing and ordinary-adopt any intervening descendant. Never force-push or rebase.

Implement the smallest causal admission repair and nothing else:

  1. In src/accounting_information_platform/accept.py, extend lookup_account_ledger with canonical library argument book_reference. Reject missing/empty/non-canonical book identity with AccountingValidationError before constructing PostgresPostingLedger or touching the database. Preserve cursor validation behavior and all existing exact-decimal/page semantics. Do not rename the library contract to accounting_book_reference.
  2. In src/accounting_information_platform/http_api.py, make /account-ledgers require exactly one logical accounting-book identity. Canonical query spelling is book_reference; accounting_book_reference is only an equivalent HTTP alias. If both spellings are present with different non-empty values, or one spelling is repeated with distinct values, return HTTP 400 and mention book_reference. Identical duplicate values may normalize to the same logical identity. Never pick first/last arbitrarily. Forward the normalized value as book_reference to the library boundary.
  3. Directly affected existing tests/call sites may be updated to pass their real fixture book. Preserve current RED files and ADR 0019. Run the admission-focused tests plus the real PostgreSQL behavior suite.

Hard boundary: do not edit src/accounting_information_platform/persistence.py, migrations, Period Close #53 source, shared CHANGELOG.md, docs/doctoring/STANDARD_TRACEABILITY.md, or docs/product-technical-gap-baseline.md. The intended partial GREEN leaves the two-book population/totals defect RED: statutory expected 25000, current persistence may still return 50000.000000. Do not weaken/skip that oracle. No self-approval, synthetic status, no-op commit, workflow edit, or source-copy workaround.

Acceptance for this slice: empty library book fails before DB; missing HTTP book is 400; conflicting alias is 400; repeated distinct canonical values are 400; explicit valid book reaches current persistence; the remaining failure is the book-unscoped SQL population/totals owned by the later persistence slice after #53 ownership is reconciled.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fresh persistence-slice finding on exact 89b8bcaa6ae3268554171abfebd2a9b65b8cab80: the planned phrase “resolve exactly one active accounting book” needs an executable ambiguity guard before the later SQL repair.

The protected schema does not make accounting_book.book_name unique for a tenant/legal entity. Its uniqueness is on (tenant_account_id, legal_entity_id, book_role_code, valid_from) plus identifier keys; later migrations contain no book_name uniqueness. Meanwhile the existing _require_book_for_close pattern selects accounting_book_id, reporting_currency_code by tenant + legal entity + book_name + valid_to IS NULL and calls .fetchone(). Therefore reusing that helper/pattern for #57 can silently choose one of two simultaneously active rows that share the requested book name/reference but differ in role or effective history. That would replace the current cross-book leak with nondeterministic book authority.

Before the persistence GREEN, add a real PostgreSQL RED that creates two active accounting-book rows for the same tenant/legal entity with the same requested book_name but distinct legal book_role_code/identities, then calls the public account-ledger inquiry and requires fail-closed ambiguity with no sibling ledger disclosure. Keep a positive case proving one exact active match succeeds. The causal implementation must either (a) resolve an actually unique immutable book identity or (b) explicitly detect 0/1/>1 active matches and reject >1; never rely on .fetchone(), implicit row order, book_role_code inference, or current account mappings.

This finding belongs to the later persistence.py slice. Do not expand the active admission writer 5599374088 or compete with Period Close #53. Keep ADR 0019 Proposed until this ambiguity case and the existing two-book 50000.000000 vs 25000 population/totals RED are both GREEN on one unchanged descendant.

seonghobae commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Foundation prerequisite for the #57 persistence phase is now #58 / Draft #59 exact c7584934791f47bfe9d7d64415571b7caf86b0c4.

The original “one active row” framing was incomplete because accounting_book is effective-dated. Same tenant/legal entity + durable book_name may be ambiguous even when only one row has valid_to IS NULL: a finite same-reference row can overlap that open-ended interval. #59 now preserves the open-ended duplicate RED, adds a finite-overlap PostgreSQL RED, and keeps a positive non-overlapping expired-history case. ADR 0022 remains Proposed and requires a database-owned temporal non-overlap invariant plus resolver 0/1/>1 fail-closed behavior; a partial unique index on valid_to IS NULL alone is insufficient.

Keep the current #57 admission writer scoped to accept.py / http_api.py; do not make it solve catalog temporal identity or touch persistence.py. After #58 reaches protected authority and #53 returns the persistence surface, the #57 SQL repair must resolve exactly one book at the inquiry’s effective scope under the protected invariant and bind both ledger lines and full-scope totals to that accounting_book_id. Until those prerequisites integrate, ambiguity remains a RED and ADR 0019 stays Proposed.

Copy link
Copy Markdown
Contributor Author

Foundation prerequisite update for the later persistence slice: #58/#59 has tightened durable book_reference identity from a current-row rule to full half-open effective-time non-overlap. Canonical RED/ADR head is now #59@72e8e342eaeb4edd40c11284f11473a8622aea79: open-ended/open-ended, open-ended/finite, and finite/finite overlaps must fail; exact [a,b) / [b,c) adjacency remains lawful. Keep this PR's active admission writer limited to accept.py/http_api.py. The later persistence.py resolver must select exactly one Accounting Book Entity at the requested effective instant under the integrated #58 invariant; do not use .fetchone(), role inference, or valid_to IS NULL as a substitute. No mutable #59 migration/source bytes are copied here.

Copy link
Copy Markdown
Contributor Author

#58/#59 persistence prerequisite strengthened on exact f2df2e59e5db2c0310980940c4b9fd108de288ed: durable (tenant, legal entity, book_reference) identity must remain temporally non-overlapping under concurrent catalog inserts, not only serial resolution. Hosted PostgreSQL 18.4 Foundation 34348867333 ran 466 tests with 4 intended REDs; the concurrency test used a fresh reference and observed both overlapping transactions commit ({'committed': True}), proving an application-only SELECT-then-INSERT guard would be insufficient. #57 admission writer ownership remains unchanged (accept.py / http_api.py only); do not expand it into persistence.py or #59 migration work. Once #58/#59 and #53 owner prerequisites reach protected lineage, GL population/totals resolution must consume exactly one effective Accounting Book Entity and fail closed on 0/>1 matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[P1 General Ledger] Scope account-ledger reads to one accounting book

1 participant