# Coverage

A capability carries an importance: `p0` (business-critical), `p1`
(important), `p2` (normal — the default), or `p3` (minor). Set it thinking
about what breaks for the business if this capability silently stops
working, not how technically complex it is to test.

## Linking is a claim, not a guarantee

Linking a flow to a capability is a claim that the flow covers it — it
is not, by itself, proof that the capability works. The actual
coverage verdict (covered, failing on a known issue, stale,
uncovered, or blocked) is derived separately: from that flow's
recent run health over a rolling window, and from the issues
linked to the capability. A link with
no healthy recent run behind it does not mean the capability is
tested; it means someone asserted it should be.

Never tell a user a capability is tested just because a link exists.
If asked about coverage, speak to the derived verdict, not the
presence of a link.

## Evals prove agent capabilities

An eval is a repeatable test of an agent, run against a fixed set of
cases. It proves a capability (typically in an agent area) the way a flow
does for a feature. Link one with `cofactor product-map capability
link-eval <CAP-…> --eval <name>` (an eval's `proves.capabilities`
does the same at `eval push`), and a rule with `rule link-eval <prule_…>
--eval <name>`. The eval must belong to the capability's application;
links to an eval in another application or organization are refused.

Coverage counts only passing FULL eval runs: every case, at the eval's
own repeats and pass bar, on the eval's default model. A partial run
(`--case`) or a run of another model proves nothing, and neither moves
the verdict. A capability is covered when any linked flow or eval has
passed recently. An eval that never passed, or whose latest full run
failed, is red: with an open issue explaining it (see Known Bugs) the
capability reads failing on a known issue, exactly as for a flow;
without one it is stale (it passed before) or uncovered (it never
did, and no eligible flow is linked). An eval whose last pass is old
is stale: rerun it. A rule is proven while a linked eval's latest
full run passed.

## Known bugs are linked issues

A bug that breaks a capability is an issue linked to it — to the
capability, or to the one rule it breaks (`cofactor issues link <id>
--capability CAP-… [--rule prule_…]`). The link is what coverage reads:

- Failing on a known issue: every flow and eval linked to the capability
  is red (never passed, failing, or degraded; for an eval, never passed
  or its latest full run failed) and an open issue is linked. A flow
  set to blocked on an open issue counts as explained too, and the
  issue it cites counts as linked. The red is explained, so the flow
  stays honest and red; it is not uncovered and not untriaged. It is
  counted on its own, never as covered. A green flow, or an eval whose
  latest full run passed recently, stays covered whatever is linked.
- Blocked by an issue: no flow or eval is linked yet and an open issue is
  linked — the bug is why coverage can't be built. This is derived; do
  not also write a blocked reason for it.
- Rerun due: a linked flow is still red and a linked issue closed after
  it last ran (or it has never run). Rerun the flow. A pass makes the capability covered; a failure means the
  issue is not fixed — reopen it or file a new one.

A red flow with no linked open issue is a failure nobody has triaged
yet. Triage it before linking anything: link an issue only when the
evidence shows the product is wrong, not the test.

## Where unmapped coverage lives

A count of flows that don't map to any capability belongs to the
application as a whole — it is not a property of any one area. Don't
attribute an application-wide unmapped-coverage count to a specific
area; it says something about the map's completeness in general, not
about that area's completeness in particular.

## Rule evidence

A rule is proven by a workflow node or assertion (below) or by an eval
(see Evals Prove Agent Capabilities); it is proven when any link is.

Link a rule to the node that proves it, or to one authored assertion on that
node. Use rule ids from `product-map show --json` and node/assertion ids from
`workflow get`. The rule and workflow must be in the same application and org;
deprecated rules cannot gain links. Both commands are idempotent:

```bash
cofactor product-map rule link <prule_…> --workflow <wf_…> --node <nodeId> [--assertion <assertionId>] --org <org> --env <env>
cofactor product-map rule unlink <prule_…> --workflow <wf_…> --node <nodeId> [--assertion <assertionId>] --org <org> --env <env>
```

`show` (including `--json`) returns each rule's links and coverage:

- gap: no links.
- unproven: links exist, but none passed in its workflow's latest finished run.
- proven: at least one link passed in its workflow's latest finished run.

Judge the linked node/assertion, not the whole run: a later failing node
does not un-prove an earlier passed node or assertion in that finished run.
An unfinished run does not replace finished evidence. Archived workflows
remain listed but never prove a rule. An assertion must actually have
passed, not merely been configured or skipped. A standalone assertion's id
is its node id. Rule evidence is separate from capability coverage health.

Fork promotion carries fork-linked evidence to mapped surviving origin
nodes/assertions while retaining the fork rows until the fork is deleted.
Sync and revision/snapshot restore preserve links for surviving node and
assertion ids and drop missing evidence. Re-link a newly authored replacement
when it has no mapped origin identity.

## Screen checkpoints prove rules

Plan visual coverage per meaningful screen state: empty, a little data,
a lot of data, mixed kinds, long or overflowing content, error or failure,
stable loading, and permission-limited access, wherever each applies.
One populated capture does not show how the page handles the other states.
For example, capture Cofactor's Workflows list empty, with three rows,
and with many rows with long names.

Name each checkpoint by page and state and link it to the capability or
rule it actually shows. Record how to reach each state in the capability's
setup: thin sandbox seeds, generic actions or a test-owned SQL fixture,
with a reset of the test's own data between independent states. Use fixed
neutral data and repeatable dates, ordering and personas. Use separate
tests with fresh sandbox copies when states cannot be reset independently.
See `cofactor workflow guide visual-checkpoints` for the authoring example.

A linked visual checkpoint proves a rule when its latest qualifying suite capture matches its automatic main baseline with the same masks; step success alone is not proof. An active screen regression makes the rule Failed.
