Skip to content

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

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

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

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Current execution receipt — 2026-09-17

Current hosted RED and causal repair

Foundation CI 34979161633 on predecessor exact head 49f620031ff9f12e4ce08d44d80518453d56207f reached the owned People suite and failed with 2 failed, 406 passed; coverage stopped at 99.86%. Both failures were in the adversarial structural-receipt contract: mutation and Employment-separation receipts were expected to remain distinct from ordinary tuples under !=.

This is a production protocol defect, not a stale test oracle. _MutationResultReceipt and EmploymentSeparationResult define exact-type __eq__ but inherited tuple.__ne__, so inequality compared raw tuple storage and contradicted the documented exact-type identity contract. Ordinary-forward cff6064c3a83ab15c47304d04959d42a34362d16 adds exact-type __ne__ to mutation receipts; 2afd3699992985abd305517eab84dcdb065a17bf applies the same repair to Employment separation. The 100% gate, storage model and hash semantics were not weakened.

Current 0b4409e50a1fd646c1f960164012df5984cbde0c adds regression coverage for the whole comparison contract: same-type equality/hash consistency, sibling-result inequality, and ordinary-tuple inequality in both operand directions. This turns the hosted RED into a direct protocol regression instead of relying on one assertNotEqual direction.

Exact-head Foundation 35005652520, Recovery 35005652499 and SAST 35005652434 are terminal SUCCESS. Security 35005652631 is terminal FAILURE in the centrally owned Dependency Review availability path already tracked by ContextualWisdomLab/.github#810; OSV/Trivy/Scorecard success does not replace that failed-closed authority. CodeQL 35005652507 is now terminal FAILURE after both current-head compatibility paths successfully requested central dispatch; the canonical verdict lookup returned state=pending, conclusion=null, terminal=false for this exact owner/repo/PR/SHA and the job failed closed, matching the shared settlement path tracked by ContextualWisdomLab/.github#312. No no-op rerun or leaf shim is authorized; an independent qualifying approval is still absent.

Employment / Position / Assignment truth

This branch remains the active canonical People writer for governed generic People mutations and Employment separation. Position creation requires current-recorded Organization Unit / Job Profile roots and current-recorded business-effective versions under the short parent-lock boundary. Assignment creation requires named Employment and Position roots to remain current-recorded under existing minimal conflict boundaries. Employment separation remains bitemporal, append-only in separation evidence, tenant-scoped and atomic with idempotency/audit/outbox. Keyverse remains policy owner; HR domain truth and PostgreSQL transaction ownership do not move.

Current owner paths / buyer gaps

No self-approval, routine administrator bypass, force-push, destructive rebase, gate weakening, predecessor-evidence transfer, synthetic status, mutable-owner source copy, or premature merge/release is authorized by this PR.

@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 제목은 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.

@seonghobae

Copy link
Copy Markdown
Contributor Author

@opencode-agent Please review the current unchanged head against protected develop. Local exact-head verification: all owned package suites pass at 100% statement/branch coverage.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head 07e4230dd4157a36b17fa90f1eea498efb8cddca after its non-force adoption of protected develop@ef1b143368cb6249c9520ca8cae10ebe844a5aa1. Revalidate the generic People mutation command/result/authorization runtime boundaries on this exact head; predecessor review/check evidence does not transfer.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

@seonghobae I will review exact head 07e4230dd4157a36b17fa90f1eea498efb8cddca against protected develop@ef1b143368cb6249c9520ca8cae10ebe844a5aa1. I will revalidate the generic People mutation command, result, and authorization runtime boundaries without relying on predecessor evidence.

⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

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

Adjacent-owner freshness update: #65 advanced non-force to exact head 5e1eb4a5146ca1fb29e93a66f7475c469c14a9ed. The new repair is confined to People/Job Analysis authenticated-principal comparison semantics: strict principal-only __eq__ is now paired with strict __ne__, satisfying the existing raw-tuple inequality compatibility RED. #64 remains the canonical generic mutation command/result acceptance owner; do not copy #65 source or treat its mutable head as a released dependency.

Copy link
Copy Markdown
Contributor Author

Adjacent-owner successor update: #65 is now exact head b468accb8a1db0f268b0c44f65e8f4bbb16e95e0. RED 92f7eb41… found returned-UUID aliasing in tuple-backed authentication principals; People/Job Analysis fixes 64deb92f… / b468accb… store validated UUID integers and reconstruct fresh values on access. #64 remains the generic mutation command/result owner; do not copy #65 source or treat its mutable head as a released dependency.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review only exact current head 3de318b69d8c01d98edf788ed087574f514049bd. Re-check #380 after the two newly repaired findings: (1) every ASGI scope key must be proven exact built-in str before scope.get() can execute a colliding key's equality behavior; (2) the malformed database-receipt HTTP regression must now pass the real autocommit=False transaction gate and prove cursor/fetch reachability before asserting 500. Also confirm #382 remains intact. Do not transfer predecessor-head verdicts.

@coderabbitai

coderabbitai Bot commented Sep 15, 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="3de318b69d8c01d98edf788ed087574f514049bd"

echo '== Exact revision and pull request state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git show --no-patch --format='commit %H%nparents %P%nsubject %s' "$head"
gh pr view 64 --repo "$repo" --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Exact-head scope and whitespace =='
git diff-tree --no-commit-id --name-status -r "$head"
git diff --check "${head}^" "$head"
git diff --stat "${head}^" "$head"
git diff --unified=180 "${head}^" "$head"

echo '== Focused current production implementations =='
for file in \
  services/people-api/src/orgmetra_people_api/separation_http.py \
  services/people-api/src/orgmetra_people_api/postgres_separation.py \
  services/people-api/src/orgmetra_people_api/hire_http.py \
  services/people-api/src/orgmetra_people_api/auth.py; do
  echo "== $file =="
  ast-grep outline "$file" --items all
  git show "${head}:${file}" | nl -ba | sed -n '1,620p'
done

echo '== Focused regression sources =='
for file in \
  services/people-api/tests/test_employment_separation_http_request_metadata_integrity.py \
  services/people-api/tests/test_employment_separation_integrity_http.py \
  services/people-api/tests/test_uuid_payload_integrity.py; do
  echo "== $file =="
  git show "${head}:${file}" | nl -ba
done

echo '== Scope validation and malformed receipt call-path references =='
git grep -n -C 20 -E \
  '(type\(scope\)|scope\.get\(|for .* in scope|scope.*key|_read_json_object|_require_transactional_connection|autocommit|MalformedReceiptCursor|fetchmany\()' \
  "$head" -- services/people-api/src/orgmetra_people_api services/people-api/tests

echo '== `#382` ordering-hook definitions and counter assertions =='
git grep -n -C 16 -E \
  '(class _ExecutableUUIDPayload|def __(lt|le|gt|ge)__|\.calls|comparison)' \
  "$head" -- services/people-api/tests/test_uuid_payload_integrity.py

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

Length of output: 202884


@seonghobae I reviewed exact head 3de318b69d8c01d98edf788ed087574f514049bd only.

I found no defect in the requested scope.

#380 repaired findings

EmploymentSeparationAsgiApp.__call__() in services/people-api/src/orgmetra_people_api/separation_http.py now validates the outer scope in the required order:

  1. It requires type(scope) is dict.
  2. It requires type(key) is str for every scope key.
  3. It calls scope.get("type"), scope.get("method"), and scope.get("path").

This order prevents dict.get() from invoking equality on a colliding str subclass key.

services/people-api/tests/test_employment_separation_http_request_metadata_integrity.py proves the boundary. The test inserts _ExecutableScopeKey("type") into an exact built-in dict. The key has a failing equality hook. The test asserts:

  • ValueError with the exact-string-key failure.
  • Zero equality-hook calls.
  • No request-body read.
  • No response send.
  • No authentication path.

The malformed database-receipt HTTP regression is now reachable. Connection.autocommit = False satisfies the production transaction gate. The test resets and verifies both Connection.cursor_calls and MalformedReceiptCursor.fetchmany_calls. Each count is one before it checks the HTTP response. The test therefore proves that the adapter reads the malformed receipt and maps the resulting integrity failure to HTTP 500. It no longer passes only because the transaction-mode gate rejects the connection.

#382

services/people-api/tests/test_uuid_payload_integrity.py remains intact.

_ExecutableUUIDPayload defines __lt__, __le__, __gt__, and __ge__. Each hook increments calls and raises TypeError. The existing equality hooks remain unchanged. The application and PostgreSQL UUID-gate tests still assert payload.calls == 0. Production validation code is unchanged.

git diff --check reported no whitespace errors. I did not run repository tests. The exact-head checks were queued or skipped when inspected.

You are interacting with an AI system.

Comment thread services/people-api/src/orgmetra_people_api/separation_http.py Fixed

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head cb459f0e46f9f56b86974991dbe14754c8dc5729 only. Focus on the #380 hosted-RED repair: whether services/people-api/tests/test_people_defensive_boundary_integrity.py meaningfully exercises the previously uncovered fail-closed trust-boundary branches (including runtime mutation-receipt property tampering), whether any test relies on an invalid Python/runtime assumption, and whether the repair weakens or masks the 100% owned coverage gate. Do not transfer predecessor verdicts.

@coderabbitai

coderabbitai Bot commented Sep 15, 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="cb459f0e46f9f56b86974991dbe14754c8dc5729"
test_file="services/people-api/tests/test_people_defensive_boundary_integrity.py"

echo '== Exact revision and pull-request state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git show --no-patch --format='commit %H%nparents %P%nsubject %s' "$head"
gh pr view 64 --repo "$repo" --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Exact commit scope and patch =='
git diff-tree --no-commit-id --name-status -r "$head"
git diff --check "${head}^" "$head"
git diff --stat "${head}^" "$head"
git diff --unified=220 "${head}^" "$head"

echo '== Focused test structure and complete exact-head source =='
ast-grep outline "$test_file" --items all
git show "${head}:${test_file}" | nl -ba

echo '== Production defensive boundary symbols and receipt implementations =='
git grep -n -C 20 -E \
 '(def _detach_authenticated_principal|def _principal_authority|def _require_port_operation|def _require_port|def _validated_payload|class (EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)|def _snapshot_(employment|position|assignment)_result|def separate_employment_record|def create_(employment|position|assignment)_record)' \
 "$head" -- services/people-api/src/orgmetra_people_api

echo '== Existing related adversarial tests and receipt tampering uses =='
git grep -n -C 12 -E \
 '(tuple\.__new__\((EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)|object\.__setattr__\(.*(record_id|replay|recorded_at)|_snapshot_(employment|position|assignment)_result|def test_.*(defensive|tamper|corrupt|receipt|boundary))' \
 "$head" -- services/people-api/tests

echo '== Coverage configuration and owned quality workflow references =='
fd -HI -t f -a 'pyproject.toml' 'setup.cfg' '.coveragerc' 'tox.ini' '.' | while IFS= read -r file; do
  echo "== $file =="
  rg -n -C 12 '(coverage|branch|fail_under|fail-under|100|people-api)' "$file" || true
done
fd -HI -t f -e yml -e yaml .github services | while IFS= read -r file; do
  if rg -q '(coverage|People API|people-api|fail-under|fail_under)' "$file"; then
    echo "== $file =="
    rg -n -C 12 '(coverage|People API|people-api|fail-under|fail_under|100)' "$file"
  fi
done

echo '== Test-only repair check and exact-head check state =='
git diff --name-only "${head}^" "$head" -- services/people-api/src
gh api "repos/${repo}/commits/${head}/check-runs?per_page=100" \
  --jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "null")\t\(.details_url)"' || true
gh pr view 64 --repo "$repo" --json reviews \
  --jq '.reviews[] | "\(.author.login)\t\(.state)\t\(.commit.oid)"' || true

Length of output: 225204


@seonghobae I reviewed exact head cb459f0e46f9f56b86974991dbe14754c8dc5729 only.

I found no defect in the requested #380 hosted-RED repair.

services/people-api/tests/test_people_defensive_boundary_integrity.py adds focused coverage for the three generic mutation receipt snapshots.

test_snapshot_revalidates_runtime_replay_digest_capability() performs the following actions for EmploymentMutationResult, PositionMutationResult, and AssignmentMutationResult:

  1. It creates a valid exact receipt.
  2. It replaces the class replay_command_digest property at runtime.
  3. It makes that property return the invalid built-in value 7.
  4. It calls the matching _snapshot_*_result() helper.
  5. It requires ValueError for replay_command_digest.

