# Frozen no-tools implementation audit: EM-XCT-04 Enterprise Temporal History 0.1.0 Act as an independent adversarial semantic reviewer. This is a materially revised candidate after your first static audit. Scope digest now binds each commit to the immutable header; native snapshot checks require expected Dimension. Exactly unchanged prior segments can retain retired pins, so archival and metadata corrections remain possible. Rebinding the same payload in a new snapshot is explicitly a new interpretation declaration. Capacity-limited archival, current config diagnostics and immediate-only native predecessor ID checks are explicit. Acceptance truncation recomputes snapshot digest; cross-Dimension, direct imported clock regression and non-overlapping overflow cases were added. Reassess D1–D6 and new regressions against the full current files. Do not browse, call tools, run code, contact anyone or modify anything. Audit the supplied candidate, not the larger research wish list. The owner separately authorizes publication; you cannot grant it. Choose BLOCK or ACCEPT WITH LIMITS and list concrete defects with reproducing inputs and violated contract claims. Distinguish implementation bugs from explicit adoption limits. Do not claim execution, byte-hash recomputation or parent/production conformance. This candidate is a trusted-host pure single-scope assertion history with opaque external payload pins. It implements no domain engine, payload validation, conflict storage, erasure or backdated source bootstrap. Current host policies/clock/latest root and durable conflict artifacts are required integrations. Read and write gates are not IAM. Current-root metadata can change while selected historical content is stable; exact sequence is needed for same-second reproducibility. Research reconciliation: both providers recommended this bounded boundary. Slug is enterprise-temporal-history. Schema pin is mandatory here (Grok suggested optional). One fixed numeric-triplet grammar, not generic SemVer compatibility. Claude's substituted facet taxonomy was rejected in favor of the canonical five supplied below. Claude's erasure exception would break exact-prefix immutability; erasure is outside this release. Grok's rejected-write-in-successful-sequence proposal was rejected: conflicts stay in the host's separately restricted audit. No historical receipt bootstrap exists. The wrong Enterprise Identity landing URL in research returned 404; the actual identity profile is under WM-XCT-036, and no implementation depends on it. Grok's one closed-closed worked-example sentence was internally reversed; the code enforces end exclusion. Tests reported by Codex: 66 behavior tests, three fresh native Dimensions, nested-invalid and predecessor/digest/truncation rejection. Treat these as reports to assess, not your execution. Native outer validation alone is insufficient. Check stale roots, clock misuse, replay after archive/config changes, temporal boundaries, schema/value repinning, erased-vs-unknown claims, current rights before diagnostics, shape strictness, snapshot prefix preservation and any documentation/code mismatch. All file sections are complete unless explicitly marked excerpt. JSON/YAML inputs are compact-rendered with identical parsed data; original byte hashes are provenance declarations, not independently verified by you. Review the full supplied content, and explicitly report missing/truncated input. Do not use final sentinel alone as evidence that an earlier file was complete. PART 1 OF 2. This is the complete executable core and contract. In a two-message browser delivery, acknowledge receipt ONLY and wait for PART 2 before a verdict. FILE temporal.py original_sha256=43f32363df1aab5c31141314bf740eb8e7705a9b867b369f7f95c390dabcdc66 """Bounded trusted-host bitemporal snapshots; no database, IAM or domain engine.""" from pathlib import Path import copy,datetime,hashlib,json,re from jsonschema import Draft202012Validator,FormatChecker HERE=Path(__file__).resolve().parent class Invalid(ValueError):pass def require(ok,message): if not ok:raise Invalid(message) def encode(x): try:return json.dumps(x,sort_keys=True,separators=(',',':'),ensure_ascii=False,allow_nan=False).encode('utf-8') except (ValueError,TypeError,UnicodeError,RecursionError) as e:raise Invalid('Invalid JSON value') from e def digest(x):return 'sha256:'+hashlib.sha256(encode(x)).hexdigest() def load(p):return json.loads(Path(p).read_text(encoding='utf-8')) SCHEMA=load(HERE/'temporal.schema.json') def instant(t): require(type(t) is str and re.fullmatch(r'[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z',t) is not None,'Unsupported timestamp') try:datetime.datetime.strptime(t,'%Y-%m-%dT%H:%M:%SZ') except ValueError as e:raise Invalid('Invalid calendar instant') from e return t def shape(x,kind): require(len(encode(x))<=8*1024*1024,'8 MiB limit exceeded') checker=FormatChecker() require('uri' in checker.checkers and 'date-time' in checker.checkers,'Required format checker unavailable') s={'$schema':SCHEMA['$schema'],'$defs':SCHEMA['$defs'],'$ref':'#/$defs/'+kind} errors=list(Draft202012Validator(s,format_checker=checker).iter_errors(x)) require(not errors,'Closed schema violation: '+(errors[0].message if errors else '')) def walk(v): if isinstance(v,dict): for k,w in v.items(): if k in {'validFrom','validUntil','validTo','recordedAt','sourceRecordedAt'} and w is not None:instant(w) if k=='sequence':require(type(w) is int,'Sequence must have integer JSON encoding') if k in {'digest','expectedHead','scopeDigest'} and w is not None:require(re.fullmatch(r'sha256:[0-9a-f]{64}',w) is not None,'Invalid digest encoding') if k=='version':require(re.fullmatch(r'(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)',w) is not None,'Unsupported version grammar') walk(w) elif isinstance(v,list): for w in v:walk(w) walk(x) def configuration(config,now): shape(config,'config');instant(now) require(config['validFrom']=last['recordedAt'],'Receipt clock moved backwards') require(q['expectedHead']==(digest(last) if last else None),'Broken head chain') require(q['key'] not in keys and q['revision'] not in revisions,'Reused commit identity');keys.add(q['key']);revisions.add(q['revision']) require(q['sourceRecordedAt'] is None or q['sourceRecordedAt']<=c['recordedAt'],'Source record time after receipt') require(q['operation']==('record' if last is None else q['operation']) and (last is None or q['operation']!='record'),'Wrong genesis operation') if last is not None:require(last['request']['operation']!='archive','Archive is terminal') if q['operation']=='archive':require(last is not None and encode(q['segments'])==encode(last['request']['segments']),'Archive rewrites timeline') segments(q['segments']) for s in q['segments']: v=s['value'];vk=(v['id'],v['revision']);require(vk not in value_definitions or value_definitions[vk]==v['digest'],'Payload revision repointed');value_definitions[vk]=v['digest'] for b in [s['schema']]+([] if s['state'] is None else [s['state']['profile']]): k=(b['id'],b['version']);require(k not in pin_definitions or pin_definitions[k]==b['digest'],'Binding repointed across history');pin_definitions[k]=b['digest'] last=c return True def validate_extension(old,new,*,now): validate_ledger(old,now=now);validate_ledger(new,now=now) require(encode({k:v for k,v in old.items() if k!='commits'})==encode({k:v for k,v in new.items() if k!='commits'}),'Scope/header changed') require(len(new['commits'])>=len(old['commits']) and encode(new['commits'][:len(old['commits'])])==encode(old['commits']),'History rewritten/truncated') return True def admit(ledger,request,config,*,actor,now): """Pure function. Host selects trusted current config/root, actor and clock; serializes persistence.""" configuration(config,now);require(actor==config['writer'],'Write denied') validate_ledger(ledger,now=now);matching(ledger,config);shape(request,'request') # Repeat is checked before expected-head and archive guards; first receipt is retained. for c in ledger['commits']: if c['request']['key']==request['key']: require(c['writer']==actor and encode(c['request'])==encode(request),'Conflicting replay') return copy.deepcopy(ledger) require(request['expectedHead']==head(ledger),'Head conflict') require(not ledger['commits'] or ledger['commits'][-1]['request']['operation']!='archive','Archive is terminal') retained=ledger['commits'][-1]['request']['segments'] if ledger['commits'] else [] segments(request['segments'],config,retained) result=copy.deepcopy(ledger);result['commits'].append(dict(sequence=len(ledger['commits'])+1,recordedAt=now,writer=actor,scopeDigest=scope_digest(ledger),request=copy.deepcopy(request))) validate_extension(ledger,result,now=now) return result def resolve(ledger,config,*,actor,purpose,validAt,knownAt,now,knownSequence=None): configuration(config,now) require(actor in config['readers'] and purpose in config['purposes'],'Read denied') validate_ledger(ledger,now=now);matching(ledger,config);instant(validAt);instant(knownAt) require(knownAt<=now,'Future knowledge cutoff') require(knownSequence is None or type(knownSequence) is int and 0<=knownSequence<=len(ledger['commits']),'Invalid knowledge sequence') known=[c for c in ledger['commits'] if c['recordedAt']<=knownAt and (knownSequence is None or c['sequence']<=knownSequence)] c=known[-1] if known else None result={'status':'insufficient-context','missing':['No registered timeline at this knowledge cutoff'] if c is None else ['No segment covers this valid instant'],'validAt':validAt,'knownAt':knownAt,'knownSequence':knownSequence,'commit':None if c is None else {'revision':c['request']['revision'],'sequence':c['sequence'],'recordedAt':c['recordedAt'],'digest':digest(c)},'segment':None,'archivedAsKnown':False if c is None else c['request']['operation']=='archive','archiveNow':bool(ledger['commits'] and ledger['commits'][-1]['request']['operation']=='archive'),'inputDigest':digest(ledger),'policyDigest':digest(config),'truth':'not-evaluated','domainValidation':'not-executed','transitionLegality':'not-evaluated'} if c: for s in c['request']['segments']: if s['validFrom']<=validAt and (s['validTo'] is None or validAt