[Story-994] Add Phase-0 agent schema prerequisites

Story 994Epic 749๐Ÿ”— Chain of CustodyAgent Platform6 files ยท +734/โˆ’1

PR #244 ยท pramaan-io/pramaan-functions ยท merged 2026-06-02

How it flows

sequenceDiagram
  autonumber
  participant mig as Migration 0068
  participant schema as Schema
  participant rls as RLS
  participant tests as Tests
  mig->>schema: Widen status check constraint
  schema->>schema: Create 3 firm-scoped tables
  schema->>rls: Enable firm RLS on each
  mig->>mig: Downgrade reverses cleanly
  rls->>tests: RLS isolation tests pass
  schema->>tests: Schema shape tests pass

1f2a3b4c5d6e_0068_agent_prompt_versions_and_quote_anchors.py ยท +298 โ€” new methods

Methodin โ†’ outwhat it does
_sql_values(values) โ†’ str
_replace_agent_run_status_check(values) โ†’ None
_enable_firm_rls(table_name) โ†’ None

What changed, file by file

Alembic migration zero-zero-six-eight widens agent-run status check and creates firm-scoped agent_prompts, prompt_versions, and quote_anchors tables with RLS.

new methodsignature
_sql_values(values) โ†’ str
_replace_agent_run_status_check(values) โ†’ None
_enable_firm_rls(table_name) โ†’ None
_disable_firm_rls(table_name) โ†’ None
upgrade() โ†’ None
downgrade() โ†’ None
New fields: revision : strdown_revision : str | Sequence[str] | Nonebranch_labels : str | Sequence[str] | Nonedepends_on : str | Sequence[str] | None

What this PR does NOT touch

schema only
tested in isolation
clean downgrade path
touching routes now risks two-to-four weeks rework if ADR-070 decision is wrong

Files changed (6)

Fileยฑ
alembic/versions/1f2a3b4c5d6e_0068_agent_prompt_versions_and_quote_anchors.py โ˜…+298
docs/walkthroughs/story-994-walkthrough.html+111
src/shared/agents_db_models.py โ˜…+43
tests/integration/test_agent_prompt_versions_rls.py+118
tests/unit/test_agent_prompt_schema_prereqs.py+147
tests/unit/test_agent_run_canonical_truth.py+17 โˆ’1