Skip to content

fork-kit: gardener kit, a daily report issue per project (#1064, phase 1) - #1068

Merged
scuttletoby merged 5 commits into
mainfrom
gardener-1064
Nov 23, 2026
Merged

scuttletoby merged 5 commits into
mainfrom
gardener-1064

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Part of #1064 (Phase 1).

What

A new kit, fork-kit/gardener: gardener run [--project NAME] [--dry-run] [--force] [--timer] runs each project's checks once a day and keeps one report issue per project, updated in place. It reports only, unless a check's config says "fix": true.

  • Check contract: any executable; the context comes in as JSON on stdin, and it prints JSON lines {id, severity, where, text, fix}. Each check has its own timeout and runs in its own process group. Output is read as it comes and stopped at 256 KiB (the process group is killed), so a check that prints forever costs no memory. A check that hangs, exits non-zero, prints junk or too much, or cannot start becomes exactly one gardener.check-failed finding, and the next check still runs. Any error inside the gardener on one check, or in one project, never stops the others.
  • Config: the machine file's "gardener" section (projects, schedule or quiet hours, time zone, optional model, checks). Project checks are given by path; the kit never names them. Typos are refused whole.
  • General checks: context-budget, facts (facts --check --no-records in the project root, never --all), worktrees (merged, gone or stale worktrees and branches; its fix is git worktree prune only), workflows-off, install-drift.
  • Report issue: found by title, then by a hidden marker <!-- gardener-report:NAME -->. Text a person writes above the marker is kept. A closed issue, or one whose marker was edited away, is left alone and a new issue is opened. The report repo may be public, so the issue is built from an allow-list: only repo-relative paths; findings outside the repo are counted (<outside repo>); paths (also Windows drive and UNC paths), URLs, IPv4/IPv6 addresses, e-mails and user@host in text are masked, and the root and home only as whole folders; a project check's own text and fix are shown only with "publicText": true (otherwise its id, count and location), and hidden findings show no id; a private project repo that reports to another, not-private repo publishes counts only (fail closed: an unreadable visibility counts as private); a failed check shows its id and exit code, never its stderr; the model endpoint is never shown. The full report stays on the machine (report.md). The whole body, a person's text too, is size-capped. Each run makes at most one issue read, two searches and one write, plus up to two visibility reads when the report repo is not the project repo. A GitHub error exits 1, but the done marker is already written: later ticks retry the issue alone, at most 3 times a day. --dry-run prints both reports and writes nothing.
  • Judgment: interface only. With model {endpoint, model}, one OpenAI-style /chat/completions request sends the public findings and a few capped git-tracked files (never ignored or untracked ones). Its answer is masked like the rest. Any endpoint error (non-HTTP too) is a note ("model unreachable"). There is no paid-model fallback.
  • State: <stateDir>/<name>/state.json holds the done marker for the day (--force runs again), the issue number, the pending-report retry count and the report repo (a changed reportRepo runs the day again for the new repo). Writes are atomic. A lock per project. Missing, broken or old-version state is read as empty and noted in the report; a newer version is refused and kept. With quiet hours that wrap past midnight, the day is the window's start (one run per window).
  • Install: gardener-install (kit_install) and bootstrap --kit gardener [--timer], which writes hourly user timer units to /etc/systemd/user. Installing never enables the timer; it is not enabled on any machine.

State question

Runs again the same day: nothing happens and no API call is made. Stopped half-way: before the done marker, the run starts again; after it, the saved issue.md is sent alone on the next tick, and the title/marker search finds an issue whose number was not saved, so no second issue is made. A report repo that keeps failing: 3 tries a day, the checks do not rerun. Old, empty or broken state: read as empty, with a note; old state without reportRepo runs once more and finds its issue by title. Two runs at once: the second skips on the lock. One project failing does not stop the others. All of these have tests.

Tests

fork-kit/gardener/tests/{run,report,checks,install}.test.py, 109 tests (38 + 30 + 31 + 10), all unittest and listed in .github/fork-ci-tests.txt. They cover:

  • state that is empty, missing, broken or old
  • a second run the same day, and --force
  • a stop after the issue write
  • a check that hangs (its child processes are killed too), one that prints junk, one that exits non-zero, one that cannot start
  • a report issue that is missing, closed, has its marker removed, or has hand-written text above the marker
  • a GitHub or rate-limit error
  • dry run, the lock, the timer window and wrapped quiet hours
  • the judge against a local fake HTTP model, and against an unreachable one
  • each general check on temporary git repos and fixture files
  • the installer
  • review fixes: a check that prints forever under a small RLIMIT_AS (stopped at the cap in under a second, the next project runs); a MemoryError in one check and in one project; an end-to-end privacy run of all five general checks plus a leaky project check, asserting no host, address, home path, private name or endpoint port reaches the issue; a junk-speaking model socket; a too-long hand-written head; repeated report failures; a newer state file; a window past midnight; branch names with shell characters; a fresh worktree, also one made from origin/main; a broken SKILL.md link; round 2: a sibling folder of the root, user@host, compressed IPv6, Windows and UNC paths, publicText off and on, counts only for a private project repo (and a failed visibility read), a reportRepo change the same day, a ~/ path in fix hints

A RedCheck in run, report, checks and install breaks each guard and shows its test fails. kit_install.test.py: 189 pass. Shared tests updated: kit_install.test.py (a Gardener contract class and bootstrap arms) and fork-ci-release.test.py (KITS row).

General vs project

General (this PR): the runner, check contract, report issue, state, the five general checks, installer and timer templates. All of it lives in the fork, with no project named.
Project: which projects, repos, folders, budgets, schedules and project checks (by path) live only in each machine's /etc/fork-kit/machine.json "gardener" section; machine.example.json uses placeholders. Test data uses only invented names (example-owner, client-acme, VM900, 100.64.0.1). Phase 2 (turning it on for a project, project checks) is not in this PR.

🤖 Generated with Claude Code

scuttletoby and others added 5 commits November 23, 2026 18:45
…e 1)

