You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: harden doctor, keychain fallback and service log after #15 #16
Follow-up from the review of #15. None of these blocked the merge.
Acceptance criteria:
doctor catches a keychain error from store.apps() (locked or unreachable) and prints a FAIL line with the reason, instead of exiting with a bare error.
When the keychain refuses a secret and tether falls back to credentials.json (in connect and in start's moveToKeychain), it prints a warning with the reason.
service.log has a size limit or rotation, and service install sets 0600 on an existing log too.
Reinstalling over a running launchd agent works: bootstrap retries or waits after bootout.
logTask caps the stored title length (about 200 chars).
If logTask throws in worker.ts, the task is logged once and its reservation is still released.
Drop network-online.target from the systemd user unit, and set persist-credentials: false in release.yml.
Before the first release: one manual run with the keychain on under the real macOS service (install, run one task) and under a systemd user unit, results noted here.
doctor: read the connected apps inside a try. A keychain error (locked, no session bus) becomes a FAIL line with the store's own message ("the credential for X is in the keychain, but ... Unlock the keychain"), and the app checks are skipped. Exit status 1.
Keychain fallback warning: Keychain.set returns why it refused the secret (or nothing when it holds it) instead of a bare boolean: a value security -i cannot quote, the tool's exit status, or a write that does not read back. For secret-tool the first line of its stderr is included (the secret only ever travels on its stdin); for security -i only the exit status, since its stdin command line carries the secret. Store.saveApp returns where the credential went plus a warning when the keychain refused it; moveToKeychain returns its warnings. connect and start print them on stderr. No keychain at all (Windows, TETHER_KEYCHAIN=off) stays silent: the file is the intended place there.
service.log: Store.trimServiceLog() cuts the file to its last ~1 MB once it passes 5 MB, rewriting it in place (launchd and the Windows >> both append, so the running service keeps writing at the new end). start runs it at startup and the worker after each finished task. service install on macOS sets 0600 on an existing log as well as creating a missing one 0600.
Reinstall over a running launchd agent: when bootout succeeded (the agent was loaded), bootstrap is retried up to 10 times, one second apart (through sleep 1 on the same runner, so tests stay instant), and the last error is reported. A first install is unchanged.
logTask stores at most 200 characters of the title (cut on code points).
worker.ts: the task's outcome is settled first, then logged exactly once inside its own try; a throwing log prints one line and the reservation, the usage, the slot and the run state are still released.
Drop After=/Wants=network-online.target from the systemd unit; persist-credentials: false on the checkout in release.yml.
The manual real-service runs (keychain on, macOS launchd and a systemd user unit) stay with the owner before the first release; the PR will say they were not run.
Invariants not to break: no secret in any log line, warning or error (the warnings name the origin and the file path, never the credential); local policy and spend reservations unchanged; credentials.json stays 0600; existing keychain behaviour (read back after write, locked vs missing) unchanged.
Tests (each written first and seen failing):
doctor with a credential marked as in the keychain and a keychain that cannot be read: exit 1, a FAIL line naming the keychain, no thrown error.
connect with a refusing keychain: stderr warns with the reason and names credentials.json; start with a refusing keychain and a file credential warns the same way. Unit tests for the reasons from both keychain backends.
store: a log over the limit is cut to its tail on a line boundary, a small one is left alone; title capped at 200.
service: an existing 0644 log is 0600 after install; a bootstrap that fails once after a successful bootout is retried and install succeeds; one that keeps failing reports the error.
worker: with tasks.jsonl unwritable, two queued tasks at concurrency 1 both complete (the slot and reservation came back) and the failure is printed once per task.
systemd unit snapshot without network-online.target.
In progress. The fixes and their tests are on the branch fix/16-harden-doctor-keychain-fallback, in draft PR #17. Next: the full test run, the quality gates, then the PR description and review. The plan review asked for two changes, both taken: bootstrap is retried on every failure (bootout can exit 36 while the old agent stops), and the service log is not trimmed in place on Windows, where cmd's >> keeps writing at its old offset.
Ready for review: #17. Criteria 1 to 7 are done, each with tests. Lint, typecheck and CI (Linux and macOS, including the real launchd install) are green; every changed function is under CRAP 10; no duplication; the three surviving mutants are equivalent and the PR lists them. Still open: criterion 8, the manual keychain-on runs under the real launchd service and a systemd user unit before the first release. The Windows service log has no size limit yet, because cmd's >> keeps its write offset; the PR explains why.
Notes: on this repo a mutation run against one targeted test file finishes in under a minute, so the full suite isn't needed for mutation testing.
Activity
parsilver commentedon Nov 14, 2026
Work has started.
parsilver commentedon Nov 14, 2026
Plan for this issue.
Approach, one item per acceptance criterion:
doctor: read the connected apps inside a try. A keychain error (locked, no session bus) becomes aFAILline with the store's own message ("the credential for X is in the keychain, but ... Unlock the keychain"), and the app checks are skipped. Exit status 1.Keychain.setreturns why it refused the secret (or nothing when it holds it) instead of a bare boolean: a valuesecurity -icannot quote, the tool's exit status, or a write that does not read back. Forsecret-toolthe first line of its stderr is included (the secret only ever travels on its stdin); forsecurity -ionly the exit status, since its stdin command line carries the secret.Store.saveAppreturns where the credential went plus a warning when the keychain refused it;moveToKeychainreturns its warnings.connectandstartprint them on stderr. No keychain at all (Windows,TETHER_KEYCHAIN=off) stays silent: the file is the intended place there.service.log:Store.trimServiceLog()cuts the file to its last ~1 MB once it passes 5 MB, rewriting it in place (launchd and the Windows>>both append, so the running service keeps writing at the new end).startruns it at startup and the worker after each finished task.service installon macOS sets 0600 on an existing log as well as creating a missing one 0600.bootoutsucceeded (the agent was loaded),bootstrapis retried up to 10 times, one second apart (throughsleep 1on the same runner, so tests stay instant), and the last error is reported. A first install is unchanged.logTaskstores at most 200 characters of the title (cut on code points).worker.ts: the task's outcome is settled first, then logged exactly once inside its own try; a throwing log prints one line and the reservation, the usage, the slot and the run state are still released.After=/Wants=network-online.targetfrom the systemd unit;persist-credentials: falseon the checkout inrelease.yml.Invariants not to break: no secret in any log line, warning or error (the warnings name the origin and the file path, never the credential); local policy and spend reservations unchanged; credentials.json stays 0600; existing keychain behaviour (read back after write, locked vs missing) unchanged.
Tests (each written first and seen failing):
FAILline naming the keychain, no thrown error.parsilver commentedon Nov 14, 2026
In progress. The fixes and their tests are on the branch fix/16-harden-doctor-keychain-fallback, in draft PR #17. Next: the full test run, the quality gates, then the PR description and review. The plan review asked for two changes, both taken: bootstrap is retried on every failure (bootout can exit 36 while the old agent stops), and the service log is not trimmed in place on Windows, where cmd's >> keeps writing at its old offset.
parsilver commentedon Nov 14, 2026
Ready for review: #17. Criteria 1 to 7 are done, each with tests. Lint, typecheck and CI (Linux and macOS, including the real launchd install) are green; every changed function is under CRAP 10; no duplication; the three surviving mutants are equivalent and the PR lists them. Still open: criterion 8, the manual keychain-on runs under the real launchd service and a systemd user unit before the first release. The Windows service log has no size limit yet, because cmd's >> keeps its write offset; the PR explains why.
Notes: on this repo a mutation run against one targeted test file finishes in under a minute, so the full suite isn't needed for mutation testing.