TTemporalStore.AI GitHub

Data model

Control State: counters, caps, and distinct sets.

Control State keeps the safety and throttling primitives close to the request path: bucketed counters, frequency caps, velocity checks, and distinct sets — for fraud, rate limits, ad frequency capping, and agent safety.

What it is

One request-time home for the "how many / how often / how unique" question.

Throttling and safety decisions all reduce to a small number read at request time. Control State keeps that number next to the request path so the check is a fast read, not a round trip to a separate rate-limit service or a warehouse.

  • Counter — bucketed counts, sums, and rates over sliding or tumbling windows.
  • Frequency cap — per-entity impression, action, or spend caps over an hour, a day, or a campaign, enforced at read time.
  • Velocity check — how many events in the last N minutes, to catch bursts for fraud and abuse throttling.
  • Distinct set — exact or approximate unique devices, merchants, IPs, sessions, or tools seen in a window.
  • Selection state — chosen or blocked entities kept consistent across requests, including agent safety counters beside Context Management memory.

In practice

Increment, count against a cap, and count distinct.

Increment a bucketed counter
ts.incr(
  table="impressions",
  entity="camp_5:user_42",
  ts_ms=now_ms,
  by=1,
)
Check a frequency cap at read time
n = ts.count(
  table="impressions",
  entity="camp_5:user_42",
  range="24h",
)
allow = n < DAILY_CAP
Count distinct in a window
u = ts.distinct(
  table="card_touch",
  entity="card_9",
  field="merchant",
  range="24h",
)

When to use it

When a "yes / no" gate depends on recent activity.

Reach for Control State whenever an allow-or-block decision hinges on how much, how often, or how many distinct things an entity has done lately — and the check sits on the hot path.

Use casePrimitiveWhy it fits
Ad frequency capsFrequency capEnforces per-user impression limits over hour/day/campaign windows.
API rate limitsCounterBucketed counts per key gate requests without a separate limiter.
Fraud velocityVelocity + distinctFlags bursts and unusual distinct-merchant fan-out in minutes.
Agent safetySelection + countersRate limits and risky-action counters beside agent memory.

Related models

Control state pairs with history and aggregates.

AggregatesAggregated FeatureFiltered rollups over the same events. SequencesLong Sequence FeatureOrdered behavior history. FlagshipContext ManagementSafety counters in agent memory.