Commit c9a291d
feat(local-coord-mcp): watchdog TTL enforcement (DD-20)
From P1 in docs/handover/COORD-MCP-TODO.md — closes the DD-20 watchdog
item. Bump cartridge version to 0.9.0.
Mechanism
---------
Each claim now carries `claimed_at_ms`, stamped at grant and refreshed
on heartbeat. `sweepExpiredClaims(now_ms)` walks active claims and
auto-releases any where `(now − claimed_at_ms) > TTL(holder.role)`.
TTLs (DD-20):
apprentice → 30 s
journeyman → 5 min
master → no watchdog (approver, not executor)
Sweep runs:
- implicitly at the top of every coord_claim_task (contention is the
natural moment abandoned work matters — the new caller benefits
immediately from the release), and
- explicitly via `coord_sweep_watchdog` for ops that want a polling
tick independent of claim traffic.
New FFI + tools
---------------
FFI:
coord_progress(token, task) — 0 OK, -1 bad token, -2 no claim,
-3 not the holder
coord_sweep_watchdog(token) — released-count, -1 on bad token
Adapter:
coord_progress {token, task}
coord_sweep_watchdog {token}
→ {released, ttl_apprentice_ms, ttl_journeyman_ms}
Durability
----------
EventType.claim_progress = 17 — payload: claim_idx:u8 timestamp_ms:u64
Replay sets claimed_at_ms from claim_progress events; claim_add alone
restores a fresh TTL (old logs predate the field).
Audit
-----
Auto-releases emit an audit record (kind=3 AUTO_RELEASE) with the
claim index, holder, role, age_ms, and task name. DD-21's warn_drift
broadcast via Opus review is a separate P1 item.
Tests
-----
watchdog: apprentice claim swept past 30s TTL
watchdog: progress heartbeat keeps claim alive
watchdog: journeyman gets 5min TTL, master never swept
watchdog: progress rejected from non-holder
watchdog: implicit sweep frees stale slot on contention
Tests rewind `claims[i].claimed_at_ms` directly (same-module private
access) to simulate elapsed time deterministically — no sleeps, no
flakiness.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_01DobLJY3jgoso4M3z7xcZi81 parent 100876c commit c9a291d
6 files changed
Lines changed: 361 additions & 4 deletions
File tree
- cartridges/local-coord-mcp
- adapter
- ffi
- docs/handover
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
821 | 854 | | |
822 | 855 | | |
823 | 856 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| 592 | + | |
| 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 | + | |
592 | 629 | | |
593 | 630 | | |
594 | | - | |
| 631 | + | |
595 | 632 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
298 | 321 | | |
299 | 322 | | |
300 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
313 | 315 | | |
314 | 316 | | |
315 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
316 | 326 | | |
317 | 327 | | |
318 | 328 | | |
| |||
478 | 488 | | |
479 | 489 | | |
480 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
481 | 500 | | |
482 | 501 | | |
483 | 502 | | |
| |||
0 commit comments