code-mode: expose create and observe operations#29291
Conversation
67fe0dd to
db85bd5
Compare
d573397 to
8fe1bf1
Compare
8fe1bf1 to
b29a55b
Compare
9ab809d to
d969450
Compare
b29a55b to
e81e125
Compare
|
|
||
| #[derive(Debug, Deserialize, PartialEq, Serialize)] | ||
| pub enum WaitOutcome { | ||
| pub enum CellOutcome { |
There was a problem hiding this comment.
This allows impossible wire states such as MissingCell(Yielded) or Completed(Yielded)
Sounds like a design smell
| assert_json_round_trip( | ||
| &CellOutcome::LiveCell(result.clone()), | ||
| json!({ | ||
| "LiveCell": { |
There was a problem hiding this comment.
These exact tests are locking the future wire format to serde's default Rust enum shape ({"LiveCell":{"Result":...}}).
That makes Rust variant names part of the protocol and is awkward to version or implement outside Rust...
e81e125 to
f3f8aa4
Compare
d969450 to
9b1d9b8
Compare
f3f8aa4 to
fbf545e
Compare
9b1d9b8 to
1ad5213
Compare
fbf545e to
bf52c09
Compare
bf52c09 to
4232322
Compare
4ac6daf to
12e7716
Compare
4232322 to
5cc94cd
Compare
12e7716 to
bc923b0
Compare
b3ba157 to
a9ed5af
Compare
a9ed5af to
96581e9
Compare
| ) -> CodeModeSessionResultFuture<'a, ObserveOutcome>; | ||
|
|
||
| fn terminate<'a>(&'a self, cell_id: CellId) -> CodeModeSessionResultFuture<'a, WaitOutcome>; | ||
| fn terminate<'a>( |
There was a problem hiding this comment.
(found by Codex)
terminate has the same ambiguous-response problem as create/observe, but no request identity or replay. Once the host tombstones the cell, a lost response retries as Missing, dropping the terminal content/outcome. Can we make termination replayable too, or retrieve its terminal result through observe?
| } | ||
|
|
||
| impl Drop for InitialObservationGuard { | ||
| fn drop(&mut self) { |
There was a problem hiding this comment.
This records a cancelled observation as a failed, already-ended runtime before terminate has succeeded
Why
Cell admission and observation need separate protocol operations. Returning a started handle plus a second asynchronous response from one
executerequest is awkward across IPC and leaves cancellation ownership unclear.At the wire boundary, each operation also needs its own result union so the serialized type cannot describe outcomes that operation cannot produce. This type narrowing is limited to the protocol/session layer: runtime-owned
CellEvent/PausableCellEventand Core's model/traceRuntimeResponseretain their existing roles.What
execute/waitwith wire-facingcreate_cell(CreateCellRequest)andobserve(ObserveRequest)operations.execandwait; only the host/Core session contract changes.CellIdat admission in this layer.ObserveOutcome:yielded,completed,terminated, ormissing.TerminateOutcome:completed,terminated, ormissing;yieldedis not representable.missingcarries only the requestedCellId.RuntimeResponseafter receipt instead of usingRuntimeResponseas the session return type.Host/Core wire sequence
sequenceDiagram participant Core participant Host Core->>Host: create_cell(CreateCellRequest) Host-->>Core: CellId Core->>Host: observe(ObserveRequest) alt cell yields Host-->>Core: ObserveOutcome::Yielded else cell completes Host-->>Core: ObserveOutcome::Completed else cell is terminated Host-->>Core: ObserveOutcome::Terminated else cell is absent Host-->>Core: ObserveOutcome::Missing end opt initial observe is canceled Core->>Host: terminate(CellId) alt cell completed first Host-->>Core: TerminateOutcome::Completed else termination wins Host-->>Core: TerminateOutcome::Terminated else cell is absent Host-->>Core: TerminateOutcome::Missing end endAll successful payloads above remain wrapped by the session's transport-level
Result<T, String>.Stack boundary
This PR defines the operation split and valid wire outcomes, but does not yet make observation delivery replayable after an ambiguous IPC response. #29397 adds caller-provided request identity and detached, replayable observations.
Validation
just test -p codex-code-modejust test -p codex-code-mode-protocolStack parent: #29403.