emrg: emit anchor-bias-heartbeat with explicit anchored state every round (issue #1078) - #1079
Merged
Merged
Conversation
…ound (issue #1078) The heartbeat used to live only inside _detect_silent_anchor_drift, so a round that skipped the detector (no usage, no prompt_tokens, no anchor, invalid estimate) produced zero heartbeat lines — byte-identical to the detector having stopped (Dev.to 3dn6k — vinhnguyenthanhdn via pm25coder). - Extract the round-loop usage-refresh block into _refresh_usage_anchor so every round emits exactly one anchor-bias-heartbeat line: anchored=false reason=no_usage / no_prompt_tokens on the outer skip paths, and pass-through to the detector when prompt_tokens arrives - Detector early returns now emit labeled anchored=false heartbeats (no_anchor / invalid_estimate / invalid_bias) instead of bare returns - Success heartbeat gains the anchored=true field (grep marker and debug level unchanged) - Tests: assert each skip state (positive + negative per repo rules) and the anchored=true success path; Agent.md Python count 1177 -> 1178
pm25coder
commented
Aug 30, 2026
Collaborator
argszero
commented
Aug 30, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle
Reviewed the full diff:
_refresh_usage_anchorhelper cleanly extracts the round-loop usage path; every round now emits exactly oneanchor-bias-heartbeatwith an explicit state.- Skip paths are first-class labeled observations:
anchored=false reason=no_usage/reason=no_prompt_tokens(round loop),reason=no_anchor/invalid_estimate/invalid_bias(detector early returns). - Success path now labeled
anchored=true, preserving the #1072 bias_shift/threshold heartbeat and the #1027 silent-drift detection (old anchor still in place before overwrite). - Tests: new
test_anchor_heartbeat_every_round_labeledcovers all 5 states; updated tests assertanchored=true;caplog.set_levelpersistence fix avoids silent DEBUG→WARNING restoration. - CI:
testandtest-windowsboth pass (run 33310636543).
The observability gap from issue #1078 (skipped rounds indistinguishable from a stopped detector) is closed. LGTM 1/3.
argszero
commented
Aug 30, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle (2/3)
Independent re-review in this cycle:
- Head
2051a82unchanged since LGTM 1/3; diff still matches the issue #1078 design exactly. - CI:
testandtest-windowsboth pass (run 33310636543) — actionlint gate and doc-count guard (Agent.md 1178) covered. _refresh_usage_anchoremits exactly one labeled heartbeat per round on all paths (anchored=false reason=no_usage/no_prompt_tokens/no_anchor/invalid_estimate/invalid_bias; anchored=true on success), closing the observability gap: skipped rounds are now labeled observations, not absence.- Tests cover all 5 states with persistent
caplog.set_level; MERGEABLE.
LGTM 2/3.
argszero
commented
Aug 30, 2026
argszero
left a comment
OwnerAuthor
There was a problem hiding this comment.
✅ LGTM — cycle (3/3)
Third consecutive approval from a distinct cycle:
- Head
2051a82still byte-identical to the LGTM 1/3 review (no drift since submission). - CI:
test+test-windowsboth pass on run 33310636543; MERGEABLE/CLEAN. - Implementation fully satisfies issue #1078's acceptance criteria: exactly one labeled
anchor-bias-heartbeatper round across all paths (anchored=false reason=no_usage/no_prompt_tokens/no_anchor/invalid_estimate/invalid_bias; anchored=true on success), with tests covering all 5 states.
3 consecutive ✅ (12:15:18Z, 12:22:24Z, this review) — merging.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes#1078
Problem
The
anchor-bias-heartbeat(added in #1073, consumed by #1076's calibration) was emitted per anchored round FROM INSIDE_detect_silent_anchor_drift— so anything that stops anchored rounds entirely yields zero heartbeat lines, byte-identical to the detector having stopped. Reader comment 3dn6k by vinhnguyenthanhdn: "that is the same ambiguity you removed one level down with anchor_loss, reappearing one level up at the call site."Failure modes that went fully silent on master 981f037:
final_usagemissing/empty → detector never called → no heartbeatprompt_tokensmissing/zero → sameChange
"Log unconditionally, alert conditionally" moves one level up — every round now emits exactly one
anchor-bias-heartbeatline with an explicit state:_refresh_usage_anchor, which emitsanchored=false reason=no_usage/reason=no_prompt_tokenson the outer skip paths and passes through to the detector when prompt_tokens arrives.anchored=falseheartbeats:reason=no_anchor,reason=invalid_estimate,reason=invalid_bias(the combined early return is split so each reason is distinguishable).anchored=true(the inside-detector case, unchanged fields otherwise).anchor-bias-heartbeatand debug level unchanged — existinggrep "anchor-bias-heartbeat"workflows keep working; only thereasonfield is new.Verification