Skip to content

Add actor profile lifecycle and evidence repair#148

Merged
abiorh-claw merged 29 commits into
mainfrom
codex/ws-auth-001-09d-actor-identity-lifecycle
Jul 18, 2026
Merged

Add actor profile lifecycle and evidence repair#148
abiorh-claw merged 29 commits into
mainfrom
codex/ws-auth-001-09d-actor-identity-lifecycle

Conversation

@Abiorh001

@Abiorh001 Abiorh001 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

WS-AUTH-001-09D-A PR Trust Bundle

Chunk

WS-AUTH-001-09D-A - Profile Lifecycle And Evidence Repair

Goal

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

  • Added migration 0026_actor_profile_lifecycle with profile reactivation
    provenance, 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.
  • Added exact profile suspend, reactivate, and terminal deactivate routes using
    reservation-first idempotency, the central AUTH kernel, serialized authority
    locks, one route-owned commit, and bounded responses.
  • Activated only the three profile lifecycle actions. Their exact owner is
    WS-AUTH-001-09D-A; both identity-link lifecycle actions remain planned under
    WS-AUTH-001-09D-B.
  • Added behavior proof for privacy, evidence, rollback, fixed-service targets,
    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 f18b620 is integrated. No identity-link
mutation route, service admission, feature-owned authorization, compatibility
alias, workflow, dependency, coverage threshold, or historical migration
changed.

Tests And Checks Run

  • Five exact isolated PostgreSQL migration nodes: passed in 250.95 seconds.
  • Repaired constraint and dirty-row nodes: passed in 111.55 seconds, covering
    all 29 supported-runtime str.strip() whitespace code points and NBSP
    previous-head refusal.
  • Historical rollback-guard cleanup and the immediately following migration
    node: passed together in 110.04 seconds.
  • Expanded real lifecycle/service/failure matrix: passed in 100.36 seconds.
  • PostgreSQL-observed concurrency node: passed in 140.69 seconds.
  • Three historical owner-split migration nodes: passed in 199.52 seconds.
  • Authorization coverage: 110 passed, 91.78 percent branch coverage.
  • Actor coverage: 90.70 percent branch coverage.
  • Lifecycle service: 100 percent branch coverage.
  • Live HTTP API contract: passed.
  • Repository-wide Ruff, stale scans, Markdown links, 87 Agent Gates,
    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 7c33e6453a2c91256c8fd416c63e30b95fd9d825
after 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-B owns identity-link revoke/reactivate routes and mixed
profile/link/grant race closure only after this PR merges, trusted-main memory
passes, and the user gives a new explicit start. WS-AUTH-001-09E remains the
later 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.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

AUTH-09D lifecycle activation

Layer / File(s) Summary
Planning split and lifecycle contracts
.agent-loop/..., docs/*, scripts/test_agent_gates.py
AUTH-09D is split into separately gated profile and identity-link lifecycle chunks, with migration reservations shifted from 0027 through 0032.
Persistence and authorization foundation
backend/alembic/versions/0026_actor_profile_lifecycle.py, backend/app/modules/actors/*, backend/app/modules/authorization/{catalogue,kernel,runtime,service}.py, backend/app/modules/audit/schemas.py
Profile reactivation provenance, database guards, action ownership, lifecycle resource contexts, authorization checks, and invalidation evidence are added or updated.
Lifecycle API orchestration
backend/app/modules/authorization/{lifecycle_schemas,lifecycle_service,repository,router}.py
Three protected lifecycle endpoints use strict reasons, reservation-first idempotency, target locking, conflict auditing, terminal deactivation, and bounded responses.
Validation and review evidence
backend/tests/*, backend/scripts/api_contract_e2e.py, .agent-loop/.../reviews/*
Migration, trigger, API, audit, concurrency, rollback, replay, OpenAPI, and action-catalogue coverage is added or updated.

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

Possibly related PRs

Suggested reviewers: abiorh-claw

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the core work, but it omits several required template sections like Why It Changed, Alternatives Rejected, Evidence, and the reviewer table. Add the missing template sections and keep the required headings, especially Why It Changed, Alternatives Rejected, Evidence, Acceptance Criteria Proof, and Internal Reviewer Results.
✅ Passed checks (3 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.
Title check ✅ Passed The title matches the main change: adding actor profile lifecycle support and evidence repair.
✨ 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 codex/ws-auth-001-09d-actor-identity-lifecycle

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.

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between f18b620 and cc2939a.

📒 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.json
  • backend/alembic/versions/0026_actor_profile_lifecycle.py
  • backend/app/modules/actors/models.py
  • backend/app/modules/actors/schemas.py
  • backend/app/modules/actors/service.py
  • backend/app/modules/audit/schemas.py
  • backend/app/modules/authorization/catalogue.py
  • backend/app/modules/authorization/kernel.py
  • backend/app/modules/authorization/lifecycle_schemas.py
  • backend/app/modules/authorization/lifecycle_service.py
  • backend/app/modules/authorization/repository.py
  • backend/app/modules/authorization/router.py
  • backend/app/modules/authorization/runtime.py
  • backend/app/modules/authorization/service.py
  • backend/scripts/api_contract_e2e.py
  • backend/tests/test_actors.py
  • backend/tests/test_alembic.py
  • backend/tests/test_api_controls.py
  • backend/tests/test_audit.py
  • backend/tests/test_auth.py
  • backend/tests/test_authorization.py
  • docs/architecture_data_model.md
  • docs/operations_authorization_service.md
  • docs/spec_authorization_service.md
  • scripts/test_agent_gates.py

Comment thread backend/app/modules/actors/models.py
@abiorh-claw
abiorh-claw self-requested a review July 18, 2026 16:45
@abiorh-claw
abiorh-claw merged commit 99ae4c9 into main Jul 18, 2026
4 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 18, 2026
@abiorh-claw
abiorh-claw deleted the codex/ws-auth-001-09d-actor-identity-lifecycle branch July 18, 2026 21:48
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.

2 participants