Files
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

22 lines
4.5 KiB
Python

from pathlib import Path
import subprocess,os,json,hashlib,difflib
r=Path('/home/jakub/devel/escapistsrereintroduced');o=Path('/tmp/erri-engineer-posts-tests-0725');a=Path('/tmp/erri-engineer-posts-source-0725');c=Path('/tmp/erri-engineer-controller-source-0725');rel='addons/core/Scripts/Game/ERR/10_AI/'
hq=a/rel/'ERR_HQ.c';posts=a/rel/'ERR_EngineerMinePosts.c';controller=c/rel/'ERR_EngineerMine.c'
env=dict(os.environ,PYTHONPATH=str(r/'tests'),TMPDIR=str(o/'scratch'),ERR_HQ_SOURCE=str(hq),ERR_ENGINEER_MINE_POSTS_SOURCE=str(posts),ERR_ENGINEER_MINE_SOURCE=str(controller))
mutationPosts=o/'five-attempts.c';s=posts.read_text();assert 'used >= 4' in s;mutationPosts.write_text(s.replace('used >= 4','used >= 5',1))
mutationController=o/'ignore-pending.c';s=controller.read_text();old='return m_Removal && !m_Removal.Result && m_Mine;';assert old in s;mutationController.write_text(s.replace(old,'return false;',1))
cases=[('old-hq-red','test_engineer_mine_hq.py',{'ERR_HQ_SOURCE':str(a/'baseline'/rel/'ERR_HQ.c')},False),('quota-mutation-red','test_engineer_mine_posts.py',{'ERR_ENGINEER_MINE_POSTS_SOURCE':str(mutationPosts)},False),('pending-mutation-red','test_engineer_mine.py',{'ERR_ENGINEER_MINE_SOURCE':str(mutationController)},False),('posts-green','test_engineer_mine_posts.py',{},True),('hq-green','test_engineer_mine_hq.py',{},True),('controller-green','test_engineer_mine.py',{},True)]
results=[]
for name,test,overrides,positive in cases:
active=env|overrides
with (o/(name+'.log')).open('w') as log:res=subprocess.run(['python3',str(o/'tests'/test)],env=active,stdout=log,stderr=subprocess.STDOUT)
text=(o/(name+'.log')).read_text();assert (res.returncode==0)==positive,(name,text)
if not positive:assert 'Assertion' in text and 'failed.' in text and "Command '['g++'" not in text,(name,text)
results.append({'name':name,'exit_code':res.returncode,'compiled':True,'log_sha256':hashlib.sha256((o/(name+'.log')).read_bytes()).hexdigest()})
patch=''
for name in ['test_engineer_mine.py','test_engineer_mine_hq.py','test_engineer_mine_posts.py']:
before=r/'tests'/name;old=before.read_text() if before.exists() else '';new=(o/'tests'/name).read_text();patch+=''.join(difflib.unified_diff(old.splitlines(True),new.splitlines(True),fromfile='a/tests/'+name if before.exists() else '/dev/null',tofile='b/tests/'+name))
(o/'fix.patch').write_text(patch)
review={'status':'pass','source_hashes':{str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in [hq,posts,controller]},'tests_sha256':{str(p.relative_to(o)):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted((o/'tests').glob('*.py'))},'baseline_test_sha256':{str(p.relative_to(o/'baseline')):hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted((o/'baseline/tests').glob('*.py'))},'patch_sha256':hashlib.sha256((o/'fix.patch').read_bytes()).hexdigest(),'results':results,'coverage':['Actual ledger classes: immutable consumed post/evidence values, task/report alias refusal, strict160m separation, chronological replay refusal,4-per-force/32-total attempts, record/source/group aliases and detached once-recorded sites.','Actual HQ MaintainEngineerMines calls actual ledger. First completed job then second spatially separate delivered post succeeds. Old retained pending job blocks admission even after unit.EngineerMine pointer clears. Two-active/32-retained/256-item caps and one query/tick preserved. No-site/no-item refusals remain consumed; replacement HQUnit cannot reset original-force quota.','Entire existing actual controller harness retained and extended. Copied prior hazard positions, invalid/overcap input, strict20m corridors and60m work area, active history exclusion, second distinct original item and shared tombstone all checked. BlocksNextPost uses exact force record: active blocks, stopped pending survives destroyed nonnull item, terminal callback or exact deletion settles without late movement/arming.','Baseline actual HQ compiles then fails new-post success. Two targeted source mutations compile then fail: fifth lifetime allowance and omitted stopped pending-removal blocker.'],'limits':['C++ source-method translation with vector/native job/inventory/AI boundary doubles. No Enforce compiler, native navigation, physical two-post mining, networking or path-safety guarantee.','No target/original mutations or full suite. New test_engineer_mine_hq imports shared ledger harness definitions from adjacent test_engineer_mine_posts; main guard prevents duplicate execution.'],'all_compilers_finished':True}
(o/'review.json').write_text(json.dumps(review,indent=2)+'\n');print(json.dumps(review,indent=2))