diff --git a/.skills/doc-sections b/.skills/doc-sections index af2d2ac..a08bc0e 100644 --- a/.skills/doc-sections +++ b/.skills/doc-sections @@ -8,7 +8,7 @@ docs/specs/2026-09-29-processor-service-design.md: a behaviour change under src/ AGENTS.md: the co-core pin and the co-pypi index under Environment & Tooling (pyproject.toml, uv.lock); the Infrastructure table (deploy/, .github/, scripts/deploy.sh); Hard Rules, its containment and parity paragraphs (src/processor/_child.py, _contain.py, tests/fixtures/parity/); Detail Docs when a doc is added or renamed docs/DEPENDENCIES.md "Bumping co-core", docs/DEPENDENCIES.md "Extraction dependencies": pyproject.toml, uv.lock, the co-pypi index and scripts/co-pypi.sh, LOCAL_GENERATION docs/DEPLOYMENT.md "Deploy a change: `scripts/deploy.sh`", docs/MONITORING.md "The drift check", docs/MONITORING.md "Liveness": deploy/ units, scripts/deploy.sh, processor.drift.RUNTIME_* -docs/PATCHING.md "Patching", docs/PATCHING.md "The patch-due check", docs/PATCHING.md "Node.js (agent tooling only)": .skills/patching-hosts, deploy/apt/, the apt timers' drop-ins, deploy/needrestart.conf.d/, deploy/nodesource.sh, src/processor/patching.py +docs/PATCHING.md "Patching", docs/PATCHING.md "The patch-due check", docs/PATCHING.md "The daily report", docs/PATCHING.md "Node.js (agent tooling only)": .skills/patching-hosts, deploy/apt/, the apt timers' drop-ins, deploy/needrestart.conf.d/, deploy/nodesource.sh, src/processor/patching.py docs/DEPENDENCIES.md "CI pins and Dependabot", docs/DEPENDENCIES.md "Local-gate attestation", docs/DEPENDENCIES.md "Shell lint", docs/DEPENDENCIES.md "The lock audit": .github/, scripts/shellcheck.sh, scripts/audit_lock.sh, .githooks/ docs/SKILLS.md: the inventory, the refresh hook, Merging under pr and the doc-check lists (skills/, .claude/, .gitmodules, the .skills/ knobs) docs/SOCRATICODE.md: the store, the index scope and the context manifest (.socraticode.json, .socraticodecontextartifacts.json, .socraticodeignore, .claude/settings.json's env block) diff --git a/.skills/patching-hosts b/.skills/patching-hosts index 0ccacfc..b2f761f 100644 --- a/.skills/patching-hosts +++ b/.skills/patching-hosts @@ -78,3 +78,11 @@ exception purged:nginx 2027-02-23 exeuntu image leftover, never enabled or serve exception purged:docker 2027-02-23 exeuntu image leftover, no containers or volumes; purged with its group 2026-11-26 (#143) records CannObserv/processor + +# --- the daily report (#168, gregoryfoster/skills#486) ---------------------- +# The operator plans a host only on a reading under 36 h old. Units installed by +# install-report.sh from the main checkout, whose submodule root then runs daily: +# after a skills bump, git submodule update there, then --check (docs/PATCHING.md +# § The daily report). The key file is root's, 0600, installed by the owner; never +# read here. +report co-processor http://provisioner:9000 /etc/patching-hosts/inventory-key diff --git a/docs/PATCHING.md b/docs/PATCHING.md index 91733bb..ac4fb8d 100644 --- a/docs/PATCHING.md +++ b/docs/PATCHING.md @@ -1,12 +1,12 @@ # Patching -Keeping `co-processor`'s packages current: the posture and its two lanes, the weekly attended run, the patch-due check, and Node.js from NodeSource (agent tooling only). Deploying and operating: [DEPLOYMENT.md](DEPLOYMENT.md). +Keeping `co-processor`'s packages current: the posture and its two lanes, the weekly attended run, the patch-due check, the daily report, and Node.js from NodeSource (agent tooling only). Deploying and operating: [DEPLOYMENT.md](DEPLOYMENT.md). ## At a glance | Thing | Value | |---|---| -| Patching | `automatic` (knob `.skills/patching-hosts`, #113): `-security` daily by unattended-upgrades (13:00 UTC, no restart, no reboot); the rest in one approved run a week, `Tue 05:00–10:00` UTC (Monday night Pacific), as the broker's window closes; `processor-patching.timer` asks for it through Status. Never a bare `apt-get upgrade`. [§ below](#patching) (#77) | +| Patching | `automatic` (knob `.skills/patching-hosts`, #113): `-security` daily by unattended-upgrades (13:00 UTC, no restart, no reboot); the rest in one approved run a week, `Tue 05:00–10:00` UTC (Monday night Pacific), as the broker's window closes; `processor-patching.timer` asks for it through Status. Never a bare `apt-get upgrade`. [§ below](#patching) (#77). A daily report to the inventory service ([§ The daily report](#the-daily-report), #168) | | Node.js | 24 LTS from NodeSource apt, agent tooling only (mayfly, SocratiCode): `deploy/nodesource.sh install\|check`, [§ below](#nodejs-agent-tooling-only) | ## Patching @@ -114,6 +114,26 @@ Status's side (status#95): `enabled: false` stops only its `missing` sweep, neve **Silence it** for a week you mean to skip: `sudo systemctl stop processor-patching.timer`, and the monitor goes `missing`, which is honest; `start` resumes it. Better: post a record saying why, which reads `ok`. +### The daily report + +The operator plans a host only on an inventory reading under 36 h old (#168). The knob's `report` line names the VM, the service and the key file; the skill's [report.md](../skills/patching-hosts/references/report.md) is the procedure. Here: + +- **The units,** `patching-hosts-report.{service,timer}` in `/etc/systemd/system`, are `install-report.sh`'s, not `deploy/`'s: `deploy.sh` never installs or compares them. The service is a root `oneshot`; the timer is daily, plus up to 1 h. +- **The key** is root's, `0600`, installed by the owner. Nothing here creates, reads or prints it: `sudo test -s /etc/patching-hosts/inventory-key` is the one check. +- **Root runs the main checkout's skill daily.** `ExecStart=` pins the real path of the `report.sh` that ran the install, and `--config` the knob. So install from `/home/exedev/processor`, with absolute paths, never from a worktree. `exedev` has sudo already, so this adds no privilege. But an edit to `skills-vendor/` in that checkout becomes code that root runs. +- **A skills bump reaches root only through the submodule.** `submodule.recurse` is unset, so the fast-forward merge leaves `skills-vendor/` on the old commit. After a bump: `git submodule update -- skills-vendor/gregoryfoster-skills`, then the install with `--check`. That writes nothing and exits 1 when a unit would change (its template, the key path, or the paths it pins): re-run the install. Its 0 says nothing about `report.sh`'s bytes, only its path. +- **Two copies of the knob.** The reporter reads the main checkout's, which moves at the merge; the patch-due check and drift read the release's, at the deploy. + +```bash +S=/home/exedev/processor/skills-vendor/gregoryfoster-skills/skills/patching-hosts/scripts +sudo bash $S/install-report.sh --host co-processor --config /home/exedev/processor/.skills/patching-hosts # [--check] +sudo systemctl start patching-hosts-report.service # blocks; exit 0 is a 201 (or 200, the same bytes) +journalctl -u patching-hosts-report.service -n 20 --no-pager +sudo systemctl enable --now patching-hosts-report.timer +``` + +A failed start exits 1; report.md's code is the unit's `ExecMainStatus` (`systemctl show -p ExecMainStatus patching-hosts-report.service`): 2 is no key or a malformed one, 3 a 4xx, 4 a 5xx or transport error after one retry. **To remove it:** `disable --now` the timer, remove both unit files, `daemon-reload`, and drop the knob line. + ## Node.js (agent tooling only) Node 24 LTS from NodeSource's apt repo, for `using-mayfly-chat` and SocratiCode (`npx`). The `processor` unit never runs it. The cohort survey and the reasons for NodeSource and for 24 are in #6. diff --git a/docs/SKILLS.md b/docs/SKILLS.md index 883bf4d..b3dca98 100644 --- a/docs/SKILLS.md +++ b/docs/SKILLS.md @@ -36,6 +36,7 @@ Two artifacts, and only the second makes it run: the `.claude/hooks/skills-submo | Remove both | `bash skills/managing-skills/scripts/install-refresh.sh --uninstall` | | Refresh by hand | on a branch in a worktree, landed as a PR (`merge_mode pr`): `git submodule update --init --remote --merge -- skills-vendor/` (`--init` is load-bearing: without it an unregistered submodule is skipped with exit 0) | | Hold one submodule | a ` ` line in `.skills/skills-pin`; never suspend the hook | +| After a bump merges | in this checkout, `git submodule update -- skills-vendor/gregoryfoster-skills`: root's daily report runs this copy, and the fast-forward leaves it behind. Then the install's `--check` ([PATCHING.md § The daily report](PATCHING.md#the-daily-report)) | The first session in a fresh clone or worktree fails the hook with exit 127 (hooks run in parallel; nothing inits the submodule first). `bash .skills/doctor.sh` once fixes it. diff --git a/docs/plans/2026-12-03-168-operator-patch-cycles.md b/docs/plans/2026-12-03-168-operator-patch-cycles.md new file mode 100644 index 0000000..14b5671 --- /dev/null +++ b/docs/plans/2026-12-03-168-operator-patch-cycles.md @@ -0,0 +1,88 @@ +--- +title: Join the cohort operator's Tuesday patch cycles (#168) +date: 2026-12-03 +status: approved by the operator 2026-12-03. Brief: #168's body and its pre-flight (comment 7391756987, epic #84); corrections on the issue (comment 7391973115) +--- + +# Join the operator's patch cycles + +## Problem + +The cohort's operator patches every host on Tuesday, one at a time, from an executor that connects over Tailscale SSH. It plans a host only when three things hold: the host's posture is `scheduled`, its newest inventory reading is under 36 hours old, and it's on the operator's host list. co-processor fails all three: its posture is `automatic` (#113), it sends no reading, and Tailscale SSH is off. Once it joins, the patch-due check would page every Tuesday, since the operator records its runs elsewhere. + +The order matters more than the edits. A wrong order leaves the host with no patching lane for a week, or pages the owner. + +## Approach + +Two PRs and two deploys, as the pre-flight suggests. Each PR is built and reviewed before its host steps, and every `sudo` step waits for the owner's approval in the session. + +**PR A, the daily report** (`168-daily-report`). It adds the knob's `report` line and the report's docs. It changes nothing about how the host is patched, so it can land at once. + +**PR B, the switch** (`168-posture-scheduled`). It moves the posture to `scheduled` and the window to `Tue 14:00-23:59`, removes the apt files of #113, turns the patch-due check off, and records Tailscale SSH. It is built and reviewed early, and lands only when the gate below holds. + +**The gate for B.** All four, or 2026-12-08 runs as today (05:00Z, attended, patch-due check on): +1. the first report answers `sent: 201`; +2. `patching-hosts-report.timer` is enabled; +3. the operator confirms co-processor is on its host list; +4. Status confirms `co-processor-patching` is paused. + +## Tradeoffs / alternatives + +- **One PR for everything** — rejected: the report can prove itself days before the posture may move, and the knob is a runtime path, so one PR would hold the report behind the gate. +- **Keep the apt files and drop-ins in `deploy/`, unused** — rejected: `deploy.sh` would journal "not installed" for each on every deploy, and their tests would guard nothing. Git history is the way back, and PATCHING.md names the commit. +- **Delete the patch-due check** (`src/processor/patching.py`, both units) — rejected, on the pre-flight's advice: the operator may post the record line here later, and then the check resumes with one `enable`. The cost is one guard in `deploy.sh` (step B3). +- **`RunSSH` documented but untested** — rejected: `accept-dns` and `auto-update` each have a live test in `tests/test_tailscaled.py`, and a later `tailscale up` without `--ssh` would cut the operator off silently. + +## Steps + +### PR A: the daily report + +- **A1. Red, then the knob.** `tests/test_patching_knob.py` gains a test that the vendored reader returns `report` as `co-processor`, `http://provisioner:9000`, `/etc/patching-hosts/inventory-key`. It fails, then the line and its comment go into the knob's global lines. +- **A2. Docs.** PATCHING.md gains *The daily report*: the units, the key path nobody here reads, that root runs the **main checkout's** `report.sh` daily, and `install-report.sh --check` after every skills bump. SKILLS.md's refresh section points at that check. AGENTS.md doesn't change. +- **A3. Review and ship.** Code review, fixes, the PR's final SHA, then a pause. On approval: merge, then `scripts/deploy.sh` (the knob is a `RUNTIME_FILES` path). Drift reads `ok`. +- **A4. Host steps,** each approved, run from the main checkout with absolute paths: + 1. `sudo tailscale debug netmap | jq .SSHPolicy`, **then** `sudo tailscale set --ssh`, then the read again. Outside the broker's `Mon 23:00–05:00Z`. The policy goes on #168. + 2. `sudo bash …/install-report.sh --host co-processor --config …`, then the same with `--check`. + 3. The owner installs the key and opens the tailnet path. The checks: `getent hosts provisioner`, `sudo test -s /etc/patching-hosts/inventory-key`. + 4. `sudo systemctl start patching-hosts-report.service`, then its journal (no sudo). + 5. `sudo systemctl enable --now patching-hosts-report.timer`. +- **A5. Reply on #168:** the knob's commit, step 2's JSON, step 4's journal lines. + +### PR B: the switch + +- **B1. Red, then the knob.** `test_the_knob_reads_clean` wants `scheduled`, and `test_the_window_is_the_owners` wants `Tue 14:00-23:59`. Then the knob: both lines, and its comments rewritten (the window block still explains Monday night and the broker). `records CannObserv/processor` stays. +- **B2. The apt files go.** Remove `deploy/apt/apt.conf.d/processor-periodic`, both `processor-window.conf` drop-ins, their three `HOST_CONFIGS` rows (`scripts/deploy.sh`, `tests/test_units.py`) and `tests/test_apt_automatic.py`. A new `tests/test_apt_scheduled.py` holds the node to `scheduled`: both apt timers `masked`, `APT::Periodic::Enable` effective `0`, none of the three files installed. It skips off the node by hostname. +- **B3. The patch-due check, off but kept.** `deploy.sh` never enables a timer in a new `DORMANT_TIMERS` list, which holds `processor-patching.timer`, so a rebuilt host doesn't start it. Red first in `tests/test_deploy.py`. +- **B4. Tailscale SSH on record.** `test_live_node_runs_tailscale_ssh` in `tests/test_tailscaled.py` (`tailscale debug prefs`, no sudo), and NETWORK.md says any later `tailscale up` carries `--ssh`. +- **B5. Docs.** PATCHING.md § Patching and § The patch-due check (off, and the way back for each); AGENTS.md's Patching row, rewritten without growing (5,962 of 6,000); `AGENTS.md:102`; `PROVISIONING.md:153`; DEPLOYMENT.md's two mentions; `patching.py`'s docstring. +- **B6. Review,** fixes, the final SHA, then wait for the gate. +- **B7. Host steps,** each approved, in this order: + 1. Status has confirmed the pause. Then `sudo systemctl disable --now processor-patching.timer`. + 2. Outside 12:00–14:00Z, with both apt services `inactive`: `disable --now` and `mask` both apt timers, remove `processor-periodic` and both installed drop-ins, `daemon-reload`. + 3. `uv run pytest` on co-processor, from B's worktree: green. +- **B8. Ship.** A pause, then merge and `scripts/deploy.sh`. Drift reads `ok`; `install-report.sh --check` exits 0. +- **B9. Reply on #168:** the `is-enabled` line, `read-knob.sh`'s output, the `SSHPolicy`. + +## Open questions / risks + +- **Where the operator reads the posture, and by when** (the owner's to answer). The daily report carries none. B must be merged before that read for the 12-08 cycle. +- **Whether the tailnet's SSH rules are acceptable** is the owner's call once A4.1 prints them. `exedev` has passwordless sudo, and no sshd runs here, so those rules alone decide who is root. +- **Between B7.2 and B8, `main`'s own suite is red on this host:** its live tests still expect `automatic`. Keep that gap short, and ship nothing else through it. +- **The ask to CannObserv/status** is a cross-repo post: drafted, posted only on the operator's approval. + +## Known limits + +- **A week with neither lane.** If B lands and the operator doesn't plan the host on 12-08, nothing patches it that week. The fallback is an attended run in this repo's session inside `Tue 14:00-23:59`, recorded here. +- **`-security` waits up to 7 days** where it waited under a day (owner, 2026-12-03, decided). +- **`cadence:off-window` is expected after the switch,** until a run lands in the new window. Traced in `probe.sh`, not measured: a non-root probe can't read the run directories. It gates nothing. +- **Root runs the main checkout's skill daily.** A merged skills bump changes what root runs; `--check` afterwards is the control. + +## For the operator's side (Provisioner) + +- **A Tailscale SSH session's OOM rank.** tailscaled runs at `-950` here. If a session inherits it, the run's apt ranks below `processor.service` (`-500`). Check `cat /proc/self/oom_score_adj` in the first session. +- **The held `tailscale` step** restarts the daemon that serves the session. `1.106.3` is pending, so the first run meets it. + +## For #84 + +- `co-processor-patching` is paused at Status, not removed. The way back is in PATCHING.md after B. +- #113's record comments stop for operator runs. A session run still posts one. diff --git a/tests/test_patching_knob.py b/tests/test_patching_knob.py index f59b0b4..2ed2f62 100644 --- a/tests/test_patching_knob.py +++ b/tests/test_patching_knob.py @@ -159,6 +159,19 @@ def test_the_window_is_the_owners() -> None: assert [(w["weekday"], w["start"], w["end"]) for w in window] == [("Tue", "05:00", "10:00")] +def test_the_host_reports_daily_to_the_inventory_service() -> None: + """The operator plans a host only on a reading under 36 h old (#168; the skill's + report.md). ```` is the exe.dev VM's name, never read from ``hostname``; the + key file is root's, installed by the owner, and nothing here reads it.""" + report = _resolved()["report"] + assert report is not None, "the knob has no report line" + assert (report["vm"], report["url"], report["key_file"]) == ( + "co-processor", + "http://provisioner:9000", + "/etc/patching-hosts/inventory-key", + ) + + def test_no_quiet_range_is_declared() -> None: """processor-drift.timer's ticks drift (OnUnitActiveSec=1h), so no fixed range fits them; liveness runs inside the service."""