feat: retain pending publications (#97)
This commit is contained in:
+20
-1
@@ -12,7 +12,7 @@ from typing import Optional
|
||||
|
||||
|
||||
# Schema version - increment on each migration
|
||||
SCHEMA_VERSION = 3
|
||||
SCHEMA_VERSION = 4
|
||||
|
||||
|
||||
# Packaged default placement (spec §8.3). The config may override it, but a
|
||||
@@ -221,6 +221,19 @@ def _create_schema(conn: sqlite3.Connection):
|
||||
)
|
||||
""")
|
||||
|
||||
_create_pending_publications(conn)
|
||||
|
||||
|
||||
def _create_pending_publications(conn: sqlite3.Connection) -> None:
|
||||
"""Create private staging for valid observations awaiting derivation."""
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS pending_publications (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sample_ts TEXT NOT NULL,
|
||||
payload TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
def _apply_migrations(conn: sqlite3.Connection, current_version: int):
|
||||
"""Apply forward-only migrations from current_version to SCHEMA_VERSION.
|
||||
@@ -275,6 +288,12 @@ def _apply_migrations(conn: sqlite3.Connection, current_version: int):
|
||||
""")
|
||||
current_version = 3
|
||||
|
||||
# Migration 3→4: retain acquired observations until derived evidence can
|
||||
# be published atomically (issue #97, ADR 0011).
|
||||
if current_version < 4:
|
||||
_create_pending_publications(conn)
|
||||
current_version = 4
|
||||
|
||||
|
||||
def migrate_to_latest(store_path: Path) -> int:
|
||||
"""Apply forward-only migrations to bring the store to SCHEMA_VERSION.
|
||||
|
||||
Reference in New Issue
Block a user