pg push service#547
Conversation
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
|
@wesm , I just pushed the last couple of tweaks to this work. As mentioned in my top comment, I added a system service (for MacOS and Linux) intended to push data from remote machines to a central pg instance without the need for a dedicated cron or manual pushes. It was motivated by a deployment of hermes that I just started using. I also added some other tweaks to the hermes parser because none of its tokens were being priced properly via my deployment. Let me know if there's any interest in merging these changes or changes like this! No worries if not, but I've been a fan of using agentsview and roborev per a recommendation from Hugh, and I thought I could contribute back. |
roborev: Combined Review (
|
roborev: Combined Review (
|
roborev: Combined Review (
|
Adds an auto-push mode that keeps PostgreSQL in sync without manual runs: - pg push --watch: long-lived daemon that does an initial catch-up push, then pushes on debounced file changes plus a periodic floor tick. It lazily connects and reconnects after errors so a transiently unreachable database never crashes the daemon, and bounds the shutdown flush so process exit cannot hang. - pg service: install/uninstall/status/start/stop/logs that run the watcher as a launchd LaunchAgent (macOS) or systemd --user unit (Linux). Service units only receive AGENTSVIEW_DATA_DIR, so install rejects env-dependent pg.url values and warns about other uninherited runtime env vars. Service unit values are validated to prevent injection. - internal/pidlock: single-instance file lock so only one watcher runs per data dir. - postgres push: sync usage_events independently of transcript messages so zero-message sessions' token/cost accounting still reaches PG. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ates - hermes: stop treating cost_status "included" as a confident $0 when cost_source is none/empty (Hermes's default for models it does not price, e.g. gpt-5.5). Such rows now leave cost_usd nil so they are catalog-priced. - hermes: populate the session-aggregate token columns (total output, peak context) from Hermes's own state.db accounting. - pricing: add gpt-5.5 and openrouter/owl-alpha fallback rates and bump FallbackVersion so the rates re-seed. - db: bump dataVersion to 30 so existing Hermes rows re-parse and pick up catalog pricing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
|
Merging this! Thank you |
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.