Skip to content

feat: A.I.R. API layer — VaultNode operational stack#2

Merged
ZoaGrad merged 1 commit into
masterfrom
feat/api-layer
Feb 21, 2026
Merged

feat: A.I.R. API layer — VaultNode operational stack#2
ZoaGrad merged 1 commit into
masterfrom
feat/api-layer

Conversation

@ZoaGrad
Copy link
Copy Markdown
Owner

@ZoaGrad ZoaGrad commented Feb 21, 2026

A.I.R. — VaultNode Operational Stack

CAGE: 17TJ5 | UEI: SVZVXPTM9AF4

Summary

  • main.py — FastAPI app with lifespan DB pool (asyncpg). Full interdiction logic: /event validates state transitions against ratified workflows, flags incidents on unauthorized transitions, commits authorized events to ledger.
  • schema.sql — Five-table Postgres ledger: agents, sessions, workflows, events, incidents. Authoritative init script mounted at container startup.
  • docker-compose.yml — Postgres 15-alpine, schema mounted as init script, credentials from .env only.
  • requirements.txt — Pinned: FastAPI 0.111, asyncpg 0.29, pydantic-settings 2.2, uvicorn 0.29.
  • .env.example — Credential template, safe to commit.
  • .gitignore.env permanently blocked from remote.

Architecture Notes

  • @app.on_event("startup") deprecated path avoided — lifespan context manager used instead.
  • No plaintext credentials in any committed file.
  • Interdiction logic is live, not a placeholder — fetches workflow, validates transition, writes incident or commits event.

Test plan

  • Merge PR feat: A.I.R. Charter — Day One Compilation #1 (charter) first
  • cp .env.example .env — populate password
  • docker-compose up -d — verify Postgres init against schema.sql
  • pip install -r requirements.txt && uvicorn main:app --reload
  • POST first workflow definition to /workflow
  • Simulate authorized and unauthorized transitions via /event
  • Verify incident appears in /incidents
  • Ratify and merge to master

🤖 Generated with Claude Code

- main.py: FastAPI app with lifespan DB pool, full interdiction logic
  wired to asyncpg. /event validates state transitions against ratified
  workflows, flags incidents on unauthorized transitions.
- schema.sql: Five-table Postgres ledger (agents, sessions, workflows,
  events, incidents). Authoritative init script.
- docker-compose.yml: Postgres 15-alpine container, schema mounted as
  init script, credentials sourced from .env (never hardcoded).
- requirements.txt: Pinned deps — FastAPI 0.111, asyncpg 0.29,
  pydantic-settings 2.2.
- .env.example: Credential template, safe to commit.
- .gitignore: .env blocked from remote.

CAGE: 17TJ5 | UEI: SVZVXPTM9AF4
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27817fffd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread main.py
event.session_id,
)

if row:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject events when no workflow is found

The interdiction check only runs inside if row, so when a session exists but has no matching workflow, the request skips validation and still inserts into events as "authorized." This creates a straightforward bypass where unratified sessions can commit transitions without incident logging, which undermines the core enforcement path described by this endpoint.

Useful? React with 👍 / 👎.

Comment thread main.py
valid_next = definition.get(event.state_before, [])
if event.state_after not in valid_next:
# Unauthorized transition — generate incident
incident_id = f"INC-{event.session_id}-{event.action}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make incident IDs unique per violation

Incident IDs are derived only from session_id and action, but inserts use ON CONFLICT (id) DO NOTHING, so multiple unauthorized transitions with the same action in one session are silently discarded after the first one. In practice this drops evidence of repeated drift and leaves the incidents ledger incomplete for exactly the cases this service is meant to audit.

Useful? React with 👍 / 👎.

@ZoaGrad ZoaGrad merged commit 480fb79 into master Feb 21, 2026
@ZoaGrad ZoaGrad deleted the feat/api-layer branch February 21, 2026 15:26
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