Simplify live dashboard and warn on memory target [skip ci]
myfileagent-python-ci/pipeline/head This commit looks good

This commit is contained in:
Codex Agent
2026-11-28 20:58:48 +00:00
parent 1bb4e0a9dd
commit d118a677e0
11 changed files with 524 additions and 231 deletions
+7
View File
@@ -13,5 +13,12 @@ counters after it verifies the successful Actions bundle, and a Prometheus scrap
then makes the increase visible. A retry does not double count. Fixture values
and missing token counts cannot masquerade as live measurements.
The two flat last-run token graphs have been removed. The memory, duration and
availability measurements are latest-run status cards. The complete workload
still has a 250,000,000-byte target, but Actions now has a 384,000,000-byte
hard ceiling with no swap. A measured target overage warns and continues if
the real model succeeds; a true OOM or model error fails safely. Prior run 43
hit its old cap, so its natural uncapped memory peak is unknown.
Source notes: handoff/member1/demo-refresh.md. Historical Member 1 work:
HANDOFF.txt. No rehearsal has been executed by this implementation update.
+8 -1
View File
@@ -320,10 +320,17 @@ def metrics(review, output, completed_at):
rows += [f'review_duration_seconds{{mode="live"}} {elapsed}']
resource = data.get('resource_measurement', {})
for field, metric in [('memory_peak_bytes', 'review_job_memory_peak_bytes'),
('memory_limit_bytes', 'review_job_memory_limit_bytes')]:
('memory_limit_bytes', 'review_job_memory_limit_bytes'),
('memory_target_bytes', 'review_job_memory_target_bytes')]:
value = resource.get(field)
if type(value) is int and value > 0:
rows += [f'{metric}{{mode="live"}} {value}']
exceeded = resource.get('memory_target_exceeded')
if type(exceeded) is bool:
peak, target = resource.get('memory_peak_bytes'), resource.get('memory_target_bytes')
if type(peak) is not int or type(target) is not int or exceeded != (peak > target):
raise ValueError('Memory target warning disagrees with measured peak')
rows += [f'review_job_memory_target_exceeded{{mode="live"}} {int(exceeded)}']
if not re.fullmatch('[0-9]+', str(completed_at)):
raise ValueError('Completion timestamp must be measured epoch seconds')
rows += [f'review_completed_timestamp_seconds{{mode="live"}} {completed_at}']
+12 -3
View File
@@ -13,7 +13,10 @@ lock = json.loads(lock_bytes)
runtime = root/'out/runtime'
cgroup = Path('/sys/fs/cgroup')
limit = int((cgroup/'memory.max').read_text())
assert 250000000 - os.sysconf('SC_PAGE_SIZE') < limit <= 250000000, 'Actual Actions container must have the page-rounded 250 MB limit'
hard_ceiling = 384000000
target = lock['memory_target_bytes']
assert target == 250000000, 'Model lock must preserve the agreed memory target'
assert hard_ceiling - os.sysconf('SC_PAGE_SIZE') < limit <= hard_ceiling, 'Actual Actions container must have the page-rounded hard ceiling'
assert (cgroup/'memory.swap.max').read_text().strip() == '0', 'Swap must be disabled'
assert not os.environ.get('REVIEWER_BACKEND_COMMAND'), 'Fixture override is forbidden'
private = Path('/private-model')/lock['quantized_filename']
@@ -29,12 +32,18 @@ result = subprocess.run([sys.executable,'-m','reviewer','--input','demo/demo.py'
peak = int((cgroup/'memory.peak').read_text())
events = {k:int(v) for k,v in (line.split() for line in (cgroup/'memory.events').read_text().splitlines())}
measurement = dict(scope='job cgroup including preparation, reviewer and private tmpfs model',
requested_memory_limit_bytes=250000000,memory_limit_bytes=limit,memory_peak_bytes=peak,memory_events=events,
requested_memory_limit_bytes=hard_ceiling,memory_limit_bytes=limit,
memory_target_bytes=target,memory_target_exceeded=peak > target,
memory_peak_bytes=peak,memory_events=events,
swap_limit_bytes=0,reviewer_exit_code=result.returncode)
Path('out').mkdir(exist_ok=True)
Path('out/resource.json').write_text(json.dumps(measurement,indent=2)+'\n')
print(json.dumps(measurement))
assert result.returncode == 0 and events['oom_kill'] == 0 and peak <= limit, 'Live acceptance gate failed'
if peak > target:
print(f'WARNING: measured Actions job memory peak {peak} bytes exceeds the {target}-byte project target; continuing under the {limit}-byte hard ceiling', file=sys.stderr)
if events.get('max', 0):
print(f'WARNING: Actions job encountered {events["max"]} hard-ceiling pressure events; check resource.json for OOM events', file=sys.stderr)
assert result.returncode == 0 and events['oom_kill'] == 0 and peak <= limit, 'Live model or hard memory ceiling failed'
p=Path('out/review/review.json');data=json.loads(p.read_text())
assert data['mode']=='live' and data['status']=='corrected'
data['resource_measurement']=measurement
+9 -2
View File
@@ -145,13 +145,20 @@ class PipelineTests(unittest.TestCase):
def test_measured_live_metric_fields(self):
data=json.loads((self.review/'review.json').read_text())
data.update(mode='live',model_id='real-model',finished_at='2026-11-27T00:00:00Z',elapsed_seconds=2.5,
resource_measurement={'memory_peak_bytes':240000000,'memory_limit_bytes':250000000})
resource_measurement={'memory_peak_bytes':260000000,'memory_limit_bytes':384000000,
'memory_target_bytes':250000000,'memory_target_exceeded':True})
(self.review/'review.json').write_text(json.dumps(data))
metrics(self.review/'review.json',self.root/'metrics.prom',None)
text=(self.root/'metrics.prom').read_text()
self.assertIn('review_duration_seconds{mode="live"} 2.5',text)
self.assertIn('review_job_memory_peak_bytes{mode="live"} 240000000',text)
self.assertIn('review_job_memory_peak_bytes{mode="live"} 260000000',text)
self.assertIn('review_job_memory_target_bytes{mode="live"} 250000000',text)
self.assertIn('review_job_memory_target_exceeded{mode="live"} 1',text)
self.assertIn('review_completed_timestamp_seconds{mode="live"} 1795737600',text)
data['resource_measurement']['memory_target_exceeded']=False
(self.review/'review.json').write_text(json.dumps(data))
with self.assertRaisesRegex(ValueError,'Memory target warning'):
metrics(self.review/'review.json',self.root/'bad-metrics.prom',None)
if __name__=='__main__':unittest.main()