Repository navigation
Conversation
…he record is still the run's own (#20023)
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
Open
3 tasks
This was referenced Nov 7, 2026
Owner
Author
|
Code review (code-reviewer pass) at e02c511 — APPROVE
Nits, not blocking:
|
This was referenced Nov 7, 2026
Closed
Owner
Author
4 tasks done
timothybrush
pushed a commit
to timothybrush/AutoBot-AI
that referenced
this pull request
Nov 7, 2026
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.
Refs #20023 (the claim-held, record-absent case still reads
idle; tracked in #21017)Thinking Path
The heartbeat and
_finishwrote the state hash with a plainHSET. When the hash had vanished while the run still held its claim, that write recreated it with noowner, and every reader then sawidle. The fix makes every write after the start owner-conditional in one atomic Lua step, so a vanished record stays absent instead of coming back ownerless. No TTL is added: the hash is the last-run record and a TTL would make it vanish by design. The wording is corrected instead.What Changed
autobot-backend/knowledge/embedding_switch.py: new_SET_IF_OWNER_LUAand_set_state_if_owner._heartbeatwrites through it and raises "lost its state record" when it returns 0, so the run fails and_finishreleases the claim._finishwrites through it too (its separate owner pre-check was a non-atomic read). Force-close passes an empty owner: it matches any record that still exists (including an ownerless one an older build left behind) and never creates one.start_switchkeeps its unconditional write, after it holds the claim and has deleted the old record. Module docstring and the settle-script comment no longer say "expired" for the record; the lock's lapse is called a lapse.autobot-backend/knowledge/embedding_switch_test.py: the fake Redis understands the new script.autobot-backend/knowledge/embedding_switch_owner_20023_test.py: new tests (the original test file is near the 600-line ceiling).Readers with a vanished hash (all covered)
switch_status{"failed_ids": [], "state": "idle"}, nothing else (test asserts it)request_switch_cancelnonenote_write_finish-1/0, write nothing (existing tests)Not determined: answers
maxmemory-policy, evictions on the knowledge database) is out of scope for a code PR. With the fix the ownerless state can no longer be produced, whatever the answer.flushdbreach the knowledge database through the cache-clear path? No, from the code:_CLEARABLE_DATABASE_NAMES = ("cache", "analytics")inapi/cache_redis_databases.py, andclearable_databaserejectsknowledgewith a 400 pointing to the deletion-proposal queue. Otherflushdbcallers (api/knowledge_mcp.py, setup script) were listed but not traced: out of scope here, no change depends on them.note_writeafter cutover lost? Reading_converge: after the settle sleep it replays pending ids, then comparesstore._collection.count()withfact_store.count_facts(); a mismatch after the replay rounds yieldscompleted_with_warningswith the reason, not silence. A write that lands in neither the pending set nor the count is not possible while the record is owned; with a vanished record the run now fails at the next heartbeat instead of continuing blind.HSETrace: still two steps (extend_claim, then the write), but the write now checksowneratomically. If a newer run took over in between, the old run's write returns 0, writes nothing, and the old run fails; the newer record is untouched (test: foreign owner leaves the record byte-identical).autobot-frontend/srcorautobot-slm-frontend/srcbeyond the generated API types; other clients not checked. Out of scope: the status payload contract is unchanged.Not done, proposed for approval (#17038)
start_switchreplaces one, and force-close still reaches one. If an operator wants one cleared sooner, that is a deletion proposal for the approval queue.idlewith a start refused as "already running" until the run fails at its next heartbeat. Reporting a held claim with no record as its own state would change the status contract; proposed as a follow-up decision, not done here.Verification
~/.venv-python-suite/bin/python -m pytest knowledge/embedding_switch_test.py knowledge/embedding_switch_owner_20023_test.py api/embeddings_switch_19379_test.py: all pass (54 passed with repo_tests/embedding_override_single_writer_19379_test.py)Tests include the script on a real Lua engine (fakeredis): vanished record writes nothing and the key stays absent; foreign owner writes nothing; ownerless legacy record reachable only by force-close.
Model Used
Claude Sonnet 5.5
Single-issue rationale
The change is confined to one module whose write path it replaces; no other open issue touches it.