Skip to content

fix(people): protect governed mutation runtime types - #64

Draft
seonghobae wants to merge 75 commits into
developfrom
fix/hire-identity-type-integrity
Draft

fix(people): protect governed mutation runtime types#64
seonghobae wants to merge 75 commits into
developfrom
fix/hire-identity-type-integrity

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Scope

Canonical Orgmetra People mutation runtime/contract-integrity lane. HR mutation truth stays in Orgmetra; this PR does not copy mutable shared-kernel, authorization, feature-lane, workflow-owner, or Assignment source.

Protected base remains develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f. Current exact head is a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4; the PR is open · Draft · mechanically mergeable. Predecessor checks/reviews do not authorize this head.

Retained repair chain

#215#225 retain hire/generic PostgreSQL trust-boundary hardening. #226#228 retain application/direct-Port post-construction command/result revalidation. #229 binds unexplained exact revalidated Employment/Position/Assignment results to pre-port target UUID snapshots and keeps confirmed-hire exact materialization identities command-bound. #230 detaches generic commands at direct PostgreSQL adapter entry. #231 detaches generic and confirmed-hire application commands before purpose-bound authorization/port callbacks. #232 requires exact built-in allocation-ratio HTTP text. #233 aligns parser/OpenAPI Assignment allocation with the authoritative strictly-positive (0, 1.0000] domain.

#233 strictly-positive Assignment allocation contract

Test-only abd5dc506d363897d0396dc9e75b1e389b47c71f established parser/schema RED for 0.0000; 7a95aa95a6a9cf4497b301ffee0748555d98776e repaired the parser and f659b652fbe307134792370ac273514f0b1830a0 repaired the published OpenAPI. 8f986853a6f234c317e29080c4982bab34f3dc51 completed the intended manifest reseal after an unrelated manifest-copy mistake was repaired by ordinary successor. #233 remains open until normal protected integration or a verified successor fully carries the delta.

#246 real hosted RED and idempotent-replay repair

Foundation run 33947715482, Repository quality job 101256719960, on exact predecessor 8f986853a6f234c317e29080c4982bab34f3dc51 actually executed. Candidate-evidence, HRIS-kernel, Keyverse, migration, Naruon, offer, requisition, selection and job-analysis suites passed with their owned 100% coverage. People API reached 232 passed / 1 failed and 99.48% total coverage. The failing contract was PostgresPeopleMutationTests.test_same_key_replays_without_second_hris_or_audit_facts: create_employment_record(...) raised PeopleMutationIntegrityError("employment result identity does not match command") before later replay branches could execute.

This is a production-contract conflict, not a stale fixture. docs/API_CONTRACT.md and docs/TEST_STRATEGY.md already require an identical tenant/route/idempotency-key retry to return the first committed created-record identity. Employment/Position/Assignment generated IDs are intentionally excluded from mutation_command_digest(...), so a retry may allocate fresh record/audit/outbox UUIDs and still be the same semantic command. #229's unconditional generic result-ID equality made that documented replay impossible. Confirmed-hire is intentionally different: its contract requires the same materialization identities and keeps exact-result binding.

Test-first d7440d40e46f59a2596167bbca54af2a79e901a4 adds focused contracts for a first-committed foreign identity backed by matching semantic replay evidence, mismatched replay evidence rejection, and exact replay-digest scalar validation. Production cc1cc53f34908178495ff657930c3950ce5931f9 adds optional replay_command_digest to generic mutation results and accepts a foreign result identity only when the application independently recomputes the same digest from its detached command and exact authorization decision. Ordinary unexplained foreign results continue to fail with the #229 identity error; a mismatched digest fails with replay-evidence integrity error.

Current successor a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4 changes _replayed_record_id(...) to return the first committed UUID plus the exact stored digest only after the stored digest has already matched the current semantic digest. PostgresPeopleMutationPort propagates that receipt on replay for Employment/Position/Assignment. Normal creates return no replay receipt and therefore still require current command identity. No SQL/schema/migration/idempotency-key/digest definition, audit/outbox semantics, or confirmed-hire behavior changed.

Compare 8f986853... → a61617f... is strictly ahead by three ordinary commits and contains only mutations.py, postgres_mutations.py, and the new focused replay-result test. No force-push or destructive rebase was used.

Exact-head evidence

CodeRabbit completed an exact-head review of a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4 against protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f and found no defect in the reviewed #246 changes. It confirmed matching replay evidence preserves first-committed generic identity, mismatched evidence and unexplained foreign identity fail closed, PostgreSQL emits replay evidence only after stored/current digest equality, confirmed-hire has no delta and retains exact identity binding, the three-commit lineage is linear, and git diff --check is clean. This is independent static review evidence, not a ruleset-qualifying approval or hosted GREEN.

Current workflows on exact a61617f... are Foundation CI 33964015934, SAST Semgrep 33964015913, Security Scan 33964015937, and CodeQL PR 33964015914. Foundation Repository quality job 101300767068 remains queued before checkout with steps=[], ubuntu-24.04, and no assigned runner at the latest read. No current-head hosted GREEN, PostgreSQL completion, repository-owned 100% statement/branch coverage, terminal security completion, or qualifying approval is claimed. Formal submitted reviews remain non-authorizing; predecessor COMMENTED reviews and resolved threads do not transfer after these pushes.

Owner dependencies

Causal order remains #63 normal protected integration as gates allow → #64 normal integration → #65 non-force protected adoption/reconciliation and integration → #141 non-force protected adoption/reconciliation of its valid feature → Assignment descendants. The independent #235 Workforce Validation lane may continue from protected develop while these owner gates run. No self-approval, administrator bypass, gate weakening, force-push, destructive rebase, no-op retrigger, mutable-owner dependency, or predecessor-evidence transfer.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: b7c5b8f6-6a9e-48af-80fd-42512f13eafa

📥 Commits

Reviewing files that changed from the base of the PR and between 61cba0f and adab344.

📒 Files selected for processing (6)
  • services/people-api/src/orgmetra_people_api/postgres_hire.py
  • services/people-api/tests/test_postgres_hire_idempotency_text_runtime_integrity.py
  • services/people-api/tests/test_postgres_hire_provenance_text_runtime_integrity.py
  • services/people-api/tests/test_postgres_hire_row_container_runtime_integrity.py
  • services/people-api/tests/test_postgres_hire_timestamp_runtime_integrity.py
  • services/people-api/tests/test_postgres_hire_uuid_runtime_integrity.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • services/people-api/tests/test_postgres_hire_timestamp_runtime_integrity.py

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


📝 Walkthrough

Walkthrough

People 변이와 채용 수락 경계가 서브클래스를 거부하도록 변경되었습니다. UUID, 문자열, Decimal, 명령, 결과, 권한 결정, 시간값, PostgreSQL 행 형태에 정확한 타입 검사를 적용했습니다. 런타임 무결성 회귀 테스트와 변경 기록을 갱신했습니다.

Changes

People 런타임 무결성

Layer / File(s) Summary
정확한 타입 검증과 변이 경로
services/people-api/src/orgmetra_people_api/hire.py, services/people-api/src/orgmetra_people_api/mutations.py
People 변이와 채용 수락의 입력, 명령, 결과, 권한 결정 검사를 정확한 타입 검사로 변경했습니다. idempotency_record_id는 테넌트 UUID를 검증한 뒤 ID를 파생합니다.
PostgreSQL 경계 검증
services/people-api/src/orgmetra_people_api/postgres_hire.py, services/people-api/src/orgmetra_people_api/postgres_mutations.py
PostgreSQL 포트가 UUID, 시간, 고정 행 형태, digest, provenance 텍스트, 명령, 권한 결정의 정확한 타입을 검증합니다. 잘못된 입력은 데이터베이스 작업 전에 기존 오류 유형으로 거부합니다.
런타임 무결성 회귀 테스트
services/people-api/tests/*runtime_integrity.py
위조된 UUID, 문자열, Decimal, 명령, 결과, 권한 결정, 시간값, 행 컨테이너가 생성, digest, 라우팅, 서비스 경계, 데이터베이스 경계를 통과하지 못하는지 검증합니다.
변경 기록과 매니페스트
CHANGELOG.md, manifest.json
고용 및 position 식별자 변경과 governance 문구 검증 변경을 기록했습니다. CHANGELOG 메타데이터를 갱신했습니다.

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

Merge Risk: ⚪ Minimal · up to adab3

This change hardens People mutation and hire-acceptance inputs against executable subtype values while preserving supported built-in values and persistence behavior. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 95.57% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 158 functions across 16 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 People 변이의 런타임 타입 보호라는 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ 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/hire-identity-type-integrity

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 changed the title fix(hire): protect governed identity runtime types fix(people): protect governed mutation runtime types Aug 21, 2026
@seonghobae
seonghobae marked this pull request as ready for review August 21, 2026 09:37
devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae marked this pull request as draft August 22, 2026 00:33
@seonghobae
seonghobae marked this pull request as ready for review August 22, 2026 00:37

Copy link
Copy Markdown
Contributor Author

Exact-head repair/evidence update for the current branch state:

  • RED ad38eb452ac1b072a146b5edf41a64a8e6553c78: direct PostgreSQL hire authority must reject HireAcceptanceCommand / AuthorizationDecision subclasses before database work.
  • GREEN 63eb051935df4291b2e423189503c0aec71b6ff1: PostgresHireAcceptancePort now requires the exact governed command and authorization runtime types.
  • RED 27623490127834413c9ffd2dc900cb06e6ca00a6: direct PostgreSQL People mutation authorization must reject AuthorizationDecision subclasses.
  • Current/root repair 76cb5b0d963ce5c2d273f23f8dce01444a38499a: _require_authorization(...) now uses the same exact governed AuthorizationDecision runtime contract as mutation_command_digest(...); the addressed review thread is resolved.

Fresh exact-current-head hosted evidence is terminal GREEN: People API Quality 32540865696, Foundation CI 32540865669, SAST Semgrep 32540865701, Security Scan 32540865651, Recovery Rehearsal Quality 32540865671. People API Quality explicitly passed the exact statement/branch coverage step on this head.

Live protected base remains develop@9e3e4847510e1e612b48474ba42b177b8ed824df; GitHub reports this PR open, mergeable, and ready-for-review. There is still no qualifying formal independent non-author APPROVE, so do not merge or reuse predecessor evidence.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae marked this pull request as draft August 22, 2026 00:42
@seonghobae
seonghobae marked this pull request as ready for review August 22, 2026 00:43

Copy link
Copy Markdown
Contributor Author

Current exact-head follow-up after fresh review:

A new review correctly identified that the three direct PostgresPeopleMutationPort entry points still used isinstance(...) for command gates even after the direct hire port was hardened. That left employment/position/assignment persistence entry points able to accept validation-bypassing command subclasses before reaching the exact-type command_route(...)/digest boundary.

  • RED e859d208766463be243dd84443a615fbc2c83da1 adds direct persistence regressions for forged EmploymentMutationCommand, PositionMutationCommand, and AssignmentMutationCommand subclasses and requires rejection before any database work.
  • Root repair/current head 0196bf545b6254a410c99be80216ac977a706683 makes all three PostgreSQL mutation entry points require the exact governed command runtime type. The matching review thread is resolved.

Fresh exact-current-head hosted evidence is terminal GREEN:

  • People API Quality 32541189508 — success; its People API contract and 100% coverage job passed the exact statement/branch coverage step.
  • Foundation CI 32541189493 — success.
  • SAST Semgrep 32541189460 — success.
  • Security Scan 32541189467 — success.
  • Recovery Rehearsal Quality 32541189512 — success.

Live protected base remains develop@9e3e4847510e1e612b48474ba42b177b8ed824df. The PR is open, mergeable and ready-for-review on current head 0196bf545b6254a410c99be80216ac977a706683. Submitted reviews remain COMMENTED only; there is no qualifying independent non-author APPROVE, so do not merge or reuse predecessor evidence.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae marked this pull request as draft August 22, 2026 01:07
@seonghobae
seonghobae marked this pull request as ready for review August 22, 2026 01:08
devin-ai-integration[bot]

This comment was marked as resolved.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="e4d538c3e5c0707b650e4eeefb7d91dc4611fe9e"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
prior="62a6b7ac2908dce2ea760c13123f8685a6f0eb5c"
generic="services/people-api/src/orgmetra_people_api/mutations.py"
hire="services/people-api/src/orgmetra_people_api/hire.py"
postgres="services/people-api/src/orgmetra_people_api/postgres_mutations.py"

echo '== Exact head, ancestry, and PR state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git cat-file -e "${prior}^{commit}"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
git merge-base --is-ancestor "$prior" "$head" && echo 'prior_is_ancestor=true'
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Issue `#231` =='
gh issue view 231 --repo "$repo" --json number,title,state,body,url

echo '== Successor sequence and changed paths =='
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
git diff --check "$base" "$head"
git diff --name-status "$prior" "$head"
git diff --stat "$prior" "$head"
echo '== Production paths changed after prior head =='
git diff --name-status "$prior" "$head" -- services/people-api/src

echo '== Per-commit scope after prior head =='
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='parents %P%nsubject %s%n' --name-status --no-renames "$commit"
done

echo '== Source maps =='
ast-grep outline "$generic" --items all
ast-grep outline "$hire" --items all
ast-grep outline "$postgres" --items all --match 'PostgresPeopleMutationPort'

echo '== Focused successor diff =='
git diff --unified=120 "$prior" "$head" -- \
  "$generic" "$hire" "$postgres" services/people-api/tests

echo '== Application authorization, snapshots, and port-call ordering =='
rg -n -C 18 --glob '*.py' \
  '(def\s+(create_employment_record|create_position_record|create_assignment_record|accept_confirmed_hire)\b|replace\s*\(|dataclasses\.replace|authorize|authorization|expected_(employment|position|assignment|person|conversion|candidate_worker).*record_id|mutation_port\.|port\.(create_|accept_)|result\.[A-Za-z_]+|command\.[A-Za-z_]+)' \
  "$generic" "$hire" services/people-api/tests

echo '== Direct PostgreSQL command-detachment ordering =='
rg -n -C 16 \
  '(def\s+(create_employment|create_position|create_assignment)\b|replace\s*\(|_require_authorization\s*\(|connection_factory\s*\(|command\.[A-Za-z_]+)' \
  "$postgres"

echo '== Candidate `#231` regression modules =='
fd -t f . services/people-api/tests | rg -i \
  '(authorization|purpose|detach|post.*construction|result.*(identity|target|snapshot)|mutation.*integrity|hire.*integrity)' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      cat -n "$file"
    done

echo '== Search for result comparisons that read command fields after port calls =='
rg -n -C 8 --glob '*.py' \
  'result\.(employment_record_id|position_record_id|assignment_record_id|person_record_id|candidate_worker_conversion_record_id)\s*!=\s*command\.' \
  services/people-api/src/orgmetra_people_api

echo '== Exact-head hosted checks and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | [.author.login, .state, .commit.oid] | `@tsv`'

Length of output: 9359


#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="e4d538c3e5c0707b650e4eeefb7d91dc4611fe9e"
prior="62a6b7ac2908dce2ea760c13123f8685a6f0eb5c"
test_first="f7415084d801bc06be316b022f41f53763197882"
generic="services/people-api/src/orgmetra_people_api/mutations.py"
hire="services/people-api/src/orgmetra_people_api/hire.py"
postgres="services/people-api/src/orgmetra_people_api/postgres_mutations.py"
snapshot_test="services/people-api/tests/test_people_mutation_authorization_command_snapshot.py"

echo '== Per-commit scopes and whitespace =='
for commit in "$test_first" "$head"; do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='parents %P%nsubject %s%n' --no-patch "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done

echo '== `#231` test-first diff and production repair diff =='
git diff --unified=120 "${test_first}^" "$test_first" -- "$snapshot_test"
git diff --unified=120 "${head}^" "$head" -- "$generic"

echo '== Final application mutation services =='
ast-grep outline "$generic" --items all
sed -n '1,500p' "$generic"

echo '== `#231` regression module =='
cat -n "$snapshot_test"

echo '== Authorization-to-port ordering and expected-result snapshots =='
rg -n -C 20 --glob '*.py' \
  '(def\s+create_(employment|position|assignment)_record\b|command\s*=\s*replace\s*\(command\)|expected_(employment|position|assignment)_record_id|authorize|authorization|mutation_port\.|result\.(employment|position|assignment)_record_id)' \
  "$generic" "$snapshot_test"

echo '== `#229` hire result-target snapshot remains intact =='
rg -n -C 20 \
  '(def\s+accept_confirmed_hire\b|expected_(person|employment|candidate_worker_conversion)_record_id|HireAcceptanceResult\.__post_init__|result\.(person|employment|candidate_worker_conversion)_record_id)' \
  "$hire"

echo '== `#230` PostgreSQL detachment remains intact =='
rg -n -C 18 \
  '(def\s+(create_employment|create_position|create_assignment)\b|command\s*=\s*replace\s*\(command\)|_require_authorization\s*\(|connection_factory\s*\(|command\.[A-Za-z_]+)' \
  "$postgres"

echo '== Changed production scope after the `#229` head =='
git diff --check "$prior" "$head"
git diff --name-status "$prior" "$head" -- services/people-api/src
git diff --stat "$prior" "$head" -- services/people-api/src

echo '== Current-head checks and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | [.author.login, .state, .commit.oid] | `@tsv`'

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head 9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3 against protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f. Focus on #231's complete test-first chain f7415084… → e4d538c3… → 5a6354a9… → 9771be6d…: Employment/Position/Assignment and confirmed-hire commands must be detached into fresh exact validated dataclasses before purpose-bound authorization callbacks, while preserving #229 pre-port result-target binding and #230 direct-PostgreSQL command detachment. Please flag any unrelated production regression or missing symmetric path; do not transfer predecessor review evidence.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
test_first="f7415084d801bc06be316b022f41f53763197882"
prior="e4d538c3e5c0707b650e4eeefb7d91dc4611fe9e"
generic="services/people-api/src/orgmetra_people_api/mutations.py"
hire="services/people-api/src/orgmetra_people_api/hire.py"
postgres="services/people-api/src/orgmetra_people_api/postgres_mutations.py"

echo '== Exact revision and PR metadata =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git cat-file -e "${test_first}^{commit}"
git cat-file -e "${prior}^{commit}"
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Issue `#231` =='
gh issue view 231 --repo "$repo" --json number,title,state,body,url

echo '== Requested chain ancestry and commit scope =='
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
git merge-base --is-ancestor "$test_first" "$head" && echo 'test_first_is_ancestor=true'
git merge-base --is-ancestor "$prior" "$head" && echo 'prior_is_ancestor=true'
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${test_first}^..${head}"
for commit in $(git rev-list --reverse "${test_first}^..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='subject %s' --no-patch "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done

echo '== Delta and production scope =='
git diff --check "$base" "$head"
git diff --name-status "$base" "$head"
git diff --stat "$base" "$head"
echo '== Production paths changed after prior `#231` repair head =='
git diff --name-status "$prior" "$head" -- services/people-api/src
echo '== Production diff after prior `#231` repair head =='
git diff --unified=100 "$prior" "$head" -- services/people-api/src

echo '== Source maps =='
ast-grep outline "$generic" --items all
ast-grep outline "$hire" --items all
ast-grep outline "$postgres" --items all --match 'PostgresPeopleMutationPort'

echo '== Complete focused implementation and regression delta =='
git diff --unified=140 "${test_first}^" "$head" -- \
  "$generic" "$hire" "$postgres" services/people-api/tests

echo '== Detachment, authorization, port call, and result-binding contexts =='
rg -n -C 20 --glob '*.py' \
  '(def\s+(create_employment_record|create_position_record|create_assignment_record|accept_confirmed_hire|create_employment|create_position|create_assignment)\b|command\s*=\s*replace\s*\(command\)|dataclasses\.replace|authorize|authorization|expected_(employment|position|assignment|person|candidate_worker_conversion)_record_id|mutation_port\.|port\.(create_|accept_)|result\.(employment|position|assignment|person|candidate_worker_conversion)_record_id|_require_authorization\s*\(|connection_factory\s*\()' \
  "$generic" "$hire" "$postgres" services/people-api/tests

echo '== Candidate `#231` and retained-boundary tests =='
fd -t f . services/people-api/tests | rg -i \
  '(authorization.*(snapshot|command|detach)|hire.*(authorization|snapshot|integrity)|mutation.*(result|snapshot|post.*construction|integrity)|postgres.*mutation.*(post.*construction|integrity))' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      sed -n '1,340p' "$file"
    done

echo '== Result comparisons that read command identities after port calls =='
rg -n -C 10 --glob '*.py' \
  'result\.(employment_record_id|position_record_id|assignment_record_id|person_record_id|candidate_worker_conversion_record_id)\s*!=\s*command\.' \
  services/people-api/src/orgmetra_people_api

echo '== Exact-head checks and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | [.name, .status, .conclusion, .details_url] | `@tsv`'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | [.author.login, .state, .commit.oid] | `@tsv`'

Length of output: 105186


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
commits=(
  "f7415084d801bc06be316b022f41f53763197882"
  "e4d538c3e5c0707b650e4eeefb7d91dc4611fe9e"
  "5a6354a9"
  "9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3"
)
generic="services/people-api/src/orgmetra_people_api/mutations.py"
hire="services/people-api/src/orgmetra_people_api/hire.py"
postgres="services/people-api/src/orgmetra_people_api/postgres_mutations.py"

echo '== Exact head and PR =='
printf 'checked_out='; git rev-parse HEAD
gh pr view 64 --repo "$repo" --json headRefOid,baseRefOid,state,isDraft,mergeable \
  --jq '{headRefOid,baseRefOid,state,isDraft,mergeable}'

echo '== Requested chain =='
for ref in "${commits[@]}"; do
  commit="$(git rev-parse "${ref}^{commit}")"
  printf '\ncommit=%s\n' "$commit"
  git show --no-patch --format='parents %P%nsubject %s'
  git diff-tree --no-commit-id --name-status -r "$commit"
  git diff --check "${commit}^" "$commit"
done
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'

echo '== Source delta after `#231` test-first =='
git diff --stat "${commits[0]}^" "$head" -- "$generic" "$hire" "$postgres" services/people-api/tests
git diff --name-status "${commits[0]}^" "$head" -- services/people-api/src

echo '== Application mutation service methods =='
rg -n -A90 -B5 \
  '^(def (create_employment_record|create_position_record|create_assignment_record)\b)' \
  "$generic"

echo '== Confirmed-hire application method =='
rg -n -A120 -B5 '^def accept_confirmed_hire\b' "$hire"

echo '== Direct PostgreSQL mutation entry methods =='
rg -n -A75 -B5 '^\s+def (create_employment|create_position|create_assignment)\b' "$postgres"

echo '== `#231` focused test files and test definitions =='
fd -t f . services/people-api/tests | rg -i '(authorization.*(snapshot|command)|hire.*authorization.*snapshot)' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      rg -n -A75 -B8 '^(def test_|class _)' "$file"
    done

echo '== Post-port result identity reads =='
rg -n -C 8 \
  'expected_(employment|position|assignment|person|candidate_worker_conversion)_record_id|result\.(employment_record_id|position_record_id|assignment_record_id|person_record_id|candidate_worker_conversion_record_id)' \
  "$generic" "$hire"

echo '== Exact-head checks =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "null")"'

echo '== Exact-head reviews =='
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | "\(.author.login)\t\(.state)\t\(.commit.oid)"'

Length of output: 50699


@seonghobae I reviewed exact head 9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3 against develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f.

I found no defect in the inspected #231 implementation.

The four application services use the same safe order:

  1. They require the exact command runtime type.
  2. They call replace(command) to create a fresh validated command.
  3. They capture the expected result identity from the detached command.
  4. They call the purpose-bound authorization callback.
  5. They pass only the detached command to the mutation port.

This order applies to:

  • create_employment_record(...)
  • create_position_record(...)
  • create_assignment_record(...)
  • accept_confirmed_hire(...)

The #231 regressions cover both application boundaries. The policy callback mutates the caller-owned command during authorization. The mutation port receives a distinct command with the original validated values. The tests cover Employment, Position, Assignment, and confirmed hire.

The #229 result-target binding remains intact. Each service compares the returned result to a UUID snapshot that it captured before authorization and before the port call. No inspected result comparison reads a command identity after the port returns.

The #230 direct PostgreSQL detachment remains intact. Each PostgresPeopleMutationPort.create_* method calls replace(command) before authorization-reference rendering and before connection_factory().

The code changes after the #231 test-first commit are limited to:

  • services/people-api/src/orgmetra_people_api/mutations.py
  • services/people-api/src/orgmetra_people_api/hire.py
  • the two #231 regression modules

git diff --check reported no whitespace errors.

The requested commit-parent sequence was not independently verified because the collection command omitted the commit argument when it printed parents. The changed-file scopes for all four specified commits were collected. Exact-head hosted checks are queued or skipped, so their final status is inconclusive. I did not use predecessor review or check evidence.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head 8d3877650865f71c4d9708b06eb55f43a7cb7661 against protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f, with particular attention to #232: the Assignment HTTP allocation-ratio parser must reject str subclasses before regex/Decimal parsing while preserving exact built-in four-decimal tokens. Do not transfer predecessor review evidence.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="8d3877650865f71c4d9708b06eb55f43a7cb7661"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
prior="9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3"

echo '== Exact revision, ancestry, and pull request metadata =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Issue `#232` =='
gh issue view 232 --repo "$repo" --json number,title,state,body,url

echo '== Successor sequence and changed paths =='
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='subject %s' --no-patch "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done
git diff --check "$base" "$head"
echo '== Production changes after prior head =='
git diff --name-status "$prior" "$head" -- services/people-api/src
git diff --stat "$prior" "$head"

echo '== Locate Assignment HTTP parser and candidate tests =='
fd -t f . services/people-api | rg -i '(http|api|route|handler|assignment|allocation|runtime.*integrity)'
rg -n -C 16 --glob '*.py' \
  '(allocation.{0,30}(ratio|Ratio)|(ratio|Ratio).{0,30}allocation|Decimal\s*\(|fullmatch\s*\(|match\s*\(|isinstance\s*\([^)]*,\s*str\)|type\s*\([^)]*\)\s+is(?:\s+not)?\s+str)' \
  services/people-api/src services/people-api/tests

echo '== Structure of HTTP source candidates =='
fd -t f -e py . services/people-api/src | rg -i '(http|api|route|handler|assignment)' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      ast-grep outline "$file" --items all
    done

echo '== Complete focused delta after prior head =='
git diff --unified=140 "$prior" "$head" -- \
  services/people-api/src services/people-api/tests

echo '== Candidate `#232` regression modules =='
fd -t f -e py . services/people-api/tests | rg -i '(assignment|allocation|http|parser|runtime.*integrity)' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      cat -n "$file"
    done

echo '== Exact-head check runs and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "null")\t\(.details_url)"'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | "\(.author.login)\t\(.state)\t\(.commit.oid)"'

Length of output: 125640


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head="8d3877650865f71c4d9708b06eb55f43a7cb7661"
prior="9771be6d65bef77408cd5ad1ae316f0a8d8fb5e3"
source="services/people-api/src/orgmetra_people_api/mutations.py"
http_source="services/people-api/src/orgmetra_people_api/mutation_http.py"
test_file="services/people-api/tests/test_people_mutation_allocation_text_runtime_integrity.py"

echo '== Exact successor commits and changed paths =='
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
  git diff --check "${commit}^" "$commit"
done

echo '== Focused changes after the prior head =='
git diff --unified=160 "$prior" "$head" -- "$source" "$http_source" "$test_file"

echo '== Final parser declaration and all direct call sites =='
ast-grep outline "$source" --items all --match 'parse_allocation_ratio'
rg -n -C 24 \
  'def\s+parse_allocation_ratio\b|parse_allocation_ratio\s*\(|fullmatch\s*\(|Decimal\s*\(' \
  "$source" "$http_source" "$test_file"

echo '== Exact parser source range =='
parser_line=$(rg -n '^def parse_allocation_ratio\b' "$source" | cut -d: -f1)
sed -n "$((parser_line - 10)),$((parser_line + 70))p" "$source"

echo '== Exact regression module =='
cat -n "$test_file"

echo '== Existing parser acceptance and rejection contracts =='
rg -n -C 8 --glob 'test_*.py' \
  '(parse_allocation_ratio|allocation_ratio.*(0\.|1\.|four|decimal)|four-decimal|allocation ratio)' \
  services/people-api/tests

echo '== Production paths changed after prior head =='
git diff --name-status "$prior" "$head" -- services/people-api/src

Length of output: 72336


@seonghobae I reviewed exact head 8d3877650865f71c4d9708b06eb55f43a7cb7661 against develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f.

I found no defect in the reviewed #232 changes.

parse_allocation_ratio(...) in services/people-api/src/orgmetra_people_api/mutations.py, Line 465, now requires type(raw_value) is str. The or condition short-circuits. Therefore, a str subclass is rejected before re.fullmatch(...) and Decimal(...) can inspect it.

The test-first and repair sequence is valid:

  1. 6fcb1c45173b6d49d14f0dd34d0f986e28b9d256 adds the str-subclass regression.
  2. 7779a852b4bdd4fb281f6813a42960c425e361f6 changes the parser from isinstance(...) to the exact built-in type gate.
  3. 8d3877650865f71c4d9708b06eb55f43a7cb7661 only restores the source trailing newline.

The regression uses a valid-looking _AllocationRatioText("0.2500") and requires ValueError. The previous isinstance(...) check would have accepted this value.

Existing parser contracts still accept exact built-in "0.2500" and "1.0000" tokens. The Assignment HTTP route continues to pass payload["allocation_ratio"] through this parser before it constructs AssignmentMutationCommand.

The production delta after the prior head is limited to services/people-api/src/orgmetra_people_api/mutations.py. I found no unrelated production regression. git diff --check reported no whitespace errors.

The exact-head hosted checks are queued or skipped. I did not use predecessor review or check evidence for this head.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head 8f986853a6f234c317e29080c4982bab34f3dc51 against protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f, with focus on #233: strictly-positive Assignment allocation parsing/OpenAPI parity, the new published-contract regression, deterministic manifest SHA/byte evidence, and whether ordinary successor 8f986853… fully removes the unrelated manifest-digest mistake introduced at da4b628…. Do not treat predecessor review evidence as current-head evidence.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="8f986853a6f234c317e29080c4982bab34f3dc51"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
prior="8d3877650865f71c4d9708b06eb55f43a7cb7661"

echo '== Exact revision and PR state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git cat-file -e "${prior}^{commit}"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
git merge-base --is-ancestor "$prior" "$head" && echo 'prior_is_ancestor=true'
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Issue `#233` =='
gh issue view 233 --repo "$repo" --json number,title,state,body,url

echo '== Successor commits and paths =='
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='subject %s' --no-patch "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done

echo '== Total and successor diff checks =='
git diff --check "$base" "$head"
git diff --check "$prior" "$head"
git diff --name-status "$prior" "$head"
git diff --stat "$prior" "$head"
echo '== Production paths changed after prior head =='
git diff --name-status "$prior" "$head" -- services/people-api/src

echo '== Locate allocation parser, OpenAPI contract, manifests, and tests =='
fd -t f . | rg -i '(mutation.*http|mutation.*openapi|openapi|swagger|assignment|allocation|manifest|contract)'
rg -n -C 12 --glob '*.{py,json,yaml,yml}' \
  '(parse_allocation_ratio|allocation_ratio|exclusiveMinimum|minimum|0\.0000|0\.0001|Assignment)' \
  services/people-api CHANGELOG.md manifest.json 2>/dev/null || true

echo '== Source outlines =='
ast-grep outline services/people-api/src/orgmetra_people_api/mutations.py --items all
for file in $(fd -t f -e py -e json -e yaml -e yml . services/people-api | rg -i '(openapi|mutation_http|contract)'); do
  echo "== ${file} =="
  ast-grep outline "$file" --items all || true
done

echo '== Focused diff after prior head =='
git diff --unified=160 "$prior" "$head" -- \
  services/people-api/src \
  services/people-api/tests \
  CHANGELOG.md \
  manifest.json \
  '*.yaml' '*.yml' '*.json'

echo '== Manifest evidence at exact head =='
if [ -f manifest.json ]; then
  cat manifest.json
  echo '== Referenced manifest entries =='
  jq -r '.. | objects | select(has("path") and (.path == "CHANGELOG.md" or (.path | test("openapi|people"; "i"))) )' manifest.json || true
fi
echo '== Recomputed CHANGELOG evidence =='
sha256sum CHANGELOG.md
wc -c -l CHANGELOG.md

echo '== Find and inspect da4b628 lineage =='
git rev-parse 'da4b628^{commit}' 2>/dev/null || true
git merge-base --is-ancestor da4b628 "$head" 2>/dev/null && echo 'da4b628_is_ancestor=true' || true
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
git log --all --oneline --decorate --max-count=80 --grep='manifest\|`#233`\|allocation' -i
git show --check --format='commit %H%nparents %P%nsubject %s%n' da4b628 2>/dev/null || true
git diff --unified=120 da4b628^ da4b628 -- manifest.json CHANGELOG.md 2>/dev/null || true

echo '== Exact-head check runs and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "null")\t\(.details_url)"'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | "\(.author.login)\t\(.state)\t\(.commit.oid)"'

Length of output: 119892


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="8f986853a6f234c317e29080c4982bab34f3dc51"
prior="8d3877650865f71c4d9708b06eb55f43a7cb7661"
mistake="da4b628fe344372ec22421cfa010e15105ad2c50"
outbox_path="database/migrations/0005_outbox_delivery_finalization.sql"

echo '== Exact PR metadata =='
git rev-parse HEAD
gh pr view 64 --repo "$repo" --json headRefOid,baseRefOid,state,isDraft,mergeable

echo '== Focused final `#233` files =='
cat -n services/people-api/src/orgmetra_people_api/mutations.py | sed -n '455,480p'
rg -n -A22 -B6 '^        allocation_ratio:' schemas/openapi.yaml
cat -n services/people-api/tests/test_people_mutation_allocation_text_runtime_integrity.py
rg -n -C 8 --glob '*.{py,mjs}' \
  '(allocation_ratio|0\\\.0000|0\\\.0001|CreateAssignmentRecordCommand)' \
  services/people-api/tests tests

echo '== All OpenAPI allocation-ratio declarations =='
rg -n -A5 -B3 'allocation_ratio:' schemas/openapi.yaml
echo '== All application allocation parser call sites =='
rg -n -C 5 'parse_allocation_ratio\s*\(' services/people-api/src services/people-api/tests

echo '== `#233` and manifest successor diffs =='
git diff --unified=100 "$prior" "$head" -- \
  services/people-api/src/orgmetra_people_api/mutations.py \
  services/people-api/tests/test_people_mutation_allocation_text_runtime_integrity.py \
  schemas/openapi.yaml \
  manifest.json
echo '== Mistake then correction only =='
git diff --unified=60 "${mistake}^" "$mistake" -- manifest.json
git diff --unified=60 "${head}^" "$head" -- manifest.json

echo '== Corrected outbox manifest evidence =='
actual_sha="$(sha256sum "$outbox_path" | awk '{print $1}')"
actual_bytes="$(wc -c < "$outbox_path" | tr -d ' ')"
actual_lines="$(wc -l < "$outbox_path" | tr -d ' ')"
manifest_entry="$(jq -c --arg path "$outbox_path" '.files[] | select(.path == $path)' manifest.json)"
printf 'actual_sha=%s\nactual_bytes=%s\nactual_lines=%s\nmanifest_entry=%s\n' \
  "$actual_sha" "$actual_bytes" "$actual_lines" "$manifest_entry"
jq -e --arg path "$outbox_path" --arg sha "$actual_sha" \
  --argjson bytes "$actual_bytes" --argjson lines "$actual_lines" \
  '.files[] | select(.path == $path) | .sha256 == $sha and .bytes == $bytes and .lines == $lines' \
  manifest.json >/dev/null && echo 'outbox_manifest_matches=true'

echo '== OpenAPI manifest evidence =='
actual_openapi_sha="$(sha256sum schemas/openapi.yaml | awk '{print $1}')"
actual_openapi_bytes="$(wc -c < schemas/openapi.yaml | tr -d ' ')"
actual_openapi_lines="$(wc -l < schemas/openapi.yaml | tr -d ' ')"
openapi_entry="$(jq -c '.files[] | select(.path == "schemas/openapi.yaml")' manifest.json)"
printf 'actual_sha=%s\nactual_bytes=%s\nactual_lines=%s\nmanifest_entry=%s\n' \
  "$actual_openapi_sha" "$actual_openapi_bytes" "$actual_openapi_lines" "$openapi_entry"
jq -e --arg sha "$actual_openapi_sha" --argjson bytes "$actual_openapi_bytes" --argjson lines "$actual_openapi_lines" \
  '.files[] | select(.path == "schemas/openapi.yaml") | .sha256 == $sha and .bytes == $bytes and .lines == $lines' \
  manifest.json >/dev/null && echo 'openapi_manifest_matches=true'

echo '== Repository manifest validator references =='
rg -n -C 6 '(manifest\.json|sha256|wc -c|line.*count|validate_repository)' \
  tests/validate_repository.py scripts tests/foundation-contract.test.mjs

Length of output: 101649


@seonghobae I reviewed exact head 8f986853a6f234c317e29080c4982bab34f3dc51 against develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f.

I found no defect in the reviewed #233 changes.

parse_allocation_ratio(...) now rejects "0.0000" before Decimal(...) construction. It accepts exact built-in tokens from "0.0001" through "1.0000" with four decimal places.

The OpenAPI CreateAssignmentRecordCommand.allocation_ratio pattern is identical to the parser pattern:

^(0\.(?!0000)[0-9]{4}|1\.0000)$

The published-contract regression rejects "0.0000" and accepts "0.0001", "0.2500", "0.9999", and "1.0000". The repository has one allocation_ratio OpenAPI declaration. The Assignment HTTP route passes the request value through parse_allocation_ratio(...) before it constructs AssignmentMutationCommand.

The #233 lineage is complete:

abd5dc5… → 7a95aa9… → f659b65… → da4b628… → 8f98685…

The ordinary successor 8f986853… fully corrects the unrelated manifest error from da4b628…. The final manifest SHA-256 for database/migrations/0005_outbox_delivery_finalization.sql matches the file content:

b7e8790595b288f752d6ef5cc6cbfe4e1b6712248f5b7a3a25fa60016b6a4961

Its byte count (6125) and line count (170) also match. The updated OpenAPI manifest entry independently matches its SHA-256, byte count (29511), and line count (1020).

git diff --check found no whitespace errors.

The PR is open, draft, and mergeable. The exact-head hosted checks are queued or skipped. I did not use predecessor reviews or checks as evidence for this head.

You are interacting with an AI system.

class _ExecutableUUID(UUID):
"""Expose UUID rendering attempted before an exact runtime-type gate."""

def __getattribute__(self, name: str) -> object:
class _ExecutableBatch(list[object]):
"""Fail if a fetched row collection is consumed before exact-type validation."""

def __bool__(self) -> bool:
"""Reject pre-gate length inspection."""
raise AssertionError("row collection length executed before exact-type validation")

def __getitem__(self, key: object) -> object:
"""Reject pre-gate row length inspection."""
raise AssertionError("row length executed before exact-type validation")

def __getitem__(self, key: object) -> object:
class _ExecutableUUID(UUID):
"""Expose any UUID attribute inspection performed before an exact-type gate."""

def __getattribute__(self, name: str) -> object:

calls = 0

def __bool__(self) -> bool:
type(self).calls += 1
raise AssertionError("outer durable row collection executed __len__")

def __getitem__(self, index: object) -> object:
class _ExecutableUUID(UUID):
"""Expose UUID attribute inspection performed before an exact-type gate."""

def __getattribute__(self, name: str) -> object:
instance.calls = 0
return instance

def __hash__(self) -> int:
instance.calls = 0
return instance

def __gt__(self, other: object) -> bool:

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4 against protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f, focusing on Issue #246. The predecessor exact head 8f986853a6f234c317e29080c4982bab34f3dc51 produced a real hosted Foundation RED because #229's unconditional result-ID equality contradicted the already-published idempotency contract: generic Employment/Position/Assignment retries deliberately exclude generated record IDs from the semantic digest and must return the first committed identity even when a retry allocated fresh UUIDs. Confirm that the new replay_command_digest evidence permits a foreign returned identity only when exact result revalidation succeeds and the application independently recomputes the same semantic digest from its detached command + authorization; unexplained foreign IDs and mismatched replay evidence must still fail closed. Confirm PostgresPeopleMutationPort emits replay evidence only after the stored idempotency digest has matched the current digest, while normal creates and confirmed-hire exact-identity semantics remain unchanged. Also check for type/coverage/contract regressions in the new focused test. Do not transfer predecessor workflow evidence as current-head GREEN.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4"
base="eb9757f8649aaad026a9865508d9aad50c1a7a4f"
prior="8f986853a6f234c317e29080c4982bab34f3dc51"

echo '== Exact revision, PR state, and ancestry =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git cat-file -e "${base}^{commit}"
git merge-base --is-ancestor "$base" "$head" && echo 'base_is_ancestor=true'
git merge-base --is-ancestor "$prior" "$head" && echo 'prior_is_ancestor=true'
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Issue `#246` =='
gh issue view 246 --repo "$repo" --json number,title,state,body,url

echo '== Successor commits and changed paths =='
git log --reverse --format='commit %H%nparents %P%nsubject %s%n' "${prior}..${head}"
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  printf '\n-- %s --\n' "$commit"
  git show --check --format='subject %s' --no-patch "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done

echo '== Delta and source scope =='
git diff --check "$base" "$head"
git diff --name-status "$prior" "$head"
git diff --stat "$prior" "$head"
git diff --name-status "$prior" "$head" -- services/people-api/src

echo '== Source maps =='
ast-grep outline services/people-api/src/orgmetra_people_api/mutations.py --items all
ast-grep outline services/people-api/src/orgmetra_people_api/postgres_mutations.py --items all --match 'PostgresPeopleMutationPort'
ast-grep outline services/people-api/src/orgmetra_people_api/hire.py --items all
ast-grep outline services/people-api/src/orgmetra_people_api/postgres_hire.py --items all

echo '== Replay evidence producers, consumers, digest checks, and identity binding =='
rg -n -C 18 --glob '*.py' \
  '(replay_command_digest|replay.*digest|_replayed_record_id|stored_digest|idempotency.*digest|mutation_command_digest|def\s+(create_employment_record|create_position_record|create_assignment_record|accept_confirmed_hire|create_employment|create_position|create_assignment)\b|expected_(employment|position|assignment|person|candidate_worker_conversion)_record_id|MutationResult\.__post_init__|HireAcceptanceResult\.__post_init__)' \
  services/people-api/src/orgmetra_people_api \
  services/people-api/tests

echo '== Focused source and test delta =='
git diff --unified=140 "$prior" "$head" -- \
  services/people-api/src/orgmetra_people_api/mutations.py \
  services/people-api/src/orgmetra_people_api/postgres_mutations.py \
  services/people-api/src/orgmetra_people_api/hire.py \
  services/people-api/src/orgmetra_people_api/postgres_hire.py \
  services/people-api/tests

echo '== Candidate Issue `#246` regression files =='
fd -t f -e py . services/people-api/tests | rg -i \
  '(replay|idempotency|result.*identity|mutation.*(integrity|digest|snapshot)|hire.*integrity)' \
  | while IFS= read -r file; do
      echo "== ${file} =="
      ast-grep outline "$file" --items all
    done

echo '== Exact-head check runs and reviews =='
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "null")\t\(.details_url)"'
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | "\(.author.login)\t\(.state)\t\(.commit.oid)"'

Length of output: 164780


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/Orgmetra"
head="a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4"
prior="8f986853a6f234c317e29080c4982bab34f3dc51"
generic="services/people-api/src/orgmetra_people_api/mutations.py"
postgres="services/people-api/src/orgmetra_people_api/postgres_mutations.py"
hire="services/people-api/src/orgmetra_people_api/hire.py"
postgres_hire="services/people-api/src/orgmetra_people_api/postgres_hire.py"
focused_test="services/people-api/tests/test_people_mutation_idempotent_replay_result.py"
postgres_test="services/people-api/tests/test_postgres_people_mutations.py"

echo '== Issue `#246` full metadata =='
gh issue view 246 --repo "$repo" --json number,title,state,body,comments,url

echo '== Exact successor parents and complete scopes =='
for commit in $(git rev-list --reverse "${prior}..${head}"); do
  echo "-- $commit --"
  git show --no-patch --format='parents %P%nsubject %s' "$commit"
  git diff-tree --no-commit-id --name-status -r "$commit"
done

echo '== Generic result evidence contracts and all consumers =='
rg -n -A45 -B10 \
  'def _validate_replay_command_digest\b|class (EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult)\b|def _require_result_identity_or_replay\b|^def create_(employment|position|assignment)_record\b' \
  "$generic"
rg -n -C 8 'replay_command_digest|_require_result_identity_or_replay\s*\(' \
  services/people-api/src services/people-api/tests

echo '== Direct PostgreSQL idempotency producer and all generic result returns =='
rg -n -A65 -B12 '^def _replayed_record_id\b|^def _record_idempotency\b' "$postgres"
rg -n -C 8 \
  'replayed\s*=|if replayed is not None|return (EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult)' \
  "$postgres"

echo '== Focused Issue `#246` regression module =='
cat -n "$focused_test"

echo '== Direct PostgreSQL generic replay regression and normal-create assertions =='
rg -n -A90 -B15 \
  'def test_same_key_replays_without_second_hris_or_audit_facts\b|def test_same_key_different_command_fails_closed\b|def test_different_key_is_a_new_command\b' \
  "$postgres_test"

echo '== Confirmed-hire code and tests, plus successor delta =='
rg -n -A150 -B10 '^def accept_confirmed_hire\b' "$hire"
rg -n -C 10 'return HireAcceptanceResult|HireAcceptanceResult\(' "$postgres_hire"
git diff --quiet "$prior" "$head" -- "$hire" "$postgres_hire" \
  && echo 'hire_source_delta_after_prior=none'

echo '== Focused test type-checking and test discovery configuration =='
fd -t f -a 'pyproject.toml' 'pytest.ini' 'tox.ini' 'mypy.ini' .
rg -n -C 8 '(mypy|pyright|pytest|coverage|strict)' \
  pyproject.toml pytest.ini tox.ini mypy.ini 2>/dev/null || true

echo '== Whitespace and final exact-head state =='
git diff --check "$prior" "$head"
printf 'checked_out='; git rev-parse HEAD
gh pr view 64 --repo "$repo" --json headRefOid,baseRefOid,state,isDraft,mergeable

Length of output: 73769


@seonghobae I reviewed exact head a61617f0cdd6f1a2e29b512b2a3c66872af5ccc4 against develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f.

I found no defect in the reviewed #246 changes.

The repair preserves both required result paths:

  • A normal Employment, Position, or Assignment create returns a result with no replay_command_digest. The application then requires the result ID to equal the detached command ID.
  • A replay can return the first committed ID. The application accepts this foreign ID only after exact result revalidation and only when replay_command_digest equals mutation_command_digest(command=command, authorization=authorization).

The replay evidence has an exact built-in str gate. A non-str value fails result revalidation before the application compares it. A mismatched exact string raises PeopleMutationIntegrityError with the result-specific replay-evidence error.

PostgresPeopleMutationPort emits the evidence in the correct order. _replayed_record_id(...):

  1. Computes the current semantic digest.
  2. Reads and exact-validates the idempotency row.
  3. Rejects a stored digest that differs from the current digest.
  4. Returns the committed ID and validated stored digest only after the match.

Each generic create_* method includes that receipt only on the replay return path. The normal-create return paths construct results without replay_command_digest.

The focused regression covers all three generic mutation services with a foreign first-committed identity and matching evidence. It also covers mismatched evidence and invalid replay-evidence type. The existing PostgreSQL replay test verifies that same-key retries return the first committed Employment, Position, and Assignment IDs without new business, audit, or idempotency writes. It also retains the same-key/different-command failure case.

Confirmed-hire code has no delta from the predecessor head. It still requires the returned Person, Employment, and conversion IDs to match the exact detached command IDs.

The #246 commit sequence is linear:

d7440d40… → cc1cc53f… → a61617f0…

git diff --check found no whitespace errors.

The exact-head workflows are queued or skipped. I did not treat predecessor workflow evidence as current-head GREEN.

You are interacting with an AI system.

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.

1 participant