367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
148 lines
11 KiB
Python
148 lines
11 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare pinned local taxi nodes with70334; no installation or runtime DB use."""
|
|
import hashlib,json,math,re,struct
|
|
from pathlib import Path
|
|
from turtle_data import DBC
|
|
|
|
def compare(source_path,native_path):
|
|
source=DBC(Path(source_path),16);raw=Path(native_path).read_bytes();rows=json.loads(raw)
|
|
native={r['ID']:r for r in rows}
|
|
if len(native)!=len(rows):raise ValueError('Duplicate native taxi IDs')
|
|
accepted=[];excluded=[]
|
|
for row in source.rows:
|
|
ident=row[0];pos=[struct.unpack('<f',struct.pack('<I',v))[0]for v in row[2:5]]
|
|
if not 1<=ident<=256 or not all(math.isfinite(v)for v in pos):raise ValueError('Source taxi identity/position bound')
|
|
target=native.get(ident);reason='missing native row'
|
|
if target:
|
|
reason='name/map/coordinates/character-bit identity differs'
|
|
if(target['Name_lang']==source.string(row[5])and target['ContinentID']==row[1]and target['CharacterBitNumber']==ident and math.dist(pos,target['Pos'])<.1):accepted.append(ident);continue
|
|
excluded.append(dict(id=ident,name=source.string(row[5]),reason=reason))
|
|
return dict(source_nodes_sha256=source.digest(),native_nodes_sha256=hashlib.sha256(raw).hexdigest(),
|
|
supported=sorted(accepted),excluded=excluded,
|
|
limits=['Local source data, not verified live Octo definitions.','IDs/map/coordinates/character bits compared; route and UI acceptance require separate tests.'])
|
|
|
|
def header(report):
|
|
ids=report['supported']
|
|
if not ids or len(ids)!=len(set(ids))or any(type(i)is not int or not 1<=i<=256 for i in ids):raise ValueError('Bounded nonempty supported taxi IDs required')
|
|
mask=[0]*32
|
|
for ident in ids:mask[(ident-1)//8]|=1<<((ident-1)%8)
|
|
return '// Generated by ops/taxi_profile.py; reviewed Source/native node definitions.\n#pragma once\n#include <array>\n#include <cstdint>\nnamespace gateway::taxi_profile {\ninline constexpr std::array<uint8_t,32> SupportedMask={'+','.join(map(str,mask))+'};\n}\n'
|
|
|
|
def reuse_saved_routes(assessment, profile, resolved, held, paths_header, nodes_header, *, current_freshness=None, current_added=None):
|
|
"""Reuse the owning static taxi relationship join without reading Source DBCs.
|
|
|
|
The existing header provides candidate Source routes; the mask restricts them
|
|
to previously proven native node identities. This is not native TaxiPath,
|
|
map projection, live-Octo route or flight acceptance.
|
|
"""
|
|
def require(ok, reason):
|
|
if not ok:raise ValueError(reason)
|
|
require(isinstance(assessment,dict) and assessment.get('status')=='OFFLINE_TAXI_RELATIONSHIP_CLOSURE_PASS_NO_SUPPORTED_NEW_PUBLICATION',
|
|
'saved original taxi relationship assessment required')
|
|
summary=assessment.get('summary',{})
|
|
require(summary.get('existing_static_node_matches')==61 and summary.get('generated_nonempty_route_rows')==359 and
|
|
summary.get('route_status_counts')=={'HELD_ENDPOINT_NATIVE_PROJECTION':107,'RESOLVED_SAME_CONTINENT_STATIC_ENDPOINT_RELATION':252} and
|
|
summary.get('additional_native_rows_staged')==0,'saved taxi relationship counts differ')
|
|
require(isinstance(profile,dict) and len(profile.get('supported',[]))==61 and
|
|
isinstance(nodes_header,str) and nodes_header==header(profile),'saved native taxi-node mask differs')
|
|
source_hash=summary.get('source_hash_receipt_reused_not_recomputed')
|
|
require(isinstance(source_hash,str) and re.fullmatch(r'[0-9a-f]{64}',source_hash) and isinstance(paths_header,str) and
|
|
paths_header.startswith('// Generated from local TaxiPath.dbc SHA256 '+source_hash+'\n'),
|
|
'saved Source taxi route header identity differs')
|
|
edges=[tuple(map(int,m)) for m in re.findall(r'\{(\d+),(\d+),(\d+)\}',paths_header)]
|
|
require(len(edges)==359,'saved Source taxi edge extent differs')
|
|
require(isinstance(resolved,dict) and resolved.get('status')=='READY_STATIC_ENDPOINT_RELATIONS_NOT_NEW_NATIVE_DEFINITIONS' and
|
|
isinstance(resolved.get('rows'),list) and len(resolved['rows'])==252 and
|
|
isinstance(held,dict) and isinstance(held.get('routes'),list) and len(held['routes'])==107,
|
|
'saved taxi route partitions differ')
|
|
supported=set(profile['supported']);seen=set();saved=[];held_rows=[]
|
|
for expected, rows, out in (('RESOLVED_SAME_CONTINENT_STATIC_ENDPOINT_RELATION',resolved['rows'],saved),
|
|
('HELD_ENDPOINT_NATIVE_PROJECTION',held['routes'],held_rows)):
|
|
for row in rows:
|
|
require(isinstance(row,dict) and row.get('status')==expected,'saved taxi route status differs')
|
|
ordinal=row.get('generated_edge_ordinal');left=row.get('source_from');right=row.get('source_to');cost=row.get('cached_source_base_cost')
|
|
require(type(ordinal)is int and 0<=ordinal<len(edges) and ordinal not in seen and
|
|
all(type(v)is int for v in (left,right,cost)) and edges[ordinal]==(left,right,cost),
|
|
'saved taxi edge ordinal or Source tuple differs')
|
|
endpoints=row.get('endpoints');require(isinstance(endpoints,list) and len(endpoints)==2,'saved taxi endpoint pair required')
|
|
if expected.startswith('RESOLVED'):
|
|
require(left in supported and right in supported and all(e.get('status')=='RESOLVED_EXISTING_STATIC_NODE_TUPLE' for e in endpoints),
|
|
'saved resolved route exceeds supported native node identities')
|
|
else:
|
|
require(any(e.get('status')!='RESOLVED_EXISTING_STATIC_NODE_TUPLE' for e in endpoints),
|
|
'held route has no unresolved endpoint')
|
|
seen.add(ordinal);out.append({'ordinal':ordinal,'source_from':left,'source_to':right,'source_cost':cost})
|
|
require(len(seen)==359,'saved taxi edge partition is incomplete')
|
|
require((current_freshness is None)==(current_added is None),'both current Source taxi receipts are required')
|
|
current = current_freshness is not None
|
|
if current:
|
|
require(isinstance(current_freshness,dict) and
|
|
current_freshness.get('kind')=='current-original-order-taxi-source-freshness-v1' and
|
|
current_freshness.get('status')=='PASS_EXACT_SOURCE_SELECTION_COMPARISON' and
|
|
isinstance(current_added,dict) and current_added.get('kind')=='current-added-taxi-paths-v1' and
|
|
current_added.get('status')=='PASS_EXACT_FOUR_ADDED_SOURCE_ROUTES',
|
|
'exact current Source taxi selection and added-route receipts required')
|
|
nodes=current_freshness.get('nodes',{});paths=current_freshness.get('paths',{})
|
|
require(nodes.get('prior_sha256')==profile['source_nodes_sha256'] and nodes.get('source_rows')==122 and
|
|
nodes.get('old_supported_count')==61 and nodes.get('current_supported_count')==61 and
|
|
nodes.get('supported_added')==[] and nodes.get('supported_removed')==[] and
|
|
paths.get('prior_sha256')==source_hash and paths.get('source_rows')==364 and paths.get('nonempty_rows')==363 and
|
|
paths.get('same_endpoint_and_cost')==359 and paths.get('changed_cost')==0 and paths.get('added_pairs')==4 and
|
|
paths.get('removed_pairs')==0 and current_added.get('source_sha256')==paths.get('current_sha256') and
|
|
current_added.get('source_archive')==paths.get('archive') and current_added.get('static_qualified')==0 and
|
|
current_added.get('held')==4 and current_added.get('prior_359_edges_changed') is False and
|
|
current_added.get('original_source_archive_order_only') is True and
|
|
current_added.get('native_taxi_path_definition_verified') is False and
|
|
current_added.get('launcher_hook_equivalence_verified') is False and
|
|
current_added.get('server_fork_or_gameplay_verified') is False,
|
|
'current Source taxi identities or saved-edge preservation differ')
|
|
additions=current_added.get('rows')
|
|
require(isinstance(additions,list) and len(additions)==4 and
|
|
{(r.get('source_from'),r.get('source_to'),r.get('source_cost')) for r in additions}==
|
|
{(14,97,500),(97,14,500),(66,97,500),(97,66,500)} and
|
|
len({r.get('source_record_id') for r in additions})==4 and
|
|
all(r.get('status')=='HELD_NATIVE_ENDPOINT_OR_CONTINENT' and
|
|
type(r.get('source_record_id')) is int and r['source_record_id']>0 and
|
|
r.get('existing_native_endpoint_identities_proved') is False and
|
|
r.get('existing_native_continent_matches') is False and
|
|
r.get('native_path_definition_verified') is False and r.get('live_octo_fare_verified') is False
|
|
for r in additions),'current Source taxi additions or native holds differ')
|
|
for r in additions:
|
|
held_rows.append({'source_record_id':r['source_record_id'],'source_from':r['source_from'],
|
|
'source_to':r['source_to'],'source_cost':r['source_cost'],
|
|
'hold':'Source node 97 lacks a qualified native endpoint'})
|
|
result={'kind':'saved-static-taxi-relationship-batch-v1','status':'REUSED_SAVED_STATIC_ASSOCIATIONS',
|
|
'source_path_table_rows':364 if current else 360,'empty_path_rows_omitted':1,'source_edges':363 if current else 359,
|
|
'native_supported_nodes':61,'resolved_static_endpoint_relations':252,'held_endpoint_relations':111 if current else 107,
|
|
'resolved':saved,'held':held_rows,'new_native_records':0,'native_taxi_path_definition_verified':False,
|
|
'flight_map_projection_verified':False,'live_octo_route_or_fare_verified':False,'native_accepted':False,'installed':False}
|
|
if current:
|
|
result.update(current_source_selection_verified_under_original_order=True,current_source_taxi_path_sha256=paths['current_sha256'],
|
|
current_source_added_held_routes=4,saved_ordinals_apply_to_existing_header_only=True,
|
|
launcher_hook_equivalence_verified=False,source_server_fork_verified=False)
|
|
return result
|
|
|
|
def path_header(path,supported_ids=None):
|
|
source=DBC(Path(path),4)
|
|
# The pinned source table contains an unused ID296/from0/to0/cost0 row.
|
|
rows=sorted(r for r in source.rows if r[1:]!=(0,0,0))
|
|
if len({r[1:3]for r in rows})!=len(rows):raise ValueError('Ambiguous directed source taxi paths')
|
|
if any(not 1<=a<=256 or not 1<=b<=256 or c>10000000 for _,a,b,c in rows):raise ValueError('Source taxi graph bounds')
|
|
if supported_ids is not None:
|
|
supported_ids=set(supported_ids)
|
|
if not supported_ids or any(type(i)is not int or not 1<=i<=256 for i in supported_ids):raise ValueError('Bounded supported taxi IDs required')
|
|
rows=[r for r in rows if r[1]in supported_ids and r[2]in supported_ids]
|
|
return '// Generated from local TaxiPath.dbc SHA256 '+source.digest()+'\n#pragma once\n#include <cstdint>\nnamespace gateway::taxi_profile {\nstruct Edge{uint32_t from,to,cost;};\ninline constexpr Edge Paths[]={'+','.join('{'+','.join(map(str,r[1:]))+'}'for r in rows)+'};\n}\n'
|
|
|
|
if __name__=='__main__':
|
|
import argparse
|
|
root=Path(__file__).resolve().parents[1];p=argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('--source',type=Path,required=True);p.add_argument('--native',type=Path,required=True)
|
|
p.add_argument('--output',type=Path,required=True);p.add_argument('--header',type=Path,required=True)
|
|
p.add_argument('--source-paths',type=Path);p.add_argument('--paths-header',type=Path);a=p.parse_args()
|
|
if bool(a.source_paths)!=bool(a.paths_header):p.error('Route generation requires both source paths and output header')
|
|
if any(not v.resolve().is_relative_to(root)for v in(a.output,a.header,*([a.paths_header]if a.paths_header else[]))):p.error('Generated outputs must remain in the gateway workspace')
|
|
if a.paths_header:a.paths_header.write_text(path_header(a.source_paths))
|
|
result=compare(a.source,a.native);a.output.write_text(json.dumps(result,indent=2)+'\n');a.header.write_text(header(result))
|
|
print('Verified taxi node identities:',len(result['supported']),'excluded:',len(result['excluded']),'no installation or gameplay verification')
|