Skip to content

feat: persist governed job-analysis snapshots - #38

Merged
seonghobae merged 39 commits into
developfrom
cursor/job-analysis-snapshot-5eef
Aug 20, 2026
Merged

feat: persist governed job-analysis snapshots#38
seonghobae merged 39 commits into
developfrom
cursor/job-analysis-snapshot-5eef

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Buyer-visible gap

Orgmetra needs one governed, tenant-scoped API that persists and rereads evidence-backed Task/FJA/KSAO truth without unbounded request buffering, foreign-tenant authority, retry races, cross-authority idempotency replay, contract drift, identity-backend exception leakage, or raw database failures becoming buyer-visible behavior.

Canonical-model convergence

Protected develop is e7ddb7a78a5e1460410005d10f43ebf18c5e12e4 and includes the governed People mutation/idempotency API plus the accepted ADR 0001–0003 source expansion. The former parallel case-model lane #30 is closed as technically superseded; this branch remains the canonical Job Analysis persistence/API lane.

The current branch keeps Job Analysis persistence on migration 0013_job_analysis_snapshot.sql, ADR 0014-job-analysis-snapshot-persistence.md, the root OpenAPI contract, bounded HTTP parsing, authenticated-principal authority, serialized tenant/key idempotency with actor/purpose binding, immutable snapshot persistence, transactional audit/outbox, parent-scope fail-closed checks, tenant RLS, append-only guards, and dedicated PostgreSQL/coverage gates. JobAnalysisSnapshot is occupational evidence, not an automated high-impact employment decision.

Current repairs

Earlier review-driven repairs add executable DELETE append-only and cross-tenant RLS proofs under a NOSUPERUSER NOBYPASSRLS role and correct ADR 0014 so tenant-qualified foreign keys are distinguished from the PostgreSQL adapter's same-Job scope invariant.

A fresh transport sweep then found an Orgmetra-owned availability/security defect: an unexpected Keyverse/OIDC authenticator backend exception escaped the ASGI boundary because the authentication try only normalized AuthenticationFailed; the later generic HTTP exception handler did not cover authentication. RED 915c54dcd171ccbf9306159dad656484be6753b8 adds a secret-bearing identity-backend failure regression that requires a governed 500 internal_error, non-disclosing support envelope, and zero protected-port access. GREEN b047f1bde8dc671bcf086cf0c76d81bbf1dfdacb adds the smallest authentication-boundary catch-all while preserving malformed/invalid credentials as 401.

All currently visible inline review threads remain resolved. Existing review submissions are COMMENTED only; there is no qualifying APPROVE.

Exact state and evidence

Current exact head: b047f1bde8dc671bcf086cf0c76d81bbf1dfdacb.
Live protected develop: e7ddb7a78a5e1460410005d10f43ebf18c5e12e4.
GitHub reports the PR open, ready-for-review, and mergeable.

Fresh exact-current-head hosted workflows are materialized but non-passing while queued:

  • Job-Analysis API Quality 32392335044 — queued
  • SAST Semgrep 32392335058 — queued
  • Recovery Rehearsal Quality 32392335053 — queued
  • Requisition Review Quality 32392335189 — queued
  • Selection Review Quality 32392335375 — queued
  • Security Scan 32392335060 — queued
  • Foundation CI 32392335097 — queued

Predecessor local or hosted results do not transfer to this head.

Merge governance

Do not self-approve, bypass protection, transfer predecessor evidence, or merge until this unchanged exact head has terminal applicable GREEN evidence and every live qualifying independent-review requirement is satisfied. Before any merge, refetch the exact head, live base, current rules/reviews/threads/checks and use expected-head protection.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Job Analysis 스냅샷을 PostgreSQL에 저장하고 조회하는 기능을 추가했습니다. OpenAPI, 인증·인가, ASGI 라우트, 멱등성, 감사 아웃박스, 테넌트 격리, append-only 보호와 계약 테스트를 함께 구성했습니다.

Changes

Job Analysis 스냅샷 영속화

Layer / File(s) Summary
계약 및 PostgreSQL 스키마
ARCHITECTURE.md, CHANGELOG.md, database/migrations/0010_job_analysis_snapshot.sql, docs/TRACEABILITY.md, docs/adr/*, schemas/openapi.yaml, services/job-analysis-api/README.md
스냅샷 요청·응답 계약과 3NF 테이블을 추가했습니다. 멱등성, 복합 외래 키, append-only 트리거와 테넌트별 RLS 정책을 정의했습니다.
인증 및 스냅샷 사용 사례
services/job-analysis-api/pyproject.toml, services/job-analysis-api/src/orgmetra_job_analysis_api/*, services/job-analysis-api/tests/fixtures.py, services/job-analysis-api/tests/test_auth.py, services/job-analysis-api/tests/test_snapshot.py
Bearer 인증, 목적 제한 인가, 문서 검증, SHA-256 다이제스트, 저장·조회 포트를 추가했습니다. 저장 결과와 조회 결과의 무결성을 검증합니다.
PostgreSQL 저장소 어댑터
services/job-analysis-api/src/orgmetra_job_analysis_api/postgres.py, services/job-analysis-api/tests/test_postgres.py, tests/test_job_analysis_snapshot_postgres.sh
스냅샷과 하위 행을 저장합니다. 멱등 요청을 재생하고 digest 충돌을 거부합니다. 부모 범위, 감사 아웃박스, 읽기 전용 재구성을 검증합니다.
ASGI HTTP 라우트
services/job-analysis-api/src/orgmetra_job_analysis_api/http.py, services/job-analysis-api/tests/test_http_route.py
스냅샷 POST·GET 라우트와 헤더, UUID, query, JSON 검증을 추가했습니다. 인증, 권한, 도메인 오류를 HTTP 응답으로 변환합니다.
계약 검증 및 CI
.github/workflows/*, scripts/foundation-contract-core.mjs, services/job-analysis-api/tests/test_workflow_contract.py, tests/validate_repository.py, manifest.json
PostgreSQL 계약 테스트와 Job Analysis API 품질 워크플로를 추가했습니다. 필수 파일, 데이터베이스 객체, OpenAPI 작업과 커버리지 기준을 검증합니다.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟠 High · up to 2038e

This PR adds persistent tenant-scoped job-analysis snapshots and idempotent writes, but the current implementation can accept unbounded request bodies, mishandle concurrent retries, conflict with an existing migration sequence, and expose a route contract that does not match the service behavior. These create concrete availability, API correctness, deployment, and client-integration risks, so merge should wait for fixes.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant JobAnalysisAsgiApp
  participant TokenAuthenticator
  participant JobAnalysisUseCase
  participant PostgresJobAnalysisPort
  participant PostgreSQL

  Client->>JobAnalysisAsgiApp: POST snapshot with Authorization and Idempotency-Key
  JobAnalysisAsgiApp->>TokenAuthenticator: authenticate bearer token
  TokenAuthenticator-->>JobAnalysisAsgiApp: return AuthenticatedPrincipal
  JobAnalysisAsgiApp->>JobAnalysisUseCase: validate document and authorize purpose
  JobAnalysisUseCase->>PostgresJobAnalysisPort: persist snapshot and audit event
  PostgresJobAnalysisPort->>PostgreSQL: write normalized rows and outbox event
  PostgreSQL-->>PostgresJobAnalysisPort: commit transaction
  PostgresJobAnalysisPort-->>JobAnalysisUseCase: return persisted snapshot
  JobAnalysisUseCase-->>JobAnalysisAsgiApp: return snapshot document
  JobAnalysisAsgiApp-->>Client: 201 JSON response
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 제목은 거버넌스된 job-analysis snapshot 영속화라는 PR의 핵심 변경을 명확하고 간결하게 설명합니다.
✨ 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 cursor/job-analysis-snapshot-5eef

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.

github-code-quality[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor Author

Active-writer handoff on exact head 2038ee154798c757683d8ce286888d5fd2a53c57: this Draft is locally GREEN, but two repository-owned numbering collisions and one scope collision are real and must be repaired on this existing cursor lane before Ready.

  1. Migration collision: this PR introduces database/migrations/0010_job_analysis_snapshot.sql, while older dependency-root PR fix: bind validity studies to exact worker cases #26 already owns 0010_validity_study_case_integrity.sql at exact head a659f9ad0a43040aa2a38e8d1cd6ff3be6ffa4e2 and is Ready/mergeable with fresh Foundation/Security/SAST GREEN. Do not let feat: persist governed job-analysis snapshots #38 reserve 0010. Preserve fix: bind validity studies to exact worker cases #26 dependency order; after the relevant roots integrate, reconcile onto exact protected develop and assign the next actually free migration number, then refresh deterministic manifest/provenance and rerun the PostgreSQL contract on the new exact head.

  2. ADR collision: this PR creates docs/adr/0009-job-analysis-snapshot-persistence.md, while older Ready PR feat: bind performance criteria to worker job scope #28 already owns ADR 0009 (0009-criterion-observation-scope...) on exact head afc5050f2544b83e40038ebc12331e445fbf9efd. Do not overwrite/reuse ADR 0009. Allocate the next free ADR number only after reconciling the dependency roots.

  3. Job-analysis ownership overlap: existing Draft feat: govern evidence-backed job analysis cases #30 is the canonical job-analysis governance lane and already defines versioned source evidence, Task/FJA/KSAO linkages, human approval, sealing, tenant isolation and append-only evidence. feat: persist governed job-analysis snapshots #38 adds a separate job_analysis_snapshot/task/KSAO schema and HTTP surface. Before adding more source, compare the two contracts and either (a) make feat: persist governed job-analysis snapshots #38 explicitly consume/extend feat: govern evidence-backed job analysis cases #30’s governed case contract after feat: govern evidence-backed job analysis cases #30 is reconciled, or (b) prove feat: persist governed job-analysis snapshots #38 supersedes feat: govern evidence-backed job analysis cases #30 and close the duplicate only with technical rationale. Do not silently ship two competing job-analysis persistence models.

RED acceptance for this lane: after dependency reconciliation there must be exactly one migration number per migration, one ADR number per ADR, and one coherent job-analysis persistence/governance model; Foundation manifest/provenance and PostgreSQL executable contracts must be GREEN on that exact reconciled head. Keep this PR Draft until those conditions hold. I am not pushing competing source while the cursor agent owns this head.

@cursor
cursor Bot marked this pull request as ready for review August 18, 2026 06:36
@seonghobae
seonghobae marked this pull request as draft August 18, 2026 07:05
@seonghobae
seonghobae marked this pull request as ready for review August 18, 2026 07:06
@seonghobae
seonghobae marked this pull request as draft August 18, 2026 07:08

Copy link
Copy Markdown
Contributor Author

State-governance repair on unchanged exact head 2038ee154798c757683d8ce286888d5fd2a53c57: this PR was marked Ready again without any source commit resolving the already-proven 0010 migration collision with #26, ADR 0009 collision with #28, or #30/#38 job-analysis ownership overlap. I restored Draft. Existing writer: do not mark Ready again until those collisions are repaired on this canonical lane (after dependency-root integration/reconciliation), the current GitHub Code Quality unused-import finding is fixed, and fresh exact-head validation is obtained. A state flip alone is not evidence.

coderabbitai[bot]

This comment was marked as resolved.

@seonghobae
seonghobae force-pushed the cursor/job-analysis-snapshot-5eef branch from 5dcb6a5 to dad95dc Compare August 20, 2026 10:36
@seonghobae
seonghobae marked this pull request as ready for review August 20, 2026 14:59

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@seonghobae
seonghobae merged commit b60bb37 into develop Aug 20, 2026
46 of 47 checks passed
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