Write the backend's logs as the estate's log line (AHT-204) #1011

Merged
merge-queue merged 3 commits from aht-204-logline into main 2026-11-26 14:29:37 -08:00
Owner

Part of AHT-204, one log line across the estate.

Before: the backend wrote free text with no time, such as console.error('OIDC callback failed:', error) or slow request: GET /api/x 200 2310ms. The solve and train Jobs wrote their own JSON lines ({"t":"...Z","event":"done",...}). Error objects went out unmasked.

After: every line is a romaine-life/logline line on stdout, through backend/log.js:

2026-11-26T14:02:11.408-08:00 pid=12 warn slow request method=GET path=/api/levels status=200 ms=2310
2026-11-26T14:02:15.001-08:00 pid=12 info postgres ready mode=workload-identity schema=auto migrations="schema migrations applied: none; ..."
  • Scope: all 57 calls in server.js, plus supervisor.js, oidcAuth.js and self-check.js. Each message is fixed text and what varies goes in fields.
  • Masking: error text (stack, or message only where the old line logged only the message), request paths and migration failures go through outside/errorText, which apply logline's redact and cap the text at 4 KiB. The session store holds OAuth tokens, so an error from it can carry one.
  • Jobs: solve-worker.mjs and train-worker.mjs log through workerEvent. The event becomes the message, the other keys become snake_case fields, and objects are written as JSON. An error, *_error or *_failed event is logged at error level, and its error field is masked.
  • Tests that waited on text: netplay-smoke-test.js (listening), smoke-test.js (postgres ready, both modes) and solve-worker-smoke-test.js (done) now read lines back with logline's parse through entries() instead of matching substrings.
  • ES module check: self-check.js loads log.js, so the image check proves the image's Node 22 loads the ES module with require().
  • Package: @romaine-life/logline 0.1.4 comes from Forgejo's npm registry through a new backend/.npmrc, pinned exactly. The Dockerfile copies it and mounts FORGEJO_PACKAGES_TOKEN for the backend's npm ci.

Unchanged: the slow-request threshold (ADR-0258 logs only requests over SLOW_REQUEST_LOG_MS, path without query). No full access log is added.

Test: backend/log.test.js (new test:log, first in test:backend) captures stdout, parses every line, and covers fields, masking, the cap, worker events, entries(), and a fresh process loading the module with no warning. I ran these locally and they pass: test:log, test:oidc, readiness.test.js, netplay-smoke-test.js, solve-worker-smoke-test.js and npm run lint. ci-check passed. The DB-backed smoke-test.js runs on the PR.

🤖 Generated with Claude Code

Part of [AHT-204](https://openproject.home.romaine.life/wp/AHT-204), one log line across the estate. **Before:** the backend wrote free text with no time, such as `console.error('OIDC callback failed:', error)` or `slow request: GET /api/x 200 2310ms`. The solve and train Jobs wrote their own JSON lines (`{"t":"...Z","event":"done",...}`). Error objects went out unmasked. **After:** every line is a [romaine-life/logline](https://forgejo.romaine.life/romaine-life/logline) line on stdout, through `backend/log.js`: ```text 2026-11-26T14:02:11.408-08:00 pid=12 warn slow request method=GET path=/api/levels status=200 ms=2310 2026-11-26T14:02:15.001-08:00 pid=12 info postgres ready mode=workload-identity schema=auto migrations="schema migrations applied: none; ..." ``` - **Scope:** all 57 calls in `server.js`, plus `supervisor.js`, `oidcAuth.js` and `self-check.js`. Each message is fixed text and what varies goes in fields. - **Masking:** error text (stack, or message only where the old line logged only the message), request paths and migration failures go through `outside`/`errorText`, which apply logline's `redact` and cap the text at 4 KiB. The session store holds OAuth tokens, so an error from it can carry one. - **Jobs:** `solve-worker.mjs` and `train-worker.mjs` log through `workerEvent`. The event becomes the message, the other keys become snake_case fields, and objects are written as JSON. An `error`, `*_error` or `*_failed` event is logged at error level, and its `error` field is masked. - **Tests that waited on text:** `netplay-smoke-test.js` (listening), `smoke-test.js` (`postgres ready`, both modes) and `solve-worker-smoke-test.js` (`done`) now read lines back with logline's `parse` through `entries()` instead of matching substrings. - **ES module check:** `self-check.js` loads `log.js`, so the image check proves the image's Node 22 loads the ES module with `require()`. - **Package:** `@romaine-life/logline` 0.1.4 comes from Forgejo's npm registry through a new `backend/.npmrc`, pinned exactly. The Dockerfile copies it and mounts `FORGEJO_PACKAGES_TOKEN` for the backend's `npm ci`. **Unchanged:** the slow-request threshold (ADR-0258 logs only requests over `SLOW_REQUEST_LOG_MS`, path without query). No full access log is added. **Test:** `backend/log.test.js` (new `test:log`, first in `test:backend`) captures stdout, parses every line, and covers fields, masking, the cap, worker events, `entries()`, and a fresh process loading the module with no warning. I ran these locally and they pass: `test:log`, `test:oidc`, `readiness.test.js`, `netplay-smoke-test.js`, `solve-worker-smoke-test.js` and `npm run lint`. `ci-check` passed. The DB-backed `smoke-test.js` runs on the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Every console.log/info/warn/error in the backend (server.js, supervisor,
oidcAuth, self-check) and the solve/train Jobs' JSON event lines become
romaine-life/logline lines on stdout through backend/log.js: a fixed message
and key=value fields, with the time's zone and the pid. Error text and
request paths are masked with logline's redact and capped; worker events
keep their event name as the message and their keys as snake_case fields.

