pg push service#547
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…sts) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a defaultFlushTimeout (30 s) and a flushTimeout field on pushLoop so a SIGTERM'd daemon cannot hang indefinitely on a stalled PostgreSQL connection during the final shutdown-flush push. Zero means unbounded, preserving the existing test behaviour where newTestLoop leaves the field unset. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…op/logs) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and promptYesNo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… --watch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…note KeepAlive tradeoff Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
Reject control characters and double quotes in BinPath/DataDir/LogPath at the buildServiceSpec chokepoint so a crafted data dir cannot break out of a quoted value and inject directives into the systemd unit (ExecStart, Environment) or launchd plist. Export config.IsEnvDependentURL and reuse it in the service manager so the env-dependent pg.url rejection shares expandBracedEnv's exact patterns and cannot silently desync. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
The background service unit only carries AGENTSVIEW_DATA_DIR, so env vars that affect runtime behavior (AGENTSVIEW_PG_SCHEMA, AGENTSVIEW_PG_MACHINE, agent dir overrides) set in the installing shell are not seen by the service, which instead uses config.toml or defaults. Install now warns about any such vars that are set so the divergence is not silent. This is advisory only and does not change the intended environment-overrides-config semantics; AGENTSVIEW_PG_URL remains a hard rejection since a missing URL breaks the service outright. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
roborev: Combined Review (
|
Problem
I track token usage across AI tools with agentsview, and lately I've been
running more remote agent tools on machines other than my primary dev box.
Each of those machines records its own sessions locally. The Postgres support
(
pg push/pg serve) already lets me review everything together, butkeeping the shared database current meant either remembering to run
pg pushby hand on each machine or wiring up a bespoke cron job per host. I wanted a
touchless way to sync data from multiple machines into one place so remote
agent token usage shows up in my primary dashboard automatically, without
maintaining custom cron entries everywhere.
I also made some updates to hermes specific code because although tokens
were being passed through, the associated costs were not being aggregated
properly.
pg push service
A long-running auto-push daemon and a first-class way to install it as an OS
service, so a recorder machine keeps the shared Postgres current on its own.
agentsview pg push --watchstart a foreground daemon that pushes to Postgresshortly after sessions change, with a periodic floor as a safety net:
serve) coalesces changeevents over a debounce window (
--debounce, default 30s) and triggers alocal sync + incremental push.
--interval, default 15m) pushes regardless of fileevents and covers any directories the watch budget couldn't cover.
reconnecting on error. A transiently unreachable database is logged and
retried on the next trigger rather than crashing the daemon.
watermarks. On shutdown (SIGINT/SIGTERM) it performs one bounded final flush.
[pg]config and project filters aspg push, andhonors
result_content_blocked_categoriesso the push path no longerdiverges from
serve.agentsview pg service install|uninstall|status|start|stop|logsinstalls and manages the daemon as a per-user OS service:
systemd --userunit on Linux, behind a smallplatform abstraction with pure (golden-tested) unit-file rendering.
installvalidates that the Postgres DSN is resolvable before creating theservice, and surfaces the systemd linger requirement so the service keeps
running on headless boxes after logout.
statusreports the manager state plus the last successful push time;logs -ftails the daemon log and survives log rotation.The daemon reads the DSN from the existing config file (no credentials are
copied into unit files), so protecting
config.tomlis sufficient.Notes
systemd --user); thedaemon command itself is cross-platform Go.
AGENTSVIEW_DATA_DIRto the install-time datadir, so the service resolves the same config regardless of the environment it
starts in.
Vacuum/BackfillSignalssteps, since signal recomputation happens on theserve side.
windows machine that I could use for testing.