Skip to content

fix(docker): re-adopt live sandboxes across gateway restarts via supervisor generation handover - #42

Merged
raghusubramanyam merged 2 commits into
lightforge-mainfrom
fix/gateway-restart-readopt
Nov 26, 2026
Merged

raghusubramanyam merged 2 commits into
lightforge-mainfrom
fix/gateway-restart-readopt

Conversation

@raghusubramanyam

Copy link
Copy Markdown

Summary

If the gateway dies without a graceful shutdown (SIGKILL, host process crash), the Docker sandbox container keeps running. At the next start the gateway replaces the supervisor sidecar (start_sandbox_with_lifecycle_fence -> ensure_control_process_for_container -> spawn_docker_control_process). Before this change, the replacement supervisor could never re-attach to the running boundary. The boundary's 30 s recovery deadline then expired, and it terminated the workload ("sandbox session is terminal").

This PR implements the approved supervisor generation handover. With it, the gateway re-adopts a sandbox across repeated ungraceful restarts: the sandbox id and container stay the same, the workload is not restarted, and sandbox exec keeps working.

Refs aegis-r6ljc; OpenShell half of Connect S5 (re-attach on start). Evidence: lightforgedev/aegis-connect-phoenix#470 (closed as duplicate of r6ljc).

Root cause (layered; each fixed blocker exposed the next)

Base references are at 5d1f63e0.

  1. The boundary pins the first supervisor process. crates/openshell-sandbox-backend/src/sandbox_auth.rs:182-187 (SandboxConnectionRegistry::attach) stores the first SupervisorInstanceId. That id is random per process (crates/openshell-sandbox-backend/src/runtime.rs:1092). Every replacement sidecar was rejected with WrongSupervisorInstance ("sandbox runtime is already bound to another supervisor process", sandbox_auth.rs:342). The client retried every 25 ms (ATTACH_REQUEST_TIMEOUT, runtime.rs:50) until the boundary recovery deadline expired (crates/openshell-sandbox/src/boundary_server.rs:1773).
  2. The proxy CA is ephemeral per supervisor. Each supervisor generated a fresh CA (crates/openshell-supervisor-network/src/host.rs:119, "ephemeral CA generated"). The replacement's start_agent replay was therefore rejected: "start_agent inputs do not match the running boundary" (boundary_server.rs:2422).
  3. Stale owner records. The killed gateway left owner records that were still fresh (OWNER_TTL 45 s, crates/openshell-server/src/supervisor_owner.rs:15; can_supersede at :258). ConnectSupervisor returned Unavailable "supervisor session owned by another gateway replica" (supervisor_session.rs:947), and the supervisor exited.
  4. The cause was invisible in logs. crates/openshell-ocsf/src/tracing_layers/shorthand_layer.rs:124-136 (MessageVisitor) dropped every field except message. The error field of "Boundary gRPC exchange failed" therefore never reached docker logs.

The stop sweep is not involved: the repro uses SIGKILL, and the container keeps running.

Generation-handover contract

  • Issuing generations. The Docker driver issues a strictly increasing supervisor generation {sandbox_id, auth_epoch, generation} for every supervisor process it starts. It persists the counter atomically in supervisor-generation.json and records it in the runtime descriptor. A corrupt counter, or one belonging to another sandbox, fails closed.
    • crates/openshell-driver-docker/src/lib.rs:4669 advance_docker_supervisor_generation, called at :5128
    • SupervisorGeneration is defined at crates/openshell-sandbox-backend/src/boundary_protocol.rs:273
  • Boundary rules (SandboxConnectionRegistry::attach_supervisor, sandbox_auth.rs:245). All checks run before any state changes, so a rejected attach never fences the current supervisor.
    • The generation must be bound to this sandbox and the principal's auth epoch, and must not be 0. Otherwise the attach fails with SupervisorGenerationMismatch.
    • A generation lower than the current one is rejected with StaleSupervisorGeneration.
    • The current generation may reconnect only from the same process (WrongSupervisorInstance).
    • A higher generation fences generation N first. N's active and pending connections are revoked and closed, and recorded as fenced. Only then is N+1 staged. Any later Attach, Confirm or request from a fenced connection gets FencedSupervisorGeneration {fenced, current}.
    • A legacy attach without a generation, made after a generation exists, gets MissingSupervisorGeneration.
  • Boundary server. commit_attach_generation is at boundary_server.rs:1730. If it fences the active connection, the boundary enters normal recovery (begin_supervisor_recovery, :1877): the workload freezes until N+1 confirms. The boundary logs CK_supervisor_handover_accepted or CK_supervisor_attach_rejected with the phase, sandbox id, runtime generation, previous and new supervisor generations, and the redacted cause.
  • Durable proxy CA. The driver provisions the CA once in driver state (ensure_docker_proxy_ca, lib.rs:4781; key written before certificate). It stages the CA into the supervisor volume and passes it via OPENSHELL_PROXY_CA_CERT/_KEY, so every generation replays identical start_agent inputs.
  • Owner records. At single-replica startup the gateway releases owner records left by the previous process (supervisor_owner.rs:211, called at crates/openshell-server/src/lib.rs:890). It does this only when the store is single-replica.

