883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
80 lines
4.7 KiB
Python
80 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual native-container alias family plus small independent refusal controls."""
|
|
import argparse
|
|
import copy
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import casc_tvfs as t
|
|
from casc_tvfs_test import fixture,table
|
|
|
|
|
|
def check(job):
|
|
load=lambda p:json.loads(p.read_text())
|
|
data=load(job/'actual180-TVFS-alias-rows.json')
|
|
manifest_path=Path(data['parent_framing_manifest']);parent=load(manifest_path)
|
|
raw=(manifest_path.parent/parent['tvfs']['child']['decoded_file']).read_bytes()
|
|
proof=Path(data['local_encoding_proof']).read_bytes()
|
|
result,audit=t.extend_file_aliases(raw,data['rows'],expected_md5=data['expected_child_md5'],
|
|
local_encoding_proof=proof,local_encoding_proof_sha256=data['local_encoding_proof_sha256'])
|
|
assert len(data['rows'])==180 and audit['new_paths']==180
|
|
before_h=t.layout(raw);after_h=t.layout(result)
|
|
for name in('container','vfs','specs'):assert table(raw,before_h,name)==table(result,after_h,name)
|
|
(job/'TVFS-child-with180-reused-containers.bin').write_bytes(result)
|
|
(job/'actual180-TVFS-alias-audit.json').write_text(json.dumps(audit,indent=2)+'\n')
|
|
# Refusals use the existing independently authored on-disk fixture;
|
|
# its synthetic local-span declaration is not a native availability claim.
|
|
small=fixture();h=t.layout(small);names=t.paths(small,h);source=next(iter(names))
|
|
record=t.container_record(small,t.spans(small,names[source],h)[0],h)
|
|
ek=record['encoding_key_prefix']+'10'*7
|
|
alias=dict(file_data_id=200,source_name=source,content_key=record['content_key'],
|
|
encoding_key=ek,encoded_size=record['encoded_size'],decoded_size=record['decoded_size'],
|
|
encoding_spec=record['encoding_spec'])
|
|
synthetic=dict(status='PASS_SYNTHETIC_ALIAS_REFUSAL_CONTROL',rows=[dict(
|
|
content_key=alias['content_key'],decoded_size=alias['decoded_size'],
|
|
status='REUSE_EXISTING_LOCALLY_INDEXED_ENCODING',reuse_candidate=dict(
|
|
encoding_key=ek,encoded_metadata=dict(encoded_size=alias['encoded_size'],encoding_spec=alias['encoding_spec']),
|
|
local_index=dict(locally_indexed_candidate=True,matches=[dict(span_within_segment=True)])))])
|
|
proof_bytes=json.dumps(synthetic).encode();refused=[]
|
|
def reject(label,body=small,row=alias,evidence=proof_bytes,pin=None):
|
|
try:t.extend_file_aliases(body,[row],expected_md5=hashlib.md5(body).hexdigest(),
|
|
local_encoding_proof=evidence,local_encoding_proof_sha256=pin or hashlib.sha256(evidence).hexdigest())
|
|
except ValueError as error:refused.append(dict(case=label,reason=str(error)))
|
|
else:raise AssertionError('Changed alias control accepted: '+label)
|
|
reject('proof-pin',pin='0'*64)
|
|
reject('wrong-source-CKey',row=dict(alias,content_key='bb'*16))
|
|
reject('existing-target-ID',row=dict(alias,file_data_id=100))
|
|
reject('unproved-EKey',row=dict(alias,encoding_key='ff'*16))
|
|
missing=copy.deepcopy(synthetic);missing['rows'][0]['reuse_candidate']['local_index']['matches'][0]['span_within_segment']=False
|
|
reject('unproved-local-span',evidence=json.dumps(missing).encode())
|
|
patched=bytearray(small);span=t.spans(small,names[source],h)[0]
|
|
patched[h['tables']['container']['offset']+span['cft_offset']+record['record_bytes']-1]=1
|
|
reject('patch-container',body=bytes(patched))
|
|
tables={name:table(small,h,name)for name in h['tables']}
|
|
old=tables['vfs'];tables['vfs']=b'\x02'+old[1:10]+old[11:20]+old[10:20]
|
|
mapping={name:entry['vfs_offset']for name,entry in names.items()}
|
|
for name in mapping:
|
|
if name!=source:mapping[name]=19
|
|
tables['paths'],depth=t.serialize_paths(mapping)
|
|
reject('multiple-spans',body=t._replace_tables(small,h,tables,depth))
|
|
assert len(refused)==7
|
|
report=dict(status='PASS_ACTUAL180_EXISTING_CFT_VFS_NAMESPACE_ALIAS_BOUNDARY',
|
|
actual_allocated_aliases=180,CFT_VFS_ESpec_bytes_and_relative_offsets_exact=True,
|
|
first_lookup_identity_exact=True,original_path_offsets_preserved=True,
|
|
newly_encoded_objects=0,native_Espec_whitelist_changed=False,
|
|
Source_or_native_body_reads=0,SDK_or_Game_queries=0,
|
|
synthetic_refusal_controls=refused,
|
|
candidate_child=str(job/'TVFS-child-with180-reused-containers.bin'),
|
|
candidate_child_CKey=after_h['md5'])
|
|
(job/'completed-actual180-TVFS-alias-focused-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
return report
|
|
|
|
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--job',type=Path,required=True)
|
|
args=parser.parse_args();check(args.job)
|
|
print('PASS:180 actual namespace aliases; original CFT/VFS/ESpec exact;7 new refusals.')
|