agentic-intent-model

Proposal (AIM 6.6) — a comparison between two fields, or a field and the clock

Status: written into the specification (AIM 6.6), 2026-11-15 — drafted 2026-11-15, revised the same day after two reviews (kept at the end; “What the revision changed” lists the changes); the eleven decisions accepted as drafted · Author: Michael & Claude working session · Would affect: §3 (Markdown restrictions: one new fence), §6.1 (Record: ### Constraints), §6.2 (Operation: ### Criteria, ### Expects, the write rule), §6.3 (Process: Criteria and Expects as on an Operation), §6.16 (Output: ### Constraints, one wording fix), §9 (impact set), §10 (diagnostics)

Where this comes from

After 6.5, all six example models under Amy’s examples/ (airline-operations, club, e-commerce, german-government, hotel-management, nasa) were read in full for commitments that only prose carries. One finding recurred in every one of them: a rule that compares two fields, or a field with the clock, cannot be written in a form a tool can check. The owner raised the same gap with a case of his own:

The clearest lines from the examples, with file and line (paths under examples/):

  1. Clock against a field. hotel-management/aim/hotel/stay/hotel.stay.aim:455: “FreeOfCharge — the guest cancels before the reservation’s free-cancellation deadline”. The Input is reservationId alone; the deadline is Reservation.cancellationDeadline (hotel.aim:116). The decision has no Criteria.
  2. Field against fields of another row. nasa/aim/nasa/jsc/mcc/telemetry/nasa.jsc.mcc.telemetry.aim:94: “Within — the value lies between the measurement’s low and high limits”. The Input is frameId alone.
  3. Computed outside the model. airline-operations/aim/airline/departure/airline.departure.aim:464: slotOffsetMinutes: integer optional label("Expected take-off against the slot, in minutes"), tested at line 485 (Cleared when slotOffsetMinutes between -5 and 10), while slotAt is stored at line 73. club/aim/tsv/aufnahme/tsv.aufnahme.aim:115 does the same with alter, tested at line 136 (Jugend when alter < 18), beside a stored geburtsdatum.
  4. Period counted from a field, no Trigger. german-government/aim/bundesregierung/legislation/secondpassage/bundesregierung.legislation.secondpassage.aim:76: “The request is within three weeks of bundesratDecisionReceivedOn”, and line 289: “lodges no objection within two weeks of objectionPeriodStartsOn”. That file holds no Trigger and no Criteria.
  5. Counting rule in a Summary. e-commerce/aim/shop/orders/shop.orders.aim:499: “The days count as the law counts them: from the day after the parcel arrived to the end of the fourteenth day”, beside 14 days after [shop.orders#Event:ParcelDelivered] (line 507). The Test at line 28 depends on it. NASA stores Mission.launchWindowCloses (nasa.esdmd.artemis3.aim:46) while its Trigger counts 3 hours after [CountdownStarted] (countdown.aim:331) and Launch expects “the window is open” (line 260).
  6. Derived values. hotel-management/aim/hotel/hotel.aim:124-126: “The departure is later than the arrival.”, “The nights are every date from the arrival to the day before the departure.”, “Free cancellation ends at 18:00 two days before the arrival.” invoicing/aim/invoicing/invoicing.aim:101: “totalAmount equals the sum of lineTotal across lines.”

The problem

Three places in 6.5 cause it.

Two further places bear on the neighbouring gaps (Part “Not in this proposal”):

6.4 left this open on purpose. 6.4-flow-constructs.md, Part 5: “Inputs are the operation’s Input fields. Nothing else in this version: a read Record names a kind of row, not a row, so Account.balance says nothing when the operation reads two accounts.” Under “What is deliberately not filled”: “Criteria over Record fields or Capability results: when an input can name a row.” And the line it drew: “no expressions beyond a comparison, no functions, nothing a parser cannot check against the schema.”

What is one problem and what is separate

Ways to close it

  Adds A tool could then Cost against §6.0 and the end of §7
Change nothing Nothing. Nothing new. Every precondition, every Constraint and every period counted from a date stays prose. The computed Input stays the only way. §6.16’s “where it is checked” still needs correcting.
A. A wider comparison, no arithmetic A field as the right side of a comparison; a field of the row a ref Input names; the clock. The same line in Criteria, Expects and Constraints. Reject unlike types; evaluate preconditions, row rules and decisions itself; name the line that refused; flag a rule when a field it names changes. Checkability is lost today (test 1). The problem shows in six models of six (test 2); A settles three of the cited cases fully (vacation, hotel cancellation, arrival before departure) and the others in part (“What the examples would then say”). Complete needs the points under “Decisions to confirm”. Does not cover sums, or periods unless the due date is a stored field.
B. A plus periods [field] + 3 weeks as an operand; a deadline anchored on a field; months and years; one counting rule. Show that the guard and the timer of one period agree; derive the e-commerce test dates. The heaviest semantics in the language. A counting rule must be opt-in, or 14 days after [Event] changes meaning. Evidence is strong for the anchor, thin for months and years (one line, hotel.stay.aim:115).
C. Derived fields A formula on a field: a total as the sum of its lines. Compute the value; nobody enters it. An expression language with aggregation, rounding and date functions. It moves AIM from outcomes to mechanics (§6.2: “states outcomes, not mechanics”). A large proposal of its own.

Recommended: A now. It is the only step that stays inside the line 6.4 drew, and it is the precondition 6.4 itself named: an Input declared ref(...) names exactly one row. The field-anchored deadline with its counting rule follows as its own proposal. Derived values stay prose.

Proposal (draft of A)

Part 1 — operands

A comparison is <left> <op> <right>, with the operators §6.2 already lists, or <operand> present / <operand> absent. What may stand on each side widens:

Every comparison names at least one field. 5 > 3 and now = now are errors.

The clock words keep every existing meaning. On the left, an Input field named now or today is that field, as it is today, and a tool says so; the clock is meant only where no such field exists. On the right, a bare now beside a datetime field, or today beside a date field, is not a valid literal today, so no valid 6.5 rule changes; beside an enum or a string it stays the literal it was.

Types. Both sides MUST be of one type.

An absent value. present and absent are always evaluated; they are how a rule asks. For any other comparison:

Part 2 — the three places

All three places exist in their promoted forms too (## Expects, ## Constraints, ## Criteria; §6.1, §6.3, §6.16), with the same grammar.

Criteria (§6.2, §6.3). The rule line stays <Outcome> when <comparison>[, <comparison>].... Its inputs are the operation’s Input fields and the rows its ref Inputs name.

FreeOfCharge when now < [reservationId.cancellationDeadline]
otherwise WithFee

Expects (§6.2, §6.3). ### Expects MAY hold one check fence, alone or beside bullets, with exactly one comparison per line; every line must hold. Operands are as in Criteria. A realization MUST refuse the operation when a line does not hold, before it performs anything, and says which line. It evaluates the check only after ### Authz and the ownership rules of §3 have passed, so a refusal never tells a caller about a row the caller may not read. The bullets are further preconditions, judged as today; a bullet that is written as a check line is replaced by it, not kept beside it.

### Input

```schema
mitarbeiterId: string required ref(firma#Mitarbeiter.id)
tageBeantragt: integer required min(1)
```

### Expects

```check
tageBeantragt <= [mitarbeiterId.tageUebrig]
```

### Ensures

- The days asked for are taken off the employee's days left — [mutates](aim:firma#Record:Mitarbeiter)

The Ensures line belongs to the example: the check alone compares, and only the write that takes the days off keeps a second request from using them again (Part 3).

On a Process the Expects check is evaluated when the case starts, before the first step. A Process runs for days and holds nothing in between; a value that must still hold at the moment of a write is guarded by the Operation that writes, or by the Record’s Constraints. A Process’s Criteria read rows and the clock when the decision is reached, after its steps.

Constraints (§6.1, §6.16). ### Constraints MAY hold one check fence, alone or beside bullets, one comparison per line. A block that holds only a fence is not empty. Operands are the fields of the Record itself, or of an Output’s Contains.

### Constraints

```check
departure > [arrival]
```

- The nights are every date from the arrival to the day before the departure.

Part 3 — rules

Part 4 — diagnostics

Hard error: an operand that is neither a literal of the other side’s type, a field of the place, a field reached through a ref or part Input, now or today; a literal on the left; a comparison that names no field; [<input>.<field>] where the Input is neither a ref(...) nor a part(...), where the ref target is not declared unique, or where the field is not in the referenced Record; two sides of unlike types; an ordering operator on a type that has no order; two ref fields compared that reference different targets; now beside anything but a datetime, today beside anything but a date; the clock in a Record’s Constraints (name the writing operation’s Expects); a check fence anywhere but Expects and Constraints; two check fences in one block; a check line with more than one comparison; a check line naming an outcome.

Informational: a rule that reads a row’s field while its operation declares neither reads nor mutates of that Record; a comparison whose two operands are the same operand (two different ref Inputs to one Record are not: [fromAccountId.currency] = [toAccountId.currency]); a check line no value can satisfy; today with no timezone in reach (ask which); an Input field named now or today in an operation whose rules use the word (say that the field is meant); an Expects check on an operation that mutates no Record the check reads (ask whether the value should be reserved).

What the examples would then say

Not in this proposal

Existing models stay valid

Every 6.5 file is valid, unchanged. A right side without brackets is a literal, as it was. Criteria over Input fields mean what they meant, also where an Input is named now or today (Part 1). A ref(...) whose target is not unique stays valid; only reading a field through it is refused. ### Expects and ### Constraints without a fence are prose, judged as before. Nothing is deprecated and nothing is migrated.

Decisions to confirm

The draft takes a position on each. All are the owner’s.

  1. A first, B as its own proposal, C not now.
  2. Brackets mark a field on the right side, are allowed on the left, and a literal never stands on the left. The alternative, a bare name that is read as a field when one exists, changes the meaning of existing rules where an enum value and a field share a name.
  3. One step through a ref Input, and through a part Input. The alternative, a path of any length, covers the telemetry case and makes “which row” harder to read.
  4. The fence is called check, lives inside Expects and Constraints (promoted forms included), at most one per block, exactly one comparison per line. The alternative is a sub-block of its own.
  5. An absent operand. Criteria: does not hold. Expects: not applied when the operation’s own optional Input is absent, refused when a field read from a row is absent. Constraints: not applied. present and absent always evaluated. The simpler alternative is that every absent operand in Expects refuses; it costs the “if given” reading of an optional Input.
  6. Constraints checks join the write rule of §6.2, on the resulting row, on create and update, not on delete. Prose Constraints stay judged, and the text says so.
  7. No clock in a Record’s Constraints; allowed in an Output’s. The alternative (second review) allows it on a Record and states that a row can age past its own rule, after which an unrelated change is refused.
  8. now and today as the two words for the clock, with an existing Input of that name winning. The alternative is a spelling no field can have, such as @now.
  9. A field is read only through a ref whose target is unique. New after review.
  10. An Expects check runs after Authz and ownership. New after review. The full order of checks is left out.
  11. On a Process, Expects is checked at case start and Criteria when the decision is reached. New after review.

What the revision changed

After the two reviews below, on the same day. The recommendation (A first, B on its own, C not now) is unchanged.

Review feedback (2026-11-15)

Overall assessment: Option A is well-scoped, well-evidenced, and stays cleanly inside 6.4’s design boundary. Deferring B (field-anchored deadlines, period offsets, counting rules) and C (derived formulas) keeps comparisons schema-checkable without smuggling calendar arithmetic or aggregation into the language, while fixing an existing contradiction in 6.5 (§3 holds parts to ### Constraints and §6.16 says rules in Constraints are “where it is checked”, while §6.2’s write rule omits Constraints).

Before writing A into the specification, eight execution and grammar edge cases should be resolved so two conforming realizations cannot follow the text and behave differently.

Execution & semantic gaps

  1. Record Constraints on the clock (now / today) create a lifecycle-brick trap (Decision 7). Under “Every write to a row MUST satisfy every line before it commits”, if Record: Reservation has arrival >= today in ### Constraints:
    • Booking on Monday for Friday succeeds (Friday >= Monday).
    • Checking out on Saturday mutates Reservation.status — and is refused because Friday >= Saturday is false. Every subsequent status transition, update, or (since mutates in §7 includes delete) deletion is bricked once the timestamp passes.
    • “Arrival must not be in the past when booked” is an ### Expects precondition on BookReservation, not a timeless row invariant. By contrast, an Output is never kept or later updated (§6.16), so a clock check on Output Constraints runs once at handover/acceptance and bricks nothing.
    • Recommendation: Either forbid now / today in Record ### Constraints (with a diagnostic directing the author to ### Expects on the creating operation) while allowing it in Criteria, Expects, and Output Constraints; or restrict Record Constraints explicitly to create and update (never delete) and warn strongly that any later update after the time passes will be refused.
  2. Absent operands in Expects when a referenced row’s field is optional (Decision 5).
    • On Record / Output Constraints, skipping a value comparison when an optional operand is absent matches SQL CHECK (closedAt >= [openedAt] passes while closedAt is absent).
    • On Expects with [<input>.<field>], Input required only requires <input> (the reference), not <field> on the target row. If Mission.windowClosesAt or Customer.creditLimit is optional and absent (null), skipping now < [missionId.windowClosesAt] or amount <= [customerId.creditLimit] silently passes the precondition.
    • Also, §6.2’s operator list already includes unary present and absent. [orderId.shippedAt] absent is a common precondition; Part 1 should keep unary <operand> present / <operand> absent explicitly, and those operators must never be skipped when the operand is absent.
    • Recommendation: Keep unary present / absent active everywhere; keep skip-on-absent for Constraints (and optional direct Input fields); and in Expects, refuse (or at minimum emit an informational diagnostic) when an unguarded value comparison reads an optional field on a referenced row [<input>.<field>] whose value is absent.
  3. Process (§6.3) Expects and Criteria timing vs. atomicity.
    • An Operation is atomic, so its Expects check and Ensures write can commit together.
    • A Process spans human steps, waits, and weeks; its Expects cannot hold a transaction lock until a step days later mutates a balance. And unlike 6.4 (where Criteria read immutable Input fields only), a Process’s Criteria can now read [<input>.<field>] and now, which change while the steps run.
    • Recommendation: State explicitly that on a Process: (a) Expects is evaluated when the case starts, before step 1, while write-time atomicity against concurrent cases belongs to the mutating Operation (or Record Constraints); and (b) Criteria is evaluated when the steps complete to reach the process’s decision, against the row values and clock at that moment.
  4. Check order & cross-owner probing in Expects. “A realization MUST refuse the operation when a line does not hold, before it performs anything, and says which line.” If Expects runs before Authz and row ownership (owner, !owner, cross-owner), an unauthorized caller can pass another actor’s mitarbeiterId and probe tageUebrig via the “says which line” refusal.
    • Recommendation: Fix the check order in §6.2: (1) Authz → (2) Input schema validity (required, types, min/max, ref existence, parts’ Constraints) & row ownership scope (§3) → (3) State Only in (§6.10) and Expects check → (4) Criteria / Ensures / Record Constraints & State Moves at commit.
  5. Record Constraints on partial updates and defaults. When an Operation creates a row or updates a subset of fields (e.g. updating arrival without rewriting departure), Constraints MUST be evaluated on the resulting post-write row (on create: after default(...) values in §3 are filled; on update: written fields merged over existing stored fields; on delete: not evaluated).

Grammar, types & diagnostics

  1. Operand, operator, and type boundaries (Part 1).
    • No literals on the left: Part 1 says “What may stand on each side widens: A literal, as today.” In 6.5 a literal cannot stand on the left. Because bare enum values and unquoted strings (open, Green) share the same token shape as bare left-hand field names, allowing literals on the left turns a misspelled field (typo = [status]) into a string literal comparison. Restrict <left> to: a local field (bare, or optionally [field]), [<input>.<field>], or now / today, and require at least one side to be a field (ruling out 5 > 3 and now = now).
    • Optional [field] brackets on the left: Since [turnaroundId.slotAt] uses brackets on the left and [arrival] uses brackets on the right, authors and tools will write [departure] > [arrival]. Accepting optional brackets on a local left-hand field (while requiring them on the right) avoids a needless syntax trap.
    • Reserve now and today: State that bare now and today always denote the clock (a field named today would be written [today], or warn on naming a field now / today). Note also that now compares absolute UTC instants against datetime (timezone-independent), whereas today requires a timezone — define runtime behavior for today when timezone is omitted (since missing timezone is informational, not a hard error).
    • Ordering operators (<, <=, >, >=, between): Restrict to integer / number / decimal, date, and datetime (hard error on boolean, enum, email, url, phone, file, ref, part, list, map). State explicitly that datetime values with different UTC offsets compare by instant (not ISO string order), and between applies to date and datetime as well as numbers.
    • “The same enum”: AIM has no nominal enum definitions — every enum(...) is inline on its field (§3). Define “the same enum” structurally as the same set of values.
    • Two ref(...) fields: Two ref fields targeting different Records (ref(team#Member.id) vs ref(shop#Product.id)) should be a type hard error even when both underlying scalars are string, whereas two refs to the same Record field (reviewerId != [ownerId]) compare as equal/unequal.
  2. Three wording/diagnostic fixes (Parts 2 & 4).
    • Contradiction in check line grammar (Part 2): “one comparison per line; the conditions of one line hold together, and every line must hold.” Since every line already holds together (AND), comma-joined conditions on a single line contradict “one comparison per line” and blur “says which line” on refusal. Make check strictly one comparison per line, with at most one check fence per Expects or Constraints block.
    • False-positive reads diagnostic (Part 4): “a rule that reads a row’s field while its operation declares no reads of that Record” will misfire on nearly every mutating operation (ApproveClaim, CancelReservation), which declare [mutates](aim:...) without a separate [reads](aim:...) (cf. “declared reads or mutates targets” in §3). Change to: “declares neither reads nor mutates of that Record”.
    • Self-comparison diagnostic (Part 4): “a comparison of a field with itself” must check operand identity, not <Record>.<field>, so [fromAccountId.currency] = [toAccountId.currency] (two distinct ref Inputs to Account) is not flagged.
  3. Promoted forms, parts, coexistence with prose, and evolution (§3, §6.1, §6.3, §6.16, §12).
    • Promoted forms: Include top-level ## Expects and ## Constraints alongside ### Expects and ### Constraints, and ensure ref(<intent>#<field>) (promoted Record entities, §3) works identically in [<input>.<field>].
    • Prose + check coexistence: Clarify that a check fence may stand alone (zero prose bullets, as in the vacation example; §6.16’s informational “an Output with no Constraints and no Ensures” must treat a check-only Constraints block as non-empty) or beside prose bullets, and that unlike ### Decides + ### Criteria, prose bullets in Expects and Constraints are additive — authors replace a prose bullet when encoding it in check rather than keeping both.
    • part(...) Inputs (Decision 3): Keep ref traversal to 1 hop, and consider also allowing [<input>.<field>] when <input> is part(<Record>) (an in-hand single value with no join or multi-row ambiguity).
    • Preservation & transforms (§3, §12): Add Criteria and check fences to Preservation of meaning in §3 (6.4 omitted Criteria there), and state in §12 that renaming a Record or Input field rewrites [<field>] and [<input>.<field>].

Summary recommendations on Decisions 1–8

# Draft position Review recommendation
1 A first, B as its own proposal, C not now Confirm.
2 Brackets mark a field on the right ([tageUebrig]) Confirm, plus disallow literals on the left and allow optional [field] brackets on the left.
3 One step through a ref Input ([<input>.<field>]) Confirm 1-hop ref limit; optionally allow [<input>.<field>] on part(<Record>) Inputs too.
4 Fence named check inside Expects and Constraints Confirm (including promoted ## Expects / ## Constraints), at most one fence per block, strictly one comparison per line.
5 Absent operand: fails in Criteria, not applied in check Revise for Expects: keep unary present/absent active; keep skip-on-absent for Constraints and optional Input fields; refuse (or warn) when [<input>.<field>] is absent in an Expects value comparison.
6 Constraints checks join §6.2’s write rule; prose stays judged Confirm, evaluated on the post-write merged row (after default(...) on create) on create and update only, never on delete.
7 A Constraint on the clock is allowed Reconsider for Records: allow on Output Constraints, Expects, and Criteria, but forbid on Record Constraints (pointing to Expects) to avoid bricking later lifecycle updates.
8 now and today as the two words for the clock Confirm, reserving bare now/today and defining today’s fallback/gate when timezone is absent.

Codex review feedback (2026-11-15)

A is a worthwhile next step, but this draft should be revised before adoption as AIM 6.6. It addresses a real gap, fits the existing facets, and sensibly separates comparisons from timers and derived values. This is additional review feedback, not an amendment to the draft or a resolution of the decisions above.

The main issues are semantic rather than syntactic:

  1. Skipping absent operands can bypass preconditions (Decision 5). The proposed absence rule lets an Expects check disappear when a compared value is missing. required does not fully solve this: a field can legitimately be optional generally but necessary for one operation. At minimum, Expects should refuse when a comparison needs an absent value. Also define present and absent separately; those predicates must still run when their operand is absent.

  2. A ref(...) does not yet establish an unambiguous lookup (Part 1). The operand definition assumes a reference names exactly one row. However, §3’s generic reference rules do not require the target field to be unique; the map-key rules explicitly do. If several employees share a referenced value, whose balance is read? Require dereferenced references to identify exactly one row, preferably through a declared unique key. Apply this restriction to the new dereferencing construct without invalidating existing references.

  3. The concurrency guarantee exceeds what the comparison establishes (Part 3). “A check and the write … commit together” is insufficient to guarantee that two vacation requests cannot consume the same balance. Even sequential requests can both pass if each merely creates a request and leaves the balance unchanged. The example needs a commitment to reserve or debit the allowance in the same atomic action. Concurrent evaluation must also protect the values read, rather than merely group the check and write together. Distinguish this from a Process’s entry precondition: a long-running Process cannot hold one transaction throughout its work.

  4. Bare clock names undermine the compatibility claim (Part 1, Decision 8). now and today can already be Input names or literal enum values. For example, an Input named now with type datetime makes now < [reservationId.cancellationDeadline] ambiguous. Amy’s current Criteria evaluator was checked and accepts both a now Input and a today enum literal. Choose distinguishable clock syntax or specify resolution that preserves every existing interpretation. This differs from the earlier review’s recommendation to reserve bare now and today: reservation must not silently reinterpret existing rules.

  5. Evaluation needs a more complete contract (Parts 1 and 2). The type rules and Constraints rules leave several implementation choices open:
    • Validate an update against the complete resulting row, including unchanged fields.
    • Use a consistent set of row values and one clock sample per evaluation.
    • Define equality and ordering for each supported type, including exact decimal comparisons and datetime comparisons by instant.
    • Define what “the same enum” means; AIM currently declares enums inline.
    • Cover unary present/absent explicitly; they do not fit <left> <op> <right>.

    These can remain compact rules. They should not be left to each realization.

  6. The telemetry example needs a relationship check. The example discussion says the existing model needs another step through a reference. In fact, TelemetryFrame.measurement is plain text, not a reference to Limit. Adding limitId also requires checking that the supplied limit belongs to the frame’s measurement:

    [frameId.measurement] = [limitId.measurement]
    

    Otherwise, the numeric comparison could use an unrelated measurement’s limits.

The graph approach is appropriate: structured dependencies need no new behavioral verb. However, the dependency rule should also cover preservation and transforms (§3, §12). Renaming a referenced field must rewrite comparison operands, and parse/serialize cycles must preserve every check. Flagging affected rules alone is insufficient.

Two broader judgments:

The strongest justification for A is the vacation precondition, hotel cancellation decision, and arrival/departure constraint. The six-model survey supports the wider problem; it should not imply that A resolves all six models’ gaps.