# Browser interface: Geoffrey Litt

This is the real main-realm browser API `window.GeoffreyLittGuide`. It operates only the three local teaching fixtures on the main HTML page. Static JSON describes the API, not live state. No remote agent, HTTP action endpoint, MCP server, background job or credential exchange exists.

## Read and locate

- `discover()`: no arguments. Returns identity, revision, ready, targets, limitations and receipt capacity.
- `inspect({targetId?})`: exact optional target ID. Module state is at `data.state`.
- `query({within?,role?,name?})`: exact string filters over controls. Use the module region to disambiguate names.
- `diagnose()`: no arguments. Checks registered DOM IDs, binding, availability and lesson invariants. It is not a security or accessibility certification.

## Operate and settle

`act(request)` returns `{replayed, receipt}`. Actions are synchronous. `wait({pageInstanceId,requestId})` returns the retained receipt directly. Receipts distinguish `executed` from `ok`: a domain refusal can execute a reducer without achieving the lesson outcome. Inspect exact error codes, result, beforeRevision and afterRevision.

Every control also supports `focus` with empty args. Inspect exposes actual browser layout, visibility, focus and textarea selection. Focus can increment the revision without changing a fixture. Native buttons, selects and textareas call the same dispatcher.

## Exact main-realm example

```js
const api = window.GeoffreyLittGuide;
const d = api.discover();
if (!d.ready) throw new Error('Guide is not ready');
const identity = { publicationId: d.publicationId, interfaceVersion: d.interfaceVersion,
  contentVersion: d.contentVersion, fixtureVersion: d.fixtureVersion, pageInstanceId: d.pageInstanceId };
const current = api.inspect({ targetId: 'geoffrey-enrich' });
const request = { ...identity, requestId: 'example.reset.1', expectedRevision: current.revision,
  target: { id: 'enrich-reset' }, action: 'reset', args: {} };
const { replayed, receipt } = api.act(request);
const settled = api.wait({ pageInstanceId: identity.pageInstanceId, requestId: request.requestId });
// settled is the receipt directly, not { receipt }. Inspect receipt.ok and receipt.error.
api.inspect({ targetId: 'geoffrey-enrich' });
```

Use a fresh request ID for each new operation. Repeating the exact request is an idempotent replay, including after a lesson reset. Altered reuse is refused. The ledger retains up to 4096 IDs without eviction. An exact replay returns the earlier receipt, not a fresh action or the latest state.

## Action envelope schema

```json
{
  "type": "object",
  "required": [
    "publicationId",
    "interfaceVersion",
    "contentVersion",
    "fixtureVersion",
    "pageInstanceId",
    "requestId",
    "expectedRevision",
    "target",
    "action",
    "args"
  ],
  "additionalProperties": false,
  "properties": {
    "publicationId": {
      "const": "geoffreylitt-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
    },
    "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"
    },
    "args": {
      "type": "object"
    }
  }
}
```

## Control catalog and argument schemas

### enrich-note

Module: enrich. Role: textbox. Name: Agenda note. Action: note. Native event: input. State field: note.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "maxLength": 160
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### enrich-start

Module: enrich. Role: combobox. Name: Agenda start. Action: start. Native event: change. State field: start.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "09:00",
        "10:00"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### enrich-compute

Module: enrich. Role: button. Name: Compute local agenda. Action: compute. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### enrich-reset

Module: enrich. Role: button. Name: Reset lesson. Action: reset. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### trace-path

Module: trace. Role: combobox. Name: Trace fixture. Action: path. Native event: change. State field: path.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "terminating",
        "repeat"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### trace-next

Module: trace. Role: button. Name: Inspect next trace frame. Action: next. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### trace-diagnosis

Module: trace. Role: combobox. Name: Diagnosis from inspected frames. Action: diagnosis. Native event: change. State field: diagnosis.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "finished",
        "cycle"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### trace-explain

Module: trace. Role: button. Name: Check local diagnosis. Action: explain. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### trace-reset

Module: trace. Role: button. Name: Reset lesson. Action: reset. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### quiz-low

