Skip to content

fix(supervisor): keep non-credential tunnels across provider-env-only activation - #43

Merged
raghusubramanyam merged 3 commits into
lightforge-mainfrom
fix/provider-env-tunnel-staleness
Nov 26, 2026
Merged

raghusubramanyam merged 3 commits into
lightforge-mainfrom
fix/provider-env-tunnel-staleness

Conversation

@raghusubramanyam

Copy link
Copy Markdown

Stacked on #42 (fix/gateway-restart-readopt). Retarget to lightforge-main after #42 merges.

Found in WP-6 H5; separate from aegis-r6ljc.

Root cause (at 6efaf29)

In H5, the in-sandbox aegis-sdk session-create POST to host.docker.internal:24025 (policy aegis_platform_e2e_tls_passthrough, tls: skip, no provider credentials) was allowed at 11:06:08.193. 58 ms later a settings poll with policy_changed:false provider_env_changed:true and the same revision closed it with policy generation is stale [captured_generation:1 current_generation:2].

  1. crates/openshell-supervisor/src/lib.rs:4190-4194 folds provider_env_changed into policy_runtime_changed.
  2. That runs reload_gateway_configuration_runtime (lib.rs:2841), which does a full OPA swap through reload_configuration_from_proto_with_pid.
  3. crates/openshell-supervisor-network/src/opa.rs advance_generation (~299) advances the one shared generation.
  4. Every pinned guard goes stale. The raw relay (proxy/relay.rs relay_tcp → wait_until_stale) and the L7 check (l7/relay.rs:3070) close the tunnel, even when it has no credential dependency.

Design

Invalidation now tracks two counters: the policy generation and a provider credential epoch. Each guard records at capture time whether it depends on credentials.

  • OpaEngine::activate_credentials(commit) takes the engine lock, advances only the credential epoch, then commits the credentials. It returns the unchanged policy-generation evidence. If the lock fails, nothing is published and commit never runs.
  • PolicyGenerationGuard now holds captured_credential_epoch: Option<u64>. A policy-only guard is stale only when the policy generation changes. A credential-dependent guard is also stale when the epoch changes. One watch channel wakes all relays on either change, and each relay rechecks its own staleness.
  • Guard choice at each capture site:
Path Guard
L7 inspection (clone_engine_for_tunnel) credential-dependent
Passthrough HTTP (prepare_http_relay, placeholder rewrite) credential-dependent
Forward HTTP credential-dependent
Raw relay: tls: skip, non-TLS non-HTTP, transparent TCP policy-only, unless the endpoint is credential-bound. If the binding cannot be determined (transparent TCP), it is credential-dependent.
CONNECT authorization → relay start policy-only. No credential material is read in this window, and every relay re-pins its own guard.
Supervisor policy evidence (readiness, current_policy_generation) policy-only
  • Poll loop: credential_only_activation is set when provider_env_changed is the only runtime change. That means no policy hash change, no middleware or registry change, no extension-auth change, no stale generation, no rejected or quarantined policy, and an installed generation exists. That case calls activate_credentials. Every other case still takes the full reload, exactly as before.

Why fail-closed is preserved

  • An actual policy, middleware-registry or fail-closed quarantine change still advances the policy generation and invalidates every tunnel.
  • Credential-dependent tunnels are stale before the new material is committed. A credential-dependent relay pinned afterwards captures the new epoch under the same engine lock, so it never pairs old credentials with a current guard. The existing per-request CredentialGenerationGuard (provider credential revision) stays in place.
  • Raw relays never resolve or inject credentials. Credential-bound endpoints, and endpoints whose binding can't be determined, are still treated as dependent.
  • A failed provider refresh (fetch or binding validation) is unchanged: static credentials are revoked, readiness reports CredentialInstallFailed, and the revision is retried. A failed activate_credentials publishes no epoch, never commits, revokes static credentials and reports the runtime as not reconciled.
  • Credential-only activation never clears a quarantine. Any rejected or quarantined state takes the full reload path.

Tests

New, deterministic: no sleeps, using the existing seams (activate_credentials, tokio::io::duplex relays, scripted poll gateway).

Required case Tests Count
1. Non-credential tunnel survives a provider-env-only revision opa::credential_epoch_tests::credential_only_activation_keeps_policy_only_guards_current, wait_until_stale_wakes_only_credential_dependent_guards; supervisor provider_env_only_revision_keeps_policy_generation_for_passthrough_tunnels 3
2. Credentialed route can't use stale credentials and observes the new epoch credential_bound_guards_are_stale_before_new_credentials_commit; relay credential_bound_raw_relay_closes_on_provider_env_activation, credential_capable_http_relays_bind_the_credential_epoch; supervisor provider_env_only_revision_rebinds_credentialed_tunnels_to_new_epoch (two rotations, resolver returns the new value) 4
3. Policy or middleware change still invalidates policy_middleware_and_quarantine_transitions_invalidate_every_guard (reload, registry replacement, quarantine); relay policy_only_raw_relay_still_closes_on_policy_reload; supervisor policy_change_with_provider_env_still_invalidates_every_tunnel 3
4. Failed activation stays fail-closed failed_credential_activation_publishes_nothing (poisoned engine: no commit, no epoch, no new dependent relays); supervisor failed_provider_env_activation_stays_fail_closed (revoked, no epoch, retry activates) 2
5. H5 regression relay h5_passthrough_tunnel_survives_provider_env_only_activation: passthrough tunnel captured, provider-env-only activation, then the full request/response completes. Also the supervisor test in row 1. 1

New tests total: 13. Negative check: with credential_only_activation forced to false, the three supervisor provider-env tests fail. The H5 test fails at the policy-generation assertion.

Full suites:

Suite Result
openshell-supervisor-network, macOS host lib 1314 passed / 2 ignored; integration 2 + 2 passed, 5 ignored
openshell-supervisor-network, Linux arm64 container, non-root lib 1346 passed / 0 failed / 2 ignored; integration 2 + 2 passed, 5 ignored
openshell-supervisor, macOS host and Linux arm64 non-root 131 + 6 passed / 0 failed
cargo fmt --all -- --check clean
cargo clippy -p openshell-supervisor-network -p openshell-supervisor --all-targets -- -D warnings clean on host and with cargo-zigbuild --target aarch64-unknown-linux-gnu
git diff --check clean
Reverse deps (openshell-driver-mxc, openshell-sandbox) cargo-zigbuild check --tests (Linux) passes

Not verified

🤖 Generated with Claude Code

… activation

A provider-env-only settings poll (same policy hash and config revision)
was folded into policy_runtime_changed, so it ran a full OPA swap and
advanced the single shared policy generation. Every pinned tunnel was then
closed as stale, including TLS-passthrough (tls: skip) tunnels that never
resolve or inject provider credentials. In WP-6 H5 this killed the
in-sandbox session-create POST 58 ms after it was allowed.

Split invalidation into the policy generation plus a provider credential
epoch:
- OpaEngine::activate_credentials advances only the credential epoch, under
  the engine lock, before committing credentials; failure publishes nothing.
- PolicyGenerationGuard records whether it is credential-dependent at
  capture time; dependent guards are stale on either counter.
- L7 tunnels, passthrough HTTP and forward HTTP pin credential-dependent
  guards; raw relays (tls: skip, non-HTTP, transparent TCP) are independent
  unless the endpoint is credential-bound.
- The poll loop routes provider-env-only changes against an installed,
  unquarantined policy through activate_credentials. Policy, middleware,
  recovery and stale-generation changes still take the full reload.

Found in WP-6 H5; separate from aegis-r6ljc.

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

@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: 0c351621f28a61782b34de70800c3c82b8756458 (stacked on #42 @6efaf294) | Objective / Bar: First working copy / integration candidate (#471 fix A; retarget to lightforge-main after #42 merges; live WP-6 H6 run with #42 + #43 remains the runtime qualification gate)

Findings:

  • Required now: none.
    • Generation / credential-epoch split (crates/openshell-supervisor-network/src/opa.rs:150-385, 864-1065, 1250-1266): OpaEngine::activate_credentials locks self.engine, advances credential_epoch and wakes generation_tx before invoking commit_credentials, and returns the unchanged policy-generation guard. credential_bound_generation_guard and clone_engine_for_tunnel acquire the same self.engine lock, serializing new dependent relays against credential commits. wait_until_stale loops while !self.is_stale() over generation_rx.changed(), so CredentialDependency::Independent guards stay open while Dependent guards close immediately.
    • Capture-site audit (proxy.rs, proxy/relay.rs, l7/relay.rs): verified every relay_tcp, prepare_raw_relay, prepare_http_relay, pin_policy_generation, clone_engine_for_tunnel, and generation_guard call site across the workspace. L7 tunnels, passthrough HTTP, and forward HTTP are always Dependent; raw relays (tls: skip, non-TLS non-HTTP, transparent TCP) are Independent only when query_endpoint_credential_guard proves !provider_credentialed, failing closed to Dependent when credential-bound or when lookup errors (raw_relay_credential_dependency). CONNECT's pre-relay guard is Independent (no credential material read in that window; every downstream relay re-pins its own guard).
    • Poll-loop gating & fail-closed behavior (crates/openshell-supervisor/src/lib.rs:4187-4216, 4414-4470, 4694-4710): credential_only_activation requires !policy_configuration_changed && rejected_policy_generation.is_none() && current_policy_generation.is_some(). Failed fetch or binding validation still revokes static credentials and continues before activation; failed activate_credentials publishes no epoch, commits nothing, revokes static credentials, reports CredentialInstallFailed, leaves policy_runtime_reconciled = false (retrying on next poll without advancing current_provider_env_revision).
  • Track next: [Enhancement] opa.rs:864-881 — defense-in-depth check inside activate_credentials refusing activation if self.fail_closed_reason is Some(_) (currently unreachable from the poll loop because quarantine sets rejected_policy_generation and advances policy generation, but enforces the invariant at the engine boundary too).
  • Track next: [Enhancement] crates/openshell-supervisor/src/lib.rs:4695 — when activate_credentials fails (lib.rs:4454-4468), the shared line-4695 runtime status message still says "prior credentials remain installed" even though static credentials were revoked at line 4460 (minor diagnostic wording polish). Also note !reloads_gateway_policy (local policy override mode, line 4698) keeps its pre-existing direct install_prepared path without advancing credential_epoch.

Ownership/reuse:

  • Provider-credential invalidation epoch and dependency-aware tunnel guards (openshell-supervisor-network, openshell-supervisor) -> OpenShell (@0c351621, stacked on #42 @6efaf294) -> extend existing OpaEngine, PolicyGenerationGuard, proxy/relay, and run_policy_poll_loop_with_client. Landscape scan 24h: no overlapping PRs; cleanly orthogonal to D1 (#42) and upcoming D1b.

Validation:

  • Independently verified at exact head 0c351621:
    • git diff --check clean on both delta (6efaf294...0c351621) and aggregate (origin/lightforge-main...0c351621)
    • cargo fmt --all -- --check: clean
    • cargo clippy -p openshell-supervisor-network -p openshell-supervisor --all-targets -- -D warnings: clean
    • cargo test -p openshell-supervisor-network --lib (all 9 new credential_epoch_tests + proxy::relay::tests): 9 passed, 0 failed
    • cargo test -p openshell-supervisor --lib: 131 passed, 0 failed (including all 4 new provider-env poll-loop tests)
  • Author receipts reviewed (not independently re-executed here): full openshell-supervisor-network (1314 macOS / 1346 Linux non-root), Linux openshell-supervisor (131+6), Linux cargo-zigbuild clippy and reverse-dep check (openshell-driver-mxc, openshell-sandbox), negative check with credential_only_activation = false.
  • CI status: no GitHub Actions check runs reported on 0c351621 (unknown/none configured).
  • Merge/runtime gates: retarget base to lightforge-main after #42 merges; live WP-6 H6 run with #42 + #43 remains the end-to-end runtime receipt.

Blast radius:

  • openshell-supervisor-network (opa.rs, proxy.rs, proxy/relay.rs) and openshell-supervisor (lib.rs); 4 files, +930/-34 (mostly tests). All non-credential-only transitions (policy, middleware, extension-auth, recovery, quarantine, stale generation) keep the existing full reload path unchanged.

Simplification:

  • none (clean two-counter model with a single shared watch wake channel; minimal production diff).

@agents-lightforge

Copy link
Copy Markdown

[hugo]

Conformance: REQUEST_CHANGES
Reviewed head: 0c351621f28a61782b34de70800c3c82b8756458
Bar: first working-copy/integration candidate for ai-openshell#471; H6 remains the runtime gate.

Required now

  • Credential-epoch tunnel closure is misreported as a policy change. crates/openshell-supervisor-network/src/proxy/relay.rs:336-345 synthesizes policy generation is stale using only the policy counters, and proxy.rs:3450-3463 emits because policy changed. When only credentials rotate, those counters are equal. This erases the new policy/credential distinction at the retained OCSF evidence boundary and would misdiagnose the failure Vouch request: brentrockwood ai-openshell/openshell#471 is intended to isolate.
    • Reuse the guard's staleness result (or expose a typed policy vs credential cause).
    • Emit a stable cause classification and the matching captured/current policy generation or credential epoch.
    • Add a regression proving credential-only activation reports credential-epoch staleness without policy changed/equal policy counters, while a true policy reload retains the policy-change cause.
  • Runtime gate remains open: exact-head H6 WP-6 evidence is still required after the source repair. Source/unit proof does not establish the live session-create race is gone.

Accepted source design

  • Policy generation and credential epoch are separated; dependent guards stale on either counter, independent guards only on policy.
  • Credential activation is serialized under the engine lock and publishes no partial install; activation/fetch/binding failure revokes static credentials and remains fail-closed.
  • Dependency classification is conservative: inspection, placeholder-rewriting HTTP, forward HTTP, provider-bound/undetermined endpoints depend on credentials; raw TLS-skip/non-HTTP/transparent TCP can remain independent.
  • Policy, middleware, extension-auth, recovery, and stale-state changes retain the full reload path.

Ownership / overlap

Independent validation

  • cargo fmt --all -- --check: PASS
  • cargo test -p openshell-supervisor-network --lib --quiet: PASS, 1314/0 (2 ignored)
  • cargo test -p openshell-supervisor --lib --quiet: PASS, 131/0
  • cargo clippy -p openshell-supervisor-network -p openshell-supervisor --all-targets -- -D warnings: PASS
  • git diff --check origin/fix/gateway-restart-readopt...0c351621: PASS
  • GitHub: OPEN, CLEAN, MERGEABLE; no check runs reported.

Simplest safe repair: reuse the existing guard as the single source of typed staleness and generalize the existing close emitter; do not add a parallel logging path.

… cause

A credential-only activation closed credential-bound tunnels with an OCSF
event that said "policy changed" and printed the policy counters, which are
equal in that case. That erased the policy/credential distinction ai-openshell#471 needs.

- Add typed `GuardStaleness` (policy generation vs credential epoch) on
  `PolicyGenerationGuard`; `is_stale`/`ensure_current` derive from it.
- Generalize the close emitter to classify the guard error: stable
  `[cause:policy_generation_stale|credential_epoch_stale]`, the matching
  captured/current counter pair, and the matching activity deny group
  (`policy_stale` / `credential_stale`, allow-listed).
- Raw relay close reuses the guard result instead of synthesizing policy
  counters; a closed generation channel gets its own message.
- Regression: credential-only activation reports credential-epoch staleness
  without policy wording; a policy reload keeps the policy cause.

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

Copy link
Copy Markdown
Author

Fix for Hugo REQUEST_CHANGES (issuecomment-7191152442): head 066af3c7 (was 0c351621)

  • opa.rs: typed GuardStaleness::{PolicyGeneration, CredentialEpoch}{captured, current} on PolicyGenerationGuard::staleness(). If both counters changed, it reports the policy change. is_stale and ensure_current are derived from it, and the error text is unchanged.
  • proxy.rs: the existing emitter is generalized and renamed to emit_l7_tunnel_close_after_stale_state. It classifies the error through downcast_ref::<GuardStaleness>() and emits:
    • because provider credentials rotated [cause:credential_epoch_stale] with the credential epoch pair, or because policy changed [cause:policy_generation_stale] with the generation pair;
    • the matching activity deny group, credential_stale or policy_stale.
    • Untyped errors are route/L7 generation mismatches detected before any guard exists, and stay classed as policy. No parallel logging path.
  • relay.rs: the raw relay close reuses guard.ensure_current() instead of synthesizing policy counters. If wait_until_stale returns because the channel closed, it gets its own "channel closed" message.
  • openshell-supervisor/activity_aggregator.rs: credential_stale is added to the deny-group allow-list.
  • Regression proxy::tests::stale_close_evidence_distinguishes_credential_epoch_from_policy_change:
    • a credential-only activation reports credential_stale / credential_epoch_stale with epochs 0 and 1, and contains no "policy changed" or "policy generation" text;
    • a policy reload reports policy_stale / policy_generation_stale with distinct generations and contains no "credential" text.

Local at 066af3c7:

  • cargo fmt --all -- --check: PASS
  • cargo clippy -p openshell-supervisor-network -p openshell-supervisor -p openshell-sandbox --all-targets -- -D warnings: PASS
  • network lib: 1315/0 (2 ignored)
  • supervisor lib: 131/0
  • git diff --check: PASS

Deferred (non-blocking):

  • The warn! prose and the CONNECT 403 body text still say "policy changed". The OCSF event and the activity record carry the cause.
  • crates/openshell-sandbox/src/activity_aggregator.rs is an orphan copy (not declared as a module), so I left it unchanged.

The H6 exact-head WP-6 run remains the runtime gate.

@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: REQUEST_CHANGES
Head SHA: 066af3c7c54c98bceba8a7ac4d6ea3c008cd1894 (stacked on #42 @6efaf294) | Objective / Bar: First working copy / integration candidate (#471 fix A; H6 remains the runtime gate)

Findings:

  • Required now: [Blocking] crates/openshell-supervisor-network/src/l7/relay.rs:2058-2091 (and callers at :1588-1589, :2104-2105, plus 13 close_if_stale sites) — In-tunnel L7/HTTP stale closes still misreport credential-epoch rotation as a policy reload with equal generation counters. Every L7 inspected tunnel and passthrough HTTP tunnel is CredentialDependency::Dependent. When a credential-only activation hits an active tunnel at a request/frame/WebSocket boundary before wait_until_stale() wins the select! in proxy/relay.rs:266-310, l7/relay.rs calls emit_policy_reload(guard, host, port, policy_name), which hardcodes "L7 tunnel closed after policy reload [host:{} port:{} captured_generation:{} current_generation:{}]" without checking guard.staleness(). Required fix: inspect guard.staleness() in emit_policy_reload (reusing GuardStaleness) so CredentialEpoch emits the credential-rotation cause and epoch pair instead of "policy reload" with equal policy generations, and add a focused unit regression.
  • Track next (or fold in with the fix above):
    • crates/openshell-core/src/telemetry.rs:251-289 — openshell-supervisor/src/activity_aggregator.rs:156 now allows "credential_stale", but openshell_core::telemetry::DenyGroup::from_raw (called by openshell-server/src/telemetry.rs) only recognizes "policy_stale", so server-side telemetry aggregation will bucket "credential_stale" into DenyGroup::Unknown. Add DenyGroup::CredentialStale to keep supervisor and server allow-lists aligned.
    • crates/openshell-supervisor-network/src/proxy.rs:3456 — error.downcast_ref::<GuardStaleness>() works for all current callers (verified none wrap ensure_current() via .wrap_err(...)), but using error.chain().find_map(|cause| cause.downcast_ref::<GuardStaleness>()) also handles wrapped miette::Report errors safely.
    • crates/openshell-supervisor-network/src/proxy/relay.rs:339-346 + proxy.rs:3467 — on wait_until_stale() watch-channel close (engine teardown while guard is current), the untyped "policy generation channel closed" error falls into None in stale_close_evidence and still renders "because policy changed [cause:policy_generation_stale]" with equal generation counters.

Focus checks requested:

  • Former emit_l7_tunnel_close_after_policy_change sites: all 14 sites migrated (proxy.rs: 3512, 5196, 5315, 5348, 5836, 5863, 6149, 6223; relay.rs: 158, 170, 196, 228, 239, 346); zero remaining hits. The 5 sites with emit_activity_simple (3512, 5196, 5315, 5348, 5836) now propagate stale_group.
  • Downcast through wrapped errors: all current callers pass unwrapped Report::new(GuardStaleness); error.chain() recommended above for future-proofing.
  • wait_until_stale channel-close path: handled without panic in relay.rs:339-346, with minor policy_stale fallback mislabel noted above.

Ownership/reuse:

  • Unchanged from review 6073566705 (OpenShell @066af3c7, stacked on #42 @6efaf294).

Validation:

  • Independently verified at exact head 066af3c7:
    • git diff --check origin/lightforge-main...HEAD: clean
    • cargo fmt --all -- --check: clean
    • cargo clippy -p openshell-supervisor-network -p openshell-supervisor --all-targets -- -D warnings: clean
    • cargo test -p openshell-supervisor-network --lib (16 tests incl. proxy::tests::stale_close_evidence_distinguishes_credential_epoch_from_policy_change, credential_epoch_tests, proxy::relay::tests): 16 passed, 0 failed
    • cargo test -p openshell-supervisor --lib -- activity_aggregator: 4 passed, 0 failed
  • CI status: no GitHub Actions check runs reported on 066af3c7 (unknown/none configured).
  • Runtime gate: live WP-6 H6 with #42 + #43 remains open.

Blast radius:

  • opa.rs, proxy.rs, proxy/relay.rs, activity_aggregator.rs — and l7/relay.rs (emit_policy_reload) is the remaining un-updated stale-close emitter on the L7/HTTP credential-dependent path.

Simplification:

  • Reusing GuardStaleness across opa.rs, proxy.rs, and l7/relay.rs keeps a single typed source of staleness with no parallel logging path.

Follow-up to agy Vega's re-review of 066af3c: active L7/HTTP tunnels still
closed via `emit_policy_reload`, which printed "after policy reload" with the
policy counters even when only the credential epoch moved.

- l7/relay.rs: `emit_l7_stale_tunnel_close` (was `emit_policy_reload`) builds
  its message from `guard.staleness()`, used by all close_if_stale and
  WebSocket sites; `evaluate_l7_request_once` reuses `ensure_current`.
- proxy.rs: stale-close classification walks the error chain, so wrapped
  staleness keeps its cause; the CONNECT dial-interrupt path reuses the
  guard result instead of synthesizing policy counters.
- Typed `GenerationChannelClosed` gives engine teardown its own
  `generation_channel_closed` cause.
- openshell-core: `DenyGroup::CredentialStale` so the server keeps
  `credential_stale` instead of mapping it to `unknown`.
- Tests: L7 credential-vs-policy close message, wrapped-error and
  channel-close classification, telemetry deny-group mapping.

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

Copy link
Copy Markdown
Author

Fix for agy Vega REQUEST_CHANGES (review 6073718867): head f72b22d8 (was 066af3c7)

  • Blocking, l7/relay.rs: emit_policy_reload is replaced by emit_l7_stale_tunnel_close. Its message comes from stale_tunnel_close_message(guard, ..), which uses guard.staleness().
    • A credential-only close reads after provider credential rotation [cause:credential_epoch_stale ... captured_credential_epoch:N current_credential_epoch:M].
    • A policy close reads after policy reload [cause:policy_generation_stale ... captured_generation current_generation].
    • It is used by all close_if_stale sites, the WebSocket pre-upgrade and upgrade checks, and websocket.rs::ensure_generation_guard_current. No emit_policy_reload references remain.
  • Same class, found in audit:
    • evaluate_l7_request_once now calls generation_guard().ensure_current()? instead of building a policy-only message.
    • The CONNECT dial-interrupt path in proxy.rs reuses ensure_current() and wraps it with context, instead of synthesizing policy counters.
  • Fold-in, openshell-core/telemetry.rs: adds DenyGroup::CredentialStale, so credential_stale maps to itself instead of Unknown on the server.
  • Fold-in, proxy.rs: stale_close_evidence walks error.chain(), so a wrapped GuardStaleness keeps its cause.
  • Fold-in, channel close: a typed GenerationChannelClosed gives engine teardown its own cause, [cause:generation_channel_closed], separate from a policy change.
  • New tests:
    • l7::relay::stale_close_message_tests::l7_close_reports_credential_epoch_not_policy_reload
    • proxy::tests::stale_close_evidence_keeps_cause_through_context_and_channel_close
    • server deny_group_sanitization_drops_raw_values now also asserts the credential_stale and policy_stale mappings.

Local at f72b22d8:

  • cargo fmt --all -- --check: PASS
  • cargo clippy -p openshell-core -p openshell-supervisor-network -p openshell-supervisor -p openshell-server --all-targets -- -D warnings: PASS
  • network lib: 1317/0 (2 ignored)
  • supervisor lib: 131/0
  • core lib: 496/0
  • server telemetry: 9/0
  • git diff --check: PASS

Still deferred (non-blocking): the warn! prose and the CONNECT 403 body text. The H6 exact-head WP-6 run remains the runtime gate.

@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-clean at f72b22d8; runtime gate H6 remains open)
Head SHA: f72b22d8da34306c9fc85e48667b101a01bf6f8d (delta from 066af3c7) | Objective / Bar: integration candidate for ai-openshell#471 fix A (stacked on #42 @6efaf294); live WP-6 H6 run remains the runtime gate.

Prior Review (6073718867) Resolution

  • Blocking (l7/relay.rs:emit_policy_reload) — RESOLVED: emit_policy_reload is removed repo-wide (0 remaining references) and replaced by emit_l7_stale_tunnel_close + stale_tunnel_close_message(guard, host, port) across all 5 L7/WebSocket call sites (l7/relay.rs:1589, 2063, 2124, 2137; l7/websocket.rs:1145). Credential-only closes now emit after provider credential rotation [cause:credential_epoch_stale ... captured_credential_epoch:N current_credential_epoch:M], distinct from policy reloads.
  • Same-class audit items — RESOLVED: evaluate_l7_request_once (l7/relay.rs:3087) now reuses engine.generation_guard().ensure_current()?, and the CONNECT dial-interrupt path (proxy.rs:2654-2662) reuses connect_generation_guard.ensure_current() / GenerationChannelClosed instead of synthesizing policy counters.
  • Prior non-blocking fold-ins — RESOLVED:
    • crates/openshell-core/src/telemetry.rs:254, 269, 289 + crates/openshell-server/src/telemetry.rs:105-110: DenyGroup::CredentialStale added and tested so "credential_stale" maps to itself instead of Unknown.
    • crates/openshell-supervisor-network/src/proxy.rs:3461-3484: stale_close_evidence walks error.chain() for both GuardStaleness and typed GenerationChannelClosed (opa.rs:236-240, used in proxy/relay.rs:340 and proxy.rs:2658), giving engine teardown its own [cause:generation_channel_closed] without mislabeling it as a policy change.

Findings

  • Required now: None in source at f72b22d8. Runtime gate remains open: exact-head WP-6 H6 receipt proving (a) non-credential passthrough tunnel survives provider-env-only revision and (b) credentialed tunnel rebinds cleanly on rotation.
  • Track next (non-blocking polish):
    • crates/openshell-supervisor-network/src/proxy.rs:3487 — stale_close_evidence formats {error} rather than {error:#}. On wrapped miette::Report chains (e.g. proxy.rs:2662 .wrap_err("CONNECT upstream dial interrupted")), Display prints only the outer context string and omits the inner counter pair ([captured_generation:.. current_generation:..]), though group and [cause:...] are preserved via error.chain(). Switching to {error:#} would retain counters in wrapped OCSF messages too.
    • Previously deferred: warn! prose / CONNECT 403 body text (proxy.rs:3526, 3536) still say "policy changed", and MiddlewareSessionEndReason::PolicyReload proto enum is shared across policy and credential stale closes. Track under the ai-openshell#471 follow-up bead if desired; not a merge gate.

Ownership / Reuse

  • Unchanged from reviews 6073566705 and 6073718867 (OpenShell stacked on #42 @6efaf294). Extends existing PolicyGenerationGuard, GuardStaleness, DenyGroup, and L7/proxy OCSF emitters with no parallel subsystem.

Validation (independently verified at exact head f72b22d8)

  • git diff --check 6efaf2943e7218850b49d8fab24a00fef66c4ef6...HEAD: clean
  • cargo fmt --all -- --check: clean
  • cargo clippy -p openshell-core -p openshell-supervisor-network -p openshell-supervisor -p openshell-server --all-targets -- -D warnings: clean
  • cargo test -p openshell-supervisor-network --lib -- stale_close_evidence stale_close_message_tests credential_epoch_tests: 8 passed, 0 failed
  • cargo test -p openshell-supervisor-network --lib -- proxy::relay::tests: 10 passed, 0 failed
  • cargo test -p openshell-server --lib -- deny_group_sanitization: 1 passed, 0 failed
  • cargo test -p openshell-core --lib -- telemetry: 10 passed, 0 failed
  • cargo test -p openshell-supervisor --lib -- activity_aggregator provider_env_only_revision: 6 passed, 0 failed
  • CI status: no GitHub Actions check runs or workflow runs reported on f72b22d8 (unknown / none configured).
  • Docker / Runtime E2E: pending live WP-6 H6 run with accepted #42 + #43 (+ D1b) exact heads.

Blast Radius

  • crates/openshell-core/src/telemetry.rs, crates/openshell-server/src/telemetry.rs, crates/openshell-supervisor-network/src/{opa.rs, proxy.rs, proxy/relay.rs, l7/relay.rs, l7/websocket.rs}. All emit_policy_reload and DenyGroup match sites audited repo-wide; zero stale callers remain.

Simplification

  • Clean: single typed GuardStaleness + GenerationChannelClosed source of truth shared across opa.rs, proxy.rs, proxy/relay.rs, l7/relay.rs, and l7/websocket.rs.

@agents-lightforge

Copy link
Copy Markdown

[hugo]

Conformance: CONDITIONAL PASS
Reviewed head: f72b22d8da34306c9fc85e48667b101a01bf6f8d
Bar: ai-openshell#471 integration candidate; exact-head H6 remains the runtime qualification gate.

Findings:

  • Required source changes from 7191152442 are resolved. GuardStaleness is now the single typed cause; wrapped reports retain it via chain-walk; raw relay, CONNECT interruption, inspected L7, WebSocket, and channel-close paths emit the correct stable cause and matching counter pair. credential_stale is preserved through supervisor and server telemetry.
  • Required runtime evidence remains open: H6 must prove the provider-env rotation no longer closes the raw TLS passthrough used by session-create.
  • Track next: the remaining warning/403 prose that says policy changed is diagnostic polish; OCSF/activity evidence is correctly typed and this is not a merge gate.

Ownership/reuse:

Validation:

  • git diff --check 0c351621...f72b22d8: PASS
  • cargo fmt --all -- --check: PASS
  • network lib: 1317 passed, 0 failed, 2 ignored
  • supervisor lib: 131 passed, 0 failed
  • core lib: 496 passed, 0 failed
  • server telemetry regression: 1 passed, 0 failed
  • clippy for core/network/supervisor/server with -D warnings: PASS
  • GitHub: OPEN, CLEAN, MERGEABLE; no check runs reported.

Blast radius: policy reloads still invalidate every guard; credential-only activation invalidates only dependent guards; failure paths remain fail-closed.

Simplification: typed guard staleness is reused by all emitters; no parallel evidence path was added.

@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: f72b22d8da34306c9fc85e48667b101a01bf6f8d

The previously deferred ai-openshell#471 runtime gate is closed by WP-6 H6d wp6-agy-20261127h6d on exact aggregate e2e20ace. First-session and restart-session passed; no sandbox_session_not_registered and no policy-generation stale close occurred. The credential-epoch split therefore passed the live session-create path that previously failed.

No required finding remains. GitHub reports no CI/check runs; prior exact-head local suites plus H6d satisfy the runtime evidence bar.

Merge sequencing: after #42 merges, retarget #43 to lightforge-main, confirm the head remains f72b22d8 and mergeability remains clean, then merge as a merge commit. The tested aggregate already contains this exact composition. No technical or evidence blocker remains.

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

@raghusubramanyam
raghusubramanyam changed the base branch from fix/gateway-restart-readopt to lightforge-main November 26, 2026 21:08
@raghusubramanyam
raghusubramanyam merged commit 03b4f36 into lightforge-main Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants