Observe the Decision Path, Not Just the Model Call
Reconstruct which versioned evidence and control path produced an outcome while collecting less sensitive content, not more indiscriminate logs.
- Authorship
- InterviewsVector
- Published / updated
- 2026-09-22 / 2026-09-22
- Review status
- Artifact tests passing · primary sources recorded
Original InterviewsVector teaching. Executable artifacts are deterministic illustrative audits with focused tests and recorded primary sources; they do not claim causal validity, production telemetry, safety certification, live incident response, or regulatory compliance.
The decision in one pass
An AI trace must preserve the decision path across retrieval, policy, model, tool, and response stages, not merely the provider request. Give one user-visible decision a stable internal trace identity; record ordered stage identity, version, bounded status, latency, cost, tenant surrogate, and content digests under a declared schema. Bind events to the same scope and trace, require exact stage cardinality and order where the product contract needs them, and correlate downstream effects with their authorized tool intent. Keep raw prompts, documents, outputs, secrets, and personal data out by default; hashes support correlation but do not prove content truth or make low-entropy data anonymous. Separate product-quality measures from telemetry health, sample intentionally, version retention and access policy, and treat trace continuity across trust boundaries as untrusted input until validated.
Why this matters
A model-call log can show a successful 300-millisecond completion while the product returned a poor answer because retrieval served an old index, policy skipped a regional rule, a tool retried a write, or rendering dropped citations. During an incident, teams need to attribute the actual path and revision without creating a second, more sensitive copy of every customer conversation.
You will be able to
- Define one decision-path trace across retrieval, policy, model, tool, and response boundaries.
- Bind every event to version, tenant scope, ordered stage, status, latency, cost, and content evidence without capturing raw payloads by default.
- Distinguish correlation, causality, evaluation, and telemetry-integrity claims.
- Design privacy, security, sampling, retention, deletion, and access controls as part of the schema.
- Use traces to drive debugging, online evaluation, SLOs, and incident response without treating them as ground truth.
Prerequisite contract
Your Vector Loop for this lab
- 01
Model
Map the user-visible decision, stage boundaries, versions, scope, downstream effects, sensitive data, retention, and operators who need evidence.
- 02
Derive
Derive a minimal event schema, ordering and cardinality invariants, latency and cost budgets, correlation identifiers, sampling rules, and privacy constraints.
- 03
Build
Build a local audit over invented digest-only trace events and a versioned contract; do not operate a telemetry backend.
- 04
Stress
Remove, duplicate, reorder, tamper with, or oversize events; inject blocked stages, broken scope, invalid trace context, and telemetry loss.
- 05
Operate
Monitor trace completeness, stage errors, version mix, end-to-end latency, cost, sampling bias, export loss, access, retention, and incident correlation.
- 06
Defend
Defend which questions the trace can answer and why a content hash, span, or successful export does not establish correctness or causality.
Trace the product decision across component boundaries
Start from the outcome a user or downstream system experienced. A useful trace links the request to eligibility, retrieval corpus and index revision, policy checks, prompt-template and model configuration, tool proposals and receipts, response validation, fallback, and final rendering. Each component still owns its local logs and metrics; the decision trace carries bounded correlation evidence rather than duplicating every payload.
| Stage | Bounded evidence | Question supported |
|---|---|---|
| retrieval | corpus/index revision, query digest, result digest, count | which knowledge snapshot informed the decision? |
| policy | policy revision, decision code, rule identity | which deterministic control allowed or blocked it? |
| model | provider/model/config/template revisions, usage | which sampled component ran under what budget? |
| tool | intent digest, authorization result, idempotency key, receipt | what external effect was proposed and observed? |
| response | schema revision, validation status, output digest | what bounded result reached the delivery path? |
Collect identifiers and evidence with explicit data policy
Prefer stable version identifiers, enumerated statuses, counts, timing, costs, and keyed or collision-resistant digests over raw content. A digest is still sensitive when the input space is small or guessable, and it cannot prove the logged content was truthful. Tenant identifiers need purpose-specific pseudonyms and access controls; trace IDs crossing an untrusted boundary must be validated for format, cardinality, and abuse before being joined to internal data.
- 01Classify fieldsName purpose, sensitivity, source, cardinality, allowed values, access, retention, deletion behavior, and whether downstream export is permitted.
- 02Version the schemaMake producer and consumer compatibility explicit so a deployment cannot silently reinterpret stage, status, cost, or identity fields.
- 03Separate content accessIf an authorized investigation truly needs payloads, retrieve them through a narrower audited system rather than placing them in default traces.
- 04Delete coherentlyPropagate retention and deletion across exporters, warehouses, exemplars, alert attachments, and debugging copies, not just the primary span store.
Audit a digest-only decision path
1export function auditDecisionTrace(contractValue: unknown, traceValue: unknown): TraceReport {2 const contract = validateContract(contractValue)3 const trace = validateTrace(traceValue)4 if (!sameStrings(trace.scope, contract.scope) || trace.contractContentId !== contract.contentId) {5 throw new TypeError("trace belongs to another observability contract")6 }7 // Check declared stage presence, cardinality, order, status, latency, and cost.8 return Object.freeze(report)9}Expected output
example=illustrative_only
status=TRACE_COMPLETE
events=5;stages=retrieval,policy,model,tool,response
latency_ms=480;cost_microusd=1500
claim=HASHED_LOCAL_TRACE_NOT_PAYLOAD_CAPTUREVerify: node --experimental-strip-types --test courses/ai-engineering/reference-impl/ai_observability/decision_trace.test.ts
The fixture declares exactly five required stages and records invented version IDs, tenant surrogate, input and output SHA-256 values, stage status, latency, and cost. Exact plain objects and arrays, safe integers, scope length, event order, closed schemas, digest binding, constructor bypass, raw-payload mode, and total budgets are tested. The returned report and its collections are frozen.
The artifact neither emits OpenTelemetry spans nor authenticates an incoming trace header. It does not capture a prompt, reconstruct causal truth, score model quality, guarantee delivery, or prove that a digest corresponds to honest source data. Its complete status is a local schema result over invented events.
Treat the telemetry pipeline as a fallible dependency
| Failure | Consequence | Control |
|---|---|---|
| head sampling drops rare harm | dashboard looks healthier than users | risk-aware sampling plus aggregate counters and audit cohorts |
| export queue loses spans | missing stage resembles success | delivery health, gap counters, and explicit unknown status |
| clock skew | negative or distorted stage timing | monotonic local durations and bounded cross-host interpretation |
| version label cardinality | cost and storage explode | registry-backed bounded identities and rejection |
| attacker-chosen trace ID | cross-tenant joins or log injection | regenerate or validate at trust boundary |
observed_rate = recorded_events / eligible_decisions; completeness is a metric, not an assumption
Measure eligibility independently enough to notice collection loss. Never convert missing spans into zero errors, zero cost, or a complete path.
Connect traces to decisions, SLOs, evals, and incidents
Use trace exemplars to move from an aggregate symptom to a bounded path, then verify source systems. Online evaluation needs treatment and version attribution. SLOs need end-to-end product latency and success, not just model availability. Incident response needs affected revisions, stage status, policy decisions, and downstream receipts. Offline datasets can sample privacy-reviewed failure traces, but the sampling decision and provenance must travel with each case.
- Monitor trace completion and export health separately from product success so telemetry loss is visible.
- Budget per-stage and end-to-end latency and cost; diagnose retries and fallbacks instead of summing only provider usage.
- Restrict high-cardinality fields and debug access with tenant-aware authorization and immutable audit trails.
- Test schema compatibility, deletion, sampling, incident joins, and fallback attribution during release rehearsals.
Operate at three altitudes
Production lens
- — Alert on missing stages, export gaps, unknown version mix, invalid trace context, error and block status, latency, cost, and downstream-effect reconciliation by product decision.
- — Run access, retention, deletion, sampling, and cardinality controls as production invariants; telemetry must not become an unowned copy of sensitive model context.
- — Correlate traces with eval cases, rollout cohorts, SLOs, support reports, and incidents through bounded identities rather than raw-content search.
Staff lens
- — Define a shared decision-path semantic contract across product, retrieval, policy, model, tool, response, privacy, and incident owners without forcing every service into one storage backend.
- — Require observability proposals to name the decision they support and the data risk they introduce; reject indiscriminate payload capture disguised as debugging convenience.
Interview defense
Users report wrong answers, but model latency and provider success are normal. What observability do you need?
I would start from the user-visible decision and correlate its retrieval index and result digest, policy revision and decision, prompt/model/config revision, tool intent and receipt, response-schema validation, fallback, and renderer version. I would also inspect trace completeness and treatment attribution because missing telemetry can mimic a clean path. Raw prompts are not my default: bounded identifiers, statuses, counts, timing, costs, and digests support correlation, with narrower audited content access if the investigation requires it. The trace narrows hypotheses; I still verify the authoritative retrieval, policy, tool, and delivery systems before claiming root cause.
Expect the interviewer to press on
- — Why is a SHA-256 value not necessarily anonymous?
- — How would you detect that sampling hid a rare failure mode?
- — Which identifier should cross a tenant or public trust boundary?
Misconceptions to remove
“Logging every prompt and output gives the best observability.”
Indiscriminate content capture expands security, privacy, retention, and cost risk while still omitting policy, retrieval, tool, assignment, and rendering context.
“A trace shows the causal chain that produced an answer.”
A trace records declared correlated events. Sampling, missing spans, dishonest producers, retries, clocks, and external state can make it incomplete or misleading; causal claims need additional design and evidence.
“A content digest proves the original payload and safely anonymizes it.”
A digest supports equality checks when inputs are trustworthy, but low-entropy content can be guessed and the logger can hash inaccurate data. It is evidence, not provenance or anonymization by itself.
Check your model
1. Why should the trace begin at the product decision rather than the provider call?
The outcome depends on eligibility, retrieval, policy, tools, fallbacks, validation, and rendering; the provider call is only one stage of that composed path.
2. What does trace completeness require?
A declared eligible-decision denominator, required stage presence and order, version and scope binding, export health, and explicit treatment of missing events as unknown rather than success.
3. When should raw content be retrieved for debugging?
Only for a named authorized purpose through a narrower audited access path with minimization, retention, tenant, and deletion controls—not in the default trace schema.
Prove the mechanism
Extend the trace artifact with an explicit fallback stage and telemetry-completeness declaration. Reject unexpected cardinality, preserve closed schemas, and add a test proving missing export evidence cannot report TRACE_COMPLETE.
Add a production constraint
Design a cross-service observability contract for retrieval, policy, two model providers, tools, and rendering. Include W3C context boundaries, tenant isolation, sampling, retention, deletion, incident access, online-eval attribution, compatibility rollout, and failure-injection tests.
Artifact: Decision-path observability contract
courses/ai-engineering/reference-impl/ai_observability/decision_trace.ts
Download reference implementationPrimary references and next links
References
- 1. Traces
OpenTelemetry. Official documentation on traces as correlated paths through distributed work and their span relationships.
- 2. Trace Context
W3C. W3C Recommendation for interoperable trace context, including privacy and trust considerations across boundaries.
- 3. AI RMF Playbook — Measure
NIST AI Resource Center. Official guidance on measuring, tracking, documenting, and monitoring AI risks and impacts.
Continue through the graph
- Online Evaluation Without Shipping Blind →
Bind exposure and online outcomes to the exact candidate and control paths.
- AI Incident Response and Correction Loops →
Use bounded path evidence to scope incidents and validate correction gates.
Glossary: decision trace · span · trace context · exemplar · cardinality · head sampling · tail sampling · telemetry completeness · data minimization