Skip to content

fix(dashboard): serialize the auto-update toggle against both config writers - #7167

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
leonlaiyc:fix/update-auto-both-config-locks
Sep 22, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
leonlaiyc:fix/update-auto-both-config-locks

Conversation

@leonlaiyc

@leonlaiyc leonlaiyc commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

POST /api/update/auto — the auto-update toggle in dashboard settings — persists the flag with a bare offload:

# handlers/updates.py:1204
await asyncio.to_thread(update_config_locked, config_path(), mutate=_set_auto_update)

That is correct about the event loop and wrong about exclusion. config.json has two writer generations that do not exclude each other:

  • update_config_locked takes the sidecar advisory flock — covering the CLI, the boot refresh, and a second gateway process.
  • The legacy dashboard handlers — core.py's theme/settings PUT, the agents endpoint, security.py, messaging.py, mcp.py, computer_use.py — do their own read-modify-write of the same file while holding only the loop-side _get_config_lock asyncio lock.

Holding just the flock excludes nothing that second family respects. core.py:424 is the plainest counterpart: async with _get_config_lock(): → KiroCrewConfig.load → mutate → save, with no flock anywhere. A theme save landing between this endpoint's read and its write commits from a snapshot taken before it, and silently reverts the auto-update flag the user just toggled — or this write reverts their theme.

config/loader.py states the rule directly: a caller running while the dashboard serves requests must also hold the in-process asyncio lock.

Why it matters

The lost update is silent and bidirectional, and it is reachable by ordinary use rather than by a race a user has to provoke — toggling auto-update and saving a setting are both routine dashboard actions. Nothing errors and nothing is logged; the endpoint reports success in both directions because the response is built from enabled rather than from a re-read of what landed on disk. The write window is not narrow either: it includes a filesystem lock wait plus, on Windows, an owner-only DACL application that can cost an unbounded SMB round-trip on a network-homed data home.

Auto-update is also the wrong setting to lose silently. A user who turned it off and finds it back on has an install that will update itself against their explicit decision.

What changed (motivation → approach → change)

Symptom → a config write that can be silently reverted, in either direction. Root cause → the dispatch holds one of the two locks that guard config.json. Change → route it through the entry point that holds both.

src/kiro_crew/dashboard/handlers/updates.py:

-    await asyncio.to_thread(update_config_locked, config_path(), mutate=_set_auto_update)
+    await run_config_write(update_config_locked, config_path(), mutate=_set_auto_update)

run_config_write (dashboard/chat_utils.py) acquires _get_config_lock on the event loop, then runs the blocking writer in a worker — so the flock wait still never stalls the loop, which is the property the bare to_thread was there for, unchanged. It also shields and drains that worker across cancellation, so a client disconnecting mid-toggle cannot unwind the lock while the write is still in flight.

