Skip to content

fix(members): enqueue the rules read/write audits inline, not via to_thread - #8844

Merged
bolichen97 merged 1 commit into
mainfrom
fix/members-audit-inline-enqueue
Sep 6, 2026
Merged

fix(members): enqueue the rules read/write audits inline, not via to_thread#8844
bolichen97 merged 1 commit into
mainfrom
fix/members-audit-inline-enqueue

Conversation

@CrysisDeu

Copy link
Copy Markdown
Collaborator

Problem / Motivation

Main is red on test/test_members_dm_thread.py::TestDenialAuditOffload::test_no_members_sel_audit_is_offloaded (seen on #8816's merge ref, Backend Tests (Windows) 3). Two PRs crossed: #8741 (#8608) warmed the SEL singleton at startup and inverted the members AST guard so that no log_api_access may sit inside an asyncio.to_thread lambda; #7235 then landed the member rules GET/PUT handlers with exactly that wrapper around their success audits (handlers/members.py lines 581 and 716).

What changed

The two rules audits become direct enqueues, guarded the way the deny-path audits in the same file already are (try/except Exception → debug log; an audit must never change the outcome). Comments updated to name the startup warm (#8608) instead of the first-touch initialization that no longer happens here. No behaviour change for the request: the audit still records the same operation/outcome/resources.

Tests

Per the owner's standing instruction no suite was run locally; CI verifies. black --check and flake8 clean on the file. Unblocker for #8816 and any PR whose merge ref includes both #8741 and #7235.

Related Issues

Cross-merge of #8741 and #7235. Unblocks #8816.

Checklist

  • One commit, Conventional Commits title
  • Existing tests pass (CI)

…thread

#8741 (#8608) warmed the SEL singleton at startup and inverted the members
AST guard: no log_api_access may hide inside an asyncio.to_thread lambda,
because the first-touch initialization that hop used to offload never runs.
#7235 then landed two to_thread-wrapped audits for the member rules GET and
PUT, so main fails test_no_members_sel_audit_is_offloaded on every PR's merge
ref (seen on #8816, Backend Tests (Windows) 3). Direct enqueue, guarded the
way the deny-path audits in this file already are.
@CrysisDeu
CrysisDeu requested a review from a team as a code owner September 5, 2026 23:53
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Minimal cross-merge repair that restores the file's own established audit pattern, pinned by the existing AST guard; nothing to redesign.

The two rules-audit sites now match the deny-path sites in the same file byte-for-pattern (direct enqueue, try/except → debug log), log_api_access without critical=True is a non-blocking enqueue post-warm (sel.py log() docstring), and the inverted guard in test_no_members_dm_thread.py already owns the invariant this change satisfies. Root cause (two PRs crossing) is correctly fixed at the violating call sites rather than by weakening the guard.

[DESIGN-REVIEWED] 7268629

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 7268629692d8645d6db1555197bdffa2db5fca6c — 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.

All claims verified. The remaining to_thread-wrapped audits in cron.py (3 sites) and md_notebook (line 1414) are critical=True synchronous writes, which the AST guard's docstring explicitly exempts — with one exception at md_notebook/server.py:1428, a non-critical audit still paying the pointless hop. The fix itself is pinned by the AST guard test test_no_members_sel_audit_is_offloaded, and the try/except guard matches the four existing audit sites in the same file.

First-Principles-Verdict: PASS

Unwedges a red main by deleting two thread hops the startup warm made pointless; every line is either the fix or the file's established audit guard.

What this change ships

Intent: get main green again after #8741's AST guard and #7235's rules handlers cross-merged — a FIX.

  1. Rules-read success audit runs inline, no worker-thread hop — justified, pinned by the AST guard test
  2. Rules-write success audit runs inline — justified, same guard
  3. A failing audit on either route now logs at debug instead of failing the request — declared, matches 4 sibling guarded audits in members.py
  4. Comments now cite the startup warm instead of the removed first-touch init — declared

The change is pure subtraction plus the guard the file already uses everywhere else (grepped log_api_access in members.py: 4 pre-existing sites, all try/except Exception → debug). No new surface, config, or export. Root cause (two green PRs whose merge violates an invariant only their union exhibits) is CI-topology, out of any diff's scope; this fix sits at mechanism level, the right level available.

Watch

[FIRST-PRINCIPLES-REVIEWED] 7268629

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 7268629

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

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

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging 7268629692d8645d6db1555197bdffa2db5fca6c. Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/dashboard/handlers/members.py:583 -- Failed SEL warm retries blocking initialization on the event loop
_sel().log_api_access( (also line 719)
Transient startup warm failure -> rules GET/PUT -> _init_locked filesystem work on the loop -> gateway requests and heartbeat stall.
Anchor: no-blocking-call-on-event-loop
Fix: Resolve _sel() with await asyncio.to_thread(_sel) before logging at both sites.
[BLOCK-MERGE] 7268629
[GPT-REVIEWED] 7268629

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

The finding is anchored to no-blocking-call-on-event-loop (AUTOSDE.yaml:91-92), which carries blocking: true. I verified the mechanism: _sel() at members.py:583 and :719 runs directly on the event loop inside async handlers (no to_thread hop), and per sel.py:3349-3384 a failed startup warm leaves the first later touch to run _init_locked's blocking file I/O (key load/create, backward tail scan bounded by _SEGMENT_MAX_BYTES, stat) on the caller's thread — here the loop thread. That is exactly the "large synchronous file IO reachable from an async handler" the rule forbids.

Harm rung: MEDIUM-to-HIGH loop stall, but the anchor rule's blocking: true flag is authoritative and outranks the weighing. The remedy (wrap _sel() in await asyncio.to_thread at both sites) is cheap and local. UPHOLD under autosde-blocking-rule.

[ADJUDICATION] 7268629 total=1 uphold=1 downgrade=0
UPHOLD F1 src/kiro_crew/dashboard/handlers/members.py:583 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 7268629

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

@bolichen97
bolichen97 merged commit 049b8c7 into main Sep 6, 2026
59 of 62 checks passed
@bolichen97
bolichen97 deleted the fix/members-audit-inline-enqueue branch September 6, 2026 00:26
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 6, 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