Skip to content

feat(server): add Handoff access control - #1398

Draft
Teingi wants to merge 2 commits into
oceanbase:masterfrom
Teingi:codex/handoff-access-control-implementation
Draft

feat(server): add Handoff access control#1398
Teingi wants to merge 2 commits into
oceanbase:masterfrom
Teingi:codex/handoff-access-control-implementation

Conversation

@Teingi

@Teingi Teingi commented Aug 30, 2026

Copy link
Copy Markdown
Member

Which issue or RFC does this PR close?

Implements #1395.

Design reference: #1396.

Rationale for this change

The current optional static Bearer token authenticates one deployment-local caller but cannot express per-user, per-scope, or exact-Handoff visibility. Handoff Receipts also record receiver observations; they are not authorization grants.

This change adds an independent Server Access Control boundary so user A can grant user B least-privilege access to one committed Handoff Revision without exposing the surrounding scope. Runtime domain APIs remain free of Principal, role, and permission parameters, and deployments can replace the built-in decision provider and relationship store with an external authorization system.

What changes are included in this PR?

  • Add typed Principal, action, structured resource, fixed role, binding, decision, and data-minimized audit models.
  • Add a built-in hierarchical RBAC provider and Server-owned relational binding/audit schema for SQLite, OceanBase, and seekDB.
  • Add replaceable AuthorizationProvider, RelationshipWriter, and AccessAuditStore boundaries for integrations such as OpenFGA, Casbin, Oso, or an AuthZEN-compatible PDP.
  • Add /v1/access/me, check, batch-check, safe resource listing, role listing, binding management, and audit APIs plus typed Python SDK methods.
  • Annotate protected OpenAPI operations with generated x-powercontext-access requirements and enforce them at one Server PEP before Runtime dependencies or business metrics.
  • Preserve the authenticated Principal across the MCP internal ASGI bridge while still executing authorization for logical MCP operations.
  • Add disabled, legacy-static-admin, and enforced rollout modes; the default legacy mode preserves the existing static-token administrator behavior.
  • Add English and Chinese configuration and HTTP API documentation.
  • Fix OceanBase Handoff trigger cursor creation to avoid an incompatible nested SAVEPOINT while retaining SQLite's concurrent-insert behavior.
  • Add focused Access Control, HTTP, MCP, SDK, OpenAPI, persistence, and Server tests.

Are there any user-facing changes?

Yes. Authenticated deployments gain public Access APIs, stable 403 behavior, exact-Handoff receiver grants, Access audit records, and two Access configuration settings. Existing static-token deployments remain compatible through the default legacy-static-admin mode.

The change adds Server-owned Access tables but does not add identity or ACL fields to Handoff, Source, Memory, Work, or other Runtime domain records. scope_id remains a business partition rather than an authorization credential.

How was this change tested?

  • PRE_COMMIT_HOME=/tmp/powercontext-prek-cache make check
  • .venv/bin/python -m pytest -q -p no:cacheprovider (974 passed, 9 skipped)
  • make contract-test (30 passed)
  • make docs-test
  • Real configured acceptance journey using the local .env OceanBase, generation LLM, and Embedding provider:
    • persisted and vector-searched Memory;
    • generated, finalized, and committed a real Handoff;
    • granted one exact Revision from A to B;
    • verified HTTP allow/deny boundaries, MCP Principal propagation, audit redaction, restart persistence, revocation, and post-revocation denial;
    • revoked the test binding and removed the failed-run Runtime fixture while preserving append-only low-sensitivity audit evidence.

AI usage statement

OpenAI Codex (GPT-5) was used to inspect the repository contracts, implement the Access Control layer and generated API changes, diagnose the real OceanBase SAVEPOINT failure, and run the validation described above. The author directed the design and publication scope.

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