Skip to content

Contract remaining SSE writes onto the downstream commit seam #223

Closed

Description

@NOirBRight

Parent

Part of #147. Delivers the contract-and-cleanup slice that completes #18.

What to build

Bring every remaining SSE downstream write path under the shared stream-commit contract, including converted-route terminal and diagnostic output, without changing how those routes parse or translate protocol events. After this slice, downstream ownership has one enforceable contract rather than route-local exceptions.

Acceptance criteria

  • All production SSE client writes, terminal commits, and stream-error commits are owned by the shared downstream seam or an explicitly documented non-streaming path.
  • No route can write after the Terminal Ledger is committed, and duplicate terminal or error output is rejected deterministically.
  • Disconnect, cancellation, and writer cleanup are bounded across Official, transparent third-party, and converted streams.
  • A scope audit demonstrates that no production route-specific direct SSE write remains outside the contract.
  • Existing protocol conversion, event parsing, tool behavior, and response payload semantics remain unchanged; event-boundary parsing stays in Reassemble multi-line SSE data events before JSON parsing #20.

Blocked by

Activity

  1. added
    bugSomething isn't working
    ready-for-agentFully specified, ready for an AFK agent
    wayfinder:taskWayfinder implementation task
    tier:heavyOrchestrator provider tier: heavy
    P1Priority 1: current iteration goal
    on Jul 25, 2026
  2. NOirBRight commented on Jul 25, 2026

    @NOirBRight
    OwnerAuthor
    {
      "contract": {
        "acceptance": [
          "Every production SSE header and body write is authorized by one request-scoped downstream commit ledger; a static audit test proves no direct streaming wfile write or framing-helper bypass remains.",
          "Physical framing helpers are permitted only beneath seam authorization, and the named non-streaming allowlist is complete and enforced by test.",
          "No route writes after protocol-correct terminal commitment, emits duplicate terminal/error output, retries, or falls back after downstream exposure.",
          "Responses terminal events seal their ledger; Chat routes that intentionally emit a finish-reason chunk followed by DONE preserve both and seal only at the correct final boundary.",
          "Official, same-format transparent, converted, retry-diagnostic, image-progress, cancellation, keepalive, and post-relay error paths preserve their current public wire and protocol semantics.",
          "Downstream disconnect closes owned upstream work and produces exactly one sanitized request_complete=499; cancellation preserves its established classification. Neither path redesigns Issue #19 reader lifecycle.",
          "Regression and scope-audit evidence covers pre-output, mid-event, keepalive, converted output, cancellation, actual downstream OSError, and post-terminal suppression."
        ],
        "change_claims": {
          "paths": [
            "src-python/codex_proxy.py",
            "tests/test_routing.py",
            "tests/test_chat_completions_gateway.py",
            "tests/test_proxy_event_logging.py",
            "tests/test_proxy_shutdown.py"
          ],
          "resources": [
            "gateway-downstream-stream-commit",
            "gateway-converted-sse",
            "gateway-request-level-sse-diagnostics",
            "gateway-shutdown-cancellation"
          ]
        },
        "dependencies": {
          "dispatch_after": [
            222
          ],
          "merge_after": [
            222
          ]
        },
        "design": [
          "Promote the downstream stream-commit seam to request scope so it authorizes every production SSE header, keepalive, data, terminal, error, retry-diagnostic, image-progress, transparent, and converted-route write while handing off owned upstream responses between attempts.",
          "Low-level framing helpers may remain, but no production streaming caller may invoke them outside the seam ledger. Preserve a static named allowlist for non-streaming JSON, WebSocket, and body relay writes.",
          "Reuse existing route observers and converters: they pass explicit protocol-specific terminal facts into the seam. Do not add a second SSE/Responses/Chat parser; Issue #20 owns event-boundary parsing.",
          "Preserve exact successful bytes, order, model/tool/usage identity, Route Affinity, target-protocol error envelopes, Chat finish-reason plus required DONE sequencing, and current conversion semantics.",
          "Issue #223 owns downstream writer and upstream-close handoff using existing bounds. It does not redesign queued reader lifecycle, backpressure, join, or shutdown bounds owned by Issue #19."
        ],
        "difficulty": "heavy",
        "done_when": [
          "Focused scope-audit and lifecycle regressions are observed failing before implementation and passing afterward.",
          "python -m pytest -q tests/test_routing.py tests/test_chat_completions_gateway.py tests/test_proxy_event_logging.py tests/test_proxy_shutdown.py",
          "python -m pytest -q tests/test_protocol_translation.py (evidence-only unless the admission is explicitly amended)",
          "python -m pytest -q",
          "git diff --check",
          "python scripts/report_quality_gates.py (report-only)",
          "An exact-local-SHA Standards and Spec review reports no blocker before the branch is pushed once."
        ],
        "priority": "P1",
        "risk": "strict",
        "sha256": "d8c39b533b7c8de2cad5d8783b24095bd69bbcf6d10f88b2b2bc870dd7b37b38",
        "unresolved_decisions": []
      },
      "dispatch": {
        "attempt": 1,
        "base_sha": "34830d81b03df0e2abe98c745ddfa3e10a936694",
        "branch": "work/issue-223",
        "claimed_at": "2026-07-25T15:34:51.083237Z",
        "contract_sha256": "d8c39b533b7c8de2cad5d8783b24095bd69bbcf6d10f88b2b2bc870dd7b37b38",
        "creator_agent_id": "d81c5928-aff7-4d9d-b6a0-2b9f70ffad21",
        "generation": 1,
        "id": "dispatch-issue-223-a1",
        "status": "running",
        "worker_agent_id": "582bfd8f-e0ce-4251-b109-16153619c9cb",
        "workspace_id": "wks_d683959a1fd8428e"
      }
    }
  3. added
    orch:readyOrchestrator V6: valid hashed contract is complete and dispatchable
    orch:activeOrchestrator V6: claimed Worker is active or rework is in progress
    and removed
    orch:readyOrchestrator V6: valid hashed contract is complete and dispatchable
    on Jul 25, 2026
  4. added a commit that references this issue on Jul 25, 2026
  5. NOirBRight commented on Jul 25, 2026

    @NOirBRight
    OwnerAuthor

    Completed by PR #231 and merged into dev.

  6. removed
    orch:activeOrchestrator V6: claimed Worker is active or rework is in progress
    on Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1: current iteration goalbugSomething isn't workingready-for-agentFully specified, ready for an AFK agenttier:heavyOrchestrator provider tier: heavywayfinder:taskWayfinder implementation task

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions