AUTH-09E: admit fixed services at runtime#157
Conversation
📝 WalkthroughWalkthroughThis change introduces strict human/service authorization contexts, fixed-service actor resolution and revalidation, lifecycle and drift denial coverage, service-token API contract checks, and updated AUTH-09E/ART-02C1 workstream records. ChangesAuthorization service admission
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ServiceToken
participant AuthorizationDependency
participant ActorService
participant AuthorizationKernel
participant API
ServiceToken->>AuthorizationDependency: authenticated service subject
AuthorizationDependency->>ActorService: resolve_service_for_authorization
ActorService-->>AuthorizationDependency: typed service actor context
AuthorizationDependency->>AuthorizationKernel: require service action
AuthorizationKernel->>ActorService: lock and revalidate service state
ActorService-->>AuthorizationKernel: refreshed context or denial
AuthorizationKernel-->>API: admission result and denial code
Possibly related PRs
Suggested reviewers: 🚥 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 |
…-fixed-service-runtime-admission # Conflicts: # .agent-loop/LOOP_STATE.md # .agent-loop/WORK_QUEUE.md
…-fixed-service-runtime-admission
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/app/modules/authorization/kernel.py (1)
252-260: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winUnguarded reconstruction of
HumanAuthorizationContextafter lock.
HumanAuthorizationContext.actor_kindisLiteral[ActorKind.HUMAN]. If the freshly lockedprofile.actor_kindever differs from"human"(concurrent drift on the same row between initial context resolution and this lock),ActorKind(profile.actor_kind)converts fine but the constructor call raises an unguardedpydantic.ValidationError— not caught here or inrequire(), surfacing as an unstructured 500 instead of a bounded denial code.Contrast with the analogous fixed-service path (
revalidate_serviceinbackend/app/api/deps/authorization.py), which rebuilds context via_authorization_contextand explicitly checksisinstance(refreshed, ServiceAuthorizationContext)before trusting it, falling back toNone(a gracefulPERMISSION_NOT_GRANTEDdenial) on mismatch rather than crashing.🛡️ Proposed defensive guard
link, profile = locked + if profile.actor_kind != "human": + return AuthorizationDenialCode.IDENTITY_LINK_REVOKED, context, None, None, True context = HumanAuthorizationContext( actor_profile_id=UUID(profile.id), actor_kind=ActorKind(profile.actor_kind),🤖 Prompt for 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. In `@backend/app/modules/authorization/kernel.py` around lines 252 - 260, Guard the post-lock reconstruction in the human authorization revalidation flow instead of constructing HumanAuthorizationContext unconditionally. Reuse the existing context-building/validation path, verify the refreshed result is a HumanAuthorizationContext (including the HUMAN actor_kind constraint), and return None or the established denial path on mismatch so require() produces PERMISSION_NOT_GRANTED rather than an uncaught ValidationError.
🤖 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 `@docs/spec_authorization_service.md`:
- Around line 504-507: Revise the wording in the authorization context
description to remove the awkward “required closed” modifier combination, while
preserving that only the service variant includes a required, closed
service_identity.
---
Outside diff comments:
In `@backend/app/modules/authorization/kernel.py`:
- Around line 252-260: Guard the post-lock reconstruction in the human
authorization revalidation flow instead of constructing
HumanAuthorizationContext unconditionally. Reuse the existing
context-building/validation path, verify the refreshed result is a
HumanAuthorizationContext (including the HUMAN actor_kind constraint), and
return None or the established denial path on mismatch so require() produces
PERMISSION_NOT_GRANTED rather than an uncaught ValidationError.
🪄 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: 40ee705a-1cb7-4829-8da8-56ec0a786a72
📒 Files selected for processing (23)
.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/STATUS.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-ART-CUSTODY-activation-custody-transfer.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09E-internal-review-evidence.md.agent-loop/initiatives/WS-AUTH-001-workstream-authorization-service/reviews/WS-AUTH-001-09E-pr-trust-bundle.md.agent-loop/merge-intents/WS-AUTH-001-09E.jsonbackend/app/api/deps/authorization.pybackend/app/modules/actors/service.pybackend/app/modules/artifacts/service.pybackend/app/modules/authorization/kernel.pybackend/app/modules/authorization/runtime.pybackend/scripts/api_contract_e2e.pybackend/tests/test_actors.pybackend/tests/test_artifact_admission.pybackend/tests/test_auth.pybackend/tests/test_authorization.pydocs/operations_authorization_service.mddocs/spec_authorization_service.mdscripts/test_agent_gates.py
|
Addressed all actionable CodeRabbit findings in d5162ce:
Validation: Ruff passes; 11 focused authorization tests pass; all nine required internal reviewer tracks pass. Full repository tests and coverage are running in GitHub Actions. |
WS-AUTH-001-09E PR Trust Bundle
Goal
Admit only explicitly provisioned fixed service actors into central AUTH while
keeping every feature action unavailable and every human authority path
separate.
Changes And Design
access, human rate control, role grant, or fallback path.
matrix membership before availability, and revalidates locked actor rows in
the caller transaction.
on denial, cancellation, or persistence failure.
specification and operations guidance.
Scope Control
No service feature action, ART/REV/CON call site, migration, schema, role,
grant, payment, review, revision, or reputation behavior is activated. ART PR
#154 and its owned
0028_artifact_admissionare already merged; AUTH-09E addsor allocates no migration.
Proof And CI Integrity
revalidation drift.
integrity, and 88 agent gates passed.
thresholds were weakened.
percent repository floor and actor/authorization 90 percent subsystem gates.
Internal Review
Candidate
881ac7fcand docs repaird859af3d, against trusted main8d5eb15b, pass senior engineering, QA/test, security/auth, product/ops,architecture, CI integrity, docs, reuse/dedup, and test-delta review after all
valid findings were repaired. Integrated candidate
98376fd1, against trustedmain
44f2467c, passes the same nine tracks after repairing ART admission'sstale exact-type check for the new closed human/service context union.
External Review
CodeRabbit raised one wording issue and one post-lock human-kind drift issue.
Both are repaired: the specification wording is clear, and human administrative
revalidation now denies actor-kind drift before context reconstruction or grant
lookup. The focused repair suite passes 11 tests; fresh external and hosted CI
checks remain required on the repair head.
Remaining Risk And Follow-up
Hosted Backend CI and external review remain. The same-initiative
WS-AUTH-001-ART-CUSTODYsuccessor is only a recorded next gate; it must notstart until this PR and signed memory are complete, its own contract
prerequisites pass, and the user explicitly starts it.
Human Review Focus
Review service-before-human dispatch, exact matrix-before-availability order,
active-only observation staging, lock-time drift denial, bounded evidence, and
the absence of feature activation or migration changes.
Human Merge Ownership
The agent may publish and repair this branch but may not merge it. Only the
human may approve this PR for merge. Trusted-main automation owns post-merge
schema-v2 memory generation when the workflow succeeds.