# Proposal (AIM 5.13) — State: the machine a record moves through is a facet

Status: **admitted in 5.13** (2026-10-21; specification §7.9, release A) — the wording below is updated where the admitted text differs: deletion from a final state, states named rather than addressed, moves kept on the node rather than as projection edges · Author: Michael & Claude working session, 2026-10-21 · Supersedes: `5.9-record-lifecycle.md` (its Options 1 and 2, in facet form) and the Amy working draft `aim/work/2026-10-21-aim-states-proposal.md` (its nested form; its probes become this proposal's acceptance tests) · Affects: §2.1, §3.6, §5.4, §7 (new §7.9, Summary Rule renumbered §7.10), §8.6, §11.3, §12.1, §12.2, §13, §15, §16 · Syntax: **one new facet heading, `## State: <Name>`; no new edge verb, no new schema-line grammar**

## The problem

Automation is state machines: who may move what, from which state, and what is final. AIM can say every piece of that except the machine itself.

A record's status is an enum (`status: enum(draft, development, testing, done)`). Every rule about how it changes lives in prose, on the operation that makes the change — `### Expects` *"Current status of the task is draft"*. So:

- **No reach.** An `Expects` binds only the operation that states it. An operation added later — in another intent, by another person, by an Architect that never read the first one — can move a done task back to draft, and nothing in the model says it may not.
- **No finality.** "Done is permanently closed" is a sentence. Nothing can refuse the write that reopens it.
- **No picture.** The graph holds four enum values and five operations, but not which moves exist. No chart can draw the task's life; the owner asked for exactly that chart and it could not be drawn.
- **A judgment where a bound belongs.** In the reference interpreter every state guard reaches the model as a judgment (`held: null, by: 'model'`). The engine bounds enums, required fields, `owner` scoping and the records an operation may write — from declarations. Which moves a status may make is a commitment of the same kind, and the only one it cannot bound, because the model has nowhere to declare it.

§8.6 has carried this as recorded pressure since 5.5. Two admission tests held it back: *demonstrated need* and *fully specified on arrival*. This proposal meets both.

## The evidence

**A real owner's model (2026-10-21).** The owner of a software agency defined how their clients and architects create tasks, in a forty-minute session with the Architect. Of their twenty decisions, the heart was a state machine:

| What they decided | In their words |
|---|---|
| The states | "ok task have statuses, draft, development, testing and done" |
| The start | "Always start as draft" |
| Who moves draft → development | "Both clients and architects" |
| Who moves development → testing | "Developers only" — then "Only the assigned developer" |
| Who moves testing → done | "Clients and architects" |
| The way back | "Can be sent back to development if testing fails" — "Feedback is mandatory" |
| The end | "Permanently closed" |
| Deleting | "Only draft tasks can be deleted by clients and architects" |

The Architect modelled it the only way 5.12 allows: five operations (`MoveTaskToDevelopment`, `MoveTaskToTesting`, `MoveTaskToDone`, `ReturnTaskToDevelopment`, `DeleteDraftTask`), each guarded by a prose `Expects`. The probes run on that model with the reference implementation found: the running app accepts done → draft and done → testing; a benchmark model with every state guard removed and done explicitly reopened still scores 10/10; and no projection can show the four states.

**The house models** carry the same machine as prose, every one of them (from the 5.9 proposal):

| Model | States | Lifecycle rules as prose |
|---|---|---|
| Expense Approval (process) | `submitted, approved, rejected, reimbursed` | "approved and not already reimbursed"; "only after approval" |
| Task Planner (app) | `open, done` | "The task is open." / "The task is done." |
| Lunch orders (app) | Round `open, closed` | "until the round is closed, not after" |
| Sales pipeline (app) | `lead, qualified, proposal, won, lost` | "starts as a lead" |
| Financial close (process) | the period | "locked only after executive approval" |

## The design

**A facet, not a sub-block.** Three shapes were on the table:

- A `### Lifecycle` block inside the Record (the 5.9 proposal's Option 1). It keeps the policy with its record, but a state then has no address of its own without extending sub-block addressing, and every edit tool that rewrites a Record must learn to carry it — the working draft's probes showed today's compiler and part-splicer silently dropping it.
- A facet per state (`## State: Testing`). Rejected: a state never stands alone — it is a value of one field of one record. As facets, a task's Done and a comment's Done would collide by name, and a state could drift from its record.
- **A facet per machine — chosen.** `## State: TaskStatus` is the whole machine of one enum field: its states and its moves. It uses the facet grammar every tool already reads (§3.6), it is addressable like every facet (`company.create_task.lifecycle#State:TaskStatus`), it can sit beside the operations that make its moves, and an edit tool carries it the way it carries a Style — as one part.

```markdown
## State: TaskStatus

### Summary

How a task moves from draft to done, and back from testing when it fails.

### Of

- `Record:Task.status`

### States

- Draft — initial
- Development
- Testing
- Done — final

### Moves

- Draft → Development — [Contract:MoveTaskToDevelopment]
- Development → Testing — [Contract:MoveTaskToTesting]
- Testing → Development — [Contract:ReturnTaskToDevelopment]
- Testing → Done — [Contract:MoveTaskToDone]
- Draft → deleted — [Contract:DeleteDraftTask]
```

### Grammar

- **`### Of`** — exactly one line: a backticked reference to a Record field, `Record:<Name>.<field>` or `<ns>#Record:<Name>.<field>`. The field must be a required, single-valued enum.
- **`### States`** — one bullet per enum value. The bullet's word is the state's name — a word inside the facet, not an address of its own (the facet is the node); it names the enum value it stands for case-insensitively, spaces read as underscores, so `Draft` is `draft`. When the display word and the value differ, the value follows in parentheses: `- In progress (in_progress)`. Exactly one state is marked `— initial`; any number `— final`. States and enum values correspond one to one.
- **`### Moves`** — one bullet per move: `<From> → <To> — <operations>`, where the operations are one or more bracketed references (`[Contract:X]`, `[Flow:Y]`, qualified as `[ns#Contract:X]`), comma-separated. `->` is accepted for `→`. The reserved target `deleted` declares where deletion may happen. A move is a **structured reference, not an edge** — the form a Trigger's schedule already uses for `after [Event:X]` (§7.7): it resolves and is checked, derives no inverse and needs no verb.
- `### Summary` is required (§7.10). No other sub-block in 5.13; unknown sub-blocks are a hard error.

### Meaning

The facet is the complete list of how its field may change. A field with no State facet keeps today's meaning: an enum, and nothing more is claimed about its moves.

| Situation | Rule |
|---|---|
| A write changes the field | The pair `(old state, new state)` must be a declared move, **and** the operation performing the write must be one the move names |
| Creation | A new record starts in the initial state, by any operation that creates it. Creation needs no move. |
| Deletion | When the facet declares `→ deleted` moves, a record may be deleted only from those states, by those operations. When it declares none, the facet says nothing about deletion. |
| A final state | No move leaves it, save a declared deletion — deletion is the record's end, not a move out of its state. Other fields may still change, and other records (a task's comments) are not frozen. |
| The same value before and after | Not a move; the operation's own rules govern the write. |
| Who may run the operation, its input, its guards | Unchanged: `### Authz`, `### Input`, `### Expects`, `### Ensures` on the operation. A legal move grants no permission. |

"Only the assigned developer moves a task to testing" stays where the owner's decision lives — on `MoveTaskToTesting`'s Authz and Expects. The facet says only that development → testing is a move and that this operation makes it. The two together are what a reader, a chart and an engine need.

### Scope and resolution

- A State facet lives in the intent that declares its Record or in any intent beneath it (§5). Its references resolve upward (§5.4), so a machine in a child intent `create_task.lifecycle` names `Record:Task.status` of its parent and the operations beside it.
- **One State facet per field**, across the whole model: a second machine for the same field is a hard error, since nothing could choose between them.
- A State facet is not an orphan (§12.2): like a Style, nothing points at it — it points at its record and its operations. It takes no part in the traceability chain (§11.3).
- On promotion of the Record (§16), the facet's `### Of` is rewritten with every other reference; on a move of an operation, its move references are rewritten like typed links.

### The graph

A State facet is a node of type `state`. The graph derives, never authors:

- `governs` — State → the Record it is `### Of` (structural);
- `moved-by` — State → each operation its moves name, carrying the move (structural);
- the moves stay on the node, each resolved to its operations and the roles their Authz admits — what a chart draws (admitted text: no projection edges in the graph).

None of these are verbs (§8.2) or inverse blocks: they are read from the facet's structure, exactly as `refs` are read from a schema. An impact query from a changed State facet reaches its record, its operations, and every other operation that `mutates` the record — a changed policy may invalidate an operation no move names yet.

### Diagnostics (§12)

Hard errors:

- `### Of` missing or not resolving to a required enum field;
- a state for no enum value, or an enum value with no state;
- no initial state, or more than one;
- a move whose endpoint is not one of the facet's states (or `deleted` as a target);
- a move out of a final state, other than to `deleted`;
- a move from a state to itself;
- a move operation that does not resolve, or does not `mutates` the record;
- the same move with the same operation twice;
- two State facets for one field;
- an unknown sub-block.

Informational:

- a state no move reaches (other than the initial one);
- a non-final state with no move out;
- an operation that `mutates` the record and appears in no move — it can change the record, but never the status;
- a facet with no moves at all.

## What it makes computable

- **A chart, exactly.** The States view draws each machine: the initial marker, the final marker, every move as an arrow with its operation and that operation's who (its Authz) on it — "Development → Testing · MoveTaskToTesting · Developer". The tree shows `TaskStatus` with its four states as rows; the Entities view shows `Task.status · 4 states`. No model call is needed to draw it.
- **A refusal, at run time.** An interpreter, or any realization that commits writes, refuses a write whose move is not declared or whose operation is not the move's: done → draft is refused before commit, from any operation, including ones not written yet.
- **Questions the model can answer.** What can follow Testing? Which operations can change a task's status? What does making Testing final affect?

## Delivery

**Release A — the language and the picture.** The specification text (§7.9 and the rest of the affected sections); the reference parser, compiler and validator; the diagnostics; the graph nodes and projection edges; the States view, the tree rows and the Entities indicator; the Architect's part shape for it (`states`), so an edit carries the facet whole and never drops it.

**Release B — enforcement.** The write boundary in the reference interpreter knows the performing operation and the before-state, and checks both in the same transaction as the write; every write path goes through it — operations, agentic plans, batch writes, imports. A model whose realization lacks the check is not described as enforced.

**The benchmark comes first.** The reference task-lifecycle benchmark (the owner's session above) gains its checks before either release lands, as advisory and then as gates:

- `L-MACHINE` (a gate at release A): a State facet over `Task.status` with the four states, Draft initial, Done final, the return from Testing to Development, and the moves naming their operations.
- `L-FINAL` (a gate at release B): reopening a done task is refused at run time.

## Compatibility

- Existing models stay valid and unchanged. An enum never acquires a machine by inference; a machine recovered from a realization (§17) is proposed with its provenance, never written without the owner's signature.
- A 5.12 reader meets `## State:` as an unknown facet type and reports it rather than dropping it silently. A writer emits State facets only for a model at `aim_version: 5.13` or later.
- The working draft's probes (`lifecycle-impact.mjs`, `current-behavior.mjs`, `policy-coherence.mjs`) become acceptance tests: a round trip that keeps the facet, a Record edit that keeps it, a moved operation whose reference follows, a change to the facet alone that the graph delta reports, and the policy matrix — every declared move passes, every other move is refused.

## Open questions

1. **The heading's name — decided: `State`** (the owner, 2026-10-21). `## State: TaskStatus` is the owner's word. `## Lifecycle: TaskStatus` reads as what the facet holds; `## Status: Task` as what the owner calls it. The proposal uses `State`; the decision is one line to change.
2. **Per-state rules.** "Editable in draft only" is a rule about a state, not a move. In 5.13 it stays a requirement and an operation's guard. A `— while` clause on a state (`- Draft — initial — editable by Client, Architect`) is recorded pressure for later.
3. **Two machines on one record** (`status` and `paymentStatus`): admitted — two facets, one per field — and checked independently. No combined states.

## Against §8.6

1. **A relational commitment?** Not a verb — a facet with structured references, which is where test 1 sends rules.
2. **Not expressible today?** The prose is. Reach, finality and the picture are not, and none can be checked.
3. **Pays rent?** A chart drawn exactly, hard diagnostics, and a run-time refusal — the strongest on the list.
4. **Demonstrated need?** A real owner's twenty decisions, and five house models.
5. **Fully specified on arrival?** This proposal. The open questions do not block release A.

## Decision needed

1. Admit the State facet in 5.13 as specified, with the heading's name decided (question 1).
2. Release A first, release B after it; the benchmark checks land before each.
