Repository navigation
Commit 4876ef1
committed
fix(mcode-island): a detector state write clears a stale sub-step (round-20 #5)
Live symptom: the pill sat on "step 1/1" showing a curl command from a
tool call that finished several turns earlier, and nothing ever cleared
it.
Cause: round-19 #2 made Write-Status merge the previous step/total/detail
back in on every write, which is correct for the two metadata refreshes
(60s 5h-usage, todo progress) because those restate the current state
rather than announcing a new step. But the detector also writes on state
inference -- it read a new tool call out of the session log and is
asserting "the agent is doing THIS now". That message has no relationship
to whatever sub-step a hook pushed last, so it inherited a counter that
had no meaning there. Every subsequent write inherited it again, which is
why it never cleared.
Write-Status now takes -KeepSubStep:
- state inference (default) resets step/total/detail to -1/-1/""
- the 5h-usage and todo refreshes pass -KeepSubStep and preserve
The two paths are distinguished explicitly by the caller, not inferred
from the message text. Distinguishing is necessary because the
state-inference call also has to be able to win the settle race against
an agent push (round-19), so "who wrote last" is not a usable signal.
Tests
-----
New section 5 in test-substep-progress.mjs, negative-first: observed
failing on 3 assertions before the fix, all passing after.
- Write-Status exposes -KeepSubStep
- state-inference write clears a stale sub-step (-1|-1|)
- metadata-refresh write still preserves it
- the inference call site does NOT pass -KeepSubStep
- exactly 2 call sites DO (5h-usage, todo)
The call-site assertions are the ones that matter: a switch nobody passes
is the dead-code shape, and a test that only exercises the function body
would not notice.
Two harness repairs, both regressions from round-20 that this work
surfaced:
- Format-ToolSummary now calls Protect-SecretText, which lives in a
separate lib. The harness extracted the function body and ran it
standalone, so it died on an unresolvable command rather than on an
assertion. The harness now dot-sources the lib, as _lib.ps1 does.
This is a genuine break of an existing test that round-20 shipped;
smoke did not catch it because smoke is static and this suite is not.
- Section 3 anchored its extraction regex on `$prev` appearing before
`$detailField`. Wrapping the block in `if ($KeepSubStep)` inverted
that order and the regex silently stopped matching, which would have
been reported as "Write-Status preserves sub-step fields: could not
find the block" -- a confusing failure for a function that works.
It now anchors on the initialisers and the payload construction.
Validation: sub-step suite 32 pass / 0 fail, smoke 116 pass / 0 fail.
Detector re-verified under Windows PowerShell 5.1 (exit 0) after the
restart, since that is the interpreter this runs under in production.1 parent df3c14d commit 4876ef1
2 files changed
Lines changed: 139 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
583 | | - | |
| 583 | + | |
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
599 | 610 | | |
600 | 611 | | |
601 | 612 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
606 | 620 | | |
607 | 621 | | |
608 | 622 | | |
| |||
808 | 822 | | |
809 | 823 | | |
810 | 824 | | |
811 | | - | |
| 825 | + | |
| 826 | + | |
812 | 827 | | |
813 | 828 | | |
814 | 829 | | |
| |||
822 | 837 | | |
823 | 838 | | |
824 | 839 | | |
825 | | - | |
| 840 | + | |
| 841 | + | |
826 | 842 | | |
827 | 843 | | |
828 | 844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
142 | 149 | | |
143 | 150 | | |
144 | 151 | | |
| |||
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
| 161 | + | |
154 | 162 | | |
155 | 163 | | |
156 | 164 | | |
| |||
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| 190 | + | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
| |||
300 | 309 | | |
301 | 310 | | |
302 | 311 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
307 | 323 | | |
308 | 324 | | |
309 | 325 | | |
310 | | - | |
| 326 | + | |
311 | 327 | | |
312 | 328 | | |
313 | 329 | | |
314 | 330 | | |
315 | 331 | | |
316 | 332 | | |
| 333 | + | |
317 | 334 | | |
318 | 335 | | |
319 | 336 | | |
320 | 337 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 338 | + | |
326 | 339 | | |
327 | 340 | | |
328 | 341 | | |
| |||
376 | 389 | | |
377 | 390 | | |
378 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 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 | + | |
379 | 481 | | |
380 | 482 | | |
381 | 483 | | |
| |||
0 commit comments