Repository navigation
Commit e235cde
authored
fix(scheduler): fence Python follow-ups on superseded heartbeat receipts (#8647)
* fix(scheduler): keep damaged history behind one receipt fence
The Python compatibility route and the native owner now agree on a single
freshness rule. A damaged row can no longer retire a valid ACK or failure
return, a committed successor still blocks an older return when only its
summary rotted, and the originating Turn plus Goal instance scope decide both
before the write and again under the state lock.
Re-applied on top of the merged #8708 minimal passthrough. This commit keeps
only the extra hardening: tolerant scheduler reads with strict settlement and
status reads, committed-successor scope proof, instance-range checks, and the
lock-time re-read before replay.
Verified on the current base with the six TypeScript suites (248 tests), the
control-plane type check, and the Python receipt-fence (30), follow-up hint
transport, single-request and rollout-log suites (53). The merged #8708
regression file passes 17 tests on the same tree. Windows, the installed host
UI, PostgreSQL and hosted CI were not exercised.
Signed-off-by: gcl-coder <gcl-coder@users.noreply.github.com>
* fix(scheduler): read an unreadable successor identity as superseding
A committed quota_should_run row can lose one byte of a nested display string
(the opening or closing quote of a details value) while every identity member
and the terminating newline stay intact. The tolerant scanner resynchronised
on the next plausible quote, swallowed the members that followed the damaged
nested value and reported the row as unrelated, so an older heartbeat return
regained write authority and both compatibility commands wrote again.
Receipt recovery now keeps the row's container state while it reads members.
A damaged byte where a value must start is that value's opening quote; a
damaged byte inside a string is the lost closing quote only when the
separator its role requires follows it, and a lost key name is reported as
such. Recovery also reports whether a separator or boundary was unknowable.
A same-scope row whose identity cannot be attributed now answers "unknown",
and the freshness check treats "cannot prove the successor is unrelated" as
stale. Rows whose readable identity proves another Agent, another Goal
lifetime or another event kind stay tolerated, and a diagnostic row with all
key names intact still cannot supersede a Turn.
Verified with real File and SQLite scheduler-ack-current and
scheduler-fail-current commands: opening-quote, closing-quote and in-text
damage of a committed turn-2 receipt all exit 1 with
heartbeat_receipt_stale, scheduler_state_mutated=false and unchanged log
bytes, while another Agent's damaged row still lets the current turn write.
TypeScript receipt log, commit, followup and CLI suites pass; the Python
receipt-fence suite passes on File and SQLite; control-plane typecheck
passes. Windows, hosted UI and hosted CI were not exercised here.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* fix(scheduler): keep a duplicated scope identity from hiding a successor
A stray rewrite can repeat a top-level scope member of an already committed
quota_should_run receipt (for example agent_id) while the only damaged byte is
in its display summary. Recovery now reads every value a member carries, so a
duplicate that repeats the same identity merges into one scope instead of
discarding the whole row. Duplicates whose values disagree keep the row inside
this scope and answer "unknown", which the freshness check already treats as
stale; only a row whose every scope value is foreign stays tolerated, together
with diagnostics whose key names survived.
Verified with real File and SQLite scheduler-ack-current and
scheduler-fail-current commands: a committed turn-2 receipt with a repeated
agent_id and one damaged summary byte exits 1 with heartbeat_receipt_stale,
scheduler_state_mutated=false and unchanged log bytes, while a foreign Agent's
row with the same shape still lets the current turn write. The full Python
receipt-fence suite passes on File and SQLite, the six scheduler TypeScript
suites pass, and control-plane typecheck passes.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* fix(scheduler): only a readable foreign identity may exclude a successor
A stray rewrite can duplicate a top-level scope member of a committed
quota_should_run receipt, name another Agent first and leave this scope's copy
where a single damaged byte makes it unreadable. The recovery reader reported
both the readable foreign value and the damaged key, but the successor check
trusted the foreign value alone and returned "unrelated", so an older Turn
regained write authority.
The exclusion branch now consults the same recovered key list: a member whose
every readable copy is foreign still proves the row unrelated only when no copy
of that member is unreadable. If the same member is also damaged, the row
answers "unknown", which the freshness check already treats as stale. Fully
readable foreign rows and surviving diagnostics stay tolerated.
Verified with real File and SQLite scheduler-ack-current and
scheduler-fail-current commands: a committed turn-2 receipt whose first
agent_id names another Agent while the trailing local copy holds a raw 0xff
now exits 1 with heartbeat_receipt_stale, scheduler_state_mutated=false and
unchanged log bytes. The mirrored order (local readable first, foreign copy
damaged) also keeps the old Turn retired. The full Python receipt-fence suite
passes (62 tests, File and SQLite), the six scheduler TypeScript suites pass
(99 tests), and control-plane typecheck passes.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* fix(scheduler): finish the scope check before reporting uncertainty
The previous commit treated an unreadable duplicate of a scope member as
uncertainty immediately, before examining the remaining members. A row whose
event kind was readable as a validation event and whose duplicate copy was
damaged therefore returned "unknown" even though its Agent identity was
complete and clearly another Agent's. That refused valid ACK and failure
writebacks on File and SQLite.
committedSuccessor now examines every identity member first. A member whose
every readable copy is foreign and whose own copies are all readable settles
the row as unrelated, regardless of damage in a different member. Uncertainty
stays local to the damaged member: a readable foreign value with an
unreadable twin of the same member still cannot exclude the row, and the
unreadable copies of this scope's members still answer "unknown".
Verified with real File and SQLite scheduler-ack-current and
scheduler-fail-current commands: another Agent's validation row with a
readable event kind and one damaged duplicate of that member no longer blocks
the current writeback (exit 0, scheduler_state_mutated=true, log bytes
unchanged), while this scope's damaged duplicates still return
heartbeat_receipt_stale with zero writes. The full Python receipt-fence suite
passes (66 tests, File and SQLite), the six scheduler TypeScript suites pass
(99 tests), and control-plane typecheck passes.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* fix(scheduler): read only committed rows when deciding freshness
A log write can stop between its complete JSON row and the newline that
commits it. The snapshot exposed that final record, so a nearly written
successor retired the old Turn and a nearly written original counted as the
Turn's receipt. The next append drops those bytes, which made the same
command flip from stale or missing to writable.
The snapshot now names the unterminated record line, and the scheduler
freshness read ignores that row for both the originating Turn and any
successor. The two Python append entry points also deduplicate against
newline-terminated rows only: retrying an interrupted append drops the
abandoned bytes and commits the row once, while a committed row still returns
the same record. General diagnostic reads keep the decodable tail.
Verified with real File and SQLite scheduler-ack-current and
scheduler-fail-current commands: an unterminated turn-2 successor no longer
retires turn-1 (exit 0, scheduler_state_mutated=true), and an unterminated
turn-1 row reports heartbeat_receipt_missing both before and after the next
append drops it. The full Python suite passes (106 tests), appended-row dedup
covers both entry points, the scheduler TypeScript suites pass (105 and 157
tests), and control-plane typecheck passes.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* fix(scheduler): ignore unterminated rows in prior-turn recovery
A complete JSON row without its committing newline is abandoned by the
next append. Use the same committed-only view for strict settlement,
receipt qualification and prior-host-Turn recovery so an interrupted
receipt cannot make a later admission ask for recovery before the next
append and then disappear.
Verify File and SQLite real CLI prior-turn recovery with committed and
unterminated guard receipts, plus TypeScript settlement preflight and
control-plane typecheck.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
* Use committed receipts for tolerant settlement history
Filter unterminated scheduler settlement rows through the existing committed
rollout view in quota settlement readback and replanned history. Add TypeScript
and real File/SQLite CLI regressions for interrupted tails while preserving
damaged-row tolerance.
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
---------
Signed-off-by: gcl-coder <gcl-coder@users.noreply.github.com>
Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>1 parent 0ddcaba commit e235cde
33 files changed
Lines changed: 4326 additions & 123 deletions
File tree
- loopx
- cli_commands
- control_plane
- quota
- runtime
- scheduler
- status
- work_items
- semantics
- tests
- control_plane_ts
- control_plane
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
365 | 372 | | |
366 | 373 | | |
367 | 374 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
380 | 409 | | |
381 | 410 | | |
382 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 113 | | |
138 | 114 | | |
139 | 115 | | |
| |||
229 | 205 | | |
230 | 206 | | |
231 | 207 | | |
| 208 | + | |
| 209 | + | |
232 | 210 | | |
233 | 211 | | |
234 | 212 | | |
| |||
250 | 228 | | |
251 | 229 | | |
252 | 230 | | |
| 231 | + | |
| 232 | + | |
253 | 233 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
| 789 | + | |
789 | 790 | | |
790 | 791 | | |
791 | 792 | | |
| |||
865 | 866 | | |
866 | 867 | | |
867 | 868 | | |
| 869 | + | |
868 | 870 | | |
869 | 871 | | |
870 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
| 189 | + | |
| 190 | + | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| |||
201 | 204 | | |
202 | 205 | | |
203 | 206 | | |
| 207 | + | |
| 208 | + | |
204 | 209 | | |
205 | 210 | | |
206 | 211 | | |
| |||
310 | 315 | | |
311 | 316 | | |
312 | 317 | | |
| 318 | + | |
| 319 | + | |
313 | 320 | | |
314 | 321 | | |
315 | 322 | | |
| |||
380 | 387 | | |
381 | 388 | | |
382 | 389 | | |
| 390 | + | |
| 391 | + | |
383 | 392 | | |
384 | 393 | | |
385 | 394 | | |
| |||
410 | 419 | | |
411 | 420 | | |
412 | 421 | | |
| 422 | + | |
| 423 | + | |
413 | 424 | | |
414 | 425 | | |
415 | 426 | | |
| |||
458 | 469 | | |
459 | 470 | | |
460 | 471 | | |
| 472 | + | |
| 473 | + | |
461 | 474 | | |
462 | 475 | | |
463 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
495 | 496 | | |
496 | 497 | | |
497 | 498 | | |
| |||
510 | 511 | | |
511 | 512 | | |
512 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
513 | 519 | | |
514 | 520 | | |
515 | 521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
252 | 262 | | |
253 | 263 | | |
254 | 264 | | |
| |||
316 | 326 | | |
317 | 327 | | |
318 | 328 | | |
| 329 | + | |
319 | 330 | | |
320 | 331 | | |
321 | 332 | | |
322 | 333 | | |
323 | 334 | | |
324 | 335 | | |
325 | 336 | | |
326 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
327 | 341 | | |
328 | | - | |
| 342 | + | |
329 | 343 | | |
330 | 344 | | |
331 | 345 | | |
| |||
406 | 420 | | |
407 | 421 | | |
408 | 422 | | |
| 423 | + | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
| |||
426 | 441 | | |
427 | 442 | | |
428 | 443 | | |
429 | | - | |
| 444 | + | |
430 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
431 | 451 | | |
432 | 452 | | |
433 | 453 | | |
434 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
435 | 457 | | |
436 | 458 | | |
437 | 459 | | |
| |||
1644 | 1666 | | |
1645 | 1667 | | |
1646 | 1668 | | |
1647 | | - | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1648 | 1675 | | |
1649 | 1676 | | |
1650 | 1677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
0 commit comments