Skip to content

feat: add Authority Envelope SDK wrappers (RFC-008)#60

Merged
beonde merged 2 commits intomainfrom
feat/envelope-sdk
May 6, 2026
Merged

feat: add Authority Envelope SDK wrappers (RFC-008)#60
beonde merged 2 commits intomainfrom
feat/envelope-sdk

Conversation

@beonde
Copy link
Copy Markdown
Member

@beonde beonde commented May 6, 2026

Summary

Adds envelope creation, derivation, and transport header generation to the Python SDK, wrapping the new gRPC surface added in capiscio-core PR #70.

RFC-008 Coverage

This PR implements Plan Section G5-G8 from the RFC-008 chain verification implementation plan.

New gRPC Client Wrappers (_rpc/client.py)

  • create_envelope() — Create root Authority Envelopes (§6.1)
  • derive_envelope() — Derive child envelopes with hash linking and narrowing validation (§6.3)
  • build_transport_headers() — Encode delegation chains into HTTP transport headers (§15.1–§15.3)

New High-Level SimpleGuard API (simple_guard.py)

  • SimpleGuard.create_envelope() — Simplified root envelope creation with auto key selection
  • SimpleGuard.derive_envelope() — Simplified child derivation with constraints serialization
  • SimpleGuard.make_delegation_headers() — Combined badge + authority chain headers

Proto Stubs Regenerated

  • simpleguard_pb2.py — 8 new message types (CreateEnvelope/DeriveEnvelope/BuildTransportHeaders/VerifyEnvelopeChain Request/Response)
  • simpleguard_pb2_grpc.py — 4 new RPC client methods

Tests

14 unit tests covering:

  • Basic envelope creation and derivation
  • Constraints JSON serialization
  • Enforcement mode min field
  • Error propagation as ConfigurationError
  • Narrowing violation errors from gRPC
  • Transport header generation with/without badge maps
  • Custom expiry times

Dependencies

  • Requires capiscio-core PR #70 (envelope gRPC surface) to be merged first
  • No new Python dependencies added

Adds envelope creation, derivation, and transport header generation to the
Python SDK, wrapping the new gRPC surface added in capiscio-core PR #70.

Changes:
- Regenerate proto stubs with CreateEnvelope, DeriveEnvelope,
  BuildTransportHeaders, VerifyEnvelopeChain RPCs and 8 new messages
- Add low-level gRPC client wrappers in _rpc/client.py:
  - create_envelope(): Create root envelopes (§6.1)
  - derive_envelope(): Derive child envelopes with hash linking (§6.3)
  - build_transport_headers(): Encode chains to HTTP headers (§15.1-§15.3)
- Add high-level SimpleGuard API methods:
  - create_envelope(): Simplified root envelope creation
  - derive_envelope(): Simplified child envelope derivation
  - make_delegation_headers(): Combined badge + chain headers for requests
- Add 14 unit tests covering all envelope operations

Tests cover: basic creation, constraints serialization, enforcement mode,
error propagation, derivation with narrowing, header generation with/without
badge maps.
Copilot AI review requested due to automatic review settings May 6, 2026 04:32
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ Documentation validation passed!

Unified docs will be deployed from capiscio-docs repo.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ All checks passed! Ready for review.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ SDK server contract tests passed (test_server_integration.py). Cross-product scenarios are validated in capiscio-e2e-tests.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds RFC-008 “Authority Envelope” support to the Python SDK by introducing new SimpleGuard helpers and gRPC wrapper methods for creating envelopes, deriving child envelopes, and producing HTTP transport headers for delegation chains.

Changes:

  • Added SimpleGuard.create_envelope(), SimpleGuard.derive_envelope(), and SimpleGuard.make_delegation_headers() high-level APIs.
  • Added _rpc/client.py SimpleGuardService wrapper methods: create_envelope(), derive_envelope(), and build_transport_headers().
  • Regenerated SimpleGuard protobuf stubs and added a new unit test suite covering envelope flows and header generation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_envelope.py New unit tests for envelope creation/derivation and delegation transport header generation.
capiscio_sdk/simple_guard.py Adds high-level RFC-008 envelope and delegation-header helpers on SimpleGuard.
capiscio_sdk/_rpc/client.py Adds RPC wrapper methods for the new SimpleGuardService envelope/header RPCs.
capiscio_sdk/_rpc/gen/capiscio/v1/simpleguard_pb2.py Regenerated protobuf messages for the expanded SimpleGuardService surface.
capiscio_sdk/_rpc/gen/capiscio/v1/simpleguard_pb2_grpc.py Regenerated gRPC stub methods for the new RPC endpoints.

Comment thread capiscio_sdk/simple_guard.py Outdated

def make_delegation_headers(
self,
chain: list,
Comment on lines 5 to 18
@@ -11,9 +11,9 @@
from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
_runtime_version.Domain.PUBLIC,
6,
33,
5,
7,
34,
1,
'',
'capiscio/v1/simpleguard.proto'
- Use list[str] instead of bare list in make_delegation_headers
- Align simpleguard_pb2.py runtime version check to 6.33.5 to match
  all other generated pb2 files and the protobuf>=6.33.5 dependency
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ Documentation validation passed!

Unified docs will be deployed from capiscio-docs repo.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ All checks passed! Ready for review.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

✅ SDK server contract tests passed (test_server_integration.py). Cross-product scenarios are validated in capiscio-e2e-tests.

@beonde beonde merged commit 8e7e36a into main May 6, 2026
13 checks passed
@beonde beonde deleted the feat/envelope-sdk branch May 6, 2026 18:49
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