Skip to content

REQ 114

sergio velderrain edited this page Nov 11, 2026 · 2 revisions

REQ-114: Bounded review lifecycle and safe cancellation

Requirement

The engine shall execute each Ollama review within an explicit finite lifecycle policy that preserves shared daemon and model-store state on completion, failure, or cancellation.

Rationale

Per-request timeouts alone do not bound a multi-frame review or define residency after a later request fails. An agent must not recover by stopping a shared daemon or deleting another user's models. Issue #235, under epic #229, provides the lifecycle boundary required before resumable inference.

Fit Criterion

The caller-approved policy specifies positive overall and per-request deadlines, finite request/retry limits (zero retries permitted), bounded backoff, maximum image count, and bounded requested residency. Deadlines use a monotonic clock and include preflight, inference, backoff, and postflight; an individual timeout never extends the overall deadline. Requests within one review are sequential unless a separately approved bounded concurrency policy is implemented. Cancellation stops scheduling new work/retries and produces a distinct incomplete/cancelled outcome rather than pass or configuration validity. A retry applies only to declared transient transport/server failures and the same approved request identity; malformed output and identity/authorization errors are not silently retried with weaker settings. Residency requests are explicit and recorded. A shared daemon is never stopped/reconfigured and models are never deleted; forced unload is forbidden without independently established exclusive ownership. A client timeout is not represented as proof that server computation stopped; uncertain remote completion is recorded and no success is inferred. Required resource limits unsupported by the daemon fail preflight rather than being asserted as enforced. Cleanup preserves the original failure cause and emits only sanitized diagnostics.

Verification

Lifecycle cases supporting TEST-116 integrated through PR #242, implementation 1a5dd256074e703c5500b048f9e93e45e776dde7, merge 2d328abe52b6594350d470c6d6f15c321ebebbd9. Local suites passed 2,109 Python and 91 .NET tests; focused slices passed 147 Python and 80 generation cases. All seven upstream checks passed, including Windows cancellation behavior. Fake clocks/events/transports cover overall/request deadlines, cancellation before and during I/O/backoff, request caps, identical bounded retries, no format retries, pending-header cancellation/timeout cleanup, and refusal of zero/unbounded residency. A separately authorized CPU-only public synthetic transport smoke succeeded within its limits; it is not resource-capacity, server-completion, private-evidence or native-build qualification.

Source

SYS-REQ-029; identity REQ-109, input limits REQ-111, and privacy REQ-113

Priority

High

TestID

TEST-116

TestArtifact

scripts/tests/test_assisted_benchmark_review.py (test_cancelled_review_never_starts_a_request, test_monotonic_deadline_stops_after_slow_preflight, test_retry_is_bounded_and_uses_identical_approved_payload, test_transport_retries_never_exceed_approval, test_cancellation_after_response_prevents_postflight_and_success, test_request_count_exhaustion_cannot_skip_postflight, test_http_request_cancellation_closes_the_active_operation, test_http_whole_request_timeout_closes_pending_headers, invalid-policy/backoff/no-unload cases); tools/source-config/ProjectBuddy.SourceConfig.Tests/GenerationTests.cs (CancelledReviewStartsNoHttpRequest, MonotonicReviewDeadlineStopsSlowPreflight, CancelledRequestCannotProceedToInference, TransientRetryIsBoundedAndResidencyIsNotAnUnload, RetriesDoNotWeakenRequestOrStatusPolicy, RequestBudgetCannotBeUsedToSkipPostflight, CancelledBackoffStartsNoRetry, MalformedModelOutputDoesNotTriggerFormatRetry); receipt fixtures in scripts/tests/test_assisted_benchmark_run.py and .github/workflows/ci-assurance.yml.

CodeRef

scripts/assisted_benchmark_contract.py (validate_review_lifecycle); scripts/assisted_benchmark_review.py (ReviewLifecycle, LifecycleTransport, LocalOllama._request, build_review_request, review_evidence: finite policy, monotonic accounting, bounded httpx 0.28.1 streaming/cancellation and residency); scripts/assisted_benchmark_run.py (orchestrate, main: lifecycle evidence and cancellation); tools/source-config/ProjectBuddy.SourceConfig/OllamaReview.cs (ReviewLifecyclePolicy, ReviewExecution.RequestAsync, Check, Summary, OllamaReview.RunAsync), Generation.cs (policy/evidence), and Program.cs (required policy and Ctrl+C), under tools/source-config/ProjectBuddy.SourceConfig/.

Status

Implemented in develop; deadline/cancellation/retry/residency regressions and CI verified, no server-completion or OS CPU/GPU hard-limit guarantee

Clone this wiki locally