19 Commits
Author SHA1 Message Date
paulandCopilot 043674989a pydantic-ai 2.75: knows Sonnet 5.5 rejects forced tool choice
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-26 17:33:43 +13:00
paulandCopilot 5170ec2f57 Model id is claude-sonnet-5-5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-26 17:29:38 +13:00
paulandCopilot 12e6fef51c Run on the core host, on Claude Sonnet 5.5 via the Anthropic API; no Ollama
The daemon moves from WSL on the workstation to the core host, where it runs
commands directly (core is the only host). One model profile, claude, with a
200k context and the existing cost caps. install.sh runs on the core host.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-26 16:59:28 +13:00
paulandClaude Opus 5.5 974abbec1d Maintain the home cluster from local, over the LAN
semprini-core's `cluster.ps1 maintainer-access` gives this WSL user kubectl
(as elz-operator) and `ssh sem-k8s-1..3`, `ssh sem-gw` straight over the
LAN, so the agent keeps cluster access while the tunnel is down. The host
descriptions now send cluster work to `local`; core still reaches the
cluster through the tunnel. The agent definition in semprini-core says
what it may change there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:36:08 +12:00
paulandClaude Opus 5.5 9aa1abf0e2 Run everything on the local model; no cloud tier
GLM-4.7-Flash can reach core over SSH, check, diagnose and upgrade, so
operator messages, alert triage, health findings and the weekly upgrade all
route to the one local profile. The Anthropic profile and its cloud-first
routing go, and with them the API key and metered billing the first draft
needed. The local profile's context_tokens rises to 131072, the window Ollama
loads GLM with, so long runs are not trimmed early.

Profiles and routing stay in configuration: a second model can still be
added, with hand-over when the first is unreachable or fails the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 01:59:28 +12:00
paulandClaude Opus 5.5 61dca2c3ca Run on the workstation, on pydantic-ai with cloud and local models
The daemon moves from the Lightsail host to WSL on the workstation (EVAI),
where the RTX 4090 can run local models and the data platform and home
cluster live. It reaches the core host over one multiplexed SSH connection:
each health check pipes probe.py to the host's python3 and gets Kuma, disk,
memory, OOM kills, restarts and reboots back in one snapshot. The agent edits
and commits core's live checkout there, as semprini-core's rules expect, and
the service desk still runs on the host. Off the host, it now notices when
the host itself stops answering.

The agent runs in-process with pydantic-ai instead of Claude Code headless.
Model profiles (anthropic, ollama, any OpenAI-compatible server) are routed
per kind of task: an unreachable model hands over at once (FallbackModel), a
run that fails as a run restarts on the next profile. The result is a typed
envelope; conversations persist as message histories; cancel stops the
command in flight; each reply names the model and its cost. `model` in Matrix
pins a room to a profile; --try-model checks a model calls tools and uses
what they return (qwen3-coder does not; GLM-4.7-Flash, the local default, does).

Cloud runs now need an API key (--set-api-key) and are billed per token; the
subscription token was for Claude Code only. Back-off is per kind of task, so
a cloud-only upgrade waiting on a key does not stall work the local model
can do. A queued task held back by a hold no longer spins the main loop.

--hold and --resume stay stdlib-only, so sync-to-host.sh can still hold the
daemon from the host's checkout; the daemon reads the host's hold each minute.
install.sh sets up WSL and retires the host's service: one Matrix bot, one
daemon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 01:46:03 +12:00
paulandClaude Opus 5 99ebfcfb38 Run semprini-core's service desk every minute; --hold never shortens
The service desk (Semprini/service-desk) is fulfilled by semprini-core's
core_stack/scripts/service-desk.py. The daemon runs its poll between agent
runs, skips it during a hold, and posts to Stack Maintenance what needs a
person: an approval, a failure, an "Ask core" request, a finished request.

--hold from a shell no longer shortens a longer hold: sync-to-host.sh's
15 minutes on each deploy cut a 2-hour hold short on 2026-09-19.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 18:06:22 +12:00
paulandClaude Sonnet 5 a8124a803b Resolve Synapse's admin API internally, not through Traefik
semprini-core now refuses /_synapse/admin/* at the edge (SR-05) — it needed
no auth of its own and let anyone on the internet create or deactivate
Matrix accounts given the registration shared secret. This script already
reads that secret straight out of the user-synapse container; it now
resolves the container's semprini_internal address the same way
semprini-core's scripts/setup-matrix-alerts.py does, and uses it for every
call instead of the public hostname.

Verified live against the real maintainer bot account: it found the
existing token still valid and re-used the existing room, unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-18 20:08:36 +12:00
paulandClaude Opus 5 4782849ce5 Add a time-boxed hold on autonomous work
Working on the live stack meant fighting the daemon: it triaged alerts a
deploy caused, and its own commits landed mid-session. Stopping the service
is the only lever today, and it is easy to leave stopped.

`hold 45m <why>` in Matrix, or `maintainer.py --hold 45m --reason …` from a
shell, pauses everything the daemon starts by itself — health cycles, alert
triage, weekly upgrades — for a bounded time. Operator messages still run,
and alerts still batch, so one triage run covers the whole hold. It says in
the room when the hold starts and when it runs out, `status` shows it, and
`resume` ends it early.

The hold lives in hold.json beside the state file: `--hold` from a shell has
to reach a daemon that rewrites its own state whenever it likes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-16 11:15:54 +12:00
paulandClaude Opus 5 a725abbfbc Default the agent to Claude Sonnet 5
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 23:48:44 +12:00
paulandClaude Opus 5 b94a19147f Use an absolute path in the ssh token command
An unquoted ~ in `ssh host ~/path` expands on the local machine, so the
documented command looked for /home/paul/semprini-maintainer on the host.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 23:41:13 +12:00
paulandClaude Opus 5 556ffb6561 Run on the stack host, react to Matrix events, keep the repo current
The stack moved to AWS Lightsail, so the maintainer now runs on that host
as ubuntu and is triggered by events rather than polling:

- A long-poll /sync delivers operator messages and #stack-alerts within
  about a second. Follow-ups resume the Claude session, so the Stack
  Maintenance room works like a chat. status, cancel, new, upgrade and
  help are answered even while a run is in progress.
- FIRING alerts from the Alertmanager bridge are batched and triaged in a
  thread, with a per-fingerprint cooldown.
- Agent runs go one at a time from a persisted priority queue, so an
  unusable agent defers work instead of losing it.
- Health checks add host resources (disk, memory, OOM kills, restart
  loops, stale Kuma) and reboot detection; one cycle's findings share a run.
- The daily report and the weekly upgrade run at fixed UTC times; the
  upgrade covers every image on the host.
- Applied changes are committed to semprini-core main and pushed. The
  daemon fast-forwards before a run and pushes leftovers after it.
- The Claude credential comes from `claude setup-token` via
  --set-claude-token. Self-update runs hourly, gated by --check.
- install.sh renders the unit for the current user and configures the git
  credential helper.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 23:22:34 +12:00
paul 46a1ec1e01 Merge pull request 'Add rolling 24h activity rollup to daily health heartbeat' (#1) from daily-heartbeat-24h-summary into main
Reviewed-on: #1
2026-07-01 09:39:39 +00:00
paulandClaude Opus 4.8 8a6a468bec Add rolling 24h activity rollup to daily health heartbeat
The daily "✅ Daily health — N/N up" message was a bare point-in-time
snapshot: it said nothing about downtime or operational support during
the preceding window. Self-recovered blips and sustained-outage
remediations were reported only as separate real-time messages, easy to
miss.

Accumulate a per-service tally in state["since_heartbeat"] and fold it
into the heartbeat line, then reset on send:
- self-recovered blips counted once per DOWN→UP window
- sustained outages counted once, at the cycle the down-streak first
  crosses down_confirmations (so a long outage isn't tallied each cycle)

Wording is autonomy-mode-neutral ("sustained outage(s)"). Existing state
files without the key are initialized via setdefault, so no reset needed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 21:37:45 +12:00
paul 00195ee6d5 Add Gitea integration for agent to push branches and open pull requests
- Implemented `register-gitea-bot.sh` to provision Gitea access token.
- Updated `maintainer.py` to support Gitea API for push and PR operations.
- Modified `install.sh` to warn if Gitea token is not provisioned.
- Enhanced documentation in `README.md`, `CLAUDE.md`, and `architecture.md` to reflect new Gitea functionality.
- Added Gitea configuration to `config.example.json`.
2026-06-29 20:46:33 +12:00
paul 9df86ead20 Update bot user ID and model name in configuration files; enhance outage recovery reporting 2026-06-23 21:25:07 +12:00
paulandClaude Sonnet 4.6 e14c21fab5 Fix 429 (model pin) and bot ignoring encrypted admin replies
Two independent bugs:

1. 429 "long context" — agentic sessions read enough files to exceed the
   200K standard window; on the default [1m] model Synapse escalates into
   the paid 1M tier. Pin claude_model to claude-opus-4-8 (200K window)
   so Claude Code compacts context instead. Updated config.example.json
   and the maintainer.py default / comment accordingly.

2. Bot silently ignores operator replies — the DM room was created with
   is_direct:true, causing Element to auto-enable E2E encryption. This
   stdlib-only bot cannot decrypt m.room.encrypted events, so all admin
   messages were dropped without any log output. Fix:
   - register-matrix-bot.sh now creates rooms with is_direct:false and
     preset:private_chat (Synapse does not force encryption on non-DM
     rooms).
   - matrix_poll_admin() now logs a loud WARN if an encrypted event
     arrives, instead of silently skipping it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-21 18:46:33 +12:00
paulandClaude Opus 4.8 d6c315d353 Provision Matrix bot via shared-secret admin API (OIDC-only homeserver)
The homeserver authenticates humans via Keycloak OIDC and has password
login disabled, so register-matrix-bot.sh's password-login flow could
never obtain a token. Rewrite it to create the bot and mint a standalone
access token through Synapse's shared-secret admin API
(/_synapse/admin/v1/register), which works with registration + password
login turned off.

- Use the claude-code identity (@claude-code:semprini.me) as the bot.
- Avoid the admin "login as user" API: it returns a puppet token that
  Synapse revokes when the issuing admin is deactivated.
- Make re-runs idempotent: reuse a still-valid token/room; only recreate
  the account when no valid token is on hand.
- Read the registration shared secret from the running synapse container.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 18:24:11 +12:00
paulandClaude Opus 4.8 e91b129841 Initial commit: autonomous maintenance agent for semprini stack
systemd-deployed daemon that drives the semprini-core stack-support agent
headless via Claude Code, monitors health via Uptime Kuma, applies safe
upgrades, and escalates to the operator over Matrix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 17:20:06 +12:00