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

# Runbooks & Knowledge Base

> How to author runbooks that agents use during incident diagnosis and resolution.

Runbooks are Markdown files in `.sureops/runbooks/`. The Diagnosis Specialist, Incident Commander, Resolution Specialist, and Verification Specialist automatically retrieve and read the most relevant runbooks for each incident — you don't need to explicitly point agents at a runbook. sureops uses hybrid search to find the best match based on the incident's symptoms, alerts, and affected services.

## How agents use runbooks

During diagnosis, the agent:

1. When the pipeline starts, builds a query from the incident's title and description, filtered to the affected services
2. Runs a hybrid search (semantic + keyword) across your knowledge base's runbooks for those services
3. Retrieves the top-matching runbooks — only matches scoring at least 70% — and includes them as grounding context in its analysis

The diagnosis stage shows which runbooks were used in a **"Customer Runbooks Referenced"** card: each match is listed by title with a relevance-score badge (0–100%), linking out to the source file. This card is **all-or-nothing** — if there's no match, the card doesn't render at all (there's no "no matching runbook found" message today). If you don't see the card during an incident that should have matched one of your runbooks, that's a signal the runbook's content or frontmatter isn't matching well — see [Content best practices](#content-best-practices) below.

***

## Naming conventions

Runbooks live in `.sureops/runbooks/` and use the filename as a searchable identifier. Recommended naming patterns:

```
.sureops/runbooks/
├── payments.md              # One file per service (linked from services.yaml)
├── auth-service.md
├── checkout.md
├── high-error-rate.md       # One file per symptom pattern
├── connection-pool-exhaustion.md
├── deployment-rollback.md   # One file per procedure type
└── database-failover.md
```

Service-specific runbooks are linked from `services.yaml` via the `runbook` field for browsing/documentation purposes, but retrieval itself doesn't use that link — it works off the runbook's own `services:` frontmatter (see the field reference below). Pattern-based runbooks (`high-error-rate.md`, `connection-pool-exhaustion.md`, etc.) are found the same way, through hybrid search — but only if their `services:` frontmatter lists every service the pattern could apply to. A pattern-based runbook with no `services:` list is excluded from retrieval for any incident where the affected service is known — it will never surface at diagnosis time, no matter how well its content matches.

***

## Frontmatter schema

Frontmatter fields help the retrieval layer rank and filter results. All are technically optional, but `services` is effectively mandatory: when an incident's affected service is known, retrieval excludes any runbook whose `services:` list doesn't include it (see the field reference below). `title` is genuinely optional but also meaningfully improves retrieval accuracy.

```markdown theme={null}
---
title: "Payments service: degraded throughput"
summary: "Payments error rate spikes when the connection pool saturates under retry storms."
services: [payments]             # matches name fields in services.yaml — a LIST, even for one service
tags: [latency, retry-storm, connection-pool]
last_validated: 2026-04-15
---
```

| Field | Type | Description |
| - | - | - |
| `title` | string | Shown in the "Customer Runbooks Referenced" card and included in search ranking. If omitted, sureops derives it from the runbook's first `# H1` heading, falling back to "Untitled runbook" if there's no H1 either — but an explicit `title` is clearer and recommended. |
| `summary` | string | Read with top priority into the runbook's stored `summary` field, which feeds the **keyword** side of retrieval (title + summary + full content are combined into the search index used for keyword matching). If omitted, sureops falls back to the first non-empty paragraph of the body (any paragraph, not necessarily under a `## Summary` heading), truncated to 500 characters — set `summary:` explicitly rather than relying on that fallback; see [Content best practices](#content-best-practices) below. |
| `services` | list | **Plural, a list** — even for a single service (`services: [payments]`). Matches `name` values in `services.yaml`. **This is a hard filter, not a ranking boost**: when an incident's affected service is known, retrieval only considers runbooks whose `services:` list includes it — a runbook missing this field, or one that doesn't list the right service, is excluded from that incident's results entirely, not merely ranked lower. The singular `service:` key is not read by anything and has no effect at all — a common authoring mistake. |
| `tags` | list | Keywords for the symptom pattern. Use consistent vocabulary across runbooks. |
| `last_validated` | date | Persisted, and shown as a "Last validated" date on the citation when this runbook is matched during an incident — but it isn't used for retrieval ranking or staleness enforcement. Treat it as a convention for your own team's file-hygiene review, not something sureops checks on your behalf. |

`severity` is not a recognized frontmatter field — nothing reads it today, so it won't filter or boost anything. Leave it out.

***

## Content best practices

### Use the canonical section structure

Structure your runbooks as: **Summary, Symptoms, Diagnosis, Remediation, Rollback, References** (`Rollback` and `References` are optional; the rest are expected). Match this structure across your own runbooks rather than inventing your own headings per file — a consistent shape makes your knowledge base easier to scan and keep current. The scaffold sureops generates via **Generate starter contract** follows this same structure.

Set frontmatter `summary:` explicitly rather than relying on a `## Summary` heading — the mechanism is: an explicit frontmatter `summary:` always wins if present; only when it's absent does sureops fall back to the first non-empty paragraph *anywhere* in the body (not specifically one under a `## Summary` heading), truncated to 500 characters. So a `## Summary` heading is a good authoring convention for humans, but it isn't what sureops actually reads — a runbook whose first paragraph happens to sit under a different heading (or no heading at all) gets that paragraph as its summary regardless. Whichever way the summary is derived, keep it tight — a sentence or two — since it's stored as its own field on the runbook row and feeds the **keyword** side of retrieval (title + summary + full content are combined into the search index used for keyword matching). The **semantic** side embeds the full cleaned content only — title and summary aren't separately embedded. Either way, a vague or missing summary weakens the keyword-search half of retrieval.

### Be action-oriented

Agents are better at following specific instructions than at interpreting vague guidance. Prefer:

```markdown theme={null}
## Diagnosis

1. Check connection pool utilization: query `redis.connections.used` for the last 15 minutes.
2. Check the service's error rate: look for `5xx` responses in the access log.
3. If pool is above 80%, check for long-running queries holding connections.
```

Over:

```markdown theme={null}
## Diagnosis

Investigate the issue using your monitoring tools to find the root cause.
```

### Include service-specific error patterns

Agents benefit from knowing what errors your service typically surfaces during failures — fold these into your `## Symptoms` section:

```markdown theme={null}
## Symptoms

- `ETIMEDOUT` in auth-service logs → usually connection pool saturation
- `too many open files` → kernel file descriptor limit
- `dial tcp: connect: connection refused` on port 6379 → Redis is down or unreachable
```

### Link to dashboards

When you reference a dashboard, include the URL directly. Agents can include it in their output so responders can navigate there without searching:

```markdown theme={null}
## Diagnosis

- [Payments error rate (Grafana)](https://grafana.acme.com/d/abc/payments-errors)
- [Redis connection pool (Grafana)](https://grafana.acme.com/d/xyz/redis-connections)
```

### Include remediation steps with commands

For procedures you want the Resolution Specialist to be able to propose, put them under `## Remediation`. Because this example itself contains a fenced shell command, wrap the outer example in four backticks so the inner triple-backtick fence doesn't close it early:

````markdown theme={null}
## Remediation

### Increase Redis connection pool size

Apply the Helm change:

```
helm upgrade payments charts/payments --set redis.maxConnections=200 -n prod
```

This change takes effect within 60 seconds and does not require a pod restart.
````

***

## The knowledge base

The knowledge base is the collection of all your runbooks, indexed and stored as vector embeddings. Every time you push a change to `.sureops/runbooks/`, sureops re-indexes the affected files.

### Verifying retrieval

During the diagnosis stage of an incident, check for the **"Customer Runbooks Referenced"** card: it lists each matched runbook by title with a relevance-score badge, linking to the source file. This card renders **only when there's a match** — there's no "no matching runbook found" message, so if the card is absent, treat that as "nothing matched" and consider whether a runbook should exist for this pattern (or whether an existing one's content/frontmatter needs tightening so it matches next time).

### Keeping runbooks fresh

Stale runbooks can mislead agents. A runbook that describes an old architecture or outdated procedures is worse than no runbook at all.

Recommended practices:

* Set the `last_validated` frontmatter field as your own team's convention and review runbooks that haven't been touched in 90+ days — sureops shows it on the citation but doesn't flag staleness itself, so reviewing for it is a process you run, not one sureops runs for you
* After a major incident where the runbook was inaccurate, update it as part of closure
* After a successful postmortem, consider whether the postmortem learnings should be folded back into the runbook

***

## Runbook format example

````markdown theme={null}
---
title: "Auth service: authentication failures"
summary: "Auth pods return a spike of 401s when the Redis session store is unreachable or token clock skew invalidates JWTs."
services: [auth]
tags: [auth, 401, token-expiry, redis-session]
last_validated: 2026-05-10
---

# Auth service: authentication failures

## Summary

Auth pods return a spike of `401 Unauthorized` responses when the Redis
session store is unreachable or when token clock skew invalidates JWTs.

## Symptoms

- Spike in `401 Unauthorized` responses from `/api/v1/auth/token`
- Users reporting login failures or session expiry
- Alert: `auth_error_rate > 5%`
- `token validation failed: redis: connection refused` → Redis session store unreachable
- `jwt: token expired` spike with no service restart → NTP skew (check clock drift)
- `too many connections` in auth-db logs → database connection pool exhaustion

## Diagnosis

1. Check the auth service error rate over the last 30 minutes.
2. Check Redis connectivity from the auth pods: `kubectl exec -n prod -it auth-pod -- redis-cli -h redis ping`
3. If Redis is unreachable, check Redis pod status: `kubectl get pods -n prod -l app=redis`
4. If Redis is healthy, check for token clock drift: query `auth.jwt.clock_skew` metric.

## Remediation

### Redis unreachable

Restart the Redis pod if it's crashed:

```
kubectl rollout restart deployment/redis -n prod
```

Recovery is typically within 30–60 seconds. Existing sessions may need to re-authenticate.

### Clock drift

Contact your platform team to investigate NTP sync on the auth service pods. This requires a node-level fix and cannot be mitigated by a pod restart.

If auth failures persist after Redis recovery or if the root cause is unclear, escalate to `#team-auth-oncall`.

## References

- [Auth service runbook (internal wiki)](https://wiki.acme.com/runbooks/auth)
````


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.