Skip to content

feat(keepalive): the audit-sink rule applies in hosted mode only (#1457) - #1470

Merged
amiddavid merged 6 commits into
mainfrom
feat/keepalive-audit-hosted-only
Nov 26, 2026
Merged

amiddavid merged 6 commits into
mainfrom
feat/keepalive-audit-hosted-only

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change (needs the owner's yes)

  • Who: a single-tenant proxy run without --dashboard: a container or a hand-run binary. The personal installer always passes --dashboard, so it does not change.
  • Old: the proxy held no thread and sent no ping. The Ping button answered 404.
  • New: the proxy holds the thread in memory and pings under the account's cache strategy. This costs pings. The Ping button works.
  • Also: the arm gate follows the same rule. It changes only the refusal text in hosted mode. The arm route is mounted by MountControl, which needs Options.Tenants, so single-tenant arming does not exist and this PR does not add it.
  • Off switch: set the cache strategy to none, or set the kill switch CONTEXT_GURU_KEEPALIVE=off.
  • Unchanged: hosted mode, and library hosts (Cortex, bifrost).

Decided by: David Amid, 2026-11-26 (design in #1457). The integrator confirms the yes before merge.

Summary

  • The "no audit sink, no retention" rule now applies only in hosted mode.
  • The hosted signal is Options.Tenants != nil, the signal the proxy already uses. No new flag.
  • The decision is a library function, keepalive.MayHoldCredentials. The proxy calls it from keeper.mayHold.

What changed

  • keepalive/mayhold.go: hosted and no sink gives no hold. Everything else gives a hold. A failure in reading the signal falls back to the old rule (a sink is needed).
  • proxy/keepalive.go: recordTouch and canPing use mayHold.
  • proxy/keepaliveoverride.go: arm uses mayHold (only the hosted refusal changes in effect).
  • proxy/manualping.go: the Ping route uses mayHold. With no dashboard it reads the cold gate from the keeper (Keeper.WarmFacts: last touch and lifetime, times only).
  • proxy/proxy.go: the Ping route stays mounted with no dashboard.
  • proxyapp/main_run.go: the startup line says "IMPOSSIBLE" only for hosted mode with no recorder. Comments updated.
  • Nothing else in the ping path reads h.rec without a nil check. The ping row is already nil-safe, and BookPing (fix(accountant): book ping savings without the dashboard, credit a manual ping's rescue #1461) runs first.

How it was tested

macOS, Go 1.27.4. go build ./..., go vet, plain go test on keepalive, proxy, proxyapp, components/all. -race -run on the new tests.

  • Single-tenant, no dashboard: a thread is held, a ping fires on a fake upstream with the caller's own header, the savings path is booked, and the Ping route sends one ping, refuses a cold thread (409) and an unknown session (404).
  • Hosted, no recorder: no hold, no ping, canPing false, Ping route 404.
  • Hosted with a recorder: holds, as before.
  • Fail open: an unreadable hosted signal gives the old rule.
  • Savings with no dashboard: TestAPingBooksSavingsWithNoDashboard (proxyapp) already pins the llm_savings_* booking from fix(accountant): book ping savings without the dashboard, credit a manual ping's rescue #1461.
  • Three old tests assumed the rule everywhere. They now set hosted mode first.
  • Mutations: (1) hosted check dropped, so single-tenant stays off: 2 tests fail. (2) hosted holds without a recorder: 3 tests fail. (3) the fail-open fallback answers true: 1 test fails.

Data dependence

keep-alive-pings and accountant-savings rows updated, docs/data-dependence.md regenerated. Keep-alive now depends on stored data (body and credential, in memory) with no dashboard, in single-tenant mode only. Decided by: David Amid, 2026-11-26.

Credential handling

The credential lives in process memory only.

  • This PR adds no write path. The keeper holds it as before.
  • The test uses the fake key sk-test-SECRET. It checks that the captured logs do not contain it, and that a temp state dir (also HOME, TMPDIR, and the working directory) holds no new file after a held ping and a manual ping.
  • The ping row is not written with no dashboard. Metrics carry numbers only.
  • I found no path that persists it. The audit of the other paths runs in parallel (see fix(proxy): book keep-alive ping savings without the dashboard #1457).

Open questions

  • Follow-up: single-tenant per-session arming needs the arm route mounted without a tenant registry. Not in this PR. Should it be?

Fixes #1457

Local tests: waived (owner rule)

🤖 Generated with Claude Code

@amiddavid amiddavid added the openai OpenAI / Codex traffic and pricing label Nov 26, 2026

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 4 c8847751feb8 blocking

Verdict: blocking

Findings

  1. PR body, "Behavior change" section — the claim that per-session arming works with no dashboard in single-tenant mode is false
    • What fails: the owner approved a behavior-change list that says "per-session arming (arm) follows the same rule, so it works with no dashboard in single-tenant mode". No route can reach arm on a single-tenant proxy. A user who tries to arm gets a 404, not the promised behavior.
    • Proof: MountControl mounts nothing when Options.Tenants is nil (proxy/control.go:188-191). The arm route POST /api/me/keepalive/sessions lives in ctlRoutes (proxy/keepalivectl.go:45), mounted only by MountControl. The only caller of keeper.arm is ctlKeepAliveArm (proxy/keepalivectl.go:135). In proxyapp, Tenants is set only when --upstreams is given (proxyapp/main_run.go:756), so a single-tenant proxy never mounts the control plane. The mayHold change in arm (proxy/keepaliveoverride.go:133) is unreachable in single-tenant mode.
    • Fix: correct the PR body. Drop the "Also" bullet, or say the arm gate only changes its refusal message for hosted deployments. If single-tenant arming is wanted, mount the route in its own PR.

Non-blocking

  • proxy/manualping.go:116-123 — with no dashboard, the cold gate covers only threads the keeper holds now. The dashboard path covered every thread with a row in the last 2 hours. A thread whose hold ended answers 404 "unknown session", where the dashboard path answers 409 "not held" with a reason. Same status as before this PR for a missing route, so no regression. Consider the 409 shape later.
  • keepalive/manualhold.go:118 — WarmFacts repeats the body of kaEntry.cacheTTL() (cacheLifetime(e.provider, e.model, e.ttl1h), keepalive/keeper.go:1971). Call e.cacheTTL() so the two cannot drift.
  • proxy/proxy.go:649-651 — the comment above if h.api != nil still says an unconfigured proxy's route table is unchanged, but mountManualPing now adds a route with no dashboard. The comment is stale in spirit.
  • Test gap: the keep-alive-off, header-on hold (x-context-guru-ping: 1) with no dashboard in single-tenant mode is a new reachable state and has no test. The new tests cover the keep-alive-on path only.
  • keepalive/mayhold.go:141-151 — the recover guards a hosted function that cannot panic today (k.h.opts.Tenants != nil). Harmless. The fail-closed direction is right.

What I checked

  • The full diff, base f9ec697c to head c8847751, and the code around each hunk.
  • The gate matrix: mayHold replaces k.h.rec == nil in recordTouch, canPing, arm and manualPing. For hosted with a recorder, hosted without one, and single-tenant with one, the old and new answers match. Only single-tenant without a dashboard changes, from no hold to hold. That is the named behavior change.
  • The hosted signal: Options.Tenants != nil in the proxy, --upstreams in proxyapp. Both mark the same deployments. The startup "IMPOSSIBLE" line now fires for hosted without a recorder only.
  • The no-dashboard Ping button: WarmFacts reads the same live map, key form and tier rule (cacheLifetime) that Record writes. The session form matches: scopedSession with an empty tenant gives the bare id, the same form serve hands to recordTouch.
  • Production wiring with no dashboard: the dashEmitter is built before the dashboard block (proxyapp/main_run.go:368), KeepAlivePing calls BookPing before the recorder check, and the savings observer comes from startMetricsPush, which runs without a dashboard. The booking the data-dependence row promises is wired.
  • Auth on the newly mounted route: adaptPrincipal with no registry accepts direct loopback callers only, the same principal as /api/adapt/*.
  • The new tests: helpers referenced (reportSink, fakeSender, testClock, waitPings, newMgrFixture, NewPingStore) all exist in the package; countObs matches acmetrics.Observer; no name collisions. The tests wait on conditions, not time.
  • Data dependence: the keep-alive-pings and accountant-savings row files and the generated page carry the same text; the flags-table edit appears in both the template and the generated page. The change of level (in-memory hold with no dashboard, single-tenant only) is named and decided by David Amid, 2026-11-26.
  • Client rules: none added; no coverage-table change needed. Host boundary: the rule itself is keepalive.MayHoldCredentials, a library function; the proxy only reads its own fields.
  • I did not run builds or tests (live tests not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 4 c8847751feb8 approve

Verdict: approve

Findings

None. I found no wrong behavior, no data loss, no broken fail-open path and no security problem.

Non-blocking

  • proxy/manualping.go:29-31 — the file's header comment overstates the "not held" answer. It says a thread with keep-alive off gets "a distinct 409 'not held'". With no dashboard, WarmFacts returns ok=false for a thread that is not held (keep-alive off, or the hold expired), so the route answers 404 "unknown session", not 409. The dashboard path still answers 409 through PingNow's ErrNotHeld. Doc-only: the plugin always passes --dashboard, so the mod never sees the 404.
  • keepalive/mayhold.go:147-150 — the panic fallback for hasAuditSink=true is unreachable. if hasAuditSink { return true } runs before hosted(), so a panic can only occur with hasAuditSink=false, where the answer is already false. TestMayHoldCredentialsFailsToTheOldRule calls MayHoldCredentials(boom, true), but boom never runs there. Harmless, but the test does not prove what its name says for that case.
  • keepalive/manualhold.go:272-291 — WarmFacts has no test for the 1-hour tier. The route test covers the 5-minute cold path only. A thread held at the 1-hour tier (e.ttl1h=true) should give a 59-minute window; nothing pins that cacheLifetime is read from the entry's own tier.
  • docs/data-dependence/features/body-stash.md:10 — the no-dashboard case is not named. canPing is now true for a single-tenant proxy with no dashboard, so the sweep also keeps its 2 in-memory conversation copies for those threads, where before it kept none. The row's text ("for a thread the keep-alive can ping") stays true, and the keep-alive-pings row names the new mode. A sentence in this row would make the widening explicit.

What I checked

  • The rule and its placement. keepalive.MayHoldCredentials is a library function; the proxy's keeper.mayHold only reads the host signal (Options.Tenants) and the recorder. No business logic moved into a host package. No client rule touched.
  • The hosted signal. Options.Tenants is set exactly when --upstreams is given (proxyapp/main_run.go:538-604), and the startup line's condition !*dashOn && *upstreamsPath != "" matches mayHold exactly. Only cmd/context-guru-proxy constructs a hosted handler.
  • The retention gate. recordTouch sets a zero policy when !mayHold, which makes the keeper core retire the key; pol.ManualHold is then never set, so the x-context-guru-ping header cannot widen the rule (test pins this). No other keepalive gate in proxy/ still reads h.rec without a nil check.
  • The Ping button without a dashboard. WarmFacts reads refreshedAt/startedAt and cacheTTL() under the keeper's lock — the same facts holdFor and the core's own cold check use. ManualPingBlock, OneHourTouchLive and PingNow are keeper-core and need no recorder. mountManualPing moved out of the h.api != nil block; adaptPrincipal and webPrincipal are nil-api safe, and a hosted proxy with no recorder answers 404 through mayHold.
  • The booking path. dashEmitter.KeepAlivePing calls BookPing before the rec check; the emitter (metrics.Tee) is wired with or without --dashboard, so a ping's spend books with no dashboard.
  • Side effects of widening canPing. Ctx.CanKeepAlive has one consumer, the sweep's registerPing. The sweep's copies and its ping-time question (PrefixAsk, Store) need no dashboard. The predictive campaign needs no recorder. The idle-exit watchdog counts PendingPings, keeper-core.
  • Behavior change and data dependence. The PR names the change at the top, with who, old and new behavior, and the off switch. The decision is recorded (David Amid, 2026-11-26, #1457) in the keep-alive-pings and accountant-savings rows. The generated page matches the row files, and the flags-table edit is in both page.md.tmpl and the generated page.
  • Tests. Read the new keepalive_singletenant_test.go and the three updated tests in full; helpers (kaPolicy, fakeSender, testClock, reportSink, syncBuffer, newMgrFixture.register) exist and the signatures match. No name collisions in the package.

amiddavid added a commit that referenced this pull request Nov 26, 2026
- WarmFacts uses the entry's cacheTTL; a 1-hour-tier test pins it.
- Test for the header hold with no dashboard.
- Fix the route-table and Ping-route comments.
- body-stash row: the in-memory copies now exist with no dashboard too.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Replies to round 1

ed4aff0d merges main (accountant v0.10.0). 83378839 holds the fixes.

Reviewer 1, finding 1: the PR body claimed per-session arming works single-tenant. Corrected. The arm route needs MountControl, which mounts nothing without Options.Tenants. So in this PR, the arm gate change only affects the refusal in hosted mode. Single-tenant arming is listed as a follow-up in Open questions, and no route is mounted.

Non-blocking notes, both reviewers:

  • WarmFacts calls e.cacheTTL(), so the two cannot drift. TestWarmFactsReportsTheOneHourTier checks that a 1-hour entry has a 1-hour lifetime, and that a press 30 minutes later is not cold.
  • The stale comments in proxy/proxy.go (route table) and proxy/manualping.go (409 vs 404) are fixed. The second now says: 409 "not held" when the keeper holds the thread's row, and 404 with no dashboard for a thread the keeper does not hold.
  • TestHeaderHoldWorksWithNoDashboard covers keep-alive off and header on, single-tenant with no dashboard. The thread is held, a press pings, and no scheduled ping follows.
  • TestMayHoldCredentialsFailsToTheOldRule: the panic case uses hasAuditSink=false. A comment now says so.
  • body-stash.md: a single-tenant proxy with no dashboard keeps the sweep's in-memory conversation copies for threads it can ping. A hosted proxy with no dashboard keeps none. The page is regenerated.
  • The recover in mayhold.go stays as a fail-closed guard.

Tests (macOS, Go 1.27.4): build and vet are clean. Plain go test passes on proxy, keepalive, proxyapp and components/all.

Local tests: waived (owner rule)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 4 8337883931a8 approve

Verdict: approve

Findings

None. My round-1 finding is fixed and verified. The new commit adds no defect I can show.

Earlier findings

  • Reviewer 1, finding 1 (PR body claimed single-tenant arming): fixed. The PR body's "Also" bullet now says the arm gate changes only the refusal text in hosted mode, that MountControl needs Options.Tenants, and that this PR adds no single-tenant route. I read the live PR body and checked it against proxy/control.go:188-191 and proxy/keepalivectl.go:45. The claim now matches the code. The follow-up question sits in Open questions.
  • Reviewer 2, round-1 notes (all non-blocking): fixed. I checked each myself:
    • The 409/404 comment in proxy/manualping.go:31-32 now states both answers. It matches the code paths (WarmFacts miss → 404; held but off → 409).
    • The panic fallback in keepalive/mayhold.go: the code is unchanged and harmless; the test now carries a comment that the panic case runs with no sink. Accept.
    • TestWarmFactsReportsTheOneHourTier pins the 1-hour tier. I traced ResolveTier: the test body sets "ttl":"1h" on every breakpoint and bills CacheWrite1h == CacheWrite == 1200, so ttl1h is true and WarmFacts must report 1 hour.
    • docs/data-dependence/features/body-stash.md now names the no-dashboard case. The generated page carries the same sentence.

Non-blocking

  • proxy/keepalive_singletenant_test.go:243-246 — the press check in TestWarmFactsReportsTheOneHourTier fails only on a 409 whose body contains "cold". A 404 or another 409 would pass silently. The direct ttl == time.Hour assertion carries the test, so this is minor. Asserting w.Code == 200 would be stronger.

What I checked

  • Last review: round 1, c8847751feb801bbadc98c6a38ecc5e339958b45, 2026-11-26T14:35:48Z.
  • New commits read: 3 — ebd659bb (accountant v0.10.0, from main), ed4aff0d (merge of main), 83378839 (round-1 fixes).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
  • New items since my last review: reviewer 2's round-1 review (approve, 4 non-blocking notes — each checked above); the author's reply comment (checked each claim against the code); the fix commit (reviewed below); the main merge (checked below).
  • The fix commit 83378839: WarmFacts now calls e.cacheTTL(), so it cannot drift from the core's rule. The two new tests: TestHeaderHoldWorksWithNoDashboard holds a thread with a zero policy and the header, presses it (200), and shows no scheduled ping follows — I traced recordTouch (ManualHold set on the mayHold path) and the manual-only entry's retirement. TestWarmFactsReportsTheOneHourTier as above. The comment fixes in proxy/proxy.go and proxy/manualping.go match the code.
  • The merge ed4aff0d: go.mod pins released tags (accountant v0.10.0), which the merge brings in from main — allowed by the pin rule. The merged docs/data-dependence.md keeps both sides: the v0.10.0 metrics-push text and this PR's rows. The accountant change (Withhold, Check.Claims) touches nothing this PR's tests assert (Result.Ops length only).
  • Data dependence at head: the body-stash row and the generated page carry the same sentence; the other rows are as checked in round 1.
  • I did not run builds or tests (live tests not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 4 8337883931a8 approve

Verdict: approve

Findings

None. Every fix is in and correct. I found no new defect in the new commits.

Earlier findings

  • Reviewer 1, finding 1 (the PR body claimed single-tenant arming works): fixed. The body now says the arm gate changes only the refusal text in hosted mode, names MountControl and Options.Tenants as the reason, and says this PR adds no single-tenant arming. I checked the claim against the code in round 1: MountControl returns early when Options.Tenants is nil, and keeper.arm has one caller, the control route. The corrected text matches the code.
  • My non-blocking notes: all addressed.
    • WarmFacts now calls e.cacheTTL() (keepalive/manualhold.go:291), so it cannot drift from the core's own rule. Fixed.
    • The manualping.go header comment now states the 404 answers (not held with no dashboard, hosted with no recorder). Fixed.
    • TestWarmFactsReportsTheOneHourTier pins the 1-hour tier. Added.
    • The body-stash row names the no-dashboard single-tenant case, and the generated page carries the same sentence. Fixed.
    • The mayhold.go recover stays, with a comment on the panic test case. The author kept it as a fail-closed guard. I accept: it is harmless and the safe direction.

Non-blocking

  • proxy/keepalive_singletenant_test.go:161-164 — the "not cold" assertion is weak. The test errors only when the answer is a 409 and the body says "cold". A 409 "not held" (the entry is past its hard deadline after 30 minutes with no sweep) would also pass. The first assertion (ttl == time.Hour) is the real pin, so this costs little.
  • keepalive/mayhold.go — MayHoldCredentials(boom, true) still does not exercise the panic path. The comment added to the test says the panic case uses hasAuditSink=false, which is accurate. The hasAuditSink=true fallback in the recover stays unreachable. Kept knowingly; no action needed.

What I checked

  • Last review: round 1, c884775, 2026-11-26T14:36:14Z.
  • New commits read: 2 (ed4aff0d merge: origin/main into feat/keepalive-audit-hosted-only; 83378839 fix(keepalive): round 1 of #1470). The merge brings main's ebd659bb (accountant v0.10.0 bump) with it.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 1's round-1 review (14:35:48Z, read now for the first time), the author's reply comment (14:40:07Z), and the two commits. I checked each one; results above and below.
  • The fix commit. Read the whole diff and the changed files around each hunk: WarmFacts → e.cacheTTL(), the two comment fixes, the body-stash row and the regenerated page, and the two new tests.
  • TestWarmFactsReportsTheOneHourTier. Traced the tier: the body asks extended TTL on every breakpoint (strings.ReplaceAll changes all three), Usage.CacheWrite1h == CacheWrite, so ResolveTier → BilledOneHour → e.ttl1h = true; cacheTTL() → modelinfo.CacheLifetime → AnthropicCacheTTL1h = time.Hour. The assertion ttl == time.Hour is right.
  • TestHeaderHoldWorksWithNoDashboard. Keep-alive off (CachePolicy{}), header on: recordTouch sets pol.ManualHold on the mayHold path, the entry is held, the press sends one ping, and the sweep 10 minutes later retires the expired 300-second hold without a scheduled ping. The assertions match the keeper's rules.
  • The merge from main. The accountant bump pins released tags (v0.10.0, root and metrics subfolder), and it comes in with a merge of main, so it is the integrator's check, not this PR's. The repo-side changes are the replay digests (with a comment saying why they changed) and version names in the metrics-push row, docs/data-dependence.md and docs/metrics/spec.md. The row file and the generated page carry the same text.
  • The conversation. The author's reply answers every finding from both reviewers. Each answer matches what the code and the PR body now say. No open request from a person is left unmet.

amiddavid added a commit that referenced this pull request Nov 26, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 2: both approve. One test fix.

Both reviewers noted that TestWarmFactsReportsTheOneHourTier failed only on a 409 whose body said "cold". Fixed in eeb24a8c, which changes test code only. The press 30 minutes after the last touch must now return 200, and exactly one ping must reach the upstream. A 404, a 409 "not held" or a 409 "cold" now fails the test.

The hasAuditSink=true recover fallback stays unreachable, as both reviewers accepted.

go vet ./proxy is clean. go test ./proxy -run 'WarmFacts|SingleTenant|HeaderHold' passes. Round 3 re-checks this delta.

Local tests: waived (owner rule)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 3 of 4 eeb24a8c0152 approve -->

Verdict: approve

Findings

None. The new commit changes test code only, and the change is right.

Earlier findings

  • My round-2 note (the "not cold" assertion was weak): fixed. eeb24a8c makes the press assert 200 and exactly one upstream request. A 404, a 409 "not held" or a 409 "cold" now fails the test. Reviewer 1 raised the same note in round 2; I checked the fix once, for both.
  • All round-1 findings and notes: fixed or accepted, as recorded in my round-2 review. Nothing regressed: the fix touches no production file.

Non-blocking

  • None new.

What I checked

  • Last review: round 2, 8337883, 2026-11-26T14:43:11Z.
  • New commits read: 1 (eeb24a8c test(keepalive): the 1-hour press must return 200 and send one ping).
  • Read in full: 3 reviews, 2 comments, 0 inline comments (from the three files).
  • New items since my last review: reviewer 1's round-2 review (approve; one non-blocking note, the same weak assertion I raised), the author's round-2 reply (14:44:41Z), and the commit eeb24a8c. I checked each one.
  • The new assertion is deterministic, not lucky. The entry is an automatic one (kaPolicy(), no manual header), so manualExpired does not apply. Its hard-deadline timer is a real-clock time.AfterFunc (keepalive/keeper.go:1240), which cannot fire inside the test's fake 30-minute advance, so the entry stays in live and PingNow reaches it. WarmFacts gives last touch 30 minutes ago and ttl 1 hour, so the cold gate passes. The fake upstream sees exactly one request: with the inline runner no scheduled ping runs, because no Sweep is called. The 200 and the count of 1 are forced by the code paths, not by timing.
  • The author's reply matches the code. The reply says the fix changes test code only, and that is what the diff shows: proxy/keepalive_singletenant_test.go, 6 lines added, 2 removed. The reply also confirms the hasAuditSink=true recover fallback stays unreachable, which both reviewers accepted in round 2.
  • The rest of the PR is unchanged since my round-2 review of head 83378839.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 3 of 4 eeb24a8c0152 approve

Verdict: approve

Findings

None. The new commit changes test code only and fixes the one open note. I found no defect in it.

Earlier findings

  • Reviewer 1, round-1 finding (PR body claimed single-tenant arming): fixed in round 2, still fixed. The PR body and Open questions are unchanged since round 2.
  • Reviewer 1 and reviewer 2, round-2 non-blocking note (the weak "not cold" assertion in TestWarmFactsReportsTheOneHourTier): fixed. eeb24a8c makes the press assert a 200 (t.Fatalf on any other code) and asserts exactly one upstream request. A 404, a 409 "not held" or a 409 "cold" now fails the test. This is the fix I asked for.
  • Reviewer 2, round-2 note (the unreachable hasAuditSink=true panic fallback): kept knowingly. The author's comment says it stays; both reviewers accepted it in round 2. It is harmless and fails in the safe direction. No action.

Non-blocking

None new.

What I checked

  • Last review: round 2, 8337883931a8e8f3ad3abc31318cba873f1e1343, 2026-11-26T14:43:06Z.
  • New commits read: 1 — eeb24a8c (test(keepalive): the 1-hour press must return 200 and send one ping).
  • Read in full: 3 reviews, 2 comments, 0 inline comments (from the three files).
  • New items since my last review: reviewer 2's round-2 review at 14:43:11Z (approve; its two non-blocking notes checked above); the author's comment at 14:44:41Z (its claims match the commit); commit eeb24a8c (below).
  • The commit eeb24a8c: test-only, in proxy/keepalive_singletenant_test.go. I traced the count it asserts: record dispatches nothing upstream, no Sweep runs in the test, and the press is synchronous, so the fake upstream sees exactly the one press. The keeper's background sweep ticker runs on real 2-second time while the test finishes in milliseconds, so it cannot add a call — the same pattern the file's other tests rely on.
  • Nothing outside the test file changed: no production code, no docs, no data-dependence rows since round 2.
  • I did not run builds or tests (live tests not approved).

amiddavid added a commit that referenced this pull request Nov 26, 2026
…signal (#1470)

The test const fakeSecret clashed with #1469. The startup line now reads
tenants != nil, the same signal the proxy decides on.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged main (with #1469), renamed a test const, aligned the log

  • b2472bda merges origin/main, which has fix(record): write request headers by allowlist (#1466) #1469. Both PRs added a test const fakeSecret in package proxy, so the merged tree did not compile. The const in proxy/keepalive_singletenant_test.go is now fakeSingleTenantKey.
  • proxyapp/main_run.go now warns "hosted mode with no recorder" on tenants != nil, the same signal as Options.Tenants, so the log and the decision cannot differ. It was *upstreamsPath != "".
  • go vet ./... is clean. Plain go test passes on proxy, proxyapp and keepalive. -race -run 'SingleTenant|WarmFacts|HeaderHold|MayHold' passes.

Round 4 re-checks this delta.

Local tests: waived (owner rule)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 b2472bdaac56 approve -->

Verdict: approve

Findings

None. The delta since round 3 holds one PR-owned fix commit and a merge of main. Both are clean.

Earlier findings

  • All findings and notes from rounds 1 to 3 stay fixed or accepted. Nothing regressed: the fix commit touches one test file and one line of proxyapp.
  • The unreachable hasAuditSink=true recover fallback stays, as both reviewers accepted in rounds 2 and 3.

Non-blocking

  • The author's comment (15:30:38Z) says "b2472bda merges origin/main". The merge commit is bdc39b71; b2472bda sits on top of it with the rename and the log change. The branch head carries both, so nothing is wrong in the tree — only the sentence names the wrong sha. No action needed.

What I checked

  • Last review: round 3, eeb24a8, 2026-11-26T14:46:29Z.
  • New commits read: 3 in eeb24a8c..HEAD — 2c38eb58 (main: the opencode v2 test waits on the condition), d0af063a (main: #1469, the recorder writes request headers by allowlist), bdc39b71 (merge of main), b2472bda (this PR: rename the test key; log hosted mode by the decision signal). The two main commits came in with the merge and are the integrator's check; I read their diffs for interaction with this PR, below.
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three files).
  • New items since my last review: reviewer 1's round-3 review (approve, no new notes), the author's comment at 15:30:38Z, and the three commits. I checked each one.
  • The fakeSecret clash was real and is fixed. Main's #1469 adds proxy/credmask_test.go with const fakeSecret = "sk-test-SECRET-123" (line 16), in the same package as this PR's test. The merged tree would not compile. The rename to fakeSingleTenantKey covers all six uses in keepalive_singletenant_test.go, and no reference to fakeSecret remains there. No other symbol of this PR's test file (bookSink, countObs, noDashHost, newNoDashHost) appears in main's new test files.
  • The startup-line change is a drift fix, not a behavior change. proxyapp/main_run.go:923 now reads tenants != nil instead of *upstreamsPath != "". tenants is set only inside the *upstreamsPath != "" block (main_run.go:535-604), so the two were equal before. The log now uses the same signal keeper.mayHold reads (Options.Tenants), so the two cannot disagree later. This closes the consistency check I made by hand in round 1.
  • The merge kept this PR's changes. proxy/proxy.go at head still mounts the Ping button outside the dashboard block (line 663) with the round-2 comment (line 641), beside main's #1469 one-line change to the event queue. The body-stash row and the generated page both carry this PR's sentence; trace-recording.md carries main's allowlist text.
  • The full PR diff at the new base d0af063a matches the files and hunks I reviewed in rounds 1 to 3, plus the two changes of b2472bda.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 b2472bdaac56 approve

Verdict: approve

Findings

None. The PR's own new commit fixes a real compile clash and aligns one log condition. I found no defect in it or in the merge.

Earlier findings

  • Reviewer 1, round-1 finding (PR body claimed single-tenant arming): fixed in round 2, still fixed. The PR body is unchanged since.
  • Round-2/3 notes (weak press assertion, unreachable panic fallback): fixed and accepted in round 3. Nothing regressed; the new commit touches none of that code.

Non-blocking

  • The author's round-4 comment says "b2472bda merges origin/main". The merge is bdc39b71; b2472bda holds the rename and the log change. The comment's substance is right; only the sha attribution is off. No action needed.

What I checked

  • Last review: round 3, eeb24a8c0152e3fa19f80baa55bb8cf16d5c4a08, 2026-11-26T14:46:33Z.
  • New commits read: 4 — 2c38eb58 (opencode test wait, #1468, from main), d0af063a (record header allowlist, #1469, from main, the new base), bdc39b71 (merge of main), b2472bda (rename the test key; log hosted mode by the decision signal).
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three files).
  • New items since my last review: reviewer 2's round-3 review at 14:46:29Z (approve; read, nothing new to check beyond round 3); the author's comment at 15:30:38Z (claims verified below); the merge and the fix commit.
  • The compile clash was real. Main's #1469 adds proxy/credmask_test.go:16 with const fakeSecret = "sk-test-SECRET-123". This PR's test declared const fakeSecret in the same package, so the merged tree did not compile. The rename to fakeSingleTenantKey covers all 6 references, and no fakeSecret reference remains in this PR's test file. I also checked the other new #1469 test file (proxy/recordheaders_test.go) for collisions with this PR's helpers (bookSink, countObs, noDashHost): none.
  • The log condition is equivalent and now names the decision signal. tenants is set only inside the if *upstreamsPath != "" block (proxyapp/main_run.go:604), so !*dashOn && tenants != nil fires on exactly the same deployments as the old *upstreamsPath != "", and it reads the same variable that becomes Options.Tenants.
  • The merge is clean. Both sides' changes to proxy/proxy.go are present at head: this PR's mountManualPing move and route-table comment, and #1469's record.AllowedHeaders(r.Header) in serve. The merged docs/data-dependence.md keeps both this PR's rows and #1469's trace-recording row. #1469's allowlist touches the trace recorder only; the keeper's in-memory header hold for pings is a different path, so the two changes do not interact.
  • I did not run builds or tests (live tests not approved).

A single-tenant proxy holds only its own user's credential, in memory.
It now holds a thread and pings with no dashboard. A hosted proxy with
no recorder still holds nothing.

- keepalive.MayHoldCredentials decides; the proxy calls it from
  keeper.mayHold (hosted = Options.Tenants != nil).
- The gate covers recordTouch, canPing, session arming and the Ping route.
- With no dashboard the Ping route reads the cold gate from the keeper
  (Keeper.WarmFacts), and the route stays mounted.
- The credential stays in memory: no new file, log or metric.

Fixes #1457

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
- WarmFacts uses the entry's cacheTTL; a 1-hour-tier test pins it.
- Test for the header hold with no dashboard.
- Fix the route-table and Ping-route comments.
- body-stash row: the in-memory copies now exist with no dashboard too.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
…signal (#1470)

The test const fakeSecret clashed with #1469. The startup line now reads
tenants != nil, the same signal the proxy decides on.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid
amiddavid force-pushed the feat/keepalive-audit-hosted-only branch from b2472bd to 23215f9 Compare November 26, 2026 15:34
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 4: both approve. Commits re-signed.

  • Both reviewers approve round 4 at b2472bda. Their one note is a sha in my earlier comment: the merge commit is bdc39b71, and b2472bda holds the rename and the log fix.
  • The merge commit bdc39b71 had no Signed-off-by. Every commit is re-signed and force-pushed with lease, as 23215f98. The tree is identical:
approved: b2472bdaac56 (base d0af063af4b7) patch-id 7b9748c8fad5
head:     23215f98f694 (base d0af063af4b7) patch-id 7b9748c8fad5
SAME CHANGE: only the base moved. The approval of b2472bdaac56 still counts. Say so on the PR.

The owner gave "1470 yes" in the integrator session.

Local tests: waived (owner rule)

@amiddavid
amiddavid merged commit db4c38f into main Nov 26, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
amiddavid added a commit that referenced this pull request Nov 26, 2026
The one conflict was in docs/data-dependence/features/accountant-savings.md.
It takes main's text, with #1470's single-tenant ping wording, and keeps
this PR's line that the tool deferral ledger reads the figure. The page
is regenerated with go run ./cmd/gen-datadep.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

openai OpenAI / Codex traffic and pricing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(proxy): book keep-alive ping savings without the dashboard

1 participant