UI for projects, templates, attributes and maturity (RBT-WP-0008-T08); stop a test from writing runs into the repo
Some checks failed
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 6s
Work Records / validate (push) Has been cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: sonnet
Assistant-Process: 295952@bnt-lap001
Assistant-Session: e93f64ad-516c-46eb-9666-aad8d300c477
This commit is contained in:
tegwick 2026-09-29 13:12:47 +02:00
parent 3470552789
commit eacbf8a21d
9 changed files with 560 additions and 12 deletions

View file

@ -242,3 +242,41 @@ def instantiate(reg: Registry, template_id: str, project_id: str, environment: s
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(yaml.safe_dump(project, sort_keys=False))
return target
# ---- editing -----------------------------------------------------------------------------------------------------
def set_attributes(reg: Registry, doc: Doc, values: dict[str, str]) -> Path:
"""Give attributes values in the project file itself. Refuses values a consuming runbook rejects."""
d = doc.data
if d["spec"] != "project/v0.1":
raise ValueError("only a project, not a template, takes values this way")
known: dict[str, list] = {}
for m in d["runbooks"]:
pack = reg.packs.get(m["pack"])
if pack is None:
continue
for x in (pack.data.get("datapoints") or pack.data.get("parameters") or []):
known.setdefault(x["id"], []).append(pack)
attrs = dict(d.get("attributes") or {})
for name, value in values.items():
value = str(value).strip()
if not value:
continue
if not re.fullmatch(r"[a-z][a-z0-9_]*", name):
raise ValueError(f"bad attribute name {name}")
from .pack import SECRET_RE
if SECRET_RE.search(value):
raise ValueError(f"{name}: value looks like a secret; attributes are never secret")
for pack in known.get(name, []):
err = check_value(pack, name, value)
if err:
raise ValueError(f"{name}: {err} (for {pack.id})")
if isinstance(attrs.get(name), dict):
attrs[name] = {**attrs[name], "value": value}
else:
attrs[name] = value
text = yaml.safe_load(doc.path.read_text())
text["attributes"] = attrs
doc.path.write_text(yaml.safe_dump(text, sort_keys=False))
return doc.path