69 lines
5.5 KiB
Python
69 lines
5.5 KiB
Python
# coding: utf-8
|
|
from pathlib import Path
|
|
import hashlib,json,shutil
|
|
R=Path('/Users/korizatou114/Projects/とりにく工房ゲーム制作部')
|
|
A=R/'artifacts/original-completion-2026-10-02'
|
|
P=A/'p23-02-native-hot-loop-candidate-r326'
|
|
C=A/'p23-02-native-input-copy-candidate-r333'
|
|
assert not C.exists() and shutil.disk_usage(A).free>=528*1048576
|
|
def pin(p):
|
|
b=p.read_bytes();return dict(path=str(p),bytes=len(b),sha256=hashlib.sha256(b).hexdigest())
|
|
C.mkdir();(C/'source').mkdir();(C/'scripts').mkdir()
|
|
for rel in ['scripts/guest_service.gd','scripts/simulation_runtime.gd','source/tree_core.hpp','source/tree_numeric_core.cpp','source/guest_candidate_batch.inc']:
|
|
(C/rel).write_bytes((P/rel).read_bytes())
|
|
p=C/'source/tree_numeric_core.cpp';s=p.read_text()
|
|
anchor=' static bool blocked(const ProjectionNames &n,Object *path, const Vector3i &cell) {'
|
|
helper=''' // Only StringName keys qualify. Conversion-sensitive and custom runtime
|
|
// cases retain the original script sorter. No owner values are retained.
|
|
static Array sorted_builtin_input_names(const ProjectionNames &n,Object *runtime,const Dictionary &inputs) {
|
|
auto original=[&]() -> Array {return runtime->call(n.k__sorted_name_keys,inputs);};
|
|
if(!builtin(n,runtime,"res://autoload/simulation_runtime.gd")) return original();
|
|
const Array keys=inputs.keys();
|
|
std::vector<std::pair<String,StringName>> rows;
|
|
rows.reserve(keys.size());
|
|
for(int64_t i=0;i<keys.size();++i) {
|
|
if(keys[i].get_type()!=Variant::STRING_NAME) return original();
|
|
const StringName name=keys[i];rows.emplace_back(String(name),name);
|
|
}
|
|
// String ordering is the same engine operator used by the script.
|
|
std::sort(rows.begin(),rows.end(),[](const auto &a,const auto &b){return a.first<b.first;});
|
|
TypedArray<StringName> result;
|
|
for(const auto &row:rows) result.push_back(row.second);
|
|
return result;
|
|
}
|
|
// Fresh writable typed output, matching the builtin append loop. Check
|
|
// the script at this original call position, after any route callbacks.
|
|
static Variant copy_builtin_guest_route(const ProjectionNames &n,Object *path,const TypedArray<Vector3i> &route) {
|
|
if(!builtin(n,path,"res://scripts/world/path_service.gd")) return path->call(n.k__copy_path,route);
|
|
TypedArray<Vector3i> copied;
|
|
for(int64_t i=0;i<route.size();++i) copied.push_back(route[i]);
|
|
return copied;
|
|
}
|
|
'''
|
|
assert s.count(anchor)==1;s=s.replace(anchor,helper+anchor)
|
|
old='const Array items = runtime->call(n.k__sorted_name_keys,inputs);'
|
|
assert s.count(old)==1;s=s.replace(old,'const Array items = sorted_builtin_input_names(n,runtime,inputs);')
|
|
old='cache[key] = path->call(n.k__copy_path, route);'
|
|
assert s.count(old)==1;s=s.replace(old,'cache[key] = copy_builtin_guest_route(n,path,route);')
|
|
p.write_text(s)
|
|
stage=A/'p23-02-native-guest-bulk-local-r315/stage'
|
|
contract=dict(plan_id='P23-02',parent=pin(P/'input.json'),whole_review=pin(A/'p23-02-native-hot-loop-whole-actual-independent-review-r330.json'),
|
|
reused_rejected_reconstruction=pin(A/'p23-02-native-reconstruction-whole-pair-actual-independent-review-r214.json'),
|
|
scope=['native builtin StringName-only inventory input key sort; fresh TypedArray and same engine String comparator','native builtin fresh route copy at original publication position; custom script dispatch retained'],
|
|
excluded=['r204 reconstruction replay','new ownership/value caches','callback suppression','budget changes','new specification values','stage clone','SDK compile','full regression before related changes stabilize'],
|
|
validation=['static independent review','authenticated SDK133 bridge compile1/link1','local Runtime150 candidate/evaluation whole-state oracle and nearest boundary/route cache ownership fixtures','input key order Unicode and conversion/custom fallbacks','original S6 and adjacent fixed646 whole state comparison','exact final regression, required OS/Windows and full independent acceptance before unit closure'],
|
|
capacity_floor_bytes=528*1048576,formal_completed_added=0,selected=False,adopted=False,unit_accepted=False)
|
|
cp=A/'p23-02-native-input-copy-work-contract-r332.json';cp.write_text(json.dumps(contract,ensure_ascii=False,indent=2)+'\n')
|
|
v=dict(plan_id='P23-02',status='uncompiled_implementation_candidate',parent=pin(P/'input.json'),contract=pin(cp),
|
|
candidate_pins={str(q.relative_to(C)):pin(q) for q in sorted(C.rglob('*')) if q.is_file()},
|
|
original_method_sources=[pin(stage/'scripts/world/path_service.gd'),pin(stage/'autoload/simulation_runtime.gd')],
|
|
selected=False,adopted=False,unit_accepted=False,performance_accepted=False,formal_completed_added=0)
|
|
(C/'input.json').write_text(json.dumps(v,ensure_ascii=False,indent=2)+'\n')
|
|
driver=(A/'p23-02-native-hot-loop-build-r327.py').read_text()
|
|
for old,new in [('p23-02-native-hot-loop-candidate-r326','p23-02-native-input-copy-candidate-r333'),('p23-02-native-hot-loop-build','p23-02-native-input-copy-build'),('p23-02-native-hot-loop-static','p23-02-native-input-copy-static'),('r327','r334'),('r326','r333')]:driver=driver.replace(old,new)
|
|
(A/'p23-02-native-input-copy-build-r334.py').write_text(driver)
|
|
v=json.loads((A/'p23-02-native-hot-loop-build-preview-r327.json').read_text())
|
|
preview=json.loads(json.dumps(v).replace('p23-02-native-hot-loop-candidate-r326','p23-02-native-input-copy-candidate-r333').replace('p23-02-native-hot-loop-build-r327','p23-02-native-input-copy-build-r334'))
|
|
(A/'p23-02-native-input-copy-build-preview-r334.json').write_text(json.dumps(preview,indent=2)+'\n')
|
|
print(json.dumps(dict(candidate=str(C),capacity=shutil.disk_usage(A).free)))
|