feat(routing): Phase-2 reship-monitor + durable Phase-3 trigger (slice 4) #24
+390
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Phase 2, Slice 4 — reship-monitor + a DEPENDABLE Phase-3 trigger
A warn-only monitor over each routed run, plus the durable watch state that turns its
signal into a dependable, exception-based Phase-3 trigger (not a fleeting email line).
Monitor (the per-run signal)
The load-bearing signal is the shard reship ratio (shards shipped / shards present):
appending new big files ships new solos and leaves shards untouched (~0), so healthy
growth never trips it; re-shipping many whole shards does — the uniform-medium-churn
signature Phase 3 (leveling) exists for.
byte_ratiois context only.reship_stats(summary)— pure overroute_and_ship's return; shard/byte ratios +watch(True iff shards exist and shard_ratio >
RESHIP_WATCH_RATIO= 25%).Durable watch (the dependable trigger)
A single tripped run is a one-off (a manual re-processing pass cries wolf), and a routine
completion email gets tuned out. So the signal is persisted + de-noised in the target's
manifest:
update_reship_watch(prior_watch, stats, run_epoch, sustain=3)— pure fold into a streak:consecutive_trips(+1 on a tripped run, reset to 0 on a quiet one),sustained(>=
sustainconsecutive trips),sustained_since,last_ratio/last_run, and analertedidempotency latch owned by the deployment alerter (engine only preserves itacross trips and clears it on reset, so a re-crossing re-alerts once).
route_and_shipcomputes the watch over the final post-prune object set and always writesthe manifest once at the end — so an all-skipped run correctly resets the streak. The
watch block is added to the return dict + the completion print/email (a single trip reads
"not yet sustained", not an action item).
The actual exception alert — one Teams @mention to the operator on crossing into a
sustained watch — is deployment glue that reads
manifest.reship_watch; it is kept outof this generic engine (lands in florasense-tools + the Negishi RUNBOOK).
Tests
tests/test_reship_monitor.py(7 monitor + 9 watch-streak) + 3 persistence cases intests/test_routing_wiring.py(persist+reset, append-does-not-accumulate,repeated-churn-sustains). Suite 238 → 257. Based on
main, not stacked.After this: slice 5 (full restore capstone) is the last Phase-2 piece.
🤖 Generated with Claude Code