Recommendations operations¶
Supported POST bodies have independent application byte caps in the optional strict
request_body_limits deployment section: training_bytes=8192, swimlane_bytes=8192, and
interaction_bytes=2097152. All three must be positive integers; booleans, fractions and unknown
fields fail startup. Lower caps can reject otherwise valid requests. The limits are runtime transport
settings and do not change training configuration identity. Deploy clients and reverse-proxy limits
together: the proxy should permit intended application payloads while applying its own bounded
buffer and upload-time policy. The application counts received bytes independently of proxy headers
and returns 413 request_body_too_large on excess, including whitespace-padded and chunked bodies.
Unauthorized protected routes return 401 before input reads. Keep request bodies and credentials out
of diagnostic evidence. Bound request concurrency and upload duration separately; these caps do not
establish a total process-memory or latency guarantee.
operations/recommendations.toml is the backend-neutral
dashboard, alert, and runbook contract. Deployments translate its intent into their monitoring
backend without adding request, scope, product, run, snapshot, session, order, account, tenant, or
user identifiers to metric dimensions. Those identifiers remain trace/log correlation fields and
durable application evidence.
Every investigation starts by recording the deployed application revision, telemetry wheel SHA3-512, dependency lock SHA3-512, OCI Collector image digest and configuration SHA3-512, configuration fingerprint, process role, deployment environment, and UTC window. Preserve query exports or screenshots with the incident; never paste credentials, request bodies, recommendation payloads, or raw SQL inputs into telemetry.
First-consumer release evidence is assembled with scripts/build_telemetry_evidence.py. Each of its
six JSON gate inputs must report pass and the SHA3-512 of the same candidate wheel. The command
checksums those inputs, the dependency lock, and Collector configuration and refuses incomplete,
failed, skipped, or stale evidence. The resulting manifest is then validated by the telemetry
repository's scripts/verify_consumer_evidence.py; the builder does not execute or invent hosted
qualification results.
Serving errors or latency¶
For reproducible local serving experiments, use the Locust serving load harness. It prepares four synthetic scope heads, separates warm-up from measurement, classifies admission and semantic errors, and retains aggregate resource/latency evidence before owned teardown. Use the report's precise gate counters and failure causes; displayed rounded percentiles alone cannot establish the latency objective. Local evidence does not establish deployment capacity.
- Split failures and latency by route template, method, status class, and bounded strategy. Never query by a raw URL or product/catalog identifier.
- Compare application request counts with ingress counts. A mismatch indicates routing or instrumentation trouble rather than model behavior.
- Use one sampled request trace to separate admission, control-database, snapshot lookup, and serialization time. Confirm the durable serving head and snapshot state directly.
- If telemetry is incomplete, diagnose the Collector separately; serving remains authoritative and must stay fail-open with respect to telemetry.
- Recover only after error and latency objectives hold for the alert recovery window.
Opt-in embedded ANN¶
The deployment document may include "ann": {"scopes": [{"data_source_id": "...",
"tracking_id": "...", "catalog_id": "..."}], "dimensions": 512, "model": "metadata_svd"}.
Set "model": "two_tower" only for an experimental PyTorch-trained representation. It needs the
optional torch package in Training Workers (for a local full environment, run
uv sync --locked --extra dev --extra postgresql --extra observability --extra torch);
API processes need only the
published NumPy weights and Faiss index. Two-tower training uses Apple MPS when available and CPU
otherwise, capped at 128 latent dimensions, 10,000 aggregate positive pairs, three epochs and
128-pair batches. A scope with fewer than two usable pairs publishes no learned artifact and retains
ordinary snapshot fallback. Omit ann or leave
scopes empty for the default-off path. Each scope must already be configured as a Relational Data
Source scope. The same document must reach workers and API processes; existing snapshots without an
ANN artifact continue to serve through the old paths until a successful opted-in Training Run.
The optional artifact is stored in the control database, not in process-local files. Budget database storage and transfer for the versioned vector matrix plus serialized native HNSW index; the learned mode also stores input vectors and query weights. Construction rejects a generation above 1 GB of these bytes. API processes retain at most two loaded generations each, with no native index shared between processes. This is a hard artifact-size bound, not evidence that multiple scopes, overlapping generations, or full process RSS satisfy the proposed 2 GiB gate. An API process loads at most one cold artifact at a time in a background worker; requests use the ordinary Snapshot fallback until that load completes, so a new serving head need not block a request on database transfer or native deserialization.
Completed loads are reaped before considering the next requested head, including successful, missing and failed old generations. Failures occupy the same bounded cache as negative entries; an unfinished load legitimately occupies the single slot. The API composition root joins its loader on shutdown and clears residency outside the scheduling lock. Applications that inject their own retriever must close it themselves.
Both metadata and learned indexes must use native inner-product distance. A checksummed L2 artifact is rejected during publication or falls back to its own Snapshot at serving time. Rebuild such an artifact with a successful Training Run; changing its checksum or interpreting the distances as similarities does not repair it. This validation uses the metric already serialized in the index, so no artifact-envelope migration is required.
Learned torch-two-tower-v1 artifacts also require rebuilding under torch-two-tower-v2, which
counts unique directed training pairs before applying the budget. Different learned identities
must not be combined in model evidence comparisons. A rejected old model retains its ordinary
same-Snapshot fallback. The controlled pair comparison reports
mixed synthetic quality changes and does not authorize broader enablement.
Do not enable ANN broadly until the separate representation-relevance, same-vector recall, restrictive
filter, full Serving API latency, memory, build/load and Linux compatibility gates in PL-244–247 pass.
The current synthetic HNSW measurements do not pass the proposed recall gate. To roll back, remove
the affected scope from ann.scopes in both API and worker configuration; the API immediately uses
the old Snapshot paths, and subsequent Training Runs omit the artifact. A failed artifact build or
publication leaves the previous serving head in place. An artifact read/validation failure falls
back to old Snapshot candidates and emits a safe snapshot-ID warning without Shopper data.
Personalization maintenance¶
Use the personalization-maintenance dashboard to compare batch outcomes, expired-interaction
counts and batch duration. backlog_lower_bound is a histogram of capped samples, not an exact
queue size: each poll counts at most 1,000 due rows in each of the interaction, idempotency,
profile and deletion queues. A saturated sample requires database/query-plan investigation;
do not export Shopper keys or interaction payloads to explain the backlog.
Expiry and rebuild have separate bounded transactions. A failed reducer leaves a durable dirty marker and retains its causal header; serving uses the insufficient-history fallback until a safe projection is published. Repeated failures should be investigated through the maintenance operation outcome and control-database health. Keep cleanup running when personalization is disabled. Shortened policies hide old projections immediately, before physical deletion finishes.
Before deploying these binaries, drain old writers and apply migration 0008. Existing projections become dirty and rebuild in bounded passes. Confirm backlog progress and serving fallback behavior before enabling personalization. Keep admission disabled when returning to a binary without dirty protection; migration downgrade refuses dirty projections or pending checkpoints. Capacity and latency under sustained ingestion still require the qualification evidence recorded in the remediation design.
Training aggregation backend¶
Set pipeline.aggregation_backend to "duckdb" (default) or "polars" in the deployment JSON
and restart the worker. This selects all derived aggregation and scoring, independently of the
merchant source dialect and service-owned snapshot database. Polars is included in the base
installation. Leave cooccurrence_backend omitted/default with Polars; accelerator overrides
remain available only for DuckDB aggregation.
For Polars, set POLARS_MAX_THREADS before process startup (for example
POLARS_MAX_THREADS=4 uv run --frozen recommendations-worker). Its native pool is process-wide;
pipeline.threads continues to configure metadata similarity but does not resize that pool.
batch_key_limit bounds ingestion buffers, with the existing maximum-group overshoot, and both
axes of exact metadata similarity products. Smaller values reduce the metadata product buffers
and increase the number of native multiplication calls. Each anchor's selector retains at most
200 matches; complete Catalog features and candidate output remain separate allocations. See
metadata similarity for the block bounds.
memory_limit checks the size of materialized derived batches and query results after allocation;
it is not a hard cap on Polars query intermediates or process RSS. max_temp_directory_size
checks owned derived Parquet storage after writes, footer closes, and compaction, allowing a
transient write/compaction overshoot. Polars-internal spill is outside that owned-file budget.
Use operating-system/container limits to enforce total memory and filesystem bounds.
Budget violations are classified as resource_exhausted; other computation failures retain the
existing strategy_computation_error classification. Both leave the previous complete serving
head intact. Temporary derived files are cleaned when the run exits. A process killed externally
cannot perform Python cleanup; normal worker scratch-volume lifecycle policy still applies.
Engine parity tests establish correctness on synthetic inputs, not faster training or production
scale qualification. Switching back to "duckdb" affects subsequent Training Runs; existing
snapshots remain servable without retraining.
Local admission state exhaustion¶
When the optional process-local serving_limits adapter returns HTTP 503
service_limit_unavailable with "The admission state capacity was exhausted.", distinguish its
bounded state_capacity_exhausted decision reason from ordinary rate/concurrency 429s and
malformed-policy 503s. No Retry-After is supplied because a safe allocation time is not promised.
Inspect the caller-selected maximum_rate_buckets and maximum_concurrency_permits, partition
cardinality, policy-version overlap and matching concurrency-rule count. Both caps are explicit
positive integers; there is no application deployment default. One matched concurrency rule
consumes one permit slot regardless of its weighted cost. Do not reset the adapter or evict depleted
rate buckets to relieve pressure: that restores spent allowance. Reclamation occurs during
admission/release only after full refill or permit expiry. Qualify headroom, per-entry memory and
expiry-burst lock duration before changing a cap. Never label metrics with raw consumer descriptors.
The adapter has no cross-process capacity, persistence or restart continuity guarantee.
Worker stall or lease loss¶
- Confirm at least one worker emitted started and ready events and continues bounded polling.
- Compare pending durable runs, active-run gauge, claim outcomes, and lease-renewal outcomes.
- Pivot from a failed bounded outcome into the correlated run trace, then verify durable run and lease timestamps. Heartbeats intentionally do not create spans.
- Do not manually publish a partial snapshot. Let lease reclamation and the database-enforced retry policy decide ownership; a second lease loss is terminal.
Publication checks the claim's recovery generation and live lease before creating staging,
each batch, and head activation. Drain older worker binaries before enabling this fencing change:
older publishers do not obey these checks. On a publication regression, stop new publication
and keep serving the last successful head; do not restore unfenced writers.
Before switching to model identity recommendations-v2, drain pending and running v1/package-version
runs under their original binary, or explicitly cancel and resubmit them under the approved
operational procedure. A run created by the older API must not silently receive new algorithms
while retaining its historical model identity. Existing available snapshots remain serveable.
5. Recover after the run reaches a durable terminal state and representative renewals remain healthy.
Training failure or publication stall¶
- Identify the first failed phase among source read, generation, evaluation, publication, quality assessment, and retention using bounded phase/outcome dimensions.
- Check the durable bounded diagnostic and source/snapshot contracts. Raw source rows and generated recommendations must not appear in exported signals.
- For publication, verify the complete strategy manifest and serving-head transaction. An older complete snapshot should remain servable when a newer run fails.
- Retention failure is investigated after publication state is known; never delete snapshots solely to make a telemetry alert recover.
- Recover after a representative run publishes a complete snapshot and the serving head is current.
Quality drift¶
- Treat drift as diagnostic, not as evidence of clicks, conversion, revenue, retention, attribution, or causal performance.
- Verify scope, model, configuration, metrics-schema versions, baseline run IDs, and minimum sample requirements from durable evidence before comparing values.
- Review the bounded largest-deviation summary and the complete durable report. Do not add run or snapshot IDs to metric dimensions to simplify the query.
- Publication and serving remain independent of the drift result. Escalate model/configuration changes through the normal review path.
Privacy or cardinality violation¶
- Stop forwarding the affected signal at the Collector if that can be done without changing application behavior; retain the application and durable data plane.
- Capture the registered metric/event name and attribute name, but do not copy the leaked value into tickets or logs. Rotate any exposed credential through its owning secret system.
- Check the consumer schema and adapter mapping. Metric dimensions are restricted to the reviewed bounded vocabulary in the operations contract.
- Re-run the privacy canaries, 100-context isolation test, and 10,000-identifier series test before re-enabling export.
- Record backend deletion or retention actions and attach checksummed evidence to qualification.