The smoke tests that waited on "listening on :port" and "postgres ready"
read the lines back with logline's parse instead of matching text, and
log.test.js checks every line parses. self-check loads log.js, so the image
check proves its Node loads the ES module with require().

@romaine-life/logline 0.1.4 comes from Forgejo's npm registry through
backend/.npmrc, pinned exactly; the Dockerfile copies .npmrc and mounts
FORGEJO_PACKAGES_TOKEN for npm ci.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The solve-worker smoke test reads the done line with logline's parse (AHT-204)
Some checks failed
Suite tofu / check-plan (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite default / scope (pull_request) Successful in 53s
Checks / check-docs (pull_request) Successful in 41s
Suite tofu / check-plan (push) Has been skipped
Suite tofu / apply (push) Has been skipped
Suite tofu / reused-checks (push) Has been skipped
Suite web-app / scope (push) Has been skipped
Suite web-app / check-image (push) Has been skipped
Suite web-app / publish (push) Has been skipped
Suite web-app / publish-static (push) Has been skipped
Suite web-app / reused-checks (push) Has been skipped
Suite cluster-service / check-image (pull_request) Has been skipped
Suite tofu / apply (pull_request) Has been skipped
Suite default / check-rules (pull_request) Has been skipped
Suite web-app / publish-static (pull_request) Has been skipped
Suite web-app / scope (pull_request) Successful in 1m16s
Suite tofu / scope (pull_request) Successful in 52s
Suite default / check-fetches (pull_request) Successful in 20s
Suite tofu / reused-checks (pull_request) Successful in 18s
Suite web-app / publish (pull_request) Has been skipped
Suite cluster-service / scope (pull_request) Successful in 52s
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite cluster-service / reused-checks (pull_request) Successful in 20s
Suite default / reused-checks (pull_request) Successful in 17s
Suite web-app / check-test (backend) (pull_request) Failing after 1m56s
merge-queue CI failed: Suite web-app / check-test (backend) (pull_request)
Suite web-app / check-image (pull_request) Successful in 2m12s
Suite web-app / reused-checks (pull_request) Has been cancelled
Suite web-app / check-test (frontend) (pull_request) Has been cancelled
1ee551a7c1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

merge-queue stopped this at 1ee551a: CI failed: Suite web-app / check-test (backend) (pull_request). Push a fix, or once it is fixed outside this pull request, remove and re-add the queue label.

merge-queue stopped this at 1ee551a: CI failed: Suite web-app / check-test (backend) (pull_request). Push a fix, or once it is fixed outside this pull request, remove and re-add the `queue` label.
Point the startup and check-mode source contracts at the new log lines (AHT-204)
All checks were successful
Suite cluster-service / scope (pull_request) Successful in 1m21s
Suite tofu / scope (pull_request) Successful in 1m23s
Checks / check-docs (pull_request) Successful in 1m4s
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite tofu / apply (pull_request) Has been skipped
Suite default / scope (pull_request) Successful in 1m25s
Suite tofu / check-plan (push) Has been skipped
Suite tofu / apply (push) Has been skipped
Suite tofu / reused-checks (push) Has been skipped
Suite web-app / publish (push) Has been skipped
Suite web-app / scope (push) Has been skipped
Suite web-app / check-image (push) Has been skipped
Suite web-app / publish-static (push) Has been skipped
Suite web-app / reused-checks (push) Has been skipped
Suite default / check-rules (pull_request) Has been skipped
Suite web-app / publish (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite cluster-service / check-image (pull_request) Has been skipped
Suite tofu / check-plan (pull_request) Has been skipped
Suite cluster-service / reused-checks (pull_request) Successful in 22s
Suite default / reused-checks (pull_request) Successful in 24s
Suite default / check-fetches (pull_request) Has been skipped
Suite web-app / scope (pull_request) Successful in 1m43s
Suite web-app / publish-static (pull_request) Has been skipped
Suite tofu / reused-checks (pull_request) Successful in 22s
Suite web-app / check-image (pull_request) Successful in 1m57s
Suite web-app / check-test (backend) (pull_request) Successful in 2m16s
Suite web-app / check-test (frontend) (pull_request) Successful in 3m9s
Suite web-app / reused-checks (pull_request) Successful in 25s
merge-queue landed on main
28da41db1a
predrawnArchiveUpgradePath.test.js reads server.js and smoke-test.js as
text: the migration target now prints as log.info('postgres schema
migration target', ...) before runMigrations(), and the check-mode proof
starts at the parsed secondaryReadyEntry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
merge-queue deleted branch aht-204-logline 2026-11-26 14:29:37 -08:00
Sign in to join this conversation.
No description provided.