Repository navigation
fix: scheduling, email rework, auth sessions, chart improvements - #104
Merged
Merged
Conversation
…eling and bounded claim-ahead parking
…hase leveling and bounded claim-ahead parking
JitterFor/RegionIndex/NextAligned compute a per-job phase from data the worker already has (check UID, its regions, and the base/split period), so a rescheduled job always lands on the same phase-aligned tick regardless of how late it runs. Pure functions, no DB access — table-driven tests cover jitter determinism, region indexing edge cases, on-time/late/ restart-after-gap ticks, and region add/remove.
calculateNextScheduledAt now aligns rescheduling to the job's deterministic phase (scheduling.NextAligned) when the job's check is attached, instead of the old "scheduled_at+period on time / now+period when late" logic that re-anchored every late job to the same claim-batch timestamp after a restart (F2 — the lockstep bug). Both release paths (ReleaseLease via releaseLease, ReleaseLeaseWithSchedulingState via releaseLeaseWithCost) get phase-locking automatically since neither changes signature. Falls back to the previous anchor-preserving/catch-up logic when no check is attached (the remote-worker submit-result paths in backend/direct.go and handlers/workers/service.go fetch a bare job with no attached check and keep their own copies unchanged, per spec's explicit carve-out for callers lacking this data).
… (D2) reconcileCheckJobs now sorts regions before assigning indices (matching scheduling.RegionIndex's own sort), and re-levels scheduled_at / effective_scheduled_at to the phase-aligned tick whenever a job's period, config, or plan weight changes, or the region set itself changed (an add/remove shifts every survivor's index even when nothing else on that row changed). New jobs use the same phase formula, replacing the one-shot time.Now().Add(basePeriod*i) stagger that F1 identified as never being maintained after creation. Scope note: check *creation* (db/sqlite.go, db/postgres.go createCheckJobs) intentionally keeps pinning region 0's first scheduled_at to time.Now() — jittering it was tried and reverted because it silently broke the check.created express-runner path (ClaimJobsForCheck gates on scheduled_at <= now with no claim-ahead window), regressing "check created -> fast first result". This matches the spec's own D1/D2 scope, which cites only calculateNextScheduledAt (worker.go) and reconcileCheckJobs (this file) — not createCheckJobs. Region leveling for a fresh check takes full effect from its first reconcile (edit) or first organic release cycle.
…(D3) selectAvailableJobs previously gated on the flat FetchMaxAhead window (5 minutes by default), so a job's next scheduled_at was almost always already inside the window right after release — the runner claimed it immediately and slept in-slot for most of that window, parking ~22 of 25 runners on a typical multi-region fleet instead of the ~3 the poll cadence actually needs. Since period is stored as a Postgres interval / SQLite text (not a plain numeric column), an exact per-row SQL comparison would need dialect-specific interval arithmetic on both backends. Instead the SQL gate uses the coarser min(FetchMaxAhead, 30s) bound, and a Go-side post-filter immediately after Scan drops any row whose own tighter per-job clamp (period/2) isn't satisfied yet — those rows were only SELECTed (row-locked under Postgres FOR UPDATE SKIP LOCKED) but never leased, so the next poll picks them up once they're within their own window. Table-driven unit tests for the clampAhead formula plus integration tests against ClaimJobs on both SQLite and an embedded PostgreSQL (service_postgres_test.go, self-skipping under -short like the existing costdist_postgres_test.go pattern, port 15437).
The "Check job completed" log line previously reported duration_ms as time.Since(startTime) — the pre-schedule sleep, the probe execution, and the save/release overhead all folded into one number. A healthy sub-second check claimed minutes ahead of its scheduled_at (which D3's old unbounded claim-ahead window made common) logged as duration_ms≈179000, which sent live incident triage down a hung-checker path the fleet had already fixed. duration_ms now reports the actual exec time (time.Since(execStart)); the pre-schedule wait and the past-due dispatch delay are broken out into their own wait_ms/delay_ms fields via the new pure waitAndDelay helper (unit-tested directly rather than parsing log output, since the codebase has no slog-capture test helper).
Adds a parked atomic counter to CheckWorker, incremented for the duration of executeJob's pre-schedule sleep and decremented once the sleep resolves — visibility into how much of the pool D3's bounded claim-ahead window is occupying at any instant, distinct from "holds a lease" (the lease spans the whole executeJob call; parked only the sleep portion). Threaded through stats.ProcessingStats (new Parked field/SetParkedFunc, mirroring FreeRunners/SetFreeRunnersFunc) into the "Processing stats" log line and a new solidping_check_runner_parked Prometheus gauge (SetCheckRunnerParked, registered alongside WorkerFreeRunners). Also wires the pre-existing WorkerFreeRunners gauge into reportStats, since SetWorkerFreeRunners was defined but never actually called anywhere in production code — leaving only the new parked gauge live would have made the two report inconsistently (parked moving, free runners frozen at 0). Test drives a real runnerLoop with an instant (non-hanging) stub checker and a job claimed ahead of its scheduled_at, asserting parked reads 1 during the sleep and releases to 0 once the checker actually runs.
… leveling and bounded claim-ahead parking
TestClaimJobsFleetScaleClampBoundsParkedCount models the spec's exact incident scenario directly: ~28 jobs on a 3-minute split period spread evenly across their cycle, default FetchMaxAhead (5m). Asserts only a small fraction (well under half) are claimed at once, not nearly all of them — the aggregate counterpart to the existing per-job TestClaimJobsBoundedClaimAheadWindow unit tests, closing a self-review gap against acceptance criterion 4's concrete fleet-size framing.
Multi-region check jobs — durable phase leveling and bounded claim-ahead parking. - D1: calculateNextScheduledAt aligns rescheduling to a deterministic per-job phase (scheduling.NextAligned) instead of the old anchor/ catch-up logic that lost phase on any late run, causing lockstep after a restart (F2). - D2: reconcileCheckJobs re-levels existing jobs' scheduled_at on period or region-set change, not just at job creation (F1). - D3: selectAvailableJobs bounds the claim-ahead window per job to min(FetchMaxAhead, period/2, 30s) instead of the flat 5-minute default, so claimed-but-sleeping jobs no longer occupy most of the runner pool (F3). - D4: the "Check job completed" log now reports actual exec duration separately from the pre-schedule wait and past-due delay. - D5: a new parked gauge/counter and Processing-stats field give visibility into claimed-but-sleeping runner slots. See specs/todos/2026-07-05-08-multi-region-check-job-phase-leveling.md for the full diagnosis and design.
…leveling and bounded claim-ahead parking
…r-check unsubscribe Co-Authored-By: Claude Fable 5 <[email protected]>
…headroom under the Postgres role limit
Checks/jobs nodes default to MaxOpenConns 8 / MaxIdleConns 2 instead of the api/all 25/10, applied after SP_NODE_ROLE is known and before the SP_DB_MAX_OPEN_CONNS/SP_DB_MAX_IDLE_CONNS env overrides so those still win for any role. Adds ConnMaxIdleTime (koanf conn_max_idle_time, default 5m) so a quiet fleet's idle connections decay instead of pinning MaxIdleConns x replica-count against the Postgres role limit forever.
Runs once when a real (non-embedded) Postgres connection is created: compares this process's MaxOpenConns to rolconnlimit for current_user and logs a WARN with both numbers plus current pg_stat_activity usage when this process's ceiling alone can already exhaust the shared role's limit. rolconnlimit <= 0 (unlimited) emits nothing. Any query error, including permission errors on pg_roles/pg_stat_activity, is swallowed silently — this is a diagnostic signal, never a startup gate.
…ing and headroom under the Postgres role limit
… precedence Fixes a real gap caught by the new tests: SP_DB_CONN_MAX_IDLE_TIME was documented in applyDatabasePoolEnv's comment but never actually read. Covers: per-role defaults (all/api/checks/jobs/unknown), a config.yml-style pre-set value being left alone, and an end-to-end Load() precedence test proving SP_DB_MAX_OPEN_CONNS/SP_DB_MAX_IDLE_CONNS still win for a checks node.
…ping Covers acceptance criteria 3 and part of 4 (spec 2026-07-05-09): checkRoleConnLimitHeadroom against real CREATE ROLE ... CONNECTION LIMIT roles (warns when maxOpenConns >= rolconnlimit, silent when unlimited/comfortable/unbounded-pool/query-error), and applyPoolLimits' ConnMaxIdleTime bound proven via sql.DB.Stats().MaxIdleTimeClosed actually incrementing, not just 'was the setter called'. Follows the repo's only real-Postgres test mechanism (embedded-postgres via fergusstrange/embedded-postgres, self-skipping under -short exactly like costdist_postgres_test.go) — there is no testcontainers-go dependency in this repo despite server/CLAUDE.md's wording. Each test gets its own port to avoid bind conflicts, but they run sequentially (nolint:paralleltest) rather than via t.Parallel(): 7 concurrent embedded-postgres subprocesses starved this dev machine and made most of them self-skip via the unavailable-instance path, a resource- contention flake rather than a correctness issue.
It sets no env vars (unlike its t.Setenv-based sibling), so paralleltest correctly flagged the missing t.Parallel().
…and headroom under the Postgres role limit
TestLoad_NodeRolePoolPrecedence only proved the env override wins for the checks role (where applyNodeRolePoolDefaults first overwrites the default); TestLoad_NodeRoleAPIOverridePrecedence proves the same for api/all, where the role-default step is a no-op and the override must still apply directly.
…gradation Co-Authored-By: Claude Fable 5 <[email protected]>
DB connection pool — role-aware sizing and headroom under the Postgres role limit (spec 2026-07-05-09). - D1: checks/jobs nodes default to MaxOpenConns 8 / MaxIdleConns 2 (api/all keep 25/10), resolved after SP_NODE_ROLE is known and before the existing SP_DB_MAX_OPEN_CONNS/SP_DB_MAX_IDLE_CONNS env overrides. - D2: new ConnMaxIdleTime (koanf conn_max_idle_time, default 5m) reaps idle connections via sqldb.SetConnMaxIdleTime; SQLite unaffected. - D3: startup-only WARN when a real Postgres role's rolconnlimit is at or below this process's MaxOpenConns, naming both values plus current pg_stat_activity usage; silent on unlimited roles or any query error (never fails startup). - D4 (k8xp rolconnlimit bump) is out of this repo's scope. Tests: table-driven config coverage for per-role defaults and env override precedence (including a real gap this caught: the conn_max_idle_time env reader was documented but not wired), plus embedded-postgres coverage (this repo's actual "testcontainer" mechanism) for the headroom check and idle-time reaping.
…nd headroom under the Postgres role limit
…nks, per-check unsubscribe Co-Authored-By: Claude Sonnet 5 <[email protected]>
…board links, per-check unsubscribe Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ncident templates
Formatter.Format now returns a plaintext alternative alongside subject/HTML,
rendered from an optional {{define "text"}} block (empty when absent, so
existing HTML-only templates are unaffected). base.html gets a full design
pass: branded header, status-banner partial (red/green/amber full-width
bar), a table-based Outlook-safe button partial, and footer links to the
dashboard/docs/unsubscribe. Replaces the incident.html stub with four
per-event templates (created/resolved/escalated/reopened) that each define
subject/content/text, ready to be driven by notifications/email.go's
upcoming view-model (next commit).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Registration, password-reset, invitation, welcome, password-changed, and
both membership-request templates now use the table-based button partial
(Outlook-safe) for their primary CTA and each define a {{define "text"}}
block, so all templates — not just new incident ones — get a plaintext
alternative. Wiring stays untouched; this is styling only, per the spec's
"all emails" scope.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…t shared fetch-params helper
Splits the combined series into one per-region <Area> when more than one region is observed and no single region is selected. Each region keeps its own gap detection/insertion so an outage on one region breaks only that region's line. Stroke color cycles through --chart-1..5 by sorted slug order; chips gain a matching color swatch as legend. Dot-click resolution switches to a per-region dataKey (durationMs:<slug>) + activeLabel lookup since activeTooltipIndex no longer safely indexes a single shared array. Selecting one region, or single-region checks, keeps the exact single-series path (status gradient, gap bands) unchanged.
… stats strip Adds a resultsRegion URL search param (independent from the chart's own graphRegion) driving a segmented-button region filter in the Recent Results card header, shown only when more than one region is observed in the chart's current window — reusing that exact dataset (chartFetchParams, same react-query key) so deriving the region set and the stats strip costs zero extra HTTP requests. Clicking a row's region badge also sets the filter (badge becomes a real <button> styled with badgeVariants, keeping the Badge look while adding a hover/focus affordance). useResults gains a region option wired to the region= query param so the list narrows server-side. The stats strip (min/avg/max/p95/count) renders only when a region is selected, tier-aware per job_aggregation.go's actual combination formulas: min/max are exact min-of-mins/max-of-maxes, avg is the totalChecks-weighted mean of durationAvgMs (falling back to durationMs when a rollup row predates that field), and p95 is an unweighted average of each row's own p95 (raw rows contribute their own durationMs as a degenerate single-sample p95) — this mirrors calculateAggregatedMetrics, which does NOT weight p95 by count. Estimates (any rollup row in the window) are marked with a ~ prefix.
Playwright coverage for spec 2026-07-05-13's acceptance criteria: two stroke colors + chip swatches in the All-regions chart view, tooltip region line, dot-click pinning in multi-series mode, server-side region= filtering on Recent Results (chip + row-badge click), the tier-aware duration stats strip (exact vs ~-prefixed), and the single-region absence case (no chips/legend/strip).
…aKey Recharts' chart-level click middleware (mouseEventsMiddleware.js) always reports activeDataKey: undefined for a chart-wide onClick — it's only ever populated by an item's own hover/click listeners, which the multi-series Area rendering here doesn't wire up. The previous resolution (looking up the clicked region via activeDataKey) silently failed on every click in the All-regions multi-series view, so dots never pinned a result. Fix: use activeLabel (the shared x-axis ts, which recharts does populate for chart-level clicks) to narrow to the regions with a real point at that ts, then pick whichever candidate's cached dot position (dotPositions, already populated by every series' own dot/activeDot renderer) is closest in pixel space to activeCoordinate.y — i.e. the line actually under the click. Verified against the actual recharts 3.8.1 source (state/mouseEventsMiddleware.js, state/externalEventsMiddleware.js) and against a live Playwright run capturing the real click state.
… + Recent Results region filter with duration stats
Check detail: one chart line per region + Recent Results region filter with duration stats. Backend exposes durationAvgMs/durationP95Ms on aggregated results; the response-time chart splits into per-region series with independent gap detection and swatch-legend chips when more than one region is observed in "All regions" view; Recent Results gains a server-side region filter (header chips + clickable row badge) and a tier-aware min/avg/max/p95 duration stats strip computed from the chart's already-fetched window (zero extra HTTP). Fixes a multi-series dot-click resolution bug discovered during QA (recharts' chart-level click state never populates activeDataKey; resolved by pixel-proximity against cached dot positions instead).
…+ Recent Results region filter with duration stats
…t result navigation
fclairamb
enabled auto-merge (squash)
July 5, 2026 22:26
fclairamb
added a commit
that referenced
this pull request
Jul 5, 2026
PR #100's squash commit bundled 8 independently-audited specs behind one flattened bullet, and PR #104's squash commit used a non-standard "Batch:" type prefix that release-please's conventional-commit parser doesn't recognize at all, so its 7 specs were silently absent from this release entirely. Expand both into their actual constituent features, sourced from each PR's own itemized description. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eight specs implemented via
/implement-todos, each independently audited (a fresh, skeptical, read-only agent verifying the actual code and tests against every requirement — not the implementing subagent's own self-report) before being archived. Two subagent crashes occurred mid-batch (API connection errors) and were recovered from partial state rather than restarted from scratch.connecting/live/reconnecting/disabled), single-flight-safe.~prefix over rollup windows, verified to match the aggregation job's own weighting math).Test plan
specs/done/2026/07/.make build-backend lint-back testgreen throughout, including dual-backend (SQLite + real embedded-Postgres) coverage for the DB-pool, multi-region scheduling, and result-neighbor specs.make build-dash0+bun run lintgreen with zero new ESLint errors introduced (pre-existing ~45-error baseline unchanged); Playwright E2E added for the sidebar dot, per-region chart/filter/stats, and result prev/next navigation.linux/amd64and deployed to the k8xp dev cluster (all threesolidping-devdeployments) for live testing;/api/mgmt/versionconfirmed the deployed commit.🤖 Generated with Claude Code