| 1 | # Native Runtime attachment |
| 2 | |
| 3 | This narrow `native_runtime_v1` capability extends authenticated local Control. |
| 4 | It does not enable the paused App Server v2 migration or change compatibility |
| 5 | Control's tool-free permissions. It requires an already running captured owner. |
| 6 | |
| 7 | Launch the Desktop-selected executable with: |
| 8 | |
| 9 | ``` |
| 10 | codewhale app-server --stdio --attach-only --native-runtime |
| 11 | ``` |
| 12 | |
| 13 | The first JSONL frame is JSON-RPC 2.0 `runtime/attach`, with an ID and closed |
| 14 | params: `contract_version:1`, `target_id`, positive `selection_revision`, absolute |
| 15 | canonical `workspace`, and `expect_owner` (the existing RuntimeOwnerReceipt). |
| 16 | The acknowledgement echoes all binding fields and |
| 17 | `capabilities:["native_runtime_v1"]`. Next send the existing `initialize` request. |
| 18 | The helper validates its acknowledgement and sends `initialized` to the owner. |
| 19 | No operations are accepted before initialization. EOF detaches observations. |
| 20 | There is no startup fallback or automatic mutation replay. |
| 21 | |
| 22 | Desktop may add `--describe-target` to the same invocation. Its single stdin |
| 23 | request is `runtime/describe-target`, with params `contract_version:1`, |
| 24 | `workspace`, `expected_pid`, `expected_data_dir`, and optional `config_path`. |
| 25 | The process inherits the selected supervisor's captured environment; in |
| 26 | particular CODEWHALE_HOME and CODEWHALE_RUNTIME_DIR select Engine's own endpoint |
| 27 | resolver. `expected_data_dir` is the actual canonical Runtime store directory, |
| 28 | not a hash. The probe authenticates without creating a store and returns |
| 29 | `contract_version`, `workspace`, `expect_owner`, and `capabilities`. Desktop must |
| 30 | recheck the selected supervisor and folder after this asynchronous operation. |
| 31 | No target-record path or credential-bearing descriptor is part of this API. |
| 32 | |
| 33 | The closed request DTOs and method names are owned by |
| 34 | `crates/app-server-protocol/src/runtime.rs` (`NativeRuntimeRequest`). Existing |
| 35 | Runtime results are preserved. Unknown fields and methods are refused. |
| 36 | The connection permits at most 64 concurrent requests and 16 observations, |
| 37 | with bounded 8 MiB frames and output bytes. Partial JSONL input and admitted |
| 38 | request bodies share an 8 MiB byte budget; the existing WebSocket transport |
| 39 | and JSON decoder additionally have finite per-frame buffers. This is a pending |
| 40 | input bound, not a total-process heap limit. A subscription acknowledgement |
| 41 | precedes `runtime/event` notifications carrying the original journal frame. |
| 42 | `stream.end` frames retain their nullable sequence. Unsubscribe only detaches. |
| 43 | Backpressure terminates an observation or closes the channel. Its |
| 44 | `last_sent_sequence` is updated only after a successful writer flush, and is |
| 45 | not an acknowledgement of client processing. Reconnecting |
| 46 | requires a fresh selected receipt and does not replay a mutation. |
| 47 | |
| 48 | Account status is read-only. Account lease/import/logout, configuration writes, |
| 49 | claim, shutdown, arbitrary HTTP/RPC, dynamic tool injection, permission escalation |
| 50 | and user-input submission are not exposed. Pending interactive input remains |
| 51 | visible in Runtime thread details and can be answered in Desktop. Native Chrome |
| 52 | message chunking and target-record file validation belong to the native-host |
| 53 | installer/adapter; this Engine surface does not authorize executing a binary |
| 54 | path from an unvalidated target record. Cross-platform source support does not |
| 55 | by itself demonstrate installed Windows ACL or named-pipe acceptance. |
| 56 |