Review syntax after model without typo whitelist
This commit is contained in:
@@ -18,15 +18,13 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
persist-credentials: false
|
||||
- name: Verify source and run reviewer and pipeline contract tests
|
||||
- name: Verify exact source commit
|
||||
env:
|
||||
SOURCE_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
set -eu
|
||||
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
|
||||
python3 -m unittest discover -s ci/tests -v
|
||||
python3 -m unittest discover -s tests -p 'test_reviewer.py' -v
|
||||
- name: Run real model, show accepted repair and measure memory
|
||||
- name: Run real model, test reviewed program, and measure memory
|
||||
env:
|
||||
SOURCE_SHA: ${{ github.sha }}
|
||||
ACTIONS_RUN_ID: ${{ github.run_id }}
|
||||
|
||||
+14
@@ -2,6 +2,20 @@
|
||||
|
||||
Updated 28 November 2026. This is the current documentation-preparation record for the Gitea Actions → real SmolLM2 review → Jenkins → LaTeX/tests → versioned ZIP demo. A broken-input commit exists, but this handoff does not assert that its complete Actions → Jenkins rehearsal has succeeded. The older `secure-delivery/HANDOFF.md` is for Assignment 8 and is unrelated to this demo. The original Member 1 record is `HANDOFF.txt`; the earlier deployed integration record is `ci/HANDOFF.txt`.
|
||||
|
||||
## Run 49 failure and revised live review contract (28 November 2026)
|
||||
|
||||
- Commit `1d20412bd6435acae9182c23b13919affa10bcb4` changed `demo/demo.py` from `print("hello"` to `print("hello`, removing the closing quote as well as the already-missing parenthesis. Gitea Actions run **49**, attempt **1**, reported reviewer exit **3**. Its job cgroup peaked at **210,649,088 bytes** under the **384,000,000-byte** hard ceiling, with **zero OOM kills**. Code inspection shows the old adapter's input-string whitelist rejected this source before invoking the model; the generic assertion hid that diagnostic. The run created no ready bundle, Jenkins release or new Grafana token event.
|
||||
- At the user's direction, the reviewer no longer enumerates permitted typo strings. A valid Python source still bypasses inference. An invalid, bounded one-line source goes to the pinned real model. Before executing the proposal, the reviewer requires a Python AST containing only the demo's `print("hello")` behavior and the same final-newline policy. It rejects extra code or different behavior. Actions now performs only exact-SHA verification before inference; `ci/run_live_review.py` executes the reviewed program **after** inference and requires the hello smoke test to pass before bundling. It prints the reviewer diagnostic on operational errors. Jenkins retains its post-inference unit and compile/execute stages.
|
||||
- The reviewer unit suite no longer lists potential broken strings. Its four contract tests read the current committed demo input, check safe output, reject extra model code, check operational diagnostics, and confirm valid-input bypass. The pipeline fixture stub no longer enumerates broken strings. The current `demo/README.md` and short PDF text describe the repair generically; the PDF verifies the actual committed source, reviewed program and exact diff rather than requiring a one-character edit.
|
||||
- One **local** pinned SmolLM2 inference on the current two-character input returned raw stdout ` print("hello")` followed by newlines, **22 measured input / 5 output tokens**, status `corrected`; the resulting `reviewed.py` executed with exact stdout `hello`. The revised reviewer tests passed **4/4**. Local pipeline tests passed **19/19**, with five TeX-image-only tests skipped on the host. A focused PDF build in the pinned TeX image produced **one page** from that real local response. Its synthetic run **999999** and version **9.9.9** identify an offline preview, **not a release**. Evidence is under `handoff/member1/evidence/two-character-local/`; the preview is `../outputs/demo-refresh-checks/two-character-preview-not-a-release.pdf`. This local run did **not** measure a complete Actions job cgroup peak; run 49's 210 MB peak occurred before inference and is not a successful-model memory result.
|
||||
- This repair is based directly on failed commit `1d20412…` in a separate worktree. It needs a new pushed SHA, a new successful Actions run, and a Jenkins build bound to that new SHA/run/attempt. The already deployed Grafana presentation source from local commit `66b544cb1fa9bf2c839441de4275716202d1ef1d` is included in this tip, so the new remote dashboard JSON will match Grafana's provisioned copy.
|
||||
|
||||
## Live Grafana display now included in source
|
||||
|
||||
- After the successful Jenkins repair, the live metrics textfile recorded **23 input / 5 output tokens**, **4.492204 seconds** review duration, **286,928,896 bytes** complete-job memory peak, a **384,000,000-byte** enforced ceiling, and release label **1.0.7**. The peak used **74.72%** of the ceiling. The original **250,000,000-byte** model-selection goal is a soft warning and remains visible in panel descriptions and raw metric `review_job_memory_target_exceeded{mode="live"} 1`.
|
||||
- The final-project Grafana dashboard colors measured peak green below **320,000,000 bytes**, yellow from there, and red near the ceiling from **360,000,000**. The **Memory capacity used** card shows peak/ceiling: green below **85%**, yellow from **85%**, red from **95%**. The hard-ceiling card is green. The static token-count availability card was removed; its raw availability metrics remain in Prometheus. This changes presentation, not measurements or enforced limits.
|
||||
- The source dashboard JSON was copied to the live provisioned file, and a read-only Grafana resource-store snapshot confirmed the new memory panel, thresholds and removal of the static availability panel. The copy in this worktree has the same SHA-256 as the live provisioned JSON. Run 49 failed before new token metrics could be published, so the live textfile's last successful values remain from the earlier successful run.
|
||||
|
||||
## Latest live attempt and Jenkins repair (28 November 2026)
|
||||
|
||||
- The user pushed `32a3c6f3f055c8a840f5bde9784137bfa39c8493` to `feature/final-ci-demo`. Gitea Actions run 47, attempt 1 produced a bundle that Jenkins `final-project-live` build #5 retrieved and verified against that SHA. Jenkins reserved version **1.0.6**. Thus earlier statements below that this tip was unpushed or that no refresh version had been reserved are superseded.
|
||||
|
||||
@@ -41,11 +41,7 @@ def main():
|
||||
candidate, status = source, 'unchanged'
|
||||
data.update(input_tokens=None, output_tokens=None)
|
||||
except SyntaxError:
|
||||
if source not in ['print("hello"', 'print("hello"\n']:
|
||||
data.update(status='rejected', summary='Unsupported fixture')
|
||||
(out / 'review.json').write_text(json.dumps(data, indent=2)+'\n')
|
||||
return 2
|
||||
candidate = source.rstrip('\n') + ')' + ('\n' if source.endswith('\n') else '')
|
||||
candidate = 'print("hello")' + ('\n' if source.endswith('\n') else '')
|
||||
status = 'corrected'
|
||||
data.update(status=status, summary=f'SIMULATED {a.case} fixture; not live AI evidence',
|
||||
diff=''.join(difflib.unified_diff(source.splitlines(True), candidate.splitlines(True),
|
||||
|
||||
@@ -43,7 +43,13 @@ 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'
|
||||
if result.returncode:
|
||||
review_path = Path('out/review/review.json')
|
||||
if review_path.is_file():
|
||||
failed_review = json.loads(review_path.read_text())
|
||||
print(f'Reviewer exit {result.returncode}: {failed_review.get("diagnostic") or failed_review.get("summary")}', file=sys.stderr)
|
||||
raise SystemExit(f'Live reviewer failed with exit {result.returncode}')
|
||||
assert events['oom_kill'] == 0 and peak <= limit, '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
|
||||
@@ -55,6 +61,6 @@ subprocess.run([sys.executable,'tests/smoke_demo.py',str(p.parent/'reviewed.py')
|
||||
print(f'LIVE REVIEW ACCEPTED for source commit {data["source_commit"]}', flush=True)
|
||||
print(f'Model: {data["model_id"]}; input tokens: {data["input_tokens"]}; output tokens: {data["output_tokens"]}', flush=True)
|
||||
print(f'Raw model response: {data["raw_response"]!r}', flush=True)
|
||||
print('Accepted one-character source diff:', flush=True)
|
||||
print('Accepted source diff:', flush=True)
|
||||
print(data['diff'], end='' if data['diff'].endswith('\n') else '\n', flush=True)
|
||||
print('Reviewed Python execution: PASS (stdout: hello)', flush=True)
|
||||
|
||||
@@ -122,7 +122,7 @@ class PipelineTests(unittest.TestCase):
|
||||
self.assertIn('review_output_tokens{mode="live"} 7',text)
|
||||
|
||||
def test_fixture_cli_and_source_integrity(self):
|
||||
source=self.root/'source.py';source.write_text('print("hello"\n')
|
||||
source=self.root/'source.py';source.write_text((Path(__file__).resolve().parents[2]/'demo/demo.py').read_text())
|
||||
before=source.read_bytes()
|
||||
for case,exit_code in [('good',0),('rejected',2),('error',3),('runtime',0)]:
|
||||
out=self.root/case
|
||||
|
||||
+14
-10
@@ -1,18 +1,22 @@
|
||||
# Controlled syntax-review demo
|
||||
|
||||
The current live-demo input in `demo.py` is `print("hello"` with its final
|
||||
closing parenthesis missing. The preceding preparation commit contained the
|
||||
valid baseline `print("hello")`; the one-character edit is already committed.
|
||||
The current live-demo input in `demo.py` is `print("hello` with its closing
|
||||
quote and parenthesis missing. The preceding successful run used a source
|
||||
with only its closing parenthesis missing. Both forms require model inference.
|
||||
|
||||
To repeat the live demonstration later, restore the valid baseline in a
|
||||
separate preparation commit, then delete only its final closing parenthesis
|
||||
in a new live commit. The Actions reviewer sends exactly `print("hello"` to the
|
||||
SmolLM2 model. It preserves the committed input and writes the validated repair
|
||||
to `reviewed.py` in the review bundle. Jenkins verifies that bundle, builds the
|
||||
short versioned demo PDF, tests the reviewed program, and packages the release.
|
||||
separate preparation commit, then introduce a small syntax error in a new live
|
||||
commit. The Actions reviewer sends the committed source line to SmolLM2 without
|
||||
matching it against a list of expected typos. It preserves the original and
|
||||
writes the model's validated proposal to `reviewed.py` in the review bundle.
|
||||
Before executing model output, the validator checks that it contains only the
|
||||
demo's `print("hello")` behavior. Jenkins verifies the bundle, builds the short
|
||||
versioned demo PDF, tests the reviewed program, and packages the release.
|
||||
|
||||
The final-project workflow runs the reviewer and pipeline unit tests. Jenkins
|
||||
then has a separate `Compile and execute model-reviewed Python` stage: it
|
||||
Gitea Actions checks the source SHA, runs the real model, then executes the
|
||||
reviewed program and requires exactly `hello` on standard output. Jenkins
|
||||
runs reviewer and pipeline unit tests after that inference, then has a separate
|
||||
`Compile and execute model-reviewed Python` stage: it
|
||||
compiles the verified `reviewed.py`, runs it, and requires exactly `hello` on
|
||||
standard output. The original broken `demo.py` is intentionally not executed.
|
||||
Legacy `pricing.py` tests belong to the older application and are not part of
|
||||
|
||||
+15
-4
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build a short versioned LaTeX PDF from an exact verified review bundle."""
|
||||
import argparse
|
||||
import ast
|
||||
import difflib
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
@@ -47,9 +49,18 @@ def main():
|
||||
review = json.loads(files["review.json"])
|
||||
source_path = ROOT / ("demo/demo.py" if args.mode == "live" else "ci/fixtures/demo_broken.txt")
|
||||
source = source_path.read_bytes()
|
||||
if source != b'print("hello"\n' or files["reviewed.py"] != b'print("hello")\n':
|
||||
raise ValueError("Demo PDF requires the exact one-character syntax repair")
|
||||
if review["status"] != "corrected" or "+print(\"hello\")" not in review["diff"]:
|
||||
try:
|
||||
ast.parse(source.decode())
|
||||
except SyntaxError:
|
||||
pass
|
||||
else:
|
||||
raise ValueError("Demo PDF requires a syntax-invalid committed source")
|
||||
if ast.dump(ast.parse(files["reviewed.py"].decode()), include_attributes=False) != ast.dump(
|
||||
ast.parse('print("hello")'), include_attributes=False):
|
||||
raise ValueError("Demo PDF requires a reviewed hello program without extra code")
|
||||
actual_diff = "".join(difflib.unified_diff(source.decode().splitlines(keepends=True),
|
||||
files["reviewed.py"].decode().splitlines(keepends=True), fromfile="original.py", tofile="reviewed.py"))
|
||||
if review["status"] != "corrected" or review["diff"] != actual_diff:
|
||||
raise ValueError("Review does not show the permitted correction")
|
||||
if review.get("input_sha256") and review["input_sha256"] != digest(source):
|
||||
raise ValueError("Review input hash differs from committed demo source")
|
||||
@@ -99,7 +110,7 @@ def main():
|
||||
if not 1 <= len(reader.pages) <= 3:
|
||||
raise ValueError("Demo PDF must be one to three pages")
|
||||
extracted = "\n".join(page.extract_text() or "" for page in reader.pages)
|
||||
for value in (args.release_version, args.sha, review["model_id"], "print(\"hello\")"):
|
||||
for value in (args.release_version, args.sha, review["model_id"], files["reviewed.py"].decode().strip()):
|
||||
if str(value) not in extracted:
|
||||
raise ValueError("Demo PDF omitted visible evidence: " + str(value))
|
||||
shutil.copy2(pdf, output / "main.pdf")
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
\textbf{Complete Actions-job memory:} \MemoryPeak\ bytes peak; target: \MemoryTarget\ bytes (\MemoryTargetStatus); hard ceiling: \MemoryLimit\ bytes; OOM kills: \OOMKills.
|
||||
|
||||
\section*{The committed input}
|
||||
The source at the commit above has one missing closing parenthesis. The reviewer preserves it and writes a separate reviewed file.
|
||||
The source at the commit above has a syntax error in its closing quote and/or parenthesis. The reviewer preserves it and writes a separate reviewed file.
|
||||
\VerbatimInput[fontsize=\small,frame=single]{source-before.txt}
|
||||
|
||||
\section*{The model's recorded proposal}
|
||||
These bytes came from the real model response in \texttt{review.json}. In fixture mode, this section is clearly labeled simulated. The validator accepts only the single permitted repair.
|
||||
These bytes came from the real model response in \texttt{review.json}. In fixture mode, this section is clearly labeled simulated. The validator accepts only the exact permitted hello repair.
|
||||
\VerbatimInput[fontsize=\small,frame=single]{raw-response.txt}
|
||||
|
||||
\section*{The accepted reviewed program}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Demo refresh implementation and evidence
|
||||
|
||||
**28 November correction:** The current demo input is `print("hello` (closing quote and parenthesis missing). The revised reviewer does not list allowed typo strings; it runs the real model for syntax-invalid one-line input, statically checks that output contains only the hello demo behavior, then executes the reviewed file. Actions performs only SHA verification before inference. The one-character preparation instructions and old test counts below describe the earlier run and must not be used as current rehearsal instructions. Current evidence and limits are in `../../HANDOFF.md` and `evidence/two-character-local/README.txt`.
|
||||
|
||||
This change prepares the existing Actions -> Jenkins -> PDF/tests -> versioned ZIP pipeline for the live missing-parenthesis demonstration. It does not execute that rehearsal or draft the final course report.
|
||||
|
||||
## What the job builds
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
Local real-model feasibility evidence for the two-character syntax repair
|
||||
Date: 2026-11-28 UTC
|
||||
Source bytes: print("hello followed by a newline (closing quote and parenthesis missing)
|
||||
Source commit containing those bytes: 1d20412bd6435acae9182c23b13919affa10bcb4
|
||||
Reviewer code: modified local worktree based on that commit; this is not Gitea run 49.
|
||||
|
||||
Pinned model: HuggingFaceTB/SmolLM2-135M-Instruct
|
||||
Quantized model: SmolLM2-135M-Instruct.Q4_0.gguf
|
||||
Quantized SHA-256: f68203bfb98b1b1e8c64fac75fab10c4e36acac081609573b4df0fcc19c90dd9
|
||||
Runtime: llama.cpp b12785 / llama-completion, pinned in reviewer/model-lock.json
|
||||
The real adapter checked the model and executable hashes before inference.
|
||||
|
||||
Real local reviewer output:
|
||||
status: corrected
|
||||
input_tokens: 22
|
||||
output_tokens: 5
|
||||
raw stdout repr: ' print("hello")\n\n\n'
|
||||
accepted reviewed file: print("hello") followed by a newline
|
||||
tests/smoke_demo.py executed reviewed.py: exit 0, exact stdout hello\n
|
||||
original committed source: untouched
|
||||
The complete review.json, raw_response.txt, runtime_response.json and
|
||||
reviewed.py are saved beside this file. They are local evidence, not a ready
|
||||
Actions bundle or released ZIP. No complete cgroup memory measurement was made
|
||||
for this local inference.
|
||||
|
||||
Post-inference local checks:
|
||||
reviewer contract tests: 4 passed
|
||||
pipeline tests: 19 passed, 5 host skips for pinned TeX-image dependencies
|
||||
focused short-PDF build in pinned TeX image: 1 page
|
||||
offline preview PDF SHA-256: 36c3d2eb86465ebd13b6f6283cd9eaac803d5f7a0b6b89d6af666db68bdb90d9
|
||||
offline preview path: ../outputs/demo-refresh-checks/two-character-preview-not-a-release.pdf
|
||||
synthetic PDF identity: run 999999, version 9.9.9, Jenkins label offline-check
|
||||
These synthetic identifiers are for validating the PDF path only; no release
|
||||
was reserved, issued or published.
|
||||
|
||||
Gitea run 49 failure context:
|
||||
Source commit: 1d20412bd6435acae9182c23b13919affa10bcb4
|
||||
Reviewer exit: 3
|
||||
Job memory peak: 210,649,088 bytes / 384,000,000-byte ceiling
|
||||
OOM kills: 0
|
||||
Old input-string guard prevented inference. Its memory peak is not a
|
||||
successful inference memory result. The next pushed code commit requires a
|
||||
new Actions run and matching Jenkins SOURCE_SHA.
|
||||
@@ -0,0 +1,3 @@
|
||||
print("hello")
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"source_commit": "1d20412bd6435acae9182c23b13919affa10bcb4",
|
||||
"model_id": "HuggingFaceTB/SmolLM2-135M-Instruct",
|
||||
"status": "corrected",
|
||||
"summary": "Model proposed runnable hello program",
|
||||
"diff": "--- original.py\n+++ reviewed.py\n@@ -1 +1 @@\n-print(\"hello\n+print(\"hello\")\n",
|
||||
"input_tokens": 22,
|
||||
"output_tokens": 5,
|
||||
"schema_version": 1,
|
||||
"mode": "live",
|
||||
"started_at": "2026-11-28T22:19:58.010821Z",
|
||||
"finished_at": "2026-11-28T22:20:00.481811Z",
|
||||
"elapsed_seconds": 2.471008,
|
||||
"input_sha256": "c0d5724fe3e83134697d04f1cd9bb510dbd323df79aa5a7af56ce56ab05618d3",
|
||||
"model_revision": "12fd25f77366fa6b3b4b768ec3050bf629380bac",
|
||||
"raw_response_file": "raw_response.txt",
|
||||
"runtime_response_file": "runtime_response.json"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
print("hello")
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"prompt": "Input: print(\"hi\"\nOutput: print(\"hi\")\nInput: print(\"hello\nOutput:",
|
||||
"raw_stdout": " print(\"hello\")\n\n\n",
|
||||
"prompt_eval_tokens": 22,
|
||||
"sampler_total_tokens": 27,
|
||||
"output_tokens_method": "sampler_total_tokens - prompt_eval_tokens",
|
||||
"runtime_log_counter_lines": [
|
||||
"0.01.556.888 I common_perf_print: samplers time = 0.41 ms / 27 tokens",
|
||||
"0.01.556.983 I common_perf_print: prompt eval time = 308.23 ms / 22 tokens ( 14.01 ms per token, 71.37 tokens per second)"
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
# Proposed report contribution: Member 1
|
||||
|
||||
**28 November evidence update:** The historical one-character results below remain valid for the earlier run. The current two-character input is `print("hello` and the reviewer no longer matches input against a typo list. A real local SmolLM2 run corrected it with 22 input and 5 output tokens; its reviewed file passed the hello execution test. See `evidence/two-character-local/README.txt`. A new Actions run and full cgroup measurement are still required before calling this a live integrated result. Final documentation should describe the current output-only safety rule and use the new live run's measured figures, not copy the historical one-character description as current behavior.
|
||||
|
||||
For Member 2 to integrate into the required **“Configuring and Running the DevOps Pipeline”** chapter. This is prose and table content only; no shared LaTeX or deployed dashboard file was edited.
|
||||
|
||||
## Why a model is in this pipeline
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"title": "SSW590 final project \u2014 live evidence",
|
||||
"uid": "ssw590-final-project",
|
||||
"schemaVersion": 39,
|
||||
"version": 3,
|
||||
"version": 4,
|
||||
"timezone": "America/New_York",
|
||||
"refresh": "30s",
|
||||
"time": {
|
||||
@@ -232,9 +232,13 @@
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 320000000
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 250000000
|
||||
"value": 360000000
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -255,59 +259,12 @@
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto"
|
||||
},
|
||||
"description": "Complete Actions workload, including runtime preparation, reviewer and private model. The previous 250 MB capped run hit its limit; its natural peak is unknown. New runs use a 250,000,000-byte warning target and 384,000,000-byte hard ceiling."
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Latest token count availability",
|
||||
"type": "stat",
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 21,
|
||||
"w": 12,
|
||||
"h": 5
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "review_input_tokens_available{mode=\"live\"}",
|
||||
"refId": "A",
|
||||
"legendFormat": "Input count available"
|
||||
},
|
||||
{
|
||||
"expr": "review_output_tokens_available{mode=\"live\"}",
|
||||
"refId": "B",
|
||||
"legendFormat": "Output count available"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"reduceOptions": {
|
||||
"values": false,
|
||||
"calcs": [
|
||||
"lastNotNull"
|
||||
],
|
||||
"fields": ""
|
||||
},
|
||||
"orientation": "auto",
|
||||
"textMode": "auto",
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto"
|
||||
}
|
||||
"description": "Measured complete Actions workload, including runtime preparation, reviewer and private model. The 250,000,000-byte model-selection goal is soft; the enforced ceiling is 384,000,000 bytes. Green below 320 MB, yellow from 320 MB, red near the ceiling from 360 MB."
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "Memory target result (latest review)",
|
||||
"description": "The 250,000,000-byte complete-workload target is a warning threshold. A value of 1 means this run exceeded it but a successful model review may continue. No sample is shown until a new measured run publishes this field.",
|
||||
"title": "Memory capacity used (latest review)",
|
||||
"description": "Measured peak divided by the enforced Actions memory ceiling. Green below 85%, yellow from 85%, red near the ceiling from 95%. The separate 250,000,000-byte model-selection goal is soft; a run may exceed it without failing. The raw review_job_memory_target_exceeded metric retains the exact result.",
|
||||
"type": "stat",
|
||||
"gridPos": {
|
||||
"x": 18,
|
||||
@@ -321,28 +278,13 @@
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "review_job_memory_target_exceeded{mode=\"live\"}",
|
||||
"expr": "review_job_memory_peak_bytes{mode=\"live\"} / review_job_memory_limit_bytes{mode=\"live\"}",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "none",
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "Within target",
|
||||
"color": "green"
|
||||
},
|
||||
"1": {
|
||||
"text": "Over target",
|
||||
"color": "red"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"unit": "percentunit",
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
@@ -350,9 +292,13 @@
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 0.85
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 1
|
||||
"value": 0.95
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -377,12 +323,12 @@
|
||||
{
|
||||
"id": 12,
|
||||
"title": "Actions hard memory ceiling (latest review)",
|
||||
"description": "Safety ceiling enforced by Docker. The previous run used about 250 MB; new runs request 384,000,000 bytes with swap disabled. An actual OOM or failed model still fails the review.",
|
||||
"description": "384,000,000-byte safety ceiling enforced by Docker with swap disabled. A modest overage of the separate 250,000,000-byte selection goal is allowed. An actual OOM or failed model still fails the review.",
|
||||
"type": "stat",
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"x": 0,
|
||||
"y": 21,
|
||||
"w": 12,
|
||||
"w": 24,
|
||||
"h": 5
|
||||
},
|
||||
"datasource": {
|
||||
@@ -397,7 +343,16 @@
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
"unit": "bytes",
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
@@ -420,5 +375,5 @@
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"description": "Cumulative measured tokens show the live review event; latest-run stat panels show memory and duration without drawing flat history lines. The 250 MB workload target warns; the Actions hard ceiling is 384 MB."
|
||||
"description": "Cumulative measured tokens show live review events. Memory panels use the 384 MB enforced ceiling for safety colors; the original 250 MB model-selection goal remains a soft warning recorded in the review metric and evidence."
|
||||
}
|
||||
|
||||
+10
-6
@@ -97,14 +97,18 @@ def review(input_path, source_commit, out_dir, propose=backend):
|
||||
candidate = response.get("candidate")
|
||||
if type(candidate) is not str:
|
||||
raise ValueError("backend candidate must be text")
|
||||
expected = {"print(\"hello\"": "print(\"hello\")",
|
||||
"print(\"hello\"\n": "print(\"hello\")\n"}
|
||||
if source not in expected or candidate != expected[source]:
|
||||
metadata.update(status="rejected", summary="Proposal exceeds the permitted closing-parenthesis repair")
|
||||
try:
|
||||
parsed = ast.parse(candidate)
|
||||
except SyntaxError:
|
||||
parsed = None
|
||||
safe_program = ast.parse('print("hello")')
|
||||
if (parsed is None or
|
||||
ast.dump(parsed, include_attributes=False) != ast.dump(safe_program, include_attributes=False)
|
||||
or candidate.endswith("\n") != source.endswith("\n")):
|
||||
metadata.update(status="rejected", summary="Proposal changes the demo behavior or adds code")
|
||||
code = 2
|
||||
else:
|
||||
ast.parse(candidate)
|
||||
metadata.update(status="corrected", summary="Added the missing closing parenthesis",
|
||||
metadata.update(status="corrected", summary="Model proposed runnable hello program",
|
||||
diff="".join(difflib.unified_diff(source.splitlines(keepends=True),
|
||||
candidate.splitlines(keepends=True), fromfile="original.py", tofile="reviewed.py")))
|
||||
code = 0
|
||||
|
||||
@@ -31,8 +31,8 @@ def propose(source):
|
||||
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")
|
||||
if len(source.encode("utf-8")) > 1024 or "\n" in source.rstrip("\n"):
|
||||
raise ValueError("demo source must be one bounded line")
|
||||
prompt = lock["prompt_template"].format(source_line=source.rstrip("\n"))
|
||||
command = [str(executable), "-m", str(model), "-p", prompt,
|
||||
"-n", str(lock["max_output_tokens"]), "-c", str(lock["context_tokens"]),
|
||||
|
||||
+43
-150
@@ -1,177 +1,70 @@
|
||||
"""Small reviewer contract tests; the current demo source supplies the error."""
|
||||
import ast
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from reviewer.__main__ import review
|
||||
import reviewer.__main__ as reviewer_module
|
||||
from smoke_demo import smoke
|
||||
|
||||
|
||||
SOURCE = Path(__file__).resolve().parents[1] / "demo/demo.py"
|
||||
SHA = "a" * 40
|
||||
BROKEN = 'print("hello"\n'
|
||||
FIXED = 'print("hello")\n'
|
||||
|
||||
|
||||
class ReviewerTests(unittest.TestCase):
|
||||
def run_case(self, source, response, code, status):
|
||||
def broken_source(self):
|
||||
source = SOURCE.read_text(encoding="utf-8")
|
||||
try:
|
||||
ast.parse(source)
|
||||
except SyntaxError:
|
||||
return source
|
||||
self.skipTest("Current demo source is valid; live repair is not needed")
|
||||
|
||||
def run_review(self, source, propose):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
original = root / "source.py"
|
||||
original.write_text(source, encoding="utf-8")
|
||||
called = []
|
||||
def propose(value):
|
||||
called.append(value)
|
||||
if isinstance(response, Exception):
|
||||
raise response
|
||||
return response
|
||||
out = root / "review"
|
||||
self.assertEqual(review(original, SHA, out, propose), code)
|
||||
data = json.loads((out / "review.json").read_text())
|
||||
self.assertEqual(data["status"], status)
|
||||
self.assertEqual(data["source_commit"], SHA)
|
||||
self.assertEqual(original.read_text(), source)
|
||||
code = review(original, SHA, out, propose)
|
||||
data = json.loads((out / "review.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(original.read_text(encoding="utf-8"), source)
|
||||
self.assertEqual((out / "reviewed.py").exists(), code == 0)
|
||||
self.assertTrue({"model_id", "summary", "diff", "input_tokens", "output_tokens"} <= data.keys())
|
||||
self.assertEqual(len(called), status != "unchanged")
|
||||
if status == "corrected":
|
||||
self.assertEqual((out / "reviewed.py").read_text(), FIXED)
|
||||
self.assertIn('+print("hello")', data["diff"])
|
||||
if code == 0:
|
||||
self.assertEqual(smoke(out / "reviewed.py"), 0)
|
||||
if status == "unchanged":
|
||||
self.assertEqual((out / "reviewed.py").read_bytes(), source.encode())
|
||||
self.assertEqual(data["diff"], "")
|
||||
self.assertIsNone(data["model_id"])
|
||||
with self.assertRaises(FileExistsError):
|
||||
review(original, SHA, out, propose)
|
||||
return data
|
||||
return code, data
|
||||
|
||||
def test_corrected(self):
|
||||
data = self.run_case(BROKEN, dict(candidate=FIXED, model_id="fake", input_tokens=24, output_tokens=8), 0, "corrected")
|
||||
self.assertEqual((data["input_tokens"], data["output_tokens"]), (24, 8))
|
||||
|
||||
def test_unchanged_skips_backend(self):
|
||||
self.run_case(FIXED, AssertionError("backend called"), 0, "unchanged")
|
||||
|
||||
def test_rejected_unrelated_edit(self):
|
||||
self.run_case(BROKEN, dict(candidate='print("bye")\n', model_id="fake"), 2, "rejected")
|
||||
|
||||
def test_rejected_invalid_syntax(self):
|
||||
self.run_case(BROKEN, dict(candidate='print("hello"\n', model_id="fake"), 2, "rejected")
|
||||
|
||||
def test_error(self):
|
||||
self.run_case(BROKEN, RuntimeError("offline"), 3, "error")
|
||||
|
||||
def test_timeout(self):
|
||||
self.run_case(BROKEN, TimeoutError("timeout"), 3, "error")
|
||||
|
||||
def test_missing_counts(self):
|
||||
data = self.run_case(BROKEN, dict(candidate=FIXED, model_id="fake"), 0, "corrected")
|
||||
def test_current_source_accepts_safe_model_output(self):
|
||||
source = self.broken_source()
|
||||
candidate = 'print("hello")' + ('\n' if source.endswith('\n') else '')
|
||||
code, data = self.run_review(source, lambda _: dict(candidate=candidate, model_id="fixture"))
|
||||
self.assertEqual((code, data["status"]), (0, "corrected"))
|
||||
self.assertIsNone(data["input_tokens"])
|
||||
self.assertIsNone(data["output_tokens"])
|
||||
|
||||
def test_invalid_counts(self):
|
||||
self.run_case(BROKEN, dict(candidate=FIXED, model_id="fake", input_tokens=True), 3, "error")
|
||||
def test_extra_model_code_is_rejected_before_execution(self):
|
||||
source = self.broken_source()
|
||||
candidate = 'print("hello")\nprint("extra")\n'
|
||||
code, data = self.run_review(source, lambda _: dict(candidate=candidate, model_id="fixture"))
|
||||
self.assertEqual((code, data["status"]), (2, "rejected"))
|
||||
|
||||
def test_missing_candidate(self):
|
||||
self.run_case(BROKEN, dict(model_id="fake"), 3, "error")
|
||||
def test_backend_error_has_diagnostic(self):
|
||||
source = self.broken_source()
|
||||
def unavailable(_):
|
||||
raise RuntimeError("backend unavailable")
|
||||
code, data = self.run_review(source, unavailable)
|
||||
self.assertEqual((code, data["status"]), (3, "error"))
|
||||
self.assertIn("backend unavailable", data["diagnostic"])
|
||||
|
||||
def test_unrelated_syntax_error(self):
|
||||
self.run_case("x = (\n", dict(candidate=FIXED, model_id="fake"), 2, "rejected")
|
||||
def test_valid_input_bypasses_backend(self):
|
||||
def forbidden(_):
|
||||
raise AssertionError("backend should not run")
|
||||
code, data = self.run_review('print("hello")\n', forbidden)
|
||||
self.assertEqual((code, data["status"]), (0, "unchanged"))
|
||||
self.assertEqual(data["diff"], "")
|
||||
|
||||
def test_no_newline(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
p = Path(temp) / "bad.py"
|
||||
p.write_bytes(b'print("hello"')
|
||||
out = Path(temp) / "out"
|
||||
self.assertEqual(review(p, SHA, out, lambda _: dict(candidate='print("hello")', model_id="fake")), 0)
|
||||
self.assertEqual((out / "reviewed.py").read_bytes(), b'print("hello")')
|
||||
|
||||
def test_invalid_sha(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
p = Path(temp) / "bad.py"
|
||||
p.write_text(BROKEN)
|
||||
out = Path(temp) / "out"
|
||||
self.assertEqual(review(p, "short", out), 3)
|
||||
self.assertFalse((out / "reviewed.py").exists())
|
||||
|
||||
def test_cli_corrected_and_malformed_json(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
p = root / "bad.py"
|
||||
p.write_text(BROKEN)
|
||||
fake = root / "fake.py"
|
||||
fake.write_text('import json,sys\njson.load(sys.stdin)\nprint(json.dumps({"model_id":"fixture","candidate":"print(\\"hello\\")\\n","input_tokens":24,"output_tokens":8}))\n')
|
||||
env = dict(os.environ, REVIEWER_BACKEND_COMMAND=json.dumps([sys.executable, str(fake)]))
|
||||
out = root / "good"
|
||||
result = subprocess.run([sys.executable, "-m", "reviewer", "--input", str(p), "--source-commit", SHA, "--out-dir", str(out)], env=env)
|
||||
self.assertEqual(result.returncode, 0)
|
||||
self.assertEqual(json.loads((out / "review.json").read_text())["mode"], "fixture")
|
||||
self.assertEqual(smoke(out / "reviewed.py"), 0)
|
||||
fake.write_text('print("not json")\n')
|
||||
out = root / "malformed"
|
||||
result = subprocess.run([sys.executable, "-m", "reviewer", "--input", str(p), "--source-commit", SHA, "--out-dir", str(out)], env=env)
|
||||
self.assertEqual(result.returncode, 3)
|
||||
self.assertFalse((out / "reviewed.py").exists())
|
||||
|
||||
def test_cli_rejected_and_unchanged(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
broken = root / "broken.py"
|
||||
broken.write_text(BROKEN)
|
||||
fake = root / "fake.py"
|
||||
fake.write_text('import json\nprint(json.dumps({"model_id":"fixture","candidate":"print(\\\"bye\\\")\\n"}))\n')
|
||||
env = dict(os.environ, REVIEWER_BACKEND_COMMAND=json.dumps([sys.executable, str(fake)]))
|
||||
out = root / "rejected"
|
||||
result = subprocess.run([sys.executable, "-m", "reviewer", "--input", str(broken),
|
||||
"--source-commit", SHA, "--out-dir", str(out)], env=env)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertEqual(json.loads((out / "review.json").read_text())["status"], "rejected")
|
||||
self.assertFalse((out / "reviewed.py").exists())
|
||||
valid = root / "valid.py"
|
||||
valid.write_text(FIXED)
|
||||
fake.write_text('raise AssertionError("must not run")\n')
|
||||
out = root / "unchanged"
|
||||
result = subprocess.run([sys.executable, "-m", "reviewer", "--input", str(valid),
|
||||
"--source-commit", SHA, "--out-dir", str(out)], env=env)
|
||||
self.assertEqual(result.returncode, 0)
|
||||
data = json.loads((out / "review.json").read_text())
|
||||
self.assertEqual(data["status"], "unchanged")
|
||||
self.assertEqual(data["diff"], "")
|
||||
self.assertEqual((out / "reviewed.py").read_bytes(), valid.read_bytes())
|
||||
|
||||
def test_cli_usage_is_separate(self):
|
||||
result = subprocess.run([sys.executable, "-m", "reviewer"], capture_output=True)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertIn(b"usage:", result.stderr)
|
||||
|
||||
def test_subprocess_timeout(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
source = root / "broken.py"
|
||||
source.write_text(BROKEN)
|
||||
sleeper = root / "sleep.py"
|
||||
sleeper.write_text("import time\ntime.sleep(2)\n")
|
||||
old_timeout = reviewer_module.TIMEOUT_SECONDS
|
||||
old_command = os.environ.get("REVIEWER_BACKEND_COMMAND")
|
||||
reviewer_module.TIMEOUT_SECONDS = 0.05
|
||||
os.environ["REVIEWER_BACKEND_COMMAND"] = json.dumps([sys.executable, str(sleeper)])
|
||||
try:
|
||||
out = root / "out"
|
||||
self.assertEqual(review(source, SHA, out), 3)
|
||||
self.assertEqual(json.loads((out / "review.json").read_text())["status"], "error")
|
||||
self.assertFalse((out / "reviewed.py").exists())
|
||||
finally:
|
||||
reviewer_module.TIMEOUT_SECONDS = old_timeout
|
||||
if old_command is None:
|
||||
os.environ.pop("REVIEWER_BACKEND_COMMAND", None)
|
||||
else:
|
||||
os.environ["REVIEWER_BACKEND_COMMAND"] = old_command
|
||||
|
||||
def test_runtime_failure(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
path = Path(temp) / "bad.py"
|
||||
path.write_text('raise RuntimeError("fixture")\n')
|
||||
self.assertEqual(smoke(path), 1)
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user