The Intent Model

Replacing prose requirements documents with a typed JSON contract before writing code.

EssayJuly 20269 min read

Hand a prose requirements document to five developers—or five coding agent sessions—and you will get five different applications. Every one of them can be defended against the text, because prose can describe a system at length while leaving its state transitions and edge cases unspecified.

On a vehicle booking system for port logistics, our project started with a 12-page business requirements document (BRD) and expanded into a 32-page specification as scope hardened. Underneath the prose sat three overlapping state machines: shipment tracking, slot booking, and pickup execution. To prevent product and engineering from drifting apart, I now encode every enterprise build into a single structured JSON contract before writing application code: the intent model. As that port logistics build scaled from 10 initial rules to 38 business rules, 17 entities, 13 user journeys, and 4 actors, the intent model served as the single source of truth for both the team and our coding agents.

Compressing the BRD into six typed sections

Before designing screens or generating code, I compress the client’s requirements document into a single typed schema containing six sections: actors, entities, journeys, business_rules, constraints, and open_questions. None of these primitives are new in isolation: Domain-Driven Design (DDD) defines entities and invariants, use-case modelling defines actors and journeys, and requirements engineering defines constraints. Combining all six into one machine-validated file ensures that downstream code, tests, and UI flows derive from the contract rather than re-interpreting prose.

Compressing prose into a strict schema exposes contradictions early. On the port logistics project, the client’s BRD listed five actors, including "Gatehouse". When we mapped each actor’s step-by-step journeys, we found that Gatehouse had no independent credentials or permissions—internal operations staff operated that screen view with the visiting truck driver as the subject. We removed Gatehouse from actors[] and modelled it as an operational screen view instead.

A deeper ambiguity sat inside the HBL (House Bill of Lading, the document governing a shipment). An HBL actually progresses through two independent lifecycles simultaneously:

  1. Physical container location: on_vessel → at_wharf → in_yard → unpacked → collected
  2. Collection custody: unassigned → assigned → delegated → booked

Both states are active at the same time on the same HBL record, whereas the client’s prose document blended them into a single status list. Separating the two state machines required three working sessions with the client; once resolved, the schema locked that behavior permanently:

{
  "name": "HBL",
  "key_fields": [
    { "name": "hbl_number", "type": "id", "required": true },
    { "name": "customs_status", "type": "enum", "enum_values": ["held", "cleared"] }
  ],
  "lifecycle_states": ["on_vessel", "at_wharf", "in_yard", "unpacked", "collected"],
  "state_machine": {
    "transitions": [
      {
        "from": "unpacked",
        "to": "collected",
        "trigger": "driver_pickup",
        "guard": "customs_status == cleared"
      }
    ]
  }
}

The guard expression (customs_status == cleared) turns a sentence buried in paragraph four of a Word document into an executable constraint. Every screen mounting a pickup action disables the button until customs_status == cleared, generated integration tests assert that transition guard directly, and future agent sessions never have to infer the rule from prose.

Stateless sessions and under-specification

In Christopher Nolan’s Memento, Leonard cannot form new long-term memories, so he runs his investigation using Polaroids, handwritten notes, and tattoos. The system fails him because he writes his notes after the fact, under stress, with no surrounding context—and eventually edits his own notes to steer his future self toward a convenient conclusion.

Every LLM coding session starts with the same stateless condition. It has no memory of yesterday’s architectural conversation, and whenever a requirement is left unstated, the model fills the gap with the most statistically common pattern in its training data. What teams often call “hallucination” in software builds is usually under-specification: leave a domain rule blank, and the model supplies the internet’s average app behavior.

The intent model corrects for statelessness in two ways:

  1. Upfront capture with stakeholders: Rules and state transitions are locked while the domain experts are in the room to clarify that delegated and booked are separate states, rather than reconstructed weeks later from meeting notes.
  2. Automated schema validation on every commit: Unlike handwritten notes that can contradict each other silently, the intent model runs through a schema and referential-integrity check in CI on every commit, recording every change in a versioned changelog.

Why JSON + EARS syntax stops specification drift

Prose allows authors to hedge; a typed JSON schema forces a decision before a coding agent ever reads the file. A prose specification can state that a concurrent edit “should generally defer to the server” and move on. A JSON schema requires selecting one enum value from last_write_wins | server_wins | prompt_user | merge—there is no enum value for "generally". In addition, coding agents are far less likely to rewrite a strict JSON file unprompted during a session than a prose Markdown file.

For business_rules[], we use EARS (Easy Approach to Requirements Syntax), a structured notation developed at Rolls-Royce for jet-engine control specifications. Every rule must conform to one of five templates:

PatternTemplate
Event-drivenWHEN [event] THE SYSTEM SHALL [behavior]
State-drivenWHILE [state] THE SYSTEM SHALL [behavior]
Unwanted behaviorIF [condition] THEN THE SYSTEM SHALL [behavior]
Optional featureWHERE [feature enabled] THE SYSTEM SHALL [behavior]
UbiquitousTHE SYSTEM SHALL [behavior]

If a rule cannot be written in one of these five templates, the product team has not actually decided how the feature works yet. Instead of letting a developer or coding agent guess, the item is added to open_questions[] with an ID and blocking reference until a human answers it. When I audited roughly thirty published requirements frameworks, only five included a dedicated slot for undecided questions.

In October, while building ntent, we ran a 90-run controlled experiment to test whether the JSON format itself prevented agent errors or whether the explicit open_questions[] ledger was the active mechanism. We gave coding agents a client brief containing 20 stated facts and 10 unstated gaps, comparing plain prose against our structured intent model:

Wrapping text in JSON braces does nothing by itself. Explicitly separating confirmed facts from proposed inferences and open questions is what stops both humans and coding agents from guessing across silent gaps.

Operational contracts for enterprise SLAs

On our second project—an enterprise mobile mail, calendar, and contacts suite carrying a 99% crash-free SLA and a 2-hour severity-1 response window—we extended the intent model to cover client-side failure and offline recovery semantics.

Every user mutation in the mobile suite declares its optimistic UI behavior, its rollback behavior on network failure, and its conflict-resolution policy:

{
  "id": "archive_thread",
  "applies_to": "mail_thread",
  "trigger": "swipe_left",
  "optimistic_behavior": {
    "action": "remove_from_active_list",
    "feedback": "trigger_light_haptic_and_show_toast"
  },
  "rollback_behavior": {
    "action": "restore_to_original_index",
    "feedback": "show_error_toast_with_retry"
  },
  "conflict_resolution": "last_write_wins",
  "offline_queueable": true
}

Keeping "trigger": "swipe_left" in a single shared mutation contract paid off as soon as gestures changed. Early in the project, archive_thread triggered on swipe_right. When we introduced two-way swipe gestures on inbox rows (swipe_right for destructive delete, swipe_left for archive), updating that single field in the contract propagated the change across every list view and its test suite simultaneously.

Every screen in the mobile suite must also declare its empty, loading, and error states (plus a stale state for offline-cached views) in the model before the screen component can be generated, and every client requirement sits in a triage ledger so scope audits can verify that nothing was dropped silently.

Comparing greenfield and brownfield deployments

Using the intent model across both the greenfield port logistics system and the brownfield enterprise mail suite highlighted how the model adapts to different architectures:

DimensionPort logistics booking systemEnterprise mail suite
Primary roleAlign client and delivery team before and during buildDrive and audit multi-domain mobile code against a legacy server
File structureSingle unified JSON modelPartitioned across domain JSON modules (~3 MB total)
Schema contentsActors, entities, journeys, business rules, open questionsScreens, entities, optimistic/rollback mutations, EARS rules, tenant capabilities, open questions
VerificationStakeholder sign-off in a custom web review appAutomated CI lint and provenance checks on every commit
Post-launch roleReconciles against the built frontend via drift reportsPermanent live ledger; generated files carry provenance headers

On the booking system, we built a lightweight web review interface on top of the JSON file where client stakeholders approved or disputed rules section by section. In a single 42-minute review call with the project PM, stepping through open_questions[] resolved 20 undecided items down to 1; an asynchronous pass resolved 21 more. Later, running our drift reconciliation script against the built frontend caught an early prototype bug where three hardcoded sample shipment IDs were being used to determine HBL hierarchy levels in production.

On the enterprise mail suite, loading a 3 MB monolithic JSON file into every coding session would overflow the context window and mix unrelated domain rules. We partitioned the model into domain modules (mail, calendar, contacts, auth, settings, admin) around a shared core. A coding session working on email compose loads only shared.json, mail.json, and patterns.json, skipping calendar and admin rules entirely. (I cover the architectural trade-offs between these two setups in What Actually Goes In a Spec.)

Two schema upgrades required by brownfield scale

Running the intent model across thousands of commits on a brownfield codebase forced two upgrades to our initial schema:

1. Two-axis state (presence × intent)

A single status: implemented | proposed field breaks on brownfield systems, where an existing production feature may need to be modified or removed. Flattening “does this exist today?” and “what are we doing to it?” into one field made it impossible to distinguish legacy behavior from target behavior. We replaced status with two orthogonal fields on every rule and entity:

presence : implemented | absent
intent   : keep | add | modify | remove

Whenever an item has presence: implemented paired with intent: modify or intent: remove, the CI schema check requires a linked data-migration open question before the commit can pass.

2. Four-tier source provenance

If coding agents are allowed to edit the specification without citing ground truth, they will occasionally write plausible-sounding server rules that do not match the actual backend. An October audit of AI-assisted spec commits on the mail suite found that roughly a third of the edits had inferred server behavior rather than verifying it. We locked a strict four-tier source hierarchy enforced by CI:

  1. Server and API source code (ground truth): What the deployed backend accepts and returns wins every disagreement.
  2. Reference web client baseline: Where server code is silent on client assembly, the shipping web application is the baseline.
  3. The intent model (falsifiable ledger): Every rule in the model must cite an exact file and line number in Tier 1 or Tier 2, or be marked open.
  4. Jira tickets (investigation prompts): A ticket is a request to inspect the code and update the ledger, never proof that the system works that way.

Code generation and design token alignment

Once the intent model is locked, our toolchain generates Zod validation schemas for every entity, typed API client stubs, SQL migrations, screen scaffolds, TanStack Query mutation hooks, and a filtered handoff specification for designers. XState state-machine skeletons are generated once and maintained by hand afterward so edge-case refinements are never overwritten. On the port logistics project, we even inverted the client documentation flow: we now generate the human-readable Word BRD directly from the JSON intent model so the prose document and codebase never drift apart.

Visual styling follows the same single-source principle through design tokens:

TweakCN theme editor
  └─ base.css               every color, radius, and spacing token
      ├─ component registry ──→ generated screens
      └─ Figma (same tokens) ──→ visual layout refinement only

Combining the intent model (behavior and rules), the token system (visual appearance), and commit-time provenance linting boxes coding sessions in on three sides. A coding agent can still make a mistake, but it cannot make a silent one.

What will age out—and what won’t

Some of this scaffolding compensates for current LLM limitations: stateless sessions and the tendency to fill unstated gaps with statistical averages. As context windows and cross-session memory improve, future models may ingest a 32-page prose brief, cross-check the legacy server repository automatically, and flag all 20 contradictions before writing code.

The part of the workflow that will not age out was never built for the AI. Those open questions in the port logistics system and the 175 open questions tracked across the mail suite were product decisions that no human on the team had made yet. When a stakeholder asks six months into a build why truck drivers cannot see slot pricing, or why swiping right deletes a thread instead of archiving it, the answer comes back in seconds with a rule ID, a source citation, a version, and a date. Getting five people across time zones to agree on how a system works—and writing it down unambiguously at the start—remains the real job.

All notes