Review the prerequisites
Suitable for: Backend developers learning Agent applications.
- Incident containment, evidence, and causal diagnosis
- Implement and explain denominator-correct metrics and first-stage diagnosis, preserve red-to-green evidence, then design containment and rollback without erasing business facts. Public checks do not prove authorship, semantic quality or real incident experience.
How does the mechanism work?
Step-by-step explanation
- How to monitor if the quality drops but HTTP 200 is normal?
Incident assessment must check business quality beyond HTTP status.
- What to do with in-progress tasks after rollback?
After containment and rollback, business operations still in flight require handling.
- What information should go into the incident log?
Causal diagnosis requires reliable records and a clear separation of facts from hypotheses.
Implementation · Build it
Implement the contract · Incident containment, evidence, and causal diagnosis
Objectives of this level: Implement validated aggregation with explicit denominators, filters, duplicates and missing labels.
Visual guide · From aggregate alarm to a task
Equal aggregate symptoms can have different causes. This fixture protocol finds an observed broken stage; missing observations remain unknown. Select the figure to open it at full size.
Your code, imported and called by the grader
Implement both functions in your own incident_student.py; do not edit the support program or return your own passed declaration. You implement aggregation here and the task-local diagnosis contract in the next layer. Until both functions are implemented, the full grade is expected to fail. Both generic solution functions are intentionally absent from the public support files. Copying an external solution is guided work and must be declared; it does not demonstrate independent work. A reviewer must change a condition and inspect your explanation and diff to assess transfer.
def summarize(tasks, events, *, version=None, tenant=None, start_ms=None, end_ms=None):
raise NotImplementedError("implement the complete metrics contract")
def first_failure(task, trace):
raise NotImplementedError("implement the evidence-stage contract")
The complete fixed inputs appear in the foundation body, and the support code appears at the end of the debugging body. Save that code as incident_lab.py, or download the same standard-library support file. Also download the public input/expected manifest and save it as incident-cases.json beside the script and your module; the grader needs that separate file. The manifest contains the public 55 behavioral checks plus fixed inputs, while the script adds the function-presence check. Neither file contains a general-purpose solution to either student function. No dependency installation, key or network call is needed after both support files are saved. The script imports the student module; use a file you control because import executes Python code. It is not a sandbox.
python3 incident_lab.py scaffold --out incident_student.py
python3 incident_lab.py sample --case amber --out amber.json
python3 incident_lab.py sample --case violet --out violet.json
python3 incident_lab.py grade --module incident_student.py --out incident-grade.json
Run scaffold only once; it refuses to overwrite an existing module. sample writes complete fixture records, exit 0. The unimplemented scaffold grades with exit 1 and a real report (1/56 checks: the functions exist but their behavior fails). Exit 0 means all public mechanical checks passed. Exit 2 means module/setup failure, not an assessed solution. The report records the actual student file SHA-256 and individual expected/actual results. Preserve the baseline report before editing.
Exact input and error protocol
tasks and events are lists of dictionaries with exactly the keys emitted by the complete foundation generator. A task's ID, tenant, version, resource and expected/actual status are nonempty strings. Start/end/rounds are nonnegative integers, end is at least start; booleans are not integers for this contract. accepted is a boolean or None. Every task ID is unique, including exact duplicate rows.
An event's ID, task ID, version and kind are nonempty strings; its timestamp is a nonnegative integer within the associated task's inclusive start/end window. Its version must equal that task's version. kind and the exact data keys are: model_step → round (integer ≥1); candidate → target_resource (nonempty string); authority → allowed (boolean), permission_epoch (integer ≥1); tool_call → call_id, name, resource_id (nonempty strings), http_status (integer 100–599), attempt (integer ≥1); context → required_ids, context_ids (lists of unique nonempty strings); terminal → status (nonempty string). Empty evidence lists are permitted. Extra fields, missing fields, other kinds and wrong types are invalid.
First validate the whole task list in order, then the whole event list in order, and only then filters. The first encountered error raises exactly ValueError(code): input_shape for a list/dictionary/field/type/range violation; duplicate_task_id for a repeated task ID; orphan_event for an unknown task binding; event_binding for mismatched version or time; event_id_conflict for a repeated event ID with different content. Identical re-deliveries with the same event ID are deduplicated. Two different IDs still count as two recorded calls; event identity is a fixture assumption, not automatic detection of duplicate remote effects. Both functions leave all inputs unchanged.
For summarize, optional version and tenant are None or nonempty strings. Optional start/end are None or nonnegative integers, excluding booleans; if both exist require start < end. Invalid filters raise ValueError("filter_shape") after input validation. Select whole tasks by version, tenant and their started_ms interval. Include all deduplicated events bound to selected tasks. Derive rounds from the task rounds field, not span count. This contract does not infer missing model-step observations or reconcile external effects.
Exact output protocol
Return exactly the 11 keys below. The eight count fields are integers (not booleans). acceptance_rate, rounds_per_task and tool_403_rate are floats, or None if their denominator is zero. Count known labels separately: acceptance = accepted / known labels, pending = task count − known labels. If labels are missing, report coverage; do not present the known-only rate as all-task success. Empty selections return zero counts and three None rates. A v2 amber result is:
{
"task_count": 4, "acceptance_known": 4, "accepted_tasks": 2, "pending_tasks": 0,
"acceptance_rate": 0.5, "rounds_total": 16, "rounds_per_task": 4.0,
"tool_call_count": 8, "tool_403_count": 4, "tool_403_rate": 0.5,
"tool_retry_count": 2
}
tool_retry_count counts selected calls with attempt > 1. It is 0 in v2 violet even though its tool call count is also 8. Implement loops/grouping yourself and keep source plus output, not only a screenshot. Use summarize(..., version="v2", tenant="t1"), the time slice [1100, 1300), an absent tenant, duplicated events and missing acceptance labels. Record the expected counts before running. The public grader imports your module, changes task/resource/policy/event IDs, changes rounds and task count, and checks slices, duplicates, invalid fields and unchanged inputs. These deterministic public variants resist fixed-number answers; they are not unseen interview evidence.
Submit incident_student.py, the scaffold baseline report, incident-grade.json, the source/input SHA-256 values and your aggregation expectations in incident-evidence.md. No score in this file measures semantic quality, incident response quality, model integration, authorship or enterprise readiness.
code example
Missing labels change coverage, not known outcomes
If two of four selected labels are unknown and two are true, the known-only rate is 2/2 with coverage 2/4. Preserve pending_tasks=2. Duplicated delivery of the same event ID does not create a second call; a conflicting payload is an error, not a silent overwrite.
Acceptance task for this level
Implement summarize in incident_student.py without calling or copying the reference as independent work; deliver the scaffold grade, your own code/diff, filter and duplicate/missing-label expectations, file hashes and final actual-import grade after the next layer.
Reading this browser’s record…
Hide the answer and check your understanding
Two of four selected tasks have accepted=None and the other two are accepted=True. What do you report, and may you claim 100% of all tasks succeeded?
Expand reference derivation
task_count=4, acceptance_known=2, accepted_tasks=2, pending_tasks=2, acceptance_rate=1.0. Report known-label coverage 2/4; all-task success is unknown. Round and call metrics use their own denominators.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.
- OpenTelemetry:Generative AI semantic conventions
- Google SRE: canary release and comparison
- Google SRE: Roles and Records in Incident Response
- OpenTelemetry: Trace, Span and Asynchronous Causal Linking
- RFC 9110: 403 refusal
- Offline public incident lab source
- Pre-generated public incident inputs and expected outputs
- Project merchant source: identity and ownership boundaries