Module: quiz. Role: combobox. Name: Subtotal 46 plus shipping 5. Action: low. Native event: change. State field: low.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "eligible",
        "not-eligible"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### quiz-edge

Module: quiz. Role: combobox. Name: Subtotal exactly 50. Action: edge. Native event: change. State field: edge.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "not-eligible",
        "eligible"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

### quiz-check

Module: quiz. Role: button. Name: Check both predictions. Action: check. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

### quiz-reset

Module: quiz. Role: button. Name: Reset lesson. Action: reset. Native event: click. 

```json
{
  "type": "object",
  "properties": {},
  "required": [],
  "additionalProperties": false
}
```

## Outputs and modules

```json
{
  "modules": [
    {
      "id": "geoffrey-enrich",
      "key": "enrich",
      "name": "Enrich an existing note",
      "sources": [
        "G01",
        "G03",
        "G08"
      ]
    },
    {
      "id": "geoffrey-trace",
      "key": "trace",
      "name": "Inspect a tiny execution world",
      "sources": [
        "G02",
        "G04"
      ]
    },
    {
      "id": "geoffrey-quiz",
      "key": "quiz",
      "name": "Predict before accepting",
      "sources": [
        "G02",
        "G06"
      ]
    }
  ],
  "outputs": [
    {
      "id": "enrich-status",
      "module": "enrich",
      "role": "status",
      "field": "status"
    },
    {
      "id": "enrich-result",
      "module": "enrich",
      "role": "log",
      "field": "result",
      "empty": "No local result yet."
    },
    {
      "id": "trace-status",
      "module": "trace",
      "role": "status",
      "field": "status"
    },
    {
      "id": "trace-result",
      "module": "trace",
      "role": "log",
      "field": "result",
      "empty": "No local result yet."
    },
    {
      "id": "quiz-status",
      "module": "quiz",
      "role": "status",
      "field": "status"
    },
    {
      "id": "quiz-result",
      "module": "quiz",
      "role": "log",
      "field": "result",
      "empty": "No local result yet."
    }
  ]
}
```

## Refusals and recovery

- INVALID_REQUEST: Use the exact JSON-shaped envelope and no extra keys.
- WRONG_PUBLICATION: Discover the correct guide.
- WRONG_INSTANCE: Rediscover after reload.
- REQUEST_ID_REUSE: Use a new request ID for changed data.
- REQUEST_LIMIT: Reload after 4096 retained IDs; exact replays still work.
- VERSION_MISMATCH: Use discovered versions.
- UNKNOWN_TARGET: Use an ID from discovery.
- AMBIGUOUS_TARGET: Reset lesson exists in three regions. Choose an exact ID or module scope.
- UNKNOWN_ACTION: Use the action declared for this control.
- INVALID_ARGUMENTS: Use exact args schema, without coercion.
- STALE_REVISION: Inspect and submit a fresh request ID at the current revision.
- CONTROL_UNAVAILABLE: Read availability reason; change the relevant lesson state.
- UNKNOWN_REQUEST: Wait only for a retained request on this page.
- DISPATCH_FAILED: Inspect diagnostics and reload; no successful effect is claimed.
- RENDER_FAILED: State may have changed; inspect and reload. No rollback is promised.
- EMPTY_NOTE: Write a supported minute-and-label agenda line.
- UNPARSED_LINE: Use a positive integer from 1 to 120 followed by m, a space and a label.
- TRACE_END: Reset or check the completed trace.
- INSUFFICIENT_TRACE: Inspect all three frames.
- WRONG_DIAGNOSIS: Compare the last frame with the earlier goal, stack and bindings.
- PREDICTION_MISMATCH: Exclude shipping and retain the inclusive threshold.

## Cleanup and boundaries

Reset each lesson with its exact reset button. Reset retains the receipt ledger. Reload clears all fixture state and receipts and creates a new pageInstanceId. No persistence, real model calls, network effects, shell, repository or permissions are provided. The fixtures are fictional, deterministic and narrower than the source projects. Do not enter secrets. Read [access](./auth.md), [privacy](./privacy/) and [sources](./sources.json).
