Skip to content

Scaffold shared governance service for SendBox governed sessions - #1

Merged
mbianchidev merged 6 commits into
mainfrom
scaffold-governance-service
Nov 15, 2026
Merged

mbianchidev merged 6 commits into
mainfrom
scaffold-governance-service

Conversation

@mbianchidev

@mbianchidev mbianchidev commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Scaffold for the shared governance service of SendBox governed sessions, increment 2 of sendbox-dev/sendbox#87 (authenticated multi-user management API, project-scoped roles, session admission, credential grants and revocation, expiring exceptions, central audit).

This is a scaffold: every /v1 endpoint returns 501 Not Implemented. No governance decision is made yet, and the service must not be deployed as an authority. Provider credentials never reach this service; injection stays in the SendBox host broker.

What is included

  • Workspace: Rust 2024, toolchain pinned to 1.93.1 (clippy, rustfmt), unsafe_code = "forbid", clippy::all = "deny". Crate crates/fleet-server, binary sendbox-fleet.
  • Shared contract: sendbox-governance as a git dependency pinned to bd7498ab24c3c9cfd98f80349bee31fed667539b. Request and response bodies reuse the contract types (GovernanceBinding, GrantRequest, CredentialGrant, RequestContext, Decision, RevocationReason, identifiers, ProfileRef, GovernanceProfile::parse).
  • Server: Actix Web with env config (FLEET_BIND, FLEET_DATABASE_URL, FLEET_LOG_DIR, FLEET_LOG_LEVEL, FLEET_LOG_RETENTION_DAYS), graceful shutdown on SIGINT/SIGTERM, GET /healthz, GET /readyz (database ping).
  • /v1 stubs: POST /v1/sessions:admit, POST /v1/grants, POST /v1/grants/{grant_id}:renew, POST /v1/grants/{grant_id}:revoke, POST /v1/authorize, GET/PUT /v1/profiles/{profile_id}, GET/POST /v1/projects/{project_id}/roles, POST /v1/exceptions, GET /v1/audit/events. Order of checks: bearer authentication middleware (401) before routing, then contract validation (400), then RFC 9457 application/problem+json 501 with a capability member. Identity headers are never treated as authentication; the production authenticator rejects every token with authentication provider not configured.
  • Schema: equivalent PostgreSQL and SQLite migrations (run at startup) for principals, projects, role bindings, profiles, minimum revisions, sessions, credential grants (no credential columns), revocations, exceptions, and an append-only hash-chained audit log. CHECK constraints bound identifiers and lifetimes (7-day grants and exceptions, 60-second revocation grace), approvers must differ from requesters, grants must match their session's principal, project, binding, and profile revision (composite foreign key), and triggers enforce chain linkage and forbid audit updates and deletes.
  • Logging: JSON lines to stdout and sendbox-fleet.YYYY-MM-DD.log (UTC daily rotation), retention of 30 days applied at startup and hourly, non-lossy bounded writer, no bodies, headers, or query strings logged.
  • Containers: multi-stage Dockerfile (digest-pinned bases, uid 10001), docker-compose.yml with a health-checked PostgreSQL (digest-pinned), read-only root filesystem, dropped capabilities, .env.example.
  • CI: fmt, Clippy -D warnings, tests on SQLite; PostgreSQL service job running the migration tests plus a server start, probe, and graceful stop; cargo audit. Actions pinned by commit SHA, permissions: contents: read, concurrency group.
  • Docs: docs/architecture.md, docs/contract.md, docs/threat-model.md, docs/roadmap.md (work items mapped to the issue's acceptance criteria), docs/development.md, plus CONTRIBUTING.md and SECURITY.md.

Testing

  • cargo fmt --all -- --check, cargo clippy --locked --workspace --all-targets -- -D warnings, cargo test --locked --workspace (18 tests: config validation, bearer grammar, log retention boundaries, probes, 401 on every route, 501 with a mocked token, 400 for invalid contract bodies, transport errors, migrations and schema invariants).
  • Migration tests also run against PostgreSQL 18.7 locally and in CI.
  • docker compose build --no-cache and docker compose up verified locally (see the note on Porto below).
  • GitHub Actions jobs for this PR did not start: GitHub reports that recent account payments failed or the Actions spending limit needs to be increased (private repository). Until that is resolved, the workflow's commands were run locally in a rust:1.93.1-slim-trixie Linux container against PostgreSQL 18.7: fmt, Clippy, SQLite tests, PostgreSQL migration tests, and the server start, probe, and graceful stop all passed, and cargo audit --deny warnings passed with cargo-audit 0.23.0. The workflow also passes actionlint.

Known limitations and accepted risks

  • cargo audit ignores two advisories, documented in .cargo/audit.toml: RUSTSEC-2026-0459 (bundled SQLite older than 3.54, used only for local development and tests; the fix needs sqlx 0.9, which requires Rust 1.94) and RUSTSEC-2023-0071 (rsa, present in Cargo.lock only and never compiled).
  • The contract pin points at a commit on the increment-1 feature branch; move it to main once that work merges.
  • Log rotation is daily only; size-based rotation is a follow-up.
  • With the Porto engine, Compose cannot resolve image: name:tag@sha256:... references (Porto stores the pulled image without its digest), so the local Compose run used a temporary tag-only override for PostgreSQL. Standard Docker and GitHub Actions resolve the pinned digest.

Follow-ups

  1. Integrate an identity provider for users and a workload identity for SendBox hosts.
  2. Persistence layer, then profile publication with signature verification and minimum revisions.
  3. Project-scoped role checks, session admission, grants with bounded leases and revocation (including existing-connection handling), and per-request authorization; remote authority client in the sendbox host.
  4. Exceptions approval flow with stale-approval rejection; central audit hash computation, correlation, queries, and external anchoring.
  5. Operations: TLS, rate limits, metrics, backups, least-privilege database role, size-based log rotation.
  6. Upgrade sqlx to 0.9 when the toolchain moves to Rust 1.94 and drop the audit exceptions.

Tables for principals, projects, project roles, signed profile revisions,
minimum revisions, sessions, credential grants, revocations, exceptions,
and an append-only hash-chained audit log, with constraints for identifier
grammar, bounded lifetimes, separation of duties, and grant-to-session
identity binding.
Actix Web service binary sendbox-fleet with environment configuration,
JSON logging to stdout and a daily-rotated log file with 30-day retention,
health and readiness probes, and versioned /v1 routes. Every /v1 route
requires a bearer token before routing, validates bodies against the
pinned sendbox-governance contract, and returns an RFC 9457 501 problem
naming the increment-2 capability.
Multi-stage Dockerfile with digest-pinned bases and a non-root runtime,
compose stack with a health-checked PostgreSQL, and CI for formatting,
Clippy, SQLite tests, PostgreSQL migrations plus a server smoke run, and
cargo audit with documented exceptions.
Cargo.toml tracks sendbox main; Cargo.lock keeps the exact commit
(9817251, the increment-1 merge). Dependabot moves the lockfile daily and
an auto-merge workflow merges those updates once required CI passes.
SECURITY.md now points to GitHub private vulnerability reporting.
@mbianchidev
mbianchidev marked this pull request as ready for review November 15, 2026 14:09
@mbianchidev
mbianchidev merged commit 434178f into main Nov 15, 2026
5 checks passed
@mbianchidev
mbianchidev deleted the scaffold-governance-service branch November 15, 2026 16:34
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