This test exercises the independent fail-closed checks in services/people-api/src/orgmetra_people_api/mutations.py Lines 641-643, 654-656, and 667-669. Those checks run after property access and before receipt reconstruction. A future removal of any of these checks will fail the relevant subtest.

The test uses a valid Python runtime mechanism. unittest.mock.patch.object() can replace a property on these Python-defined tuple subclasses. The patched property remains a descriptor. Each snapshot helper therefore receives an exact receipt instance with behavior-bearing property output. The context manager restores the original property after each subtest.

The repair does not replace the existing forged-storage tests. Existing tests still cover low-level tuple.__new__() fabrication and retained-payload revalidation. The new test covers the separate boundary where an exact result object returns invalid evidence through its property.

The repair does not weaken or mask the owned coverage gate:

  • This commit changes only a test file.
  • services/people-api/pyproject.toml still requires --cov-branch.
  • services/people-api/pyproject.toml still requires --cov-fail-under=100.
  • The production branches remain present and are now directly exercised.
  • git diff --check reported no whitespace errors.

I did not execute repository tests. The exact-head check runs were queued when inspected.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

Owner-path handoff only; no #64 source change from this lane. Fresh live authority is #64 exact 49f620031ff9f12e4ce08d44d80518453d56207f on protected develop@eb9757f8649aaad026a9865508d9aad50c1a7a4f; the delta from cb459f0... is only removal of the unused AuthenticatedPrincipal import in separation_http.py. Draft #317 now has merge base exactly this head, 0 behind, and current exact 273396de823b94c1456602318cb0f8c7c14ba32c. #387 adds a performance-evidence media-type boundary without copying/changing People source. Current #64 Foundation is pending and the other current-head gates remain queued, so no predecessor GREEN or merge authority is transferred.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head 2afd3699992985abd305517eab84dcdb065a17bf, specifically the hosted Foundation RED from run 34979161633: tuple-backed People receipts define exact-type __eq__ but previously inherited tuple.__ne__. Verify the two minimal __ne__ repairs preserve exact-type equality/hash semantics, forged-storage fail-closed behavior, and do not introduce sibling-result or ordinary-tuple false equality/inequality.

@coderabbitai

coderabbitai Bot commented Sep 15, 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="2afd3699992985abd305517eab84dcdb065a17bf"

echo '== Exact revision and pull-request state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git show --no-patch --format='commit %H%nparents %P%nsubject %s' "$head"
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Exact commit scope, patch, and whitespace =='
git diff-tree --no-commit-id --name-status -r "$head"
git diff --check "${head}^" "$head"
git diff --stat "${head}^" "$head"
git diff --unified=180 "${head}^" "$head"

echo '== Receipt implementation map =='
ast-grep outline services/people-api/src/orgmetra_people_api/mutations.py --items all
git show "${head}:services/people-api/src/orgmetra_people_api/mutations.py" \
  | nl -ba \
  | sed -n '1,760p'

echo '== All tuple-backed receipt equality, inequality, hash, and storage checks =='
git grep -n -C 20 -E \
  '(class (EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)\b|def __eq__|def __ne__|def __hash__|tuple\.__new__|_validated_payload|_snapshot_(employment|position|assignment)_result)' \
  "$head" -- services/people-api/src/orgmetra_people_api services/people-api/tests

echo '== Focused equality and forged-storage test inventory =='
git ls-tree -r --name-only "$head" services/people-api/tests \
  | rg -i '(mutation.*(result|receipt|equal|identity|integrity|alias|snapshot)|separation.*(result|receipt|equal|identity|integrity|alias|snapshot))' \
  | sort \
  | while IFS= read -r file; do
      echo "== $file =="
      git show "${head}:${file}" | nl -ba
    done

echo '== Comparison assertions and direct construction across all tests =='
git grep -n -C 12 -E \
  '((EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)\(|(EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult).*[!=]=|[!=]=.*(EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)|hash\()' \
  "$head" -- services/people-api/tests

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

Length of output: 203063


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head="2afd3699992985abd305517eab84dcdb065a17bf"
source="services/people-api/src/orgmetra_people_api/mutations.py"

