Point Nix at relocated CI scripts and remove legacy plan paths
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# Advisory scan — specification
|
||||
|
||||
What `cc-ci-plan/advisory-scan.py` does, step by step, and why each step exists. This documents the
|
||||
What `scripts/cc-ci/advisory-scan.py` does, step by step, and why each step exists. This documents the
|
||||
implementation as it stands (2026-08-11); if you change the code, change this file in the same commit.
|
||||
`cc-ci-plan/test-advisory-scan.py` is the executable half of this spec — every rule below is asserted
|
||||
`scripts/cc-ci/test-advisory-scan.py` is the executable half of this spec — every rule below is asserted
|
||||
there.
|
||||
|
||||
**Role.** A per-recipe CVE detector run as a **pre-step of `/recipe-upgrade`** (step 2a). It is
|
||||
@@ -45,7 +45,7 @@ advisory-scan.py <recipe> --compose-to <URL> [--compose-from <URL>] # windows
|
||||
|
||||
| Input | Meaning |
|
||||
|---|---|
|
||||
| `<recipe>` | Recipe name; selects `cc-ci-plan/upstream/<recipe>.md` (the per-recipe URL registry) |
|
||||
| `<recipe>` | Recipe name; selects `data/cc-ci/upstream/<recipe>.md` (the per-recipe URL registry) |
|
||||
| `--from` / `--to` | The **primary app image's** version window being upgraded across |
|
||||
| `--image NAME=FROM:TO` | A **sidecar image and the versions it moved between** (repeatable, all in ONE call). `NAME` is substring-matched against source repo names. Malformed values warn on stderr and are skipped. Without it that image's advisories stay unclassified. |
|
||||
| `--compose-to URL` | **Derive every window by diffing this compose against its baseline**, instead of typing `--from/--to/--image`. Point it at a PR's `compose.yml`. |
|
||||
@@ -67,7 +67,7 @@ sidecar is scanned under its own image name.
|
||||
|
||||
## Step 1 — Collect source URLs from the registry
|
||||
|
||||
Read `cc-ci-plan/upstream/<recipe>.md` and extract every `http(s)://…` URL.
|
||||
Read `data/cc-ci/upstream/<recipe>.md` and extract every `http(s)://…` URL.
|
||||
|
||||
**Trailing markdown punctuation is stripped** (`` ` `` `'` `"` `*` `.` `,` `;` `:` `>` `)`). The registry
|
||||
is markdown, so URLs appear inside backticks and quotes; capturing the punctuation produced fetches of
|
||||
|
||||
@@ -17,7 +17,7 @@ SOURCES (measured against the gitea case before being chosen):
|
||||
CVE id, GHSA id, severity AND vulnerable/patched version ranges, so "fixed by THIS upgrade" is
|
||||
computable rather than guessed. Found both gitea CVEs. Derived from the source-repo URLs the
|
||||
per-recipe registry already records — no new per-recipe config needed.
|
||||
2. Vendor release/security pages — every URL in cc-ci-plan/upstream/<recipe>.md, fetched and
|
||||
2. Vendor release/security pages — every URL in data/cc-ci/upstream/<recipe>.md, fetched and
|
||||
regex-scanned for CVE ids. This is what would have caught gitea: the vendor blog names both,
|
||||
while the GitHub releases page names neither. Add vendor security/announcement URLs to the
|
||||
registry to widen this.
|
||||
@@ -50,7 +50,7 @@ import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
REGISTRY_DIR = os.environ.get("CCCI_UPSTREAM_REGISTRY", "/srv/cc-ci/cc-ci-plan/upstream")
|
||||
REGISTRY_DIR = os.environ.get("CCCI_UPSTREAM_REGISTRY", "/srv/cc-ci/data/cc-ci/upstream")
|
||||
UA = "cc-ci-advisory-scan (+https://git.autonomic.zone/recipe-maintainers/cc-ci)"
|
||||
TIMEOUT = int(os.environ.get("ADVISORY_SCAN_TIMEOUT", "45"))
|
||||
CVE_RE = re.compile(r"CVE-\d{4}-\d{4,7}")
|
||||
@@ -1154,7 +1154,7 @@ def scan(recipe: str, v_from: str | None, v_to: str | None, registry_dir: str,
|
||||
# NEVER report 0 for something we could not determine — a 0 asserts safety. If ANY requested
|
||||
# window could not be ordered at all, the total is UNKNOWN rather than a partial number.
|
||||
# A scan with NO usable source has not measured anything, so it must not report a number —
|
||||
# least of all 0, which asserts safety. mumble had no cc-ci-plan/upstream/mumble.md at all and
|
||||
# least of all 0, which asserts safety. mumble had no data/cc-ci/upstream/mumble.md at all and
|
||||
# still produced "0 identified", which was then published as a clean 0 in a CVE report.
|
||||
usable_sources = [s for s in report["sources"] if s["status"] == "ok"]
|
||||
no_sources = not usable_sources
|
||||
@@ -1191,7 +1191,7 @@ def markdown(rep: dict) -> str:
|
||||
+ ", ".join(rep["fixed_by_this_upgrade"][:15]))
|
||||
if rep.get("no_usable_sources"):
|
||||
L.append("\n⚠ This is NOT zero. **No usable source was checked at all** — the registry "
|
||||
"file `cc-ci-plan/upstream/<recipe>.md` is missing or every source failed, so "
|
||||
"file `data/cc-ci/upstream/<recipe>.md` is missing or every source failed, so "
|
||||
"nothing was measured. Render this recipe's cve cell as `?`, never `0`, and add "
|
||||
"the registry file.")
|
||||
else:
|
||||
|
||||
@@ -46,7 +46,7 @@ def load_config(path):
|
||||
"backends": raw.get("backend", {}),
|
||||
"defaults": defaults,
|
||||
"loop": raw.get("loop", {}),
|
||||
"plan_dir": str(SCRIPT_DIR),
|
||||
"plan_dir": str(SCRIPT_DIR.parent.parent / "archive/original-build/cc-ci-plan"),
|
||||
"log_dir": defaults.get("log_dir", "/srv/cc-ci/.cc-ci-logs"),
|
||||
"session_prefix": defaults.get("session_prefix", "cc-ci-"),
|
||||
}
|
||||
@@ -210,9 +210,9 @@ def build_loop_kickoff(cfg, agent):
|
||||
pid, plan, status = ph["id"], ph["plan"], ph["status"]
|
||||
preamble = (
|
||||
f"*** cc-ci SUB-PHASE {pid} ***\n"
|
||||
f"SINGLE SOURCE OF TRUTH for THIS phase: /srv/cc-ci/cc-ci-plan/{plan} — read it in full "
|
||||
f"SINGLE SOURCE OF TRUTH for THIS phase: /srv/cc-ci/scripts/cc-ci/{plan} — read it in full "
|
||||
f"now; it defines this phase's mission and Definition of Done.\n"
|
||||
f"The general loop protocol still applies and lives in /srv/cc-ci/cc-ci-plan/plan.md "
|
||||
f"The general loop protocol still applies and lives in /srv/cc-ci/archive/original-build/cc-ci-plan/plan.md "
|
||||
f"(§6.1 coordination, §7 pacing, §9 guardrails) — read those sections too.\n"
|
||||
f"Track loop state in PHASE-NAMESPACED files UNDER machine-docs/ in your repo clone "
|
||||
f"(create the dir if missing): machine-docs/{status}, machine-docs/BACKLOG-{pid}.md, "
|
||||
|
||||
@@ -34,7 +34,7 @@ supports_resume = false
|
||||
prompt_delivery = "ping" # send after the TUI connects
|
||||
connect_delay = 12
|
||||
submit_key = "C-m"
|
||||
preamble = "set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a"
|
||||
preamble = "set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a"
|
||||
stall_idle = 900
|
||||
active_re = "esc interrupt|thinking|inferring|running tool|tool call|preparing patch|reading|searching"
|
||||
limit_re = "spend limit|usage limit|limit reached|reached your .*limit|out of (credits|tokens)"
|
||||
@@ -72,7 +72,7 @@ resume = true
|
||||
watch = "none"
|
||||
enabled = false
|
||||
prompt = """
|
||||
You are the cc-ci ASSISTANT. Read cc-ci-plan/JOURNAL.md for context, then wait for a specific \
|
||||
You are the cc-ci ASSISTANT. Read data/cc-ci/JOURNAL.md for context, then wait for a specific \
|
||||
plan/task from the orchestrator or operator. Work autonomously until the assigned task is \
|
||||
complete, report the result, and then wait for the next assignment."""
|
||||
|
||||
@@ -101,5 +101,5 @@ You generate the public weekly "Recipe Report". Run the /recipe-report skill now
|
||||
# Non-AI helper services (started by `up`, not AI sessions)
|
||||
[[service]]
|
||||
name = "cleanlogs" # tmux session: cc-ci-cleanlogs
|
||||
command = "python3 cc-ci-plan/agent-log.py follow-all"
|
||||
command = "python3 scripts/cc-ci/agent-log.py follow-all"
|
||||
dir = "/srv/cc-ci-orch"
|
||||
|
||||
@@ -7,9 +7,9 @@ Anything the two disagree on is a miscategorization in one of them.
|
||||
"""
|
||||
import importlib.util, json, re, sys
|
||||
|
||||
spec = importlib.util.spec_from_file_location("A", "/srv/cc-ci-orch/cc-ci-plan/advisory-scan.py")
|
||||
spec = importlib.util.spec_from_file_location("A", "/srv/cc-ci-orch/scripts/cc-ci/advisory-scan.py")
|
||||
A = importlib.util.module_from_spec(spec); spec.loader.exec_module(A)
|
||||
REG = "/srv/cc-ci-orch/cc-ci-plan/upstream"
|
||||
REG = "/srv/cc-ci-orch/data/cc-ci/upstream"
|
||||
|
||||
|
||||
def sv(s):
|
||||
|
||||
@@ -47,8 +47,8 @@ _aspec = importlib.util.spec_from_file_location("advisory_scan", os.path.join(HE
|
||||
A = importlib.util.module_from_spec(_aspec)
|
||||
_aspec.loader.exec_module(A)
|
||||
|
||||
REGISTRY_DIR = os.environ.get("CCCI_UPSTREAM_REGISTRY", os.path.join(HERE, "upstream"))
|
||||
USED_RECIPES = os.path.join(HERE, "used-recipes.md")
|
||||
REGISTRY_DIR = os.environ.get("CCCI_UPSTREAM_REGISTRY", os.path.join(HERE, "../../data/cc-ci/upstream"))
|
||||
USED_RECIPES = os.path.join(HERE, "../../data/cc-ci/used-recipes.md")
|
||||
DEPRECATION_RE = re.compile(
|
||||
r"\b(deprecat|no longer maintain|unmaintained|superseded|moved to|migrated to|"
|
||||
r"has moved|discontinued|end.of.life|archived)\b", re.I)
|
||||
@@ -194,7 +194,7 @@ def audit_recipe(recipe: str, ssh: str | None, quiet_days: int) -> dict:
|
||||
pass
|
||||
if reg_path is None:
|
||||
out["findings"].append({"level": "warn", "what": "no upstream registry file",
|
||||
"detail": f"cc-ci-plan/upstream/{recipe}.md is missing — the advisory "
|
||||
"detail": f"data/cc-ci/upstream/{recipe}.md is missing — the advisory "
|
||||
f"scan has nowhere to look"})
|
||||
seen = set()
|
||||
for u in urls:
|
||||
|
||||
@@ -37,7 +37,7 @@ REMOTE_CONTROL = os.environ.get("REMOTE_CONTROL", "1") == "1"
|
||||
DEFAULT_ID = "9db267a4-9b9e-4818-8197-0a42dba443ea"
|
||||
ID_FILE = os.environ.get("ASSISTANT_ID_FILE", f"{LOG_DIR}/.assistant-session-id")
|
||||
STARTUP_PROMPT = os.environ.get("ASSISTANT_STARTUP_PROMPT", (
|
||||
"You are the cc-ci ASSISTANT. Read cc-ci-plan/JOURNAL.md for context, then wait for a "
|
||||
"You are the cc-ci ASSISTANT. Read data/cc-ci/JOURNAL.md for context, then wait for a "
|
||||
"specific plan/task from the orchestrator or operator. Work autonomously until the assigned "
|
||||
"task is complete, report the result, and then wait for the next assignment."
|
||||
))
|
||||
@@ -112,7 +112,7 @@ def start(mode="resume"):
|
||||
if not Path(OPENCODE_BIN).exists():
|
||||
die(f"opencode not found at {OPENCODE_BIN}")
|
||||
cmd = (
|
||||
f"set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a; "
|
||||
f"set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a; "
|
||||
f"NO_COLOR=1 {OPENCODE_BIN} attach {OPENCODE_SERVER} --dir {WORKDIR}"
|
||||
)
|
||||
log(f"starting {SESSION} (backend=opencode, model={LOOP_MODEL or 'default'})")
|
||||
|
||||
@@ -112,7 +112,7 @@ def start(mode, date):
|
||||
cwd = "/srv/cc-ci-orch/cc-ci"
|
||||
share_flag = "--share" if OPENCODE_SHARE else ""
|
||||
cmd = (
|
||||
f"set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a; "
|
||||
f"set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a; "
|
||||
f"{OPENCODE_BIN} run {model_flag} {share_flag} --attach '{OPENCODE_SERVER}' "
|
||||
f"--title '{SESSION}' --dir {cwd} \"$(cat '{kf}')\""
|
||||
)
|
||||
@@ -134,7 +134,7 @@ def start(mode, date):
|
||||
# runs under the tmux server (survives the systemd oneshot like the run sessions).
|
||||
if os.environ.get("REPORT_WATCHDOG", "1") == "1":
|
||||
import shlex
|
||||
LU = "/srv/cc-ci/cc-ci-plan/launch-upgrader.py"
|
||||
LU = "/srv/cc-ci/scripts/cc-ci/launch-upgrader.py"
|
||||
rf = Path(LOG_DIR) / f".kickoff-{SESSION}-resume.txt"
|
||||
rf.write_text(
|
||||
"The opencode usage limit has reset (or the report stalled). CONTINUE generating and "
|
||||
|
||||
@@ -80,12 +80,12 @@ DO THIS, in order — stop as soon as the run is healthy again:
|
||||
`GET /session/{sid}/message`) and the open recipe PRs to see which enrolled recipes already have
|
||||
a PR this week and which remain. Do NOT redo any recipe that already has a PR.
|
||||
3. DRIVE TO COMPLETION. Prefer to RESUME the existing run (context preserved) once the environment
|
||||
is healthy: `python3 {WORKDIR}/cc-ci-plan/launch-upgrader.py resume`. Then CONFIRM it actually
|
||||
is healthy: `python3 {WORKDIR}/scripts/cc-ci/launch-upgrader.py resume`. Then CONFIRM it actually
|
||||
restarted and is progressing (a fresh `opencode run … -s {sid} --continue` proc + the session
|
||||
advancing). If the session is truly gone/unresumable, drive the remaining recipes yourself the
|
||||
/upgrade-all way (per-recipe /recipe-upgrade DEFAULT-mode subagents, !testme verify), then make
|
||||
sure the weekly summary is written to {WORKDIR}/.cc-ci-logs/upgrades/ and launch the public
|
||||
report: `python3 {WORKDIR}/cc-ci-plan/launch-report.py fresh`.
|
||||
report: `python3 {WORKDIR}/scripts/cc-ci/launch-report.py fresh`.
|
||||
4. If on inspection the run is actually FINE (progressing) or already COMPLETE, do NOTHING.
|
||||
5. Print `SUPERVISOR DONE` and go idle. Do NOT loop.
|
||||
|
||||
@@ -107,7 +107,7 @@ def spawn_supervisor(sid, reason):
|
||||
kf = Path(LOG_DIR) / f".kickoff-{SUP_SESSION}.txt"
|
||||
kf.write_text(build_kickoff(sid, reason))
|
||||
share = "--share" if OPENCODE_SHARE else ""
|
||||
cmd = (f"set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a; {OPENCODE_BIN} run --model '{MODEL}' {share} "
|
||||
cmd = (f"set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a; {OPENCODE_BIN} run --model '{MODEL}' {share} "
|
||||
f"--attach '{OPENCODE_SERVER}' --title '{SUP_SESSION}' --dir {WORKDIR} \"$(cat '{kf}')\"")
|
||||
_sh(["tmux", "new-session", "-d", "-s", SUP_SESSION, "-c", WORKDIR, cmd])
|
||||
_sh(["tmux", "pipe-pane", "-o", "-t", SUP_SESSION, f"cat >> '{LOG_DIR}/{SUP_SESSION}.log'"])
|
||||
|
||||
@@ -220,7 +220,7 @@ def start(mode="use-or-create"):
|
||||
# so they must come AFTER `run` (a global `opencode --model X run` is ignored).
|
||||
share_flag = "--share" if OPENCODE_SHARE else ""
|
||||
cmd = (
|
||||
f"set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a; "
|
||||
f"set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a; "
|
||||
f"{OPENCODE_BIN} run {model_flag} {share_flag} --attach '{OPENCODE_SERVER}' "
|
||||
f"--title '{SESSION}' \"$(cat '{kf}')\""
|
||||
)
|
||||
@@ -522,10 +522,10 @@ def resume(reason="manual"):
|
||||
"!testme, open/extend the recipe PR (NEVER merge, NEVER weaken a test), <= DRONE_RUNNER_CAPACITY "
|
||||
"concurrent. immich has a tag+digest image abra can't parse — do the upstream-direct cross-check "
|
||||
"(recipe-upgrade SKILL §1), don't silently skip it. When all remaining recipes are done: "
|
||||
"write+push the weekly summary, then `python3 /srv/cc-ci/cc-ci-plan/launch-report.py fresh`, print "
|
||||
"write+push the weekly summary, then `python3 /srv/cc-ci/scripts/cc-ci/launch-report.py fresh`, print "
|
||||
"'" + DONE_MARKER + "', and go idle.")
|
||||
share = "--share" if OPENCODE_SHARE else ""
|
||||
cmd = (f"set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a; {OPENCODE_BIN} run -s {sid} --continue "
|
||||
cmd = (f"set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a; {OPENCODE_BIN} run -s {sid} --continue "
|
||||
f"--model '{MODEL}' {share} --attach '{OPENCODE_SERVER}' --dir '{WORKDIR}' \"$(cat '{kf}')\"")
|
||||
subprocess.run(["tmux", "new-session", "-d", "-s", SESSION, "-c", WORKDIR, cmd])
|
||||
subprocess.run(["tmux", "pipe-pane", "-o", "-t", SESSION, f"cat >> '{LOG_FILE}'"])
|
||||
|
||||
@@ -38,7 +38,7 @@ import urllib.request
|
||||
from datetime import datetime, timezone
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
USED_RECIPES = os.path.join(HERE, "used-recipes.md")
|
||||
USED_RECIPES = os.path.join(HERE, "../../data/cc-ci/used-recipes.md")
|
||||
TESTENV = os.environ.get("CCCI_TESTENV", "/srv/cc-ci/.testenv")
|
||||
PUBLIC_ENV = "/srv/cc-ci/cc-ci/.env.public"
|
||||
NS = "recipe-maintainers"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# only logs when the current boot_id differs from the last one we recorded.
|
||||
set -u
|
||||
|
||||
REBOOTS="/srv/cc-ci/cc-ci-plan/REBOOTS.md"
|
||||
REBOOTS="/srv/cc-ci/data/cc-ci/REBOOTS.md"
|
||||
LAST_BOOT_FILE="/srv/cc-ci/.cc-ci-logs/.last-boot-id"
|
||||
PHASE_IDX_FILE="/srv/cc-ci/.cc-ci-logs/.phase-idx"
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ RECONCILE="${RECONCILE:-$ORCH/.claude/skills/recipe-upgrade/open-recipe-pr.sh}"
|
||||
USED_RECIPES="${USED_RECIPES:-$HERE/used-recipes.md}"
|
||||
|
||||
[ -f "$RECONCILE" ] || { echo "ERROR: reconcile helper not found: $RECONCILE" >&2; exit 1; }
|
||||
set -a; . /srv/cc-ci/cc-ci-plan/load-env.sh; set +a
|
||||
set -a; . /srv/cc-ci/scripts/cc-ci/load-env.sh; set +a
|
||||
: "${GITEA_USERNAME:?}"; : "${GITEA_PASSWORD:?}"; : "${GITEA_URL:=git.autonomic.zone}"
|
||||
|
||||
if [ "${1:-}" = "--all" ]; then
|
||||
|
||||
@@ -163,17 +163,17 @@ class TestRegistryUrls(unittest.TestCase):
|
||||
self.assertEqual(urls, ["https://github.com/cryptpad/cryptpad"])
|
||||
|
||||
def test_image_source_table_maps_monorepo_images(self):
|
||||
mapping = A.registry_image_sources("lasuite-drive", str(HERE / "upstream"))
|
||||
mapping = A.registry_image_sources("lasuite-drive", str(HERE / "../../data/cc-ci/upstream"))
|
||||
self.assertIn("github-advisories:suitenumerique/drive", mapping["drive-backend"])
|
||||
self.assertIn("github-advisories:CollaboraOnline/online", mapping["code"])
|
||||
|
||||
def test_common_database_cpes_follow_registry_images(self):
|
||||
self.assertIn(("postgres", A.COMMON_IMAGE_CPES["postgres"]),
|
||||
A.registry_cpes("immich", str(HERE / "upstream")))
|
||||
A.registry_cpes("immich", str(HERE / "../../data/cc-ci/upstream")))
|
||||
self.assertIn(("mariadb", A.COMMON_IMAGE_CPES["mariadb"]),
|
||||
A.registry_cpes("gitea", str(HERE / "upstream")))
|
||||
A.registry_cpes("gitea", str(HERE / "../../data/cc-ci/upstream")))
|
||||
self.assertIn(("rustdesk-server", "cpe:2.3:a:rustdesk:rustdesk_server:*:*:*:*:oss:*:*:*"),
|
||||
A.registry_cpes("rustdesk-server", str(HERE / "upstream")))
|
||||
A.registry_cpes("rustdesk-server", str(HERE / "../../data/cc-ci/upstream")))
|
||||
|
||||
def test_strips_trailing_markdown_punctuation(self):
|
||||
# Production defect: a captured backtick 404'd the fetch and rendered n8n/immich as '?'.
|
||||
@@ -880,7 +880,7 @@ class TestMarkdownOutput(unittest.TestCase):
|
||||
class TestHistoricReportNumbers(unittest.TestCase):
|
||||
"""Re-derive counts published in week-2026-08-07. Network + GitHub token; opt in with --live."""
|
||||
|
||||
REGISTRY = str(HERE / "upstream")
|
||||
REGISTRY = str(HERE / "../../data/cc-ci/upstream")
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../cc-ci-plan/upstream
|
||||
@@ -1 +0,0 @@
|
||||
../../cc-ci-plan/used-recipes.md
|
||||
Reference in New Issue
Block a user