# The engine's persisted data model

The engine owns three standalone document types in the Content Lake:

| Doc type                     | Constructed by                               | Mutated after create                                                                          |
| ---------------------------- | -------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `sanity.workflow.definition` | `planDefinitionDeploy` (`src/api/deploy.ts`) | never — deploys are create-only                                                               |
| `sanity.workflow.instance`   | `buildInstanceBase` (`src/instance.ts`)      | every persist writes the canonical state via `instanceStateFields` (`src/engine/mutation.ts`) |
| `temp.system.guard`          | `compileGuards` (`src/core/guards.ts`)       | full-body refresh on stage re-entry; revision-conditional delete on retract                   |

These field trees are **our contract with every past and future engine
version reading the same dataset**. This file is where changes to them are
declared; the model-surface gates keep undeclared drift red:

- **The shape ledger** — `src/__tests__/model-shapes/model-<N>.json`, one
  file per `DATA_MODEL_VERSION`, **append-only**: only the current version's
  file is ever regenerated (`vitest -u` on the gate test), so past model
  shapes stay checked in verbatim — the historical corpus future upgrade
  machinery tests against. The instance and guard shapes are **declared**
  trees, derived from each doc type's runtime schema
  (`WorkflowInstanceSchema` / `MutationGuardDocSchema` via
  `schemaTreeShape`) — the schema is the single source of truth for the
  stored shape, and a declared tree pins optional fields no fixture
  reaches. The definition document and the persist write-set stay
  **concrete** trees built through the real constructors (the deploy plan's
  envelope and the persist field-set are constructor facts). The ledger also
  pins the stored grammar's vocabulary (every enum's values, every variant
  discriminator), so a value rename is as red as a key rename.
- **Coverage tests** (`src/__tests__/model-surface.test.ts`) walk the stored
  definition schema and fail when any declared key, discriminator, or
  instantiable enum value stops appearing in the canonical document — the
  grammar cannot grow past the fixture silently. Parse gates keep the
  schemas and the constructors in lockstep: the canonical constructor-built
  instance and guard must parse cleanly through their doc schemas.
- **The lifecycle ledger** (`model-shapes/model-<N>.lifecycle.json` in
  `workflow-engine-test`) drives real instances through the verbs —
  including the recovery paths (expired-lease sweep, loop-back re-entry
  adoption, dead-end propagation, abort) — and pins the interior trees a
  fresh construction can't reach: `StageEntry` / `ActivityEntry` /
  `SubworkflowEntry` rows, pending effects (claim included), effect
  history, the idempotency ledger, and ALL `HistoryEntry` variants (the
  accounting is compile-checked against the union, so a new variant fails
  the build until the scenarios produce it). Every verb-driven document
  must ALSO parse cleanly through the instance schema — a verb writing a
  tree the read boundary would reject fails here, not in production.

This is **not** definition-content versioning: `version` / `pinnedVersion` /
`contentHash` track what an author deployed; the model stamp tracks the shape
of the documents the engine itself writes.

## The stamp pair

The two doc types whose format the engine owns outright — definition and
instance — carry two numbers (built together by `modelStampFor` in
`src/core/model-version.ts`).
Provenance and compatibility are deliberately separate, because consumers
sharing a dataset upgrade months apart (Functions lag Studios lag CLIs) and
"newer" must not mean "incompatible".

**The guard doc carries NO stamp.** `temp.system.guard` is a foreign
contract: the persisted format mirrors the Content Lake's forthcoming guard
primitive, and the engine must not grow fields on a shape it doesn't own —
the lake dictates that format long-term. The guard doc's versioning event is
the `_type` cutover itself (an engine that predates `system.guard` simply
never matches the new type).

- **`modelVersion` — provenance ("conforms-to").** The value of
  `DATA_MODEL_VERSION` at write time: "this document conforms to model N
  now". Advances for **every** declared shape change, additive included,
  though several changes merged into one unreleased model share its number
  (rule 9).
  Instances are re-stamped on every full persist (and rollback restore).
  Partial patches deliberately leave the pair alone — they don't normalize
  the shape, so restamping there would lie.
- **`minReaderModel` — the document's reader floor.** The oldest engine model
  that can safely _interpret this particular document_. Writers derive it
  from compatibility-bearing features present in the canonical stored tree,
  while retaining the unconditional `DATA_MODEL_MIN_READER` baseline of 4.
  `DATA_MODEL_MAX_READER` is the maximum floor the current writer can emit.
  A deployment acknowledges the highest reader model verified
  for its shared runtimes, and the writer compares it with the submitted
  definitions' required floor.
- **Missing stamp = model 0** (floor 0) — the document was last written
  before the stamp existed. A `modelVersion` with no `minReaderModel` is
  malformed foreign data and gates conservatively: the stamp is the floor.
- **Backward compatibility is unconditional.** An engine at model N reads
  every stamp `0..N`. There is no supported-version floor for _old_ docs;
  introducing one is a deliberate future mechanism, never a side effect of
  a shape change.
- **Fail hard on `minReaderModel` ahead.** Every engine read of a stamped
  doc type (definition, instance) passes through `assertReadableModel` —
  point reads, list queries, the drained-children projection, snapshot
  hydration's raw reads. A floor ahead of the engine's `DATA_MODEL_VERSION`
  throws `ModelVersionAheadError` ("upgrade `@sanity/workflow-engine`")
  instead of silently misreading a shape this engine predates. Deliberately
  wholesale: one such document in a read's scope fails the whole read (a
  listing, a verdict computation) rather than degrading silently. Two
  structural exceptions: existence-only probes (no shape is interpreted),
  and lake-side GROQ filters, which evaluate persisted fields server-side
  before any client gate can run — their safety rests entirely on rule 3's
  additive-only constraint.
- **Parse, don't cast — the shape gate behind the model gate.** After the
  floor check, every engine read of an instance document parses it through
  the runtime schema (`parseInstanceDocument`; `readInstanceDoc` composes
  gate + parse), and every guard read parses through
  `parseGuardDocument` — a malformed tree throws `PersistedDocShapeError`
  naming the document and the offending fields, instead of corrupting
  behavior downstream. The parse is TOLERANT where governance requires it:
  unknown keys pass at every level (the round-trip rule), and `history[]`
  admits unknown future variants (audit rows an engine only appends and
  filters by known `_type`s). It is EXACT on everything the engine
  interprets — statuses, discriminators, refs, timestamps — which makes
  vocabulary growth inside a known persisted shape a **breaking** change
  under rule 5 (a validating old reader rejects the new value): widen the
  fleet's readers before any writer emits it, or raise the floor. The
  definition document deliberately has no read-side content parse: deploys
  are create-only and the content is strictly parsed at that sole write
  boundary; a read-side strict parse would wrongly reject additive
  newer-model definitions.
- **Consumer surfaces adopt the gate at their own direct reads.** The
  reactive studio/sdk adapters validate every engine-owned stream at the
  observer boundary (gate + parse, surfaced as an explicit invalid/
  model-ahead session state instead of a throw); the CLI's direct reads, and
  the MCP tools and Studio-plugin reads that interpret rows from the
  deliberately-ungated `engine.query` escape hatch, apply
  `assertReadableModel` per document — list projections carry the stamp
  pair so projected rows gate too. Those surfaces are deliberately
  gate-only (no shape parse): projections structurally can't shape-parse,
  and the CLI's full-doc readers are INSPECTION surfaces — an operator must
  be able to open the very document being investigated, so a corrupt doc
  renders best-effort there instead of refusing.
- **Old writers restamp down — the round-trip rule.** An older engine
  persisting a newer-but-compatible instance stamps its own `modelVersion`
  (honest conforms-to; the stamp oscillates in mixed fleets, harmlessly).
  This is safe because full persists are set-only patches and mutation
  copies are spreads, so fields the older engine doesn't know **survive the
  round-trip**. That is a load-bearing invariant: an additive change whose
  fields would NOT survive an old writer's round-trip is not additive — it
  is breaking, and must raise the floor.
- **The floor is raise-only.** A rewrite writes `max(stored minReaderModel, floor derived from the complete post-state)` — it never lowers or drops the
  stored floor, because preserved unknown fields or a historical semantic
  requirement may still require it. (The failure mode this fences off is
  documented across the industry: a rewriter that drops the compatibility
  gate it doesn't understand silently reopens the door the floor closed.)
- **Persisting a floor-bearing feature is an availability decision.** Before a
  definition using that feature deploys, every reader sharing its workflow
  resource — customer-deployed Functions foremost — must run an engine at or
  above the feature's floor. Increasing the writer's maximum alone requires no
  coordinated rollout. Like every engine-side check, the floor is advisory —
  it gates our own clients; the Content Lake stays the sole enforcement point.
- **The gate ships from the engine.** `assertReadableModel`, the parse
  functions, and the error classes are exported from
  `@sanity/workflow-engine`, so every consumer surface composes the same
  primitives — the reactive adapters at gate + parse, the CLI/MCP/plugin
  direct reads at gate only (see "Consumer surfaces adopt the gate" above
  for the split and its rationale).

## Definition-language philosophy

The authoring DSL is one language, not a bag of options. The principle of
least surprise applies to the WHOLE surface, and the test for any addition is
self-similarity: **someone who knows one part of the DSL should be able to
guess the rest.** Every change to the definition tree is designed against
these principles before the change-process rules below apply.

1. **Same concept, same word, same shape — at every level.** The gating
   vocabulary is the canonical example: `filter` is **existence** (a
   non-match might as well not exist — hidden, never merely disabled),
   `requirements` is **readiness** (named readiness gates; an unmet entry
   keeps the node visible but disabled, with the failing entries named),
   `when` is **trigger**. A position that needs one of these concepts uses
   the name and shape the concept has everywhere else; a concept that
   changes name or shape between levels is a defect in the language, not a
   local convenience.
2. **Surfaced things are nodes; mappings are internal.** Anything a person
   will see — stages, activities, actions, transitions, fields, guards —
   is an entry in a **polymorphic array of named objects**:
   `{name, title?, description?, …}`, discriminated by `type` where
   variants exist, so every surfaced entry can carry its own human copy.
   Plain records (name → expression) are for internal mappings no surface
   renders (predicates, effect bindings, role aliases). If an entry can be
   shown to a person, it is an object in an array; a concept that outgrows
   a record becomes an array of nodes, never a record of objects. Existence filters need none of this: a filtered-out entry
   renders nothing, so there is nothing to title — bare condition strings
   remain correct there.
3. **New capability is a new value in an existing slot, never a parallel
   mechanism.** Extend the vocabulary of an existing slot — a new named
   entry, a new declared value, a new synthetic variable — before adding a
   sibling property. A proposal arriving with its own error type, its own
   ordering rule against an existing gate, or its own verdict leg beside an
   existing mechanism's is the smell that it duplicates that mechanism.
4. **Legibility comes from structure, not from bespoke props.** When a
   surface needs to explain a refusal, the fix is named or structured slots
   whose entries surfaces can address — never a one-off property added so
   the engine can recognize a single policy. If the existing mechanism is
   illegible or undiscoverable, restructure that mechanism. Authoring-time
   discoverability can also live at the library layer — typed, documented
   helpers that emit canonical expressions — before the model grows any
   surface for it.
5. **If the gap is scoping, add a scope, not a mechanism.** A rule that
   duplicates an existing behavior with different scoping (per-definition
   vs cross-definition, per-subject vs per-run) is the existing mechanism
   plus a scoping value or variable, not a new property.
6. **A persisted name is forever.** The shape ledger is append-only and
   renames are forbidden (rule 3 below), so the name and shape of a new
   definition-tree property are merge-blocking review concerns, not
   bikeshedding. Names describe the check (`requirements`), never promise
   an outcome the advisory engine cannot deliver (`unique`, `locked`).
   Value vocabularies follow the established scheme — single lowercase
   words, camelCase for multiword values (`todoList`, `fieldRead`), dotted
   namespaces for families (`doc.ref`, `field.set`) — and nothing else: the
   definition grammar has no kebab-case values, and no addition introduces
   the first.

System documents are never workflow subjects by default: the reserved `sanity.`
and `system.` namespaces, and the engine's own document types (instance,
definition, guard). The rule is the engine's and it applies at read,
identically for a definition stored under any model, so a `subject` entry that
declares no `types` accepts every content type and none of those. Naming a
reserved-namespace type explicitly in `types` opts back in; an engine-owned
type never matches, even when named.

One block sits outside the persisted language entirely: `runtime` declares where
the generated unattended runtime hosts a workflow or an effect, tooling reads it
at authoring and generation time, and the deploy strips it so nothing reaches the
Content Lake. One rule decides the category for any new property: it is stored
if the engine reads it while running, and authoring-only if only tooling reads it
before deploy.

## Rules for changing the model

`DATA_MODEL_CHANGES` is the append-only, machine-readable counterpart of the
model log. Every independently reasoned persisted-model feature records a
stable id, introduction model, affected document types, compatibility class,
reader floor, and summary. The manifest drives writer-side floor derivation
and diagnostics; this prose log remains authoritative for the reasoning,
absent-value behavior, and old-writer round-trip proof.

Feature applicability is explicit. A **detectable** feature contributes its
floor only when its stable marker is present in the canonical stored tree. An
**unconditional semantic requirement** applies to every newly written document
of its declared type when no reliable marker exists. Readers trust the
persisted floor; they do not recompute features they may be too old to know.
Every reader-floor increase is represented as a manifest feature and classified
this way. Raising `DATA_MODEL_MAX_READER` expands what the writer may emit; a
detectable feature raises only documents carrying its stable marker above the
retained model-4 baseline.

1. **Any change to a persisted field tree is a model change** and must be
   declared: update the model-surface snapshot, add an entry to the model
   log below, and decide — in the same change — whether `DATA_MODEL_VERSION`
   moves **and whether the reader floor moves with it**. Nothing lands
   "incidentally".
2. **Additive optional fields are allowed** without machinery: land on the
   current model per rule 9 — bumping `DATA_MODEL_VERSION` when that model has
   shipped and joining it when it has not — leave the reader constants
   untouched, and declare the tolerant read (what an absent value means on
   docs written before the field existed) plus why the field survives an old
   writer's round-trip.
3. **Renames, removals, and semantic changes are not allowed yet.** They
   require versioned upgrade machinery (per-model normalization steps applied
   on read) that does not exist; until it does, the model may only grow
   additively. When such a change eventually lands, it raises the affected
   documents' reader floor — through `DATA_MODEL_MIN_READER` when no reliable
   marker exists — and ships only after the fleet story is written.
4. **`DATA_MODEL_VERSION` moves when compatibility reasoning changes** — when
   a reader would need to know which shape it is looking at, and that model has
   already shipped (rule 9). A purely internal refactor that provably writes an
   identical tree does not move it.
5. **Classify by misinterpretation, not parseability.** The snapshot gate
   catches structural drift only. A change can be structurally additive yet
   change the MEANING of existing fields — old readers parse it fine and
   silently misinterpret. That judgment (would an old reader misread, not
   just fail to parse?) is exactly what decides whether
   a feature floor moves, and no snapshot can make it — each model
   log entry states it explicitly.
6. **Manifest and prose move together.** Every structural model change adds a
   manifest entry and matching model-log declaration. The ledger snapshots
   the stored grammar and manifest. A semantic-only implementation change may
   have no observable schema delta; review must still classify and log any
   change to how persisted values are interpreted.
7. **The PR compatibility callout is mandatory and explicit.** Near the top of
   the PR body, state the writer's `modelVersion`, name every feature introduced
   or changed by the PR that contributes a `minReaderModel`, and state the floor
   for documents where those features are absent. Say plainly whether model-0
   readers still work for those documents. Give the rollout order and scope:
   readers-first before any writer can persist a floor-bearing feature, not a
   misleading fleet-wide minimum when floor derivation is document-specific.
8. **A new definition-tree property justifies itself against the
   definition-language philosophy above.** The model-log entry states why no
   existing slot, value, or variable could carry the behavior. "The existing
   mechanism is illegible or undiscoverable to surfaces" is an argument for
   restructuring that mechanism, not for a sibling property beside it.
9. **A model number is assigned per release, not per merged change.** A change
   merged before its model has shipped joins that model's log entry and its
   ledger instead of opening a new number, so one release carries one model.
   Reworking a ledger that has not shipped is the one exception to
   append-only; once a model is released its entry and ledger are frozen.
10. **Raising any feature's reader floor raises every acknowledgement whose
    definitions now require it, in the same change.** Each app under `apps/*` that deploys
    definitions submits them with a reviewed `expectedMinReaderModel` literal,
    so a feature whose floor those definitions now require breaks that app's
    definition deploy until the literal moves with it. Raise every affected
    literal in the same pull request, after confirming the runtimes sharing
    that workflow resource read the new model. `pnpm test` proves it for every
    app that declares its deployments in a `sanity.workflow.ts`: each runs an
    offline guard deriving the required floor over its own definitions and
    fails when its literal is below it. A script passing an acknowledgement
    directly to `deployDefinitions` follows the same rule with no guard
    covering it. The rollout order and the guard's wiring are in
    `docs/reader-model-rollout.md`.

## Model log

### Model 0 — pre-governance

Everything written before the stamp existed. Documents carry no
`modelVersion`. The shape history of model 0 was absorbed by tolerant reads
that predate this file — recorded here so they are declared compatibility
rules, not folklore:

- **Instances without `subworkflows[]`** (persisted before the subworkflow
  registry existed) — read as `[]`; the next full persist materializes it.
- **Instances without `processedRequests[]`** (persisted before the
  idempotency ledger existed) — read as `[]`; the next full persist
  materializes it.
- **Definitions without `contentHash`** (deployed before content-addressing)
  — always read as changed, so the first redeploy after upgrade mints a
  fresh version.

### Model 1 — stamping introduced; actions-only payload model (reader floor: 0)

Manifest feature: `governed-model-stamps` (definition + instance, additive,
floor 0).

The `modelVersion` + `minReaderModel` pair is stamped on the definition and
instance doc types; the guard doc deliberately carries none (foreign lake
contract — see "The stamp pair"). The floor is 0: model-0 documents keep
reading exactly as before, and every engine from the amendment below onward
reads model-1 documents fine (the amendment's sanction — no readers or
writers existed outside this repo — is what made the pre-amendment window
irrelevant).

**Amended in place before any consumer existed** (a sanctioned exception to
rule 3 — model 1 had no readers or writers outside this repo when the
reshape landed, so the freeze point moved rather than minting a model 2):
actions became the only payload mechanism, and the persisted trees reshaped
accordingly. One caveat was weighed and accepted when the exception was
confirmed: released engines predating the amendment stamp model 1 while
writing the pre-amendment shapes, so documents they wrote pass the stamp
gate and then fail ungoverned (a raw shape error, not
`ModelVersionAheadError`). Those documents are declared disposable — every
dataset holding them is a this-repo test dataset and must be reset before a
post-amendment engine touches it. Nothing migrates them.

Definition tree (the stored authoring model):

- Activities carry no payload: `activation`, `ops`, `effects`,
  `completeWhen`, `failWhen`, `subworkflows`, and `kind` are gone from the
  activity tree. `target` survives as the off-system marker.
- Actions gained `when` (a cascade-fired trigger condition), `spawn` (the
  subworkflow block formerly on the activity), and `roles` (stored verbatim
  only on cascade-fired actions — the execute pin; fireAction actions still
  fold roles into `filter` at desugar).
- Transitions are pure edges: `{name, when, to}` plus presentation —
  `filter` renamed to `when`, `ops`/`effects` gone.

Instance tree:

- `effectsContext` renamed to `context` (entry `_type`s
  `effectsContext.<kind>` → `context.<kind>`); it now holds ONLY the
  start-time seed and a parent's spawn handoff. Completed effects' outputs
  live solely on `effectHistory[].outputs` (the `$effects` read derives from
  there).
- `ActivityEntry` statuses lost `pending` (entries are `active` from stage
  entry, or `skipped`) and gained `firedActions: string[]` — the per-visit
  ledger of cascade-fired actions.
- `SubworkflowEntry` gained required `action` (the spawning action's name;
  rows key per activity + action).
- History: the `activityActivated` variant is gone; `actionFired` gained
  `triggered?: true`; `opApplied` lost its `transition` origin key;
  `EffectOrigin.kind` is only ever `'action'`.

**Pre-adoption model-1 amendment: moved `applicableWhen` to `start.filter`,
added `start.kind` — a deliberate freeze bypass; no external consumers
exist.** Same sanction as the amendment above (rule 3 untouched, the freeze
point moves, no model 2 minted). The definition root gained an optional
`start` block: `kind` (`'interactive' | 'autonomous'`, stored explicitly —
desugar fills the default; the block itself stays absent on definitions that
never declared one, and an absent block reads as interactive with no filter)
and `filter` — the former `applicableWhen`, re-scoped from a pure
candidate-doc predicate to the start-filter context (`$tag` / `$definition` /
`$now` / `$fields` bound, `*[...]` reading the workflow dataset; the
`startFilterVars` vocabulary joins the ledger). `start.filter` is a READ-SIDE
visibility rule — evaluated by `definitionsForDocument`/applicability and the
Studio start control to decide what appears in Start lists; `startInstance`
never reads it and never throws on it. An earlier iteration of this amendment
added a `startFilterOverridden` instance-history variant (paired with a
throwing start-time gate and an `overrideStartFilter` verb arg); that gate was
removed before any consumer existed, so this same in-place amendment ALSO
removed the `startFilterOverridden` variant — no gate, no override, nothing to
audit. The instance tree is back to its pre-amendment history variants.
Would an old reader misread (rule 5)? No reader exists outside this repo —
which is the sanction; post-amendment engines read pre-amendment model-1
definitions fine (no `start` block ⇒ the defaults above). The released-engine
caveat above covers this amendment identically: definitions a released engine
wrote with `applicableWhen` stamp model 1 and then fail the strict parse
ungoverned — same disposition, those datasets are this-repo test data and are
reset, not migrated.

**Pre-adoption model-1 amendment: split `start.filter` into visibility +
permission — the definition root's `start` block gained `allowed`, and
`filter` tightened to browse-time-pure.** Same sanction as the amendments
above (rule 3 untouched, the freeze point moves, no model 2 minted; the
stored definition parse is strict, so even an additive `start` key would
fence out released readers — the sanction is what makes that acceptable).
The two keys answer different questions with different evaluation contexts:

- `filter` — visibility: "should a start surface offer this workflow for
  this document?" Browse-time-pure — candidate document as root,
  `$tag`/`$definition`/`$now` bound (`startFilterVars` in the ledger shrank
  accordingly), `*[...]` reading the workflow dataset — and any `$fields`
  read is deploy-rejected with a pointer to `allowed`: `$fields` cannot
  exist before inputs do, and an unbound `$fields` made permission-style
  filters pass vacuously (GROQ null matches no row, so a
  `count(...) == 0` dedupe rule surfaced a definition despite an open run).
  Evaluated by `definitionsForDocument`/applicability and start controls,
  exactly as before; `startInstance` still never reads it.
- `allowed` — permission: "given these concrete inputs, may a run start
  now?" (dedupe, WIP limits, overlap rules). Same context vars plus
  `$fields` (the caller's `initialFields` as GDR envelopes —
  `startAllowedVars` joins the ledger vocabulary), never a candidate root
  (deploy-rejected; the subject rides `$fields.<entry>.id`). `startInstance`
  ENFORCES it: declaring the expression is the opt-in, false or GROQ null
  throws `StartNotAllowedError` (kind `start-not-allowed`), no override arg.
  The `evaluateStart` verb pre-flights the same verdict as an
  insight-carrying read. Advisory under races like every engine-side check —
  the Content Lake stays the only enforcement point.

Would an old reader misread (rule 5)? No reader exists outside this repo —
the sanction. A post-amendment engine reads pre-amendment model-1
definitions fine: an absent `allowed` means no permission gate, and a
pre-amendment `$fields`-reading `filter` still evaluates with the read as
GROQ null (no surface binds `$fields` there anymore) — the rule is inert,
and whether the filter hides the definition (`defined()`-style reads fail
closed) or surfaces it vacuously (the count-dedupe shape above) depends on
its shape. Redeploying one fails validation until the expression moves to
`allowed`.
The released-engine caveat above covers this amendment identically: those
datasets are this-repo test data and are reset, not migrated.

### Model 2 — subject fields, scalar constraints, and action semantics (reader floor: 2)

Four additive growths — a new field kind and three optional facets — ship
together as model 2.

**The `subject` field kind.** An elevated single `doc.ref` (same GDR value
shape and validation, the `types` facet included) that names THE document a
workflow is about — workflow scope only, at most one, both deploy-enforced.
Both stamped trees grow the value:

- **Definition tree** — `fields[].type` admits `'subject'`, and a `subject`
  entry may carry `types` like `doc.ref` / `doc.refs`.
- **Instance tree** — resolved `fields[]` entries admit `_type: 'subject'`
  (the same arm shape as `doc.ref`, optional `types` included).

Manifest feature: `subject-field-kind` (definition + instance, additive,
detectable, floor 0).

Would an old reader misread the kind (rule 5)? No — it refuses loudly, never
silently: the definition document has no read-side content parse, and a
model-1 engine that loaded a subject-carrying **instance** would fail the
shape gate (the strict `fields[]` variant rejects the unknown discriminator
with `PersistedDocShapeError`) before interpreting anything — under the
document-specific floor derived below only fences it when another floor-bearing
feature (a choice list or scalar bounds) is also present. The subject kind
itself leaves the floor at 0.

One evaluation-semantics reconciliation rides the same change, declared
here under rule 5's judgment: the subject-entry rule (applicability's type
matching, the autonomous-start invariant, the root-read deploy check) now
keys on the `subject` kind, where it previously classified any required
`doc.ref` / `doc.refs` input as the subject. A stored pre-subject
definition still parses and runs everywhere, but no longer surfaces in
document pickers until redeployed with a `subject` entry — a deliberate
refuse-to-guess, not a misread.

**Typed scalar choice lists.** Definition value declarations and resolved
instance field entries gained an optional `options.list[]` tree. Each item
carries a display `title` and a typed scalar `value`; an absent `options`
retains the unconstrained behavior of every model-0/model-1 declaration and
instance entry.

Manifest feature: `typed-scalar-choice-lists` (definition + instance,
reader-floor, detectable, floor 2).

The field tree grows additively, and an absent `options` keeps every older
document's meaning unchanged. A document carrying `options.list` nevertheless
requires reader floor 2: an older engine would interpret the declaration as
unconstrained and could commit a value outside the list. That is semantic
misinterpretation, not a presentation downgrade. Writers of model 2 must
therefore deploy only after every engine reader has upgraded to model 2; the
floor makes an older reader fail explicitly instead of silently bypassing
the declaration. A model-2 definition or instance without a choice list retains
the floor derived from its other features (often 0). Resolved entries carry the
same optional tree so field writes remain self-validating. Full persists derive
from the complete post-state and preserve any higher stored floor.

**Action semantics.** Ordinary stored definition actions gained an optional
`semantics[]` bag whose initial closed vocabulary is `decision.accept` and
`decision.decline`. The values express advisory workflow meaning shared by
consumers; they change no execution, gate, transition, status, history, or
instance state. An absent `semantics` retains the generic behavior of every
older definition.

Manifest feature: `action-semantics` (definition, additive, detectable, floor
0).

Would an old reader misread (rule 5)? No. Definition content has no strict
read-side parse, and an engine predating the facet ignores the unknown optional
key, treating the action as generic. That loses advisory information but does
not change workflow execution. Definition documents are immutable after create,
so an old writer never rewrites and drops the array. The feature therefore
leaves the reader floor unchanged.

**Inclusive scalar bounds.** Workflow value declarations gained an optional
`validation` tree with finite `min` / `max` bounds. On `string` and `text`
declarations the bounds constrain character length and must be non-negative
integers; on `number` declarations they constrain the numeric value.

The same tree is available on action params, top-level fields, and nested field
shapes. Resolved instance field entries carry it so every later field write
validates against the declaration that created the instance. Definitions and
instances that omit `validation` retain their unconstrained behavior.

Manifest feature: `inclusive-scalar-bounds` (definition + instance,
reader-floor, detectable, floor 2).

The shape growth is additive, but a document carrying `validation` requires
reader floor 2. An older engine would preserve the unknown tree while
interpreting the value as unconstrained, and could therefore commit an
out-of-range value. That is semantic misinterpretation under rule 5, so older
readers must fail at the model gate. A model-2 definition or instance without
scalar bounds retains the floor derived from its other features (often 0).
Spread-based mutation copies preserve `validation` across every full persist;
the derived floor prevents older writers from reaching constrained model-2
instances.

### Model 3 — the `progress` field kind + effect claim tokens (reader floor: 2)

Two additive growths ship together as model 3 — model 2 was released (npm
`@sanity/workflow-engine@0.18.0`) before either landed, so they mint the next
version rather than amending a shipped one. Neither raises the reader floor;
the writer maximum stays 2.

**The `progress` field kind.** An elevated `number` (same stored numeric
value) carrying application-defined 0–100 completion, so surfaces can
identify and elevate it without guessing which number field means "how far
along". Every non-null value is finite and within 0–100 inclusive (fractions
allowed), enforced at every write boundary by the kind's one value schema.
Model 2's `validation` tree composes with it as NARROWING only: each declared
bound must itself sit within 0–100, gated at authoring. Both stamped trees
grow the value:

- **Definition tree** — `fields[].type` (and nested `FieldShape.type`)
  admits `'progress'`.
- **Instance tree** — resolved `fields[]` entries admit `_type: 'progress'`
  (the same arm shape as `number`).

Manifest feature: `progress-field-kind` (definition + instance, additive,
detectable, floor 0).

Would an old reader misread the kind (rule 5)? No — the same loud refusal as
the `subject` kind: an older engine (model 2 and below) that loaded a
progress-carrying instance fails the strict `fields[]` variant with
`PersistedDocShapeError` before interpreting anything, and cannot deploy or
evaluate a progress-declaring definition. No older code path can write a
progress field while skipping its bound, so there is no silent bypass to
fence — the kind leaves the floor at 0.

**Effect claim tokens.** `pendingEffects[].claim` grows an optional
`claimToken` — an opaque identifier minted fresh on every claim and
takeover. It is the exact-claim identity a mid-dispatch state report
(`commitEffectOps`) must present: `effectKey` cannot serve because a lease
takeover keeps the same key. A successful report also renews the claim's
`leaseExpiresAt` in the same commit.

Manifest feature: `effect-claim-tokens` (instance, additive, detectable,
floor 0).

Tolerant read: an older engine's claim parse admits unknown keys, so the
token rides through untouched and means nothing to it — older claim
semantics (presence + lease) are unchanged. Round-trip survival: full
persists derive from the complete loaded post-state, so an older writer
carries the token along; the claim-REPLACING writes (takeover, sweep
release, completion drain) discard it deliberately, which is the token's
own lifecycle — a report presenting a discarded token is rejected before
writing, failing closed. A claim without a token (older writer's takeover)
simply cannot authorise mid-dispatch reports; dispatch and completion are
unaffected.

### Model 4 — classified principal ids (reader floor: 4)

One namespace change ships as model 4, and it is the first UNCONDITIONAL
reader-floor raise — model 2's floor-bearing features were detectable,
fencing only the documents that carried them; this one fences every
instance the engine writes: **every principal id the engine writes into
live state is the account-global user id** (`sanityUserId` — the `g…`-prefixed identity
that is stable across projects and org-level resources). Model 3 was
released before it landed, so it mints the next version.

The platform has two identity namespace families: project datasets speak
per-project principal ids (lake `identity()` returns the project user id — a
different value per project for the same person), while org-level resources
(Canvas, Media Library) and the global API host speak the account-global id.
Documents written before this model carry whichever namespace their engine's
client host happened to resolve — for dataset-anchored workflows, the
workflow resource project's local ids. The id string itself carries its
namespace (`g…` global, `p-…` robot, `e-<globalId>` third-party project form,
`p…` project-scoped, `<anonymous>`/`<system>` sentinels) — the discrimination
Sanity's own session middleware applies; `src/core/identity.ts` is the one
classifier.

**What changes.** No field is added, removed, or renamed — the stamped trees
are shape-identical to model 3. The declared change is the namespace
semantics of the principal-id VALUES in live state (`Assignee` user items,
`Actor` stamps in field values, `completedBy`), plus the read/write discipline
around them:

- **Write boundary** — identity kinds admit global-namespace ids only:
  `g…` and `p-…` verbatim, `e-…` normalized to its embedded global id in the
  persisted output; plain project ids and unclassifiable forms are rejected
  with the remediation named. Every persisted id has passed classification —
  the `e-…` rewrite is the only spelling change.
- **Read funnel (the versioned upgrade step)** — the instance point-read
  resolves legacy project-scoped ids in live state to their global form
  through the project-users directory (`/projects/<id>/users/<ids>`, the
  sanctioned namespace bridge), ALL-OR-NOTHING per document: if any id
  cannot be resolved the document is read as stored (comparisons against
  those values fail closed, one loud warning). Because every commit persists
  the in-memory instance wholesale, a resolved document's next commit
  converges its stored spellings — normalize-on-rewrite IS this change's
  migration mechanism; there is no separate tooling and no bulk migration.
- **The anchor-scope invariant** — a bare project-scoped id in stored live
  state belongs to the workflow resource's own project (the document's home
  resource). This held by construction for every pre-model-4 writer
  (assignment surfaces loaded the anchor project's members; the actor
  resolved against the anchor host), and the read funnel resolves under it.
- **`history[]` and `effectHistory[]` stay verbatim forever** — append-only
  audit rows record who-acted-as-written; engine logic never compares
  history actor identity for decisions (topology and provenance reads only),
  and display resolves rows through the directory at presentation time.

**Why the floor rises (rule 5).** An older engine reading a model-4 instance
would not refuse it — it would MIS-COMPARE it: `$assigned` and the baked
claim gates are raw string equality, so a global-id assignee against an
older engine's project-scoped actor silently evaluates false (and the
mirror-image for legacy values under a new actor). Misinterpretation, not
parse failure — exactly the case the floor exists for. `minReaderModel: 4`
makes pre-classifier engines refuse the document loudly instead. The writer
baseline (`DATA_MODEL_MIN_READER`) rises to 4; deployment acknowledgements
follow the readers-first rollout (`docs/reader-model-rollout.md`).

Manifest feature: `classified-principal-ids` (instance, reader-floor,
**unconditional** — every instance this engine writes stamps actor identity
in the global namespace, so no instance persist can leave the floor below 4;
definitions carry no principal ids and are unaffected).

Round-trip survival: not applicable in the old-writer direction — the floor
raise means a pre-model-4 writer refuses the document before any write; the
one legal mixed state is old documents under new readers, which the read
funnel owns.

#### Model 4 also adds named polymorphic readiness requirements

Readiness becomes an ordered array of named nodes. `start.requirements`
accepts authored GROQ nodes and the declared `singleSubject` node;
`activity.requirements` becomes an array of named GROQ nodes. Each node may
carry editor-facing `title` and `description` metadata. The singular
`start.allowed` and the activity requirement record are removed.

- **Definition tree** — start and activity readiness use requirement arrays
  discriminated by `type`; names are unique within their owning array.
- **Instance definition snapshot** — the same definition tree is pinned into
  every new instance. Readers normalize legacy activity requirement maps in
  existing snapshots into named GROQ nodes before evaluation; newly persisted
  snapshots use only the array form.

Manifest feature: `readiness-requirements` (definition, reader-floor,
detectable, floor 4).

Model 4 is the default floor after this change, not a compatibility mode for
legacy deployed definitions. Deploy the model-4 definition set before running
the new reader; environments that retain incompatible earlier definitions
should follow the documented destructive reset (`nuke`) rollout path instead
of expecting those definitions to be normalized on read.

Would an old reader misread the field (rule 5)? Yes. An older engine ignores
the new arrays and therefore treats gated starts and activities as ready,
which changes the state-machine decisions it may commit. Missing arrays keep
their historical meaning (no requirements), but a present array requires a
model-4 reader. The writer floor is raised unconditionally to 4 because every
new instance embeds a model-4 definition snapshot and can later be evaluated
from that snapshot. Definitions are create-only and instance persists retain
unknown fields, so model-4 data survives round trips; the floor prevents an
older engine from interpreting it in the first place.

### Model 5 — the `dueDate` / `dueDatetime` field kinds (reader floor: 4)

One additive growth ships as model 5 — model 4 was released before it landed,
so it mints the next version rather than amending a shipped one. It does not
raise the reader floor; the writer maximum stays 4.

Two elevated scalar aliases mark THE due date for a level (workflow, stage, or
activity): `dueDate` aliases `date` (same stored `YYYY-MM-DD` value and
validation) and `dueDatetime` aliases `datetime` (same stored ISO-8601 value
and validation). The kind lets surfaces identify a level's deadline instead of
guessing which date field means "due". Both are optional; a deploy invariant
allows at most one due-\* (either kind, combined) per scope, so "the due date"
is never ambiguous. Both stamped trees grow the value:

- **Definition tree** — `fields[].type` admits `'dueDate'` and `'dueDatetime'`
  on a scope's own entries only. A due-\* nested in an `object`/`array`
  sub-field, or in an effect's `outputs`, is rejected at deploy: the kind names
  the deadline OF A LEVEL, and every deadline reader consults scope entries, so
  a nested one is dead configuration. Nested dates stay `date` / `datetime`.
  Existing `todoList` sugar is unaffected — its `dueDate` row column is a
  `date` named `dueDate`, not the kind.
- **Instance tree** — resolved `fields[]` entries admit `_type: 'dueDate'` and
  `_type: 'dueDatetime'` (the same arm shapes as `date` / `datetime`).

Manifest feature: `due-date-field-kinds` (definition + instance, additive,
detectable, floor 0).

Would an old reader misread the kinds (rule 5)? No — the same loud refusal as
the `subject` and `progress` kinds: an older engine (model 4 and below) that
loaded a due-date-carrying instance fails the strict `fields[]` variant with
`PersistedDocShapeError` before interpreting anything, and cannot deploy or
evaluate a due-date-declaring definition. The stored value is byte-identical to
its base `date` / `datetime`, so no older code path can write it while skipping
validation — there is no silent bypass to fence, and the kinds leave the floor
at 0.

### Model 6 — node semantics and field patch operations

#### Semantics at every definition level

The optional non-empty `semantics[]` field now appears on the workflow root,
stages, and activities as well as actions. Its engine-owned vocabulary adds
`signal.positive`, `signal.caution`, and `signal.critical` at every level;
`custom.<meaning>` is an open, grammar-validated namespace at every level.
Actions retain their action-only `decision.accept` and `decision.decline`
values. The values remain advisory and change no execution, gating, transition,
status, history, or instance state. An absent field retains the generic behavior
of older definitions.

Manifest feature: `node-semantics` (definition, additive, detectable, floor 0).

Would an old reader misread (rule 5)? No. Definition content has no strict
read-side parse, and an older engine ignores the optional fields and new
advisory values. Definition documents are immutable after creation, so an older
writer never rewrites and drops them. The feature itself remains readable by
model-0 engines; new writers still stamp the unconditional writer minimum of 4.
This uses the existing `semantics` slot and extends that same word and shape to
the remaining definition nodes; a sibling property would duplicate the
advisory-meaning mechanism and violate the definition language's
self-similarity rules.

#### Field patch operations

The stored definition grammar additively admits `field.inc`, `field.dec`, and
`field.setIfMissing` action ops. Instances may embed the same definition tree
in `definitionSnapshot`, and effect-completion use records the new discriminator
in `history[]` rows' `opType`. Missing discriminators retain the historical op
vocabulary, so documents written before model 6 need no normalization. A
`field.setIfMissing` whose target already has a value writes no `opApplied` row:
persisting a targeted no-op would make older provenance and feed readers report
a field write that never happened.

Manifest feature: `field-patch-ops` (definition + instance,
additive, detectable, floor 0).

Would an old reader misread these ops (rule 5)? No. An older engine strictly
parsing or deploying a definition document rejects the unknown discriminator.
The instance runtime is different: `definitionSnapshot` is decoded without a
definition-schema parse, so an older engine can reach `applyOp`; its exhaustive
switch has no matching arm and the commit aborts when the missing summary is
used to build the audit row. That is a loud runtime failure rather than silent
execution with different semantics. Definition documents are create-only,
instance persists preserve the opaque `definitionSnapshot` string, and history
readers already treat `opType` as an opaque audit label, so the discriminator
survives an old writer's round trip. Rule 5 fences silent misinterpretation,
not loud refusal, therefore this detectable feature contributes floor 0 and does
not raise the writer maximum. The floor does not protect these definitions from
older runtimes: upgrade every runtime that can process shared workflow data
before adopting the new ops.

Why could the existing definition vocabulary not carry the behavior (definition
language rule 8)? Incrementing requires a read-modify-write primitive, while
`ValueExpr` deliberately describes context-free reads and has no arithmetic.
The existing `field.set` cannot atomically derive its value from the current
number. Conditional initialization also has no existing field-op equivalent:
an action-level `when` gates every op and effect in the action, while
`initialValue` runs only when an entry is first resolved and cannot initialize a
value cleared later by `field.unset`. These additions are new values in the
existing `ops[].type` slot and reuse the established field target and
value-expression shapes. Their abbreviated names deliberately mirror
`@sanity/client`'s patch vocabulary (`setIfMissing`, `inc`, `dec`) as one trio;
definition authors who know Sanity patches can predict the workflow spellings.

### Model 7 — the `$attributes` condition variable (reader floor: 4)

One additive growth of the condition dialect ships as model 7. It does not
raise the reader floor; the writer maximum stays 4.

A new caller-bound synthetic variable `$attributes` binds the acting token's
org-level User Attributes (Enterprise) as a flat key → active-value record —
the same values lake role filters read via `user::attributes()`, spelled for
the workflow condition dialect. Soft-gate paths resolve it when a
caller-bound projection runs (`evaluate` / fireAction filter re-check /
editField) — project → organization → global-host attributes page with
`limit=100`, no further pages; warn when the envelope reports `hasMore` —
parallel to grants on those paths, not on every `resolveAccess`. It is never
persisted on `Actor` / history, and left unbound (`undefined`) when the fetch
is an expected absence (401/402/403/404 — non-Enterprise org, missing feature,
forbidden) so conditions that read it fail closed — the same posture as `$can`
without grants. Unexpected fetch failures (5xx, network) throw and are not
cached, so the next soft-gate call retries; ticks and drainers never call the
endpoint. Legal sites match `$can` (fireAction action filters, activity
requirements, editable predicates, and those commit re-checks); cascade gates
and other caller-free sites deploy-reject it.

Manifest feature: `attributes-condition-var` (definition condition dialect,
additive, unconditional, floor 0).

Would an old reader misread the var (rule 5)? No — an older engine never binds
`$attributes`, so a GROQ read is null / fail-closed rather than a silent
misinterpretation of persisted trees. Definitions that mention `$attributes`
still deploy and evaluate on older engines; gates that depend on it simply
never pass until the fleet reads model 7. No reader-floor raise.

**Author-predicate shadowing (model ≤6 → 7):** `attributes` joins the reserved
condition-var names, so a **new** predicate named `attributes` is
deploy-rejected. A definition already stored under model ≤6 that declared
`predicates.attributes` is a different story: on a model-7 engine that binds
the caller bag, `$attributes` in that definition flips from “the author
predicate” to “the synthetic User Attributes bag” with no redeploy. Likely
zero real instances; no migration. Authors who hit it rename the predicate
and redeploy.

### Model 8 — role-constrained assignment fields (reader floor: 8)

Assignment-valued field shapes may carry a non-empty `roles` list. The facet
limits newly written user assignees to project members who fulfil at least one
listed role, including the definition's role aliases. A collective role
assignee remains ownership rather than capability and is eligible only when
its literal role is listed. An absent facet preserves the historical
unconstrained meaning.

Freshly resolved values and singular replacements validate the complete
assignment. For plural and composite replacements, stale retention is
count-bounded per declared assignment location: a candidate may retain no more
occurrences of one assignment identity than the previous value held at that
location. Array indices are not part of the location, so removal and reordering
do not make surviving assignments new; an added copy exceeds the previous count
and must qualify. An `updateWhere` merge validates every assignment location
present in its incoming fragment strictly, so a fragment must omit rather than
restate a stale assignment. Each top-level engine verb uses one project-directory
snapshot across retries, cascade hops, and spawned children; a later verb reads
a fresh snapshot.

The property is valid on `assignee` and `assignees` wherever field shapes are
declared: scope fields, nested object/array shapes, and effect outputs. This
follows the definition language's existing facet vocabulary: as `types` says
which documents may occupy a reference slot, `roles` says which people or
collective roles may occupy an assignment slot. The existing vocabulary could
not carry this behavior because `editable` governs who may mutate a field,
while action `roles` governs who may act; neither describes eligible field
values.

Both stamped trees grow the property: definitions persist it on field shapes,
and instances copy it onto resolved assignment entries so later writes remain
self-describing. Model-6 and model-7 writers shipped without this behavior. An
older reader would preserve the unknown property but silently accept an
assignee the declaration excludes, so the facet is appended at model 8 rather
than backfilled into either shipped ledger.

Manifest feature: `role-constrained-assignment-fields` (definition + instance,
reader-floor, detectable, floor 8). A submitted definition set carrying the
facet requires acknowledgement 8; a set without it may retain acknowledgement 4. Documents without the facet retain the model-4 floor; only definitions and
instances whose canonical field tree carries a non-empty `roles` list stamp
floor 8.

### Model 9 — split guard ID spaces and singular assignment member lists (reader floor: 9)

#### Split guard ID spaces

A guard whose actions span more than one emitted ID space produces separate
temporary guard documents: direct create/delete actions preserve authored IDs,
content updates lock draft IDs, and publish/unpublish gates target published
IDs. The split prevents one match from applying every action to every ID, but
it also means retraction must reconstruct more than the historical base guard
ID. The definition and instance field trees do not grow; model 9 records the
new compatibility meaning of the existing guard action list, as required by
rule 4.

Manifest feature: `split-guard-id-spaces` (definition + instance,
reader-floor, detectable, floor 9). The stable marker is a guard whose actions
occupy at least two of the direct, edit, and lifecycle groups. Definitions and
instances without such a guard retain the floor derived from their other
features, normally model 4 or model 8.

Would an old reader misread (rule 5)? Yes. A pre-model-9 engine can read the
unchanged guard definition but only knows the base temporary-guard ID. If it
advances or aborts an instance after a model-9 engine emitted the sibling
document, it retracts the base and silently strands the sibling. That stale
advisory guard can keep an action locked after its stage exited. The instance's
embedded `definitionSnapshot` makes the feature detectable, so the commit that
can first deploy split guards stamps floor 9 before deployment; an older engine
then fails at the instance reader gate, and a concurrent old write loses its
revision compare-and-swap before it can retract anything. Full persists retain
the raise-only floor, so a newer engine cannot reopen the old-writer path.

Roll out readers first: upgrade every Studio, CLI, MCP server, Function, and
other engine runtime sharing the workflow resource, then raise the deployment's
reviewed `expectedMinReaderModel` literal to 9 before deploying a definition
with a split guard. Existing definitions and instances are safe to leave in
place: until a model-9 engine commits an affected instance, no split sibling
exists; that first commit establishes the floor before deploying one. The guard
document remains the unstamped foreign Content Lake shape—the compatibility
marker belongs to the engine-owned definition and instance trees.

The model-9 vocabulary ledger also records `document` beside `guard` and
`mutation` as a guard-predicate root. This pins the already-authored foreign
predicate dialect to the evaluator: `document.before` and `document.after`
must not disappear from a later reader while stored guard predicates still
reference them.

#### Singular assignment member lists

The singular `assignee` value becomes the same ordered user-or-role member
list as `assignees`, with one cardinality rule: it admits at most one user
member while role members do not consume the limit. This lets a singular slot
retain one or more routing roles while one person holds it. An empty value is
`[]`; append and remove-where ops apply to the list.

Like plural and composite assignment values, a singular replacement validates
new members against the current project directory while retaining already
stored members that have since left it. Taking or releasing routed work must
not become impossible merely because another retained member is now stale.

Readers permanently accept the model-8-and-earlier object/null representation
and normalize it to a zero-or-one-element list in memory. Writers partition by
the frozen definition snapshot's model stamp: instances pinned to definitions
below model 9 re-encode singular values as object/null for their whole lives,
while instances pinned to model-9 definitions write lists. A legacy instance
therefore never mixes representations, and no stored document is backfilled.
Redeploying is the opt-in migration for future instances; already-running
instances finish under their pinned definition model.

An older reader would interpret the list as an invalid singular value rather
than the assignment it represents, so this is a reader-floor change. The
definition tree gains no property: the existing `assignee` kind is the right
slot and its persisted value evolves. Definitions that declare that kind and
their instances require model 9. Definitions without it retain the highest
floor required by their other features, including the unconditional model-4
instance floor.

Manifest feature: `singular-assignee-lists` (definition + instance,
reader-floor, detectable, floor 9).

### Model 10 — required content-reference availability and bounded effect retry (reader floor: 10)

#### Required content-reference availability

A workflow-scope `subject`, `doc.ref`, or `doc.refs` field marked `required: true`
requires its selected targets to remain readable in the workflow's perspective
after initialization. Missing targets produce a derived fault and prevent normal
actions, triggered actions, and transitions from advancing. Abort and direct
field repair remain available. Other field kinds retain the input-presence
contract; optional references retain their authored runtime requirements.

This is an explicitly approved extension of the existing `required` contract.
It changes interpretation without changing stored field shapes. Existing
reference values and frozen definition snapshots remain readable without
normalization or backfill. The behavior applies when the upgraded engine reads
an existing instance as well as when it starts a new one. The same word and
shape carry requiredness; no parallel definition property is introduced.

Manifest feature: `required-content-references` (definition + instance,
reader-floor, detectable, floor 10). The marker is a workflow-scope required
content-reference declaration, including one in an instance's frozen definition
snapshot. New writes stamp model 10. Documents without this feature retain the
floor required by their other features, normally 4, 8, or 9.

Would an old reader misread (rule 5)? Yes. Older engines interpret `required`
only at initialization and can advance after a required target disappears.
Upgrade all runtimes sharing affected workflows before relying on this rule,
then acknowledge reader model 10 before deploying affected definitions. A new
engine's next full instance write raises the stored floor to 10. Existing
instances are not backfilled, so until that write the stored floor alone cannot
prevent an older runtime from advancing them; the readers-first rollout is
required for those existing workflows too. Unknown fields and frozen snapshots
survive full persists unchanged, and the floor remains raise-only.

#### Bounded effect retry policy

An effect node may declare `retry: {kind, attempts, backoff?: {kind, delayMs},
expiryMs?}`. The block's `kind` says who runs the policy, and `engine` is its
only member: the stored schema requires the discriminator and rejects any
other value, and an authored block may omit it because desugar fills `engine`
in, the same shape `start.kind` has. `attempts` is the total number of
attempts, the first included. `backoff.kind` is `fixed` or `exponential`, and
`delayMs` is the wait between two attempts: the same every time under `fixed`,
doubled per attempt already made under `exponential`. `expiryMs` decides
whether a further attempt may start rather than bounding the run, so an
attempt already running is never interrupted.

The accepted range is bounded on one side: `expiryMs` and the backoff a policy
accumulates are each capped at 366 days. The whole policy runs inside one
`drainEffects` invocation and no host offers a single execution longer than a
year, so a policy declaring more than that could never run as written wherever
it ran. The caps weigh declared waits alone, because a handler's
duration is unknown at deploy; at runtime every elapsed millisecond counts
against `expiryMs`, handler time included. This
is a tightening of the accepted values in a new field, not a reshape: no
previously valid stored tree becomes invalid, because nothing before model 10
could carry a `retry` block at all. Bounding the span also keeps every deadline
the engine stamps from it inside the range a timestamp can carry.

The discriminator is there from the start because who runs the policy is the
one thing about it that will vary, and a later member is then a new value in
this slot rather than a second mechanism beside it. A `caller` member — the
engine holding the claim and the expiry ceiling while surfacing each failure
to whoever called `drainEffects` — is a separate, additive change under its
own ticket.

This is a definition-tree addition only. The policy runs inside one
`drainEffects` call: the drain dispatches, waits the declared backoff on a
failure that has attempts left, renews the claim's lease across the wait, and
dispatches again, stopping when `attempts` are used up, or rather than start
a wait that would carry the run past `expiryMs`. Nothing about an attempt is
persisted, because nothing needs to survive the call — the run is one dispatch
as far as the instance is concerned, and it ends in the `effectCompleted` row
the engine already writes.
That row's `detail` names how the run ended: the attempts used and the last
error on a failure, or the attempt that succeeded when a later one did. No
instance field, history row, or vocabulary value is added or changed.

An absent `retry` preserves the model-9 meaning exactly: a failing handler
completes the effect as failed on its first attempt, and a claim abandoned by
a dead drainer is redispatched without limit under `effects.leaseMs`. That
recovery path is also unchanged for an effect that declares a policy — a
drainer that dies mid-run leaves a lapsed claim, the sweep releases it, and
the next drain starts a fresh run.

Why the existing vocabulary could not carry this (rule 8). The engine's only
retry control was `effects.leaseMs`, a runtime construction option and one
global number for every effect a deployment drains; it cannot say that a
payout gets five paced attempts and a notification gets one. The definition
could already express a retry LOOP — a counter field, an incrementing op, and
transitions reading `$effectStatus` — but that re-enters a stage and queues a
new effect entry each pass, which is a different thing: it retries the
workflow step, not the dispatch. This policy governs how one queued entry is
dispatched, and no existing slot speaks about a dispatch. `retry` is a new
value in the existing effect node rather than a sibling mechanism: it
introduces no error type, no ordering rule against an existing gate, and no
verdict leg. Its failure is the effect-failure outcome that already exists,
and its routing is the `$effectStatus` variable that already exists.

Would an old reader misread (rule 5)? Yes. A pre-model-10 engine reading a
definition preserves the unknown `retry` property and ignores it, so a handler
failure completes the effect on the first attempt: an author who declared five
attempts silently gets one, and the instance takes its failure branch four
attempts early. That is a silent wrong outcome rather than a refused read,
which is exactly what the floor exists for. Instances need no separate
judgment — the policy writes no instance shape a model-9 reader has not seen.

The marker is an effect node carrying `retry`, detectable in a definition
document's own tree and in an instance's embedded `definitionSnapshot`. An
instance derives the floor from its pinned definition, so an instance of a
policy-bearing definition is held to the same reader as the definition itself.
Definitions and instances without a `retry` effect retain the floor their
other features derive, normally model 4, 8 or 9, or model 10 through the
required-reference feature beside it.

Manifest feature: `effect-retry-policy` (definition + instance, reader-floor,
detectable, floor 10). The instance document type is listed because an
instance inherits its pinned definition's floor, not because the policy adds
an instance shape.

## Pending governed changes

- **`temp.system.guard` → `system.guard`** — the guard doc type's `temp.`
  prefix drops when the lake's own guard primitive ships (see
  `GUARD_DOC_TYPE` in `src/types/authorization.ts`). A breaking type change
  for already-persisted guard docs; it must land as a declared model change
  with a migration story, through this process.
