Skip to content

refactor(poller): share background job scheduling - #1703

Open
jzila wants to merge 2 commits into
kenn-io:mainfrom
jzila:background-poller
Open

refactor(poller): share background job scheduling#1703
jzila wants to merge 2 commits into
kenn-io:mainfrom
jzila:background-poller

Conversation

@jzila

@jzila jzila commented Sep 10, 2026

Copy link
Copy Markdown

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/poller and cmd/agentsview/pricing_schedule.go.

@jzila
jzila marked this pull request as draft September 10, 2026 18:02
@roborev-ci

roborev-ci Bot commented Sep 10, 2026

Copy link
Copy Markdown

roborev: Combined Review (9f570c1)

Verdict: Changes require fixes for 2 findings.

Medium

  • internal/config/config.go:1743-1745: AGENTSVIEW_POLLER_ENABLED is loaded before the config file, but an explicit [poller].enabled value unconditionally overwrites it, so the documented environment override cannot take effect when the file specifies enabled. Preserve an environment-set value when applying TOML, or apply the environment override after loading the file; add a file-plus-environment precedence test.

    Reported by: codex

  • internal/cursorusage/job.go:22-26,51-58: Cursor polling always uses a fixed 24-hour lookback, even when the configured cursor-usage interval is longer, creating gaps where events are permanently missed. Make the lookback at least the configured interval plus scheduling jitter, or persist and use the last successful fetch boundary so consecutive polls overlap.

    Reported by: codex


Reviewers: 2 done | Synthesis: codex, 11s | Total: 9m28s

@jzila jzila changed the title feat(poller): extract a reusable background scheduler for periodic jobs refactor(poller): extract the pricing refresh loop into a reusable background scheduler Sep 10, 2026
@roborev-ci

roborev-ci Bot commented Sep 10, 2026

Copy link
Copy Markdown

roborev: Combined Review (39818e3)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 4m50s

@jzila
jzila marked this pull request as ready for review September 10, 2026 19:36
jzila added a commit to jzila/agentsview that referenced this pull request Sep 10, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 10, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
@roborev-ci

roborev-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

roborev: Combined Review (6f5f3b1)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 3m17s

jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
@roborev-ci

roborev-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

roborev: Combined Review (110ea0b)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 4m10s

jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
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.
jzila added a commit to jzila/agentsview that referenced this pull request Sep 11, 2026
…] 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.
@mariusvniekerk mariusvniekerk self-assigned this Sep 11, 2026
@jzila
jzila marked this pull request as draft September 11, 2026 13:06
@jzila jzila changed the title refactor(poller): extract the pricing refresh loop into a reusable background scheduler refactor(poller): share background job scheduling Sep 11, 2026
@roborev-ci

roborev-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

roborev: Combined Review (41ac768)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 3m59s

Share startup job scheduling for pricing refresh and future Claude usage polling. Keep pricing writes serialized with resync.
@jzila
jzila marked this pull request as ready for review September 11, 2026 17:34
@jzila

jzila commented Sep 11, 2026

Copy link
Copy Markdown
Author

@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-ci

roborev-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

roborev: Combined Review (987913c)

Verdict: Changes require fixes for 1 finding.

Medium

  • cmd/agentsview/main.go:462: The scheduler returned by poller.Start is discarded, so its goroutine is not waited on before engine and database cleanup run. A pricing refresh may remain blocked in RunExclusive or continue database work while shutdown closes its dependencies. Retain the scheduler, stop or cancel it, and call Wait during shutdown before closing the engine or database; use cancellation-aware lock acquisition if necessary.

    Reported by: codex


Reviewers: 2 done | Synthesis: codex, 8s | Total: 7m27s

@mariusvniekerk

Copy link
Copy Markdown
Collaborator

Yeah that's much less. Thanks

@roborev-ci

roborev-ci Bot commented Sep 12, 2026

Copy link
Copy Markdown

roborev: Combined Review (8d9f11b)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 5m47s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants