Reject lower-level monitor errors in item1 postfit wrapper; preserve original receipt
This commit is contained in:
1 parent
1f7fccbbfa
commit
365460302b
43 files changed
+76811
-47
No files matched your search
@@ -11,6 +11,7 @@ def final_reasons(reasons,receipt,result,tracker,gpu_seconds,cpu_seconds,cpu_cap
|
||||
def add(s):
|
||||
if s not in out:out.append(s)
|
||||
if not receipt or receipt['status']!='PASS':add('WORKER_NOT_PASS')
|
||||
if receipt and receipt.get('monitor_errors'):add('WORKER_MONITOR_ERRORS')
|
||||
if not result or result.get('status')!='COMPLETE' or result.get('parts')!=expected_parts:add('INCOMPLETE_FOLD')
|
||||
if not all(k in tracker.witnesses for k in ['peak_allocated_bytes','peak_reserved_bytes']):add('MISSING_PEAKS')
|
||||
if any(v>15*2**30 for v in tracker.maxima.values()):add('RECORDED_VRAM_LIMIT')
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
"""Rebind an unlaunched postfit after the same-review monitor-error correction."""
|
||||
import json,re,shutil,subprocess,time
|
||||
from pathlib import Path
|
||||
from phase2_h1_worker_v2 import checked,sha,save
|
||||
from phase2_home_freeze_io import freeze,verify
|
||||
from phase3_item1_postfit_common import config,read
|
||||
B=Path('/home/frank14f/optane/MeltMind');R=Path('/home/frank14f/MeltMind-runs/phase3-item1-postfit-2026-11-18');A=B/'artifacts/phase3-item1-postfit-monitor-fix-2026-11-18'
|
||||
def main():
|
||||
import psutil
|
||||
if any((R/n).exists() for n in ['started.json','review.json','monitor-correction.json']):raise RuntimeError('Already launched/reviewed/revised; inspect rather than overwrite')
|
||||
for p in psutil.process_iter(['cmdline']):
|
||||
if any(Path(x).name in {'phase3_item1_postfit.py','phase3_item1_postfit_worker.py'} for x in p.info['cmdline'] or []):raise RuntimeError('Postfit process present')
|
||||
checked(R/'contract.json','4229906e5d2a6e7febee84b932e2e45b817421f255127cbfb0fe66cc74d6e9aa');old=read(R/'contract.json');proof=read(A/'original-root/implementation-git-freeze.json')
|
||||
if proof['commit']!='53cca79a47caebaa1ddb8a10e201c1b050dfa258':raise ValueError('Original review identity')
|
||||
for p in (A/'original-root').iterdir():
|
||||
if p.is_file() and sha(p)!=sha(R/p.name):raise ValueError('Original root not preserved exactly')
|
||||
# Validate archived source bytes against the old immutable Git, independent of edited working paths.
|
||||
for name in ['phase3_item1_postfit_guard.py','test_phase3_item1_postfit.py']:
|
||||
data=subprocess.check_output(['git','-C',proof['local_repository'],'show',proof['commit']+':tools/'+name])
|
||||
if data!=(A/'original-source'/name).read_bytes():raise ValueError('Original source archive differs')
|
||||
train=Path(old['training_root']);tc=read(train/'contract.json');verify(train,'implementation')
|
||||
for p,h in tc['code_sha256'].items():checked(p,h)
|
||||
log=A/'synthetic-attempt1.log';text=log.read_text()
|
||||
if 'Ran 29 tests' not in text or not text.rstrip().endswith('OK'):raise ValueError('Actual29 tests required')
|
||||
codes=dict(old['code_sha256']);changed=[]
|
||||
for p,h in codes.items():
|
||||
now=sha(Path(p))
|
||||
if now!=h:changed.append(p);codes[p]=now
|
||||
expected={str(B/'tools/phase3_item1_postfit_guard.py'),str(B/'tools/test_phase3_item1_postfit.py'),str(B/'docs/phase3-item1-postfit-2026-11-18.md')}
|
||||
if set(changed)!=expected:raise ValueError('Unexpected existing code-map changes')
|
||||
me=B/'tools/revise_phase3_item1_postfit_monitor.py';codes[str(me)]=sha(me)
|
||||
c=dict(old,code_sha256=codes,engineering_revision='MeltAssist1794952096 monitor-error wrapper correction',supersedes_unreviewed_implementation=proof['commit'],same_independent_review=True)
|
||||
correction=dict(status='CORRECTED_PENDING_SAME_REVIEW_NOT_LAUNCHED',finding='1794952096.039169',old_implementation=proof['commit'],old_contract_sha256=sha(R/'contract.json'),old_binding_sha256=sha(R/'expected-review-binding.json'),changed_existing_code_files=changed,shared_supervisor_unchanged=True,training_pins_verified=len(tc['code_sha256']),actual_monitor_failure_observed=False,wrapper_error_reason='WORKER_MONITOR_ERRORS',original_receipt_retained=True,synthetic_wrapper_calls=2,new_fits=0,new_predictions=0,new_scores=0,test_target_values_read=False,unix=time.time())
|
||||
save(R/'contract.json',c);save(R/'monitor-correction.json',correction);shutil.copyfile(log,R/'synthetic-monitor-correction.log')
|
||||
save(R/'acceptance.json',dict(status='PASS',tests=29,elapsed_seconds=float(re.search(r'Ran 29 tests in ([0-9.]+)s',text).group(1)),log_sha256=sha(log),test_source_sha256=sha(B/'tools/test_phase3_item1_postfit.py'),scope='CPU synthetic; actual wrapper with synthetic supervisor receipt and mocked GPU probes; no real worker or targets',old_logs_preserved=True))
|
||||
save(R/'training-live-snapshot.json',read(train/'live-progress.json'))
|
||||
freeze(R,'implementation',[R/'contract.json',R/'comparison-contract.json',R/'acceptance.json',R/'preparation-audit.json',R/'monitor-correction.json',R/'training-live-snapshot.json',*[p for p in R.glob('synthetic*.log')],*[Path(p) for p in codes],A/'before.json',*[p for p in (A/'original-root').iterdir() if p.is_file()],*[p for p in (A/'original-source').iterdir() if p.is_file()]])
|
||||
proof=verify(R,'implementation');binding=dict(reviewed_commit=proof['commit'],contract_sha256=sha(R/'contract.json'),implementation_proof_sha256=sha(R/'implementation-git-freeze.json'),comparison_contract_sha256=c['comparison_contract_sha256'],code_sha256=codes);save(R/'expected-review-binding.json',binding)
|
||||
freeze(R,'review-binding',[R/'contract.json',R/'expected-review-binding.json',R/'implementation-git-freeze.json',R/'implementation-authorization.json']);config(R)
|
||||
result=dict(root=str(R),implementation=proof['commit'],contract_sha256=sha(R/'contract.json'),proof_sha256=sha(R/'implementation-git-freeze.json'),binding_sha256=sha(R/'expected-review-binding.json'),comparison_sha256=c['comparison_contract_sha256'],code_files=len(codes),tests=29,actual_review_pending=True,launched=False)
|
||||
save(A/'revised-identity.json',result);print(json.dumps(result))
|
||||
if __name__=='__main__':main()
|
||||
@@ -1,4 +1,4 @@
|
||||
import unittest,tempfile,ast,copy
|
||||
import unittest,tempfile,ast,copy,json
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
import numpy as np
|
||||
@@ -7,8 +7,26 @@ from phase3_item1_postfit_common import expected_checkpoint,require_budget,termi
|
||||
from phase3_item1_postfit_worker import query_indices,score
|
||||
from test_phase2_gate_outcome_postfit import SemanticReview
|
||||
from phase3_item1_postfit_data import load_evaluation_part
|
||||
from phase3_item1_postfit_guard import final_reasons
|
||||
from phase3_item1_postfit_guard import final_reasons,run_prediction
|
||||
class PostfitTests(unittest.TestCase):
|
||||
def wrapper_receipt(self,errors):
|
||||
receipt=dict(status='PASS',cpu_seconds=.01,monitor_errors=errors,last_monitor_error=dict(operation='tree_usage',message='synthetic sampling failure') if errors else None)
|
||||
original=copy.deepcopy(receipt)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
root=Path(d);job=root/'jobs/0';job.mkdir(parents=True)
|
||||
def synthetic_supervise(*args,**kwargs):
|
||||
out=job/'prediction-records';out.mkdir()
|
||||
(out/'result.json').write_text(json.dumps(dict(status='COMPLETE',parts=1,peak_allocated_bytes=1024,peak_reserved_bytes=2048)))
|
||||
return receipt
|
||||
with patch('phase3_item1_postfit_guard.supervise',side_effect=synthetic_supervise) as supervisor,patch('phase3_item1_postfit_guard.device_usage',return_value=(0,0)),patch('phase3_item1_postfit_guard.tree_usage',return_value=(0,0,1)),patch('phase3_item1_postfit_guard.time.sleep'):
|
||||
result=run_prediction(root,dict(gpu_uuid='synthetic-no-device',jobs=[dict(expected_parts=1)]),{},0,600,300)
|
||||
supervisor.assert_called_once();self.assertEqual(receipt,original);self.assertEqual(result['worker'],original)
|
||||
self.assertEqual(json.loads((job/'prediction-guard.json').read_text())['worker'],original)
|
||||
return result
|
||||
def test_wrapper_clean_PASS_accepted(self):
|
||||
r=self.wrapper_receipt(0);self.assertEqual(r['status'],'PASS');self.assertEqual(r['reasons'],[])
|
||||
def test_wrapper_PASS_with_monitor_errors_stops_retains_receipt(self):
|
||||
r=self.wrapper_receipt(1);self.assertEqual(r['status'],'STOPPED');self.assertEqual(r['reasons'],['WORKER_MONITOR_ERRORS']);self.assertEqual(r['worker']['status'],'PASS')
|
||||
def terminal_fixture(self):
|
||||
return (dict(status='TRAIN_COMPLETE_POSTFIT_PENDING',entries=[dict(id=i,status='PASS',returncode=0,gpu_seconds_charged=100) for i in range(6)],training_gpu_seconds=600,test_targets_read=False),dict(models=[dict(job=i) for i in range(6)],test_prediction_started=False,new_fits=6,new_checkpoints=6))
|
||||
def test_six_terminal_identity_and_once_ledger(self):
|
||||
|
||||
Reference in new issue
Block a user