Bench: --move-to tests a step that adds a service; --write-ladder --to-definition writes it (R-762 tooling); rules copies line
gates / gates (push) Successful in 7s
gates / gates (push) Successful in 7s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
ecb8552ee9
commit
c48a0db3a7
4 files changed
+81
-4
No files matched your search
@@ -6,8 +6,8 @@ unconditional: true
|
||||
> Goal sessions, nightly sessions, "work the register" sessions. **A session that starts from
|
||||
> `/goal` or a standing brief inherits these rules exactly as it inherits the gates.** They are the
|
||||
> part of `PROMPT-TEMPLATE.md` that a task file used to carry and a goal does not. Same wording lives
|
||||
> in `felhom.eu`, `felhom-controller` and `app-catalog-felhom.eu` `.claude/rules/`, and in the workspace root's
|
||||
> unversioned `.claude/rules/`; change all four or none.
|
||||
> in `felhom.eu`, `felhom-controller`, `felhom-agent` and `app-catalog-felhom.eu` `.claude/rules/`, and in the workspace
|
||||
> root's unversioned `.claude/rules/`; change all five or none.
|
||||
|
||||
## 1. What you may pick up on your own
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
## 2026-10-06 (evening) — the bench can test a step that adds a service (R-762 tooling)
|
||||
|
||||
**What runs on a box changed:** nothing. Test tools only.
|
||||
|
||||
- `upgrade-test.py --move-to <app> <dir>`: an edge FROM the template as it stands TO the whole definition in `templates/<dir>` — a step that adds a service, a volume or an env switch, which the per-service image substitution cannot express. `--write-ladder … --to-definition <dir>` writes such a step: the definition's images must equal what the bench tested TO, and the file the bench ran is the file written. Tests: DefinitionEdge (red-proved: an edge without `to_template` renders the FROM template).
|
||||
- `.claude/rules/unprompted-work.md`: the copies line names five copies (the agent repo has one now, `09` §3 decision 152).
|
||||
|
||||
## 2026-10-06 (afternoon) — vaultwarden's first update step (1.36.0 → 1.37.4), proven on both venues; the test box may seed it through its admin page (R-890)
|
||||
|
||||
**What runs on a box changed:** vaultwarden's pin moves to `vaultwarden/server:1.37.4-alpine` with its first ladder entry, so a box offers the update and the night may take it. Written by `upgrade-test.py --write-ladder` from both verdicts: bench LXC 9401 (harness v5, 10-minute memory watch, anon peak 16.3 %, seed read back, no restart) and scratch 9202 (the product's guarded Update, done in 12.3 s, seed read back, badge „Naprakész" after). Evidence: `felhom.eu/documentation/audits/r890-instructions-2026-10-06/{bench,box/vaultwarden}`.
|
||||
|
||||
@@ -9,6 +9,7 @@ import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
spec = importlib.util.spec_from_file_location("upgrade_test_mod", os.path.join(HERE, "upgrade-test.py"))
|
||||
@@ -350,6 +351,45 @@ class BoxAdminSeedGuard(unittest.TestCase):
|
||||
fxbox.box_admin_invite(FakeBoxWalk(), 'x"}; rm -rf /; {"@gate.invalid')
|
||||
|
||||
|
||||
class DefinitionEdge(unittest.TestCase):
|
||||
"""R-762: `--move-to <app> <dir>` — a step that ADDS a service. The TO side is the whole definition in <dir>, and the
|
||||
TO render reads it (render() alone cannot add a service). RED-PROOF (REPORT): drop `to_template` from the edge — the
|
||||
render test reads the FROM template and fails."""
|
||||
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp(prefix="bench-defedge-"))
|
||||
for d, extra in (("app1", ""), ("app1@new", " side:\n image: nginx:1.30.5-alpine\n")):
|
||||
(self.root / d).mkdir()
|
||||
(self.root / d / "docker-compose.yml").write_text("services:\n app1:\n image: app/one:1.0\n" + extra)
|
||||
self.p = mock.patch.object(ut, "TEMPLATES", self.root)
|
||||
self.p.start()
|
||||
|
||||
def tearDown(self):
|
||||
self.p.stop()
|
||||
shutil.rmtree(self.root, ignore_errors=True)
|
||||
|
||||
def test_the_edge_names_the_new_service(self):
|
||||
eid = ut.add_definition_edge("app1", "app1@new")
|
||||
e = ut.EDGES[eid]
|
||||
self.assertEqual(e["frm"], {"app1": "app/one:1.0"})
|
||||
self.assertEqual(e["to"], {"app1": "app/one:1.0", "side": "nginx:1.30.5-alpine"})
|
||||
self.assertEqual(e["to_template"], "app1@new")
|
||||
|
||||
def test_the_to_render_reads_the_new_definition(self):
|
||||
eid = ut.add_definition_edge("app1", "app1@new")
|
||||
e = ut.EDGES[eid]
|
||||
wd = self.root / "work"
|
||||
with mock.patch.object(ut, "apply_bench_overrides", lambda app, t: t), mock.patch.object(ut, "pg_mounts_for", lambda t: t):
|
||||
ut.render("app1", e["to"], wd, {}, e.get("to_template") or e.get("template"))
|
||||
self.assertIn("nginx:1.30.5-alpine", (wd / "docker-compose.yml").read_text())
|
||||
|
||||
def test_nothing_new_is_refused(self):
|
||||
(self.root / "same").mkdir()
|
||||
(self.root / "same" / "docker-compose.yml").write_text((self.root / "app1" / "docker-compose.yml").read_text())
|
||||
with self.assertRaises(SystemExit):
|
||||
ut.add_definition_edge("app1", "same")
|
||||
|
||||
|
||||
class SecretHygiene(unittest.TestCase):
|
||||
"""The run's secrets: .env 0600 and shredded, every evidence file redacted. RED-PROOF (REPORT): make redact_tree
|
||||
return [] without rewriting — test_evidence_files_are_redacted fails."""
|
||||
|
||||
+32
-2
@@ -896,7 +896,7 @@ def bench_convert(conv, e, app, project, workdir, env, ev, say):
|
||||
raise RuntimeError(f"no named volume under /var/lib/postgresql on {cid}: {vols}")
|
||||
cvp._sh(["docker", "stop", "-t", "60", cid])
|
||||
cvp._sh(["docker", "run", "--rm", "-v", vol + ":/v", "alpine", "sh", "-c", "find /v -mindepth 1 -delete"])
|
||||
render(app, e["to"], workdir, env, e.get("template"))
|
||||
render(app, e["to"], workdir, env, e.get("to_template") or e.get("template"))
|
||||
up = compose(workdir, project, "up", "-d", "--no-deps", svc)
|
||||
if up.returncode != 0:
|
||||
raise RuntimeError(f"the new engine did not start: {up.stderr[-400:]}")
|
||||
@@ -1027,7 +1027,7 @@ def run_edge(edge_id: str) -> dict:
|
||||
say(f"CONVERSION FAILED: {ex}")
|
||||
return rec
|
||||
say(f"{edge_id}: swapping to TO {e['to']}")
|
||||
render(app, e["to"], workdir, env, e.get("template"))
|
||||
render(app, e["to"], workdir, env, e.get("to_template") or e.get("template"))
|
||||
up2 = compose(workdir, project, "up", "-d")
|
||||
say(f"TO up -d rc={up2.returncode}")
|
||||
ok2, secs2, states2 = settle(project, workdir)
|
||||
@@ -1158,6 +1158,20 @@ def add_move_edge(app: str, moves: list) -> str:
|
||||
return eid
|
||||
|
||||
|
||||
def add_definition_edge(app: str, to_dir: str) -> str:
|
||||
"""`--move-to <app> <dir>` (R-762, 2026-10-06) → an edge FROM the template as it stands TO the definition in
|
||||
TEMPLATES/<dir> — a step that is more than image lines (a new service, a new volume, an env switch). `render()`'s
|
||||
per-service image substitution cannot add a service, so the TO side is that whole definition, with its own images.
|
||||
The FROM side is still read from the catalog, never typed. --write-ladder --to-definition writes such a step."""
|
||||
frm = template_images(app, TEMPLATES)
|
||||
to = template_images(to_dir, TEMPLATES)
|
||||
if not to or to == frm and (TEMPLATES / to_dir / "docker-compose.yml").read_text() == (TEMPLATES / app / "docker-compose.yml").read_text():
|
||||
raise SystemExit(f"--move-to: {to_dir} defines nothing new against {app}")
|
||||
eid = f"MV-{app}"
|
||||
EDGES[eid] = dict(app=app, note=f"definition step to {to_dir}", frm=frm, to=to, to_template=to_dir)
|
||||
return eid
|
||||
|
||||
|
||||
def plain_refs(m: dict) -> dict:
|
||||
"""{svc: ref} with any `@sha256:…` dropped — the ladder's `from`/`to` name TAGS; digests ride in `digest`."""
|
||||
return {k: v.split("@", 1)[0] for k, v in (m or {}).items()}
|
||||
@@ -1312,6 +1326,20 @@ def write_ladder(argv) -> int:
|
||||
if not smp.exists(): # R-664: and its own .felhom.yml, without the ladder
|
||||
smp.write_text(ladder.strip_ladder_block(fy_p.read_text()))
|
||||
print(f"STEP {app}: … and its .felhom.yml at {ladder.step_meta_file(cur)}")
|
||||
todef = arg("--to-definition")
|
||||
if todef:
|
||||
# R-762: a definition step (a new service): the TO compose is that definition as a whole, and its images must
|
||||
# be exactly what the bench tested TO. Never a hand edit — the file the bench ran is the file written.
|
||||
newc = (Path(todef) / "docker-compose.yml").read_text()
|
||||
if ladder.images_in(newc) != bto:
|
||||
print(f"REFUSED {app}: the definition names {ladder.images_in(newc)}, the bench tested TO {bto}")
|
||||
return 1
|
||||
comp_p.write_text(newc)
|
||||
fy = fy_p.read_text()
|
||||
fy = re.sub(r'^catalog_since:.*$', 'catalog_since: "%s"' % _dt.date.today().isoformat(), fy, count=1, flags=re.M)
|
||||
fy_p.write_text(ladder.append_entry(fy, entry))
|
||||
print(f"WROTE {app}: DEFINITION STEP {bfrom} -> {bto} peak {peak}% marks {entry['marks']}")
|
||||
return 0
|
||||
# move the compose, per service, on that service's own image: line
|
||||
out, svc = [], None
|
||||
for line in comp.splitlines():
|
||||
@@ -1398,6 +1426,8 @@ def main(argv):
|
||||
argv = argv[2:]
|
||||
if argv and argv[0] == "--move":
|
||||
argv = [add_move_edge(argv[1], argv[2:])]
|
||||
if argv and argv[0] == "--move-to":
|
||||
argv = [add_definition_edge(argv[1], argv[2])]
|
||||
if argv and argv[0] == "--retest":
|
||||
argv = [add_retest_edge(argv[1], argv[2:])]
|
||||
if not argv or argv[0] == "--list":
|
||||
|
||||
Reference in new issue
Block a user