Skip to content

Identity agent: Store abstraction with in-memory fallback#11

Closed
bokelley wants to merge 1 commit intomainfrom
bokelley/identity-hardening
Closed

Identity agent: Store abstraction with in-memory fallback#11
bokelley wants to merge 1 commit intomainfrom
bokelley/identity-hardening

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Summary

  • Extract Store interface abstracting sorted-set, set, and KV operations used by the identity agent
  • RedisStore wraps go-redis with StorePipeline for batched commands
  • InMemoryStore provides graceful fallback when Valkey is unavailable
  • Auto-detect Valkey connectivity on startup, fall back to in-memory
  • Health endpoint (GET /health) reports store status
  • Fix all pre-existing lint issues

Closes #5

Test plan

  • All existing tests pass (using RedisStore + miniredis)
  • New in-memory store tests: full frequency cap flow, audience segments
  • Tests pass with -race
  • golangci-lint clean

🤖 Generated with Claude Code

Extract Store interface from go-redis direct usage. RedisStore wraps
go-redis; InMemoryStore provides fallback when Valkey is unavailable.
Pipeline batching via StorePipeline interface. Health endpoint. Auto-detect
Valkey availability on startup and fall back gracefully.

Closes #5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley
Copy link
Copy Markdown
Contributor Author

Leaving this open intentionally as the architectural reference for the exposure-storage design discussion happening on #68.

The Store interface here (ZAdd/ZCount/Expire + Pipeline + in-memory fallback) is exactly the shape #68 is arguing against in the production targeting/ package. Before rebasing the layout changes (reference/identity-agent was restructured into cmd/identity-agent/ after this was filed), we need to resolve: does the production Store keep sorted-set primitives, or not?

Tagging for resolution alongside #68.

@bokelley
Copy link
Copy Markdown
Contributor Author

Closing — premise is superseded.

PR #75 (merged 2026-04-22) removed the sorted-set primitives (ZAdd / ZCount / Expire / ZRemRangeByScore) from the production Store interface, which was the abstraction this PR built on. The reference layout also moved from reference/identity-agent/ to cmd/identity-agent/, so this branch has been CONFLICTING against a moving target for a month.

The in-memory fallback idea is still useful but belongs in a fresh, small PR against the current targeting/store.go shape — not a rebase of this 395-line diff. Will file a separate issue if/when we want it.

@bokelley bokelley closed this Apr 28, 2026
@bokelley
Copy link
Copy Markdown
Contributor Author

Acknowledged — closing rationale noted. The in-memory fallback concept is tracked for a future standalone issue against the current targeting/store.go shape whenever you're ready to pursue it.

Triaged by Claude Code. Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}


Generated by Claude Code

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.

Identity agent: real Valkey with sorted set frequency capping

1 participant