fix(kanban): serialize all SQLite writers across processes - #67477
Open
o269 wants to merge 1 commit into
Open
Conversation
Collaborator
teknium1
reviewed
Jul 19, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the focused single-writer hardening. Current main still has an unguarded normal write_txn() path at hermes_cli/kanban_db.py:2307-2344, while its existing .dispatch.lock only surrounds dispatch_once() at hermes_cli/kanban_db.py:7453-7502. The change therefore targets a current gap. Remote main is only one JS-only commit beyond this PR's base, so the Kanban changes should salvage cleanly.
Problems
hermes_cli/kanban_db.py:1515-1576adds a distinct Windowsmsvcrtacquisition/release path, buttests/hermes_cli/test_kanban_write_lock.py:1-175contains no Windows-path coverage. The multiprocessing checks validate the hostfcntlpath, not the added Windows behavior.
Suggested changes
- Add a Windows-path regression for lock contention, bounded failure, and unlock-on-exception before relying on the cross-platform guarantee.
Automated hermes-sweeper review.
| timeout_seconds = max(0.0, float(timeout_seconds)) | ||
| deadline = time.monotonic() + timeout_seconds | ||
|
|
||
| if _IS_WINDOWS: |
Contributor
There was a problem hiding this comment.
This starts a separate Windows msvcrt implementation, but the added regression file has no _IS_WINDOWS/msvcrt coverage. Please add a Windows-path test for contention, bounded failure, and release after an exception.
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Serializes every Hermes Kanban SQLite write transaction across processes with the board's existing
.dispatch.lock, while preserving the dispatcher's non-blocking skip behavior.This is a focused defense-in-depth fix for orphan gateways and worker stampedes: readers remain concurrent, but only one process may run a Kanban write transaction or close-time WAL checkpoint at once.
Fixes #53819.
Defense in depth for #35240.
Changes
flockand Windowsmsvcrt.lockingwrite_txn()calls around the shared lock and useBEGIN IMMEDIATEwith jittered busy retries at transaction boundaries.An applicable patch for the separate local bridge-state SQLite writer was also validated against the installed script (
kanban_bridge_state.patchin the associated Kanban task workspace); it uses the same lock protocol and is intentionally not included as an unrelated host-local script in this repository PR.Verification
Exact rebased tree (base
ad0d21188):HERMES_PYTHON=/home/odai/.hermes/hermes-agent/venv/bin/python scripts/run_tests.sh tests/hermes_cli/test_kanban*.py tests/tools/test_kanban*.py tests/gateway/test_kanban*.py tests/plugins/test_kanban*.py tests/agent/test_kanban_stop.py -qpython -m ruff check hermes_cli/kanban_db.py tests/hermes_cli/test_kanban_db.py tests/hermes_cli/test_kanban_write_lock.pypython -m py_compile ...git diff --check origin/main...HEADuv build --quiet --out-dir /tmp/t_27b4be27-dist-final-rebasedpy_compile+ RuffConcurrent load gate
A mandatory 12-minute monitor ran against a fresh throwaway copy of the fleet board (the live board was read-only source material). It mixed:
hermes kanbanCLI writer processesResult:
0[]PRAGMA quick_check:okPRAGMA integrity_check:okPRAGMA foreign_key_check: 0 rowsRisk / compatibility
mainpath retain the pre-existing transaction behavior.HERMES_KANBAN_BUSY_TIMEOUT_MSand fails closed instead of silently falling back to unsafe concurrent writes.