Skip to content

REQ 127

sergio velderrain edited this page Nov 12, 2026 · 3 revisions

REQ-127: Bound live-session streaming and cancellation

Requirement

The live-session orchestrator shall apply one finite resource, deadline, and cancellation policy across on-demand, periodic, and continuous local-model interaction modes.

Rationale

Epic #250 compares three interaction modes while capture remains active. An unbounded event queue, response stream, retry, or residency interval could starve the capture workload or turn a partial result into a success. Existing per-request Ollama lifecycle and privacy contracts remain applicable; issue #255 adds the capture-time orchestration boundary.

Fit Criterion

The orchestrator uses the approved local model digest and execution settings, one overall monotonic deadline, bounded request count, bounded per-request time, bounded queue/batch size, and zero implicit retries. It preserves capture/event sequence and annotates each request, first/final streamed token, selected action, cancellation, and result with monotonic timestamps and the capture state. Backpressure never silently drops evidence: if the cursor gap, queue bound, deadline, cancellation, or resource budget is reached, the run becomes incomplete and no final assessment or further UI action is emitted. Cancellation is awaited and unresolved calls remain non-retryable. No remote inference fallback is permitted. Numeric latency/grounding/task thresholds are supplied only by a separately reviewed calibration requirement.

Verification

TEST-128 exercises fake-stream tests for delayed/partial tokens, queue saturation, budget exhaustion, cancellation during a request, error after partial output, and zero retries in all three modes. Opt-in candidate composition uses the real MCP SDK, a compiled Actor with temporary capture fixtures, and mock Ollama HTTP. This offline integration is merged through PRs #256 and #258; native Windows execution remains unqualified under issue #255.

Source

SYS-REQ-033; REQ-114; REQ-125; epic #250; P2 #255

Priority

High

TestID

TEST-128

TestArtifact

scripts/tests/test_assisted_benchmark_session.py tests all three modes, queue/request bounds, overall deadlines, cancellation settlement, capture-state/timestamp attribution, model drift, token-budget exhaustion, and incomplete status after partial responses. It also scores bounded observedState reading/limit claims with the independent synthetic oracle, separately from action correctness and task success, and rejects malformed observation claims. scripts/tests/test_assisted_benchmark_review.py checks the async HTTP stream and metadata boundaries, including redirect/compression/size refusal and response closure on cancellation. Set PROJECTBUDDY_ACTOR_FIXTURE_SERVER to an explicitly chosen compiled Actor candidate to enable the SDK/Actor/mock-HTTP composition cases; no real inference or capture is run.

CodeRef

scripts/assisted_benchmark_session.py implements the local LiveCaptureSession candidate under issue #255. It uses existing authorization, model-budget, request-budget, privacy, and frame-transformation validators; scripts/assisted_benchmark_review.py provides bounded async loopback model metadata and token streams. Capture polling and inference share one finite deadline, request bounds, a bounded queue, and zero retries. On-demand consumes explicit triggers, periodic schedules request starts, and continuous drains ordered evidence immediately. Streamed choices are checked against the exact run/frame and the two-action enum. With an explicitly supplied LiveChoiceDispatcher from scripts/assisted_benchmark_mcp_router.py, the scheduler consumes one existing sealed broker grant while capture is active; the dispatcher validates the pinned server set, immutable contract digest, capture/run/VM binding, model digest, exact task/candidate, and acknowledgement. Without that dispatcher the scheduler remains advisory. Returned results always have authorizesAction: false; actionApplied and actionOutcomeUnknown record only the broker-observed outcome, never new authority. Errors abort remaining authority and uncertain outcomes are non-retryable. Production pinning, approved launcher wiring, calibration, and live qualification remain pending.

Status

Candidate scheduler, streaming, SDK resource reads, and sealed one-shot action dispatch are integrated and offline-tested. No production enablement, calibration thresholds, or Windows/live capture/model qualification is claimed.

Clone this wiki locally