Repository navigation
feat: manager-controlled keep-alive strategies - #107
Merged
Merged
Conversation
added 5 commits
August 25, 2026 09:56
Scheduled, cross-account keep-alive policies (time windows, targets, per-strategy cost-vs-savings) layered above the existing per-account config and per-session override mechanisms. Signed-off-by: Osher-Elhadad <[email protected]>
The idle keep-alive ping mechanism was reachable only two ways: a manager
flipping one account-wide boolean, or arming a single session for up to 12h.
There was no way to run a schedule ("only during Israel business hours"), no
way to apply one policy across every account at once, and no way to see cost
vs. savings broken out per policy per account.
This adds a manager-authored, durable Strategy: Idle/MaxPings/MinPrefixTokens/
MaxUSDPerPing plus one or more time-of-day Windows (day-of-week, HH:MM, IANA
timezone) and a Target (every account, or a named list). It slots into the
keep-alive's existing resolution chain between account config and the
per-session override: account CachePolicy -> highest-priority matching ACTIVE
strategy -> session override (unchanged, still wins on top, still cannot widen
MaxUSDPerPing). Precedence among matching strategies is fixed, not
configurable: a list-target strategy beats an all-target one, and ties go to
the most recently updated.
Persistence lives in the tenant registry (new keepalive_strategies table),
because a strategy is a standing rule a manager expects to survive a deploy,
unlike a per-session override which is deliberately memory-only. It is loaded
into the keeper's memory at boot and reloaded on every write through the new
control routes, so a strategy created through the API matches on the very
next request with no restart.
New control routes (all manager-only, audited): GET/POST
/api/keepalive/strategies, PATCH/DELETE /api/keepalive/strategies/{id}.
Validation reuses the existing per-session override's numeric bounds for
Idle/MaxPings/MinPrefixTokens, plus its own checks for windows, timezone and
target shape.
A ping fired under a matching strategy is tagged with the strategy's id on its
own dash.Event (a new nullable, never-backfilled keepalive_strategy_id column
on `requests`), which a new dashboard route
(GET /api/keepalive/strategies/{id}/ledger) reads to show pings, ping cost and
each tenant's own keep-alive credit, grouped by tenant.
The dashboard gains a manager-only "Strategies" tab (create/edit form, a
table with active/pause/edit/delete and a per-tenant ledger), and every user's
Overview tab gets a small keep-alive savings callout reusing the existing
account ledger response.
One stdlib-only addition beyond the letter of the design: a blank import of
time/tzdata, so IANA zone data is compiled into the binary rather than
depending on the deployed image's OS packages (the shipped Dockerfile does
not install tzdata), which would otherwise make every window silently fail to
resolve its timezone.
Signed-off-by: Osher-Elhadad <[email protected]>
…lers The four new keep-alive strategy control routes relied only on the route table's ctlManager gate. Every other handler in this file's neighbourhood (ctlKeepAliveArm) re-checks the role inside the handler itself as defense in depth, and the list handler did not call webPrincipal at all. Add the same check to list/create/patch/delete. Also revert a strategy's PATCH when its audit write fails, the same way create already deletes what it cannot account for, so a strategy update never stands without an audit row. Signed-off-by: Osher-Elhadad <[email protected]>
docs/superpowers/ holds working design docs for the skill that authored them, not published site content. mkdocs build --strict was failing because the new keep-alive strategies spec had no nav entry. Signed-off-by: Osher-Elhadad <[email protected]>
OsherElhadad
pushed a commit
to OsherElhadad/context-guru-1
that referenced
this pull request
Aug 26, 2026
Resolves overlap with rossoctl#107 (manager-controlled keep-alive strategies, already on main) and rossoctl#108 (dash/api.go, dash/schema.go caching/index fixes). The predictor pipeline in this branch was built as a superset of rossoctl#107's base feature, so every conflict resolves by keeping this branch's version (already contains rossoctl#107's content plus the predictor gate on top); rossoctl#108's caching and index additions land untouched alongside it. Signed-off-by: Osher-Elhadad <[email protected]>
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
Adds a manager-controlled layer above the existing keep-alive mechanism: a strategy is a durable, scheduled rule (idle interval, max pings, time windows in a timezone, and a target of all tenants or a specific list) that a manager creates from a new dashboard tab. A matching strategy forces the keep-alive ping on for a request, overriding that tenant's own account-level off switch — evaluated live per request, so an "all tenants" strategy automatically covers tenants created after it was set up.
This sits above the existing per-account config switch and below the existing per-session override, both of which are unchanged:
/api/keepalive/strategies*), all manager-only, with an explicit role re-check inside each handler in addition to the route-table gate.keepalive_strategiesin the tenant registry DB, loaded into the keeper's memory and refreshed on every write — unlike per-session overrides, a strategy is meant to survive a restart.keepalive_strategy_idcolumn onrequests, additive, never backfilled.GET /api/keepalive/strategies/{id}/ledger) and a new manager-only "Strategies" tab; a small keep-alive savings callout on the Overview tab for every user.docs/superpowers/specs/2026-08-25-keepalive-strategies-design.md.Test plan
go build ./...,go vet ./...cleango test ./proxy/... ./dash/... ./tenant/... ./config/...— all passgo test -raceonproxy,dash,tenant— no racesGET /api/keepalive/strategies/{id}/ledger