echo '== Exact commit metadata and changed paths =='
git show --no-patch --format='commit %H%nparents %P%nsubject %s' "$head"
git diff-tree --no-commit-id --name-status -r "$head"

echo '== Exact patch =='
git diff --unified=100 "${head}^" "$head"

echo '== Result classes, equality, inequality, and hash at exact head =='
git show "${head}:${source}" | nl -ba | sed -n '250,560p'

echo '== Parent result classes for comparison =='
git show "${head}^:${source}" | nl -ba | sed -n '250,560p'

echo '== Test definitions added or changed by this commit =='
git diff-tree --no-commit-id --name-only -r "$head" -- services/people-api/tests \
  | while IFS= read -r file; do
      echo "== $file =="
      git show "${head}:${file}" | nl -ba
    done

echo '== All exact-head tests that compare People mutation results with tuples or sibling result types =='
git grep -n -C 12 -E \
  '(assert(Not)?Equal\(|assert .* [!=]= |!= .*|== .*)' \
  "$head" -- services/people-api/tests/test_people_defensive_boundary_integrity.py \
                    services/people-api/tests/test_people_mutation_result_identity_integrity.py \
                    services/people-api/tests/test_people_mutation_returned_receipt_integrity.py \
                    services/people-api/tests/test_people_mutation_post_construction_integrity.py \
  | rg -C 10 '(MutationResult|EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|tuple\()' || true

echo '== Source references to `__ne__` and all result-class definitions =='
git grep -n -C 8 -E 'def __ne__|class (EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult)\b' \
  "$head" -- services/people-api/src/orgmetra_people_api services/people-api/tests

Length of output: 108707


@seonghobae I reviewed exact head 2afd3699992985abd305517eab84dcdb065a17bf.

I found no defect in the requested scope.

The two receipt implementations now use matching inequality rules:

  • _MutationResultReceipt.__ne__() in services/people-api/src/orgmetra_people_api/mutations.py.
  • EmploymentSeparationResult.__ne__() in services/people-api/src/orgmetra_people_api/separation.py.

Each method returns not self.__eq__(other). Each corresponding __eq__() first requires type(self) is type(other). Therefore:

  • Two equal instances of the same receipt type compare equal and are not unequal.
  • Different receipt types compare unequal.
  • A receipt and an ordinary tuple with identical tuple storage compare unequal.
  • Neither direction can produce the prior false result from inherited tuple.__ne__().

The hash contract remains correct. Both receipt implementations hash (type(self), tuple.__hash__(self)). Equal receipts have equal hashes. Sibling receipt types cannot compare equal, and their type participates in hashing.

The repair does not change receipt storage or validation. _validated_payload() remains the authority for property access. Low-level tuple.__new__() fabrication still fails closed when a property reads malformed retained storage.

Existing focused checks cover ordinary-tuple inequality for both mutation and separation receipts. The implementation also makes sibling-result inequality deterministic through the exact runtime type gate.

git diff --check reported no whitespace errors. I did not run repository tests. The exact-head workflows were queued when inspected.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Exact-head refresh: please review 0b4409e50a1fd646c1f960164012df5984cbde0c. In addition to the two __ne__ production repairs, this head extends the existing defensive regression to prove same-type equality/hash consistency, sibling receipt inequality, and ordinary-tuple inequality in both operand directions. Please do not transfer a predecessor verdict.

@coderabbitai

coderabbitai Bot commented Sep 15, 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="0b4409e50a1fd646c1f960164012df5984cbde0c"
mutation_source="services/people-api/src/orgmetra_people_api/mutations.py"
separation_source="services/people-api/src/orgmetra_people_api/separation.py"
test_source="services/people-api/tests/test_people_defensive_boundary_integrity.py"

echo '== Exact revision and pull-request state =='
printf 'checked_out='; git rev-parse HEAD
git cat-file -e "${head}^{commit}"
git show --no-patch --format='commit %H%nparents %P%nsubject %s' "$head"
gh pr view 64 --repo "$repo" \
  --json number,state,isDraft,headRefOid,baseRefName,baseRefOid,mergeable,url

echo '== Exact-head scope and whitespace =='
git diff-tree --no-commit-id --name-status -r "$head"
git diff --check "${head}^" "$head"
git diff --stat "${head}^" "$head"
git diff --unified=180 "${head}^" "$head"

echo '== Receipt implementation and regression maps =='
ast-grep outline "$mutation_source" --items all
ast-grep outline "$separation_source" --items all
ast-grep outline "$test_source" --items all

echo '== Exact receipt equality, inequality, hash, and validation implementations =='
git show "${head}:${mutation_source}" | nl -ba | \
  rg -n -C 35 \
  '(class (_MutationResultReceipt|EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult)|def __eq__|def __ne__|def __hash__|def _validated_payload|def _snapshot_(employment|position|assignment)_result)'
git show "${head}:${separation_source}" | nl -ba | \
  rg -n -C 35 \
  '(class EmploymentSeparationResult|def __eq__|def __ne__|def __hash__|def _validated_payload)'

echo '== Complete current defensive regression =='
git show "${head}:${test_source}" | nl -ba

echo '== All exact-head receipt comparisons and hash assertions =='
git grep -n -C 14 -E \
  '(assert(Equal|NotEqual)\(|assert .*([!=]=).*|hash\(|EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)' \
  "$head" -- services/people-api/tests \
  | sed -n '1,2800p'

echo '== Forged storage and snapshot validation coverage =='
git grep -n -C 18 -E \
  '(tuple\.__new__\((EmploymentMutationResult|PositionMutationResult|AssignmentMutationResult|EmploymentSeparationResult)|_snapshot_(employment|position|assignment)_result|_validated_payload|forged|malformed|corrupt)' \
  "$head" -- services/people-api/tests \
  | sed -n '1,2400p'

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

Length of output: 203282


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head="0b4409e50a1fd646c1f960164012df5984cbde0c"
log="/tmp/coderabbit-shell-logs/shell-output-v3kb6H"
mutation_source="services/people-api/src/orgmetra_people_api/mutations.py"
separation_source="services/people-api/src/orgmetra_people_api/separation.py"
test_source="services/people-api/tests/test_people_defensive_boundary_integrity.py"

echo '== Exact revision and PR state from retained log =='
sed -n '1,80p' "$log"

echo '== Exact changed paths and patch =='
git diff-tree --no-commit-id --name-status -r "$head"
git diff --check "${head}^" "$head"
git diff --unified=120 "${head}^" "$head" -- "$test_source" "$mutation_source" "$separation_source"

echo '== Generic mutation receipt methods =='
git show "${head}:${mutation_source}" | nl -ba | sed -n '275,430p;610,685p'

echo '== Employment separation receipt methods =='
git show "${head}:${separation_source}" | nl -ba | sed -n '100,240p'

echo '== Full extended equality and inequality regressions =='
git show "${head}:${test_source}" | nl -ba | sed -n '84,195p'

echo '== Exact receipt comparison behavior by isolated standard-library model =='
python3 - <<'PY'
class Receipt(tuple):
    def __new__(cls, payload):
        return tuple.__new__(cls, payload)
    def __eq__(self, other):
        return type(self) is type(other) and tuple.__eq__(self, other)
    def __ne__(self, other):
        return not self.__eq__(other)
    def __hash__(self):
        return hash((type(self), tuple.__hash__(self)))

class SiblingReceipt(Receipt):
    pass

receipt = Receipt((1, None))
same = Receipt((1, None))
sibling = SiblingReceipt((1, None))
plain = (1, None)
checks = {
    "same_eq": receipt == same,
    "same_ne": receipt != same,
    "same_hash": hash(receipt) == hash(same),
    "sibling_ne_forward": receipt != sibling,
    "sibling_ne_reverse": sibling != receipt,
    "tuple_ne_forward": receipt != plain,
    "tuple_ne_reverse": plain != receipt,
    "tuple_eq_forward": receipt == plain,
    "tuple_eq_reverse": plain == receipt,
}
for name, value in checks.items():
    print(f"{name}={value}")
PY

Length of output: 37541


@seonghobae I reviewed exact head 0b4409e50a1fd646c1f960164012df5984cbde0c as fresh authority.

I found no defect in the requested scope.

The commit changes only services/people-api/tests/test_people_defensive_boundary_integrity.py. It does not change production code.

The production comparison contract remains correct:

  • _MutationResultReceipt.__eq__() and EmploymentSeparationResult.__eq__() require type(self) is type(other) before tuple comparison.
  • Both __ne__() methods return not self.__eq__(other).
  • Both __hash__() methods include type(self) and the tuple-storage hash.

The extended mutation receipt regression now proves:

  • Same-type EmploymentMutationResult instances compare equal.
  • Equal EmploymentMutationResult instances have equal hashes.
  • EmploymentMutationResult and PositionMutationResult compare unequal in both directions.
  • EmploymentMutationResult and an identical ordinary tuple compare unequal in both directions.

The generic result classes inherit the same _MutationResultReceipt implementation. Therefore, the type-sensitive behavior also applies to PositionMutationResult and AssignmentMutationResult.

The extended Employment-separation regression now proves:

  • Same-type EmploymentSeparationResult instances compare equal.
  • Equal EmploymentSeparationResult instances have equal hashes.
  • EmploymentSeparationResult and its identical ordinary tuple compare unequal in both directions.

The existing forged-storage assertions remain present. They still verify that malformed tuple-backed receipt storage fails closed when receipt properties validate the retained payload.

git diff --check reported no whitespace errors. I did not execute repository tests. The exact-head workflows were queued when inspected.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

Canonical baseline handoff is now materialized in #100 at exact 6bf05ea7c84c52f3c53ed1cadc9f1003cb7c13a0. The single-writer baseline records the durable protocol invariant from this lane's hosted RED: a storage-backed receipt whose equality includes exact runtime type must keep ==, !=, and hashing semantically coherent, with same-type/sibling-type/ordinary-container regressions covering both operand directions. No baseline file was edited from #64 or #317, and #100's new exact-head gates/review must be reacquired independently.

Copy link
Copy Markdown
Contributor Author

Child-owner currentization: Draft #317 advanced from 79c522971... to exact 3a78672949032f324fe3bbeae0f427ec73920bd7 under #393. The child remains based directly on this #64 exact head 0b4409e50a1fd646c1f960164012df5984cbde0c, behind 0 / ahead 286, with all 45 child-owned files under tests/performance/....

#393 is performance-evidence-only: it disables k6 request redirects per request so a final response reached through a redirect chain cannot certify the canonical Employment-separation route. No People source/OpenAPI/domain truth was copied or modified. #317 still has no hosted exact-head k6 acceptance and remains Draft.

Copy link
Copy Markdown
Contributor Author

Current child-owner receipt: buyer-performance Draft #317 advanced to exact 822e591b3b111e5900daecefdd20ea160e50abbe under #394 while remaining stacked exactly on this People head 0b4409e50a1fd646c1f960164012df5984cbde0c (0 behind; 45 child-owned files, all tests/performance/...). #394 adds an authenticated-HTTPS-origin requirement before the credential-bearing Employment-separation benchmark can send any request; it does not change People production source.

This People exact head now has Foundation CI, Recovery Rehearsal and SAST terminal SUCCESS. Security Scan and CodeQL remain nonterminal, and there is still no qualifying independent APPROVED review, so mechanical mergeability is not merge authorization.

Copy link
Copy Markdown
Contributor Author

Fresh exact-head gate update for 0b4409e50a1fd646c1f960164012df5984cbde0c: Security Scan 35005652631 is now terminal FAILURE, superseding the PR body's earlier nonterminal snapshot. RCA is bounded to the central Dependency Review evidence-availability probe, not People source.

Dependency-review job 104573057646 verified the exact #64 checkout, then GET /repos/ContextualWisdomLab/Orgmetra/dependency-graph/compare/eb9757f8649aaad026a9865508d9aad50c1a7a4f...0b4409e50a1fd646c1f960164012df5984cbde0c returned HTTP 403 with curl_exit=0; the workflow correctly failed closed before actions/dependency-review-action. OSV, Trivy and Scorecard in the same run are SUCCESS. Foundation 35005652520, Recovery 35005652499 and SAST 35005652434 are SUCCESS; CodeQL 35005652507 remains queued.

The 403 is already owned by central .github#810; I added this run/job as a fresh public non-fork canary there. No blind rerun, no leaf workflow shim, no no-op commit, no scanner substitution and no merge authorization. #64 stays Draft/open until central evidence is restored and normal current-head review/gates complete.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant