Skip to content

feat(observe): appRequestKind tells approvals, questions and adapter-served calls apart - #137

Merged
xxchan merged 1 commit into
mainfrom
observe-app-request-kind
Oct 5, 2026
Merged

xxchan merged 1 commit into
mainfrom
observe-app-request-kind

Conversation

@xxchan

@xxchan xxchan commented Oct 5, 2026

Copy link
Copy Markdown
Member

What

A new observe helper, appRequestKind(type), returns "approval" | "question" | "service" | "unknown". It is exported from @botiverse/oar/observe and from the root, the same way classifyTool / groupToolActivity are. The AppRequestKind type is exported too. Its input is the type of an app_request event, view part or pending request, which is the runtime's native method or subtype of a toApp request.

Why

A host that renders app_request parts can't currently tell an approval from a terminal call the adapter already served. The type is the runtime's own name, and each runtime names the same request differently. Only OAR knows the mapping, so it lives in observe/, as classifyTool's does. Unrecognised types return "unknown" so hosts keep showing them. Record and contract types are unchanged.

Names per class, and where each came from

type kind runtime source
session/request_permission approval ACP (kimi, grok, antigravity) methods.client.session.requestPermission in @agentclientprotocol/sdk 1.4.0, registered in shared/acp/client-app.ts; tests/acp/acp-session.test.ts
item/commandExecution/requestApproval approval codex codex app-server generate-json-schema (0.160.0) ServerRequest; tests/codex/codex-session-stream.test.ts
item/fileChange/requestApproval approval codex same schema
item/permissions/requestApproval approval codex same schema
can_use_tool approval claude control_request subtype that claude 2.1.288 sends its host, recorded as the type by claude/projection.ts; tests/events.test.ts
approval approval morph (community) community/morph/tracker.ts
elicitation/create question ACP methods.client.elicitation.create (SDK 1.4.0)
item/tool/requestUserInput question codex codex 0.160.0 schema
mcpServer/elicitation/request question codex codex 0.160.0 schema
elicitation question claude control_request subtype that claude 2.1.288 sends for an MCP server's question
terminal/create, terminal/output, terminal/wait_for_exit, terminal/kill, terminal/release service ACP methods.client.terminal.* (SDK 1.4.0), all served by shared/acp/client-app.ts; recorded in the kimi and grok vendor fixtures
fs/read_text_file, fs/write_text_file service ACP methods.client.fs.* (SDK 1.4.0)

Left unknown on purpose:

  • codex item/tool/call: a dynamic tool the app runs, neither a question nor served by the adapter.
  • codex account/chatgptAuthTokens/refresh and attestation/generate.
  • codex's legacy execCommandApproval / applyPatchApproval: they only answer turns started through the v1 APIs, which OAR doesn't use.
  • claude hook_callback, mcp_message and request_user_dialog: these need hooks, SDK MCP servers or dialog kinds that the host declares, and OAR declares none.

Notes:

  • OAR advertises fs: { readTextFile: false, writeTextFile: false } and registers no elicitation handler, so fs/* and elicitation/create can't appear in a record today. They're classified so a future handler doesn't need a change here.
  • The lists aren't imported from the adapters. observe/ stays free of Node and adapter imports, and the codex and claude adapters record whatever method or subtype arrives, with no constant to derive a list from. The ACP names are instead checked by a test against the SDK constants that client-app.ts registers.

Tests

tests/app-requests.test.ts:

  • the observe and root exports;
  • an inline snapshot of the per-runtime table;
  • the SDK's methods.client request constants (permission, terminal, fs, elicitation);
  • every request the recorded kimi and grok ACP vendor runs sent (tests/replay/fixtures/*-acp-v1.vendor.json), checked against "unknown";
  • claude control_request frames folded through foldClaudeStdout, so the projection's recorded type is what gets classified;
  • "unknown" for unrecognised and prototype-like keys (toString, __proto__).

pnpm run check passes (typecheck, lint, 607 tests passed / 31 skipped, mock sea-trial 19/19). pnpm run build also passes.

🤖 Generated with Claude Code

…served calls apart

A host that shows `app_request` parts cannot tell an approval from a
terminal call the adapter already served: the `type` is the runtime's own
method or subtype, and each runtime names the same ask differently.
`appRequestKind(type)` maps it to "approval" | "question" | "service" |
"unknown", exported from @botiverse/oar/observe and the root like
classifyTool. Unrecognised types are "unknown" so hosts keep showing them.

- approval: ACP session/request_permission; codex
  item/{commandExecution,fileChange,permissions}/requestApproval; claude
  can_use_tool; morph approval
- question: ACP elicitation/create; codex item/tool/requestUserInput and
  mcpServer/elicitation/request; claude elicitation
- service: ACP terminal/{create,output,wait_for_exit,kill,release} and
  fs/{read_text_file,write_text_file}

Record and contract types are unchanged. Tests pin the table, cross-check
the ACP names against the SDK's methods.client constants that
shared/acp/client-app.ts registers, classify every request the recorded
kimi and grok vendor runs sent, and fold claude control_requests through
the claude projection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 522beeb into main Oct 5, 2026
13 checks passed
@xxchan
xxchan deleted the observe-app-request-kind branch October 5, 2026 14:58
@xxchan xxchan mentioned this pull request Oct 5, 2026
xxchan added a commit that referenced this pull request Oct 5, 2026
Patch release: #137 (Ferryman) adds `appRequestKind(type)` to observe
and the root: `approval`, `question`, `service` (a client call the
adapter serves itself, such as an ACP terminal) or `unknown`. Version
bump only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
stamp-build Bot added a commit that referenced this pull request Oct 31, 2026
<!-- stamp:review:v1 -->
<sup><img
src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp"
width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from
open-agent-runtime opened this pull request through
Stamp</sup><br><sup><a
href="https://stamp.build/review?receipt=prc_d6aec29df39540533f20f22961f6626f"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img
src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg"
width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp
→</a></sup>

---
<!-- /stamp:review:v1 -->

Windows disposal could spend more than ten seconds capturing descendants
before native shutdown: each failed CIM read had its own five-second
limit, while waiting for a fresh serial batch was unbounded. The
observed Claude 2.1.316 failure took 16.439 seconds and exceeded the
unchanged 15-second behavior check.

Give Windows before-EOF capture, force revalidation and post-exit
revalidation separate five-second caller budgets, including queueing.
Capture does not retry a timeout; another failure may retry once with
only the remaining time. Expired callers report unverified cleanup and
discard late identity evidence; force still stops the owned root. The
one-second pre-cancellation observation uses the same deadline
mechanism. Other platforms retain their existing cleanup policy.

The first actually spawned Windows tree-owning line process starts one
bounded background preparation through the serial reader. This includes
short model, inventory and account probes that use that process
abstraction; `runExecutable` help/version queries do not trigger it.
Preparation never supplies cleanup identity evidence. Only completed
cleanup retains a snapshot of its diagnostic metadata. Preparation alone
does not keep the host alive: its timers, query process and pipe are
unreferenced, while any foreground caller promotes the batch and retains
its handles. Synchronous host-exit cleanup remains independent.

The standalone behavior entry does not prewarm CIM, so Windows CI
exercises the product's cold path with the existing 15-second disposal
assertion. Native shutdown-hook grace is unchanged. Observation budgets
do not bound total disposal: taskkill and native exit still have no hard
deadline. The accepted tradeoff is that the slowest measured capture
would report unverified cleanup near five seconds instead of recovering
through retries after 11.4 seconds.

The committed
[report](https://github.com/botiverse/oar/blob/65b29c41ba54afc503bf407ba15a37ba7b0af558/experiments/windows-dispose-timing/README.md),
probe, manifest and selection script preserve both Windows baseline
groups from run 41193731535, including all 102 stops and physical query
intervals. Batching remains effective; the slowest capture includes
about five seconds of queueing. The original trace's remaining 6.418
seconds cannot be reconstructed by phase, and is not attributed to
post-exit revalidation. The temporary workflow is not included.

Validation:

- Full `CI=1 pnpm run check`: 2,856 unit tests and 18 mock behavior
cases passed; package builds passed.
- All 14 behavior backends passed with bounded concurrency, including
the native aimock/replay backends; Pi RPC normal and hanging native
shutdown-hook regressions passed.
- Regressions cover queued budgets, remaining retry time, no timeout
retry, expired cancellation results, fresh capture after completed
preparation, stable cleanup-only metadata, actual spawn semantics, and
real host exit with background or foreground queries. Targeted mutations
verify the budget, identity and handle-reference boundaries.
- Downloaded baseline evidence is reproducibly selected byte-for-byte.
Changed Windows product behavior and macOS checks remain subject to this
PR's CI.

Raft task #137. Release remains with Cindy after review and successful
CI.

---------

Co-authored-by: Otter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant