# The Context Pack (resume --pack)

```bash
memprove resume --pack                 # this Workspace's Task, budget 9000
memprove resume --pack --budget 3000
memprove resume --pack --query "truncated header"
memprove resume --pack --claims 3,5-7  # the full lines of those claims, no budget
memprove resume --text                 # one line per statement, for a person
```

The Pack is a fixed set of lines, in this order: `Pack:` (format, `capsule_digest`, ledger sequence, probed HEAD,
budget), `Ontology:` (the version of the verdict rules), `Query:` (only with `--query`: the phrase and the matches by
rank), `Task「<title>」 (<state>): <verdict>` with the reason codes and the counts of active, superseded and withdrawn
statements, `Integrity:` (every record of the Task recomputes, or which one does not), `Sessions:` (how many in all,
ended normally, ended abandoned, not ended, and the last part counting the Sessions that declared the Pack they
continue from). Then a `Session ` line for every Session that has not ended, with its start, its last write, its agent
(`; agent「<name>」(<role>[, dispatched by Session <j>])`), `continues from the Pack at ledger sequence N (self-reported, digest sha256:<first 12 hex>)` when it declared one, and the takeover hint when it is not yours. The
Session lines list every Session that has not ended, the latest Session that ended, and the latest three that ended
abandoned (`ended abandoned`); Every other Session is only counted on the summary line. Then `Last passed:` (the
latest passed test run, its commit and the arguments that record it again), `Can:`/`Cannot:` lines for completing the
Task, beginning a Session and recording a fact on the latest run (with the Problem code a write would get), `Base:`
lines (each commit facts are bound to and the files changed since), the claim lines (`#n verified: 「…」 (evidence bound
to commit …; from Session k)`, `#n fact stale: …`, `#n open item: …`, `#n decision: …`, `#n next action: …`), `Rerun:`
(the command to run again on the current HEAD and the facts it would confirm) or `No rerun needed:`, `Gaps:`,
`Omitted:` and `Digest:`.

- The budget counts UTF-16 code units of the whole output. The default is 9000; `--budget` takes a whole number from
  1000 through 1000000. When the Pack is longer, it leaves things out in steps that stop as soon as it fits: level 1
  writes only the number of changed files on each base line; level 2 shortens each body longer than 120 characters to
  its first 120 and says how many were left out; level 3 omits whole bodies; level 4 folds the verified active facts
  into one `Folded:` line with their numbers; level 5 stops listing claims one by one, facts first, then Decisions,
  then open items, and counts them on a `Not listed:` line. The next action is never shortened and the first,
  integrity, session, `Can:`/`Cannot:` and `Omitted:` lines are never left out. The `Omitted:` line says the level and
  how many bases, bodies and claims were affected. When even level 5 does not fit, nothing is printed and the command
  exits 1, and standard error names the least budget that fits.
- The last line is `Digest: sha256:<pack_digest>`, the SHA-256 of the UTF-8 bytes of every line before it. The Pack
  holds no time of its own, so the same ledger, probe and budget give the same bytes.
- Every text an agent wrote is between `「」`, with control and format characters, line separators and the quote-like
  characters escaped, so a statement cannot forge a Pack line. Put the conclusion in the first sentence of a
  statement's text: the Pack may keep only its first 120 characters.
- `--pack --claims <NUMBERS>` prints the full Pack lines of the claims named, superseded and withdrawn ones too, after
  the base lines they name, with no budget. `--text --claims <NUMBERS>` prints only the `resume --text --all` lines of
  the claims named, in full, superseded and withdrawn ones too. Both take numbers and ranges separated by commas
  (`3,5-7`).
- `--query <TEXT>` (1 to 256 characters) selects the statements that match the phrase, best first (an in-memory FTS5
  index: terms of three or more characters by substring, shorter ones as whole words; the kind words `fact`,
  `open_item`, `decision` and `next_action` match statements of that kind), with what supersedes them and the next
  action in force; the `Query:` line gives the matches by rank, and `0 matches` leaves the statement section empty.
- `resume --text` is the same record for a person: one line per statement (`#n verified: 「…」 (evidence bound to commit
  X, current HEAD Y; verdict: verified; from Session k)`), the `Rerun:` line with the listed argv (the `env
  NAME=value` prefix included; A run with a different argv is a different command), and one last line for the
  statements that a later one superseded or withdrew. That line counts each kind and names their numbers; `resume
  --text --all` lists each of those statements on its own line instead.
- In a `tampered` Pack the first `Integrity:` line adds `claim numbers may differ from before`, no line says
  `verified`, and `Cannot:` lines give `evidence_stale`.
