# Geoffrey Huntley field guide: agent interface

Canonical HTML: https://open-hutch-b2hd.here.now/agent-interface.html

Operate the three fictional lessons through `window.GeoffreyGuide` on the [main page](https://open-hutch-b2hd.here.now/), in its browser main JavaScript realm. There is no HTTP mutation endpoint, MCP server, model call, real shell or Ralph runner. Native UI events and agent calls share one dispatcher.

## Discovery and reads

Call `discover()` without arguments and require `ready: true`. Extract only publicationId, interfaceVersion, contentVersion, fixtureVersion and pageInstanceId. Do not spread the entire discovery result into an action.

- `inspect({targetId?})` returns detached state under `data.state` and its controls, outputs, fixtures, source IDs and limits. Omit targetId for root `ghuntley-guide`.
- `query({within?,role?,name?})` returns exact case-sensitive matches within a registered region. No CSS selectors or fuzzy names.
- `wait({pageInstanceId,requestId})` returns the retained receipt directly, not `{receipt}`. It is a synchronous lookup, not job polling.
- `diagnose()` returns listed runtime and lesson invariants. Read `healthy`; not security or accessibility certification.

## Operational main-realm example

This resets the context lesson, replays the exact request and retrieves its receipt. Each changed action requires a new request ID.

```js
const api = window.GeoffreyGuide;
const d = api.discover();
if (!d.ready) throw new Error('Page is not ready');
const identity = {
  publicationId: d.publicationId,
  interfaceVersion: d.interfaceVersion,
  contentVersion: d.contentVersion,
  fixtureVersion: d.fixtureVersion,
  pageInstanceId: d.pageInstanceId
};
const request = {
  ...identity,
  requestId: 'example.' + crypto.randomUUID(),
  expectedRevision: api.inspect({targetId: 'ghuntley-lesson-context'}).revision,
  target: {id: 'context-reset'},
  action: 'reset',
  args: {}
};
const first = api.act(request);
if (!first.receipt.ok) throw new Error(first.receipt.error.code);
const replay = api.act(request); // No second mutation.
const receipt = api.wait({pageInstanceId: d.pageInstanceId, requestId: request.requestId});
const lesson = api.inspect({targetId: 'ghuntley-lesson-context'});
const health = api.diagnose();
```

## Exact action envelope

Unknown keys, invalid JSON data, accessors and mismatched identities are rejected. Every control also supports `focus` with `{}`, moving actual DOM focus and incrementing revision without changing lesson state.

```json
{
  "type": "object",
  "properties": {
    "publicationId": {
      "type": "string",
      "const": "ghuntley-field-guide"
    },
    "interfaceVersion": {
      "type": "string",
      "const": "1.0.0"
    },
    "contentVersion": {
      "type": "string",
      "const": "1.0.0"
    },
    "fixtureVersion": {
      "type": "string",
      "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-load",
        "set-task",
        "pack",
        "reset",
        "set-mode",
        "step",
        "record",
        "restart",
        "set-patch",
        "set-suite",
        "check",
        "accept",
        "focus"
      ]
    },
    "args": {
      "type": "object",
      "description": "Use the exact resolved control schema; focus takes {}."
    }
  },
  "required": [
    "publicationId",
    "interfaceVersion",
    "contentVersion",
    "fixtureVersion",
    "pageInstanceId",
    "requestId",
    "expectedRevision",
    "target",
    "action",
    "args"
  ],
  "additionalProperties": false
}
```

## Control catalog and argument schemas

### context-load

Region: `ghuntley-lesson-context`. Accessible name: **Context packet**. Role: `combobox`. Native event: `change`. Action: `set-load`. State field: `load`.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "focused",
        "history",
        "missing-spec"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

- `focused`: Focused packet
- `history`: Old transcript included
- `missing-spec`: Specification omitted

### context-task

Region: `ghuntley-lesson-context`. Accessible name: **One task for this iteration**. Role: `textbox`. Native event: `input`. Action: `set-task`. State field: `task`.

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



### context-pack

Region: `ghuntley-lesson-context`. Accessible name: **Assemble packet**. Role: `button`. Native event: `click`. Action: `pack`.

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



### context-reset

Region: `ghuntley-lesson-context`. Accessible name: **Reset lesson**. Role: `button`. Native event: `click`. Action: `reset`.

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



### progress-mode

Region: `ghuntley-lesson-progress`. Accessible name: **Checkpoint contents**. Role: `combobox`. Native event: `change`. Action: `set-mode`. State field: `mode`.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "chat",
        "plan",
        "evidence"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

- `chat`: Chat only
- `plan`: Plan claim only
- `evidence`: Evidence checkpoint

### progress-step

Region: `ghuntley-lesson-progress`. Accessible name: **Run fixture step**. Role: `button`. Native event: `click`. Action: `step`.

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



### progress-record

Region: `ghuntley-lesson-progress`. Accessible name: **Record checkpoint**. Role: `button`. Native event: `click`. Action: `record`.

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



### progress-restart

Region: `ghuntley-lesson-progress`. Accessible name: **Start fresh iteration**. Role: `button`. Native event: `click`. Action: `restart`.

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



### progress-reset

Region: `ghuntley-lesson-progress`. Accessible name: **Reset lesson**. Role: `button`. Native event: `click`. Action: `reset`.

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



### pressure-patch

Region: `ghuntley-lesson-pressure`. Accessible name: **Candidate implementation**. Role: `combobox`. Native event: `change`. Action: `set-patch`. State field: `patch`.

```json
{
  "type": "object",
  "properties": {
    "value": {
      "type": "string",
      "enum": [
        "placeholder",
        "count-all",
        "unique"
      ]
    }
  },
  "required": [
    "value"
  ],
  "additionalProperties": false
}
```

- `placeholder`: Placeholder zero
- `count-all`: Count all occurrences
- `unique`: Distinct count

### pressure-suite

Region: `ghuntley-lesson-pressure`. Accessible name: **Feedback coverage**. Role: `combobox`. Native event: `change`. Action: `set-suite`. State field: `suite`.

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

- `smoke`: One smoke case
- `contract`: Contract cases

### pressure-check

Region: `ghuntley-lesson-pressure`. Accessible name: **Evaluate fixture**. Role: `button`. Native event: `click`. Action: `check`.

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



### pressure-accept

Region: `ghuntley-lesson-pressure`. Accessible name: **Attempt acceptance**. Role: `button`. Native event: `click`. Action: `accept`.

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



### pressure-reset

Region: `ghuntley-lesson-pressure`. Accessible name: **Reset lesson**. Role: `button`. Native event: `click`. Action: `reset`.

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



## Output catalog

- `context-status`: role status, module `context`, state field `status`.
- `context-output`: role log, module `context`, state field `report`.
- `progress-status`: role status, module `progress`, state field `status`.
- `progress-output`: role log, module `progress`, state field `report`.
- `pressure-status`: role status, module `pressure`, state field `status`.
- `pressure-output`: role log, module `pressure`, state field `report`.

Status outputs are live regions. Complex evidence appears in preformatted logs. Null output means no current result; changing an input invalidates its corresponding observation.

## Results and refusals

`act` returns `{replayed,receipt}`. A domain refusal can have `executed: true` and `ok: false` and still advance revision. Evaluate fixture succeeds as an operation even if case results fail. Attempt acceptance enforces sufficient coverage and passing cases. Inspect `check.passed` rather than confusing transport success with domain acceptance.

Run fixture step becomes disabled after its single step completes or parser becomes next. Disabled native controls emit no new receipt. Other explicit attempt buttons stay enabled to demonstrate missing prerequisites. Three Reset lesson controls are ambiguous at root scope; use an ID or narrow the region.

- `INVALID_REQUEST`: Supply only the exact JSON-shaped fields, without accessors, cycles or extra keys.
- `WRONG_PUBLICATION`: Use this publication identity.
- `WRONG_INSTANCE`: Discover the new page after reload.
- `VERSION_MISMATCH`: Use current discovery versions and a new request ID.
- `REQUEST_ID_REUSE`: Replay exactly or use a new ID for changed data.
- `REQUEST_LIMIT`: 4096 IDs retained. Reads and exact replay still work; reload clears state and ledger.
- `UNKNOWN_TARGET`: Discover an exact registered target.
- `AMBIGUOUS_TARGET`: Use an exact ID or narrower region; Reset lesson has three root matches.
- `UNKNOWN_ACTION`: Use an action advertised by the control.
- `INVALID_ARGUMENTS`: Follow the exact control schema without extra keys or coercion.
- `STALE_REVISION`: Inspect current state and use a new ID and revision.
- `CONTROL_UNAVAILABLE`: Read availability; a completed fixture step is disabled.
- `UNKNOWN_REQUEST`: wait retrieves only retained IDs in this page instance.
- `DISPATCH_FAILED`: Inspect diagnostics and reload. No successful effect is claimed.
- `RENDER_FAILED`: State may already be committed. Inspect diagnostics and reload; no rollback is promised.
- `TASK_REQUIRED`: Enter a task and assemble again.
- `SPEC_REQUIRED`: Select Focused packet.
- `CONTEXT_OVER_BUDGET`: Select Focused packet to remove old history.
- `NO_VERIFIED_PROGRESS`: Run the fixture step first.
- `CHECKPOINT_NOT_DURABLE`: Choose Evidence checkpoint and record again.
- `PROGRESS_LOST`: Re-run the step, record an Evidence checkpoint and restart.
- `CHECKPOINT_UNSUPPORTED`: Re-run the step and record evidence, artifact and rationale.
- `STEP_ALREADY_COMPLETE`: Reset the single-step fixture; native UI disables the completed step.
- `CHECK_REQUIRED`: Evaluate the current candidate and suite.
- `INSUFFICIENT_BACKPRESSURE`: Select Contract cases, evaluate and attempt acceptance.
- `CHECK_FAILED`: Choose Distinct count, evaluate and attempt acceptance.

## Revisions, replay and cleanup

All lessons share a revision. Each admitted action, including focus and domain refusal, advances it once. Exact replay returns the retained receipt without another mutation even after the revision changes. Altered reuse of a request ID is rejected. A stale request requires new inspection and a new ID, not a modified replay.

The ledger retains up to 4096 IDs without eviction. At capacity, reads and prior replay still work. Reset lesson increments its epoch and restores initial lesson state but keeps the ledger. Reload erases all lesson state and receipts and creates a new pageInstanceId. Rediscover afterward. No rollback, durable storage or cross-page receipt recovery is promised. There are no background jobs or external effects to clean up. Reset or reload when finished.

## Limits

- Three deterministic fictional fixtures, not a live model, shell, compiler or repository.
- Context units are invented teaching units, not measured tokens or model performance.
- A checkpoint survives only the simulated iteration inside this page. There is no filesystem, browser storage or other persistence.
- Reload resets every lesson and the receipt ledger and creates a new pageInstanceId.
- No asynchronous jobs, network actions, model calls, credential access, real permissions or security isolation. Initial document and asset requests still reach hosting.
- No autonomous repeat loop. Every teaching transition requires an explicit action; no deployment, purchasing or publishing.
- Fixture checks cover only the named finite cases; passing is not a proof of compiler correctness or permission to run a real agent.

A checkpoint is only simulated external memory, not a file or localStorage. Context units are invented. Four passing cases are not compiler validation. Read [Privacy](https://open-hutch-b2hd.here.now/privacy/) for ordinary hosting requests and [Sources](https://open-hutch-b2hd.here.now/sources.json) for attribution.
