feat(targeting): extract fcap into Service + Valkey 9 + glide#108
Open
ohalushchak-exadel wants to merge 3 commits intomainfrom
Open
feat(targeting): extract fcap into Service + Valkey 9 + glide#108ohalushchak-exadel wants to merge 3 commits intomainfrom
ohalushchak-exadel wants to merge 3 commits intomainfrom
Conversation
…y Valkey 9 + glide
Replaces the engine's inline frequency-cap logic (binary exposure log + sorted
sets) with a dedicated fcap package. State now lives as Valkey hash fields
keyed by hashed user identity (fcap:{hash}), one field per (seller_agent_url,
package_id) tuple, with TTL set to the end of the cap window via HSETEX. Caller
decides when the cap fires (writes happen on the last allowed exposure).
Drops: campaign-level caps, intent score, ExposureLog/Entry/binary log path,
RecordExposure, and the go-redis-backed valkeystore module. Switches the
Valkey client to valkey-glide/go/v2; bumps the runtime to Valkey 9.
The engine is now segment-only; callers compose engine + fcap.Service.
Adds testcontainers-based Valkey 9 integration tests for both the
fcap.Store and targeting.Store interfaces, plus end-to-end engine flows
against real Valkey, behind the integration build tag.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
IPR Policy Agreement Required@ohalushchak-exadel — thanks for the contribution. Before this PR can be merged, the AgenticAdvertising.Org IPR Policy requires your agreement. To agree, post a new comment on this PR with the exact phrase: Your signature is recorded once and covers all contributions to AAO repositories. See |
- Drop dead Engine.Now/now() and loadPackageIdentityConfig (no callers). - Tighten coerceBool: HEXISTS batch result is plain bool; surface %T on mismatch. - Defend MGet length in glidestore for symmetry with FieldExistsBatch. - Annotate Store.MSet TTL atomicity at the interface level. - Reference agent: drop unused fcap.Service construction, simplify initStore to a single targeting.Store, comment the in-memory fallback's intent, and return errors from seedConfigs instead of os.Exit(1). - Pin fcap field-name format with fieldDelimiter constant + format-pinned test. - Drop misleading "matches HashToken" coupling comment on identityKey. - Rename targeting/exposure.go -> targeting/identity.go (the file no longer contains exposure types). - Update UserProfile doc to drop "intent score" reference. - Add fcap.MockStore TTL unit test (mock-only path was uncovered). - Document segment-default-eligible semantics on EvaluateIdentityResolved. - Add multi-identity segment-union engine test (regression cover for MergeUserProfiles fan-out across identities). - Trim Redis from targeting.Store doc; bump fcap.Store doc to "Valkey 9+". - gofmt fcap integration test struct-literal alignment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Modernizations from `go fix ./...`: - C-style index loops -> range over int - Manual slice-contains loops -> slices.Contains Module versions normalized by `go mod tidy` (go 1.25 -> go 1.25.0). go.sum entries refreshed where indirect deps shifted. No behavior changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
I have read the IPR Policy |
Contributor
|
Thanks for confirming, @ohalushchak-exadel — noted. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
targeting/fcappackage:Serviceover aStoreinterface for frequency-cap state. Keys arefcap:{sha256(user_identity)[:16]}, fields are literal{seller_agent_url}:{package_id}strings, value"1", TTL set viaHSETEXto the end of the cap window. Writes happen on the last allowed exposure (caller decides).targeting/glidestorepackage: singlevalkey-glide/go/v2client implementing bothtargeting.Store(engine) andfcap.Store. Replaces the deletedtargeting/valkeystore(go-redis) submodule.RecordExposure, campaign-level caps (CampaignFreqConfig+ helpers), intent score (ComputeIntentScore,LatestExposure*),ExposureLog/ExposureEntryand the binary-log path, sorted-set helpers (ZAdd/ZCount/ZExpire/ZRemRangeByScore),FrequencyRuleprimitive, andIntentScorefromtmproto.PackageEligibilityandbenchtypes/fixtures.valkeystore/go-redistoglidestore/valkey-glide.fcap.Serviceis initialized but not wired to an HTTP route — the exposure-write surface is intentionally out of scope (no caller today).go fix ./...rewrites picked up along the way (maps.Copy,sync.WaitGroup.Go, gofmt realignment intargeting/entity.go,e2e/e2e_test.go,router/router.go,router/providerset_test.go).Schema
user:exposures:{tokenHash}(binary blob, 30d TTL)fcap:{tokenHash}(HSET, per-field TTL){url}:{pkg} → "1", TTL = end of windowMaxCountHEXISTSHSETEX(preferred)Test plan
go build ./...clean across all 4 modules (root,e2e,bench,reference/identity-agent)go test ./...clean across all 4 modules — segment/property/URL/topic engine logic still covered by unit tests againsttargeting.MockStorefcap.Serviceunit tests againstfcap.MockStorecover plumbing (hashing, field formatting, batch fan-out)go test -tags integration ./targeting/glidestore/...against a real Valkey 9 container (testcontainers): 11 tests, ~13s end-to-endfcap.Store: HSETEX write + HEXISTS read + TTL expiry + batch read/writetargeting.Store: Get/Set/MGet/MSet/SetIsMember/SetIntersect/SetMembers/Exists across types + TTLEvaluateContext+EvaluateIdentityResolved) reading topic/URL/segment data from real Valkeygo vet ./...clean across all 4 modulesgo fix ./...clean across all 4 modulesOpen follow-ups (out of scope here)
fcap.Service.RecordCapdirectly.RecordCapon the last allowed one.🤖 Generated with Claude Code