Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
Adds a Docker Engine “PTY adapter” for controlled-session workloads, enabling the host to attach to a container’s TTY stream, forward input bytes, resize the PTY via the Engine API, and observe exit status independently. This fits into the controlled-session stack by implementing the workload-side PTY boundary while leaving controller/protocol orchestration for later slices.
Changes:
- Implement Docker Engine attach + resize over local unix/npipe endpoints and a hijacked PTY stream writer.
- Add
DockerWorkloadPTYV1to create an inert workload container, attach before start, start + resize, signal stop, and wait for exit observation. - Add unit + integration coverage for ordering, exact byte preservation, resize, stop behavior, and exit observation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/dockerdeploy/docker_pty_attach.go | Implements Docker Engine HTTP attach/resize over a hijacked local connection and a context-aware write path. |
| internal/dockerdeploy/docker_pty_attach_windows.go | Windows npipe dialing for local Docker endpoints. |
| internal/dockerdeploy/docker_pty_attach_unix.go | Unix socket dialing for local Docker endpoints. |
| internal/dockerdeploy/controlled_session_workload_pty.go | Adds the workload PTY lifecycle wrapper (prepare/attach, start+resize, input, resize, stop, wait). |
| internal/dockerdeploy/controlled_session_workload_pty_test.go | Unit tests for ordering, rollback, cancellation, and exact writes. |
| internal/dockerdeploy/controlled_session_workload_pty_integration_test.go | Docker integration evidence for PTY I/O, resize, Ctrl-C, stop behavior, and exact exit. |
| go.mod | Promotes github.com/Microsoft/go-winio to a direct dependency for Windows dialing. |
| docs/CONTROLLED_SESSION_DESIGN.md | Updates design doc to reflect that the Docker workload PTY adapter slice is now implemented. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func resizeDockerContainerPTYV1( | ||
| ctx context.Context, | ||
| docker CommandSpec, | ||
| container string, | ||
| columns uint32, | ||
| rows uint32, | ||
| timeout time.Duration, | ||
| ) error { | ||
| endpoint, source, err := effectiveDockerEndpointV1(ctx, docker, timeout) | ||
| if err != nil { | ||
| return err | ||
| } |
| func attachDockerContainerPTYV1( | ||
| ctx context.Context, | ||
| docker CommandSpec, | ||
| container string, | ||
| timeout time.Duration, | ||
| ) (dockerPTYAttachmentV1, error) { | ||
| endpoint, source, err := effectiveDockerEndpointV1(ctx, docker, timeout) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
| workload.stateMu.Lock() | ||
| workload.started = true | ||
| workload.stateMu.Unlock() | ||
| go workload.observeExit() | ||
|
|
||
| columns, _ := strconv.ParseUint(workload.plan.InitialColumns, 10, 16) | ||
| rows, _ := strconv.ParseUint(workload.plan.InitialRows, 10, 16) | ||
| if err := workload.resizeLocked(ctx, uint32(columns), uint32(rows)); err != nil { | ||
| return fmt.Errorf("apply initial controlled-session workload PTY dimensions: %w", err) | ||
| } | ||
| return nil |
| The Docker workload PTY adapter is implemented: it creates the frozen | ||
| workload plan inert, establishes the Engine attachment before start, applies | ||
| the initial and later dimensions through the Engine API, preserves exact | ||
| input and output bytes, independently observes the container exit code, and | ||
| exposes graceful and forced stop operations. Controller launch, protocol/PTY |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Stack created with Sapling. Best reviewed with ReviewStack.