P22 preserved finalization exact tree probe
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
"""Build only the authorized ledger, preserving complete JSON fields."""
|
||||
"""Initialize a compact ledger. Not invoked by read-only verification.
|
||||
|
||||
All historic fields are retained by raw-SHA references. This initializer
|
||||
replaces selection work; never use it to refresh pins after a source change.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -9,67 +13,21 @@ INPUT = 'docs/spec/inputs/P22-02-accepted-usage.json'
|
||||
CURRENT = 'docs/plans/original-completion-2026-10-02/checkpoints/p22-02-slot-contract-r02/all-slot-current-candidate-contracts.json'
|
||||
EVIDENCE = 'docs/plans/original-completion-2026-10-02/checkpoints/p22-02-current-contract-r01'
|
||||
|
||||
|
||||
def build():
|
||||
keys, strings, pool = [], [], []
|
||||
key_ids, string_ids, object_ids = {}, {}, {}
|
||||
def key_id(key):
|
||||
if key not in key_ids:
|
||||
key_ids[key] = len(keys)
|
||||
keys.append(key)
|
||||
return key_ids[key]
|
||||
def encode(value):
|
||||
if isinstance(value, str):
|
||||
if value not in string_ids:
|
||||
string_ids[value] = len(strings)
|
||||
strings.append(value)
|
||||
return ['s', string_ids[value]]
|
||||
if isinstance(value, (dict, list)):
|
||||
signature = json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(',', ':'))
|
||||
if signature in object_ids:
|
||||
return ['r', object_ids[signature]]
|
||||
if isinstance(value, dict):
|
||||
node = ['d']
|
||||
for key, item in value.items():
|
||||
node.extend([key_id(key), encode(item)])
|
||||
else:
|
||||
node = ['l'] + [encode(item) for item in value]
|
||||
index = len(pool)
|
||||
pool.append(node)
|
||||
object_ids[signature] = index
|
||||
return ['r', index]
|
||||
return value
|
||||
pins = {}
|
||||
for path in [ROOT / CURRENT, *sorted((ROOT / EVIDENCE).iterdir())]:
|
||||
if path.is_file():
|
||||
pins[str(path.relative_to(ROOT))] = hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
paths = [INPUT, CURRENT] + [str(p.relative_to(ROOT)) for p in sorted((ROOT / EVIDENCE).iterdir()) if p.is_file()]
|
||||
pins = {p: hashlib.sha256((ROOT / p).read_bytes()).hexdigest() for p in paths}
|
||||
current = json.loads((ROOT / CURRENT).read_text())
|
||||
ledger = {
|
||||
'accepted_input': json.loads((ROOT / INPUT).read_text()),
|
||||
'current': json.loads((ROOT / CURRENT).read_text()),
|
||||
'evidence_pins': pins,
|
||||
'original_conditions': {
|
||||
'all_exact_uses_selected_and_usable': False,
|
||||
'all_creator_and_rights_evidence_accepted': False,
|
||||
'all_naming_resolution_layout_replacement_references_accepted': False,
|
||||
'all_mandatory_unmade_and_disclosure_gaps_resolved': False,
|
||||
'applicable_display_and_hearing_evidence': False,
|
||||
'independent_opus_review': False,
|
||||
'root_static_and_meaningful_negative_validation': False,
|
||||
'integration_and_final_original_30_88_acceptance': False,
|
||||
},
|
||||
'selection_contract': {
|
||||
'selected_assets': [],
|
||||
'candidate_names': 'Exact candidate_pool path names; no rename or final assignment',
|
||||
'replacement_chain': 'Accepted historical representation -> current candidate_ref (prior applicability retained) -> selected replacement UNKNOWN',
|
||||
'format': 'candidate_pool observed_format for physical media; representation_kind and exact raw source for code. Final per-use format/layout UNKNOWN.',
|
||||
'rights': 'candidate_pool rights_provenance and complete pinned publisher/license/manifest evidence; internal recipe is origin only, not final rights or hearing acceptance',
|
||||
'quantity': 'D08/D09 UNKNOWN. 2 state groups are not images. Never infer final file/frame/variant counts from 614 identities.',
|
||||
},
|
||||
'schema': 'p22-reference-contract-v2',
|
||||
'references': pins,
|
||||
'reconstruction': 'All accepted codec fields and snapshot fields retained by raw SHA; selections inherit entire snapshot contracts by identity, including every unmade condition.',
|
||||
'selections': {c['id']: ('candidate' if c['candidate_refs'] else 'missing') for c in current['contracts']},
|
||||
'source_pins': {p: f['current_raw_sha256'] for p, f in current['candidate_pool'].items()},
|
||||
'unit_proofs': {},
|
||||
}
|
||||
files = encode(ledger)
|
||||
packet = {'keys': keys, 'strings': strings, 'pool': pool, 'files': files, 'encoding': 'd=flat key-id/value; l=list; s=string index; r=complete object/list index'}
|
||||
raw = json.dumps(packet, ensure_ascii=False, separators=(',', ':')).encode() + b'\n'
|
||||
(HERE / 'asset-contracts.json').write_bytes(raw)
|
||||
print(json.dumps({'ledger_bytes': len(raw), 'formal_tests': 'not_run'}))
|
||||
(HERE / 'asset-contracts.json').write_text(json.dumps(ledger, ensure_ascii=False, indent=2) + '\n')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
build()
|
||||
|
||||
Reference in New Issue
Block a user