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
+20 -6
View File
@@ -1,10 +1,13 @@
name: Final project review (fixture)
name: Final project review (live)
on:
push:
branches: [feature/final-ci-demo, final-project-demo]
jobs:
review:
runs-on: manual-latex
container:
image: sha256:579106aaffa81dc2436a72a5dbfc51d3590f1a97646321fd38c694aae6d7cba1
options: --memory=250000000 --memory-swap=250000000 --tmpfs /private-model:rw,size=100000000
timeout-minutes: 15
permissions:
contents: read
@@ -13,23 +16,24 @@ jobs:
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Verify source and run fixture contract tests
- name: Verify source and run combined contract tests
env:
SOURCE_SHA: ${{ github.sha }}
run: |
set -eu
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
python3 -m unittest discover -s ci/tests -v
- name: Produce explicitly simulated review bundle
python3 -m unittest discover -s tests -v
- name: Run real model under measured 250 MB cap
env:
SOURCE_SHA: ${{ github.sha }}
ACTIONS_RUN_ID: ${{ github.run_id }}
ACTIONS_ATTEMPT: ${{ github.run_attempt }}
run: |
set -eu
echo 'Mode: fixture. No live model or live token evidence.'
python3 ci/fixtures/reviewer_stub.py --input ci/fixtures/demo_broken.txt --source-commit "$SOURCE_SHA" --out-dir out/review
python3 ci/final_project.py bundle --review-dir out/review --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode fixture --output out/review-bundle.zip
python3 -m reviewer.prepare_runtime --dest out/runtime --model-dir /private-model
python3 ci/run_live_review.py
python3 ci/final_project.py bundle --review-dir out/review --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode live --output out/review-bundle.zip
- name: Publish ready bundle for this exact run and attempt
uses: https://github.com/actions/upload-artifact@c6a366c94c3e0affe28c06c8df20a878f24da3cf
with:
@@ -37,3 +41,13 @@ jobs:
path: out/review-bundle.zip
if-no-files-found: error
retention-days: 14
- name: Preserve raw model and resource evidence
if: always()
uses: https://github.com/actions/upload-artifact@c6a366c94c3e0affe28c06c8df20a878f24da3cf
with:
name: live-evidence-${{ github.run_id }}-${{ github.sha }}
path: |
out/review
out/resource.json
if-no-files-found: warn
retention-days: 30
@@ -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
+15
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():
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" ;;
+58
View File
@@ -177,6 +177,64 @@
},
"overrides": []
}
},
{
"id": 7,
"title": "Measured review duration",
"type": "timeseries",
"gridPos": {
"x": 0,
"y": 24,
"w": 12,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"expr": "review_duration_seconds{mode=\"live\"}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
}
},
{
"id": 8,
"title": "Actual Actions job memory peak and limit",
"type": "timeseries",
"gridPos": {
"x": 12,
"y": 24,
"w": 12,
"h": 8
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"expr": "review_job_memory_peak_bytes{mode=\"live\"}",
"refId": "A"
},
{
"expr": "review_job_memory_limit_bytes{mode=\"live\"}",
"refId": "B"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes"
},
"overrides": []
}
}
],
"annotations": {
+2
View File
@@ -29,6 +29,8 @@ def propose(source):
raise ValueError("model checksum mismatch")
if not executable.is_file():
raise FileNotFoundError("llama-completion executable missing")
if _sha256(executable) != lock["runtime_entrypoint_sha256"]:
raise ValueError("llama-completion checksum mismatch")
if source not in ('print("hello"', 'print("hello"\n'):
raise ValueError("real-model adapter only supports the hello fixture")
prompt = lock["prompt_template"].format(source_line=source.rstrip("\n"))
+7 -1
View File
@@ -30,5 +30,11 @@
],
"memory_target_bytes": 250000000,
"batch_tokens": 32,
"microbatch_tokens": 32
"microbatch_tokens": 32,
"runtime_entrypoint_sha256": "7119bef261611b26f326f7c4da4dc3fdeb7bb28e2faf1ec392bda7b21215ef52",
"libgomp_package": "libgomp1_14.2.0-4ubuntu2~24.04.1_amd64.deb",
"libgomp_package_sha256": "e8a95ec58125b4933597f30ff56c2ae10edf90f287262e366d4b6edea3019144",
"libgomp_url": "https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libgomp1_14.2.0-4ubuntu2~24.04.1_amd64.deb",
"libgomp_library_path": "usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0",
"libgomp_library_sha256": "135f3c8f006d2fe5e68e51281c7974cb991a03de3bfb3593d68d174dfcf854d1"
}
+29 -5
View File
@@ -1,9 +1,10 @@
"""Download and checksum the pinned public GGUF model and llama.cpp CPU archive."""
"""Prepare checksum-pinned model, llama.cpp CPU runtime, and libgomp1."""
import argparse
import hashlib
import json
from pathlib import Path
import shutil
import subprocess
import tarfile
import urllib.request
@@ -36,25 +37,48 @@ def fetch(url, target, expected):
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--dest", type=Path, required=True, help="directory outside Git for model/runtime files")
parser.add_argument("--model-dir", type=Path, help="optional private tmpfs model directory")
args = parser.parse_args()
lock = json.loads(LOCK.read_text())
args.dest.mkdir(parents=True, exist_ok=True)
model = args.dest / lock["quantized_filename"]
model_dir = args.model_dir or args.dest
model_dir.mkdir(parents=True, exist_ok=True)
model = model_dir / lock["quantized_filename"]
archive = args.dest / lock["runtime_archive"]
fetch(lock["quantized_url"], model, lock["quantized_sha256"])
fetch(lock["runtime_url"], archive, lock["runtime_archive_sha256"])
package = args.dest / lock["libgomp_package"]
fetch(lock["libgomp_url"], package, lock["libgomp_package_sha256"])
with tarfile.open(archive) as bundle:
members = bundle.getmembers()
root_name = "llama-" + lock["runtime_tag"]
if any(member.name != root_name and not member.name.startswith(root_name + "/") for member in members):
raise ValueError("unexpected runtime archive layout")
# The pinned compiler has Python 3.11 without tarfile.data_filter.
# Reject traversal, special files and escaping link targets before extraction.
from pathlib import PurePosixPath
for member in members:
for name in (member.name, member.linkname):
path = PurePosixPath(name)
if path.is_absolute() or ".." in path.parts:
raise ValueError("unsafe archive member/link")
if not (member.isfile() or member.isdir() or member.issym() or member.islnk()):
raise ValueError("special archive member")
if hasattr(tarfile, "data_filter"):
bundle.extractall(args.dest, filter="data")
else:
bundle.extractall(args.dest)
server = args.dest / f"llama-{lock['runtime_tag']}" / lock["entrypoint"]
if not server.is_file():
raise FileNotFoundError("runtime entrypoint missing from verified archive")
if not server.is_file() or digest(server) != lock["runtime_entrypoint_sha256"]:
raise ValueError("runtime entrypoint checksum mismatch")
libgomp_root = args.dest / "libgomp-root"
subprocess.run(["dpkg-deb", "--extract", str(package), str(libgomp_root)], check=True)
library = libgomp_root / lock["libgomp_library_path"]
if not library.is_file() or digest(library) != lock["libgomp_library_sha256"]:
raise ValueError("libgomp1 library checksum mismatch")
print(f"REVIEWER_MODEL_PATH={model}")
print(f"REVIEWER_LLAMA_COMPLETION={server}")
print("Install libgomp1 in the execution image and ensure its directory is on the loader path.")
print(f"LD_LIBRARY_PATH={library.parent}:{server.parent}")
if __name__ == "__main__":