Skip to content

feat(core): persist bitemporal position reporting relationships - #106

Draft
seonghobae wants to merge 32 commits into
feat/position-reporting-hierarchyfrom
feat/position-reporting-persistence
Draft

feat(core): persist bitemporal position reporting relationships#106
seonghobae wants to merge 32 commits into
feat/position-reporting-hierarchyfrom
feat/position-reporting-persistence

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Buyer-visible gap

PR #94 defines governed Position→Position solid-line reporting snapshots but intentionally leaves durable persistence/mutation out of scope. This stacked Orgmetra-only lane adds normalized bitemporal persistence without deriving supervision from Person, Assignment, or organization-unit parentage.

Governed persistence contract

position_reporting_relationship_record owns stable (tenant, subordinate Position, solid_line) identity and position_reporting_relationship_version owns manager Position plus effective/business time and PostgreSQL-owned system-recorded time. Persisted versions require same-tenant Position references, distinct human reviewer/applying actor, immutable review/application audit+outbox correlation, staffable PositionVersion coverage for both endpoints across the full effective interval, cycle-free graph state, immutable history/TRUNCATE resistance, and FORCE RLS. Person/Assignment/worker identity, compensation, ratings, assessment output, and free-form HR text are absent. RLS is defense in depth and does not replace purpose-bound application authorization.

Repair sequence

  • Initial RED 78e092353be310f2bcefd30c1f7439b5ed1b235e established database-owned recorded time, one durable solid-line anchor per subordinate, same-tenant scope, self-report/cycle rejection, immutable history, audited human-reviewed application, and FORCE-RLS acceptance criteria.
  • Root implementation 209259120d10b1cd18ab1e6184297f5af4730ffc added the normalized relations and guards. 2e421d8927516dd4b67e469c25ef9cf12107ca34 made self-report/cycle regressions transaction-independent.
  • Review/application integrity was strengthened through 566b74570e479735bbc2fedae7c6b56eb35ff3d9, fc1fb92ad208abdc895b1f94a8d637531e126d2b, affa260b1e94e0040fdfcc59f7bcdad5117bd9a4, and cfef3e27258104b2de448580777271e8ac7d16bf: the audit event's orgmetraevidence must equal the reviewed-evidence digest and stored application evidence must equal the immutable audit envelope digest exactly.
  • Concurrency RED 69923053bb8f39fbe9ea876c33443c38b5ef4b63 demonstrated that concurrent opposite edges need serialization; df13397ded4dfa6b605b7ded7cfb7e4468d3f0fc added a transaction-scoped tenant graph advisory lock before graph reads.
  • Staffable endpoint RED 8f0a874761bcf1f84e7d0544fabf9394178773ba showed persistence accepted Position anchors with no staffable PositionVersion coverage. Root repair facfff9d91243fe06639d60a978cb5072cfec64f added position_reporting_has_staffable_coverage(...), using PostgreSQL 16 multirange containment so same-tenant active/open PositionVersion ranges must cover the relationship's entire effective interval.
  • Concurrency-fixture repair 61611908b49a5ff74f2b7f10a2883a2572070b54 added active PositionVersion fixtures for the X/Y race endpoints. Exact-head Position Reporting Persistence Quality run 32688382859, job 97317512146, completed GREEN and proved exact checkout, deterministic provenance, primary persistence regressions, immutable review binding, two-session cycle prevention, and a clean checkout.
  • Audit-semantics regression 2af25408d95ac9bb362f318d218af507c0861f8b added a valid immutable audit/outbox event whose purpose/actor/evidence/subject/result/time all matched the requested mutation but whose governed orgmetrareason was unrelated_change. The RED-head hosted run 32692438893 was cancelled after the branch advanced and is not claimed as terminal RED evidence.
  • Root repair ef8c7776b2520e6839c14da8122aacfe3f6ad1e4 now requires orgmetrareason = approved_reporting_line_change in the authoritative insert guard. ADR 0106 and traceability were aligned in 8ede14cc7430d83955c38c867d1521989a557ea7 and alignment head c35ad114edbce7a4ebafcea793748493f1346351.

Exact-current-head evidence

Current exact head: a367b4ea09f6abb4b6b8523c1e7726ee11bfc483.
Fresh live base: 3f67182bb3065f2fc8fd974bfdd75a390d8a8fdc (PR #94 stack base).

GitHub reports the PR open, draft, mergeable MERGEABLE, merge state CLEAN, review decision NONE. The latest named check run on this exact head is terminal success or skipped. Current exact-head review state is 0 unresolved thread(s), with no APPROVED review record. Any predecessor-head run IDs and GREEN claims elsewhere in this body are historical and do not transfer.

Stack and merge governance

This PR is intentionally stacked on #94. #94 must integrate first; its checks/reviews do not transfer. After #94 integrates, retarget #106 to fresh develop, reconcile migration/document ordering, refetch exact head/base/rules/reviews/threads, and rerun all applicable Foundation/SAST/Security/Recovery/product evidence on the resulting head before review readiness.

PR #95 remains the separate Orgmetra owner for the pre-mutation review packet; this branch consumes only reviewed-evidence digest plus immutable application audit correlation and does not rewrite #95. No dedicated-writer dependency repository or cross-service application table is modified.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@seonghobae
seonghobae marked this pull request as ready for review August 25, 2026 23:30

@devin-ai-integration devin-ai-integration 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.

Devin Review found 4 potential issues.

Open in Devin Review

Comment thread database/migrations/0020_position_reporting_relationship.sql
Comment thread tests/test_position_reporting_concurrency_postgres.sh
Comment thread tests/test_position_reporting_concurrency_postgres.sh
Comment thread docs/adr/0106-position-reporting-persistence.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant