Skip to content

Controller fixes from code review: queue timeout, LF line model, rejection reasons - #115

Merged
kudama merged 4 commits into
mainfrom
review/controller-fixes
Nov 19, 2026
Merged

kudama merged 4 commits into
mainfrom
review/controller-fixes

Conversation

@kudama

@kudama kudama commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Fixes three issues in the existing Forge controller:

  1. Queue wait and execution use separate budgets. FORGE_QUEUE_TIMEOUT defaults to 600 seconds; queued tasks expire independently of running inference, release their source packets/admission capacity, and report queue_expired without inference. Dispatch cancels the queue timer; shutdown cancels remaining timers. Configuration requires a finite positive queue timeout.
  2. Source readers, evidence validation and evaluation use LF-only line numbering. Native work orders explicitly reject carriage-return sources as unsupported_line_endings.
  3. Rejected work orders return bounded reason codes, relayed through MCP as invalid_request: .

Review follow-up adds regression coverage for expiry while inference remains blocked, repeated slot reuse without physical queue buildup, surviving FIFO order, queue completion accounting, cancellation/shutdown, running-task protection, and nonfinite direct/environment configuration. The 600-second default remains configurable.

Validation: full suite passes, 548 tests and 2 subtests. New regressions reproduced the failures on the original PR. Runtime/source/test files are unchanged by the rebase onto main.

Targets main because these are existing-controller fixes. Draft Forge v2 specification documents remain separately on forge-v2; this PR does not include them. No deployed service or model configuration changed.

@kudama kudama left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2026-11-18 against f2d59c9. Independently ran the full suite: 538 passed, 2 subtests passed; GitHub Tests and Checkmk compatibility are green. LF-only source numbering and the execution/queue budget separation are sensible changes, but I recommend addressing the queue-expiry gap before merge; details inline. Also reject nonfinite queue-timeout settings.

Independent expiry probe: with execution timeout=5s, queue_timeout=0.05s and capacity=2, a second task remains queued after 0.15s behind blocked inference; a third submission is rejected with 503. Only after releasing the first task is the second marked queue_expired, with no additional inference. Thus the new setting is currently a dispatch-time eligibility test, not an actual bound on queued lifetime/capacity.

600s is a reasonable provisional configurable default, not a measured scheduling recommendation. No controller configuration, model default, deployed source, or service state was changed during review. This PR targets forge-v2, not main; the draft v2 specification is an additional branch commit rather than another new open PR.

Comment thread src/forge_controller/app.py Resolved
Comment thread src/forge_controller/config.py Resolved
claude and others added 4 commits November 18, 2026 21:56
The execution deadline previously started at enqueue time while a single
worker drains the queue, so a task could be killed (or expire before it ever
ran) purely because of work ahead of it.

- Execution deadline (FORGE_TASK_TIMEOUT) now starts at dispatch.
- New FORGE_QUEUE_TIMEOUT (default 600s) bounds queue wait; expiry is the
  distinct terminal error 'queue_expired', decided before the task is marked
  running and without consuming inference.
- Docs updated; this intentionally changes documented v1 semantics to meet
  docs/v2 SRV-04 / MCP-07 (queue wait separate from execution time).
…xplicitly

Line numbers were produced with str.splitlines(), which also splits on
\x0b, \x0c, \x1c-\x1e, \x85 and U+2028/9. Any such character shifted every
later line number away from git/editor numbering (8 of 8 separators
reproduced), while evidence validation used the same wrong numbering, so a
citation could pass validation yet point a reviewer at the wrong line.

- Add tools.split_lines (LF only) and use it for reads, snapshot reads,
  result-evidence bounds and the evaluator.
- CRLF sources can never satisfy exact multi-line replacement (the model is
  shown text the raw source does not contain). Preflight now rejects any
  source containing CR with the explicit reason 'unsupported_line_endings'
  instead of failing every edit later as 'replacement_not_exact'.
- Tests compare snapshot numbering with 'git grep -n' as the oracle.
Every preflight failure (about a dozen distinct HandoffError codes such as
stale_revision, runtime_limits_mismatch, source_hash_mismatch, scope_denied)
collapsed to a bare 422 'invalid_work_order', and the MCP bridge collapsed it
again to 'invalid_request', so callers could not tell what to fix (#76,
docs/v2 MCP-07).

- Controller: 422 body now carries {'detail','reason'} when the failure is a
  HandoffError whose code matches ^[a-z0-9_-]{1,64}$. KeyError/ValueError and
  malformed codes still return the bare 'invalid_work_order'.
- Bridge: relays 'invalid_request: <reason>' only for a bounded, well-formed
  reason on a 422 invalid_work_order; never relays other upstream text. The
  existing 403 source_reads_required behaviour is unchanged.
- Docs list the closed reason vocabulary.
@kudama
kudama force-pushed the review/controller-fixes branch from f2d59c9 to 2711efa Compare November 19, 2026 05:57
@kudama
kudama changed the base branch from forge-v2 to main November 19, 2026 05:57

kudama commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Review fixes pushed in 2711efa (2026-11-18). Queued expiry now runs independently, settles/reclaims waiting entries while inference continues, preserves FIFO and Queue accounting, and cancels timers at dispatch/shutdown. NaN/infinity are rejected for both direct and environment configuration. Original review regressions failed before the fix; full suite now passes: 548 tests and 2 subtests.

Per Mike’s correction, rebased the controller-only commits onto main and retargeted this PR to main. The draft v2 docs remain untouched on forge-v2 and are excluded from this diff. Verified the tested runtime/scripts/tests and relevant v1 docs are byte-identical across the rebase. Remote update used an expected-head lease to preserve any concurrent edits. Nothing merged or deployed; next gate is refreshed CI/review.

kudama commented Nov 19, 2026

Copy link
Copy Markdown
Owner Author

Refreshed CI is green for 2711efa: Tests (including fresh Ubuntu/macOS environments) and Checkmk compatibility both passed. Both review findings are resolved. PR #115 targets main and excludes docs/v2; the v2 specification remains on its separate branch. Ready for merge review; not merged or deployed.

@kudama
kudama merged commit 26c901d into main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants