Skip to content

feat: add shadow-mode invoke fair-share reporting - #625

Open
samgbafa wants to merge 13 commits into
mainfrom
feat/tc-3216-invoke-fair-share
Open

samgbafa wants to merge 13 commits into
mainfrom
feat/tc-3216-invoke-fair-share

Conversation

@samgbafa

@samgbafa samgbafa commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Add per-invoker and per-account fair-share reporting for /invoke. Both enforcement flags default to false: requests over these limits remain admitted and are counted only. Existing request behavior is unchanged by default.

Includes #606 event support; merge #606 first. No database migration. Before-enforcement work remains tracked in TC-3254.

Details: TC-3216

samgbafa pushed a commit that referenced this pull request Nov 17, 2026
Bobbie on #625: the limit was spent before the replay check, so a leaked
request replayed during its lifetime drained its invoker's share. The pre-DB
check now only peeks; the request is charged after its outcome unless it was
refused as a replay (InvokeError::Replayed, still 409).
samgbafa pushed a commit that referenced this pull request Nov 17, 2026
…er line; take-then-refund invoker share

- fair_share.rs: invoker token taken at check, refunded on replay or an enforced
  account refusal (Bobbie #625 Low); per-account (account_hash) query-time
  bucket debited in the tracing fairing on every route; per-account in-flight
  cap; once-a-minute invoke_rate_limited / account_limited lines naming the top
  account pseudonym, and node_top_talkers (top 3 by DB time with share).
- All shadow by default (account_limit_enforce, rate_limit_enforce).
- routes/public.rs back to main.
@samgbafa samgbafa changed the title feat(TC-3216): per-invoker /invoke fair share (shadow by default) feat(TC-3216): /invoke fair share: per-invoker and per-account limits, top-talker line (shadow) Nov 17, 2026
Extend the public RateLimiter with a per-verified-invoker bucket family
checked after signature admission and before any DB work. Defaults 600/min,
burst 240 (about 2x the busiest account's 24h peaks). Shadow mode counts
over-limit requests (tinycloud_invoke_rate_limited_total, one log line a
minute); rate_limit_enforce answers 429 rate_limited with Retry-After.
Both bucket families are bounded at 100k tracked callers.
Bobbie on #625: the limit was spent before the replay check, so a leaked
request replayed during its lifetime drained its invoker's share. The pre-DB
check now only peeks; the request is charged after its outcome unless it was
refused as a replay (InvokeError::Replayed, still 409).
…er line; take-then-refund invoker share

- fair_share.rs: invoker token taken at check, refunded on replay or an enforced
  account refusal (Bobbie #625 Low); per-account (account_hash) query-time
  bucket debited in the tracing fairing on every route; per-account in-flight
  cap; once-a-minute invoke_rate_limited / account_limited lines naming the top
  account pseudonym, and node_top_talkers (top 3 by DB time with share).
- All shadow by default (account_limit_enforce, rate_limit_enforce).
- routes/public.rs back to main.
…from 24 h of node_top_talkers/account_limited before any enforcement
@samgbafa
samgbafa force-pushed the feat/tc-3216-invoke-fair-share branch from 494af02 to 27d30e7 Compare November 18, 2026 00:22
…point back-off, size probe, chain-guard wait and http_5xx; vendor canonical schema (TC-3006)
The sidecar ships invoke_rate_limited, account_limited and node_top_talkers
(target tinycloud::fair_share) as node_warning events with exactly their keys,
declared types, enum values and bounds; account fields only as 64-hex
pseudonyms, absent ranks omitted. Any other line on that target stays an
unclassified count. Uncapped like the headroom event: at most four a minute,
worst case 79.4 MB per 30 days.

Re-vendors fields.json from tinycloud-dev-sam #343 (57e4b569) and regenerates
the N0 compose: template 15448ac0..., raw 99c68db3...

test-ruling: TC-3216 (budget.test.mjs individual-code list, profile.test.mjs
sink/route assertions)
…ified (TC-3216)

Bobbie's #606 note 1: every negative case changed the key count, so a
regression in the per-key checks would go unnoticed. Five cases rename one
key with the count unchanged (invoker: top_account_count, mode; account:
limit; top-talker: top3_share, db_ms).

test-ruling: TC-3216
@samgbafa samgbafa changed the title feat(TC-3216): /invoke fair share: per-invoker and per-account limits, top-talker line (shadow) feat: add shadow-mode invoke fair-share reporting Nov 19, 2026
@samgbafa
samgbafa marked this pull request as ready for review November 19, 2026 16:41

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant