Prepare purpose image release with bounded custody protocol and owner reviews
Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a126e1-76f8-7643-8cf3-e93336539ade
This commit is contained in:
parent
cf79c71f0a
commit
e0359bcb6c
83 changed files with 22144 additions and 3 deletions
|
|
@ -0,0 +1,39 @@
|
|||
"""Pre-open schema/integrity/count proof; stdlib only, never constructs Store."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
|
||||
|
||||
def inspect_readonly(path):
|
||||
path = Path(path)
|
||||
if not path.is_file() or path.is_symlink():
|
||||
raise ValueError('existing nonsymlink private database required')
|
||||
with sqlite3.connect(path.resolve().as_uri() + '?mode=ro', uri=True, timeout=5) as db:
|
||||
db.execute('PRAGMA query_only=ON')
|
||||
db.execute('BEGIN')
|
||||
version = db.execute('PRAGMA user_version').fetchone()[0]
|
||||
if version != 5:
|
||||
raise ValueError('pre-open database is not schema5; refuse migration')
|
||||
if db.execute('PRAGMA integrity_check').fetchall() != [('ok',)]:
|
||||
raise ValueError('read-only integrity check refused')
|
||||
lifecycle = {name: db.execute('SELECT COUNT(*) FROM ' + table).fetchone()[0]
|
||||
for name, table in (('records', 'lifecycle_records'),
|
||||
('events', 'lifecycle_events'),
|
||||
('pending', 'lifecycle_pending'))}
|
||||
result = {'schema_version': version, 'lifecycle': lifecycle,
|
||||
'outbox': dict(db.execute('SELECT state,COUNT(*) FROM outbox GROUP BY state')),
|
||||
'submissions': dict(db.execute('SELECT state,COUNT(*) FROM submissions GROUP BY state')),
|
||||
'integrity': 'ok', 'read_only_pre_open': True, 'store_constructed': False}
|
||||
db.rollback()
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--db', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
print(json.dumps(inspect_readonly(args.db), sort_keys=True))
|
||||
except Exception:
|
||||
raise SystemExit('read-only schema5/integrity/count gate refused; no Store/admin open') from None
|
||||
Loading…
Add table
Add a link
Reference in a new issue