Skip to content

Fail closed when session watchdog exits - #35

Open
omry wants to merge 28 commits into
mainfrom
pr35
Open

Fail closed when session watchdog exits#35
omry wants to merge 28 commits into
mainfrom
pr35

Conversation

@omry

@omry omry commented Aug 10, 2026

Copy link
Copy Markdown
Owner

omry added 6 commits August 5, 2026 02:47
Route persistent workloads and transient application commands through one validated sandbox plan. Rename the system-install identity field to account and cover renderer parity and schema migration.
@omry
omry changed the base branch from main to pr34 August 10, 2026 03:46
@omry

omry commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4c093f5a08

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

@omry
omry changed the base branch from pr34 to main August 10, 2026 04:09
omry added 19 commits August 10, 2026 18:41
Reject runtime host sources that resolve to the filesystem root or protected kernel system trees. Use platform-specific filesystem and mount topology identity to catch direct, aliased, and nested kernel-control filesystems while preserving explicit ordinary directory binds with nested application objects.

Reject unsupported remote Docker endpoints before runtime and recovered-container operations, including admission cleanup paths.

Document the narrowed direct-bind security contract, close the corresponding backlog item, and add a security changelog fragment.
Add portable public and local runtime-network controls that default to deny, compile into the locked runtime policy, and grant declared inbound ports only to the persistent workload shape. Classify translation and tunneling ranges conservatively, require both ordinary grants by default, and provide a documented temporary escape hatch for environments that explicitly need the ambiguous class.

Install IPv4 and IPv6 nftables policy through the trusted startup helper, retain declared-only inbound admission even when egress is unrestricted, then irreversibly drop setup capabilities and assume the final application identity for workloads, commands, shells, lifecycle actions, and private-environment execution. Preserve declared endpoint traffic, constrain Docker DNS, admit only established responses plus related ICMP network errors, and surface setup failures with their backend diagnostics.

Add unit and live Docker coverage for all policy combinations, public exceptions, ambiguous ranges, declared and undeclared inbound ports, root and non-root execution, DNS, endpoint persistence, and transient isolation. Run the live policy matrix in CI, document the security boundary and temporary escape hatch, update the deferred gateway backlog, and revise the security changelog fragment.
Add immutable session authorization records that bind opaque handles to exact deployments, generations, builds, admitted runs, container plans, runtime identities, controller operations, and declared endpoints.

Extract the canonical container runtime identity contract so blueprint resolution, application sandbox planning, and controlled sessions share the same portable user, numeric ID, root-group, and supplementary-group validation. Reuse the deployment live-run ID validator instead of defining another controlled-session grammar.

Keep connection ownership and lifetime as non-transferable host lease state: one controller connection owns one admitted live run until disconnect or host cancellation. Document that boundary and prevent authorization digests from implying reconnect or lease extension.

Derive canonical authorization digests and add deterministic handle, shared identity, and adversarial validation coverage.
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.
Add the concurrency-safe host-owned lifecycle machine for preparing, active, terminating, and terminated sessions. Latch the first accepted termination cause, enforce granted controller requests, preserve explicit completion across later disconnects, permit bounded controller finalization after application exit, and prevent terminal status reports from rewriting observed outcomes.

Reject startup failures after controller activation. Ensure host cancellation, runtime-observation loss, and controller-requested termination end a pending controller-finalization wait without rewriting the already-latched cause.

Add lifecycle race, authorization immutability, disconnect, timeout, idempotence, abortive-finalization, startup-boundary, and hostile-result coverage. Clarify controller-requested termination as a distinct design cause.
Add a backend-neutral bridge that dispatches typed controller requests through lifecycle authorization, applies accepted PTY input and resize operations, and forwards exact ordered output with bounded backpressure.

Give validated lifecycle events a separate prioritized write admission path without allowing callers to forge opened or output events. Preserve explicit cancellation, disconnect, and output-finalization diagnostics while leaving lifecycle and resource ownership to the host supervisor.

Cover authorization rejection, binary output, lifecycle priority and cancellation, slow consumers, disconnects, resize, ordinary Ctrl-C, and exact Docker exit behavior with race-enabled unit and live integration tests. Update the controlled-session implementation status.
@omry
omry changed the base branch from main to pr34 August 10, 2026 11:17
@omry
omry marked this pull request as ready for review August 10, 2026 11:17
Copilot AI lite review requested due to automatic review settings August 10, 2026 11:17

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

This PR makes controlled sessions “fail closed” when the cleanup watchdog process exits unexpectedly, distinguishing this from Docker runtime-observation loss and surfacing a dedicated lifecycle cause/observation plus a safe diagnostic.

Changes:

  • Extend the watchdog runtime interface to expose Done(), ExitError(), and Close() so the supervisor can detect and react to premature watchdog exit.
  • Add a new lifecycle observation/cause (cleanup-containment-lost) and update the Docker supervisor to observe watchdog exit both during startup and while active, emitting a bounded diagnostic event when possible.
  • Add/extend unit + integration tests, update design docs, and include a Changie fragment for the behavior change.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/dockerdeploy/controlled_session_watchdog.go Extends watchdog runtime interface for exit observability and explicit closure.
internal/dockerdeploy/controlled_session_watchdog_linux.go Implements watchdog exit tracking (Done/ExitError) and idempotent Close; refactors readiness/teardown coordination.
internal/dockerdeploy/controlled_session_watchdog_integration_linux_test.go Updates integration test to use the new watchdog exit channel/error surface.
internal/dockerdeploy/controlled_session_supervisor.go Observes watchdog exit (startup + active), latches containment-loss observation, emits diagnostic, and adjusts teardown behavior accordingly.
internal/dockerdeploy/controlled_session_supervisor_test.go Adds regression tests for failing closed after watchdog exit (startup + active) and extends fakes to support new watchdog/channel behaviors.
internal/controlledsession/model.go Adds new termination cause constant and validation support.
internal/controlledsession/lifecycle.go Adds new observation kind that latches the cleanup-containment-lost cause.
internal/controlledsession/lifecycle_test.go Adds coverage ensuring the new cause participates correctly in lifecycle behavior and racing.
docs/CONTROLLED_SESSION_DESIGN.md Documents the new containment-loss semantics and diagnostic behavior.
.changes/unreleased/+controlled-session-cleanup-containment-loss.yaml Release note fragment for the user-visible behavior change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@omry

omry commented Aug 10, 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: d6c0fb6361

ℹ️ 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/dockerdeploy/controlled_session_supervisor.go
@omry
omry changed the base branch from pr34 to main August 10, 2026 11:37
@omry

omry commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 492fcbe498

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

@omry

omry commented Aug 10, 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: 492fcbe498

ℹ️ 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/dockerdeploy/runtime_host_preflight.go
@omry

omry commented Aug 10, 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: 492fcbe498

ℹ️ 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/dockerdeploy/controlled_session_watchdog.go Outdated
@omry

omry commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 6bcd565ab0

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

@omry
omry changed the base branch from main to pr34 August 10, 2026 14:02
@omry
omry changed the base branch from pr34 to main August 10, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants