# Amelia Wattenberger: browser interface

Canonical page: https://pure-maple-xmr8.here.now/

This is an in-page, main-realm JavaScript API at `window.AmeliaGuide`. It is not an HTTP action endpoint, remote agent or MCP server. Reading Markdown does not execute actions. Open the HTML guide, require readiness and inspect the chosen region. Native inputs and API requests share the exact dispatcher.

## Exact invocation

```js
const api = window.AmeliaGuide;
const d = api.discover();
if (!d.ready) throw new Error('Page is not ready');
api.inspect({ targetId: 'amelia-lesson-spec' });
const request = {
  publicationId: d.publicationId, interfaceVersion: d.interfaceVersion,
  contentVersion: d.contentVersion, fixtureVersion: d.fixtureVersion,
  pageInstanceId: d.pageInstanceId, requestId: 'example.reset.1',
  expectedRevision: d.revision,
  target: { id: 'spec-reset' }, action: 'reset', args: {}
};
const { receipt } = api.act(request);
if (!receipt.ok) throw new Error(receipt.error.message);
const retained = api.wait({ pageInstanceId: d.pageInstanceId, requestId: request.requestId });
const replay = api.act(request); // Exact replay; do not alter this ID's envelope
api.inspect({ targetId: 'amelia-lesson-spec' });
api.diagnose();
```

For a new action, obtain the latest revision and use a fresh request ID. Never spread all of discover into a request. Query scoped controls with `api.query({within: 'amelia-lesson-spec', role: 'button', name: 'Reset lesson'})`. A root-level Reset lesson match is ambiguous.

## Methods and schemas

```json
{
  "discover": {
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "callingConvention": "No arguments",
    "returns": "Identity, ready, revision and targets including live layout, availability, values, focus and textarea selection."
  },
  "inspect": {
    "argsSchema": {
      "type": "object",
      "properties": {
        "targetId": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "returns": "Detached data.state, fixtures, controls, outputs, provenance and limitations; defaults to root."
  },
  "query": {
    "argsSchema": {
      "type": "object",
      "properties": {
        "within": {
          "type": "string"
        },
        "role": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "returns": "All exact case-sensitive control matches. within must be a registered region, not a CSS selector."
  },
  "act": {
    "argsSchema": {
      "type": "object",
      "properties": {
        "publicationId": {
          "const": "wattenberger-field-guide"
        },
        "interfaceVersion": {
          "const": "1.0.0"
        },
        "contentVersion": {
          "const": "1.0.0"
        },
        "fixtureVersion": {
          "const": "1.0.0"
        },
        "pageInstanceId": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,80}$"
        },
        "expectedRevision": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "target": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                }
              },
              "required": [
                "id"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "match": {
                  "type": "object",
                  "properties": {
                    "within": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "within",
                    "role",
                    "name"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "match"
              ],
              "additionalProperties": false
            }
          ]
        },
        "action": {
          "type": "string",
          "enum": [
            "set-goal",
            "set-requirement",
            "set-packet",
            "approve",
            "implement",
            "verify",
            "reset",
            "set-need",
            "set-view",
            "set-choice",
            "compare",
            "justify",
            "set-target",
            "set-operation",
            "preview",
            "apply",
            "undo",
            "focus"
          ]
        },
        "args": {
          "type": "object",
          "description": "Exact resolved control argsSchema; focus takes {}."
        }
      },
      "required": [
        "publicationId",
        "interfaceVersion",
        "contentVersion",
        "fixtureVersion",
        "pageInstanceId",
        "requestId",
        "expectedRevision",
        "target",
        "action",
        "args"
      ],
      "additionalProperties": false
    },
    "returns": "{replayed,receipt}; receipt includes ok, executed, result, error and revisions."
  },
  "wait": {
    "argsSchema": {
      "type": "object",
      "properties": {
        "pageInstanceId": {
          "type": "string"
        },
        "requestId": {
          "type": "string"
        }
      },
      "required": [
        "pageInstanceId",
        "requestId"
      ],
      "additionalProperties": false
    },
    "returns": "Retained receipt directly, not a wrapper. Synchronous, no job polling."
  },
  "diagnose": {
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "callingConvention": "No arguments",
    "returns": "healthy plus named DOM, receipt and lesson invariant checks. Not a security certification."
  }
}
```

## Complete control catalog

```json
[
  {
    "id": "spec-goal",
    "module": "spec",
    "role": "textbox",
    "name": "Design objective",
    "action": "set-goal",
    "event": "input",
    "field": "goal",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "maxLength": 600
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "set-goal",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-requirement",
    "module": "spec",
    "role": "combobox",
    "name": "Required interaction",
    "action": "set-requirement",
    "event": "change",
    "field": "requirement",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "keyboard",
            "pointer"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "set-requirement",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-packet",
    "module": "spec",
    "role": "combobox",
    "name": "Implementor packet",
    "action": "set-packet",
    "event": "change",
    "field": "packet",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "current",
            "stale"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "set-packet",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-approve",
    "module": "spec",
    "role": "button",
    "name": "Approve the local spec",
    "action": "approve",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "approve",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-implement",
    "module": "spec",
    "role": "button",
    "name": "Simulate implementor wave",
    "action": "implement",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "implement",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-verify",
    "module": "spec",
    "role": "button",
    "name": "Compare packet with spec",
    "action": "verify",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "verify",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "spec-reset",
    "module": "spec",
    "role": "button",
    "name": "Reset lesson",
    "action": "reset",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-spec",
    "supportedActions": [
      "reset",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-need",
    "module": "context",
    "role": "combobox",
    "name": "Design requirement",
    "action": "set-need",
    "event": "change",
    "field": "need",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "keyboard",
            "spatial",
            "both"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "set-need",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-view",
    "module": "context",
    "role": "combobox",
    "name": "Recommendation context",
    "action": "set-view",
    "event": "change",
    "field": "view",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "single",
            "matrix"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "set-view",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-choice",
    "module": "context",
    "role": "combobox",
    "name": "Candidate design",
    "action": "set-choice",
    "event": "change",
    "field": "choice",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "compact",
            "canvas",
            "hybrid"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "set-choice",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-compare",
    "module": "context",
    "role": "button",
    "name": "Inspect alternatives",
    "action": "compare",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "compare",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-justify",
    "module": "context",
    "role": "button",
    "name": "Check this selection",
    "action": "justify",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "justify",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "context-reset",
    "module": "context",
    "role": "button",
    "name": "Reset lesson",
    "action": "reset",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-context",
    "supportedActions": [
      "reset",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-target",
    "module": "brush",
    "role": "combobox",
    "name": "Selected design text",
    "action": "set-target",
    "event": "change",
    "field": "target",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "heading",
            "body"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "set-target",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-operation",
    "module": "brush",
    "role": "combobox",
    "name": "Text brush",
    "action": "set-operation",
    "event": "change",
    "field": "operation",
    "argsSchema": {
      "type": "object",
      "properties": {
        "value": {
          "type": "string",
          "enum": [
            "shorten",
            "question"
          ]
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "set-operation",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-preview",
    "module": "brush",
    "role": "button",
    "name": "Preview local edit",
    "action": "preview",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "preview",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-apply",
    "module": "brush",
    "role": "button",
    "name": "Apply preview",
    "action": "apply",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "apply",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-undo",
    "module": "brush",
    "role": "button",
    "name": "Undo last edit",
    "action": "undo",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "undo",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  },
  {
    "id": "brush-reset",
    "module": "brush",
    "role": "button",
    "name": "Reset lesson",
    "action": "reset",
    "event": "click",
    "argsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    },
    "parentId": "amelia-lesson-brush",
    "supportedActions": [
      "reset",
      "focus"
    ],
    "focusArgsSchema": {
      "type": "object",
      "properties": {},
      "required": [],
      "additionalProperties": false
    }
  }
]
```

## Regions and outputs

```json
{
  "modules": [
    {
      "id": "amelia-lesson-spec",
      "key": "spec",
      "name": "Keep implementation attached to a living spec",
      "sources": [
        "A01",
        "A02"
      ]
    },
    {
      "id": "amelia-lesson-context",
      "key": "context",
      "name": "Compare a recommendation with its neighbors",
      "sources": [
        "A03",
        "A02"
      ]
    },
    {
      "id": "amelia-lesson-brush",
      "key": "brush",
      "name": "Preview a bounded edit and reverse it",
      "sources": [
        "A04",
        "A05",
        "A06"
      ]
    }
  ],
  "outputs": [
    {
      "id": "spec-status",
      "module": "spec",
      "role": "status",
      "field": "status"
    },
    {
      "id": "spec-result",
      "module": "spec",
      "role": "log",
      "field": "result"
    },
    {
      "id": "context-status",
      "module": "context",
      "role": "status",
      "field": "status"
    },
    {
      "id": "context-result",
      "module": "context",
      "role": "log",
      "field": "result"
    },
    {
      "id": "brush-status",
      "module": "brush",
      "role": "status",
      "field": "status"
    },
    {
      "id": "brush-result",
      "module": "brush",
      "role": "log",
      "field": "result"
    }
  ]
}
```

## Receipts and recovery

Every admitted action advances revision once, even domain refusal and focus. Reset retains receipts. Reload clears state and receipts and creates a fresh pageInstanceId. Exact replay returns original receipt before stale revision checks.

The action result is `{replayed,receipt}`; wait returns the receipt directly. Check `receipt.ok` and `receipt.error`. A domain refusal can have `executed: true` and `ok: false`: the dispatcher ran, but the teaching outcome was refused. Transport refusals do not execute the reducer. There are no asynchronous jobs. Focus is a real DOM action, not a simulated field.

- `INVALID_REQUEST`: Use the exact plain JSON envelope or method arguments.
- `WRONG_PUBLICATION`: Use identity from this guide.
- `WRONG_INSTANCE`: Rediscover after reload.
- `VERSION_MISMATCH`: Use discovered versions and a new request ID.
- `REQUEST_ID_REUSE`: Never change an existing ID envelope; use a new ID.
- `REQUEST_LIMIT`: 4096 IDs retained with no eviction. Reload for a new ledger.
- `UNKNOWN_TARGET`: Discover registered exact targets.
- `AMBIGUOUS_TARGET`: Use an exact ID or narrower region. Reset lesson has three matches at root.
- `UNKNOWN_ACTION`: Use the selected control action or focus.
- `INVALID_ARGUMENTS`: Match the exact argsSchema, including enums and maximum length.
- `STALE_REVISION`: Inspect state, reconsider the action, and submit a new ID with the current revision.
- `CONTROL_UNAVAILABLE`: Read availability.reason and satisfy the prerequisite.
- `UNKNOWN_REQUEST`: Wait only for a retained request in this page instance.
- `DISPATCH_FAILED`: Inspect diagnostics and reload. No successful effect is claimed.
- `RENDER_FAILED`: State may already be committed; inspect before recovery. No rollback is claimed.
- `GOAL_REQUIRED`: Write a nonempty objective before approving.
- `SPEC_NOT_APPROVED`: Approve the current spec first.
- `PACKET_REQUIRED`: Simulate an implementor wave first.
- `SPEC_DRIFT`: Choose the current packet, simulate again and compare with the current spec.
- `CONTEXT_REQUIRED`: Inspect the full comparison matrix before checking the selection.
- `CAPABILITY_MISSING`: Choose a candidate with the required capabilities and inspect again.
- `NO_CHANGE`: Choose another text brush or undo.
- `PREVIEW_REQUIRED`: Preview the current target and brush before applying.
- `PREVIEW_STALE`: Preview the current document again.
- `UNDO_REQUIRED`: Apply an edit before undoing; undo is unavailable without a snapshot.

## Boundaries and cleanup

- Static fictional fixtures, not Intent, Copilot Labs or a language model.
- No network, shell, repository, asynchronous job, real agent, account, credential or real permission.
- Page-memory state only. Reload resets state and receipts; no persistence.
- Spec approval is a local simulation, not authenticated approval or security isolation.
- Alternative capabilities are authored fixture facts, not measured usability results. Text brushes are exact lookup transformations, not general rewriting.

Reset each lesson with its scoped Reset lesson control when finished. Reset does not clear the receipt ledger. Reload to clear the full page-memory session; discover the new identity before issuing more actions. No upstream tools are contacted or cleaned up.
