Repository navigation
feat(server): persist openwork-server logs to a rotating file - #4371
Conversation
The desktop runs openwork-server in-process, so its structured logger only reached Electron's stdout and was invisible in packaged builds: engine rollover reasons, reload triggers, and MCP re-sync errors were emitted and lost. Diagnosing today's engine churn required reconstructing the timeline from sidecar run IDs and file mtimes. - apps/server: OPENWORK_SERVER_LOG_FILE enables an append-only sink that always receives JSON lines regardless of the stdout format, rotates once at 20 MB (file + .1), disables itself on I/O errors, and redacts credential-looking attribute keys before any line is written. - apps/desktop: default the sink to <userData>/logs/openwork-server.log before the embedded bundle loads and expose logFilePath in the server snapshot; Settings > Debug shows the path. - evals/specs/server-log-file.test.ts boots the real CLI with and without the variable and asserts structured lines, no token material, and no file when unset.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Test evidence — openwork-server-persists-structured-credential-free-logs-when-openwork-server-lo — ✅ passed✅ passed · 4 expectations passed · 0 failed · 0 pending verdict passed · 0 user observations · 0 probes · steps 0/0 ℹ️ ASSERTION — 1. Server log lines are persisted as structured JSON4 JSON lines at /var/folders/87/_t5df82d0bv7vnphlldtg_fc0000gp/T/openwork-server-log-spec-4NIKLl/userData/logs/openwork-server.log, including the listening line and a request line with status and durationMs, while stdout stays in pretty format.
ℹ️ ASSERTION — 2. Persisted logs never carry the client or host tokenThe explicit --token and --host-token values are absent from the file even though the server logged startup and a request.
ℹ️ ASSERTION — 3. Generated startup credentials remain on stdout but are redacted from the fileA real CLI boot without --token/--host-token printed both generated values for the operator; the JSON file contained only Client token: <redacted> and Host token: <redacted>.
ℹ️ ASSERTION — 4. No file sink is created when OPENWORK_SERVER_LOG_FILE is unsetA second server booted without the variable served /health and created neither a log file nor its directory.
Test run created 2026-09-03T23:45:51.077Z · Source: |
The file sink redacted credential-looking attribute keys but not message bodies. CLI startup messages embed generated client and host tokens directly, so enabling OPENWORK_SERVER_LOG_FILE persisted credentials that authenticate to the server. Build a separate file-only record that removes exact configured client, host, and OpenCode passwords from message bodies and nested attribute values. Keep stdout unchanged because generated CLI credentials must remain visible to the person launching the server. Regression coverage asserts stdout retains them while the file contains only <redacted>.
…d logs Boot the real CLI without explicit tokens, assert the generated client and host values remain visible on stdout for the operator, and assert the structured file contains only <redacted> message bodies.
|
Addressed the high-severity token finding in f47dfe8: the persisted record now redacts exact client, host, managed-engine, and workspace engine passwords from message bodies and nested attributes. CLI stdout remains unchanged so generated credentials remain usable. The real-CLI test now boots without explicit tokens and proves generated values appear on stdout while the file contains only |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (f47dfe8c35ef1d5e590b0ebcf984f0532e37fd9d). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Why
The desktop runs openwork-server in-process, so its structured logger only reached Electron's stdout — invisible in packaged builds. Every
Engine rollover requested. {engine.rollover.reason}, reload-watcher trigger, and MCP re-sync error was emitted and lost. Diagnosing today's engine churn (8 engine spawns in 25 min, each 1.1–1.6 GB) had to be reconstructed from sidecar run IDs and file mtimes; the actual rollover reasons are still unknown because nothing persisted them.What
OPENWORK_SERVER_LOG_FILEenables an append-only file sink (server-log-file.ts). It always receives structured JSON lines regardless of the stdout format, rotates once at 20 MB (file+file.1), disables itself on I/O errors, and redacts credential-looking attribute keys (authorization|token|secret|password|api[-_]?key|cookie|credential) before any line is written. Writes are synchronous appends on one descriptor; a stream opens its fd asynchronously and races the rotation rename.<userData>/logs/openwork-server.logbefore the embedded bundle loads (the server memoizes the sink fromprocess.envon first logger creation) and exposeslogFilePathin the server snapshot.Server log: <path>(en + ru).OpenworkServerInfo.logFilePath.No behavior change for the CLI unless the variable is set.
Verification
Lane: local (no Daytona prerequisites are needed for this server-only spec; nothing app-driving).
Boots the real
src/cli.tstwice: with the variable → JSON lines including the listening line (service.name=openwork-server,run.id,process.pid) and aGET /health 200line withstatus/durationMs, explicit--token/--host-tokenvalues absent, stdout still pretty; without the variable → no file, no directory.Verdict: Passed.
Follow-ups (separate PRs)
isolatedheadless world its ownOPENCODE_DB.