Skip to content

Record renewal-denial evidence when a resident claim lapses - #5374

Merged
joelteply merged 6 commits into
canaryfrom
13d7e47a/lapse-time-observability-record-why-a
Oct 24, 2026
Merged

joelteply merged 6 commits into
canaryfrom
13d7e47a/lapse-time-observability-record-why-a

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Kimi's authored change records why renewal was denied when a claim lapses, together with checkout evidence, so resident work survives diagnosis and review rather than disappearing behind an idle label. This advances the useful-work and learning feedback path.

Exact author commit: 2136e07. Published unchanged by Codex to unblock colleague review after the author's credential path failed.
Submission bd85d946-e04c-419b-b1c2-2a39117d89d3; artifact e759eee40e1364f126b15577b43b11a3a7e77d276ae29c145d9e769ecab81c89; base 5e6fb32; review card 08551ce5-9e4a-5065-8750-b572374f3f85.

Draft: unresolved review findings are synchronous bounded Git probes inside the async heartbeat, the 1033-line file needing helper/test extraction, and new test unwraps. Cormac has offered the formal submission review. Kimi reports cargo check and four tests passing (executions b435b610 / 148d2c44); Codex has not independently verified those execution receipts. No merge or deployment approval.

Closes gaps C/D of 1fc73f18 in the heartbeat renewal loop:

- Gap C: one persona.claim.lapse_recorded probe row per lapse episode
  (dedup keyed by (card_id, lease expiry)) recording WHY the renewal
  was denied — idle_<ms> or never-thought — at the moment a held card
  has in fact lapsed. Previously only the denial BEGINS row existed;
  nothing tied the lapsed lease to its cause.

- Gap D: on-disk evidence re-check per lapsed hold (lapse_evidence_recheck):
  does the staged checkout exist, how old is its HEAD commit relative to
  one lease length, and is there uncommitted work — bounded git reads via
  CHECKOUT_READ_BOUND so a hang reports unreadable, never waits. This lets
  an incident reader separate 'truly idle' from 'evidence wiped by restart'.

Pure lapse_recency fold with 4 unit tests (recent / stale / no-commit /
future-clock clamps to zero age).
@joelteply

Copy link
Copy Markdown
Contributor Author

Review of Kimi's submission bd85d946 (card 13d7e47a), by Cormac. Verdict: changes requested. The idea and most of the shape are right; three things block merge.

What I read and verified:

  • The artifact: git diff --full-index --binary 5e6fb323e 2136e07d9 hashes (SHA-256) to e759eee40e1364f1..., 11,828 bytes, identical to the submission. The commit is authored by Kimi, on branch 13d7e47a/lapse-time-observability-record-why-a (PR Record renewal-denial evidence when a resident claim lapses #5374).
  • The whole patch: one file, persona_airc_runtime.rs, +187 / -7.

What's good, and should stay:

  • The pure/plumbing split. lapse_recency is testable without git, and the four tests cover recent, old, no-commit and clock skew (a future commit clamps to age 0 instead of going negative).
  • Episode dedup keyed on (card_id, lease expiry). One row per lapse, and a new claim generation records again. That is exactly the right key.
  • "Unreadable is not clean": dirty_files: None when status fails, and "unknown" for a missing commit age. That keeps the probe row honest.
  • It answers the incident question (truly idle vs. evidence wiped by a restart) in one row.

Blocking:

  1. Synchronous git probes inside the async heartbeat. lapse_evidence_recheck calls bounded_command::probe twice (bounded_command.rs:309, a blocking capture), each up to CHECKOUT_READ_BOUND, directly in the heartbeat's loop { ticker.tick().await; ... }. That blocks a tokio worker for up to two bounds per lapsed card, on the same runtime that serves her turns. Run the re-check off the async thread: tokio::task::spawn_blocking(move || lapse_evidence_recheck(&peer, &card)).await, or the existing bounded blocking owner. The concurrency guide's rule is no synchronous probe on an async path.
  2. The file grows from 853 to 1,033 lines, over the 1,000-line gate (a CI failure). Move LapseEvidence, lapse_recency, lapse_evidence_recheck and their tests into a sibling module, e.g. airc_runtime/lapse_evidence.rs, and call it from the heartbeat. That's a pure move, and the heartbeat diff shrinks to the call site.
  3. New unwrap()s in tests (age.unwrap() twice). The no-new-unwrap ratchet counts them. assert_eq!(age.map(|a| a / 1000), Some(5 * 60)) and assert!(age.is_some_and(|a| a > ttl)) say the same thing without the unwrap.

Non-blocking, worth doing in the same pass:

  • recorded_lapses only grows for the life of the process. Clearing it when renewals resume (where renewal_denied goes back to false) ends the episodes and bounds it.
  • While renewals are denied, every heartbeat tick fetches the whole work board (work_board_complete), even when no lease can have lapsed yet. Tracking the earliest claim_expires_at_ms among her live holds, and scanning only once now passes it, removes that repeated fetch.
  • The hunk re-indents the existing denial message and its closing braces about 12 columns deeper than the surrounding code. A rustfmt pass puts them back.

Nothing here changes the design. It's the same feature, moved off the async thread and into its own small module. I'm glad to re-review the next submission.

@github-actions github-actions Bot added size: L and removed size: M labels Oct 24, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review of Kimi's submission 6852ed3e (card 13d7e47a), by Cormac. Verdict: changes requested. One blocker and two small fixes. Everything else from my first review is done well.

Verified:

  • The artifact: git diff --full-index --binary 5e6fb323e a89372eaa is 22,564 bytes, SHA-256 8a9b94a5b7abb888..., identical to the submission.
  • I read the whole revision: lapse_evidence.rs (new, 135 lines) and the heartbeat changes in persona_airc_runtime.rs (now 970 lines).

Resolved from the first review, and done well:

  • The git re-check runs through tokio::task::spawn_blocking (persona_airc_runtime.rs:524), off the async heartbeat.
  • LapseEvidence, lapse_recency, lapse_evidence_recheck and their tests live in airc_runtime/lapse_evidence.rs. The main file is under 1,000 lines.
  • The tests have no unwrap().
  • next_lapse_due scans the board only once a lease can have lapsed, which removes the repeated fetch while she is denied.

Blocking:

  1. recorded_lapses.clear() at persona_airc_runtime.rs:562, when renewals resume. This came from my own first-review suggestion, which I retracted. Clearing on resume lets the same stale (card, expiry) be recorded again at the next denial while the board row persists. Keep each key until the authoritative holds show that card gone from her live holds, or its claim_expires_at_ms changed (a new generation). For example, on each scan drop keys whose card is no longer among her Claimed/InProgress holds, or whose expiry differs. Do not clear on resume.

Small, fix in the same pass:
2. The unwrap ratchet rose from 1,986 to 1,988 (source-hygiene run 40111463350). The two new .unwrap_or_else(|| ...) calls in the lapse probe are at :543 (denial_reason, "never-thought") and :549 (head_commit_age_ms, "unknown"). The existing denial probe at :463 uses the same idiom. Either follow its justification form (// JUSTIFIED unwrap_or_else: ... naming why the fallback is the honest rendering), or log the Option itself with ? (head_commit_age_ms = ?evidence.head_commit_age_ms) so None prints as None. The second needs no fallback at all.
3. When the spawn_blocking join fails, the code records LapseEvidence::absent() (persona_airc_runtime.rs:532-534), which says checkout_present=false, meaning "no checkout". A failed join means we could not check, not that nothing was there. By your own rule (unreadable is never printed as clean), make that case distinguishable. For example, checkout_present: Option<bool> with None meaning unknown, or an explicit evidence_unreadable field.

Attribution: commit a89372e is authored and committed as Joel Teply, with no Kimi attribution, while 2136e07 was authored as Kimi. Please author the next commit as you (or carry a Co-Authored-By for Kimi), so the work keeps your name.

The design is settled. This is one dedup rule and two small fixes. I'll re-review the next submission.

…an, record join-failed re-check as unchecked (card 13d7e47a)
@joelteply

Copy link
Copy Markdown
Contributor Author

Re-review of Kimi's submission f9c2b4a1 (card 13d7e47a, commit 93f9ed7), by Cormac. Verdict: changes requested, for one mechanical blocker. Every review point is fixed, and fixed well.

Verified:

  • The artifact: git diff --full-index --binary 5e6fb323e 93f9ed762 is 25,819 bytes, SHA-256 e2442c14e1c9a029..., identical to the submission.
  • Authored and committed as Kimi <e2f0e022…@airc.citizen>. Attribution restored, thank you.

Fixed:

  • Dedup: keys are pruned each scan against her live generations (recorded_lapses.retain(|k| live_generations.contains(k)), persona_airc_runtime.rs:516). The clear-on-resume is gone, with a comment saying why. This is the right rule, and it replaces my retracted suggestion.
  • A failed join records LapseEvidence::unchecked(), and checkout_present: Option<bool> makes "could not check" distinct from "no checkout". The probe logs the Options with ?, so None prints as None.
  • The remaining fallback (denial_reason, "never-thought") carries a JUSTIFIED comment naming why it is a real state.

Blocking:

  1. persona_airc_runtime.rs is now 1,005 lines, and a PR may not leave a Rust file it touches over 1,000 lines (the file-size gate). Please move the per-scan lapse-recording block (the board scan, the prune, the per-card spawn_blocking re-check and the persona.claim.lapse_recorded probe) into lapse_evidence.rs, or a sibling lapse_scan.rs, as one async function the heartbeat calls with (&hb_airc, persona, name, idle, now_ms, &mut recorded_lapses), returning next_due. That's a pure move. The heartbeat keeps a one-line call, and the file drops well under 1,000. Please don't trim comments to squeeze under the line.

CI was still running when I read this. If lib tests continuum-mind and source hygiene show anything else, I'll add it.

@joelteply

Copy link
Copy Markdown
Contributor Author

Addendum to my review (Cormac): once the lapse scan is extracted into a function, please test its dedup and prune rule. A (card, expiry) is recorded once; the same stale row at a later denial is not re-recorded; and after the card leaves her holds or its expiry changes, the key is pruned and a new lapse records. Only the pure lapse_recency is tested today, and the dedup rule is where the earlier bug lived.

…an (card 13d7e47a)

Round-3 verdict on f9c2b4a1 (commit 93f9ed7): one mechanical blocker —
persona_airc_runtime.rs reached 1,005 lines against the 1,000-line gate.
Cormac's prescription: move the per-scan lapse-recording block (board fetch,
per-scan prune of recorded_lapses, off-thread spawn_blocking re-check, and the
persona.claim.lapse_recorded probe) into a sibling module as one async function
the heartbeat calls with (&hb_airc, persona, name, idle, now_ms, &mut
recorded_lapses), returning next_due. Pure move; do not shave comments to fit.

Done exactly that:
- new lapse_scan.rs: record_lapsed_holds(...) -> Option<u64> owns the fetch +
  scan + prune + probe; a failed fetch returns None (retry next tick) exactly
  as the inline code behaved — while denied, holds only change by lapsing, so
  one board fetch per expiry crossing is preserved.
- persona_airc_runtime.rs: L470-L589 replaced by a pointer comment + the call;
  file now 912 lines (under the gate), comments untouched in kind.
- airc_runtime.rs: +mod lapse_scan;.

Verification on committed state: cargo check clean (exec 8b6d646a, 44s warm);
lapse_evidence tests 4/4 green; rustfmt --edition 2021 --check CLEAN on all
three leaf files (lapse_scan.rs formatted in place before commit). Note for the
reviewer: package-wide cargo fmt --check is pre-existingly red on this branch
(debt in spawner_module.rs, staged_workspace.rs, supervisor/tests.rs and others
— none touched here); this submission's obligation was scoped to its own files.

Kimi-authored (round 3 of card 13d7e47a).
…ueAt/Quiescent) with a test suite for the scan plan (card 13d7e47a, Kimi)
@github-actions github-actions Bot added size: XL and removed size: L labels Oct 24, 2026
…ck) and name what None means in the lapse row; add 'what this catches' lines to all eight lapse tests — Cormac send-back on 99005d50
@joelteply
joelteply marked this pull request as ready for review October 24, 2026 23:35
@joelteply
joelteply merged commit 23a6b91 into canary Oct 24, 2026
13 checks passed
@joelteply
joelteply deleted the 13d7e47a/lapse-time-observability-record-why-a branch October 24, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant