Skip to content

docs: draft the invariants of each component (keep-alive and the sweep first) - #820

Draft
amiddavid wants to merge 21 commits into
mainfrom
feat/component-invariants
Draft

amiddavid wants to merge 21 commits into
mainfrom
feat/component-invariants

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

Summary

A draft for inline review: docs/invariants.md. It defines, for each component, the rules that must hold on real traffic, and how to check each one from metadata. A monitor will later run these checks every day or week.

This PR is for comments. It is not ready to merge.

What is in it

  • The component list, grouped, with where each one's purpose is written.
  • Keep-alive (K1 to K6) and the sweep (S1 to S5): proposed invariants, with baselines from a copy of the laptop dashboard database.
  • 4 suspected breaches:
    • B1: two counters give 28.7% and 6.7% for the sweep's false-drop rate.
    • B2: requests labelled hit that re-wrote the prefix.
    • B3: toolfilter reports acted = 0 but mutated = 3204.
    • B4: cachesplit never acted.
  • 5 gaps. None of them needs stored content.
  • A draft monitor spec.

What to review

  • Confirm, change or drop each invariant.
  • Give the thresholds. Every number in the document is a proposal.
  • Decide on each suspected breach: open an issue now, or keep it in the document only.

Data dependence

None. The document and its queries read metadata columns only. No code change.

Open questions

  • The components with no laptop baseline are marked as gaps, as you decided.
  • The production part (cg2, tenants, real thresholds, who gets the report) goes into the internal repo, later.

…-alive and the sweep

A first draft for review. It lists the components, proposes invariants
for keep-alive and the sweep with baselines from a copy of the laptop
dashboard database, and lists the suspected breaches and the gaps.
Metadata only. No code change.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Add T1 to T4 for the option B fallback: a disable by reason, with the
Claude Code version, and the one cache rewrite it costs. The signal
names come with the #898 PR, so they are gap G6 until then.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Fill T1 to T4 with the metric, the /stats field and the log line from
PR #900 (open, not reviewed). Add how each reason counts, the disable
scope, today's known-good hash, and the log join T4 needs.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
From sweep-mcp's brief and a check of main: purpose, the signals that
exist, 9 invariants with the laptop baseline since the switch to
ultrahigh, and gaps G7 (no cg_* metric) and G8 (a missed tool, a purge).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Rewrite K1 to K6 for the per-wait ping plan (#867) with a v0.6.6
baseline, add K7 (no sweep question in a tool wait) and K8 (no ping
when done), close G1 with wake_cause. Add breaches B5 to B7. Update T4
and the #900 signals. Add the expand-rate section E1 to E3 and gap G9
(no per-component expand count).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Fill E1 to E3 with fleet totals from a read-only scan of the cg2
dashboard database (2026-11-04, 2 days, 13,338 real requests), add E4
(expands per 1,000 requests), and schedule them weekly. Per-tenant
numbers stay out of the repo.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The break is real, at the end of system + tools, on xhigh too, and not
caused by keep-alive. Two candidate causes; sweep-mcp checks the
deferral one.

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

The ping and the request keep the cold clock under different keys on
ultrahigh, so the sweep cuts a prefix a ping just kept warm. S6 counts
sweep applies within the cache lifetime of a ping read, daily.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
cache-strategies traced each of the 5: two restarts dropped the planned
pings, a subagent system prompt rewrite, a new subagent thread, and a
ping plan that ended 3 s early. B2 gets 3 confirmed mislabels. B8: a
restart drops the planned pings. B9: a 20k read is the shared head.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The disable metric now has 2 reasons, unknown_description and break.
T4 counts break only. Releases up to v0.6.7 still send the old label;
the monitor ignores it.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Add K9 (pings per long wait), K10 (no-ping misses by prefix band) and
X6 (savings share by thread type), each compared with the week before
and split by main or subagent thread. Add the #1040 case with a laptop
baseline, and gap G10 (the keep-alive settings in effect are not
recorded).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Fleet totals from a read-only scan on 2026-11-11 (2 days, 11,376 real
requests). The fleet stays at 0.97 expands per 1,000 requests. Add the
token-weighted sweep rate (E1b) and the referenced-later rate (E1c).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- K11: a real turn that comes back warm after a ping gets keep-alive
  credit. Daily check, with baselines measured on 2026-11-11.
- B10: credit is $0 on a host that embeds the library and does not wire
  PingSavings.
- G11: no counter of pings that went out but were never priced.
- Q4: pseudocode for K11.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Add checks for too-large refusals, manual-hold evictions by the
per-tenant cap, and the held-body size histogram (#1103, #1137). Mark
G12 as partly closed, and note how to read /metrics on a hosted
deployment with no tenant id in the report.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Add checks for the return rate against the #1143 break-even, the
reserve's net, the refresh rule's decisions, and subagent reserves, with
baselines from #1143 and the laptop. Add gap G13 (which cold return used
a reserve).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
X7 catches a cut the pipeline books but never forwards: the wire-order
fallback WARN, acc_fallback ops_dropped on an acted request, or a large
claimed cut with no fall in billed input. Laptop baseline: 27, 32 and
18 of 19 on 2026-11-16, 0 on other days. X8: a summary that does not
shrink the context.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
…ead end

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

A fresh summarizer act on a request whose own thread was below the
trigger is a breach. Laptop 2026-11-16: 1 of 1 fresh subagent act.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The owner's new invariant, with #1183/#1184 as the example and #1064 as
earlier kin. I1-I2 check that a summary or sweep fires only on its own
thread's size, I3 reports the exposure (19% of laptop subagent requests
read another thread's figure today), I4 checks tenant isolation, and I5
is a code check that no component reads the session-wide figure.

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

This branch has not been deployed

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

Labels

None yet

Projects

Status: New/ToDo

Development

Successfully merging this pull request may close these issues.

1 participant