> ## Documentation Index
> Fetch the complete documentation index at: https://internal.softcrum.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Canonical Slice #2 (SPEC) — trackEvent: Asynchronous Event Pipeline Archetype

> Coexists with createInitiative (synchronous command archetype). Every task spec declares which archetype it follows (DEC-I5). Implemented by TS-004; becomes WALKTHROUGH status once real.

## The seven layers

1. **Runtime route** `POST /v1/core/track` — auth (api key | write key), Zod envelope, Upstash rate limit, permission core.events.write. NO business logic. Returns 202 \{event\_id} in \<100 ms p95.
2. **Queue publication** — QueuePort.publish('core.ingest', envelope\{job\_id, tenant\_id, correlation\_id, data}). Adapter bound in core module composition root (Vercel Queues at F1).
3. **Processor (worker)** — idempotency gate (core.processed\_jobs by job\_id; tracked\_events idempotency\_key as second fence). Steps in ONE logical flow: identity resolution/upsert → append tracked\_events (partitioned; occurred\_at predicate discipline) → incremental segment eval (diff → entered/exited) → rules engine match (compiled-rules cache per tenant).
4. **Domain writes** — effects execute via loyalty domain services (e.g., award\_points → ledger transaction + lot + balance projection SAME transaction).
5. **Outbox + audit** — every state change emits events + audit\_log rows with correlation\_id/causation\_id (ADR-017 pattern).
6. **Consumers** — notification dispatch (resolveChannels → per-channel rail jobs), webhooks out (HMAC), cache invalidation, metering.
7. **Tests & budgets** — unit: resolveChannels, DSL eval, rules dedupe; integration: full pipeline with duplicate job replay (must no-op); load: k6 track p95 \<100 ms, end-to-end effect visibility \<5 s p95 in cert. All budgets are DoD items.

## What agents copy from here

Fast-ack shape · processed\_jobs gate placement · one-transaction write+outbox+audit · correlation propagation · partition-key discipline · rail selection for notifications.
