Skip to content

feat: Add TrackedDeck and CueBox to decking module#8

Open
Nicholas-Keystate wants to merge 2 commits intoWebOfTrust:masterfrom
Nicholas-Keystate:feat/tracked-deck-cuebox
Open

feat: Add TrackedDeck and CueBox to decking module#8
Nicholas-Keystate wants to merge 2 commits intoWebOfTrust:masterfrom
Nicholas-Keystate:feat/tracked-deck-cuebox

Conversation

@Nicholas-Keystate
Copy link
Copy Markdown

Summary

  • TrackedDeck: extends Deck with optional cap enforcement, push/pull/drop counters, and high water mark tracking. Drop-in replacement — all existing Deck tests pass unchanged. Prevents unbounded memory growth when producers outpace consumers by silently dropping elements at capacity (back-pressure).

  • CueBox: two-phase cue lifecycle manager (claimresolve | reject) that prevents the re-push livelock pattern where unhandled cues bounce between Doers indefinitely. Includes maxRetries limit to cap reject cycles and expireLeaked() to detect abandoned claims.

  • Both classes are exported from hio.help alongside Deck.

Motivation

Several patterns in downstream KERI usage (keripy) show unbounded Deck growth and re-push livelock:

  1. Unbounded cuesRegistrar.processWitnessEscrow() iterates witDoer.cues without removing entries
  2. Re-push livelockRespondant.cueDo re-appends unhandled cues to shared Decks
  3. No back-pressure — Deck has no mechanism to cap growth or signal overload

TrackedDeck and CueBox address these at the infrastructure level so individual Doers don't need to re-implement bounds checking.

Test plan

  • All existing test_deck tests pass unchanged
  • TrackedDeck: basic push/pull, cap enforcement, stats tracking, unbounded mode, initial elements, deque method compatibility
  • CueBox: claim/resolve, claim/reject, maxRetries enforcement, leak detection, stats reporting, bool/len semantics
  • 13 new tests, 0 regressions

🤖 Generated with Claude Code

Nicholas Racz and others added 2 commits February 20, 2026 11:14
TrackedDeck extends Deck with optional cap enforcement, push/pull/drop
counters, and high water mark tracking. Prevents unbounded memory growth
in producer-faster-than-consumer scenarios by silently dropping elements
when at capacity (back-pressure). Drop-in replacement for Deck — all
existing Deck tests pass unchanged.

CueBox provides two-phase cue lifecycle management (claim/resolve/reject)
to prevent re-push livelock where unhandled cues bounce between Doers
indefinitely. Includes maxRetries limit and leak detection for claimed
but never-resolved cues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously claim() always set retries to 0, making maxRetries
ineffective — rejected cues would cycle indefinitely (the exact
livelock pattern CueBox is designed to prevent).

Now uses _retryCounts dict keyed by id(cue) to persist retry count
across reject → re-push → re-claim cycles. Cue is permanently
dropped once retries reaches maxRetries. Count is cleaned up on
resolve() to prevent memory leaks.

Test updated to verify livelock actually terminates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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