> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Verified Input

> Use Kernel CLI 0.26.11 to post keyboard input once, observe application state, and require stable postconditions before continuing.

# Verified Input

Keyboard event delivery is not the same as application acceptance. Verified
input waits for observable application state before the next step proceeds.

## The transaction

```text theme={null}
preflight   settle app   read before   post once   observe   stable   finish
    │            │            │            │           │        │        │
    └─ refuse ───┴────────────┘            └─ POSTED   │        │        │
                                                       └─ OBSERVED       │
                                                                └─ VERIFIED
                                                       └────────── TIMEOUT
                                           └────────────────────── ERROR
```

An action is posted at most once. Verification never retries the mutation.

| Outcome    | Meaning                                                                       |
| ---------- | ----------------------------------------------------------------------------- |
| `POSTED`   | The operating-system writer accepted the event; app consumption is not proven |
| `OBSERVED` | The postcondition matched, but not for the full stability window              |
| `VERIFIED` | The same postcondition remained true for `stable_ms`                          |
| `TIMEOUT`  | The required observable state did not arrive before the deadline              |
| `REFUSED`  | A precondition, target, identity, or timing rule rejected the write           |
| `ERROR`    | Event posting or observation failed                                           |

`TIMEOUT`, `REFUSED`, and `ERROR` return non-zero; MCP returns `isError:true`.
Results expose focused identity plus value length and SHA-256, not typed text,
focused values, selections, or clipboard contents.

## Verify one action

```bash theme={null}
# Final value must equal the submitted text.
kernel-cli type "hello" --app TextEdit --verify
kernel-cli paste "long or multiline text" --app TextEdit --verify

# The final value differs from the submitted fragment.
kernel-cli type " world" --expect-value "hello world"

# Focus must move and land on the expected kind of control.
kernel-cli key tab --wait-focus-change --expect-role AXTextField
kernel-cli key tab --expect-focus message-composer
```

`--expect-app` is a precondition that prevents a write into the wrong
frontmost application. `--verify`, `--expect-value`, `--wait-focus-change`,
`--expect-role`, and `--expect-focus` are postconditions.

```bash theme={null}
kernel-cli type "hello" --expect-app TextEdit --verify \
  --timeout-ms 5000 --poll-ms 50 --stable-ms 150
```

Timing controls require a postcondition. The deadline begins after the writer
returns, so slow per-character posting does not consume the app-acceptance
window. Use timing to control observation load and deadline, not as a substitute
for correctness.

## Execute a multi-step plan

`kernel-cli input` reads a `kernel.input.plan.v1` JSON document:

```bash theme={null}
kernel-cli --json input --file plan.json
kernel-cli --json input --file - < plan.json
```

```json theme={null}
{
  "schema_version": "kernel.input.plan.v1",
  "app": "TextEdit",
  "expect_app": "TextEdit",
  "timeout_ms": 4000,
  "poll_ms": 50,
  "stable_ms": 100,
  "restore_focus": true,
  "steps": [
    {
      "id": "draft",
      "action": "paste",
      "text": "hello",
      "via": "shortcut",
      "postcondition": {"kind": "value_equals", "value": "hello"}
    },
    {
      "id": "next-field",
      "action": "key",
      "combo": "tab",
      "postcondition": {"kind": "focus_changed", "role": "AXTextField"}
    }
  ]
}
```

Supported actions are `type`, `key`, and `paste`. Type/key mode is `synthetic`
or `real`; paste uses `shortcut` or `menu`.

| Postcondition   | Proof                                                             |
| --------------- | ----------------------------------------------------------------- |
| `value_equals`  | Focused accessibility value exactly equals the expected value     |
| `value_suffix`  | Focused value ends with the expected suffix                       |
| `focus_changed` | Strong focused identity changed; optional focus fields also match |
| `focus_matches` | Resulting focus fields match without requiring a change           |

Focus can be constrained by app, role, subrole, identifier, developer id, or
title. Weak or missing identity is inconclusive, never silently counted as a
focus change. An empty string is a real value only when the platform exposes an
available text/value channel.

Every plan step is strict by default. `allow_unverified:true` is an explicit
compatibility escape hatch for a step without a postcondition; its result is
`posted`, never `verified`.

## Replace sleeps with observable barriers

```text theme={null}
Cmd+Shift+G
     └─▶ wait for location-field focus
paste path
     └─▶ wait for exact path value
Enter
     └─▶ wait for chooser selection or dialog focus change
Enter
     └─▶ only when state proves this Enter belongs to the intended control
```

If a file chooser cannot expose the required focus or value, stop with an
observer limitation. A screenshot match or a longer sleep is not equivalent to
verified application state.

## Clipboard and focus leases

```text theme={null}
capture original → stage text → paste → verify/grace → compare current
                                                        │
                          still staged ──────────────────┴─▶ restore original
                          changed by user or app ──────────▶ preserve newer data
```

Paste restores the original text clipboard only while the clipboard still
contains Kernel CLI's staged text. Cleanup runs after success, timeout,
refusal, or post error. Rich non-text pasteboard formats are outside this first
lease contract.

Focus restoration follows the same ownership rule. It restores only while the
transaction's activated app still owns frontmost; newer user or application
focus is preserved.

## PID, profiles, and handoff

On macOS, `type --pid` and `key --pid` can prove event posting to a background
process, but not bind the frontmost accessibility observer to that target.
Strict postconditions with PID targeting are refused before posting. Linux and
Windows refuse `--pid` rather than silently sending global input.

Profiles can embed the same strict input step and required waits. Before an
agent takes frontmost keyboard control, use `--yield` or the profile yield
policy for human coordination. The handoff prompt coordinates ownership; the
accessibility postcondition remains the correctness proof.

## MCP and computer-use

* MCP `input` accepts the complete plan under `plan`.
* MCP `type`, `type_text`, `paste`, and `key` expose the same verification flags.
* `computer_use` routes type, paste, and key through the same transaction and
  preserves the outcome under `result`.
* Capability version 2 advertises `verification.readback`; paste and input also
  advertise clipboard read/write.

## What VERIFIED does not mean

```text theme={null}
draft value VERIFIED ── proves ──▶ the app accepted the draft
                                  ╳ message delivered

focus change VERIFIED ─ proves ──▶ navigation occurred
                                  ╳ server-side save/upload/send succeeded
```

Sending, uploading, saving, and other domain actions require a separate
observer owned by that domain. Never label an Enter key as “delivered” merely
because the keyboard transaction verified.

<CardGroup cols={2}>
  <Card title="Chat Exports" icon="messages" href="/kernel-cli/chat">
    Analyze the artifact after an app-pack export completes.
  </Card>

  <Card title="Commands" icon="rectangle-terminal" href="/kernel-cli/commands">
    See the complete 111-command surface.
  </Card>
</CardGroup>
