diff --git a/V2_HTTP_API_AUDIT.md b/V2_HTTP_API_AUDIT.md deleted file mode 100644 index ab850f81f39..00000000000 --- a/V2_HTTP_API_AUDIT.md +++ /dev/null @@ -1,279 +0,0 @@ -# V2 HTTP API audit checklist - -**Source:** `packages/protocol/openapi.json` -**Current endpoint count:** 139 -**Last regenerated:** 2026-09-13 - -## How to use this checklist - -Review endpoints in document order. For each endpoint, select one disposition and capture rationale or follow-up work in Notes. Mark **Reviewed** only after the disposition is agreed. - -### Review criteria - -- Resource and operation naming -- HTTP method and idempotency -- Request parameters and location scope -- Response shape and error taxonomy -- Authentication and authorization -- Current production consumers -- Stability level: public, experimental, or internal -- Whether the generated client API is intuitive - -### Disposition legend - -- **Keep:** ship unchanged as a supported V2 API -- **Change:** retain after a defined contract change -- **Remove:** exclude from the official V2 API -- **Experimental-only:** retain outside the stable API commitment - -## Progress - -- [x] Group 1: Foundation and placement (4) -- [x] Group 2: Configuration and capability catalogs (16) -- [x] Group 3: Credentials, integrations, MCP, and web search (22) -- [x] Group 4: Session lifecycle (12) -- [x] Group 5: Session execution and inputs (11) -- [x] Group 6: Session history and recovery (13) -- [x] Group 7: Inbox, permissions, and forms (19) -- [x] Group 8: Filesystem, worktrees, and VCS (12) -- [x] Group 9: PTYs, persistent terminals, and shells (24) -- [x] Group 10: Events, RPC, and experimental operations (6) - -## Resolved during audit - -### [x] `POST /api/plugin/await-activation` - -- **Decision:** Remove -- **Notes:** Activation timing is an internal server concern. Catalog reads remain non-blocking. - -### [x] Location response wrappers - -- **Decision:** Reduce generic endpoint response locations to `{ directory }`. -- **Notes:** Full project metadata remains available from `GET /api/location`; no consumers used it from wrapped responses. - -### [x] `GET /api/health` and `GET /api/server` - -- **Decision:** Merge and rename -- **Replacement:** `GET /api/info` with operation ID `server.info`. -- **Notes:** Returns `version`, `pid`, and connection `urls`; readiness is conveyed by HTTP status. - -### [x] `GET /api/project/current` - -- **Decision:** Remove -- **Replacement:** `GET /api/location`, using `project` from the response. -- **Notes:** The endpoint duplicated `Location.Info.project`; production callers were migrated. - -### [x] `POST /api/workspace` and `DELETE /api/workspace/{workspaceID}` - -- **Decision:** Remove -- **Notes:** Provider-backed workspaces are not part of the V2 HTTP contract and can be introduced later. Core and the embedded SDK retain internal workspace support. - -## Group 1: Foundation and placement - -**Endpoints:** 4 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 001–002 | `GET` | `/api/info` | `server.info` | Keep | Replaces the former health and server endpoints. | -| [x] 003 | `GET` | `/api/location` | `location.get` | Keep | Workspace selectors and response fields removed until workspace support ships. | -| [x] 004 | `GET` | `/api/project` | `project.list` | Keep | Removed unused `time.initialized`; the database column remains for migration data. | -| [x] 005 | `PATCH` | `/api/project/{projectID}` | `project.update` | Keep | Request and response accepted as-is. | - -## Group 2: Configuration and capability catalogs - -**Endpoints:** 16 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 008 | `GET` | `/api/agent` | `agent.list` | Keep | Request and response accepted as-is. | -| [x] 009 | `GET` | `/api/agent/{agentID}` | `agent.get` | Keep | Request, response, and not-found error accepted as-is. | -| [x] 010 | `GET` | `/api/plugin` | `plugin.list` | Keep | Request and response accepted as-is. | -| [x] 012 | `POST` | `/api/plugin/check` | `plugin.check` | Keep | Request and response accepted as-is. | -| [x] 013 | `POST` | `/api/plugin/update` | `plugin.update` | Keep | Request and errors accepted as-is. | -| [x] 014 | `GET` | `/api/model` | `model.list` | Keep | Request and response accepted as-is. | -| [x] 015 | `GET` | `/api/model/default` | `model.default` | Keep | Request and nullable response accepted as-is. | -| [x] 016 | `GET` | `/api/provider` | `provider.list` | Keep | Request and response accepted as-is. | -| [x] 017 | `GET` | `/api/provider/{providerID}` | `provider.get` | Keep | Request, response, and not-found error accepted as-is. | -| [x] 018 | `GET` | `/api/command` | `command.list` | Keep | Request and response accepted as-is. | -| [x] 019 | `GET` | `/api/skill` | `skill.list` | Keep | Renamed `location` to `path`; removed the skill-specific `slash` flag and slash-command behavior. | -| [x] 020 | `GET` | `/api/reference` | `reference.list` | Keep | Removed duplicate `description` and `hidden` fields from nested `source`. | -| [x] 021 | `GET` | `/api/config` | `config.get` | Keep | Compatibility entries removed; response now contains only documents and OpenCode directories. | -| [x] 022 | `GET` | `/api/config/preferences` | `config.preferences` | Remove | Redundant special projection of global config. | -| [x] 023 | `PATCH` | `/api/config/preferences` | `config.updatePreferences` | Remove | Redundant field-specific config mutation API. | -| [x] 024 | `GET` | `/api/config/shell` | `config.shells` | Keep | Required by the server Terminal shell setting. | -| [x] 024a | `PATCH` | `/api/experimental/config` | `experimental.config.update` | Change | Experimental global config mutation; initially accepts only `shell`. | - -## Group 3: Credentials, integrations, MCP, and web search - -**Endpoints:** 22 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 025 | `GET` | `/api/integration` | `integration.list` | Keep | Full integration inventory is consumed by authentication and integration-selection clients. | -| [x] 026 | `GET` | `/api/integration/{integrationID}` | `integration.get` | Change | Missing integration now returns typed `404` instead of optional data. | -| [x] 027 | `POST` | `/api/experimental/integration/wellknown` | `experimental.integration.wellknown.add` | Experimental-only | Retained outside the stable API commitment. | -| [x] 028 | `POST` | `/api/integration/{integrationID}/connect/key` | `integration.connect.key` | Change | Missing integration returns typed `404`; key form answers retained. | -| [x] 029 | `POST` | `/api/integration/{integrationID}/connect/oauth` | `integration.oauth.connect` | Keep | OAuth connection start contract retained. | -| [x] 030 | `GET` | `/api/integration/{integrationID}/connect/oauth/{attemptID}` | `integration.oauth.status` | Change | Missing integration or OAuth attempt returns typed `404`. | -| [x] 031 | `DELETE` | `/api/integration/{integrationID}/connect/oauth/{attemptID}` | `integration.oauth.cancel` | Keep | Idempotent cancellation remains a no-op for unavailable or terminal attempts. | -| [x] 032 | `POST` | `/api/integration/{integrationID}/connect/oauth/{attemptID}/complete` | `integration.oauth.complete` | Change | Missing integration or OAuth attempt returns typed `404`; code remains mode-dependent. | -| [x] 033 | `POST` | `/api/integration/{integrationID}/connect/command` | `integration.command.connect` | Change | Missing integration or command method returns typed `404`. | -| [x] 034 | `GET` | `/api/integration/{integrationID}/connect/command/{attemptID}` | `integration.command.status` | Change | Missing integration or command attempt returns typed `404`. | -| [x] 035 | `DELETE` | `/api/integration/{integrationID}/connect/command/{attemptID}` | `integration.command.cancel` | Keep | Idempotent cancellation remains a no-op for unavailable or terminal attempts. | -| [x] 036 | `GET` | `/api/mcp` | `mcp.list` | Keep | MCP inventory and connection status retained. | -| [x] 037 | `PUT` | `/api/experimental/mcp/{server}` | `experimental.mcp.add` | Experimental-only | Runtime-only MCP override; does not persist configuration. | -| [x] 038 | `DELETE` | `/api/experimental/mcp/{server}` | `experimental.mcp.remove` | Experimental-only | Runtime removal override; missing server returns `404`. | -| [x] 039 | `POST` | `/api/experimental/mcp/{server}/connect` | `experimental.mcp.connect` | Experimental-only | Runtime connection override retained outside the stable API. | -| [x] 040 | `POST` | `/api/experimental/mcp/{server}/disconnect` | `experimental.mcp.disconnect` | Experimental-only | Runtime disconnection override retained outside the stable API. | -| [x] 041 | `GET` | `/api/mcp/resource` | `mcp.resource.catalog` | Keep | Reviewed separately by coworker. | -| [x] 042 | `PATCH` | `/api/credential/{credentialID}` | `credential.update` | Change | Removed redundant location query; credentials and events are global. | -| [x] 043 | `DELETE` | `/api/credential/{credentialID}` | `credential.remove` | Change | Removed redundant location query; credentials and events are global. | -| [x] 044 | `POST` | `/api/credential/{credentialID}/activate` | `credential.activate` | Change | Removed redundant location query; credentials and events are global. | -| [x] 045 | `GET` | `/api/websearch/provider` | `websearch.providers` | Keep | Provider availability remains location-scoped; singular resource path retained. | -| [x] 046 | `POST` | `/api/websearch` | `websearch.query` | Keep | Unknown provider remains an invalid request; published time documented as Unix epoch milliseconds. | - -## Group 4: Session lifecycle - -**Endpoints:** 12 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 047 | `GET` | `/api/session` | `session.list` | Keep | Existing filtering, ordering, and cursor contract retained for now. | -| [x] 048 | `POST` | `/api/session` | `session.create` | Keep | Existing creation contract retained; model reference includes optional variant. | -| [x] 049 | `GET` | `/api/experimental/session/stats` | `experimental.session.stats` | Experimental-only | Session analytics retained outside the stable API commitment. | -| [x] 050 | `GET` | `/api/session/active` | `session.active` | Keep | Status record retained for future active-state expansion. | -| [x] 051 | `GET` | `/api/session/{sessionID}` | `session.get` | Keep | Specific session read and typed `404` retained. | -| [x] 052 | `DELETE` | `/api/session/{sessionID}` | `session.remove` | Keep | Session and child deletion with typed `404` retained. | -| [x] 053 | `POST` | `/api/session/{sessionID}/fork` | `session.fork` | Change | Request now accepts optional branded `before` message ID; omission copies full history. | -| [x] 054 | `POST` | `/api/session/{sessionID}/agent` | `session.switchAgent` | Keep | Subsequent-execution agent selection retained. | -| [x] 055 | `POST` | `/api/session/{sessionID}/model` | `session.switchModel` | Keep | Subsequent-execution model and optional variant selection retained. | -| [x] 056 | `PATCH` | `/api/session/{sessionID}` | `session.update` | Change | General session patch updates title and permissions; rules emit `session.permissions`. | -| [x] 057 | `POST` | `/api/session/{sessionID}/move` | `session.move` | Change | Removed inaccurate local-change transfer claim; delivery behavior retained. | -| [x] 058 | `POST` | `/api/session/{sessionID}/background` | `session.background` | Keep | Backgroundable foreground tools transition to background observation; idle requests remain no-ops. | - -## Group 5: Session execution and inputs - -**Endpoints:** 11 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 059 | `POST` | `/api/session/{sessionID}/prompt` | `session.prompt` | Keep | Durable admission, delivery mode, and admit-only resume control retained. | -| [x] 060 | `POST` | `/api/session/{sessionID}/command` | `session.command` | Change | Renamed request field from `command` to `name`; `204` retained. | -| [x] 061 | `POST` | `/api/experimental/session/{sessionID}/skill` | `experimental.session.skill` | Experimental-only | Skill ID is now the `id` field; standalone activation remains experimental. | -| [x] 062 | `POST` | `/api/session/{sessionID}/synthetic` | `session.synthetic` | Keep | Durable synthetic admission and delivery controls retained. | -| [x] 063 | `POST` | `/api/session/{sessionID}/shell` | `session.shell` | Change | Caller ID is now the optimistic shell message ID; server derives its event ID. | -| [x] 064 | `POST` | `/api/session/{sessionID}/compact` | `session.compact` | Keep | Durable compaction admission and delivery controls retained. | -| [x] 065 | `POST` | `/api/experimental/session/{sessionID}/wait` | `experimental.session.wait` | Experimental-only | Race-free idle barrier retained outside the stable API. | -| [x] 066 | `POST` | `/api/session/{sessionID}/generate` | `session.generate` | Keep | Transient generation from session context retained. | -| [x] 067 | `POST` | `/api/session/{sessionID}/interrupt` | `session.interrupt` | Change | Renamed `continue` to `resume` across public and internal interruption APIs. | -| [x] 068 | `PUT` | `/api/session/{sessionID}/environment` | `session.environment` | Keep | Process-local environment replacement retained in the stable API. | -| [x] 069 | `POST` | `/api/session/{sessionID}/view` | `session.view` | Change | Idle watermark now uses the standard epoch-millisecond timestamp schema. | - -## Group 6: Session history and recovery - -**Endpoints:** 13 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 070 | `POST` | `/api/experimental/session/import` | `experimental.session.import` | Experimental-only | Existing projected transcript import contract retained outside the stable API. | -| [x] 071 | `GET` | `/api/experimental/session/{sessionID}/export` | `experimental.session.export` | Experimental-only | Existing projected transcript export contract retained outside the stable API. | -| [x] 072 | `POST` | `/api/session/{sessionID}/revert/stage` | `session.revert.stage` | Keep | Existing staged history and optional file restoration behavior retained. | -| [x] 073 | `DELETE` | `/api/session/{sessionID}/revert` | `session.revert.clear` | Change | Clearing staged revert now deletes the session revert resource. | -| [x] 074 | `POST` | `/api/session/{sessionID}/revert/commit` | `session.revert.commit` | Keep | Explicit staged-revert commit action retained. | -| [x] 075 | `GET` | `/api/session/{sessionID}/context` | `session.context` | Keep | Active model-context projection retained. | -| [x] 076 | `GET` | `/api/session/{sessionID}/diff` | `session.diff` | Keep | Turn-range structured diff contract retained. | -| [x] 077 | `GET` | `/api/experimental/session/{sessionID}/instructions/entries` | `experimental.session.instructions.entry.list` | Experimental-only | API-managed durable context entries retained outside the stable API. | -| [x] 078 | `PUT` | `/api/experimental/session/{sessionID}/instructions/entries/{key}` | `experimental.session.instructions.entry.put` | Experimental-only | API-managed durable context entries retained outside the stable API. | -| [x] 079 | `DELETE` | `/api/experimental/session/{sessionID}/instructions/entries/{key}` | `experimental.session.instructions.entry.remove` | Experimental-only | API-managed durable context entries retained outside the stable API. | -| [x] 080 | `GET` | `/api/experimental/session/{sessionID}/log` | `session.log` | Experimental-only | Retained outside the stable API commitment. | -| [x] 081 | `GET` | `/api/session/{sessionID}/message/{messageID}` | `session.message.get` | Change | Normalized specific-message operation ID. | -| [x] 082 | `GET` | `/api/session/{sessionID}/message` | `session.message.list` | Change | Normalized session-scoped message-list operation ID. | - -## Group 7: Inbox, permissions, and forms - -**Endpoints:** 19 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 083 | `GET` | `/api/session/{sessionID}/inbox` | `session.inbox.list` | Change | Inbox timestamps now use the standard nested `time.created` shape. | -| [x] 084 | `DELETE` | `/api/session/{sessionID}/inbox/{inboxID}` | `session.inbox.cancel` | Change | Cancellation is idempotent and returns `204` when the session exists. | -| [x] 085 | `PATCH` | `/api/session/{sessionID}/inbox/{inboxID}` | `session.inbox.update` | Change | Consolidated delivery mutation with `delivery: "steer" | "queue"`. | -| [x] 086 | — | — | — | Remove | Replaced by `session.inbox.update`. | -| [x] 087 | `GET` | `/api/form` | `form.list` | Change | Removed redundant `request` path and operation namespace. | -| [x] 088 | `GET` | `/api/session/{sessionID}/form` | `session.form.list` | Keep | Pending session form list retained with temporary MCP sentinel compatibility. | -| [x] 089 | `POST` | `/api/session/{sessionID}/form` | `session.form.create` | Keep | External form creation and temporary MCP sentinel ownership retained. | -| [x] 090 | `GET` | `/api/session/{sessionID}/form/{formID}` | `session.form.get` | Change | Form definition and lifecycle state are now returned together. | -| [x] 091 | — | — | — | Remove | State is included by `session.form.get`. | -| [x] 092 | `POST` | `/api/session/{sessionID}/form/{formID}/reply` | `session.form.reply` | Keep | One-shot validated form reply retained. | -| [x] 093 | `DELETE` | `/api/session/{sessionID}/form/{formID}` | `session.form.cancel` | Change | Form cancellation now deletes the pending form resource. | -| [x] 094 | `GET` | `/api/permission/request` | `permission.request.list` | Keep | Pending-request namespace retained alongside saved permissions. | -| [x] 095 | `GET` | `/api/permission/saved` | `permission.saved.list` | Change | Added persisted creation and update timestamps under `time`. | -| [x] 096 | `DELETE` | `/api/permission/saved/{id}` | `permission.saved.remove` | Keep | Idempotent saved-permission deletion retained. | -| [x] 097 | `POST` | `/api/session/{sessionID}/permission` | `session.permission.create` | Keep | Non-blocking permission evaluation and pending-request creation retained. | -| [x] 098 | `GET` | `/api/session/{sessionID}/permission` | `session.permission.list` | Keep | Pending session permission list retained. | -| [x] 099 | `GET` | `/api/session/{sessionID}/permission/{requestID}` | `session.permission.get` | Keep | Specific pending permission read with ownership validation retained. | -| [x] 100 | `POST` | `/api/session/{sessionID}/permission/{requestID}/reply` | `session.permission.reply` | Change | Renamed request field from `reply` to `decision`. | -| [x] 101 | — | — | — | Remove | Permission rules are updated through `session.update`. | - -## Group 8: Filesystem, worktrees, and VCS - -**Endpoints:** 12 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 102 | `GET` | `/api/fs/read/*` | `fs.read` | Keep | Relative wildcard file reads and raw byte responses retained. | -| [x] 103 | `GET` | `/api/fs/list` | `fs.list` | Keep | Existing path scope and minimal entry metadata retained. | -| [x] 104 | `GET` | `/api/fs/find` | `fs.find` | Keep | Existing ranked filesystem search retained. | -| [x] 105 | `GET` | `/api/worktree` | `worktree.list` | Keep | Reviewed separately by coworker. | -| [x] 106 | `POST` | `/api/worktree` | `worktree.create` | Keep | Reviewed separately by coworker. | -| [x] 107 | `DELETE` | `/api/worktree` | `worktree.remove` | Keep | Reviewed separately by coworker. | -| [x] 108 | `POST` | `/api/worktree/refresh` | `worktree.refresh` | Keep | Reviewed separately by coworker. | -| [x] 109 | `GET` | `/api/vcs` | `vcs.get` | Change | Preserved branch nesting and added selected VCS provider ID. | -| [x] 110 | `GET` | `/api/vcs/base` | `vcs.base` | Keep | Review-base inference and nullable unavailable state retained. | -| [x] 111 | `GET` | `/api/vcs/status` | `vcs.status` | Keep | Existing working-copy status shape retained for now. | -| [x] 112 | `GET` | `/api/vcs/branch` | `vcs.branch.list` | Change | Singular collection path and normalized operation ID. | -| [x] 113 | `GET` | `/api/vcs/diff` | `vcs.diff` | Keep | Existing working, branch, and committed comparison modes retained. | - -## Group 9: PTYs, persistent terminals, and shells - -**Endpoints:** 24 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 114 | `GET` | `/api/pty` | `pty.list` | Keep | PTY endpoints reviewed together and retained. | -| [x] 115 | `POST` | `/api/pty` | `pty.create` | Keep | PTY endpoints reviewed together and retained. | -| [x] 116 | `GET` | `/api/pty/{ptyID}` | `pty.get` | Keep | PTY endpoints reviewed together and retained. | -| [x] 117 | `PUT` | `/api/pty/{ptyID}` | `pty.update` | Keep | PTY endpoints reviewed together and retained. | -| [x] 118 | `DELETE` | `/api/pty/{ptyID}` | `pty.remove` | Keep | PTY endpoints reviewed together and retained. | -| [x] 119 | `POST` | `/api/pty/{ptyID}/connect-token` | `pty.connect.token` | Keep | PTY endpoints reviewed together and retained. | -| [x] 120 | `GET` | `/api/pty/{ptyID}/connect` | `pty.connect` | Keep | PTY endpoints reviewed together and retained. | -| [x] 121 | `GET` | `/api/experimental/session/{sessionID}/terminal/read` | `server.experimental.persistentPty.read` | Experimental-only | Retained outside the stable API commitment. | -| [x] 122 | `GET` | `/api/experimental/session/{sessionID}/terminal` | `server.experimental.persistentPty.list` | Experimental-only | Retained outside the stable API commitment. | -| [x] 123 | `POST` | `/api/experimental/session/{sessionID}/terminal` | `server.experimental.persistentPty.create` | Experimental-only | Retained outside the stable API commitment. | -| [x] 124 | `POST` | `/api/experimental/persistent-pty/shutdown` | `server.experimental.persistentPty.shutdown` | Experimental-only | Retained outside the stable API commitment. | -| [x] 125 | `POST` | `/api/experimental/persistent-pty/handoff` | `server.experimental.persistentPty.handoff` | Experimental-only | Retained outside the stable API commitment. | -| [x] 126 | `GET` | `/api/experimental/persistent-pty/{ptyID}` | `server.experimental.persistentPty.get` | Experimental-only | Retained outside the stable API commitment. | -| [x] 127 | `PUT` | `/api/experimental/persistent-pty/{ptyID}` | `server.experimental.persistentPty.update` | Experimental-only | Retained outside the stable API commitment. | -| [x] 128 | `DELETE` | `/api/experimental/persistent-pty/{ptyID}` | `server.experimental.persistentPty.remove` | Experimental-only | Retained outside the stable API commitment. | -| [x] 129 | `GET` | `/api/experimental/persistent-pty/{ptyID}/snapshot` | `server.experimental.persistentPty.snapshot` | Experimental-only | Retained outside the stable API commitment. | -| [x] 130 | `POST` | `/api/experimental/persistent-pty/{ptyID}/connect-token` | `server.experimental.persistentPty.connectToken` | Experimental-only | Retained outside the stable API commitment. | -| [x] 131 | `GET` | `/api/experimental/persistent-pty/{ptyID}/connect` | `persistentPty.connect` | Experimental-only | Retained outside the stable API commitment. | -| [x] 132 | `GET` | `/api/shell` | `shell.list` | Change | Stable shell inventory retained; numeric timestamps documented as epoch milliseconds. | -| [x] 133 | `POST` | `/api/shell` | `shell.create` | Change | Timeout is optional and defaults to zero; caller metadata retained. | -| [x] 134 | `GET` | `/api/shell/{id}` | `shell.get` | Keep | Specific running or retained shell read retained. | -| [x] 135 | `DELETE` | `/api/shell/{id}` | `shell.remove` | Change | Shell deletion is idempotent and returns `204` when already absent. | -| [x] 136 | — | — | — | Remove | Timeout mutation remains an internal Core shell operation. | -| [x] 137 | `GET` | `/api/shell/{id}/output` | `shell.output` | Keep | Existing byte-cursor text output paging retained. | - -## Group 10: Events, RPC, and experimental operations - -**Endpoints:** 6 - -| Done | Method | Path | Operation ID | Decision | Notes | -|---|---|---|---|---|---| -| [x] 138 | `POST` | `/api/experimental/generate` | `experimental.generate.text` | Experimental-only | Stateless generation retained alongside session generation. | -| [x] 139 | `POST` | `/api/rpc/{rpcID}/{method}` | `rpc.call` | Keep | Generic typed-error plugin RPC transport retained. | -| [x] 140 | `GET` | `/api/event` | `event.subscribe` | Keep | Unified native and dynamic plugin event stream retained. | -| [x] 141 | `GET` | `/api/debug/location` | `debug.location.list` | Keep | Loaded-location debug inventory retained. | -| [x] 142 | `DELETE` | `/api/debug/location` | `debug.location.evict` | Keep | Idempotent loaded-location eviction retained. | -| [x] 143 | `GET` | `/api/experimental/migration/v1` | `experimental.migration.v1.status` | Experimental-only | Retained outside the stable API commitment. | diff --git a/packages/plugin/src/effect/PLAN.md b/packages/plugin/src/effect/PLAN.md deleted file mode 100644 index 30c27a84dad..00000000000 --- a/packages/plugin/src/effect/PLAN.md +++ /dev/null @@ -1,515 +0,0 @@ -# V2 Plugin System Implementation Plan - -## Status - -This document describes the agreed target design for the V2 plugin system. It is an implementation plan, not documentation for the current API. - -## Goals - -- Internal and external plugins use the same public plugin API. -- Effect plugins import `@opencode/plugin/effect`, not `@opencode/core`. -- Public domain values use generated `@opencode/sdk` types. -- Core may retain branded IDs, decoded Effect schemas, and internal service types. -- Plugins may register replayable domain transforms and runtime hooks imperatively during setup. -- Registrations are scoped, independently disposable, ordered, and removable. -- Dynamic sources such as models.dev, config files, and skill directories can rebuild one domain without reloading the entire Location. -- The initial implementation covers the Effect API. A Promise API will be designed afterward as a wrapper over the same capabilities. - -## Authoring Model - -A plugin setup effect receives `PluginHost` and imperatively registers transforms and hooks. - -```ts -export const Plugin = define({ - id: "example", - effect: (ctx) => - Effect.gen(function* () { - yield* ctx.agent.transform( - Effect.fn(function* (agent) { - agent.update("reviewer", (item) => { - item.description = "Reviews code for regressions" - item.mode = "subagent" - }) - }), - ) - - yield* ctx.tool.hook( - "execute.before", - Effect.fn(function* (event) { - event.args.update(sanitizeArgs) - }), - ) - }), -}) -``` - -Plugin setup does not return hooks. - -## Public Naming - -Settled names: - -- Replayable domain registration: `transform` -- Explicit domain replay: `rebuild` -- Runtime callback registration: `hook` -- Registration cleanup: `dispose` -- Event domain: singular `event` -- Other domains are singular: `agent`, `command`, `integration`, `reference`, `session`, `skill`, and `tool`; `catalog` remains `catalog` -- Hook names use dotted lifecycle names such as `"execute.before"` and `"execute.after"` - -## Transform API - -Each transformable domain exposes: - -```ts -interface TransformDomain { - transform(callback: (editor: Editor) => Effect.Effect): Effect.Effect - - rebuild(): Effect.Effect -} -``` - -The actual callback may be represented with the project's normal `Effect.fn` style. - -```ts -const registration = - yield * - ctx.catalog.transform( - Effect.fn(function* (catalog) { - const integration = yield* ctx.integration.get("anthropic") - if (!integration) return - - catalog.provider.update("anthropic", (provider) => { - provider.name = "Anthropic" - }) - }), - ) -``` - -Transforms may perform arbitrary Effects, including reads from other PluginHost services, filesystem I/O, and network I/O. Reads from another domain observe that domain's latest committed state. - -Transforms have no typed error channel. Unexpected failures are defects. - -## Transform Semantics - -- Every call to `transform()` creates an independent registration. -- Multiple transforms from one plugin and domain are allowed. -- Transform order is plugin registration order, then transform registration order within the plugin. -- A transform is automatically removed when its registration scope closes. -- `Registration.dispose` removes it early and is idempotent. -- Registering or disposing a transform automatically rebuilds its domain. -- During bulk plugin boot, automatic rebuilds are deferred and each affected domain is rebuilt once after the batch. -- `rebuild()` waits until replay and finalization complete. -- `rebuild()` always replays every active transform for the domain. -- Rebuilds are serialized and coalesced. Calls arriving during an active rebuild schedule at most one additional rebuild. -- A rebuild captures its registration list at the start. Concurrent registration changes affect the next rebuild. -- Transforms may not register or dispose transforms while replaying. Such changes are rejected or deferred by the runtime. -- Calling `rebuild()` for the currently rebuilding domain from one of its transforms is rejected. -- Rebuilding another domain from a transform is deferred until the current transform finishes. - -## Registration API - -Transforms and runtime hooks return the same Effect registration type. - -```ts -interface Registration { - readonly dispose: Effect.Effect -} -``` - -Registration behavior: - -- Automatically attached to the current `Scope.Scope` -- Explicitly disposable before scope closure -- Disposal affects future replays or invocations -- An in-flight rebuild or hook invocation uses the registration snapshot captured when it started and is allowed to finish - -## Runtime Hook API - -Domains expose runtime interception through `hook()`. - -```ts -const registration = - yield * - ctx.tool.hook( - "execute.before", - Effect.fn(function* (event) { - event.args.update(sanitizeArgs) - }), - ) -``` - -Runtime hook behavior: - -- Multiple registrations for the same hook are allowed. -- Hooks run sequentially in plugin and registration order. -- Later hooks observe mutations made by earlier hooks. -- Hook registration is scope-owned and independently disposable. -- Disposal affects future invocations; an in-flight invocation finishes using its captured registration snapshot. -- Runtime hooks are not replayed during domain rebuilds. -- Runtime hook callbacks have no typed error channel. - -## Hook Contexts - -Each hook receives one purpose-built context object rather than separate input/output parameters. - -```ts -ctx.tool.hook("execute.before", (event) => { - event.args.update((args) => ({ - ...args, - timeout: 30, - })) -}) -``` - -Hook context objects may contain: - -- Readonly SDK-typed operation data -- Purpose-built methods for allowed mutations -- Capability methods where the operation requires more than field assignment - -They must not expose core editors or unrestricted internal objects. - -## Domain Transforms Versus Runtime Hooks - -Both use the same low-level scoped registration registry, but consumers invoke them differently. - -```ts -ctx.tool.transform(...) // replayed to build effective tool registry state -ctx.tool.hook(...) // invoked at a live tool operation boundary -``` - -The shared low-level machinery owns registration order, scope cleanup, disposal, and snapshots. Each domain owns when its transforms or runtime hooks execute. - -## Event API - -The Effect API exposes the existing event system as typed streams using generated SDK event discriminants. - -```ts -ctx.event.subscribe("catalog.updated") -// Stream.Stream -``` - -Example: - -```ts -yield * - ctx.event.subscribe("catalog.updated").pipe( - Stream.runForEach(() => ctx.agent.rebuild()), - Effect.forkScoped, - ) -``` - -The plugin package derives event payload types from the generated SDK `Event` union: - -```ts -type EventMap = { - [Item in Event as Item["type"]]: Item -} -``` - -Core resolves the public event type string to its internal event definition and delegates to `Event.Service.subscribe`. - -## Domain State Model - -Each transformable core service continues to own: - -- Base state -- Effective committed state -- Editor creation -- Ordered transform registrations for that domain -- Rebuild serialization and coalescing -- Core finalization -- Commit and post-commit events - -The initial implementation should evolve the existing generic `State` helper rather than create a central cross-domain state manager. - -```text -base state -→ replay active transforms in order -→ core domain finalization -→ commit effective state -→ publish updated event -``` - -No cross-domain transform or transaction API is included. - -## Finalization - -Each domain has one plugin transform phase followed by core finalization. - -Core finalization is for invariants and materialization, not plugin extension behavior. - -Examples: - -- Catalog policy filtering and validation -- Reference repository materialization -- Integration connection projection -- Index construction -- Post-commit update events - -Finalizers should distinguish pre-commit work from post-commit notification. Update events should publish after the new state is visible. - -## Plugin Order - -The default distribution uses an opinionated internal order: - -```text -1. Built-in agents, commands, and skills -2. Base data sources such as models.dev -3. Configuration projections -4. Provider-specific normalization and authentication -5. External user plugins -6. Core domain finalization -``` - -For catalog transforms: - -```text -models.dev -→ config provider overrides -→ built-in provider normalization -→ user catalog transforms -→ catalog finalization -``` - -This replaces the current distinction between setup-installed State transforms and catalog hooks invoked from the catalog finalizer. - -Replacing a plugin with the same ID retains its existing order position. The old plugin is disabled before the replacement setup starts. - -## Boot Batching - -Plugin boot runs in an internal registration batch. - -```text -begin batch -→ initialize plugins sequentially -→ register transforms and hooks -→ collect affected domains -→ rebuild each affected domain once -→ end batch -``` - -Registration itself is not staged per plugin. If setup fails, closing the plugin's child scope removes every registration made before the failure. A replacement then retries the previous definition; if that setup also fails, the plugin remains inactive. - -Outside a batch, transform registration and disposal rebuild immediately. - -## Models.dev Example - -Models.dev performs effectful reads directly from its transforms and rebuilds affected domains after refresh. - -```ts -export const ModelsDevPlugin = define({ - id: "models-dev", - effect: (ctx) => - Effect.gen(function* () { - const modelsDev = yield* ModelsDev.Service - const event = yield* Event.Service - - yield* ctx.integration.transform( - Effect.fn(function* (integration) { - const data = yield* modelsDev.get() - applyIntegrations(data, integration) - }), - ) - - yield* ctx.catalog.transform( - Effect.fn(function* (catalog) { - const data = yield* modelsDev.get() - applyCatalog(data, catalog) - }), - ) - - yield* event.subscribe(ModelsDev.Event.Refreshed).pipe( - Stream.runForEach( - Effect.fn(function* () { - yield* ctx.integration.rebuild() - yield* ctx.catalog.rebuild() - }), - ), - Effect.forkScoped({ startImmediately: true }), - ) - }), -}) -``` - -The two domains rebuild sequentially. This plan does not add a cross-domain atomic transaction. - -## Config Watcher Example - -```ts -export const ConfigPlugin = define({ - id: "config", - effect: (ctx) => - Effect.gen(function* () { - const config = yield* ConfigSource.Service - - yield* ctx.agent.transform( - Effect.fn(function* (agent) { - applyAgentConfig(yield* config.get(), agent) - }), - ) - - yield* ctx.command.transform( - Effect.fn(function* (command) { - applyCommandConfig(yield* config.get(), command) - }), - ) - - yield* config.changes.pipe( - Stream.runForEach( - Effect.fn(function* () { - yield* ctx.agent.rebuild() - yield* ctx.command.rebuild() - }), - ), - Effect.forkScoped, - ) - }), -}) -``` - -## Cross-Domain Read Example - -A transform may read another committed service. It must still arrange for its own domain to rebuild when that dependency changes. - -```ts -export const AnthropicAgentPlugin = define({ - id: "anthropic-agent", - effect: (ctx) => - Effect.gen(function* () { - yield* ctx.agent.transform( - Effect.fn(function* (agent) { - const providers = yield* ctx.catalog.provider.list() - if (!providers.some((provider) => provider.id === "anthropic")) return - - agent.update("anthropic-reviewer", (item) => { - item.description = "Reviews code using Anthropic" - item.mode = "subagent" - item.model = { - providerID: "anthropic", - id: "claude-sonnet", - } - }) - }), - ) - - yield* ctx.event.subscribe("catalog.updated").pipe( - Stream.runForEach(() => ctx.agent.rebuild()), - Effect.forkScoped, - ) - }), -}) -``` - -The runtime does not infer cross-domain dependencies. - -## Embedding API Compatibility - -The imperative registration model maps naturally to a future application embedding API: - -```ts -const registration = oc.agent.transform((agent) => { - agent.update("reviewer", configureReviewer) -}) - -registration.dispose() -``` - -An application registration is stored as an application-level plugin registration. It attaches to every current Location and is installed during future Location boot. Disposal removes all current attachments and prevents future attachment. - -The Effect implementation remains the canonical runtime. Promise and embedding wrappers are deferred until after the Effect API is stable. - -## Migration Plan - -### 1. Define Public Contracts - -- Define `PluginHost` domain capabilities in `@opencode/plugin/effect`. -- Define SDK-typed editors for agent, catalog, command, integration, reference, skill, and tool. -- Define typed runtime hook maps per domain. -- Define `Registration`. -- Define typed `event.subscribe(type)`. - -### 2. Generalize Registration Machinery - -- Add one low-level scoped registration registry used by transforms and runtime hooks. -- Preserve plugin order and registration order. -- Support idempotent disposal and registration snapshots. -- Retain plugin position during same-ID replacement. - -### 3. Evolve State - -- Replace the current returned transform-slot updater with direct `transform(callback)` registration. -- Support Effectful callbacks. -- Add public `rebuild()`. -- Add rebuild serialization and coalescing. -- Add boot batching that defers automatic rebuilds. -- Move update event publication after commit. - -### 4. Expand Domain Transform Hooks - -- Agent -- Catalog -- Command -- Integration -- Reference -- Skill -- Tool - -### 5. Migrate Existing Plugins - -- Built-in agent transform -- Built-in command transform -- Built-in skill transform -- Models.dev catalog and integration transforms -- Config transforms -- OpenAI integration transform -- Provider catalog transforms - -### 6. Migrate Runtime Hooks - -- AI SDK resolution -- Language model resolution -- Tool execution hooks -- Session prompt/context hooks as required - -### 7. Remove Returned Hooks - -- Remove `HookFunctions` as the plugin setup return value. -- Remove catalog's special finalizer-triggered plugin hook path. -- Remove `plugin.added` catalog mutation handling. -- Make add/remove/replacement rely on scoped registration and domain rebuilds. - -### 8. Add Event Adapter - -- Build the SDK event discriminant map. -- Resolve public type strings to internal Event definitions. -- Return typed Effect streams. - -### 9. Verification - -- Transform order is deterministic. -- Multiple transforms per plugin/domain compose. -- Registration and disposal rebuild automatically outside boot batches. -- Boot performs one rebuild per affected domain. -- Plugin setup failure removes prior registrations. -- Same-ID replacement retains order and disables the old plugin first. -- Rebuilds serialize and coalesce. -- Registration changes during replay affect the next rebuild. -- Same-domain recursive rebuild is rejected. -- Cross-domain rebuild requests from transforms are deferred. -- Hook execution is sequential and snapshot-based. -- Models.dev refresh replays config and provider transforms. -- Config and skill watcher refreshes remove stale entries. -- Plugin removal restores prior effective state. -- Events observe newly committed state. - -## Deferred Decisions - -- Promise API shape -- Typed error model -- Transform timeouts -- Cross-domain atomic rebuilds -- Automatic dependency tracking -- Whole-Location generation reload -- Exact editors and runtime hooks not required by current plugins diff --git a/perf/test-suite.md b/perf/test-suite.md deleted file mode 100644 index 1d88d790908..00000000000 --- a/perf/test-suite.md +++ /dev/null @@ -1,145 +0,0 @@ -# Test Suite Speed - -## Goal - -Speed up the `packages/opencode` test suite without reducing coverage or hiding failures. - -## Benchmark Command - -Run from `packages/opencode`: - -```sh -bun run bench:test -``` - -The full-suite benchmark defaults to one measured run. Use repeated runs only after a targeted win: - -```sh -BENCH_WARMUPS=1 BENCH_RUNS=3 bun run bench:test -``` - -To identify slow files, run: - -```sh -bun run profile:test -``` - -Scope it while exploring: - -```sh -TEST_PROFILE_GLOB='test/server/**/*.test.ts' bun run profile:test -TEST_PROFILE_LIMIT=20 bun run profile:test -``` - -## Primary Metric - -`METRIC test_suite_seconds=` - -## Secondary Metrics - -`test_suite_best_seconds`, `test_suite_worst_seconds`, failures, and noisy spread. - -For profiling: `slowest_test_file_seconds` and the slowest file list. - -## Files In Scope - -`packages/opencode/test/**`, test fixtures, package test scripts, and implementation setup paths only when a benchmarked bottleneck points there. - -## Signals To Watch - -Repeated setup work, long sleeps/timeouts, serial integration tests, filesystem/database fixture costs, and broad test globs pulling unrelated work. - -## Hypothesis Loop - -| Hypothesis | Change | Before | After | Decision | Notes | -| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | --------- | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | -| Repeated full-suite runs are too expensive for discovery | Switched full-suite benchmark to one run and added per-file profiler | ~250s/run | pending | keep | Bun has no slowest-test reporter in this version; profile files directly. | -| Plugin install concurrency test spends time spawning more workers than needed to exercise lock contention | Reduced worker counts from 12/10/8 to 6/6/5; kept `holdMs: 30` | 7.800s | 6.204s | keep | Median from 3 targeted runs; still covers concurrent cross-process writes to server, server+tui, and existing json config. | -| `httpapi-listen` PTY route tests pay for git repositories they do not assert on | Removed `git: true` from temp dirs while keeping config setup | 10.554s | 7.818s | keep | Median from 3 targeted runs; HTTP routes, tickets, websocket upgrade, restart, and no-auth paths still pass. | -| `workspace.waitForSync` timeout test waits the full production timeout | Added optional timeout parameter defaulting to production timeout; timeout test uses 25ms | 12.949s | 8.305s | keep | Median from 3 targeted runs; production callers keep the 5000ms default. | -| `config.test` waits after dependencies even though `.gitignore` is written synchronously | Removed obsolete 1000ms sleep from writable `OPENCODE_CONFIG_DIR` test | 10.270s | 9.433s | keep | Median from 5 targeted runs because one run was noisy; simpler test and no fixed sleep. | -| SDK parity helpers create git repos for tests that only need files/config/session state | Changed `withProject` default to no git; explicit git init test still opts into no-git fixture | 8.011s | 5.180s | keep | Median from 5 targeted runs because first run was cold/noisy. | -| Provider plugin filter test waits on plugin dependency readiness setup | Marked local plugin dependencies ready using the existing fixture helper | 7.543s | 6.366s | keep | Median from 3 targeted runs; matches neighboring plugin provider test setup. | -| HTTP provider tests generate local plugins without dependency-ready fixture state | Marked generated `.opencode` plugin fixtures dependency-ready | 7.905s | 2.980s | keep | Median from 3 targeted runs; avoids unrelated plugin dependency setup in route tests. | -| TUI plugin lifecycle timeout coverage waits the full production cleanup timeout | Added optional runtime dispose timeout override and used 25ms in the timeout test | 7.330s | 1.507s | keep | Median from 3 targeted runs; production default remains 5000ms. | -| Skill tool test initializes git even though it only reads local skill files | Removed `git: true` from the temporary directory fixture | 2.320s | 1.425s | keep | Single targeted rerun; still exercises skill discovery, permission request, and bundled file output. | -| Prompt shell semantics tests initialize git though they only assert shell/session behavior | Removed `git: true` from shell-focused prompt fixtures while preserving config setup | 26.930s | 23.400s | keep | Three targeted reruns passed after the change: 23.80s, 23.55s, 23.40s. | -| Remaining prompt behavior tests mostly do not require repository state | Removed git setup from safe loop/reference/error fixtures; restored shell queue/cancel cases | 23.400s | 19.610s | keep | Safety review found shell runner readiness depends on git-backed setup in several tests; current single rerun passes. | -| Session processor effect tests do not require repository state | Removed git setup from all processor-effect temp server fixtures | 12.500s | 9.230s | keep | Two targeted reruns passed after the change: 9.61s, 9.23s. | -| HTTP listen PTY ticket tests restart the same listener topology twice | Folded directory-scoped ticket regression into the broader unsafe-ticket test | 7.051s | 6.170s | keep | Two targeted reruns passed after the change: 6.76s, 6.17s; still covers mint failure and successful same-directory upgrade. | -| File watcher readiness can write before async native subscriptions are active | Retried short readiness writes and accepted symlink-realpath HEAD events | failed | 4.62s | keep | Three sequential focused watcher runs passed: 4.62s, 4.57s, 4.64s; full suite no longer failed in `watcher.test.ts`. | -| First provider config/env/filtering block can use Effect-aware instance fixtures | Migrated six `tmpdir` + `withTestInstance` cases to `it.instance` | 6.06s | 6.07s | keep | Neutral timing, but removes manual config file writes and instance plumbing; use as the pattern for later provider slices. | -| Custom provider/model config cases can use Effect-aware instance fixtures | Migrated three more config-heavy provider cases to `it.instance` | 6.07s | 6.12s | keep | Neutral timing within noise, but continues removing manual config file writes on top of the first provider fixture PR. | -| Provider env precedence and model lookup cases can use Effect-aware instance fixtures | Migrated four more provider lookup/default-model cases to `it.instance` | 6.12s | 6.36s | keep | Noisy 5-run median; kept as a small stacked cleanup slice but do not claim speedup from this migration. | -| Simple config load cases can use Effect-aware instance fixtures | Migrated JSON, shell, formatter, and lsp config load cases to `it.instance` | 14.18s | 3.93s | keep | Three-run medians before/after; removes manual `tmpdir` + `withTestInstance` setup from the first simple config block. | -| Config template, file include, and simple agent cases can use Effect-aware instance fixtures | Migrated JSONC, env/file substitution, invalid config, and agent config cases to `it.instance` | 1.87s | 1.90s | keep | Stacked on the first config slice; neutral timing but removes more manual `tmpdir` + instance plumbing. | -| Agent option, command, and legacy migration config cases can use Effect-aware instance fixtures | Migrated agent variant, command, autoshare, and mode migration cases to `it.instance` | 1.90s | 1.83s | keep | Stacked on the config template slice; small neutral-to-positive timing and less manual setup. | -| Local config update and directory cases can use Effect-aware instance fixtures | Migrated local `update` and `directories` cases to `it.instance` | 1.77s | 1.71s | keep | Three-run medians; small positive/neutral timing, removes manual instance plumbing, and eliminates one existing unsafe cast. | -| `.opencode` agent and command file-loading cases can use Effect-aware instance fixtures | Migrated singular/plural agent and command markdown fixture cases to `it.instance` | 7.21s | 1.87s | keep | Parent baseline was noisy (7.42, 7.21, 2.83); after runs were stable at 1.87, 1.98, 1.83. Keep as cleanup with no broad claim. | -| Legacy tools and permission-order config cases can use Effect-aware instance fixtures | Migrated legacy `tools` migration and permission order cases to `it.instance` | 1.87s | 1.87s | keep | Neutral timing; removes more manual temp-instance plumbing from legacy config migration coverage. | -| Remaining simple config load cases can use Effect-aware instance fixtures | Migrated default config load and legacy TUI-key cases to `it.instance` | 7.78s | 6.39s | keep | Single baseline before edit; after median from three sequential reruns (5.76, 6.39, 6.53). Keep as cleanup with cautious timing. | -| Managed settings config cases can use Effect-aware instance fixtures | Migrated managed override and missing-managed-file cases to `it.instance` | 2.40s | 1.76s | keep | Single baseline before edit; after median from three sequential reruns (1.75, 1.76, 1.80). | -| Local plugin and subagent config fixtures can use Effect-aware instance fixtures | Migrated scoped npm plugin and custom subagent markdown cases to `it.instance` | 2.37s | 1.67s | keep | Single baseline before edit; after median from three sequential reruns (1.66, 1.67, 1.67). | -| MCP merge config cases can use Effect-aware instance fixtures | Migrated three MCP merge/override cases to `it.instance` | 1.98s | 1.95s | keep | Neutral timing within noise; removes manual `tmpdir` + `withTestInstance` setup from isolated filesystem-only config cases. | -| Remaining legacy tools config cases can use Effect-aware instance fixtures | Migrated allow/deny legacy `tools` permission cases to `it.instance` | 2.65s | 1.90s | keep | Single baseline before edit; after median from three sequential reruns (2.58, 1.90, 1.90). | -| Oversized snapshot batch tests only need to cross the 100-file boundary | Reduced large diff/revert fixture sizes while keeping each case above the batch boundary | 4.32s | 3.66s | keep | Three affected snapshot tests; after median from three reruns (4.32, 3.66, 3.66) while still crossing the 100-file boundary. | -| Prompt tests without LLM calls do not need the test LLM server | Added a no-server runner and moved obvious non-LLM prompt/shell cases to it | 25.41s | 21.03s | keep | Full prompt file after simplify pass median from three reruns (20.66, 21.03, 21.64); LLM-backed tests stay on original runner. | -| CLI run subprocess cases can run independently | Marked `run-process.test.ts` subprocess cases concurrent | 11.87s | 4.13s | keep | Newest-dev single baseline; after median from three reruns (4.13, 4.17, 4.11). Each case has an isolated temp home and LLM port. | -| Snapshot initialization does not need to commit seeded files in the source repo | Removed extra `git add`/`commit` from the snapshot test `initialize()` helper | 22.22s | 20.23s | keep | Newest-dev single baseline; after median from three reruns (20.23, 22.59, 20.11). Fixture still creates a git repo root commit. | -| Processor AI SDK tool-call case does not assert git behavior | Removed `git: true` from the non-native tool-call processor test | 10.22s | 9.48s | keep | Newest-dev single baseline; full-file after median from three reruns (9.48, 9.60, 9.36); focused case passes in 1.39s. | - -## Profiling Results - -Command shape: - -```sh -TEST_PROFILE_GLOB='test//**/*.test.ts' TEST_PROFILE_TOP=15 bun run profile:test -``` - -Initial slowest files observed during discovery: - -| File | Seconds | Scope | -| ----------------------------------------- | ------: | ------------- | -| `test/config/config.test.ts` | 23.546 | config | -| `test/provider/provider.test.ts` | 18.747 | provider | -| `test/control-plane/workspace.test.ts` | 16.447 | control-plane | -| `test/plugin/install-concurrency.test.ts` | 14.804 | plugin | -| `test/server/httpapi-cors.test.ts` | 14.620 | server | -| `test/server/httpapi-listen.test.ts` | 10.073 | server | -| `test/server/httpapi-sdk.test.ts` | 8.661 | server | -| `test/server/httpapi-provider.test.ts` | 7.905 | server | -| `test/cli/tui/plugin-lifecycle.test.ts` | 7.330 | cli/tui | -| `test/file/index.test.ts` | 7.214 | file | - -This table is historical profiling input, not the current ranking after kept changes. - -Targeted 3-run baselines: - -| File | Runs | Median | Notes | -| ----------------------------------------- | ---------------------- | -----: | ---------------------------------------------------------------------------- | -| `test/control-plane/workspace.test.ts` | 12.949, 12.949, 12.773 | 12.949 | Stable slow target. | -| `test/server/httpapi-listen.test.ts` | 10.554, 10.631, 10.479 | 10.554 | Stable slow target; WebSocket/listener lifecycle. | -| `test/config/config.test.ts` | 10.270, 9.042, 10.737 | 10.270 | Large serial file; initial 23s was mixed-scope contention/noise. | -| `test/server/httpapi-sdk.test.ts` | 7.600, 8.011, 8.035 | 8.011 | Stable slow target. | -| `test/plugin/install-concurrency.test.ts` | 7.949, 7.800, 7.712 | 7.800 | Stable slow target; many subprocesses. | -| `test/provider/provider.test.ts` | 8.323, 7.543, 7.474 | 7.543 | Large serial file. | -| `test/server/httpapi-cors.test.ts` | 2.621, 1.682, 1.518 | 1.682 | Not a standalone top target; initial 14s was mixed-scope noise/order effect. | - -Full-suite sanity checks: - -| Command | Result | Notes | -| -------------------- | -------: | ----------------------------------------------------------------------------------------------------------------------------------------------- | -| `bun run bench:test` | 225.069s | Before continuing prompt/session work. | -| `bun run bench:test` | 186.729s | After prompt, processor, and PTY wins before safety review restores. | -| `bun run bench:test` | 202.317s | After restoring prompt shell coverage and SDK VCS parity coverage. | -| `bun run bench:test` | failed | Watcher blocker cleared; current run later failed in focused-passing `tool/skill.test.ts` and prompt shell timeout cases under full-suite load. | - -## Dead Ends - -| Hypothesis | Change Tried | Before | After | Decision | Notes | -| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -----: | -----: | -------- | --------------------------------------------------------------------------------------------- | -| `file/index.test.ts` pays unnecessary per-test global instance cleanup | Removed `afterEach(disposeAllInstances)` while keeping the explicit disposal test import | 5.262s | 5.089s | discard | Improvement was within noise and the cleanup is a safety guard for many instance-state tests. | -| Socket reset retry test can shorten its idle-timeout path | Reduced Bun server idle timeout and tried forced server close | 16.46s | failed | discard | Shorter idle timeout changed the error shape; forced close hung. Keep the real socket reset. | -| `tool/webfetch` can avoid per-test instance setup | Switched local HTTP tests from `it.instance` to `it.live` | 1.219s | failed | discard | Tool execution reads instance-local agent state, so the temp instance is required. | -| LSP client interop tests can shorten coarse request-handling sleeps | Reduced fixed post-notification waits from 100ms to 10ms | 4.270s | 4.740s | discard | First run improved to 3.870s but verification was slower than baseline; not a clear win. | -| Config content env cases can use Effect-aware instance fixtures | Migrated two `OPENCODE_CONFIG_CONTENT` token substitution cases to `it.instance` | 1.95s | 2.06s | discard | Passing but not neutral-or-better in focused reruns; keep existing explicit env cleanup. |