Skip to content

feat(identity): escalating signature-throttle policy and instrumentation seam (2/3) - #2602

Open
SurbhiAgarwal1 wants to merge 2 commits into
LFDT-Panurus:mainfrom
SurbhiAgarwal1:feat/1643-signature-throttle-policy-seam
Open

SurbhiAgarwal1 wants to merge 2 commits into
LFDT-Panurus:mainfrom
SurbhiAgarwal1:feat/1643-signature-throttle-policy-seam

Conversation

@SurbhiAgarwal1

Copy link
Copy Markdown
Contributor

Summary

Part 2 of 3 for #1643 (supersedes #2440 from #2084, co-authored with @Effi-S). Stacks on #2531.

Adds the policy engine, throttle configuration, and makes the signature services instrumentable, while leaving the feature dormant (no driver wires it yet, so the observer stays Nop and the gate stays nil with zero behavior change or hot-path overhead until activated in Part 3):

  • token/services/identity/throttle: Escalator implementing both Observer and Gate, automated multi-tier throttling (Normal, Soft, Blocked), sliding violation window, cooldown recovery, block re-arming, memory bounding via O(1) LRU eviction lists (lruNormal, lruSoft), and Config with validated defaults.
  • token/services/identity/sigpolicy: Stack assembling policy observers and gates behind a unified lifecycle interface.
  • token/principalkey.go: enrollmentKeyResolver mapping rotating anonymous pseudonyms to stable enrollment IDs (eid:...) from local audit information so pseudonym rotation cannot bypass per-principal quotas.
  • token/services/identity/sigobserve & token/services/ratelimit: Added <empty> sentinel and unattributed() handling in audit.go, and added EvictIdleNow() alongside old-rate override settling in ClearRate.
  • token/sig.go: The single gated surface with the SignatureThrottled sentinel, WithSignatureObserver / WithSignatureGate / WithPrincipalKeyResolver options, and the allow() helper.
  • token/core/common/deserializer.go & token/services/identity/provider.go: SetObserver and instrumentation of verifier and signer operations with a lock-free Nop fast path.
  • token/core/common/tms.go & token/tms.go: SignatureInstrumentation plumbing and enrollment key resolver wiring so drivers can install the stack.

Tests

  • Unit tests in stack_test.go, config_test.go, escalator_test.go, principalkey_test.go, sig_gate_test.go, deserializer_observe_test.go, provider_observe_test.go, and tms_test.go.
  • All tests pass cleanly.

Part of #1643
Supersedes #2440

SurbhiAgarwal1 and others added 2 commits October 29, 2026 19:47
…servation vocabulary (1/3)

Part 1 of 3 for LFDT-Panurus#1643 (supersedes LFDT-Panurus#2439 from LFDT-Panurus#2084), addressing review feedback:

- ratelimit: require canReclaimIdleBucket (idle >= idleTTL and accrued >= max(b.burst, s.burst)) before evicting idle buckets so slow overrides are never refunded a full default burst after idleTTL

- ratelimit: replace O(maxKeys) eviction scan with O(1) intrusive doubly-linked LRU lists for non-overridden and overridden buckets, admit new keys at the MRU head under saturation while bounding initial tokens via minEvictedTokens, and reclaim abandoned overrides on bounded sets

- sigobserve: quote non-enum Op, Role, and Outcome values in AuditLogger to prevent log injection, guard nil receiver/field and nil clock function in AuditLogger.SetNow, and preserve driver.Verifier in InstrumentSigner when driver.SigningIdentity is not implemented

Co-authored-by: Effi-S <effi.szt@gmail.com>

Signed-off-by: Effi-S <effi.szt@gmail.com>
Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
…ion seam (2/3)

Part 2 of 3 for LFDT-Panurus#1643 (supersedes LFDT-Panurus#2440 from LFDT-Panurus#2084):

- sigpolicy: introduces Stack bundling policy observers, gates, and lifecycle management
- throttle: introduces the Escalator policy engine with automated multi-tier throttling (normal, soft, blocked), configurable duration/error thresholds, and O(1) LRU eviction
- principalkey: introduces enrollment-ID principal-key resolver to prevent pseudonym rotation bypass
- sigobserve: adds <empty> sentinel handling and unattributed principal support to prevent shared bucket collisions
- ratelimit: adds EvictIdleNow for deterministic sweep control and settles idle gap at the old override rate on ClearRate
- token: wires signature gating, options, and instrumentation seams across deserializer, provider, and TMS

Co-authored-by: Effi-S <effi.szt@gmail.com>
Signed-off-by: Effi-S <effi.szt@gmail.com>
Signed-off-by: Surbhi Agarwal <SurbhiAgarwal1@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 12:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

2 participants