Re-attach deadline and ReattachTimedOut

Re-attaching each retained sandbox during the startup sweep is bounded by STARTUP_REATTACH_TIMEOUT = 3 min (180 s) (crates/openshell-server/src/compute/mod.rs:4742). On expiry:

  • the sandbox is marked Error with Ready reason ReattachTimedOut (:4744);
  • the gateway logs CK_sandbox_startup_reattach_failed (phase=gateway_startup, reason);
  • the reason is treated as a recoverable start error, so an explicit start can retry.

The Docker start fence is released by a drop guard, so an abandoned start cannot leave the fence held.

Log-field fix

The shorthand layer now renders non-message fields as key=value after the message, like the default fmt layer (shorthand_layer.rs:131, test test_non_ocsf_fallback_includes_structured_fields).

Proof from collected docker logs bytes: the E2E reads raw docker logs <sandbox container> after each restart. It asserts that a handover line exists carrying code="CK_supervisor_handover_accepted", previous_supervisor_generation=Some(N) and supervisor_generation=Some(N+1). Lines collected at this head:

... Supervisor generation accepted code="CK_supervisor_handover_accepted" phase="attach" sandbox_id=94e5f62d-... runtime_generation=9a579132-... previous_supervisor_generation=Some(1) supervisor_generation=Some(2) fenced_active=false
... previous_supervisor_generation=Some(2) supervisor_generation=Some(3) fenced_active=false
... previous_supervisor_generation=Some(3) supervisor_generation=Some(4) fenced_active=false

During diagnosis, the same layer surfaced the cause for blocker 1, which had been hidden. Collected from docker logs with the field fix but before the handover fix:

WARN openshell_sandbox::boundary_server::linux: Boundary gRPC exchange failed error=sandbox runtime is already bound to another supervisor process
ERROR openshell_sandbox::boundary_server::linux: Sandbox Protocol recovery deadline expired; terminating workload recovery_id=1

E2E harness fix (not a product bug)

sandbox exec failed after restart 1 with "Resource temporarily unavailable (os error 35)", which is EAGAIN on macOS. Verified cause:

  • openshell_cmd() let every CLI child inherit the test runner's stdin.
  • The OpenSSH client under sandbox create/connect sets O_NONBLOCK on that shared open file description. A watcher on the pipe caught the flag flipping while openshell sandbox connect -> ssh was running.
  • sandbox exec reads a non-TTY stdin to EOF, so the read returned EAGAIN.

The failure also reproduces before any restart when the runner's stdin is a pipe, and it never reproduces when stdin is /dev/null. So it is unrelated to re-adoption. The fix is in the harness: openshell_cmd() (e2e/rust/src/harness/binary.rs:55) and the restarted gateway now get a null stdin. With a pipe stdin, the flag no longer flips and the E2E is green.

Tests

The deterministic interleaving tests are in sandbox_auth.rs (registry; host) and boundary_server.rs (Linux).

Interleaving Test
N+1 attaches while N is confirmed, before N is fenced: N is fenced first, then N+1 staged; transport loss of fenced N is not a new recovery next_generation_fences_confirmed_generation_before_staging
N+1 attaches between N's Attach and N's Confirm; N's late Confirm / retry is rejected next_generation_fences_unconfirmed_generation_and_rejects_its_late_confirm
Stale-generation Confirm on the fenced connection; N reconnects on a new transport after N+1 was accepted (Stale); legacy attach (Missing) fenced_generation_cannot_reattach_or_confirm
A second process claiming the current generation current_generation_reconnects_only_as_same_process
Wrong sandbox, epoch or generation 0; rejections change nothing generation_must_be_bound_to_sandbox_and_epoch
A rejected handover does not fence the current generation rejected_handover_does_not_fence_current_generation
Legacy -> generation-aware handover generation_handover_replaces_legacy_supervisor
Boundary server: fencing closes N's connection, freezes for recovery and rejects N's requests supervisor_generation_handover_fences_previous_generation
Boundary server: handover after transport loss supervisor_generation_handover_after_transport_loss
Boundary server: logged causes are redacted and bounded logged_causes_are_redacted_and_bounded
Driver each_supervisor_spawn_issues_a_strictly_larger_generation, corrupt_or_foreign_supervisor_generation_fails_closed, proxy_ca_is_provisioned_once_and_reused
Server startup_reattach_that_never_completes_fails_with_typed_reason, plus the owner release test in supervisor_owner.rs

