refactor(poller): share background job scheduling - #1703
Conversation
roborev: Combined Review (
|
9f570c1 to
39818e3
Compare
roborev: Combined Review (
|
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
39818e3 to
6f5f3b1
Compare
roborev: Combined Review (
|
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
6f5f3b1 to
110ea0b
Compare
roborev: Combined Review (
|
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
Add internal/cursorusage.Job, registered on the internal/poller Scheduler when cursor_admin_api_key is configured, so the archive stays current between manual `agentsview usage cursor` runs. Refactor the CLI command onto the same FetchAndStore helper the Job uses, so on-demand and scheduled fetches share one implementation and the existing cursor_usage_events dedup key holds across both. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): the poll's lookback window was a fixed 24h regardless of the configured interval, so an interval configured longer than 24h would permanently miss events landing in the gap between polls (the interval is 30m by default today, but [poller.intervals] can override it once the [poller] config lands). Add resolveLookback, which keeps the existing 24h default but grows the lookback to interval-plus-a-margin whenever interval exceeds it, so consecutive on-schedule polls always overlap.
…] config Add a [poller] config section (master enabled switch plus per-job interval overrides) plumbed through the same load/env/TOML spots as cursor_admin_api_key, and wire pricing refresh and the Cursor usage poll onto it via resolvePollerInterval. Add an IdleNotifier interface to internal/poller (Options.KeepsDaemonAlive, wired to server.IdleTracker) so a future job can opt into keeping an otherwise- idle detached daemon alive; both current jobs default to false, so neither does today. Add `agentsview doctor pollers`, an offline diagnostic that reads poller_status directly from the SQLite archive, and GET /api/v1/system/pollers, a live status endpoint backed by the running Scheduler, plus the generated frontend client for it. Fix roborev-ci finding on upstream PR kenn-io#1703 (kata vtk4): loadEnv runs before loadFile, so an explicit config.toml [poller] section unconditionally overwrote whatever AGENTSVIEW_POLLER_ENABLED set, even when the file only restated the default. Track that the environment variable set Poller.Enabled and skip the file's value in that case, so the documented environment override actually wins. Covered by a table-driven test over all four true/false combinations of env and file values.
110ea0b to
41ac768
Compare
roborev: Combined Review (
|
41ac768 to
4146917
Compare
Share startup job scheduling for pricing refresh and future Claude usage polling. Keep pricing writes serialized with resync.
4146917 to
987913c
Compare
|
@mariusvniekerk I feel much better about this. I took a machete to what the agents produced and positioned it properly for subsequent integration into use cases that might need to poll, like Claude usage window tracking. |
roborev: Combined Review (
|
|
Yeah that's much less. Thanks |
roborev: Combined Review (
|
Claude usage collection will also require polling. This moves pricing refresh
onto a shared scheduler so both jobs can use the same timing and retry behavior.
Jobs are configured at startup, with jitter, cooldown, capped retry backoff,
Retry-After support, and manual triggering. Pricing remains the only job; it
refreshes at startup and serializes writes with resync. State stays in memory,
with no new configuration, API routes, or tables.
Review
internal/pollerandcmd/agentsview/pricing_schedule.go.