Three properties checked before making the swap rather than assumed, because a canonical-helper swap on a persistence path is not mechanical:

  • The file is the same one. config_path() here is the main config.json the legacy family mutates, not a sidecar.
  • No outer config lock is already held. api_update_auto is a flat coroutine with no async with of its own, so run_config_write is its only lock acquisition and this introduces no nesting. (This is what distinguishes the site from apps/routes.py, where the same swap in fix(apps): serialize the builtin config sync against both config writers #6984 sat inside app_lifecycle_lock and needed an explicit lock-ordering argument. There is no second lock here to order against.)
  • The fail-closed contract survives. run_config_write awaits the worker through asyncio.shield and re-raises, so ConfigReadError still reaches the handler's 500 arm and an unreadable config is still never overwritten with a one-key file. Pinned by a test rather than asserted.

The import is module-level, unlike #6984's call-time one: updates.py already lives inside kiro_crew.dashboard, so there is no layering inversion to avoid and no import cycle (verified by importing both modules in either order).

The comment block above the call is rewritten. The old one explained why the flock replaced _get_config_lock and read as though that were the end of the story; it now says why both are needed.

Scope. This is the one update_config_locked site in updates.py. It is the sibling the First Principles review on #6984 counted as the remaining same-class one-lock config writer, and #6984 (merged) names updates.py in its own problem statement. No other handler is touched.

Tests

New in test/test_config_rmw_preserves_settings.py, class TestAutoUpdateToggleHoldsBothConfigLocks — the file that already owns this endpoint's config-write contract:

  • test_the_loop_side_lock_is_held_across_the_write — the defect, pinned behaviourally. Spies update_config_locked and, from inside the worker, records _get_config_lock().locked() and the thread identity. Probing from inside is what makes this a test of the property rather than of the spelling of the dispatch. It also asserts the write is still off the loop, so the fix cannot pass by moving the blocking call back onto it.
  • test_the_loop_side_lock_is_released_afterwards — holding it is only correct if the handler gives it back; also asserts the toggle actually landed on disk.
  • test_an_unreadable_config_still_fails_closed_and_releases — the 500 arm survives the new dispatch, the torn file is byte-identical afterwards, and the lock is not stranded on the exception path.
  • test_the_dispatch_cannot_regress_to_a_one_lock_offload — an AST ratchet (not a substring search, so a reformat cannot defeat it) that names the offending updates.py:<line> if update_config_locked is ever dispatched with a bare asyncio.to_thread again.
  • test_the_ratchet_can_actually_fail — a scan that matches nothing passes vacuously; this plants a violating source and asserts the scan finds exactly one.

Red-before, production change reverted with the tests in place: 2 failed, 3 passed.

AssertionError: config.json was rewritten without the loop-side lock, so a legacy
                dashboard writer could interleave and revert the toggle
AssertionError: update_config_locked dispatched with a bare asyncio.to_thread at
                updates.py:[1204] -- that holds only the sidecar flock; use
                run_config_write, which holds both config locks

Green after: test_config_rmw_preserves_settings.py + test_dashboard_updates_coverage.py — 99 passed, 3 skipped, 0 failed (Python 3.10.6, Windows).

Gates green: flake8, isort, scripts/check_black_formatting.py, mypy on the changed handler (no issues in it), and scripts/check_loop_bound_locks.py including its own --test self-check (21/21 probes).

Manual verification

N/A — unit coverage sufficient: the defect is which lock is held around a write, and the test observes that lock's state from inside the worker doing the write, which is the exact moment a manual toggle could not show. Reproducing it by hand would require winning a millisecond-scale interleaving between two dashboard requests.

Related Issues

Sibling of #6984 (merged), which made the same correction at the two apps/routes.py call sites and whose First Principles review counted this one as the remaining member of the class.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|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

Pattern harvest

Rule candidate: semgrep / AST ratchet — when one file has two writer families guarded by different locks (here config.json: a sidecar advisory flock and the loop-side _get_config_lock), holding only one of them excludes nothing the other family respects, so every writer must go through the entry point that takes both; a bare asyncio.to_thread(update_config_locked, ...) is the detectable shape of the defect, and the resulting lost update is silent and bidirectional.

Section appended by a maintainer to satisfy the PR Hygiene gate, which began requiring a Pattern harvest section on fix: PRs after this PR was opened. No other part of this description, and nothing on the branch, was touched.

@leonlaiyc
leonlaiyc requested review from a team and CrysisDeu August 31, 2026 01:52
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 31, 2026
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.10, 1) is red on this PR and is not attributable to the diff.

The failure is test/test_agent_spec_hardened_reads.py::TestResolveMcpServer::test_valid_agent_spec_still_resolves_under_the_same_cap — AssertionError: assert (('c', 'a'), {}) == ('c', 'a'). #2602 (merged as 5fe1d64e4) changed _resolve_mcp_server to return (argv, env) and updated two of the three test files that assert it; this one still asserts the old bare tuple. It reproduces on origin/main with no patch applied (1 failed, 52 passed, 2 skipped), and this PR touches only dashboard/handlers/updates.py and test_config_rmw_preserves_settings.py — no path to cron_script or agent-spec reads.

