audit-core/workplans/AUDIT-WP-0012-chained-sqlite-import.md
tegwick 146f4e1dd3
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
fix: repair chained imports and track blocked evidence dependencies
Assistant: codex
Assistant-Model: gpt-6.1-sol
Assistant-Session: 01a1046e-465c-7d43-8c4c-d10f0a1feadd
2026-10-04 11:36:06 +02:00

65 lines
3 KiB
Markdown

---
id: AUDIT-WP-0012
type: workplan
title: "Repair historical SQLite import into PostgreSQL custody"
domain: infotech
repo: audit-core
status: finished
owner: codex
topic_slug: audit-evidence-dependencies
created: "2026-10-04"
updated: "2026-10-04"
state_hub_workstream_id: "0d3658fe-bbe0-560c-8814-c367a93bb844"
---
# AUDIT-WP-0012 — Repair historical SQLite import into PostgreSQL custody
Repair the open residual AUDIT-IN-0004. Source completion only: coordinating deployment of link-order append/verify workers is required before any historical production import; no deployment or native import is performed by this plan.
## Preserve historical events in the existing destination chain
```task
id: AUDIT-WP-0012-T01
status: done
priority: high
state_hub_task_id: "63d39a39-cae8-5773-a451-dfd78e78eac0"
```
AUDIT-IN-0004. Import takes a SQLite snapshot and the same PostgreSQL advisory lock as native append. PostgreSQL follows stored links instead of historical accepted_at order; existing links and exact timestamps remain untouched. No trigger is disabled. New migration 0007 adds indexes and side-table import receipts without editing released migrations. Conflicting historical evidence is reported, never overwritten. CLI exposes stable --source-id across source relocation.
## Make dead-letter and finding replay idempotent
```task
id: AUDIT-WP-0012-T02
status: done
priority: high
state_hub_task_id: "f310efd2-4b8c-5ee6-902f-4ad51a5ce5ec"
```
Transactional receipts identify source/row fingerprints. Replays skip dead letters, increment findings only by newly observed source counts, and report changed historic rows or decreasing counts as conflicts. Imported evidence and its receipt commit together.
## Verify populated destinations, concurrency and complete PostgreSQL suite
```task
id: AUDIT-WP-0012-T03
status: done
priority: high
state_hub_task_id: "2ef142c6-ba31-5cea-97c7-618af2f834cb"
```
Disposable local PostgreSQL at 127.0.0.1:55446, database audit_core; no production import. Final full suite: 322 passed, zero skips and no migration exclusions. New regression coverage: pre-existing attestation survives older imports, exact acceptance-time conflict, native append after import, concurrent native/import/replay, side-table replay and incremental counts, forks/orphans, and instance count boundaries. Rollback of events/side tables/receipts and stable source identity after file relocation also pass. Optional PyYAML/jsonschema checks were enabled in the repo venv; PYTHONPATH=/home/worsch/infospace-bench/src supplies the existing local canon dependency.
## Review decision
State Hub decision `8a896602-b6c6-4ecf-af81-2504e3e123dc` records the
historical-time versus stored-link ordering rule and the owner evidence bounds.
Validation command:
```bash
PYTHONPATH=/home/worsch/infospace-bench/src \
AUDIT_CORE_TEST_DATABASE_URL=postgresql://postgres:test@127.0.0.1:55446/audit_core \
.venv/bin/python -m pytest -q -rs
```
The database and password above are disposable local test fixtures.