Skip to content

fix(issue-radar): render the ledger read-back traceback to text, not exc_info - #12943

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/crew-store-landed-since-exc-info
Sep 23, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/crew-store-landed-since-exc-info

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

main is red: test/test_crew_log_exc_info_sites.py::test_no_exc_info_site_anywhere_in_kiro_crew_holds_a_crew_log_handle fails on every shard that carries it (seen first on Backend Tests (Windows) 7 of PR #12776's merge ref), and every open PR inherits the red through refs/pull/N/merge.

The offenders are two logger.debug(..., exc_info=True) calls in src/kiro_crew/apps/builtins/issue_radar/backend/crew_store.py (_landed_since and _all_landed), both landed by #12303. Each sits in a frame that holds a CrewLog handle obtained from projection.open_session_log(...).

Why it matters

The guard exists because an exc_info triple on a log record keeps the traceback, the traceback keeps the frame, and the frame keeps the CrewLog handle -- whose write lease is only released by a finalizer when the handle is dropped. A record-keeping handler (pytest's caplog, a MemoryHandler) then keeps the lease alive for as long as it keeps the record. That is the order-dependent lease flake the guard turned deterministic. Left as is, the ledger read-back path can pin a session log's lease, and the whole repository's CI stays red.

What changed (motivation -> approach -> change)

Symptom: guard test red on main. Root cause: two new exc_info=True sites inside handle-holding frames. Change: both sites now call kiro_crew.crew_log.store.log_exception_text, the package's helper for exactly this frame shape -- it renders traceback.format_exc() to text behind isEnabledFor(level), so the record carries a string and no frame. Same message, same DEBUG level, same attempt argument; only the traceback's carrier changes. The import is top-level, next to the existing kiro_crew.crew_log.entry_types import (crew_log.store imports nothing from apps, so there is no cycle).

Backwards compatibility

Compatible: log message text and level are unchanged; only the traceback moves from the record's exc_info to the rendered message body.

Tests

No new tests: the existing guard test_no_exc_info_site_anywhere_in_kiro_crew_holds_a_crew_log_handle is the regression test and flips red -> green with this change (it names both sites at _landed_since and _all_landed before, none after).

Run on native Windows (Python 3.12.10) against this branch's src:
test/test_crew_log_exc_info_sites.py test/test_issue_radar_crew_store.py test/test_issue_radar_crew_runtime.py src/kiro_crew/apps/builtins/issue_radar/tests -> 1351 passed, 2 skipped, 0 failed.

Manual verification

N/A -- unit coverage sufficient: the guard test is a whole-tree AST walk, and the behavioural tests of the ledger read-back paths (_landed_since / _all_landed) are in the crew store suite above.

Related Issues

Follow-up to #12303. Unblocks the inherited red on #12776 and every other open PR.

Pattern harvest

Rule candidate: review-prompt
Pattern: exc_info=True inside a function whose frame binds a CrewLog handle (including one returned by open_session_log) -- already enforced by the AST guard; the review prompt should point a PR that adds a log-reading helper at store.log_exception_text before CI has to.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality (guard test is the regression test)
  • Self-review completed; code follows project style guidelines (crew_store.py stays in .github/black-baseline.txt; black's only requested hunk is the pre-existing NAME_POOL block, not these lines)
  • Documentation updated (if applicable) -- N/A, no documented behaviour changes
  • No secrets, credentials, or internal references in the diff

…exc_info

Both read-back helpers in crew_store.py (_landed_since, _all_landed) hold a CrewLog handle from open_session_log and logged with exc_info=True, which the exc_info-sites guard refuses because the record's traceback would pin the handle's lease under a record-keeping handler. Route both through crew_log.store.log_exception_text.
@bolichen97
bolichen97 requested review from a team and Zedmor September 22, 2026 23:28
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of d6165b75fe8cdc67a84b748326e6778bcfeb33d2 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify CI's test_no_exc_info_site_anywhere_in_kiro_crew_holds_a_crew_log_handle run goes green on this merge ref; I could not execute it locally.

[DESIGN-REVIEWED] d6165b7

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of d6165b75fe8cdc67a84b748326e6778bcfeb33d2 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d6165b7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt d6165b75fe8cdc67a84b748326e6778bcfeb33d2: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed d6165b75fe8cdc67a84b748326e6778bcfeb33d2 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] d6165b7

Verdict parsed from the review's SHA-scoped output markers for commit d6165b75fe8cdc67a84b748326e6778bcfeb33d2.

False positive or not applicable? A repository writer can comment:
/ai-review override fable d6165b75fe8cdc67a84b748326e6778bcfeb33d2: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of d6165b75fe8cdc67a84b748326e6778bcfeb33d2 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Guard's green is the only proof this contract can't read — confirm test_crew_log_exc_info_sites.py passes on this branch's CI, not just the author's Windows run.

What this change ships

Inventory (3 items) — 3 justified

Intent: turn the guard test on main green again by removing two exc_info=True calls from frames that hold a CrewLog handle — a FIX.

  1. _landed_since's read-back failure now logs its traceback as rendered text, not exc_info — justified
  2. _all_landed's read-back failure does the same — justified
  3. crew_store.py now imports log_exception_text from crew_log.store at top level — justified

Evidence: the pin test_no_exc_info_site_anywhere_in_kiro_crew_holds_a_crew_log_handle exists on base and its assertion message says "use store.log_exception_text instead"; both fixed frames bind handle = projection.open_session_log(...) (crew_store.py:851, 2461), so the guard fails on base by direct reading of its _mentions_handle walk. Sibling count: 8 other exc_info=True sites remain in crew_store.py (grep exc_info), all in frames naming no handle — zero unfixed siblings under the invariant. The helper is the existing mechanism (20 prior call sites, grep log_exception_text), not a second spelling.

[FIRST-PRINCIPLES-REVIEWED] d6165b7

@chenmingwei23
chenmingwei23 merged commit 80532c1 into main Sep 23, 2026
92 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/crew-store-landed-since-exc-info branch September 23, 2026 00:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 23, 2026
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…exc_info (kirodotdev#12943)

Both read-back helpers in crew_store.py (_landed_since, _all_landed) hold a CrewLog handle from open_session_log and logged with exc_info=True, which the exc_info-sites guard refuses because the record's traceback would pin the handle's lease under a record-keeping handler. Route both through crew_log.store.log_exception_text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants