Skip to content

fix(diag): skip a diag, stub-fallback or spool line nested past the limit - #29059

Merged
RohanK6 merged 1 commit into
mainfrom
crew/conductor/nested-line-infra-r80b
Nov 3, 2026
Merged

RohanK6 merged 1 commit into
mainfrom
crew/conductor/nested-line-infra-r80b

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: One diag snapshot, stub-fallback or inbound-spool line nested past the recursion limit costs that line, not the whole read.

The diag snapshot query (Recorder._iter_rows), the stub-fallback counter (fallback_counts) and the inbound spool reader (_read_entries) parse each JSONL line inside except ValueError (the counter, except json.JSONDecodeError). json.loads raises RecursionError on a line nested past the interpreter limit, which is neither, so one such line raised out of the read. The counter documents that it never raises.

Why it matters

The diag query answers the health questions an operator asks after an incident, the counter feeds the gateway fallback-rate stats, and the spool reader runs on the boot path to replay inbound messages. Each already skips a torn line so one bad record cannot stop it; a deeply nested line stopped it instead.

Not a goal

  • Not changing how any parseable line is read.
  • Not changing the bounded-record cap, the spool file-safety checks or the outer error handling.

What changed (motivation → approach → change)

Symptom: one [[[[...]]]] line past the decoder depth makes the reader raise. Cause: RecursionError is not a ValueError. Change: each of the three sites catches (ValueError, RecursionError) and skips the line, the shape the repo readers that already handle it use (for example apps/builtins/issue_radar/backend/pipeline_fold.py), and the history readers in #29020.

reader file
Recorder._iter_rows diag/recorder.py
fallback_counts mcp_gateway/stub_fallback.py
_read_entries messaging/inbound_spool.py

Backwards compatibility

Compatible: every line that parsed before parses the same; only a line that raised is now skipped.
Removes nothing: no record, route or setting is removed.

Tests

test/test_infra_readers_nested_line.py writes a nested line beside one ordinary record for each reader and asserts the reader does not raise and still returns the ordinary record. All three fail on main.

Proof: PROVEN test/test_infra_readers_nested_line.py::test_the_diag_query_skips_a_nested_line, test/test_infra_readers_nested_line.py::test_the_stub_fallback_counter_skips_a_nested_line, test/test_infra_readers_nested_line.py::test_the_inbound_spool_skips_a_nested_line (head 41e6e53)

Manual verification

N/A. Each test drives the real reader against a temp file.

Related Issues

Part of #29018 (these three readers; the dashboard readers are in #29058).

Sibling sweep

Swept: git grep -nA2 "json.loads(" -- src/kiro_crew/diag/recorder.py src/kiro_crew/mcp_gateway/stub_fallback.py src/kiro_crew/messaging/inbound_spool.py
Sibling: src/kiro_crew/diag/recorder.py -- changed here
Sibling: src/kiro_crew/mcp_gateway/stub_fallback.py -- changed here
Sibling: src/kiro_crew/messaging/inbound_spool.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/usage_spend.py -- tracked in #29058

Pattern harvest

Rule candidate: semgrep
Pattern: json.loads(...) inside except ValueError (or JSONDecodeError) with no RecursionError, in a line reader that promises to skip bad lines

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the Apache-2.0 license of this project.

…imit

The diag snapshot query, the stub-fallback counter and the inbound spool
reader parse each JSONL line inside except ValueError (the counter only
JSONDecodeError). json.loads raises RecursionError on a line nested past
the interpreter limit, which is neither, so one such line raised out of
the whole read; the counter promises it never raises. Each now catches
ValueError and RecursionError and skips the line.
@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 3, 2026 09:54
@RohanK6
RohanK6 requested a review from CrysisDeu November 3, 2026 09:54
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 41e6e53f220da05ebef2107f88b1e901e177acde touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 41e6e53f220da05ebef2107f88b1e901e177acde — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

This is a narrow, proportionate fix at the right place: each reader now catches RecursionError where it already skipped bad lines. It removes nothing and changes no visible surface.

[DESIGN-REVIEWED] 41e6e53

Description read

[DESCRIPTION-READ] e5364d53ed02bf8dc50970460a57768da3d447f52844a5e18e5a37fd1e5350d6

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 41e6e53f220da05ebef2107f88b1e901e177acde — 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 does not.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (4 items) — 4 justified

Intent: a single diag, stub-fallback or inbound-spool line nested too deeply should cost only that line, not the whole read. This is a FIX.

  1. A diag snapshot query with a deeply nested line now skips that line and still returns the other rows. — justified
  2. The stub-fallback counter skips a deeply nested line (or any line that fails to parse) and keeps counting. — justified
  3. The inbound spool replay at boot skips a deeply nested line and still replays the other messages. — justified
  4. A new test file checks each reader against a nested line next to an ordinary record. — justified

[FIRST-PRINCIPLES-REVIEWED] 41e6e53

Description read

[DESCRIPTION-READ] a00198c03e544f8987a4694b31fb55e8bb9311ed4d8b9923fd9597850fd71472

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 41e6e53

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 41e6e53f220da05ebef2107f88b1e901e177acde false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 41e6e53f220da05ebef2107f88b1e901e177acde and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 41e6e53

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 41e6e53f220da05ebef2107f88b1e901e177acde false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 3, 2026
@RohanK6
RohanK6 enabled auto-merge (squash) November 3, 2026 10:40

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: diag, stub-fallback and spool readers skip a JSON line nested past the recursion limit.

@RohanK6
RohanK6 merged commit fe88a52 into main Nov 3, 2026
95 checks passed
@RohanK6
RohanK6 deleted the crew/conductor/nested-line-infra-r80b branch November 3, 2026 11:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 3, 2026
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