.agents/memory/2026-02-23-auto-update-observability-plan.md

26 lines
2.1 KiB
Markdown

# 2026-02-23 Session Notes
## Auto-Update Observability Plan
Nicholai provided a comprehensive plan to add observability to Signet's auto-update system. The daemon currently has full update mechanics (GitHub/npm checks, package manager invocation, timer) but zero observability—errors vanish into logs, agents never know when Signet is outdated, and `/api/status` is blind to update state.
Root causes identified: `autoInstall` defaults to false (users never see updates), all update state is trapped as module-scoped bindings in daemon.ts (inaccessible to other modules), `getDaemonVersion()` silently returns "0.0.0" on failure, package manager fallback order favors npm over bun (misaligned with project standards), and the diagnostics system lacks an update health domain.
## Implementation Strategy
The plan calls for extracting the update system to a dedicated `update-system.ts` module (~350 LOC) following the singleton pattern used by `llm.ts` and `db-accessor.ts`. The module will export `getUpdateState()` and `getUpdateSummary()` for read-only access from anywhere in the daemon.
Update status will be surfaced in the session-start hook via `handleSessionStart` in hooks.ts, making it visible to agents during session initialization. A new `categorizeUpdateError()` helper will translate raw errors (rate limits, network failures, permission denied, etc.) into actionable messages.
API surface will expand: `/api/status` gains an `update` field with version info and error state, `/health` adds two booleans (`updateAvailable`, `pendingRestart`), and a new `UpdateHealth` domain joins diagnostics scoring.
## Implementation Order
1. Extract update-system.ts from daemon.ts
2. Wire initUpdateSystem() in daemon main, update route handlers
3. Add categorizeUpdateError() helper
4. Add getUpdateSummary() and wire into handleSessionStart
5. Expand /api/status and /health endpoints (parallelizable)
6. Add UpdateHealth to diagnostics.ts (parallelizable)
The plan emphasized that extracting update-system.ts unblocks all downstream work. Verification includes typecheck, runtime endpoint testing, and error categorization scenarios.