From f0d5eafcac0254cff69752641464a00b821b9941 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 22 Nov 2026 22:09:28 +0000 Subject: [PATCH] feat(ci): kvb-ci-track keeps one fingerprinted list of CI failures until each is acked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New skill kvb-ci-track: track.py add/poll/wait/ack/known follows workflow runs, PR checks, code-scanning and secret alerts and issues, clusters each failing job by its failing line (ci_failures.failing, now split from signature without a change in behaviour), fingerprints every cluster, and prints only clusters nobody acked yet. A failing line that matches a hotfix register signature carries that hotfix as a hint. kvb-ci-observe and kvb-ci-triage poll through it instead of re-reading every log; kvb-ci-artifacts names failing(). Untrusted text never reaches the terminal raw: printable() drops every character str.isprintable() refuses (escape sequences, zero-width characters), a tab or other whitespace control becoming a space. masked() runs it before hiding URL credentials, assigned secrets and 24-character tokens, and report() cleans every cell, so a log line, title or job name cannot send a terminal sequence, forge a tab-separated cell or dodge an ack with an invisible character. Tests: tests/test_ci_track.py, including test_control_and_zero_width_characters_never_reach_a_cell. Written, not run: the full suite runs once on master after all bundles (operator order). Both new expectations checked inline; ci_failures.signature() proven identical on every path, the empty-log sentinel included. Security: MEDUSA over the staged tree on master: 100, 8 files covered, 0 findings. 6 low findings accepted as false positives after a skeptic review and the operator's accept on 2026-11-22: MP-SCAN-1781 at track.py 516, 557, 571, 572 and MP-SCAN-1878 at 557, 571, all on the word 'ack' in the CLI's own subcommand and messages. 🎯 Fix: 90 % 💥 Break: 4 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 86 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- README.md | 6 + skills/kvb-ci-artifacts/SKILL.md | 4 +- .../kvb-ci-artifacts/scripts/ci_failures.py | 15 +- skills/kvb-ci-observe/SKILL.md | 46 +- skills/kvb-ci-track/SKILL.md | 57 ++ skills/kvb-ci-track/scripts/track.py | 587 ++++++++++++++++++ skills/kvb-ci-triage/SKILL.md | 9 +- tests/test_ci_track.py | 251 ++++++++ 8 files changed, 946 insertions(+), 29 deletions(-) create mode 100644 skills/kvb-ci-track/SKILL.md create mode 100755 skills/kvb-ci-track/scripts/track.py create mode 100644 tests/test_ci_track.py diff --git a/README.md b/README.md index 80913bc..56f2094 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ flowchart LR ci --> ci_triage[kvb-ci-triage] ci --> ci_artifacts[kvb-ci-artifacts] ci --> ci_observe[kvb-ci-observe] + ci --> ci_track[kvb-ci-track] git --> git_commit_next[kvb-git-commit-next] git --> git_commit_no_verify[kvb-git-commit-no-verify] git --> git_merge_fix[kvb-git-merge-fix] @@ -160,6 +161,7 @@ flowchart LR triage[kvb-ci-triage] ci_artifacts[kvb-ci-artifacts] observe[kvb-ci-observe] + track[kvb-ci-track] end subgraph cat_git [git] commit_next[kvb-git-commit-next] @@ -339,6 +341,10 @@ flowchart LR observe --> triage observe --> ci_artifacts + observe --> track + triage --> track + track --> ci_artifacts + track --> hotfix triage --> ci_artifacts triage --> democracy triage --> dialectic diff --git a/skills/kvb-ci-artifacts/SKILL.md b/skills/kvb-ci-artifacts/SKILL.md index bb3db5d..aa0f2b9 100644 --- a/skills/kvb-ci-artifacts/SKILL.md +++ b/skills/kvb-ci-artifacts/SKILL.md @@ -1,8 +1,8 @@ --- name: kvb-ci-artifacts description: > - Pull failed CI job logs (also mid-run), clustered by error line, and - cause-holding artifacts. Trigger to explain a CI failure, and from triage. + Pull failed CI job logs, clustered by error line, and cause-holding + artifacts. Trigger to explain a CI failure. --- A job log tells you what broke. An artifact tells you why. diff --git a/skills/kvb-ci-artifacts/scripts/ci_failures.py b/skills/kvb-ci-artifacts/scripts/ci_failures.py index e8174fc..b65eda7 100755 --- a/skills/kvb-ci-artifacts/scripts/ci_failures.py +++ b/skills/kvb-ci-artifacts/scripts/ci_failures.py @@ -92,7 +92,12 @@ def is_lint(lines: list[tuple[str, str]], index: int) -> bool: return bool(LINT_CODE.match(line) and LINT_ARROW.match(following)) -def signature(text: str) -> str: +def failing(text: str) -> str: + """Returns: + The line that ended the job, as the log holds it: the last annotation, + else the last fatal line after its task, lint finding or error word, + else the last kept line. + """ lines = output_lines(text) tiers = ( (lambda i: ANNOTATION.search(lines[i][1]), False), @@ -105,8 +110,12 @@ def signature(text: str) -> str: if matches(index): task, line = lines[index] found = ANNOTATION.sub("", line).strip() - return normalise(f"{task} {found}" if with_task and task else found) - return normalise(lines[-1][1]) if lines else "" + return f"{task} {found}" if with_task and task else found + return lines[-1][1] if lines else "" + + +def signature(text: str) -> str: + return normalise(failing(text)) def cluster(jobs: list[tuple[str, str]]) -> dict[str, list[str]]: diff --git a/skills/kvb-ci-observe/SKILL.md b/skills/kvb-ci-observe/SKILL.md index 8c1818b..d88033a 100644 --- a/skills/kvb-ci-observe/SKILL.md +++ b/skills/kvb-ci-observe/SKILL.md @@ -1,8 +1,8 @@ --- name: kvb-ci-observe description: > - Watch a CI run, pipeline, build or log on a cadence, triaging and fixing - new failures. Trigger when asked to keep monitoring. + Watch a CI run, pipeline, build or log, triaging and fixing new failures. + Trigger when asked to keep monitoring. --- Keep a target under watch and act only when it degrades: the loop watches, @@ -19,37 +19,43 @@ re-triages solved failures. ## The loop -Drive it with `/loop` in dynamic mode (no fixed interval unless the operator -gave one): after each observation, schedule the next wake-up and pass this -skill's prompt back unchanged. +A GitHub Actions run, a pull request's checks, scanning alerts and issues +run on the `kvb-ci-track` skill: `track.py add` the target, then +`track.py wait` as a background task; its end is the wake-up and its lines +are the new clusters, already diffed against what any agent saw or acked. +Any other target (another CI system, a build, a log file) runs on `/loop` +in dynamic mode (no fixed interval unless the operator gave one): after each +observation, schedule the next wake-up and pass this skill's prompt back +unchanged. -1. **Poll the target**: its job list, check conclusions or log tail; for a - GitHub Actions run, the `kvb-ci-artifacts` skill's `ci_failures.py `. - Enumerate failures as the `kvb-ci-triage` skill's step 1 does: failure, - cancelled, timed-out; a downstream aggregate that fails only because an - upstream did is not its own failure. +1. **Poll the target**: the lines `wait` printed; elsewhere its job list, + check conclusions or log tail. Enumerate failures as the `kvb-ci-triage` + skill's step 1 does: failure, cancelled, timed-out; a downstream + aggregate that fails only because an upstream did is not its own failure. 2. **Diff against the baseline.** A failure is new only if it is neither in - the baseline nor triaged this session. Nothing new: log one short line - ("still green" / "N known failures, no change") and reschedule. + the baseline nor triaged this session; `track.py` keeps that baseline + for its targets. Nothing new: log one short line ("still green" / "N + known failures, no change") and wait again. 3. **Triage each new failure** with the `kvb-ci-triage` skill on the new set only; it applies `kvb-think-dialectic` per failing job to a ~99% root cause and a real fix. Never mask (no retry-until-pass, disabled check or soft skip). A new failure and its verdict go to peers by radio, never with a wake: `${CLAUDE_SKILL_DIR}/../kvb-org-radio/scripts/radio.py post ": -> "`. Fold each newly fixed - failure into the baseline. -4. **Reschedule** by what you wait on: an active run that changes every few - minutes gets a check matched to its cadence, a quiet or long-running - target a long fallback (1200s+). Stop once the target reaches a terminal - state (run completed, pipeline finished) AND every failure it produced + failure into the baseline: `track.py ack --verdict + ''`. +4. **Wait again** by what you wait on: an active run that changes every few + minutes gets an interval matched to its cadence, a quiet or long-running + target a long one (1200s+). Stop once the target reaches a terminal + state (`wait` exit 20, a pipeline finished) AND every failure it produced has a verified fix. ## Rules - The loop is a fallback timer, not a busy-wait: for tracked work the - harness reports (a background task, a spawned agent), wait for that - notification; reserve the timed wake-up for state the harness cannot see - (a remote CI run, a deploy queue). + harness reports (a background task, a spawned agent, `track.py wait`), + wait for that notification; reserve the timed wake-up for state neither + the harness nor `track.py` can see (another CI system, a deploy queue). - Executed evidence beats reasoning: read the failing log line and the artifact, not the job title. - One baseline, updated in place: dedup every observation against all diff --git a/skills/kvb-ci-track/SKILL.md b/skills/kvb-ci-track/SKILL.md new file mode 100644 index 0000000..9c4af19 --- /dev/null +++ b/skills/kvb-ci-track/SKILL.md @@ -0,0 +1,57 @@ +--- +name: kvb-ci-track +description: > + Track CI runs, PR checks, alerts, issues; wake on new failures. +--- + +`${CLAUDE_SKILL_DIR}/scripts/track.py` keeps one JSON file per target in the +shared council directory, so every agent sees what was already reported and +triaged. Its docstring holds the full contract. + +```bash +track.py add run [--rules ] +track.py add pr [--rules ] +track.py add alerts --codeql --secrets +track.py add issues [--label ...] +track.py poll [ ...] +track.py wait [ ...] --interval --timeout +track.py ack --verdict '' +``` + +## Watch + +1. `add` prints the target id. Pass `--rules` the repository's own rules + file when it has one: failing-line regexes such as Ansible's `fatal:` with + its last `TASK`, or Playwright's `✘ ::` with its first + `Error:`. +2. Start `wait` as a background task (Claude Code: `run_in_background`; + elsewhere the runtime's equivalent), the interval matched to how fast the + target changes: about 300 s for a running matrix, 1800 s for alerts or + issues. Its end is the wake-up; never `/loop`, cron or a shell loop over + `poll`. +3. On its end, read the exit code: + - **10**: each printed line is one new cluster: fingerprint, target, + label, job count, failing line and any matching hotfix. Triage it with + the `kvb-ci-triage` skill, then start `wait` again. + - **20**: every target terminal, every cluster acked: the watch is done. + - **30**: every target terminal, a cluster still unacked: finish its + triage and ack it. + - **3**: gh failed (auth, network, a broken rules file); the reason is on + stderr. **0**: timeout, nothing new: start `wait` again. + +## Ack + +Once a cluster has its verdict (fixed, flake proven transient, fixed by a +later commit), `ack` it. The ack silences that fingerprint in every target, +so the same failure in the next run stays quiet. Never ack a cluster just to +quiet it; an ack without a verdict is refused. + +## Rules + +- One line per new cluster; alerts carry the rule id or secret type and + path:line, never a secret value. Every line is masked, but treat it like a + log line: quote it, never widen it with the raw log. +- The failing line is a lead. The log and artifacts (`kvb-ci-artifacts`) + stay the evidence. +- A hotfix hint lists every repository's hotfixes; confirm it with + `hotfix.py match --repo ` before you sync. diff --git a/skills/kvb-ci-track/scripts/track.py b/skills/kvb-ci-track/scripts/track.py new file mode 100755 index 0000000..fcb31be --- /dev/null +++ b/skills/kvb-ci-track/scripts/track.py @@ -0,0 +1,587 @@ +#!/usr/bin/env python3 +"""Track CI runs, pull request checks, scanning alerts and issues; report only what is new. + +Environment: + AGENTS_COUNCIL_ROOT, XDG_STATE_HOME, HOME: the council directory the + kvb-org-organize councilroot.py resolves; each target is one JSON file + in its track/ directory, the acks are track/acks.json. + +Args: + add run [--rules ]: one Actions run. + add pr [--rules ]: every Actions run of the + pull request's current head commit. + add alerts [--codeql] [--secrets]: the open code scanning + and secret scanning alerts; at least one flag. + add issues [--label ...]: the open issues carrying + every label given. + add prints the target id; adding a tracked target again keeps its + clusters, sets the rules anew and polls it again after it ended. + --rules is a JSON file of the calling repository: {"job_name": + [, ...], "lines": [{"id": , "match": , "pick": + "first"|"last", "context": , "side": "before"|"after"}, ...]}. + Each job_name regex is cut from a job name after the matrix list + " (...)"; the first lines rule whose match hits a kept output line + of ci_failures.py makes the failing line, joined with the nearest + context line on its side when one is given; without a hit + ci_failures.py's failing line stands. Every regex passes + kvb-git-hotfix's backtracking check. + poll [ ...]: one pass over the targets. + wait [ ...] --interval --timeout : poll every + interval seconds inside this process until a poll exits 10, 20 or + 30, ERRORS polls in a row exit 3, or the next poll would start after + the timeout; run it as a background task, its end wakes the agent. + ack --verdict : silence a triaged cluster in every + target, as an Alertmanager silence does. + +Output: + poll and wait print one line per cluster no earlier poll of the target + saw and no ack silences: + `\\t\\t