gardener run [--project NAME] [--dry-run] [--force] [--timer] runs each
project's checks once a day (done marker per project per day; --force
runs again) and writes one report issue per project, found by a hidden
marker and updated in place. Report only unless a check sets "fix".

- Check contract: JSON context on stdin, JSON-line findings on stdout;
  per-check timeout in its own process group; any failure is exactly
  one finding and never stops the run.
- Config: the machine file's "gardener" section; project checks by path.
- General checks: context-budget, facts (current project, never --all),
  worktrees, workflows-off, install-drift.
- Report issue: closed or de-marked issues are left alone; hand-written
  text above the marker is kept; local paths redacted; at most one read,
  one search, one write per run; errors exit 1 with no done marker.
- Judgment: interface only (gardener.model, OpenAI-style endpoint); an
  unreachable model is a note; no paid fallback.
- gardener-install + bootstrap --kit gardener [--timer]: hourly user
  timer units; installing never enables them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gardener runs reports on machines; the merge gate reads none of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iew fixes)

Fixes from the #1068 review:
- B1: check output is read as it comes and stopped at 256 KiB (process group
  killed); stderr keeps its last 4 KiB. Any error inside the gardener on one
  check is one finding; any error in one project never stops the others.
- B2: the report issue is built from an allow-list. Only repo-relative
  paths; findings outside the repo are counted; local names are masked; a
  failed check shows its id and exit code, not stderr; the model endpoint is
  never shown; the judge reads only git-tracked files and its answer is
  masked. The full report stays local (report.md).
- S1: the judge catches every error (a non-HTTP endpoint too).
- S2: the done marker is written before the issue; a failed issue write is
  retried alone, at most 3 times a day. The whole body, a person's text
  too, is held under the size limit.
- S3: fix hints quote every name. S4: a fresh worktree is not "merged".
- M1-M6: a newer state is refused; a window past midnight is one day; the
  issue is searched by title too; a broken SKILL.md link is a warning; the
  uninstall says "disable first" before it removes; the test prefix is an
  environment variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- worktrees: a branch whose upstream is the base itself (worktree add -b X
  PATH origin/main) is not pushed work, so it is never "merged"; a ~/ repos
  path stays expandable in fix hints.
- report: the root and home are replaced only at a folder boundary; masks for
  user@host, compressed IPv6 (also ::), Windows drive and UNC paths.
- A project check's text and fix reach the issue only with publicText: true;
  otherwise its id, count and where. Hidden (outside/no-where) findings show
  no id.
- A private (or unknown) project repo that reports to another, not-private
  repo publishes counts only, and no judgment.
- state keeps reportRepo; a change runs the day again for the new repo and
  drops the old issue number.
- README: publicText, counts only, new masks, a warning for check authors,
  visibility reads, the reportRepo state key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scuttletoby
scuttletoby merged commit 9941b26 into main Nov 23, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant