Skip to content

[ZASI v33 P1] Identity, tenant scope, durable persistence, audit and event foundation #10

Description

@cvsz

Objective

Build the identity and persistence layer required before ZASI may expose autonomous or multi-user control-plane behavior.

Source-grounded findings

  • backend/server.py uses an optional static X-API-Key; when the environment key is empty, API authentication is disabled.
  • WebSocket upgrade handling occurs before normal API auth middleware.
  • Rate-limit windows and WebSocket client state are process-local.
  • src/api_server.py contains a hard-coded default bearer token and in-memory audit log.
  • Current SQLite persistence stores selected state variables, not principals, sessions, approvals, events, evidence, or durable runs.

Scope

  • Add principal, tenant/workspace, device, session, role/capability, and credential contracts.
  • Centralize authentication middleware for REST, SSE, WebSocket, MCP, files, and connectors.
  • Enforce tenant/device scope in repository methods, never from untrusted request fields.
  • Add migration-managed persistence: SQLite local profile; PostgreSQL production/multi-process profile.
  • Add durable immutable audit/event records and transactional outbox.
  • Persist/recover sessions, approvals, cursors, idempotency records, and rate-limit state where required.
  • Add secret redaction and credential rotation/revocation behavior.

Acceptance criteria

  • Missing/expired/revoked/wrong-tenant credentials fail closed.
  • Unauthenticated WebSocket/SSE clients receive no telemetry or events.
  • Cross-tenant read and mutation tests pass.
  • State mutation + audit + event + outbox commit atomically.
  • Restart does not lose authoritative session, approval, cursor, or audit state.
  • No raw credential appears in logs, events, exception payloads, or UI telemetry.
  • Database migration backup/restore test passes.

Depends on

#9

Priority

P1 / foundation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions