Skip to content

feat(core): add governed Organization hierarchy-change review - #96

Open
seonghobae wants to merge 22 commits into
developfrom
feat/organization-hierarchy-change-review
Open

feat(core): add governed Organization hierarchy-change review#96
seonghobae wants to merge 22 commits into
developfrom
feat/organization-hierarchy-change-review

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Scope

Adds an Orgmetra-only, value-minimized pre-mutation review boundary for an Organization Unit parent change. It binds tenant/Organization Unit/current-parent/proposed-parent scope, business effective_on, system recorded_at, reviewed snapshot digests, controlled reason, distinct requester/reviewer evidence and explicit evidence versioning. It carries no Person PII, worker values, compensation, ratings, free-form personal text or employment-decision authority, performs no cross-service application-table SQL and writes no foreign CWL repository.

Repair history

Initial contract head d455631ff23db843ad9da3c4476a991397b144be deliberately imported a missing production module; its hosted run was later cancelled after implementation superseded it, so cancelled evidence is not claimed as terminal RED. Root implementation 46629a26c9bbdf78b32940355af613dac2a74c18 added the boundary.

Fresh self-review then found conflicting live reissuance under one tenant-qualified hierarchy-change reference. Regression 9af73947b910a5e6ac43c86e9bae17313f84902f and repair 2d16a1b486ae380cd67a63f21d621f8abd3e4958 bind all still-live idempotent duplicates to one shared evidence digest while leaving durable uniqueness to authoritative persistence/audit.

A later review found future system-recorded issuance was accepted. Regression 73d1bdb42bd1f284fc1fbe5c22f652afe795d487 and root repair 9ce512bf4db5968780c1435007541b7b6e367889 make recorded_at issuance-only fresh: exact fixed-offset temporal shape is required and a future instant fails closed, while later evidence export does not re-enter wall-clock freshness. CHANGELOG/README/traceability were aligned.

CodeRabbit then identified test-state coupling in root attach/detach coverage because the attach case reused a live reference with a different payload. Exact current head b9f8e3d291c4bdcd2f0aa5f9d0378dea09e5e7cd gives that case a distinct UUIDv4 change reference. The corresponding thread was resolved only after exact-current-head GREEN.

Governed contract

Root attach/detach uses None, not sentinel parents. Self-parenting and no-op reparenting fail closed. HRIS-owned operational UUID evolution is preserved while packet-owned change/actor correlations remain UUIDv4. Caller-defined trust primitive subclasses are rejected. Canonical JSON/SHA-256 is deterministic, routine repr is redacted, and post-construction evidence mutation is detected. Governance remains fixed to requires_human_review, requires_authoritative_resolution, not_authorized_to_apply, and human_review_only.

Before mutation, the authoritative Orgmetra HRIS boundary must re-resolve same-tenant Organization Unit/current-parent/proposed-parent/hierarchy truth at effective_on and the current system-recorded cutoff, reject stale current-parent evidence, self-parenting, cycles and multiple visible parents, re-establish actor separation, verify reviewed evidence, and write immutable audit/outbox evidence atomically with the mutation.

Exact-current-head evidence

Base: develop@9e3e4847510e1e612b48474ba42b177b8ed824df
Head: b9f8e3d291c4bdcd2f0aa5f9d0378dea09e5e7cd

GitHub reports open, non-draft, mergeable. Every applicable exact-current-head hosted workflow is terminal GREEN:

  • Organization Hierarchy Change Review Quality 32627448936 — success; focused job 97164863086 checked out the exact candidate, built/installed the exact package artifact, passed exact statement/branch coverage and clean-checkout steps.
  • Foundation CI 32627448972 — success, including Foundation validation and PostgreSQL integrity matrix on the exact candidate.
  • Recovery Rehearsal Quality 32627448969 — success.
  • SAST Semgrep 32627448992 — success.
  • Security Scan 32627448956 — success.

Fresh review-thread state has the future-time BUG and root-transition test-isolation finding resolved. The remaining weak live-reference/GC observation is informational and matches the documented process-local defense-in-depth boundary. No qualifying independent non-author APPROVE or CHANGES_REQUESTED is present.

Merge governance

This exact head is ready for independent review, not merge. Keep unmerged until a qualifying independent non-author approval exists and issue #89's enforceable develop protection defect is actually repaired. Immediately before any merge, refetch exact head, live base, reviews, threads, rules/protection and checks and use expected-head protection only if every live gate is satisfied. Do not self-approve, weaken gates, simulate protection in workflow code or transfer predecessor evidence.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

조직 계층 부모 변경을 위한 OrganizationHierarchyChangeReviewPacket 패키지를 추가했습니다. 입력 검증, 결정적 증거 직렬화, 다이제스트 무결성, 계약 테스트, 거버넌스 문서 및 GitHub Actions 품질 게이트를 포함합니다.

Changes

조직 계층 변경 검토

Layer / File(s) Summary
패킷 계약 및 공개 API
packages/organization-hierarchy-change-review/pyproject.toml, packages/organization-hierarchy-change-review/src/...
패키지 설정과 OrganizationHierarchyChangeReviewPacket, build_organization_hierarchy_change_review_packet 공개 API를 추가했습니다.
검증 및 증거 무결성
packages/organization-hierarchy-change-review/src/.../review.py
UUID, 부모 관계, 시간, 코드 및 다이제스트를 검증합니다. 결정적 JSON과 SHA-256 증거를 생성합니다. 사후 변조와 충돌하는 참조 재발행을 거부합니다.
실행 가능한 계약 검증
packages/organization-hierarchy-change-review/tests/test_review.py
정상 입력, 루트 전환, 잘못된 입력, 행위자 분리, 시간 정규화, 변조 방지 및 권한 경계를 검증합니다.
거버넌스 및 추적성 문서
docs/adr/..., docs/doctoring/..., docs/traceability/..., packages/organization-hierarchy-change-review/README.md, packages/organization-hierarchy-change-review/CHANGELOG.md
패킷의 책임 범위, HRIS 재검증 경계, 개인정보 제한, 근거 자료 및 요구사항 추적성을 문서화했습니다.
패키지 빌드 및 품질 게이트
.github/workflows/organization-hierarchy-change-review-quality.yml
Python 3.14.7 환경에서 고정된 wheel을 빌드하고 설치합니다. pip check, 컴파일, 테스트 커버리지 및 깨끗한 작업 트리를 검사합니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🔵 Low · up to 31107

The Organization hierarchy review boundary is covered by passing checks, but its process-local evidence binding can make conflicting-reference decisions depend on object lifetime, and one test reuses a shared default reference. The PR is mergeable with explicit owner awareness and follow-up to make this behavior deterministic and tests isolated.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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 제목은 Organization 계층 변경 검토 경계를 추가하는 주요 변경 사항을 명확하고 간결하게 설명합니다.
✨ 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 feat/organization-hierarchy-change-review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@seonghobae
seonghobae marked this pull request as draft August 23, 2026 08:02

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +274 to +285
if self.decision_authority != _DECISION_AUTHORITY:
raise ValueError("decision_authority must remain human_review_only")
if type(self.next_action) is not str or self.next_action != _NEXT_ACTION:
raise ValueError("next_action must remain the governed hierarchy-change instruction")

payload_json = _canonical_payload_json(_payload(self))
creation_digest = sha256(payload_json.encode("utf-8")).hexdigest()
live_key = (self.tenant_record_id, self.organization_hierarchy_change_reference)
with _REGISTRY_LOCK:
binding = _LIVE_REFERENCE_BINDINGS.get(live_key)
if binding is None:
binding = _LiveReferenceBinding(creation_digest)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Live-reference uniqueness is process-local and GC-dependent

The conflicting-reissuance guard in __post_init__ (review.py:274-285) holds only while some packet sharing the reference stays alive, since _LIVE_REFERENCE_BINDINGS is weak-valued and kept alive only by _PACKET_BINDINGS. Once all such packets are collected, a conflicting reference is accepted again. Documented as intentional defense-in-depth, not durable uniqueness.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

coderabbitai[bot]

This comment was marked as resolved.

@seonghobae
seonghobae marked this pull request as ready for review August 23, 2026 08:21

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +139 to +143
def _validate_issuance_timestamp(value: object) -> None:
"""Require structurally valid system-recorded evidence that has already occurred."""
_canonical_timestamp(value)
if value > datetime.now(timezone.utc):
raise ValueError("recorded_at must not be in the future")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Freshness enforced at construction only

_validate_issuance_timestamp rejects a future recorded_at only at construction; canonical_json revalidates structure and the creation digest but never re-checks the wall clock. This matches the documented design so backward clock movement cannot make issued evidence unreadable.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@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.

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