# Grade contract: structured for a grade

Licence: MIT, see LICENSE-MIT.md.

Version 1. A public interchange format for grading one sent Campaign, in the same family as the copy contract that "Structured for copy generation" appends.

On a settled Campaign's Performance tab, Copy Grade packet offers two items. **Structured for a grade** copies the Campaign's Grade packet with the contract below appended; **Raw context** copies the packet alone. The Grade packet holds the Brand context packet, the Campaign's Brief, its settled figures with their attribution window and read time, the Brand's averages for the 90 days before the send by category, related sends and their results, products sold, link clicks and the email's link layout.

An agent that receives the Grade packet replies with one fenced block in the format below. Import a Retro (HIG-1507) parses this format.

The text between the markers is the contract exactly as the packet appends it. `packages/shared/lib/brand-context/grade-contract.ts` produces it, and a test fails if the two differ.

<!-- grade-contract:start -->
## Response format: structured for a grade (required)

Grade the send above against what its Brief asked it to do. Respond with ONLY one fenced code block, tagged `sendfire-grade`, that holds one JSON object. Write nothing before or after it.

Fields, all required:
- `version` (number): always `1`.
- `outcome` (string): one of `met`, `partly`, `missed`, `unclear`. `met`: the send did what its Brief asked. `partly`: it did some of it. `missed`: it did not. `unclear`: the figures in the packet cannot decide it.
- `read` (string): the grade, in Markdown. Say what the send was for, what happened and why, and cite the figures as the packet writes them.
- `holdTheSame` (array of strings): what the next send of this kind should keep. Use `[]` when nothing should.
- `decidingMeasure` (string): the one figure that decided the outcome, with the figure it was compared against.
- `proposedLearning` (object or null): at most one thing the Brand should remember from this send, or `null`. An object has `statement` (string: the learning in one sentence) and `evidence` (string: the figures from this packet that support it).

Rules:
- The JSON must parse: double-quoted keys and strings, no comments, no trailing commas. Write a line break inside `read` as `\n`.
- Use only the facts in the packet. Do not invent figures, products, links, audiences or results.
- A related send's results are for comparison. Never count them as this send's results.
- Propose a learning only when this send shows something the Brand's learnings do not already say. When the evidence is this one send against a thin average, use `null`.

Example:

```sendfire-grade
{
  "version": 1,
  "outcome": "partly",
  "read": "The Brief asked this send to sell the restocked mug to repeat buyers. It earned the attention: click rate was 3.1% against the Brand's 2.4% average for the 90 days before it. It sold less than those clicks promised: 14 mugs from 412 clicks on the mug's page.\n\nThe opening image link took 61% of human clicks, so the photo did the work the subject line was meant to do.",
  "holdTheSame": [
    "Open with the product photo as the first link.",
    "Keep the subject line under 40 characters."
  ],
  "decidingMeasure": "Units sold: 14 mugs from 412 clicks on the mug's page, when the Brief asked to clear the restock.",
  "proposedLearning": {
    "statement": "On a restock, a product photo as the first link earns most of the clicks.",
    "evidence": "The opening image link took 61% of human clicks on this send (412 of 675)."
  }
}
```
<!-- grade-contract:end -->
