fix(gateway): close Phase 3C audit gaps
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-29
|
||||
@@ -0,0 +1,47 @@
|
||||
## Context
|
||||
|
||||
The implementation already contains a source-shaped Apollo fake, native recovery, bounded gateway queues, fair pacing, Verse framing/QUIC, independent client support, lifecycle reporters, and low-cardinality telemetry. Audit defects arise where those existing pieces are bypassed or not connected.
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
|
||||
- Reuse the existing production path for policy, lifecycle, recovery, telemetry, and qualification.
|
||||
- Delete duplicate qualification simulation.
|
||||
- Preserve all trust, cleanup, and resource bounds.
|
||||
|
||||
**Non-Goals:**
|
||||
|
||||
- Add codecs, provider transports, dependencies, or a generic lifecycle/telemetry framework.
|
||||
- Claim live Apollo/macOS/firewall interoperability.
|
||||
- Run the normative qualification before immutable consumer resolution.
|
||||
|
||||
## Decisions
|
||||
|
||||
- Format ANNOUNCE from `ProviderStreamPolicy` using the pinned Moonlight common-c bitrate and codec attributes. H.264 and HEVC with audio enabled are supported; AV1 and audio disabled fail before management/network readiness.
|
||||
- Treat the current exact `client_decode` string as the negotiated decode profile. The default advertises the bounded H.264+HEVC set, and provider work must be a member of it.
|
||||
- Consume existing provider events in the gateway session loop. Termination and disconnect cancel forwarding, then reuse current cleanup/release/reporting machinery and its cleanup-pending result.
|
||||
- On a full audio FEC map, evict the oldest block according to existing block ordering and increment existing drop telemetry.
|
||||
- Sample existing process counters at heartbeat time; calculate rate from byte and monotonic-time deltas while leaving configured capacity in registration.
|
||||
- Build qualification on the existing native/provider fixture and public QUIC client path. Production stage observations replace the standalone codec and arithmetic impairment simulator; short smoke gates freeze the wiring, while normative durations remain deferred.
|
||||
- Preserve the production fair-pacer schedule across short host-timer overshoots so
|
||||
measured allocation can catch up within the already bounded provider queue
|
||||
instead of accumulating timer granularity as lost capacity.
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- [Apollo cannot represent disabled audio truthfully] → Reject it rather than silently streaming stereo.
|
||||
- [Provider event races with media] → Cancel the session first and let bounded cleanup serialize final release/reporting.
|
||||
- [Counter reset or zero elapsed time] → Emit zero measured rate and establish a new baseline.
|
||||
- [Corrected qualification is more expensive] → Run only short smoke tests until the immutable candidate is frozen.
|
||||
- [Pacer catch-up can emit a short burst after timer overshoot] → Clamp schedule
|
||||
debt to five milliseconds in addition to the existing 16-packet provider
|
||||
queue.
|
||||
|
||||
## Migration Plan
|
||||
|
||||
Land focused red/green repairs locally, verify through the temporary Protocol workspace, preserve old artifacts as superseded, and stop at the publication boundary. After a separately authorized immutable Protocol release is pinned, freeze inputs and run the corrected normative qualification once.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,28 @@
|
||||
## Why
|
||||
|
||||
Fresh audit evidence shows the gateway ignores the immutable launch policy, leaves tunnels alive after provider termination/disconnect, can permanently stall audio after sustained loss, reports configured capacity as measured egress, and qualifies a standalone simulator instead of the production path.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Apply the effective policy to Apollo ANNOUNCE and reject unsupported or downgraded profiles before readiness (P3C-009, P3C-016, P3C-038).
|
||||
- Convert provider termination/disconnect into bounded tunnel and durable lifecycle transitions while preserving cleanup-pending semantics (P3C-018–021, P3C-027).
|
||||
- Evict bounded stale audio FEC blocks so newer recoverable media continues (P3C-001, P3C-026).
|
||||
- Derive heartbeat egress and required low-cardinality telemetry from observed counters (P3C-022, P3C-028).
|
||||
- Replace standalone processing/impairment simulation with a driver around the source-shaped provider, production queues/pacer/framing, QUIC, and an independent client (P3C-029–033, VER-008, VER-010).
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
- `apollo-stream-policy`: Native Apollo launch consumes the authenticated effective stream policy without downgrade.
|
||||
- `provider-session-lifecycle`: Provider terminal events close forwarding and report the correct durable lifecycle outcome.
|
||||
- `audio-fec-resilience`: Bounded Apollo audio recovery continues after permanently incomplete blocks.
|
||||
- `gateway-heartbeat-telemetry`: Authenticated heartbeat telemetry reports observed traffic and provider-path measurements.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `gateway-qualification`: Normative evidence must traverse the production gateway path and retain raw resource, impairment, fairness, cap, and convergence observations.
|
||||
|
||||
## Impact
|
||||
|
||||
The native Apollo adapter, transport lifecycle, audio FEC state, heartbeat sampling, qualification driver, focused fixtures, and canonical qualification spec change. No dependency, cgo, sidecar, codec operation, direct provider route, or live interoperability claim is added.
|
||||
@@ -0,0 +1,15 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Apollo launch consumes the effective policy
|
||||
The native Apollo backend SHALL derive ANNOUNCE resolution, frame rate, supported codec, selected bitrate, and audio profile from authenticated `ProviderSessionWork`, and MUST NOT substitute local defaults.
|
||||
|
||||
#### Scenario: Supported HEVC policy reaches Apollo
|
||||
- **WHEN** provider work selects HEVC at 2560×1440, 120 FPS, 40000 Kbps, with audio enabled
|
||||
- **THEN** the encrypted ANNOUNCE carries those settings and the source-backed HEVC and bitrate attributes
|
||||
|
||||
### Requirement: Provider policy cannot downgrade
|
||||
The gateway MUST reject an invalid, unsupported, audio-disabled, AV1, or capability-mismatched Apollo policy before provider readiness because the current native path cannot truthfully honor those combinations.
|
||||
|
||||
#### Scenario: Unsupported policy fails closed
|
||||
- **WHEN** authenticated provider work selects audio disabled, AV1, or a codec outside the negotiated client-decode profile
|
||||
- **THEN** setup fails before readiness without falling back to H.264, stereo, or another local default
|
||||
@@ -0,0 +1,8 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Bounded audio FEC state advances after loss
|
||||
The Apollo audio recovery window SHALL remain bounded and SHALL evict the oldest incomplete block when accepting a newer block would otherwise be rejected.
|
||||
|
||||
#### Scenario: Newer complete block follows sustained loss
|
||||
- **WHEN** more than the bounded number of permanently incomplete audio blocks arrive before a complete newer block
|
||||
- **THEN** the oldest stale state is dropped, drop telemetry advances, and the newer encoded payload is relayed unchanged
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Heartbeat egress is observed
|
||||
Authenticated gateway heartbeat telemetry SHALL calculate egress from monotonic transmitted-byte deltas over monotonic elapsed time and MUST NOT report configured capacity as measured traffic.
|
||||
|
||||
#### Scenario: Controlled byte delta is sampled
|
||||
- **WHEN** transmitted bytes increase by a known amount during a known interval
|
||||
- **THEN** heartbeat egress equals the measured rate while configured capacity remains a separate registration value
|
||||
|
||||
### Requirement: Required telemetry remains bounded and low cardinality
|
||||
The established authenticated path SHALL expose observed bytes, packets, drops, RTT, loss, jitter, queue delay, processing delay, pacing, reconnect, and provider state without session, route, credential, or payload labels.
|
||||
|
||||
#### Scenario: Telemetry snapshot is published
|
||||
- **WHEN** the gateway emits a heartbeat after forwarding traffic
|
||||
- **THEN** it carries the bounded process-level observations and no high-cardinality or secret-bearing value
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Fixed media processing qualification
|
||||
The qualification harness SHALL drive the source-shaped provider fixture through Apollo recovery/FEC, bounded production queues, the production fair pacer, Verse framing/QUIC, and an independent client for 1080p60 H.264 at 20 Mbps, 1440p120 HEVC at 50 Mbps, and 4K60 HEVC at 80 Mbps. After a recorded warm-up, the frozen candidate SHALL run each profile for ten wall-clock minutes, preserve encoded payload bytes, retain every monotonic processing sample plus bounded CPU, memory, goroutine, and allocation observations, and report count, min, median, p90, p95, p99, max, mean, standard deviation, timing overhead, and observed bitrate. Any payload mutation or p95 above 5 ms SHALL fail.
|
||||
|
||||
#### Scenario: Healthy fixed profile
|
||||
- **WHEN** a frozen candidate runs one fixed profile for the normative duration
|
||||
- **THEN** the harness emits compressed raw path and resource samples plus a summary tied to the exact command, topology, source commit, immutable Protocol version, environment, and payload hash
|
||||
|
||||
#### Scenario: Processing gate failure
|
||||
- **WHEN** any production path stage is bypassed, payload integrity fails, or measured p95 exceeds 5 ms
|
||||
- **THEN** the qualification command exits unsuccessfully without recording a passing candidate
|
||||
|
||||
### Requirement: Bounded impairment qualification
|
||||
The harness SHALL run exactly the baseline, latency, jitter, loss, reorder, and constrained Section 7.2 profiles once against traffic traversing the production gateway path. Baseline SHALL cover all three media profiles and the other profiles SHALL cover 1080p60. Each artifact SHALL retain raw impairment observations and record tool version, exact command/configuration, environment, candidate commit, immutable Protocol version, direction, queue discipline, topology, fixed seed, and observed RTT, jitter, loss, reorder, throughput, drops, and capacity-step statistics.
|
||||
|
||||
#### Scenario: Complete six-profile run
|
||||
- **WHEN** the frozen candidate runs impairment qualification
|
||||
- **THEN** one result exists for each named profile, with no Cartesian expansion and with raw observed rather than configured statistics from the real traversal
|
||||
|
||||
#### Scenario: Unsupported or unbounded configuration
|
||||
- **WHEN** a profile name, packet count, queue bound, loss, reorder, or bandwidth step falls outside the fixed catalog
|
||||
- **THEN** the harness rejects it before allocating or running traffic
|
||||
|
||||
### Requirement: Fairness and cap qualification
|
||||
The harness SHALL exercise the production fair pacer with eight equal-tier synthetic sessions for the required 60-second virtual interval, retain every per-flow and aggregate observation, report every share error and Jain's fairness index, and fail above 10% share error. It SHALL apply 25% and 50% capacity steps, measure convergence of observed allocation rather than first delivery, fail convergence beyond ten virtual seconds, and fail aggregate egress above 105% of the cap over any rolling five-second window.
|
||||
|
||||
#### Scenario: Equal-tier and capacity-step evidence
|
||||
- **WHEN** the frozen candidate runs scheduler qualification
|
||||
- **THEN** the artifact contains raw per-flow bytes, aggregate-cap series, share errors, Jain's index, measured allocation convergence, and rolling cap observations derived from the production pacer
|
||||
|
||||
### Requirement: Honest qualification boundary
|
||||
Qualification artifacts SHALL contain no provider endpoint, credential, clipboard text, input payload, secret, or raw media content and SHALL make no claim of live Apollo/macOS/firewall interoperability. The harness SHALL add no codec operation, production dependency, cgo, sidecar, direct provider route, or duplicate processing/impairment simulator. Deterministic smoke evidence SHALL remain distinct from the single normative run on the frozen immutable consumer candidate.
|
||||
|
||||
#### Scenario: Deterministic evidence publication
|
||||
- **WHEN** qualification completes
|
||||
- **THEN** the manifest labels fake-provider, path impairment, and local processing evidence separately and leaves live interoperability deferred-owner-e2e
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Provider terminal events end forwarding
|
||||
Encrypted provider termination and unexpected provider disconnect SHALL stop media forwarding, close the Verse tunnel within a bounded interval, release the session reservation, and report the appropriate durable provider/session state.
|
||||
|
||||
#### Scenario: Host termination closes the tunnel
|
||||
- **WHEN** the native provider emits an authenticated termination event
|
||||
- **THEN** no later provider media is delivered and the client tunnel, reservation, and durable lifecycle transition complete
|
||||
|
||||
#### Scenario: Unexpected provider disconnect is reconnectable
|
||||
- **WHEN** required provider transport disconnects without acknowledged termination
|
||||
- **THEN** forwarding stops and the Server receives the existing reconnectable lifecycle state rather than a termination claim
|
||||
|
||||
### Requirement: Cleanup failure remains durable
|
||||
Gateway cleanup MUST preserve `cleanup_pending` when provider input release, transport cleanup, authorized cancellation, or durable reporting fails.
|
||||
|
||||
#### Scenario: Terminal cleanup fails
|
||||
- **WHEN** a provider terminal event is handled but required cleanup cannot complete
|
||||
- **THEN** the session is not reported released or reusable and durable state remains cleanup pending
|
||||
@@ -0,0 +1,23 @@
|
||||
## 1. Native Policy and Media
|
||||
|
||||
- [x] 1.1 Drive supported immutable policy values into encrypted Apollo ANNOUNCE
|
||||
- [x] 1.2 Reject unsupported and capability-mismatched policy before readiness
|
||||
- [x] 1.3 Evict oldest incomplete audio FEC state and pass sustained-loss relay regression
|
||||
|
||||
## 2. Lifecycle and Telemetry
|
||||
|
||||
- [x] 2.1 Close forwarding and report durable state on provider termination and disconnect
|
||||
- [x] 2.2 Preserve cleanup-pending on terminal cleanup failure
|
||||
- [x] 2.3 Report measured heartbeat egress and required bounded telemetry
|
||||
|
||||
## 3. Qualification Path
|
||||
|
||||
- [x] 3.1 Add a red-to-green end-to-end production-path smoke gate
|
||||
- [x] 3.2 Remove duplicate processing and impairment simulation
|
||||
- [x] 3.3 Retain raw processing, impairment, fairness, cap, convergence, and resource observations
|
||||
- [x] 3.4 Pass short fixed-profile, impairment, fairness, race, parser fuzz, and resource smoke checks
|
||||
|
||||
## 4. Immutable Freeze
|
||||
|
||||
- [ ] 4.1 Pin and verify a separately published never-reused Protocol version from an empty cache
|
||||
- [ ] 4.2 Freeze all normative inputs and run the corrected Section 7 qualification exactly once
|
||||
Reference in New Issue
Block a user