No description
  • JavaScript 88.7%
  • Shell 9.3%
  • Python 2%
Find a file
le king fu b928b91ece
All checks were successful
CI / verification (pull_request) Successful in 39s
fix(pg-backup-pull): keep files landed by a failed pull private
rsync cut by its timeout or a dropped link has already moved the whole files
into place, with the default modes. The chmod now runs on both paths, and the
comment that said nothing lands on a failed pull is gone (review of PR #72).

Refs #71

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 20:43:11 -04:00
.forgejo/workflows ci: add a Forgejo Actions workflow with a boot-from-COPY check (#24) 2026-09-27 20:22:48 -04:00
__tests__ fix(pg-backup-pull): keep files landed by a failed pull private 2026-10-27 20:43:11 -04:00
agent fix(pg-backup-pull): keep files landed by a failed pull private 2026-10-27 20:43:11 -04:00
docs fix(pg-backup-pull): keep files landed by a failed pull private 2026-10-27 20:43:11 -04:00
scripts docs: slim CLAUDE.md below 30k characters, move details to docs/ (#67) 2026-10-20 20:30:39 -04:00
.env.example feat(claude-usage): add POST and GET /claude-usage behind a third token kind 2026-10-04 09:16:05 -04:00
.gitignore fix(security): ignore *.pem and *.key files (#64) 2026-10-20 21:12:45 -04:00
backups.js feat(backups): pass the files[] block of status.json through GET /backups 2026-10-12 20:04:12 -04:00
claude-usage-history.js feat(backups): GET /backups and POST /backups/pull 2026-10-10 19:43:07 -04:00
claude-usage.js feat(server): archive closed Claude usage days by month, serve them on /claude-usage/history 2026-10-08 20:41:30 -04:00
CLAUDE.md docs: apply the four review suggestions on PR #68 (#67) 2026-10-20 21:02:43 -04:00
Dockerfile feat(backups): GET /backups and POST /backups/pull 2026-10-10 19:43:07 -04:00
index.js feat(backups): GET /backups and POST /backups/pull 2026-10-10 19:43:07 -04:00
metrics.js refactor: extract CPU/RAM/disk collection into metrics.js 2026-08-16 11:30:03 -04:00
package-lock.json fix(deps): bump vitest to 5 to clear the dev-chain advisories (#66) 2026-10-20 21:22:19 -04:00
package.json fix(deps): bump vitest to 5 to clear the dev-chain advisories (#66) 2026-10-20 21:22:19 -04:00
README.md docs: apply the four review suggestions on PR #68 (#67) 2026-10-20 21:02:43 -04:00
REVIEW.md fix(pg-backup-pull): cap the backups at 30 days from today, even on a failed pull 2026-10-26 21:15:58 -04:00
test-curl.sh feat(backups): GET /backups and POST /backups/pull 2026-10-10 19:43:07 -04:00
vitest.config.js feat(defenseurs): add GET /defenseurs/findings?project=X route 2026-05-12 20:56:56 -04:00

vps-health-api

Lightweight health monitoring API for the VPS. Node 22, HTTP-native, zero runtime deps.

Endpoints

Read endpoints require Authorization: Bearer $HEALTH_TOKEN. Each write endpoint has its own token — $HOSTS_INGEST_TOKEN for workstation snapshots, $CLAUDE_USAGE_INGEST_TOKEN for the Claude usage snapshot, $BACKUPS_INGEST_TOKEN for the backup pull report — so an agent can push its data without gaining read access to the Defenseurs reports, and no ingestion token opens another one's route.

Method Path Token Description
GET /health HEALTH_TOKEN CPU, memory, disk, uptime, Logto reachability
GET /defenseurs HEALTH_TOKEN Defenseurs executive status (status.json)
GET /defenseurs/findings?project=X HEALTH_TOKEN Detailed findings for a project's Defenseur
GET /defenseurs/state HEALTH_TOKEN Sergent's per-finding state (findings-state.json)
GET /reports/scans?date=YYYY-MM-DD HEALTH_TOKEN Aggregated scan reports for a UTC date
GET /hosts HEALTH_TOKEN Latest snapshot of every allowlisted workstation
POST /hosts/<id> HOSTS_INGEST_TOKEN Ingest one workstation snapshot
GET /claude-usage HEALTH_TOKEN Latest Claude usage snapshot, with server-side staleness
POST /claude-usage CLAUDE_USAGE_INGEST_TOKEN Ingest the Claude usage snapshot
GET /claude-usage/history?from=YYYY-MM&to=YYYY-MM HEALTH_TOKEN Archived closed days of Claude usage (12 months by default)
GET /backups HEALTH_TOKEN PostgreSQL backups: VPS status and last workstation pull, with server-side staleness
POST /backups/pull BACKUPS_INGEST_TOKEN Ingest the workstation's pull report

Routing resolves before authentication: an unknown path or a wrong method answers 404, never 401.

Full contract of every route — bodies, response codes, examples, the whitelist rebuild and the atomic writes behind the three POST routes: docs/endpoints.md (in French).

Config

Environment variables and their defaults are listed in CLAUDE.md (« Config »). Every token is fail-closed: a missing HEALTH_TOKEN answers 401 on reads, a missing ingest token 503 on its own route.

Bind-mounts (Coolify)

Three read-only mounts (the Defenseurs files and the VPS backup status) and three read-write ones owned by uid 1000 (/data/hosts, /data/claude-usage, /data/backups-pull), always mounting the directory, never the file. Paths, the two layers that keep the API out of the Defenseurs files, and the post-redeploy check: docs/mounts.md (in French).

Workstation agent

agent/ holds the zero-dependency collector that runs from cron on a workstation and feeds POST /hosts/<id>. It is not part of the server image — it is installed by copying files onto the machine it measures. Install steps, crontab line and failure modes: agent/README.md.

Tests

npm install
npm test
bash test-curl.sh
sh scripts/boot-from-copy.sh

What each test file and script guards: docs/tests.md (in French).