mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 02:08:18 +00:00
fix(images): the replay entry leaves benchmarks/unseen, so the replay stage builds (item 5b)
The maintainer's answer of 2026-11-27 to question 1 of the ninth session's menu, "Move the file, fix now": the script leaves benchmarks/unseen for a path the build context keeps, and the four references follow. .dockerignore:32 has excluded benchmarks/unseen since9017038(2026-11-24), so the COPY of the replay stage of plane/Dockerfile.engine-task stopped the build. Measured again here from the root context, with scratch Dockerfiles: a COPY of the old path fails with "not found", a COPY of a kept path succeeds, and after the change a COPY of the new path succeeds. What changed: - benchmarks/unseen/replay_entry.py is benchmarks/replay/replay_entry.py (git mv, the content unchanged). The directory is the session's choice; no decision names it. The script's own line 18 looks for learn/ beside its own directory (parents[1] / "learn"), so a sibling of benchmarks/learn keeps that line as it is. Measured in a probe image: with the file directly under benchmarks/, the import of engine_task_entry fails at line 19. - plane/Dockerfile.engine-task:47 copies the new path to ./benchmarks/replay/. The command of benchmarks/unseen/replay.py:46 names /app/benchmarks/replay/replay_entry.py. The two tests import benchmarks.replay.replay_entry. - tests/test_task_images.py gains test_copy_sources_are_kept_by_the_build_context, over the four Dockerfiles that build from the root context: a COPY source that the root .dockerignore excludes stops the build. Evidence: - RED: the new test on a git archive of HEAD plus the new test file, 1 failed and 3 passed (the engine-task Dockerfile copies benchmarks/unseen/replay_entry.py); the first version of the helper gave the same on the working tree before the move. - GREEN: 458 passed over tests/test_task_images.py, tests/test_unseen_*.py, tests/test_independent_population.py and tests/test_search_image.py after the move, and tests/test_task_images.py again, 27 passed, after the helper was hardened. - ruff, mypy, the three gates and compileall pass, and the gates print what they printed before. `git diff --check` exits 0. No whole-suite run: that is step 9. - An independent reviewer approved the change in one round. Its optional hardening of the helper is applied after the approval, as proposed: a line of .dockerignore is now matched against the path and each directory above it, where the first version took a line without a wildcard by prefix only. Two shapes stay as the reviewer found them: a line written with a leading ./ or /, and a `!` line with a wildcard are not read as Docker reads them. - The scratch is under /tmp/opencode/s10_* and is not kept. Side effect, by reading: the root Dockerfile copies the whole benchmarks directory (Dockerfile:44), so the next scan image carries benchmarks/replay/replay_entry.py, where the file was excluded with its directory. No image is rebuilt. Found and not fixed, for the maintainer: after this commit the replay job of engine-image.yml builds again, and the image it publishes cannot start its entry. In an image built from plane/Dockerfile.engine-task the import at benchmarks/learn/ engine_task_entry.py:17 (from benchmarks.valid.artifact_contract, from11059c4cof 2026-11-03) has nothing to resolve. By reading: the engine stage copies pyproject.toml, README.md, LICENSE, src and three named files of benchmarks/learn, and the replay stage adds one file, so neither image holds benchmarks/valid. Measured on the shipped scan image openultrasast:dev 3f959b31f2f2 (built from88ea171, before this change) with the network off; the engine image and the replay image were not built or run here, and the runner's environment was not read: `python3 /app/benchmarks/learn/engine_task_entry.py`, the way benchmarks/learn/engine_trace_ax.py:38 launches the engine workload, stops at line 17 with "No module named 'benchmarks'"; with /app on the path it stops with "No module named 'benchmarks.valid'", because9017038keeps benchmarks/valid out of every image; and the replay actor's command in a probe image built from the scan image stops at replay_entry.py:19 and then at that line. So a green replay job is not a working replay. The fix is a decision: carry artifact_contract.py in the two stages, move write_benchmark_artifact out of benchmarks/valid, or make the import lazy. It is not made here; the fault is outside the answer. Left as they are: .kiro/steering/roadmap.md:289 and .kiro/specs/engine-change-scoped-analysis/brief.md:36 name the old path in the image (steering is the maintainer's; both are reported); the contributor-scan record, benchmarks/measurements/2026-10-04-unseen-06-scorer/record.json:8 and a PATHFINDER document are dated records. No test reads the command path of replay.py:46 against the COPY's destination; they agree by reading.
This commit is contained in:
@@ -43,7 +43,7 @@ def make_item(change, arm, image, *, deadline_scale=1.0, lane="ax", deadline=Non
|
|||||||
"replay-" + identity,
|
"replay-" + identity,
|
||||||
{"SPEC_URL": data},
|
{"SPEC_URL": data},
|
||||||
"result.dat",
|
"result.dat",
|
||||||
("python3", "/app/benchmarks/unseen/replay_entry.py"),
|
("python3", "/app/benchmarks/replay/replay_entry.py"),
|
||||||
{},
|
{},
|
||||||
digest,
|
digest,
|
||||||
{"SPEC_URL": "spec.dat"},
|
{"SPEC_URL": "spec.dat"},
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ RUN /venv/bin/python -I -c 'import pathlib, runpy, sys; sys.modules.update(yaml=
|
|||||||
# ENTRYPOINT and CMD belong to the upstream AX runner.
|
# ENTRYPOINT and CMD belong to the upstream AX runner.
|
||||||
|
|
||||||
FROM ${ENGINE_REF} AS replay
|
FROM ${ENGINE_REF} AS replay
|
||||||
COPY benchmarks/unseen/replay_entry.py ./benchmarks/unseen/replay_entry.py
|
COPY benchmarks/replay/replay_entry.py ./benchmarks/replay/replay_entry.py
|
||||||
RUN /venv/bin/ousast pre-push --help > /dev/null
|
RUN /venv/bin/ousast pre-push --help > /dev/null
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
from fnmatch import fnmatchcase
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -270,6 +271,33 @@ def test_search_pilot_files_stay_out_of_the_image():
|
|||||||
assert not any(line.startswith(f"!{private}".rstrip("/")) for line in patterns), f"{private} is let back in"
|
assert not any(line.startswith(f"!{private}".rstrip("/")) for line in patterns), f"{private} is let back in"
|
||||||
|
|
||||||
|
|
||||||
|
def _kept_by_build_context(path, patterns):
|
||||||
|
"""Docker keeps a path unless a line of .dockerignore names it or a directory above it; the last matching line wins."""
|
||||||
|
kept = True
|
||||||
|
ancestors = [path[:cut] for cut in (match.start() for match in re.finditer("/", path))]
|
||||||
|
for pattern in patterns:
|
||||||
|
negated = pattern.startswith("!")
|
||||||
|
pattern = pattern[1:] if negated else pattern
|
||||||
|
if any(fnmatchcase(candidate, pattern.rstrip("/")) for candidate in (path, *ancestors)):
|
||||||
|
kept = negated
|
||||||
|
return kept
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"name",
|
||||||
|
["Dockerfile", "plane/Dockerfile.base", "plane/Dockerfile.engine-task", "plane/Dockerfile.search-task"],
|
||||||
|
)
|
||||||
|
def test_copy_sources_are_kept_by_the_build_context(name):
|
||||||
|
"""A COPY whose source the root .dockerignore excludes stops the build: the replay stage copied from benchmarks/unseen."""
|
||||||
|
patterns = [line.strip() for line in read(".dockerignore").splitlines()]
|
||||||
|
patterns = [line for line in patterns if line and not line.startswith("#")]
|
||||||
|
copies = [line.split()[1:] for line in instructions(name) if line.startswith("COPY ") and "--from=" not in line]
|
||||||
|
sources = [word for words in copies for word in words[:-1] if not word.startswith("--")]
|
||||||
|
assert sources
|
||||||
|
for source in sources:
|
||||||
|
assert _kept_by_build_context(source, patterns), f"{name} copies {source}, which the root .dockerignore excludes"
|
||||||
|
|
||||||
|
|
||||||
def test_app_layers_carry_their_owner():
|
def test_app_layers_carry_their_owner():
|
||||||
"""`COPY --chown` on every layer under /app: a final `chown -R` would store each of its files twice."""
|
"""`COPY --chown` on every layer under /app: a final `chown -R` would store each of its files twice."""
|
||||||
lines = instructions("Dockerfile")
|
lines = instructions("Dockerfile")
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ def test_scaled_task_contract(lane, arm, expected):
|
|||||||
spec = json.loads(item.inputs["SPEC_URL"])
|
spec = json.loads(item.inputs["SPEC_URL"])
|
||||||
assert spec["hook_flags"] == ["--deadline", str(expected)]
|
assert spec["hook_flags"] == ["--deadline", str(expected)]
|
||||||
assert spec["deadline_seconds"] == expected and spec["deadline_scale"] == 2.5
|
assert spec["deadline_seconds"] == expected and spec["deadline_scale"] == 2.5
|
||||||
entry = importlib.import_module("benchmarks.unseen.replay_entry")
|
entry = importlib.import_module("benchmarks.replay.replay_entry")
|
||||||
entry.validate_spec({**spec, "repository_url": "https://public.example/test", "base": "a" * 40, "head": "b" * 40})
|
entry.validate_spec({**spec, "repository_url": "https://public.example/test", "base": "a" * 40, "head": "b" * 40})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from pathlib import Path
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||||
e = importlib.import_module("benchmarks.unseen.replay_entry")
|
e = importlib.import_module("benchmarks.replay.replay_entry")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user