Skip to content

Add controlled-session framed protocol - #17

Open
omry wants to merge 1 commit into
pr16from
pr17
Open

Add controlled-session framed protocol#17
omry wants to merge 1 commit into
pr16from
pr17

Conversation

@omry

@omry omry commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Define shared lifecycle result and status types, then add the versioned typed frame codec used between the host supervisor and controller. Preserve terminal bytes exactly while validating structured event payloads, frame direction, dimensions, endpoint identifiers, result semantics, duplicate JSON fields, protocol version, and bounded payload length.

Add round-trip, malformed-frame, direction-confusion, duplicate-field, binary-data, and fuzz-seed coverage.


Stack created with Sapling. Best reviewed with ReviewStack.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the controlled-session V1 wire protocol layer for host↔controller communication, including shared lifecycle/result models, a versioned framed codec, and strict JSON validation to prevent malformed or ambiguous payloads.

Changes:

  • Introduces V1 lifecycle/result/status model types and validation helpers.
  • Implements a versioned framed transport with magic/version/kind/length header, bounded payloads, and strict decoding (including duplicate-field rejection).
  • Adds unit tests for round-trips and malformed frames plus fuzz coverage for request/event decoding.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/controlledsession/protocol.go Defines the V1 framing format, request/event encoding/decoding, and strict JSON validation.
internal/controlledsession/protocol_test.go Adds round-trip, malformed-frame, duplicate-field, and fuzz-seed coverage for the protocol codec.
internal/controlledsession/model.go Introduces V1 termination/result/status types and validates cross-field semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/controlledsession/protocol.go Outdated
Comment on lines +280 to +281
case wireRequestOpenEndpointV1:
return RequestV1{Kind: RequestOpenEndpointV1, EndpointID: string(payload)}, nil

omry commented Aug 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 970425ae12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread internal/controlledsession/model.go Outdated
Comment on lines +84 to +87
if err := validateTerminalControllerStatusV1(result.ControllerStatus); err != nil {
return err
}
return validateCleanupResultV1(result.CleanupStatus, result.RecoveryAction)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject contradictory terminal results

When a malformed peer or state-machine bug produces a result such as cause: controller-complete with controller_status: lost, or cause: application-exit with an unknown application status, this validator accepts it because it checks each field independently. Since the cause is the authoritative latched outcome, accepting causally contradictory combinations can make downstream code interpret a failed or incomplete session as successful; validate the cause/status relationships before accepting or emitting the terminal event.

Useful? React with 👍 / 👎.

Define the versioned typed frame codec and shared lifecycle result types used between the host supervisor and controller. Give every V1 frame and event an explicit stable wire assignment while preserving terminal bytes exactly and validating structured payloads, direction, dimensions, endpoint identifiers, protocol version, duplicate JSON fields, and bounded payload length.

Treat controller completion as finalization rather than a termination cause, and model bounded workload-output finalization explicitly in the opened contract, events, and final result. Align the controlled-session design and follow-up networking backlog with the temporary coarse lease-network grant and the planned gateway-based direct path.

Add stable-wire, round-trip, malformed-frame, direction-confusion, duplicate-field, binary-data, output-finalization, and fuzz-seed coverage.
@omry

omry commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 2d8112e8e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR reviewed and approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants