PostgreSQL direction and bounded evaluation
Self-hosted PostgreSQL is the preferred candidate for a future shared operational database. This document specifies ownership and a later evaluation; it does not approve a database replacement, service installation, production settings change, data migration, dual writes or cutover. The modular-lane and momentum milestone continues against the existing authoritative stores. No PostgreSQL speed multiplier is claimed.
Decisions established now
- Lane adapters receive immutable evidence/configuration and return assessments and missing-evidence requirements. They receive no connection, transaction, provider, accounting or delivery handle.
evidence_requests.EvidenceRequestis the common immutable demand contract.ConsumerAccessimplements cutoff-bound evidence reads and only the named consumer's demand/result/cancellation.sqlite_shared_evidencecontains its SQLite connections, queries and transactions; the publicshared_evidencemodule exposes the fixed capabilities.storage_accessnames narrow evidence/request interfaces and collector-only accounting and shared-owner assessment capabilities. Their existing implementations retain budget validation, arbitration and immutable writes. There is no interchangeable backend registry or general database framework.- DD writes reports only through its existing
DDStoreowner.SavedReportReaderreads and verifies original bytes/digests from that ledger without initialization or publication into another store. Historical reports without completion timestamps have unknown availability and cannot become retrospective point-in-time evidence. Paper decisions, balances and journals remain in their existing owners. - The optional schema-11 addition stores new consumer attribution and group/publication records beside existing canonical market evidence. It relocates no existing ledger and is not physical consolidation of operational storage. Startup does not prepare it. Only synthetic schema rehearsals have been performed for this change.
These boundaries are required for clean lane interfaces today. Selecting and deploying PostgreSQL belongs to a separately reviewed migration.
Proposed PostgreSQL ownership
One shared operational cluster/database may eventually hold the following owned schemas. Database placement does not merge write authority. Roles must have no cross-owner updates; lane adapters still have no SQL credentials. Migrations/maintenance use a separate privileged principal.
| Owner | Proposed records and write authority |
|---|---|
| Collection/evidence | Append original dispatch intents/outcomes, source responses, normalized evidence and provenance; one canonical result can satisfy many consumers. Evidence validation remains with its current collector/validator. |
| Request/scheduler | Consumer/purpose subscriptions, selected identity/policy/freshness, cancellations, immutable slots/deadlines, groups/membership, claims and publication/outbox records. Each consumer can submit/cancel only its own demand; scheduler alone claims/groups work. |
| Accounting | Existing grants, expiry fences, quota journals, reservations and charge/outcome transitions. Admission stays with the accounting owner. Attribution links do not multiply charges or assign a whole shared charge to one lane. |
| Assessment/arbitration | Persist lane assessments and selected decisions through the existing shared assessment/decision owner. Lanes cannot change another lane's state, final exits, events or delivery. |
| DD | Original requests, research plans, operation reservations/results, reports and delivery outbox. Alfa cannot write DD interpretation or make DD a qualification veto. |
| Agents | Separate agent/campaign decisions, reservations, immutable journals and paper balances; each agent writes only its own namespace through existing controls. No live execution authority is added. |
| Delivery | Authoritative event/outbox and delivery attempts/acknowledgments under existing event/delivery rules. Consumers cannot independently create alerts. |
Keep original canonical UTF-8 bytes (or bytea) and original digests as authoritative values. A JSONB projection may support indexing but cannot replace canonical bytes or determine a historical hash by reserialization. Retain identifiers with original owner/ledger namespaces, candidate/chain/token/pool identities, observed/retrieved/available timestamps, policy versions and original interpretation. Preserve receipts, expired authority, sticky suspensions, budgets, reservations, balances and all journals exactly. Do not fabricate missing historical clocks or remap IDs merely for convenience.
Transactions and external-call uncertainty
- Submit/reuse: validate caller, exact identity, policy, cutoff and freshness. In a short transaction append the idempotent consumer request or reference eligible existing evidence. Never restamp evidence freshness.
- Claim/admit: scheduler selects bounded already-due work in priority/expiry/fairness order, preserving protected capacity. Atomically claim only records it owns, establish immutable dispatch identity and original reservations, then commit before leaving the storage boundary. If reservations remain in separate stores, preserve the current ordered durable protocol and reconciliation; do not pretend those commits are atomic.
- Dispatch: no provider/model wait while a database transaction, row lock or pool connection is held. Persist the original attempt intent before external I/O. A lost response, connection loss or ambiguous local commit is an uncertain attempt, not permission to resend, grant another allowance, move its deadline or renew a receipt. Recover by the original idempotency/dispatch key and saved outcome. Retry external calls only where the original provider contract and current authority explicitly allow it.
- Return/publication: append exact response/evidence once under the original dispatch key; validate lineage before satisfying subscriptions. Publish the canonical result and its consumer links idempotently. A shared result has one accounting outcome and multiple preserved consumer purposes. Re-reading a committed result after an ambiguous commit must not redispatch.
- Assessment/outbox: evaluate an explicit point-in-time evidence set outside a write transaction. In a short owner transaction validate its frozen identity/policy and append the assessment/decision/event plus authoritative outbox atomically where they share the approved owner database. Current split ledgers retain existing recovery protocols until reviewed migration. Delivery reserves its original attempt before I/O and records acknowledgment afterward; uncertain sends remain uncertain.
SELECT … FOR UPDATE SKIP LOCKED is a candidate for bounded queue claims only. It skips locked rows and gives an inconsistent view, so it is unsuitable for general evidence/arbitration reads. Claim order alone does not ensure fairness: preserve immutable due slots, per-consumer demand/work limits, expiry checks and protected-service interleaving, and measure starvation. PostgreSQL documents these queue-specific tradeoffs in SELECT locking.
Bounded offline evaluation plan
Evaluation is a separate artifact/review, not an operational prerequisite to merging working lane interfaces. Use synthetic state first. If representative copied state is later authorized, stop all writers for one consistent runtime snapshot or use a proven coordinated snapshot procedure; independent backups of related SQLite files taken at different moments are insufficient. Keep an immutable source copy and exact per-owner manifest of schemas, canonical bytes/hashes, IDs, timestamps, policy/receipt fences, journal totals and balances. Imports run only into disposable isolated PostgreSQL databases. No application dual writes and no production credentials, network destinations or provider/model probes.
Use the same deterministic scenario/evidence sequence and fixed machine limits for SQLite and PostgreSQL. Preserve four simultaneous workloads: 15-minute collection/publication batches; LTF/HTF and unchanged Small-Cap evaluation; independently requested DD jobs with simulated provider/model waits; and bounded dashboard readers. Include due benchmark/position-protection/outbox work during a long funnel, restart and large historical backlogs. Run one representative data size and one bounded larger synthetic history, with 1/2/4/8 workers. Cap each measured case at 15 minutes, repeat three times, and stop on accounting/identity mismatch or resource limits. This bounds experiments; it is not a throughput target.
Report database execution/commit/lock time, pool acquisition delay, connection occupancy, transaction age, WAL/fsync, CPU, RSS, disk/temp growth, IOPS and p50/p95/p99 query/commit latency separately from application hashing/decoding/evaluation and injected provider/model wait. Record complete wall time as well. Report protected-work deadline misses, claim starvation, cancellation behavior and publication lag by consumer. A faster database cannot remove an external wait; no speed multiplier should be inferred from synthetic latency alone.
Test connection budgets of 16 and 32 only in the disposable evaluation, reserving administrative and protected-work capacity and bounding per-service pools/timeouts. Measure connection exhaustion, queue wait and recovery rather than increasing limits until contention disappears. PostgreSQL allocates resources based on connection limits; document the resulting footprint using its connection settings. Include shared buffers, process/cache overhead and concurrent sorts/hash operations when setting a test memory budget: work_mem can be consumed by multiple operations per query, as described in resource consumption.
Repeat representative cases with bounded synthetic RAM pressure and sequential/random disk pressure representing colocated inference's resident model and I/O footprint; do not invoke a model to generate load. Record actual pressure limits, swap/OOM behavior, free disk, WAL/checkpoint and temporary-file growth. Test on the proposed host class before choosing production allocations. Database and OS failure are shared failure domains; this architecture does not promise full resource isolation.
Inject process death/disconnect before/after reservation, claim, dispatch intent, response commit and publication, including a lost commit acknowledgment, partial provider batches, expired grants and outbox acknowledgment loss. Compare the recovered accounting/decision/event oracle with the uninterrupted run: no duplicate charge/alert, no allowance renewal, no ID/clock/policy rewrite, no blind retry of uncertain calls, and no loss of already-due protected work.
Rehearse backup and restore to another isolated instance, including restoration while the original remains fenced off. Verify the exact committed journal prefix, canonical hashes, balances and immutable receipts, then test replay/reconciliation of permitted later work. Evaluate base backup plus WAL archiving and point-in-time recovery as described in PostgreSQL backup and continuous archiving. Include archive loss, disk-full, interrupted backup/restore and crash recovery. Record measured recovery time and data-loss window; RPO/RTO and archive retention require separate approval.
Later migration decisions
A migration proposal must select the supported PostgreSQL version, host/storage placement versus inference, roles/TLS/authentication, connection/pool/resource limits, schema/indexes, backup/archive retention and recovery objectives. It must include a versioned import/verification tool, representative workload results, an independently reviewed ownership/security check and restore drill, a stopped-writer cutover with a single authoritative writer, and a rollback procedure that preserves post-cutover journals. Rolling an application back must never restore an old database over newer accounting or paper state.
No migration is approved until copied-state invariants and behavior match, resource/deadline results are acceptable, and the concrete cutover/rollback plan is reviewed. PostgreSQL evaluation does not authorize Emerging development or another pilot.