Results at this head, macOS arm64 host plus a Linux arm64 container:

Suite Result
E2E docker_gateway_restart_readopt (--features e2e-docker, 3 SIGKILL restarts) 1 passed. After each restart: same container and gateway sandbox id; StartedAt and RestartCount unchanged (Connect S5 AT-S9); new healthy sidecar with /run/openshell/health.sock probed; Ready; sandbox exec returns pre-restart state; volumes retained; handover log fields. Also a baseline exec before the restarts, and delete removes the volumes. Green with /dev/null stdin and with a held-open pipe stdin.
openshell-sandbox lib (Linux, as non-root ubuntu) 223 passed, 1 ignored; repeated 5x green. Main bin: 5 passed. stdout_logging: 1 passed.
openshell-sandbox-backend 58 passed
openshell-driver-docker 124 passed, 1 ignored
openshell-server 1785 passed, 8 ignored
openshell-ocsf 180 passed, 2 ignored
openshell-driver-podman / -kubernetes / -vm 223 / 231 / 189 passed
cargo fmt --all -- --check, e2e fmt clean
clippy -D warnings clean on touched crates --all-targets (host); openshell-sandbox on aarch64-linux, with and without perf-harness; e2e/rust --all-targets; readopt test with e2e-docker

One earlier Linux full run, as uid 1000 without a passwd entry, had 3 failures: two boundary_exec process-group tests and canonical_exit_preserves_pending_network_accept_and_exec. They passed in isolation and in 5 later full runs. I did not investigate this further; it looks like pre-existing timing sensitivity.

Known limits

  • Pre-change sandboxes fail closed. Sandboxes created before this change have no persisted generation or durable CA. They cannot be warm re-adopted: a replacement fails the start_agent replay. The fix applies to new sandboxes.
  • Multi-replica gateways fail closed. The startup owner purge runs only on single-replica stores. A multi-replica gateway still waits out OWNER_TTL, and a replacement can still time out as ReattachTimedOut.
  • Supervisor volume removal was not reproduced. The volumes were kept in every run, and this PR does not address the reported disappearance of the supervisor volume.
  • Rejected attaches still drop the stream, which lets transport-reconnect races recover. A running sidecar's credentials are not reloaded live.
  • Each re-attach is bounded separately. The startup sweep handles sandboxes one at a time, so many retained sandboxes that never re-attach each take up to 3 min.

🤖 Generated with Claude Code

…rvisor generation handover

An ungraceful gateway exit leaves the Docker sandbox running; the next
gateway start replaces the supervisor sidecar. The replacement could never
re-attach, so the boundary's recovery deadline expired and the workload was
terminated. Layered causes, fixed in order:

- Boundary registry pinned the first SupervisorInstanceId, so any
  replacement process got WrongSupervisorInstance. The Docker driver now
  persists a per-sandbox supervisor generation bound to the sandbox id and
  auth epoch; the boundary fences generation N (active and pending
  connections) before staging N+1, rejects stale generations, mismatched
  bindings and fenced connections, and logs both generations and the cause.
- The replacement supervisor generated an ephemeral proxy CA, so the
  start_agent replay mismatched. The driver now provisions a durable proxy
  CA in driver state and hands it to every supervisor.
- A SIGKILLed single-replica gateway left fresh supervisor owner records;
  startup now releases them (sqlite / single replica only).
- Startup re-attach is bounded (3 min) and fails as recoverable
  Error/ReattachTimedOut instead of hanging the startup sweep.
- The OCSF shorthand layer dropped all non-message fields, hiding causes
  such as `error`; it now renders them as key=value.

Adds a repeated SIGKILL-restart Docker E2E (3 restarts) and makes the e2e
harness give CLI children and the restarted gateway a null stdin: the
OpenSSH client under `sandbox create` set O_NONBLOCK on the inherited
stdin, which made a later `sandbox exec` fail with EAGAIN.

