# Agentic platform observability contract

Status: illustrative template; complete and approve before production use.
Version: 1.0 | Owner: platform team | Review cadence: every material release

## 1. Purpose and user stories

Record the user journey, its accountable owner, and the decision each signal enables.

| User story | Evidence | Decision | Acceptance test |
| --- | --- | --- | --- |
| A user needs one correct result within the task deadline | Durable task outcome, age, completion latency, quality evaluation | Detect stalled or incorrect work | Inject a timeout and a valid-looking incorrect answer |
| On-call needs to identify the failing dependency | Step metrics, trace waterfall, release and policy versions | Isolate retrieval, model, tool, or credential failures | Fail one child span while a retry succeeds |
| A platform owner needs bounded remediation | Approved action record, before/after metrics, verification probe | Execute or roll back an allowlisted change | Replay the same event and verify one action |

## 2. Boundary and definitions

- Task: one durable logical user operation. Accepted only after persistence.
- Attempt: one execution of a step; retries are separate attempts.
- Failure: terminal task failure or step failure according to the signal definition.
- Denied action: expected policy enforcement unless independently classified as a fault.
- SLI population: eligible production tasks; define exclusions before measuring.
- Task success SLI: successful terminal tasks / eligible terminal tasks. Track unfinished task age separately.
- Task latency SLI: successful tasks completed within deadline / eligible terminal tasks.
- Step error ratio: failed attempts / all attempts, over identical tags and windows.
- Evaluation coverage: evaluated eligible records / all eligible records, with sampling policy attached.
- Unknown: missing, stale, inconsistent, or incomplete evidence. Never equal to healthy.

## 3. Signal registry

For each signal record: name, type, unit, instrumentation point, schema version,
allowed dimensions, numerator/denominator, aggregation, sampling dependencies,
delay, retention, data classification, owner, dashboard, monitor, and runbook.

| Signal | Type / unit | Population | Suggested dimensions |
| --- | --- | --- | --- |
| agent.step.calls | count / attempts | Every completed instrumented step attempt | env, service, step |
| agent.step.errors | count / failures | Same population and window as calls | env, service, step |
| agent.step.duration_seconds | distribution / seconds | Every completed step attempt | env, service, step |
| agent.task.completed | count / tasks | Durable terminal-state transitions, deduplicated | env, service, outcome |
| agent.task.oldest_age_seconds | gauge / seconds | Outstanding accepted tasks | env, queue |
| agent.eval.coverage | gauge / ratio | Explicit eligible cohort and time window | env, evaluator_version, cohort |

The Go sample implements only the three step metrics. Task, evaluation,
collector, and remediation signals require their own producers.

## 4. Trace and dataset schema

Require trace_id, span_id, parent_span_id, operation, start/end time,
service, environment, release, contract_version, safe error category,
attempt number, and task correlation reference. Keep high-cardinality IDs out
of metric tags. Use an explicit service/env/version mapping in Datadog.

Document queue propagation, span links, fan-out, timeout/cancellation handling,
terminal outcome, maximum task duration, clock assumptions, and completeness.

Dataset manifest: dataset_id, source interval, sampling/retention policy,
schema version, deduplication key, completeness checks, redaction version,
consent/access rules, deletion deadline, evaluator model/rubric version,
ground-truth labels, and train/calibration/holdout split by task.

## 5. Example thresholds, not measured service promises

- Retrieval step latency marker: greater than 1.5 seconds.
- Retrieval deadline: 2 seconds; dependencies must honor cancellation.
- Error-rate candidate: greater than 2% over five minutes, with at least 100 attempts.
- Recovery candidate: below 1% with sufficient volume and healthy telemetry.
- Before auto-action: breach persists in multiple fresh windows and an independent probe confirms it.
- Separate zero-traffic, collector heartbeat, dropped-span, task-age, and missing-data monitors.
- State routing, owner, escalation, maintenance policy, and safe action for every monitor.

## 6. Dashboard specification

Journey: task success, latency, outstanding age, volume, version overlays.
Dependencies: per-step volume/error/latency, retries, queues, provider quota.
Quality: semantic failures, reviewed findings, evaluator coverage, drift.
Telemetry: SDK/Collector loss, export retries, trace completeness, ingestion/indexing volume.
Recovery: action count, guardrail denials, verification success, rollback and recurrence.

Every widget needs a query, unit, window, denominator, owner, source population,
and link to a runbook and filtered evidence. Display sampling and missing-data caveats.

## 7. Retention and analytics

Compute metrics before trace sampling. Error-focused policy: keep marked errors,
slow traces, and a small healthy baseline; strictly error-only is an explicit tradeoff.
Specify SDK recording, Collector decision wait, trace-affinity routing, memory budget,
late-span handling, Datadog ingestion, span/trace indexing, and dataset deletion.

Run cheap deterministic checks on every received record. Enqueue permitted,
redacted evidence for bounded AI evaluation. Treat tool text as untrusted data.
Require evidence span IDs, evaluator version, abstention, and reviewed calibration.
An AI score is not an incident or an authorization to run a command.

## 8. Remediation contract

Allowlist actions and target selectors. Require authenticated events, fresh independent
evidence, policy approval, idempotency, cooldown, distributed locking, an action budget,
canary scope, rollback, a kill switch, and post-action verification. Keep incident history
and record denied actions. Bound privilege by the same identity rules as other tools.

## 9. Delivery and acceptance

Version this document, machine-readable contract, Go instrumentation, Collector config,
Terraform monitors/dashboard, dataset schema, evaluator rubric, and runbooks together.
CI validates schema/units/tag cardinality, compiles examples, checks monitor queries,
and tests delayed/missing spans, cancellation, low traffic, silent failures, judge errors,
export loss, duplicate actions, and failed rollback in staging.

Required approvals: service owner, on-call owner, platform/security, data governance.
Record actual targets and evidence before changing status from draft to approved.
