feat(python): fresh agent list in advance_dag, background DAG scan; bump cnats 3.9.3→3.12.0#475
Merged
Conversation
| task = walker.start_background_scan(stop_event) | ||
| assert isinstance(task, asyncio.Task) | ||
| stop_event.set() | ||
| await task |
| scan_task = walker.start_background_scan(stop_event) | ||
| await asyncio.sleep(0.07) # allow ~3 intervals to fire | ||
| stop_event.set() | ||
| await scan_task |
| scan_task = walker.start_background_scan(stop_event) | ||
| await asyncio.sleep(0.07) | ||
| stop_event.set() | ||
| await scan_task |
| stop_event = asyncio.Event() | ||
| stop_event.set() # pre-set before starting | ||
| scan_task = walker.start_background_scan(stop_event) | ||
| await scan_task |
| task = walker.start_background_scan(stop_event) | ||
| assert walker._scan_task is task | ||
| stop_event.set() | ||
| await task |
| ) | ||
| # stop_event was set — exit cleanly. | ||
| break | ||
| except asyncio.TimeoutError: |
✅ Dependency Audit
See the Security tab for detailed findings. Workflow: Dependency Audit |
| ) | ||
| # stop_event was set — exit cleanly. | ||
| break | ||
| except asyncio.TimeoutError: |
| task = walker.start_background_scan(stop_event) | ||
| assert isinstance(task, asyncio.Task) | ||
| stop_event.set() | ||
| await task |
| scan_task = walker.start_background_scan(stop_event) | ||
| await asyncio.sleep(0.07) # allow ~3 intervals to fire | ||
| stop_event.set() | ||
| await scan_task |
| scan_task = walker.start_background_scan(stop_event) | ||
| await asyncio.sleep(0.07) | ||
| stop_event.set() | ||
| await scan_task |
| stop_event = asyncio.Event() | ||
| stop_event.set() # pre-set before starting | ||
| scan_task = walker.start_background_scan(stop_event) | ||
| await scan_task |
| task = walker.start_background_scan(stop_event) | ||
| assert walker._scan_task is task | ||
| stop_event.set() | ||
| await task |
Security Scan Results
Recommendations
Workflow: Security Scanning |
f5b04d1 to
241e6b3
Compare
241e6b3 to
f6b30b3
Compare
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
DAGWalker.advance_dag()now callsclient.get_agents()(if the client exposes it) to fetch a fresh agent list before evaluating availability, preventing stale-cache double-assignment races. Falls back toself.agentson exception or if the client has noget_agentsmethod.start_background_scan(stop_event)and_background_scan_loop()toDAGWalker. The background loop periodically callsadvance_dag()as a safety net for missed NATS trigger events. Usesasyncio.wait_for(_stop_event.wait(), timeout=interval)for interruptible sleep; exceptions in each scan are caught and logged so the loop survives transient failures.cnats/3.9.3→cnats/3.12.0inconanfile.py(matching the nats.c 3.12.0 version already in use per CLAUDE.md and previous fix commits).Files changed
src/keystone/dag_walker.py— fresh-agent refresh (Add get_agents() to DAGWalker.advance_dag() so agent list is always fresh #196) + background scan loop (Add periodic background DAG scan as safety net #98)conanfile.py— cnats version bump (Upgrade cnats dependency from 3.9.3 to latest (3.12.x when available) #179)tests/test_dag_walker.py— 13 new tests (5 forTestAdvanceDagFreshAgents, 5 forTestBackgroundScan, 3 existing tests updated to configureget_agentscorrectly)Test plan
python -m pytest tests/test_dag_walker.py -v— 43 tests passTestAdvanceDagFreshAgents— fresh-agent path, no-client path, missing-method fallback, exception fallback, None-return fallbackTestBackgroundScan— happy path, exception survival, immediate-stop exit, task reference storedCloses #98
Closes #179
Closes #196
🤖 Generated with Claude Code