Commit d420117
fix(scheduler): serve in_progress SHORTEST-REMAINING first — turn effort into completions
Within a stage the matrix workers took the STALEST project. But working on a
project REFRESHES its `updated_at` and sends it to the back of the queue — so
in_progress was a strict ROUND-ROBIN over all 435 projects. Draining one takes
several ticks (~38 tasks at ~10/tick), so each project had to wait for the other
434 between touches. Every project crept forward and NONE ever finished: classic
processor-sharing starvation, and a direct reason zero projects had EVER crossed
research_complete even when the pipeline was healthy.
Meanwhile 68 projects were already close: 8 with <=5 tasks left, 54 with 16-30.
They were never prioritised, so they never landed.
FIX: implement stages (in_progress / paper_in_progress) are served
shortest-remaining-first — the project closest to done goes first (optimal for
mean completion time). Staleness stays the tiebreak. It cannot starve the long
projects: a finished project LEAVES the stage, so the queue steadily advances to
them. Everywhere else keeps oldest-waiting-first (no "remaining work" to be short
of). tasks.md is resolved via the SSoT `feature_dir_for`; an unreadable one sorts
LAST, so "no tasks file" can never masquerade as "almost finished".
Live effect (12 workers): the 8 in_progress workers now land on the projects that
can actually cross — five with 0 tasks remaining (straight to the execution gate),
then 1, 1, 2 remaining — instead of three arbitrary 60-task projects.
Also fixes a bug in the new apportionment: MAX_STAGE_WORKER_SHARE could IDLE a
worker when only one stage was occupied (nothing else to spend the capped slot
on). The cap exists to stop one stage crowding out others, never to waste a
worker — leftover slots are now filled ignoring the cap, bounded by pile size.
Full offline suite: 6147 passed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b544e23 commit d420117
2 files changed
Lines changed: 131 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
449 | 512 | | |
450 | 513 | | |
451 | 514 | | |
| |||
531 | 594 | | |
532 | 595 | | |
533 | 596 | | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
534 | 613 | | |
535 | 614 | | |
536 | 615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
0 commit comments