Integrate real reviewer with measured Actions execution and live Jenkins pipeline
myfileagent-python-ci/pipeline/head This commit looks good
Final project review (live) / review (push) Failing after 1m24s

This commit is contained in:
Codex
2026-11-27 19:08:59 +00:00
parent ad69828bc5
commit 9275fcdcae
11 changed files with 277 additions and 15 deletions
@@ -0,0 +1,52 @@
test_invalid_quantity (test_pricing.PricingTests.test_invalid_quantity) ... ok
test_total (test_pricing.PricingTests.test_total) ... ok
test_cli_corrected_and_malformed_json (test_reviewer.ReviewerTests.test_cli_corrected_and_malformed_json) ... ok
test_cli_rejected_and_unchanged (test_reviewer.ReviewerTests.test_cli_rejected_and_unchanged) ... ok
test_cli_usage_is_separate (test_reviewer.ReviewerTests.test_cli_usage_is_separate) ... ok
test_corrected (test_reviewer.ReviewerTests.test_corrected) ... ok
test_error (test_reviewer.ReviewerTests.test_error) ... ok
test_invalid_counts (test_reviewer.ReviewerTests.test_invalid_counts) ... ok
test_invalid_sha (test_reviewer.ReviewerTests.test_invalid_sha) ... ok
test_missing_candidate (test_reviewer.ReviewerTests.test_missing_candidate) ... ok
test_missing_counts (test_reviewer.ReviewerTests.test_missing_counts) ... ok
test_no_newline (test_reviewer.ReviewerTests.test_no_newline) ... ok
test_rejected_invalid_syntax (test_reviewer.ReviewerTests.test_rejected_invalid_syntax) ... ok
test_rejected_unrelated_edit (test_reviewer.ReviewerTests.test_rejected_unrelated_edit) ... ok
test_runtime_failure (test_reviewer.ReviewerTests.test_runtime_failure) ... ok
test_subprocess_timeout (test_reviewer.ReviewerTests.test_subprocess_timeout) ... ok
test_timeout (test_reviewer.ReviewerTests.test_timeout) ... ok
test_unchanged_skips_backend (test_reviewer.ReviewerTests.test_unchanged_skips_backend) ... ok
test_unrelated_syntax_error (test_reviewer.ReviewerTests.test_unrelated_syntax_error) ... ok
----------------------------------------------------------------------
Ran 19 tests in 2.187s
OK
test_concurrent_reservation (test_pipeline.PipelineTests.test_concurrent_reservation) ... ok
test_duplicate_and_symlink (test_pipeline.PipelineTests.test_duplicate_and_symlink) ... /usr/lib/python3.11/zipfile.py:1569: UserWarning: Duplicate name: 'reviewed.py'
return self._open_to_write(zinfo, force_zip64=force_zip64)
ok
test_fixture_cli_and_source_integrity (test_pipeline.PipelineTests.test_fixture_cli_and_source_integrity) ... ok
test_fixture_unchanged (test_pipeline.PipelineTests.test_fixture_unchanged) ... ok
test_fresh_output_required (test_pipeline.PipelineTests.test_fresh_output_required) ... ok
test_good_bundle_and_smoke (test_pipeline.PipelineTests.test_good_bundle_and_smoke) ... ok
test_measured_live_metric_fields (test_pipeline.PipelineTests.test_measured_live_metric_fields) ... ok
test_metrics_reject_fixture (test_pipeline.PipelineTests.test_metrics_reject_fixture) ... ok
test_missing_live_counts_are_unknown (test_pipeline.PipelineTests.test_missing_live_counts_are_unknown) ... ok
test_rejected_not_bundled (test_pipeline.PipelineTests.test_rejected_not_bundled) ... ok
test_runtime_failure_reaches_smoke (test_pipeline.PipelineTests.test_runtime_failure_reaches_smoke) ... ok
test_tampered_transfer (test_pipeline.PipelineTests.test_tampered_transfer) ... ok
test_unexpected_paths (test_pipeline.PipelineTests.test_unexpected_paths) ... ok
test_version_retry_and_mode (test_pipeline.PipelineTests.test_version_retry_and_mode) ... ok
test_wrong_identity (test_pipeline.PipelineTests.test_wrong_identity) ... ok
test_existing_version_refuses_changed_review (test_release.ReleaseTests.test_existing_version_refuses_changed_review) ... ok
test_publish_and_retry_preserve_bytes (test_release.ReleaseTests.test_publish_and_retry_preserve_bytes) ... Reusing immutable release and its original build identity
ok
test_report_mismatch_prevents_release (test_release.ReleaseTests.test_report_mismatch_prevents_release) ... ok
test_runtime_failure_prevents_release (test_release.ReleaseTests.test_runtime_failure_prevents_release) ... ok
test_failed_compile_removes_stale_publish_targets (test_tex_failure.CompilerFailureTests.test_failed_compile_removes_stale_publish_targets) ... ok
----------------------------------------------------------------------
Ran 20 tests in 2.886s
OK
+16 -1
View File
@@ -217,7 +217,10 @@ def test_review(verified, receipt):
# Adopt Member 1's smoke entry point when integrated; retain the independent assertion.
member1 = ROOT / 'tests/smoke_demo.py'
if member1.exists():
subprocess.run([sys.executable, str(member1), str(root/'reviewed.py')], check=True, timeout=20)
try:
subprocess.run([sys.executable, str(member1), str(root/'reviewed.py')], check=True, timeout=20)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as exc:
raise ValueError('Member 1 smoke test failed') from exc
smoke(root / 'reviewed.py')
write_json(receipt, {'reviewed_sha256': digest((root/'reviewed.py').read_bytes()), 'result': 'passed'})
@@ -295,6 +298,18 @@ def metrics(review, output, completed_at):
rows += [f'review_{key}_available{{mode="live"}} {int(known)}']
if known:
rows += [f'review_{key}{{mode="live"}} {value}']
if completed_at is None and data.get('finished_at'):
from datetime import datetime
completed_at = int(datetime.fromisoformat(data['finished_at'].replace('Z', '+00:00')).timestamp())
elapsed = data.get('elapsed_seconds')
if type(elapsed) in (int, float) and 0 <= elapsed < float('inf'):
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')]:
value = resource.get(field)
if type(value) is int and value > 0:
rows += [f'{metric}{{mode="live"}} {value}']
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}']
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow-definition plugin="workflow-job">
<description>SSW590 integrated real-model pipeline. Exact Actions bundle and measured review evidence. Separate from the protected-main Python check.</description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition><name>SOURCE_SHA</name><description>Full SHA matching the selected Actions run and current Member 2 branch HEAD</description><defaultValue></defaultValue><trim>true</trim></hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition><name>ACTIONS_RUN_ID</name><description>Successful exact Actions run ID</description><defaultValue></defaultValue><trim>true</trim></hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition><name>ACTIONS_ATTEMPT</name><defaultValue>1</defaultValue><trim>true</trim></hudson.model.StringParameterDefinition>
<hudson.model.ChoiceParameterDefinition><name>MODE</name><choices class="java.util.Arrays$ArrayList"><a class="string-array"><string>live</string><string>fixture</string></a></choices></hudson.model.ChoiceParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps">
<scm class="hudson.plugins.git.GitSCM" plugin="git">
<configVersion>2</configVersion>
<userRemoteConfigs><hudson.plugins.git.UserRemoteConfig><url>https://myfileagent.tech/myfileagent/myfileagent-pipeline.git</url></hudson.plugins.git.UserRemoteConfig></userRemoteConfigs>
<branches><hudson.plugins.git.BranchSpec><name>*/feature/final-ci-demo</name></hudson.plugins.git.BranchSpec></branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="empty-list"/>
<extensions/>
</scm>
<scriptPath>Jenkinsfile.final-project</scriptPath>
<lightweight>true</lightweight>
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>
+45
View File
@@ -0,0 +1,45 @@
"""Run the pinned reviewer inside the actual capped Actions job and retain measurements."""
import hashlib
import json
import os
from pathlib import Path
import shutil
import subprocess
import sys
root = Path(__file__).resolve().parents[1]
lock_bytes = (root/'reviewer/model-lock.json').read_bytes()
lock = json.loads(lock_bytes)
runtime = root/'out/runtime'
cgroup = Path('/sys/fs/cgroup')
limit = int((cgroup/'memory.max').read_text())
assert limit == 250000000, 'Actual Actions container must have the exact 250 MB limit'
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']
assert private.is_file(), 'Model must be downloaded into private tmpfs'
library = runtime/'libgomp-root'/lock['libgomp_library_path']
assert hashlib.sha256(library.read_bytes()).hexdigest() == lock['libgomp_library_sha256']
env = os.environ.copy()
env.update(REVIEWER_MODEL_PATH=str(private),
REVIEWER_LLAMA_COMPLETION=str(runtime/f"llama-{lock['runtime_tag']}"/lock['entrypoint']),
LD_LIBRARY_PATH=str(library.parent)+':'+str(runtime/f"llama-{lock['runtime_tag']}"))
result = subprocess.run([sys.executable,'-m','reviewer','--input','tests/fixtures/demo_broken.py',
'--source-commit',env['SOURCE_SHA'],'--out-dir','out/review'],cwd=root,env=env)
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='actual Actions job including runtime preparation, reviewer and private tmpfs model',
memory_limit_bytes=limit,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'
p=Path('out/review/review.json');data=json.loads(p.read_text())
assert data['mode']=='live' and data['status']=='corrected'
data['resource_measurement']=measurement
data['model_lock_sha256']=hashlib.sha256(lock_bytes).hexdigest()
data['raw_response']=(p.parent/'raw_response.txt').read_text()
data['runtime_response']=json.loads((p.parent/'runtime_response.json').read_text())
p.write_text(json.dumps(data,indent=2)+'\n')
subprocess.run([sys.executable,'tests/smoke_demo.py',str(p.parent/'reviewed.py')],check=True)
+12
View File
@@ -142,4 +142,16 @@ class PipelineTests(unittest.TestCase):
self.assertEqual((out/'reviewed.py').read_bytes(),source.read_bytes())
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})
(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_completed_timestamp_seconds{mode="live"} 1795737600',text)
if __name__=='__main__':unittest.main()
+6 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Called on the existing trusted agent. No host socket/network enters this container.
set -eu
name="ssw590-final-${BUILD_NUMBER:-local}"
name="ssw590-final-${JOB_BASE_NAME:-local}-${BUILD_NUMBER:-local}"
image='sha256:579106aaffa81dc2436a72a5dbfc51d3590f1a97646321fd38c694aae6d7cba1'
case "$1" in
start)
@@ -11,6 +11,11 @@ case "$1" in
docker cp . "$name:/work"
docker exec "$name" git config --global --add safe.directory /work
;;
metrics)
docker run --rm -i --network none --memory 64m --memory-swap 64m --cpus .2 \
--mount type=bind,src=/home/codex/ssw590-final-metrics,dst=/metrics \
--entrypoint python3 "$image" -c 'import os,sys; from pathlib import Path; p=Path("/metrics/final-project.tmp"); p.write_bytes(sys.stdin.buffer.read()); os.replace(p,"/metrics/final-project.prom")' < out/review.prom
;;
exec) shift; docker exec "$name" "$@" ;;
collect) mkdir -p out/collected; docker cp "$name:/work/out/." out/collected/ ;;
stop) docker rm -f "$name" ;;