SAME FROZEN R3 SOURCE RECOVERY 2/9. Browser paragraph rendering adds blank separator lines; all nonempty lines and indentation are verified unchanged. These are static display fragments, not raw-byte hash verification. Do not audit yet. Reply only ACK 2/9 if all code in this fragment is visible. No tools. BEGIN action_bundle.py fragment 2/9 ritative fixture. Public methods return redacted results. The host must construct authenticated actor/time inputs and isolate admin API, exports and database access. The epoch pin detects a wrong store, not a coherent rollback. Restored stores require external continuity reconciliation before use. """ def __init__(self,path,expected_epoch): self.path=Path(path).resolve(); self.expected_epoch=expected_epoch @classmethod def create(cls,path,dimension,issuer,now): require(re.fullmatch(SCHEMA['$defs']['Intent']['properties']['dimensionId']['pattern'],dimension) is not None,'dimension-id') require(re.fullmatch(SCHEMA['$defs']['Intent']['properties']['dimensionId']['pattern'],issuer) is not None,'issuer-id') cls._time(now) path=Path(path).resolve(); path.parent.mkdir(parents=True,exist_ok=True) # Exclusive create, so accidental use never truncates a prior history. with path.open('xb'): pass epoch=_id('epoch') c=sqlite3.connect(path) try: c.executescript(SQL) c.execute('INSERT INTO meta VALUES(1,?,?,?,?,0,0)',(dimension,issuer,epoch,now)) c.execute('INSERT INTO policies VALUES(0,?,?,0)',('[]',now)); c.commit() finally: c.close() return cls(path,epoch) @staticmethod def _time(now): require(type(now) is int and 946684800<=now<=4102444800,'host-time') @contextmanager def _tx(self,now): self._time(now) c=sqlite3.connect(self.path.as_uri()+'?mode=rw',uri=True,timeout=15,isolation_level=None) c.row_factory=sqlite3.Row try: c.execute('PRAGMA synchronous=FULL'); c.execute('BEGIN IMMEDIATE') meta=dict(c.execute('SELECT * FROM meta WHERE id=1').fetchone()) require(meta['epoch']==self.expected_epoch,'store-epoch') require(now>=meta['clock'],'host-clock-regression') mseq=meta['control_sequence']+1 require(mseq<=9007199254740991,'control-sequence-overflow') c.execute('UPDATE meta SET clock=?,control_sequence=? WHERE id=1',(now,mseq)) meta['control_sequence']=mseq; meta['clock']=now yield c,meta # Check before COMMIT: an overflowing operation, including its effect, # request and clock increment, rolls back as one unit. for table in ('definitions','policies','resources','requests','events'): require(c.execute('SELECT COUNT(*) FROM '+table).fetchone()[0]<=MAX_ROWS,'store-capacity') c.execute('COMMIT') except BaseException: if c.in_transaction: c.execute('ROLLBACK') raise finally: c.close() def set_policy(self,policy,now): """TRUSTED fixture host administration: verify issuer standing/basis externally.""" validate('Policy',policy) with self._tx(now) as (c,m): rev=m['policy_revision']+1 # Reserve the final policy row for a host-wide revocation. Never # overwrite older policy evidence or silently create a new store. require(not policy or rev