Commit 1109caf
committed
Redesign per Copilot review: sticky bypass after watchdog + tests in tree
Two issues from Copilot's review on PR #381 + the second CI failure:
(A) Cross-scan signal race [Copilot]: scan #1 watchdog'd, scan #2 then
arms a fresh `filesystem_changed` listener. A delayed emission
from scan #1 fires on whichever listener is currently connected
to the shared signal — Godot can't tag emissions with their
source scan — so scan #2's listener falsely settles before its
actual filesystem scan completed, re-enabling the plugin against
a potentially incomplete on-disk install. Generation-counter +
Callable.bind doesn't help because a single emission still fires
every connected listener (CONNECT_ONE_SHOT only auto-disconnects
after firing).
(B) Second CI failure: `Timer.start()` requires the Timer to be
inside a SceneTree. The previous fix removed `add_child(runner)`
from tests but didn't parent the runner anywhere, so when
`_arm_scan_watchdog` called `add_child(timer)` and `timer.start()`
inside the runner, the timer wasn't in any tree.
Fix:
- Add a sticky `_scan_timed_out` flag set by `_on_scan_watchdog_timeout`.
- `_start_filesystem_scan` checks the flag at the top and bypasses the
connect + `fs.scan()` path entirely, falling straight through to
`call_deferred(deferred_step)`. With no listener armed, a delayed
emission from the timed-out scan has nothing to satisfy. Godot's
normal background scan catches up after the plugin re-enables.
- Tests now parent the runner via `(Engine.get_main_loop() as
SceneTree).root.add_child(runner)` so `Timer.start()` works.
Cleanup via a `_free_runner` helper (remove_child + free).
- New regression test `test_subsequent_scan_after_watchdog_bypasses_
listener_arm` explicitly drives scan #1 → watchdog → scan #2 and
asserts scan #2 does NOT set `_waiting_for_scan = true` (i.e. no
listener armed for a delayed scan-#1 emission to satisfy).
- Existing watchdog test `test_watchdog_no_op_when_signal_already_settled`
also asserts `_scan_timed_out` stays false on the late-Timer-after-
successful-signal path — guards against the watchdog poisoning
subsequent scans when no actual deadlock happened.1 parent c58590f commit 1109caf
2 files changed
Lines changed: 112 additions & 18 deletions
File tree
- plugin/addons/godot_ai
- test_project/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| |||
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
134 | 156 | | |
135 | 157 | | |
136 | 158 | | |
| |||
156 | 178 | | |
157 | 179 | | |
158 | 180 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
162 | 190 | | |
163 | 191 | | |
164 | 192 | | |
165 | 193 | | |
166 | 194 | | |
167 | 195 | | |
| 196 | + | |
168 | 197 | | |
169 | 198 | | |
170 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
486 | 509 | | |
487 | 510 | | |
488 | 511 | | |
| |||
498 | 521 | | |
499 | 522 | | |
500 | 523 | | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
| 524 | + | |
506 | 525 | | |
507 | 526 | | |
508 | 527 | | |
| |||
511 | 530 | | |
512 | 531 | | |
513 | 532 | | |
514 | | - | |
| 533 | + | |
| 534 | + | |
515 | 535 | | |
516 | 536 | | |
517 | 537 | | |
518 | 538 | | |
519 | 539 | | |
520 | 540 | | |
521 | | - | |
522 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
523 | 544 | | |
524 | 545 | | |
525 | 546 | | |
526 | 547 | | |
527 | 548 | | |
528 | 549 | | |
529 | | - | |
530 | | - | |
| 550 | + | |
| 551 | + | |
531 | 552 | | |
532 | 553 | | |
533 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
534 | 559 | | |
535 | 560 | | |
536 | 561 | | |
537 | 562 | | |
538 | 563 | | |
539 | 564 | | |
540 | | - | |
| 565 | + | |
541 | 566 | | |
542 | 567 | | |
543 | 568 | | |
| |||
547 | 572 | | |
548 | 573 | | |
549 | 574 | | |
550 | | - | |
| 575 | + | |
551 | 576 | | |
552 | 577 | | |
553 | 578 | | |
554 | 579 | | |
555 | 580 | | |
556 | 581 | | |
557 | 582 | | |
558 | | - | |
| 583 | + | |
559 | 584 | | |
560 | 585 | | |
561 | 586 | | |
| |||
565 | 590 | | |
566 | 591 | | |
567 | 592 | | |
568 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
0 commit comments