Repository navigation
fix(devtools): bound workload diagnostics and cleanup pytest temps - #2163
Conversation
Problem: workload diagnostics could hang on large archives by running unbounded SQLite counts and integrity checks before emitting any JSON. Broad xdist test runs could also leave managed tmpfs basetemps resident until a later pytest startup sweep, pinning GiBs in /dev/shm after successful runs. What changed: the workload probe no longer counts FTS internal segment tables, skips SQLite quick_check and exact derived reconciliation by default, and exposes --integrity-check / --exact-derived-counts for explicit expensive diagnostics. The verify supervisor now removes managed per-run pytest basetemps after pytest exits, including xdist seed/full lanes. Verification: devtools test tests/unit/devtools/test_daemon_workload_probe.py tests/unit/devtools/test_verify.py::test_cleanup_managed_pytest_basetemp_removes_run_root tests/unit/devtools/test_verify.py::test_cleanup_managed_pytest_basetemp_keeps_seed_cache tests/unit/test_pytest_temp_policy.py -q; devtools verify --quick; devtools verify --seed-testmon --skip-slow; devtools verify. Live workload probe against the real archive returned ok JSON in 3.1s; /dev/shm returned to seeded caches only after the tmpfs seed run.
|
Warning Review limit reached
More reviews will be available in 50 minutes and 56 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo independent changes: (1) the daemon workload probe gains optional ChangesDaemon workload probe optional integrity and exact-counts modes
Managed pytest basetemp cleanup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f9bd5fb93
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devtools/daemon_workload_probe.py`:
- Around line 1155-1159: The change to action_count at line 1155 alters its
semantics from an exact count to a presence bit (0 or 1) when exact_counts is
false, which breaks the contract for downstream consumers relying on the numeric
field shape. Either increment REPORT_VERSION to signal the format change to
downstream systems, or refactor by keeping action_count as the exact count and
creating a separate new key (like action_present) for the presence indicator
when exact_counts is false. Choose the approach that best fits your versioning
strategy and downstream consumer requirements.
In `@devtools/verify.py`:
- Line 727: The cleanup_managed_pytest_basetemp function call is executed
unconditionally but depends on the POLYLOGUE_PYTEST_RUN_ID environment variable
being set by env_for_pytest_step, which only occurs when both run and artifacts
are not None. When these conditions are false, the empty string from
env.get("POLYLOGUE_PYTEST_RUN_ID", "") creates an invalid path that could delete
unintended directories. Move the cleanup_managed_pytest_basetemp call inside the
conditional block that checks if run is not None and artifacts is not None,
ensuring the cleanup only executes when env_for_pytest_step has properly
populated the environment variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a362b33a-7045-43d5-8469-4848522d21f9
📒 Files selected for processing (9)
AGENTS.mddevtools/daemon_workload_probe.pydevtools/verify.pydevtools/verify_runs.pydocs/internals.mdpolylogue/cli/commands/diagnostics.pytests/unit/devtools/test_daemon_workload_probe.pytests/unit/devtools/test_verify.pytests/unit/test_pytest_temp_policy.py
| "action_count": _scalar_int(conn, "SELECT COUNT(*) FROM actions") | ||
| if exact_counts | ||
| else _presence_count(conn, "actions"), | ||
| "action_count_exact": exact_counts, | ||
| "cost_profile_count": _scalar_int( |
There was a problem hiding this comment.
Preserve count semantics or bump REPORT_VERSION for compatibility
Line 1155 changes action_count to a presence bit in default mode (0/1), while the key name and numeric shape still look like an exact count. That is a contract break for downstream compare/automation consumers unless REPORT_VERSION is incremented (or the approximate metric is moved to a new key like action_present).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@devtools/daemon_workload_probe.py` around lines 1155 - 1159, The change to
action_count at line 1155 alters its semantics from an exact count to a presence
bit (0 or 1) when exact_counts is false, which breaks the contract for
downstream consumers relying on the numeric field shape. Either increment
REPORT_VERSION to signal the format change to downstream systems, or refactor by
keeping action_count as the exact count and creating a separate new key (like
action_present) for the presence indicator when exact_counts is false. Choose
the approach that best fits your versioning strategy and downstream consumer
requirements.
| if run is not None and artifacts is not None: | ||
| env = env_for_pytest_step(env, run=run, artifacts=artifacts) | ||
| result = _run_pytest_with_heartbeat(cmd, cwd=cwd, env=env, t0=t0, run=run, artifacts=artifacts) | ||
| cleanup_managed_pytest_basetemp(root=ROOT, run_id=env.get("POLYLOGUE_PYTEST_RUN_ID", ""), env=env) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check that env_for_pytest_step sets POLYLOGUE_PYTEST_RUN_ID
ast-grep --pattern $'def env_for_pytest_step($$$) {
$$$
}'Repository: Sinity/polylogue
Length of output: 42
🏁 Script executed:
# Search for env_for_pytest_step function
rg "env_for_pytest_step" -nRepository: Sinity/polylogue
Length of output: 346
🏁 Script executed:
# Read the devtools/verify.py file around line 727 to see context
sed -n '700,750p' devtools/verify.pyRepository: Sinity/polylogue
Length of output: 2441
🏁 Script executed:
# Find the cleanup_managed_pytest_basetemp function definition
rg "def cleanup_managed_pytest_basetemp" -A 15Repository: Sinity/polylogue
Length of output: 1268
🏁 Script executed:
# Read env_for_pytest_step implementation in verify_runs.py starting at line 186
sed -n '186,250p' devtools/verify_runs.pyRepository: Sinity/polylogue
Length of output: 3039
🏁 Script executed:
# Also check pytest_basetemp_path to understand the impact of empty run_id
rg "def pytest_basetemp_path" -A 20Repository: Sinity/polylogue
Length of output: 1596
Fix missing environment variable guard in cleanup call.
The cleanup is called unconditionally within the pytest block, but env_for_pytest_step (which sets POLYLOGUE_PYTEST_RUN_ID) is only called if run is not None and artifacts is not None. If this condition is false, env.get("POLYLOGUE_PYTEST_RUN_ID", "") returns an empty string, constructing a basetemp path like pytest-polylogue-{checkout_hash}-, which passes the validation check in cleanup_managed_pytest_basetemp and would be deleted if it exists. Either ensure the cleanup is only called when env_for_pytest_step was applied, or guarantee POLYLOGUE_PYTEST_RUN_ID is always set in the environment before reaching this point.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@devtools/verify.py` at line 727, The cleanup_managed_pytest_basetemp function
call is executed unconditionally but depends on the POLYLOGUE_PYTEST_RUN_ID
environment variable being set by env_for_pytest_step, which only occurs when
both run and artifacts are not None. When these conditions are false, the empty
string from env.get("POLYLOGUE_PYTEST_RUN_ID", "") creates an invalid path that
could delete unintended directories. Move the cleanup_managed_pytest_basetemp
call inside the conditional block that checks if run is not None and artifacts
is not None, ensuring the cleanup only executes when env_for_pytest_step has
properly populated the environment variable.
Problem: PR #2163 added explicit workload diagnostic flags but did not update the tier-0 showcase help baseline, causing showcase-verify to fail in CI. What changed: refreshed the help-ops-diagnostics-workload baseline to include --integrity-check and --exact-derived-counts. Verification: devtools lab scenario verify-baselines --update; devtools lab scenario verify-baselines.
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Bound the default daemon workload diagnostic path and made pytest temp cleanup supervisor-owned after managed runs. The default workload probe now returns promptly on the real archive instead of hanging on full SQLite/FTS scans, while expensive integrity and exact reconciliation checks remain available through explicit flags.
Problem
Two memory/runtime issues were observable locally:
polylogue ops diagnostics workload --jsoncould sit resident around a few hundred MiB and emit no JSON on the live archive. Stack dumps showed it blocked in default table-count/integrity/readiness scans:messages_fts_data,PRAGMA quick_check, generatedblocks.search_textreconciliation, andactionscounts.pytest_sessionfinishcleanup. A successful run could leave a multi-GiB/dev/shm/pytest-polylogue-*basetemp until another pytest startup sweep or manual cleanup.Solution
messages_fts_datafrom workload boundary/tier counts and reportsmessages_fts_docsizeinstead.PRAGMA quick_checkto defaultintegrity: not_checked, with--integrity-checkfor explicit expensive runs.--exact-derived-countsfor full reconciliation scans.polylogue ops diagnostics workload.cleanup_managed_pytest_basetemp()in the verify supervisor so managed per-run basetemps are reclaimed after pytest exits, including xdist seed/full runs.AGENTS.mdfor the new diagnostic contract.Verification
devtools test tests/unit/devtools/test_daemon_workload_probe.py tests/unit/devtools/test_verify.py::test_cleanup_managed_pytest_basetemp_removes_run_root tests/unit/devtools/test_verify.py::test_cleanup_managed_pytest_basetemp_keeps_seed_cache tests/unit/test_pytest_temp_policy.py -q— 23 passed.polylogue ops diagnostics workload --help— shows--integrity-checkand--exact-derived-counts.timeout 30s nix develop --command python -m devtools.daemon_workload_probe --jsonreturned status 0 in 3.132s, emitted 18,524 bytes,ok=True,integrity=not_checked, nomessages_fts_datacounts.devtools render all --check— clean after refreshing.cache/site.devtools verify --quick— exit 0.devtools verify --seed-testmon --skip-slow— 11,507 passed, 1 xfailed; peak pytest PSS 3,089.6 MiB;/dev/shmreturned to seeded caches only afterward.devtools verify— 7 affected tests passed; peak pytest PSS 122.4 MiB.Summary by CodeRabbit
New Features
--integrity-checkand--exact-derived-countsflags to thediagnostics workloadCLI command for optional deep integrity validation and exact derived-counts reconciliation.Documentation
Tests