Fixed separately in #7176 rather than folded in here. No SHA churn on this branch for it.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Aug 31, 2026
@leonlaiyc

Copy link
Copy Markdown
Contributor Author

Full CI triage on this head — three distinct failures, none attributable to the diff. This PR touches only dashboard/handlers/updates.py and test_config_rmw_preserves_settings.py.

  1. test_agent_spec_hardened_reads.py::TestResolveMcpServer::test_valid_agent_spec_still_resolves_under_the_same_cap — assert (('c','a'), {}) == ('c','a'). On 3.10 shard 1, 3.12 shard 1, and Windows shard 1. Main-side: fix(cron): forward per-server env, sanitized, and pin wrappers at their source #2602 changed _resolve_mcp_server to return (argv, env) and updated two of the three asserting test files. Reproduces on origin/main unpatched. Fixed in test(cron): pin the env half of the post-#2602 resolver contract #7176. It also fails identically on fix(kiro-cli): derive the POSIX search dirs from the home that was asked for #7172, whose diff is unrelated to both.
  2. test_denied_commands_security.py::TestSelfModuleIndexIsLinear::test_the_scan_is_linear_not_quadratic — 0.0402s -> 0.1354s looks super-linear. A wall-clock complexity guard on a shared runner; no path from a config-lock change to a denied-commands module index scan.

No commit, no rebase, and no empty push to reroll — none of these is a signal about this branch.

@bolichen97

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: bolichen97#66809557]: This PR has been inactive for 3+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: The failing Backend Tests are not in this PR's diff. Shard-1 (3.10 & 3.12) fails on test_agent_spec_hardened_reads.py:359 (a mock call-args shape (('c','a'), {}) == ('c','a') that drifted on main after this PR's base), and the Windows shards fail on test_denied_commands_security.py:3910, a known super-linear timing-ratio flake unrelated to the change. This PR's own tests (test_config_rmw_preserves_settings.py) pass. Fix plan: rebase onto current origin/main to pick up the corrected mock assertion and re-mint the merge ref, then re-run to clear the timing flake. The change itself (routing the updates.py auto-update write through run_config_write to hold both config locks, sibling of merged #6984) is untouched.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 4, 2026
@bolichen97
bolichen97 force-pushed the fix/update-auto-both-config-locks branch from bcbaecb to 586e55d Compare September 4, 2026 00:37
@bolichen97

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: bolichen97#66809557]: Rebased this branch onto current main and force-pushed (bcbaecb→586e55d, lease-pinned). Changes made:

  1. Rebase onto 711544f (current main). One conflict in test/test_config_rmw_preserves_settings.py: main had appended TestEveryConfigWriterIsLocked (Legacy config writers bypass the advisory lock, so a locked read-modify-write can still lose their change #8032) at the same end-of-file position where this PR appends TestAutoUpdateToggleHoldsBothConfigLocks. Resolved by keeping both classes in sequence (main's first, this PR's after) — no line of either class was altered.
  2. No production-code change. handlers/updates.py is byte-identical in intent to the original commit: the single asyncio.to_thread → run_config_write swap and its comment block are unchanged. The design is preserved as-authored.
  3. The rebase picks up test(cron): pin the env half of the post-#2602 resolver contract #7176's corrected (argv, env) assertion in test_agent_spec_hardened_reads.py, which should clear the shard-1 failures (3.10/3.12/Windows) that were inherited through the stale merge ref. The Windows test_denied_commands_security.py timing flake was not touched, per assessment — a re-run should clear it.
  4. Commit trailer credits the rebase as Co-authored-by: Kiro Crew; original work remains authored by Leon (leonlaiyc).

Local gates before push, all green: check_black_formatting.py, isort, flake8, mypy src/kiro_crew (1282 files, no issues), pytest test_config_rmw_preserves_settings.py test_dashboard_updates_coverage.py (107 passed, 1 skipped) and test_agent_spec_hardened_reads.py (65 passed).

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 156e2b0d856034f29110e94915229bc0b2d5a6f8 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Legacy writers still hold only the loop-side lock against the CLI/second gateway — confirm that mirror-image gap is tracked as a follow-up.

[DESIGN-REVIEWED] 156e2b0

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed 156e2b0d856034f29110e94915229bc0b2d5a6f8 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 156e2b0

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 156e2b0d856034f29110e94915229bc0b2d5a6f8 via the fork AI-review pipeline — 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

One residual, declared: legacy handlers holding only the asyncio lock still race the CLI/second-gateway flock — the description scopes that out explicitly, nothing to hold here.

I verified the sibling claim myself: grepping asyncio.to_thread(update_config_locked finds 3 sites on base; the other two (core.py:2469, tailnet_mobile.py:663) already sit inside async with _get_config_lock():, so this was the last one-lock dispatch of its class. The defect's provenance is a test in this PR that fails on base by construction (_get_config_lock().locked() is False under a bare to_thread), and the two-lock rule is already documented in chat_utils.run_config_write's docstring and config/loader.py — the fix routes through that existing mechanism rather than adding one. The rewritten comment is declared and extends, not reverses, the old one's claim.

What this change ships

Inventory (4 items) — 4 justified

Intent: stop a routine dashboard settings save from silently reverting the auto-update toggle (or vice versa) — a FIX.

  1. Toggling auto-update can no longer be silently undone by a concurrent dashboard config write — justified
  2. The comment above the write now explains why both locks are needed, not just the flock — justified
  3. Three behavioural tests pin the lock held/released and the fail-closed 500 path — justified
  4. An AST ratchet (plus its self-test) names any future bare re-dispatch in updates.py — justified

[FIRST-PRINCIPLES-REVIEWED] 156e2b0

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 156e2b0d856034f29110e94915229bc0b2d5a6f8 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 156e2b0

@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main 41dcadf2c by a maintainer as part of the 2026-09-08 open-PR audit. Old head 586e55df3 -> new head 3fbbd8871.

Clean rebase: no conflicts. Your api_update_auto change sits on top of main's already-converted api_log_level, and both now share the module-level run_config_write import.

Gates run locally on the changed files only: isort clean, flake8 clean, pytest test/test_config_rmw_preserves_settings.py 29 passed / 1 skipped. black --check reports the test file as reformattable, but that is pre-existing on main and the file is listed in .github/black-baseline.txt, so nothing was reformatted.

Please review the rebased result. A maintainer push makes the maintainer the last pusher, so under this repo's last-push rule a second approver is needed. Reply here if anything looks wrong.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 8, 2026
…writers

`POST /api/update/auto` persisted the flag with a bare
`asyncio.to_thread(update_config_locked, ...)`. That holds only the
sidecar advisory flock, which excludes the CLI and a second gateway but
not the legacy dashboard writers -- core.py's theme/settings PUT, the
agents endpoint, security.py, messaging.py, mcp.py, computer_use.py --
which read-modify-write the same config.json holding only the loop-side
`_get_config_lock`.

So a theme save landing between this endpoint's read and its write
commits from a snapshot taken before it and silently reverts the
auto-update flag the user just toggled, or this write reverts their
theme. Nothing errors; the response is built from `enabled`, not from a
re-read of what landed.

Route it through `run_config_write`, the one entry point that holds both
generations. It takes the loop-side lock on the event loop and runs the
blocking writer in a worker, so the flock wait still never stalls the
loop. Nothing here holds a config lock already, so no nesting is
introduced, and the helper propagates the writer's exceptions unchanged
so the fail-closed 500 arm is untouched.

Sibling of kirodotdev#6984, which made the same correction in apps/routes.py.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Rebased onto main by Kiro Crew (conflict in test_config_rmw_preserves_settings.py
resolved by keeping both appended test classes); original work by Leon (leonlaiyc).

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
@iamwhatever
iamwhatever force-pushed the fix/update-auto-both-config-locks branch from 3fbbd88 to 156e2b0 Compare September 21, 2026 21:02
@iamwhatever

Copy link
Copy Markdown
Contributor

Rebased onto current main by a maintainer (maintainer_can_modify), force-pushed to 156e2b0d856034f29110e94915229bc0b2d5a6f8. The branch is now a single commit whose parent is 17c96c7ab0001984b3e148dfe33bcd80163663e8. No behaviour change — the production edit is still the one-line dispatch swap.

Conflicts resolved (two, not one)

1. src/kiro_crew/dashboard/handlers/updates.py — comment only. main had reworded the same sentence about the sidecar flock, dropping the phrase "this endpoint used to rely on". This PR rewrites that sentence so it leads into the new paragraph it adds directly below. Took this PR's wording: it carries main's meaning, and the phrase main removed is not reintroduced.

2. test/test_config_rmw_preserves_settings.py — both sides append at end of file. main added TestTheAtomicJsonWriteConfigFamilyIsRatcheted; this PR adds TestAutoUpdateToggleHoldsBothConfigLocks. They are independent, so the resolution is a concatenation — both kept, in that order. Verified all 7 of main's classes are still present in the merged file, plus this PR's new one (8 total).

One formatting fix on top of the rebase

The repo's black gate (scripts/check_black_formatting.py) scopes to the change's own diff, and this test file is not in .github/black-baseline.txt, so it must be fully black-clean. The new class had been written at 88 columns while the repo runs line-length = 100, so the gate failed. Confirmed main's version of the file is already clean under the gate's exact options, then ran black --target-version py310 on the whole file — all four resulting hunks fall inside this PR's own new class, so no main line was touched.

Tests and gates run

Against the pushed head, using the repo's own config:

Gate Command scope Result
pytest test_config_rmw_preserves_settings.py + test_dashboard_updates_coverage.py 116 passed, 1 skipped
black gate check_black_formatting.py, scope origin/main...HEAD pass
isort both changed files pass
flake8 both changed files pass
mypy updates.py pass, no issues

The 1 skip is test_windows_applies_an_owner_only_dacl, a Windows-only branch, unrelated to this change. All 5 of this PR's own tests in TestAutoUpdateToggleHoldsBothConfigLocks pass, as do both TestAutoUpdateToggleKeepsSettings tests.

Anti-revert verification

Rebases of this kind can silently drop upstream work while the file count stays the same, so both checks were run explicitly:

  • git diff --stat origin/main...HEAD (three dots) → +170 / -7, against a pre-rebase +177 / -8. The one missing deletion is the comment line main had already reworded; the 7 fewer insertions are black collapsing wrapped lines in the new test class.
  • comm -23 on ^(async )?def names between origin/main:updates.py and HEAD:updates.py → empty. No function present on main is missing here.

CI has not been polled from here; the conductor is watching the checks on 156e2b0d8.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 21, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Backend Tests (Windows) (1) is not this PR

The red is the known flake tracked in #12376, not this diff.

Failing tests (run 35654756860 / job 106519145208, head 156e2b0d8):

FAILED test/test_decisions_tool_risk_end_to_end.py::test_a_credential_in_the_command_is_annotated_rather_than_refused - AssertionError: a redacted argument is a question, not a refusal
FAILED test/test_decisions_tool_risk_end_to_end.py::test_a_trusted_tool_call_is_flagged_on_its_card_and_takes_a_verdict - AssertionError: the card must carry the annotation the oracle answered

Why it cannot be this diff

  • This PR changes one production line in src/kiro_crew/dashboard/handlers/updates.py plus one new test file. Neither the failing test file nor anything it exercises is touched.
  • test/test_decisions_tool_risk_end_to_end.py, test/test_decisions_tool_risk_card.py, src/kiro_crew/dashboard/chat_runner.py and the whole src/kiro_crew/decisions/ tree are byte-identical to origin/main on this head (same git blob/tree SHAs).
  • The same test fails on fix(issue-radar): decode az output as utf-8, not the host code page #7560, whose diff is disjoint from this one (an encoding= argument in issue_radar/azure_client.py). Two unrelated diffs, one failure: the cause is shared, not either diff.
  • Shard membership is a stable SHA-256 hash of the file path (scripts/ci_file_shards.py), so adding a test file does not reshuffle shards.
  • The file passes locally on Linux on this head, 3/3.

The mechanism

_record_outcome in src/kiro_crew/decisions/points/tool_risk.py bounds the outcome-row write at LOG_BUDGET_SECS = 0.05. On expiry it returns None by design, the tool card gets no decisions_tool_risk meta, and the only trace is a logger.debug line — which is exactly the assertion that fails. The module's autouse _generous_append_deadline fixture raises platform_log_append._APPEND_TIMEOUT_SECONDS to 10 s but leaves this 50 ms caller-side budget at its production value.

Reproduced on Linux by setting tool_risk.LOG_BUDGET_SECS = 0.0001 and changing nothing else: the same two tests fail with the same two messages, and the file's third test still passes — the exact failure set from the Windows job.

Load correlates. Backend Tests (Windows) (1) on this head took 18m25s, the slowest observed; the nine unrelated PRs where that shard passes ran 5m15s–12m31s.

Posting evidence only — nothing pushed, and no rebase is needed for this.

@iamwhatever

Copy link
Copy Markdown
Contributor

Backend Tests (Windows) (1) re-verified on today's head — still main's, not this diff

Re-checked on head 156e2b0d8 (run 35654756860, job 106519145208). Same two tests, same mechanism as the earlier triage on this PR:

FAILED test/test_decisions_tool_risk_end_to_end.py::test_a_credential_in_the_command_is_annotated_rather_than_refused - AssertionError: a redacted argument is a question, not a refusal
FAILED test/test_decisions_tool_risk_end_to_end.py::test_a_trusted_tool_call_is_flagged_on_its_card_and_takes_a_verdict - AssertionError: the card must carry the annotation the oracle answered

Both reduce to assert None is not None: the tool card carries no decisions_tool_risk meta.

Mechanism

_record_outcome in src/kiro_crew/decisions/points/tool_risk.py bounds the outcome-row write at LOG_BUDGET_SECS = 0.05. On expiry it returns None by design, the card gets no annotation, and the only trace is a logger.debug line — exactly the assertion above. The module's autouse _generous_append_deadline fixture raises platform_log_append._APPEND_TIMEOUT_SECONDS to 10 s and leaves this 50 ms caller-side budget at its production value. Reproduced on Linux by setting that one constant to 0.0001 and changing nothing else.

Tracked in #12376 (open, needs-investigation).

Why it is not this diff

  • This PR changes one dispatch line in src/kiro_crew/dashboard/handlers/updates.py plus test/test_config_rmw_preserves_settings.py. The failing test reaches neither.
  • src/kiro_crew/decisions/, src/kiro_crew/dashboard/chat_runner.py and the failing test file are byte-identical to origin/main on this head.
  • LOG_BUDGET_SECS is still 0.05 on main (17c96c7ab); no landed or open fix touches it.
  • On main's own recent CI runs (35664404383, 35660947297) all eight Windows backend shards pass, so this is a load-dependent timing flake on a 50 ms budget, not a standing red — the same shard also failed on fix(issue-radar): decode az output as utf-8, not the host code page #7560, whose diff is disjoint from this one.
  • The shard took a long wall-clock on this attempt; load correlates.

Nothing pushed. gh run rerun 35654756860 --failed requested (attempt 3) — a flake of this shape usually passes on a re-roll.

@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 Sep 22, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 22, 2026 03:07

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

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 (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean (the single Semgrep annotation on this head is GitHub's own ubuntu-latest runner-migration notice on .github, annotation_level=notice, not a finding), security checklist all-NO, AI reviewers green. Category: the auto-update toggle held only the sidecar advisory flock, which does not exclude the legacy dashboard writers that read-modify-write the same config.json under the loop-side lock, so a concurrent theme or settings save could silently revert the toggled flag -- swapping the bare asyncio.to_thread for run_config_write holds both locks while still keeping the blocking wait off the event loop, and the fail-closed unreadable-config contract is unchanged. CodeQL is not applicable on this fork PR (default-setup emits no check-run); SAST coverage is Semgrep only, latest run success with 0 real annotations.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after a live re-verification: readiness: passed label, PR Readiness status success on this head, no required check pending/failed/cancelled, mergeable, no effective CHANGES_REQUESTED, and no unresolved human blocking request found in comments or review threads. Native auto-merge (squash) enabled; no admin override used.

@iamwhatever
iamwhatever merged commit 6103fd4 into kirodotdev:main Sep 22, 2026
140 of 141 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 22, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…writers (kirodotdev#7167)

`POST /api/update/auto` persisted the flag with a bare
`asyncio.to_thread(update_config_locked, ...)`. That holds only the
sidecar advisory flock, which excludes the CLI and a second gateway but
not the legacy dashboard writers -- core.py's theme/settings PUT, the
agents endpoint, security.py, messaging.py, mcp.py, computer_use.py --
which read-modify-write the same config.json holding only the loop-side
`_get_config_lock`.

So a theme save landing between this endpoint's read and its write
commits from a snapshot taken before it and silently reverts the
auto-update flag the user just toggled, or this write reverts their
theme. Nothing errors; the response is built from `enabled`, not from a
re-read of what landed.

Route it through `run_config_write`, the one entry point that holds both
generations. It takes the loop-side lock on the event loop and runs the
blocking writer in a worker, so the flock wait still never stalls the
loop. Nothing here holds a config lock already, so no nesting is
introduced, and the helper propagates the writer's exceptions unchanged
so the fail-closed 500 arm is untouched.

Sibling of kirodotdev#6984, which made the same correction in apps/routes.py.



Rebased onto main by Kiro Crew (conflict in test_config_rmw_preserves_settings.py
resolved by keeping both appended test classes); original work by Leon (leonlaiyc).

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…writers (kirodotdev#7167)

`POST /api/update/auto` persisted the flag with a bare
`asyncio.to_thread(update_config_locked, ...)`. That holds only the
sidecar advisory flock, which excludes the CLI and a second gateway but
not the legacy dashboard writers -- core.py's theme/settings PUT, the
agents endpoint, security.py, messaging.py, mcp.py, computer_use.py --
which read-modify-write the same config.json holding only the loop-side
`_get_config_lock`.

So a theme save landing between this endpoint's read and its write
commits from a snapshot taken before it and silently reverts the
auto-update flag the user just toggled, or this write reverts their
theme. Nothing errors; the response is built from `enabled`, not from a
re-read of what landed.

Route it through `run_config_write`, the one entry point that holds both
generations. It takes the loop-side lock on the event loop and runs the
blocking writer in a worker, so the flock wait still never stalls the
loop. Nothing here holds a config lock already, so no nesting is
introduced, and the helper propagates the writer's exceptions unchanged
so the fail-closed 500 arm is untouched.

Sibling of kirodotdev#6984, which made the same correction in apps/routes.py.



Rebased onto main by Kiro Crew (conflict in test_config_rmw_preserves_settings.py
resolved by keeping both appended test classes); original work by Leon (leonlaiyc).

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
@mbriones98 mbriones98 removed the drive-to-green PR claimed by drive-to-green pipeline label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants