Add actor profile lifecycle and evidence repair#148
Conversation
…-actor-identity-lifecycle # Conflicts: # scripts/test_agent_gates.py
…-actor-identity-lifecycle
📝 WalkthroughWalkthroughThis PR splits AUTH-09D into profile and identity-link lifecycle chunks, activates actor-profile suspend/reactivate/deactivate operations, adds migration 0026 with lifecycle provenance guards, wires authorization and idempotent HTTP flows, and expands PostgreSQL, migration, API, audit, concurrency, and gate coverage. ChangesAUTH-09D lifecycle activation
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
@.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-internal-review-evidence.md:
- Around line 3-8: Regenerate the internal review evidence document for the
final PR head, updating the reviewed and implementation SHAs to the final state.
Re-run the required review tracks and emit the checker’s canonical rows,
including docs, reuse/dedup, test delta, and CI integrity, then verify with
check_internal_review_evidence.py and git diff --check.
- Around line 3-56: Re-run all required reviewers against the final head, then
update the reviewer evidence at
.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-internal-review-evidence.md
lines 3-56 with the final SHA and checker-recognized reviewer-row schema; update
.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-pr-trust-bundle.md
lines 81-86 with the regenerated exact-head result, replacing the stale SHA and
pass assertion.
In `@backend/app/modules/actors/models.py`:
- Around line 76-83: Align lifecycle reason database validation with
ActorLifecycleBody.reason’s str.strip() whitespace behavior. Update
lifecycle_reason_bounds in models.py, the corresponding constraints in
0026_actor_profile_lifecycle.py, and dirty-row tests to reject
tab/newline-padded values for suspension_reason, reactivation_reason, and
deactivation_reason while preserving the existing null, trimming, and 1–500 byte
bounds checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fdc818ca-ee84-4788-8994-8ebb87002569
📒 Files selected for processing (46)
.agent-loop/LOOP_STATE.md.agent-loop/REVIEW_LOG.md.agent-loop/WORK_QUEUE.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/CHUNK_MAP.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/DECISIONS.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/DISCOVERY.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/PLAN.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/STATUS.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-09D-A-profile-lifecycle.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-09D-B-identity-link-lifecycle.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-09D-actor-identity-lifecycle.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-09E-fixed-service-runtime-admission.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-10-project-role-grants.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-11-project-read-cutover.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-12-project-mutation-cutover.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-13-task-assignment-cutover.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-14-submission-checker-cutover.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/chunks/WS-AUTH-001-15-worker-authority-removal.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-internal-review-evidence.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-pr-trust-bundle.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09D-A-preimplementation-review-evidence.md.agent-loop/merge-intents/WS-AUTH-001-09D-A.jsonbackend/alembic/versions/0026_actor_profile_lifecycle.pybackend/app/modules/actors/models.pybackend/app/modules/actors/schemas.pybackend/app/modules/actors/service.pybackend/app/modules/audit/schemas.pybackend/app/modules/authorization/catalogue.pybackend/app/modules/authorization/kernel.pybackend/app/modules/authorization/lifecycle_schemas.pybackend/app/modules/authorization/lifecycle_service.pybackend/app/modules/authorization/repository.pybackend/app/modules/authorization/router.pybackend/app/modules/authorization/runtime.pybackend/app/modules/authorization/service.pybackend/scripts/api_contract_e2e.pybackend/tests/test_actors.pybackend/tests/test_alembic.pybackend/tests/test_api_controls.pybackend/tests/test_audit.pybackend/tests/test_auth.pybackend/tests/test_authorization.pydocs/architecture_data_model.mddocs/operations_authorization_service.mddocs/spec_authorization_service.mdscripts/test_agent_gates.py
WS-AUTH-001-09D-A PR Trust Bundle
Chunk
WS-AUTH-001-09D-A- Profile Lifecycle And Evidence RepairGoal
Add exact administrative ActorProfile suspension, reactivation, and terminal
deactivation while repairing truthful lifecycle provenance and linked authority
evidence at the database boundary.
Human-Approved Intent
The user explicitly started AUTH-09D. Required L1 review rejected the combined
parent contract before runtime edits and split it into 09D-A and separately
gated 09D-B. This PR implements only 09D-A.
What Changed
0026_actor_profile_lifecyclewith profile reactivationprovenance, API-equivalent whitespace normalization and 1-to-500-byte reason
guards, fresh profile/link transition attribution, truthful reactivation
direction, and fail-closed upgrade/downgrade checks.
reservation-first idempotency, the central AUTH kernel, serialized authority
locks, one route-owned commit, and bounded responses.
WS-AUTH-001-09D-A; both identity-link lifecycle actions remain planned underWS-AUTH-001-09D-B.failure injection, real PostgreSQL lock waits, migration refusal, OpenAPI,
and the live API contract.
Design Chosen
The route reserves its idempotency key before authorization, locks the authority
singleton and verified caller lineage before the exact target, revalidates the
current system grant, stages the profile transition and linked invalidation
evidence in one transaction, touches only the human caller, and commits once.
Missing targets and SQL failures roll back all staged evidence and state.
Reactivation provenance must be complete, non-null, and different from the
previous transition tuple. Deactivation is terminal. Fixed-service profiles may
be administrative targets, but this chunk never admits a service caller.
Scope Control
Trusted main through REV PR #147 at
f18b620is integrated. No identity-linkmutation route, service admission, feature-owned authorization, compatibility
alias, workflow, dependency, coverage threshold, or historical migration
changed.
Tests And Checks Run
all 29 supported-runtime
str.strip()whitespace code points and NBSPprevious-head refusal.
node: passed together in 110.04 seconds.
merge-intent validation, and diff integrity: passed.
Test Delta
Tests assert exact action/permission/owner parity, normalized reason bounds,
API/database whitespace parity for all 29 supported-runtime points, fresh
transition provenance, denial privacy, service-target invariance, all nine
transaction failure stages, reusable failed idempotency keys, and actual
PostgreSQL waiter observation. No test was skipped, weakened, or rewritten to
conceal behavior.
CI Integrity
The repository-wide 78 percent floor and focused 90 percent subsystem floors
remain unchanged. No workflow, dependency, threshold, skip, or exclusion was
modified. GitHub Backend remains authoritative for the full suite.
Reviewer Results
Senior engineering, QA/test, security/auth, product/ops, architecture,
migration/data integrity, CI integrity, docs, reuse/dedup, and test delta all
pass exact integrated head
7c33e6453a2c91256c8fd416c63e30b95fd9d825after every valid finding was repaired.
Remaining Risks
These system-authority routes intentionally change exact profile lifecycle
state and produce append-only authority evidence. PostgreSQL serialization and
database guards contain concurrent and direct-write risk. Identity-link state
can still make a reactivated profile unable to authenticate; that component
truth is deliberate and remains visible to later AUTH logic.
Follow-Up Work
WS-AUTH-001-09D-Bowns identity-link revoke/reactivate routes and mixedprofile/link/grant race closure only after this PR merges, trusted-main memory
passes, and the user gives a new explicit start.
WS-AUTH-001-09Eremains thelater fixed-service runtime-admission boundary.
Human Review Focus
Review terminal deactivation, fresh reactivation provenance, denial privacy,
reservation and lock order, fixed-service non-admission, rollback atomicity,
exact child action ownership, and observed PostgreSQL waiter proof.
Human Merge Ownership
The agent may publish and repair this branch but may not merge it. Only the
human may approve and merge the PR. Trusted-main automation owns post-merge
memory; 09D-B does not start automatically.