Repository navigation
Description
Parent epic: #2116
Priority and sequence
P0 within the Context Engine epic · CE05. Required for the first two-song/two-brief checkpoint.
Customer journey
A customer returns next week. Recoup can retrieve what it learned, where it came from and which version was used, instead of starting over.
Customer value and architecture
Turn one-off generation context into reusable, inspectable product data.
Scope
- Add persisted source/source-version, media reference, extraction result, accepted topic-document version, document-input relationship and brief-snapshot concepts with enforced subject references.
- Include durable request/module/attempt/accounting references agreed with CE06/CE07; table names are finalized after the baseline.
- Retain origin, publication/event/retrieval/analysis timestamps and precision, fingerprints, visibility, coverage, raw versus normalized output, model/prompt/recipe/schema versions and source citations.
- Keep storage access-controlled and removable; separate provider URLs from retained bytes and record reference-only versus approved production-asset status.
- Use additive database-repository migrations, indexes and scoped access rules; keep existing artist/song/catalog readers compatible. All API database calls use the repository Supabase access-layer pattern.
Acceptance criteria
- Each result and document can be reconstructed from stable input versions and recipe references.
- Source versions and accepted document versions are immutable history with an explicit current pointer, subject to defined deletion/retention rules.
- Private storage and row access follow CE04; no source/subject reference points to an unconstrained or missing entity.
- Migration tests cover existing data compatibility and a safe disable/rollback strategy without dropping customer data.
- Schema supports independent module commits rather than one final all-or-nothing Sites snapshot.
Blocking dependencies
- [Context] Verify the deployed schema and inventory context identity conflicts #2117
- [Context] Define context contracts, ownership rules and acceptance fixtures #2118
- [Context] Resolve provider identities and attach artists to the correct workspace #2119
- [Context] Enforce context ownership consistently across API, MCP and workers #2120
These are completion prerequisites, mirrored by native GitHub blocked-by links. Contracts, fixtures and independent scaffolding may begin earlier.
Execution gates
Draft migrations can be developed with fixtures; production migration PR/merge waits for CE01 conflict handling.
Validation
Synthetic migration, foreign-key, access, source-version and lineage tests; demonstrate artist/recording/release distinctions and old reader compatibility.
Owning implementation
Database repository migrations + API lib/supabase access layer
Delivery conventions
Shared API business logic serves HTTP, MCP and workers; clients do not duplicate it. Validate input with Zod and use the existing Supabase access layer. Database changes go through database-repository migrations and PRs. Use Vercel Workflows for new durable work. Reuse existing credits and record costs without exposing credentials or private traces. Every owning repository uses a feature branch and PR; distinguish fixture, local, merged and deployed verification.
Activity
Make document history trigger-only and subject-scoped
Count the lineage tool and test it through the real adapter
Point read_document_history at real document ID sources
sidneyswift commentedon Nov 6, 2026
Partly done. Context sources, immutable source versions and results, documents with a current pointer, execution records, saved brief snapshots and private audio results are on main (recoupable/database#72, recoupable/database#74, recoupable/database#77, recoupable/database#78, recoupable/database#79).
Still open: immutable history for accepted document versions (draft recoupable/database#99 with recoupable/api#1004), a documented disable/rollback test, and the access and withdrawal checks owned by recoupable/api#2120 and recoupable/api#2124.