Refs aegis-r6ljc

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agents-lightforge

Copy link
Copy Markdown

[hugo] REQUEST_CHANGES on ad6391b279597238d61fa292830b06728df5c68d.

Blocking:

  • crates/openshell-ocsf/src/tracing_layers/shorthand_layer.rs:94-108,129-157 changes the non-OCSF fallback from message-only to emitting every structured field without a field allow-list or redaction. This layer is installed on supervisor stderr and /var/log (crates/openshell-supervisor/src/main.rs:360-383). A concrete existing event at main.rs:418 records command = ?command; after this change, the full agent command vector is persisted/pushed. Command arguments are not a secret-free contract and can contain tokens, signed URLs, or other credentials. The D1 diagnostic requirement cannot widen generic log disclosure.

Smallest safe fix: leave the generic fallback message-only and render the required D1 lifecycle fields through a dedicated safe event/message, or allow-list only the D1 fields (code, phase, sandbox/runtime and previous/new generation identifiers, fenced state, and an already-redacted/bounded cause). Add a negative regression proving credential-like fields and a command containing a sentinel secret are absent/redacted; also normalize embedded newlines so fields cannot forge log records.

Accepted at this head:

  • generation is bound to sandbox id + auth epoch, persisted monotonically, and the higher generation fences active/pending predecessors before staging;
  • durable per-sandbox proxy CA and single-replica stale-owner release address the other observed restart layers without weakening multi-replica ownership;
  • bounded startup failure becomes ReattachTimedOut, and the production Docker E2E covers three SIGKILL restarts with stable sandbox/container/StartedAt, Ready + exec after each handover, and generations 1→2→3→4.

Local focused receipts (exit 0):

  • cargo test -p openshell-ocsf tracing_layers::shorthand_layer --lib — 7/0
  • cargo test -p openshell-sandbox-backend sandbox_auth --lib — 11/0
  • git diff --check origin/lightforge-main...ad6391b2 — clean

PR is OPEN/CLEAN/MERGEABLE; GitHub reports no check runs. Pre-change retained sandboxes, multi-replica handover, and supervisor-volume loss remain explicit follow-up/release gates; do not describe the 180s startup sweep as replacing the boundary's separate 30s authenticated reconnect window.

@raghusubramanyam raghusubramanyam left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

[vega]

Conformance: CONDITIONAL PASS (source + host suites)
Head SHA: ad6391b279597238d61fa292830b06728df5c68d | Objective / Bar: First working copy / integration candidate (D1 aegis-r6ljc + OpenShell half of Connect S5 + D4 log-sink fix + D5 L1; exact-head H5 integrated run remains the runtime qualification gate)

Findings:

  • Required now: none.
    • Generation-handover state machine (crates/openshell-sandbox-backend/src/sandbox_auth.rs:245-355, boundary_protocol.rs:273-319): all validation runs before state mutation so rejected attaches never fence the current supervisor; higher generation fences both active and pending connections (FencedSupervisorGeneration) before staging N+1; stale (StaleSupervisorGeneration), missing (MissingSupervisorGeneration), mismatched sandbox/epoch/zero (SupervisorGenerationMismatch), and same-generation impostor (WrongSupervisorInstance) all fail closed.
    • Boundary server (crates/openshell-sandbox/src/boundary_server.rs:1730-1890): commit_attach_generation freezes the workload (begin_supervisor_recovery) and closes the fenced connection before accepting N+1; transport_disconnected of the fenced connection does not trigger a duplicate recovery; start_agent replay mismatches log field names only (never values) under CK_start_agent_replay_rejected; handover accepts/rejects emit CK_supervisor_handover_accepted / CK_supervisor_attach_rejected with both generations and redacted cause.
    • Structured log sink (crates/openshell-ocsf/src/tracing_layers/shorthand_layer.rs:95-157): MessageVisitor now preserves non-message fields as key=value so error/cause/generations reach docker logs.
    • Docker driver (crates/openshell-driver-docker/src/lib.rs:2199-2207, 4669-4857): FinishStart RAII drop guard prevents lifecycle-fence deadlock when gateway startup timeout cancels start_sandbox; advance_docker_supervisor_generation persists supervisor-generation.json atomically before updating runtime-descriptor.json; ensure_docker_proxy_ca persists proxy-ca.key before proxy-ca.crt (cert without key fails closed) and mounts both 0600 into the supervisor bundle.
    • Gateway server (crates/openshell-server/src/lib.rs:886-899, supervisor_owner.rs:216-249, compute/mod.rs:2944-3095): single-replica startup releases stale owner records via compare-and-delete before binding the listener (strictly gated on store.is_single_replica(), which returns true only for Store::Sqlite); startup re-attach is bounded by STARTUP_REATTACH_TIMEOUT (180 s) -> Error with typed reason ReattachTimedOut + CK_sandbox_startup_reattach_failed.
    • E2E integrity (e2e/rust/tests/docker_gateway_restart_readopt.rs): exercises real docker, real ManagedGateway::kill (SIGKILL) / start, real openshell CLI, real /run/openshell/health.sock probe, S5 AT-S9 (StartedAt + RestartCount unchanged), pre/post-restart sandbox exec, and raw docker logs handover proof (1->2->3->4); no production boundaries stubbed or mocked.
  • Track next: [Enhancement] crates/openshell-driver-docker/src/lib.rs:4698-4765 — advance_docker_supervisor_generation_in documents that a missing counter for an existing record fails closed, but currently treats supervisor-generation.json NotFound as generation: 1 without first checking whether runtime-descriptor.json already has supervisor_generation: Some(_). The boundary still rejects generation: 1, so fencing is not bypassed, but reading runtime-descriptor.json first and refusing NotFound when runtime_descriptor.supervisor_generation.is_some() makes the driver itself fail closed immediately. Suggest tracking bead.
  • Track next: [Enhancement] crates/openshell-sandbox/src/boundary_server.rs:1330-1365 — redact_cause splits only on ' ' and checks word.starts_with("eyJ"); splitting on whitespace and redacting inline eyJ... substrings (e.g. token=eyJ...) hardens against formatted error strings. Also, validating supervisor_generation before dispatch(Request::Attach) (boundary_server.rs:1280-1297) prevents a malformed first-ever attach in AwaitingAttach from transitioning AwaitingAttach -> Bound (handover on existing Bound/Ready/Running sandboxes is already read-only in self.attach).
  • Track next: [Enhancement] crates/openshell-driver-docker/src/lib.rs:4044-4057, 4842-4857 — write_docker_boundary_file creates temp files under process umask before set_file_owner_only (pre-existing pattern inside the 0700 state dir); creating with 0o600 + sync_all before rename further hardens proxy-ca.key persistence.
  • Track next: [Enhancement] Known limits documented in PR body (suggest tracking beads where not already tracked): multi-replica owner handover, investigating the 3 transient Linux boundary_exec failures from the earlier uid-1000 run, and supervisor-volume disappearance root cause.

Ownership/reuse:

  • Supervisor generation handover, durable proxy CA, single-replica owner release, bounded startup re-attach, and OCSF shorthand field logging -> OpenShell (@ad6391b2, base lightforge-main 5d1f63e0) -> extend existing SandboxConnectionRegistry, BoundaryRuntime, DockerComputeDriver, SupervisorOwnerIndex, ComputeRuntime, and OcsfShorthandLayer. Landscape scan 24h: no overlapping OpenShell PRs; coordinates with Connect S5 and aegis-ie3nn.18/W3 (stale_runtime_identity stays in Connect).

Validation:

  • Independently verified at exact head ad6391b2:
    • git diff --check origin/lightforge-main...HEAD: clean
    • cargo fmt --all -- --check: clean
    • cargo test -p openshell-sandbox-backend --lib: 58 passed, 0 failed (all 7 new interleaving/fencing tests)
    • cargo test -p openshell-driver-docker --lib: 124 passed, 0 failed, 1 ignored (all 3 new generation/CA tests)
    • cargo test -p openshell-ocsf --lib: 163 passed, 0 failed (test_non_ocsf_fallback_includes_structured_fields passed)
    • cargo test -p openshell-server --lib -- startup_reattach_that_never_completes_fails_with_typed_reason single_replica_restart_releases_owner_of_exited_gateway: 2 passed, 0 failed
  • Author receipts reviewed (not independently re-executed in this review): Linux openshell-sandbox suite (223 passed, 5x), full openshell-server (1785 passed), sibling drivers (podman/k8s/vm), clippy -D warnings, and docker_gateway_restart_readopt 3-SIGKILL-restart Docker E2E (1->2->3->4).
  • CI status: no GitHub Actions check runs reported on ad6391b2 (unknown/none configured).
  • Runtime gate: exact integration-head WP-6 H5 run (Connect desktop + OpenShell closure + Shell + Phoenix + global-e2e) remains the end-to-end qualification gate.

Blast radius:

  • Protocol (SandboxRuntimeDescriptor, Request::Attach with backwards-compatible #[serde(default)] supervisor_generation: Option<SupervisorGeneration>), auth registry, Linux boundary server, Docker driver + sibling driver struct initializers (kubernetes/podman/vm set None), server startup & owner index, OCSF shorthand layer, and Rust E2E harness (openshell_cmd + ManagedGateway null stdin).

Simplification:

  • none (clean, well-scoped fixes directly addressing each of the 4 layered root causes without speculative multi-replica or live-credential-reload machinery).

Hugo review on #42 (issuecomment-7188173452): the non-OCSF fallback rendered
every structured field, and existing call sites record values that are not
secret-free (supervisor `command = ?command` carries the full command vector).

Fields are now opt-in: only the supervisor-lifecycle diagnostics (code, phase,
sandbox_id, runtime/supervisor generations, fenced_active, auth_epoch, cause,
reason, released) render. Values have control characters replaced and are
bounded at 512 bytes, so an event stays one line. Negative tests cover a
command vector with a bearer token, token and error fields, newline/CR
injection, and the length bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raghusubramanyam

Copy link
Copy Markdown
Author

Fixed at 6efaf2943e7218850b49d8fab24a00fef66c4ef6. This responds to Hugo's issuecomment-7188173452.

The non-OCSF fallback in shorthand_layer.rs now renders structured fields opt-in only, from FALLBACK_FIELD_ALLOW_LIST:

  • code, phase, sandbox_id
  • runtime_generation, supervisor_generation, previous_supervisor_generation, current_supervisor_generation, requested_supervisor_generation
  • fenced_active, auth_epoch
  • cause (every call site redacts it with redact_cause first), reason, released

Any other field is dropped. That covers the existing supervisor command = ?command (openshell-supervisor/src/main.rs:418) as well as error, token and similar fields. Rendered values have control characters replaced and are bounded at 512 bytes, so one event stays one line.

New negative tests

Test Asserts
test_non_ocsf_fallback_drops_fields_outside_the_allow_list A command vector carrying Authorization: Bearer …, plus token= and error="…password=…": none of the values or field names appear, and the allowed phase is kept.
test_non_ocsf_fallback_field_values_stay_on_one_bounded_line Embedded \n and \r with a forged log line give exactly one output line, and a 4096-byte value is cut to 512 bytes followed by ....
test_non_ocsf_fallback_includes_allow_listed_lifecycle_fields The attach-rejected fields render.

The restart E2E asserts code="CK_supervisor_handover_accepted", previous_supervisor_generation and supervisor_generation, all of which are allow-listed.

Gate Result
openshell-ocsf 165/0 (163 before, plus 2 new tests; 1 existing test rewritten)
cargo fmt --check, clippy -D warnings (openshell-ocsf, all targets) clean
3-SIGKILL restart E2E at this head (images rebuilt) running; result will follow in a comment

agy Vega's non-blocking track-next items (review 6071652978) are recorded for a follow-up:

  • a driver-side check when supervisor-generation.json is absent but the runtime descriptor has Some(_);
  • hardening redact_cause for whitespace and inline JWTs;
  • validating the generation before dispatch(Attach) in AwaitingAttach;
  • writing proxy-ca.key to a 0600 temp file with fsync.

@raghusubramanyam

Copy link
Copy Markdown
Author

The 3-SIGKILL restart E2E at 6efaf294 passes. Gateway, CLI, sandbox and supervisor images were rebuilt at this head (tag local/readopt/*:allowlist). docker_gateway_restarts_readopt_live_sandbox: 1 passed, E2E_EXIT=0. The collected docker logs contain the handover lines with previous_supervisor_generation=Some(1), Some(2) and Some(3), each paired with the next generation, so the allow-listed fields survive the sink. No command= or token= field appears in the captured output.

@agents-lightforge

Copy link
Copy Markdown

[hugo]

Conformance: PASS
Head: 6efaf2943e7218850b49d8fab24a00fef66c4ef6
Bar: D1 first working copy / integration candidate; exact integration-head WP-6 H5 remains release qualification.

Findings:

  • Required now: none. The prior information-disclosure blocker is resolved: FALLBACK_FIELD_ALLOW_LIST is opt-in, excludes command, error, and token, replaces control characters, and bounds each rendered value to 512 bytes. The negative regressions cover a bearer-bearing command vector, credential-like fields, CR/LF log forgery, and the byte bound.
  • The accepted generation/auth-epoch fencing, durable proxy CA, stale-owner release, bounded re-attach failure, and fail-closed compatibility boundaries are unchanged from ad6391b2.
  • Track next: agy Vega's recorded driver-counter/runtime-descriptor consistency check, broader cause redaction, pre-dispatch attach validation, and durable 0600+fsync proxy-key write remain non-gating hardening. Pre-change retained sandboxes, multi-replica handover, supervisor-volume loss, and the separate 30s boundary recovery versus 180s startup sweep remain rollout/qualification gates.

Validation:

  • git diff --check origin/lightforge-main...6efaf294 — clean
  • cargo fmt --all -- --check — clean
  • cargo test -p openshell-ocsf --lib — 165/0
  • cargo clippy -p openshell-ocsf --all-targets -- -D warnings — clean
  • Exact-head production Docker E2E receipt reviewed: rebuilt images, three SIGKILL restarts, stable live sandbox, generations 1→2→3→4, and collected logs contain handover fields with no command=/token=.
  • PR is OPEN/CLEAN/MERGEABLE; GitHub reports no check runs.

Ownership/reuse and blast radius are unchanged from the prior exact-head review; this delta only narrows the existing OCSF shorthand sink. Simplification: none; the explicit allow-list is the smallest safe correction and avoids a second logging path.

@agents-lightforge agents-lightforge added the hugo-reviewed Reviewed by Hugo label Nov 26, 2026

@raghusubramanyam raghusubramanyam left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

[vega]

Conformance: CONDITIONAL PASS (source + host suites)
Head SHA: 6efaf2943e7218850b49d8fab24a00fef66c4ef6 | Objective / Bar: First working copy / integration candidate (D1 aegis-r6ljc + OpenShell half of Connect S5 + D4 log-sink fix + D5 L1; exact-head H5 integrated run remains the runtime qualification gate)

Findings:

  • Required now: none.
    • Hugo's blocking log-disclosure finding (issuecomment-7188173452 on ad6391b2) is cleanly resolved in crates/openshell-ocsf/src/tracing_layers/shorthand_layer.rs:134-187:
      • OcsfShorthandLayer non-OCSF fallback is now strictly opt-in via FALLBACK_FIELD_ALLOW_LIST (code, phase, sandbox_id, runtime_generation, supervisor_generation, previous_supervisor_generation, current_supervisor_generation, requested_supervisor_generation, fenced_active, auth_epoch, cause, reason, released).
      • Non-allowlisted fields (including command, token, error) are dropped before formatting (push_field returns immediately).
      • Allow-listed values have control characters (\n, \r, etc.) flattened to spaces and are truncated at a UTF-8 char boundary to 512 bytes (MAX_FALLBACK_FIELD_BYTES), preventing log-line forgery and unbounded lines.
      • Verified by 3 unit tests covering allow-listed lifecycle fields, secret-bearing command/token/error rejection, and newline/CR forgery + 512 B truncation.
    • Delta ad6391b2..6efaf294 touches only shorthand_layer.rs; prior source/interleaving verification from review 6071652978 holds unchanged.
  • Track next: [Enhancement] Prior non-blocking follow-ups from review 6071652978 remain recorded for follow-up (driver-side missing-counter check against runtime-descriptor.json, redact_cause whitespace/inline-JWT hardening, pre-dispatch generation validation in AwaitingAttach, 0o600 + sync_all temp write for proxy-ca.key, and PR-documented known limits).

Ownership/reuse:

  • Unchanged from review 6071652978 (OpenShell @6efaf294 -> extend OcsfShorthandLayer + existing handover/driver/server components).

Validation:

  • Independently verified at exact head 6efaf294:
    • git diff --check origin/lightforge-main...HEAD: clean (1-file delta ad6391b2..6efaf294)
    • cargo fmt --all -- --check: clean
    • cargo test -p openshell-ocsf --lib: 165 passed, 0 failed
    • cargo clippy -p openshell-ocsf --all-targets -- -D warnings: clean
  • Author receipts reviewed (not independently re-executed in this pass): rebuilt 3-SIGKILL restart E2E at 6efaf294 (local/readopt/*:allowlist) 1 passed (E2E_EXIT=0), docker logs handover 1->2->3->4, no command=/token= leaked.
  • CI status: no GitHub Actions check runs reported on 6efaf294 (unknown/none configured).
  • Runtime gate: exact integration-head WP-6 H5 run remains the end-to-end qualification gate.

Blast radius:

  • Scoped exclusively to OcsfShorthandLayer non-OCSF fallback rendering (shorthand_layer.rs), which narrows disclosure back to an explicit 13-field lifecycle allow-list while keeping all D1/D4 handover diagnostics intact.

Simplification:

  • none.

@raghusubramanyam

Copy link
Copy Markdown
Author

WP-6 H6 live runtime receipt: run wp6-agy-20261127h6d PASSED (2026-11-26T20:56–21:03Z)

Exact composition (local build, no GitHub CI is configured for these PRs):

Repo Pin
Connect integration integration/wp6-agy-h6b2 64fa3f38 = ai-openshell#472 a57e3609 + ai-openshell#474 52f1ebb2 + ai-openshell#461 af0133d4
OpenShell closure integration/wp6-agy-h6 e2e20ace = #42 6efaf294 + #43 f72b22d8 + #44 64fc5dcf. Images: gateway f31ba45a, sandbox 720f7bbd, supervisor 63dd0bd0
Shell b08afb13
Phoenix e89345f7
global-e2e control dcee6fe1
SDK linux-arm64 09de4309 (sha256 520f4a9a…)

The SDK differs from attempts 2 and 3, which used 2642ce34. That binary predates SDK ai-openshell#160 --lane, while Shell D-070 calls session-start --lane connect. h6c is kept as the record of that pin skew.

Diagnostics on: AEGIS_CONNECT_GATEWAY_DIAGNOSTIC_LOG=1, OPENSHELL_LOG_LEVEL=debug. Run with native-run/run-native-gates.sh --diag --restarts 3 (aegis-api-phoenix#3900).

Gate Result
1 inputs passed: pins equal the checkouts, artifact SHA-256 values match, 0 FIFO wrappers, umask 022
accept passed: runtime-setup, bootstrap, first-session, restart-session; mind smoke post-enroll and post-restart
D1 restart re-adoption, 3 restarts passed: same sandbox container 53f47c46 and StartedAt 21:00:04.395Z across all restarts; supervisor generation 2→3→4→5, advancing by exactly one each time; a distinct healthy sidecar per restart; Ready, and exec rc=0 after each restart
D1b shutdown disposition CK_gateway_shutdown_disposition_selected mode=retain-running-sandboxes reason=runtime_restart on all 5 Gateway stops (preflight, accept and 3 proof restarts); no sweep
ai-openshell#471 passed: first_session_passed, no sandbox_session_not_registered, no policy-generation stale close
ai-openshell#474 diagnostic log home/logs/gateway.log plus 3 rotations, each ≤1.05 MB (bounded), mode 0600; 4 [redacted] substitutions; 0 hits from a credential-pattern scan (Authorization/Cookie/Bearer/token/secret/password, JWT, sk-, ghp_, PEM); no CK_gateway_output_log_unavailable; readiness unchanged
5 down down result=verified, rc=0; no namespace containers or volumes left; custody-unproven agent/identity volumes kept (ai-openshell#85); 0 lingering wrappers

Receipts are private (0600) on the build host under out/wp6-agy-20261127h6d/ (inputs.txt, accept.log, restart/restart-proof-receipt.json, 471-receipt.json, postdown-receipt.txt, restart/gateway.log*).

@agents-lightforge

Copy link
Copy Markdown

[hugo]

Conformance: PASS
Reviewed head: 6efaf2943e7218850b49d8fab24a00fef66c4ef6

The previously deferred D1 runtime gate is closed by WP-6 H6d wp6-agy-20261127h6d. The exact OpenShell aggregate e2e20ace contains #42/#43/#44 and passed three graceful Gateway restarts with the same sandbox container and StartedAt, supervisor generations 2→3→4→5, distinct healthy sidecars, Ready, and exec rc=0 after each restart. D1b retained the sandbox on every runtime stop; final down verified.

No required finding remains. GitHub reports no CI/check runs; the exact-head local suites from the source review plus the production-boundary H6d receipt satisfy this PR's evidence bar.

Merge sequencing: merge #42 first as a merge commit into lightforge-main; then retarget and re-check #43/#44. No technical or evidence blocker to merging #42.

Comment-only review: no approval, merge, or label change performed.

@raghusubramanyam
raghusubramanyam merged commit 25b738e into lightforge-main Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants