feat: persist governed job-analysis snapshots - #38
Conversation
📝 WalkthroughWalkthroughJob Analysis 스냅샷을 PostgreSQL에 저장하고 조회하는 기능을 추가했습니다. OpenAPI, 인증·인가, ASGI 라우트, 멱등성, 감사 아웃박스, 테넌트 격리, append-only 보호와 계약 테스트를 함께 구성했습니다. ChangesJob Analysis 스냅샷 영속화
Estimated code review effort: 5 (Critical) | ~120 minutes Merge Risk: 🟠 High · up to 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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Active-writer handoff on exact head
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. |
|
State-governance repair on unchanged exact head |
5dcb6a5 to
dad95dc
Compare
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
developise7ddb7a78a5e1460410005d10f43ebf18c5e12e4and 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, ADR0014-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.JobAnalysisSnapshotis 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 NOBYPASSRLSrole 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
tryonly normalizedAuthenticationFailed; the later generic HTTP exception handler did not cover authentication. RED915c54dcd171ccbf9306159dad656484be6753b8adds a secret-bearing identity-backend failure regression that requires a governed500 internal_error, non-disclosing support envelope, and zero protected-port access. GREENb047f1bde8dc671bcf086cf0c76d81bbf1dfdacbadds the smallest authentication-boundary catch-all while preserving malformed/invalid credentials as401.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:
32392335044— queued32392335058— queued32392335053— queued32392335189— queued32392335375— queued32392335060— queued32392335097— queuedPredecessor 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.