Repository navigation
fix(cli): isolate heavy foreground maintenance - #711
Conversation
Problem: foreground doctor repairs and heavy run stages inherited interactive CPU and I/O priority, which could starve the desktop during large archive maintenance. A concurrent reparse fix from another agent also left the force-write path only partially wired, so --reparse could still skip same-hash row replacement after resetting parse status. What changed: add a central maintenance resource-boundary policy with systemd-scope preference, process demotion fallback, JSON/plain reporting, and --resource-mode overrides. Route mutating doctor maintenance plus heavy run/embed stages through it. Finish force_write propagation from run --reparse through pipeline execution, parsing services, and sync ingest writes. Verification: ruff check/format on changed files; pytest focused maintenance/resource, doctor, run, snapshot, and ingest tests; devtools render-all --check; devtools verify-topology; devtools verify-layering; devtools verify --quick. Ref #708.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR adds resource isolation for mutating maintenance tasks and heavy pipeline stages through a new resource-boundary system that supports systemd scope, process demotion, and test harness detection, with a ChangesResource Isolation System
Sequence DiagramsequenceDiagram
actor User
participant CLI
participant ResourceMgr as Resource Boundary<br/>Manager
participant OS as OS/Systemd
participant Workflow
participant Report as Resource Report<br/>Renderer
User->>CLI: Run 'polylogue doctor --resource-mode auto'
CLI->>CLI: Normalize resource_mode
CLI->>ResourceMgr: doctor_resource_request(repair,cleanup,preview,mode)
ResourceMgr->>ResourceMgr: Classify workload & heavy flag
CLI->>ResourceMgr: apply_resource_boundary(request)
alt Heavy + auto/scope mode
ResourceMgr->>OS: Check systemd-run available?
OS-->>ResourceMgr: Yes/No
alt Systemd available
ResourceMgr->>OS: Re-exec in systemd-run --scope
OS->>OS: Isolate with cgroup/demotion
OS-->>ResourceMgr: Report applied
else Fallback to process demotion
ResourceMgr->>OS: nice() + ionice()
OS-->>ResourceMgr: Report demoted
end
else Not heavy or off mode
ResourceMgr-->>ResourceMgr: Skip, report "not_applicable"
end
ResourceMgr-->>CLI: ResourceBoundaryReport
CLI->>Workflow: Execute maintenance/run
Workflow->>Workflow: Perform work
Workflow-->>CLI: Result
CLI->>Report: Render resource_boundary report
Report-->>User: Display "Resource mode: effective_mode (status)"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Suggested labels
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 docstrings
🧪 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Polylogue Proof PackRefs: Affected Domains
Additional routed domains with zero affected claims
Focused Gates
Required PR Gates
Optional Confidence Gates
Known Gaps
Additional gaps in zero-claim routed domains
Oracle / Cost
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43ad4f66c2
ℹ️ 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".
## Summary Handle `systemd-run --user --scope` launch failures as unavailable resource isolation rather than exiting the original command with the `systemd-run` status. ## Problem The resource boundary work from #711 made `auto` mode prefer transient systemd scopes for heavy foreground maintenance. A nonzero `systemd-run` exit is not the same as successful re-exec inside a scope: in `auto` mode it should fall through to process-local demotion, and in explicit `scope` mode it should report an unavailable scope with the diagnostic. ## Solution - Capture `systemd-run` output and treat nonzero return codes as `ScopeLaunchUnavailableError`. - Preserve the existing `SystemExit(0)` path when scope launch succeeds. - Add a focused test for explicit scope-mode launch failure and diagnostic propagation. ## Verification - `ruff check polylogue/maintenance/resources.py tests/unit/maintenance/test_resources.py` - `ruff format --check polylogue/maintenance/resources.py tests/unit/maintenance/test_resources.py` - `mypy tests/unit/maintenance/test_resources.py` - `pytest -q tests/unit/maintenance/test_resources.py` - `devtools verify --quick` - pre-push hook: `devtools verify --quick` Ref #708
Summary Add Polylogue-owned resource isolation for mutating maintenance and heavy foreground run stages, and finish force-write propagation for reparse runs. Problem Foreground `doctor --repair` and heavy `run` stages inherited interactive CPU and I/O priority, which could starve the desktop during large archive maintenance. An in-flight reparse fix also left `force_write` only partially wired, so `run --reparse` could reset parse status while same-hash conversation rows still skipped replacement. Solution Added `polylogue.maintenance.resources` as the central classifier and applicator for heavy foreground workloads. Mutating doctor maintenance and heavy run/embed stages now use `--resource-mode auto|scope|process|off`, preferring a user systemd transient scope and falling back to process-local nice/ionice. Doctor JSON/plain output and run output report the effective mode. Finished `force_write` propagation from `run --reparse` through run workflow, pipeline execution, parsing services, and sync ingest writes. Added regression coverage for same-hash forced replacement. Verification - `ruff check` and `ruff format --check` on changed runtime/test files - `pytest -q tests/unit/maintenance/test_resources.py tests/unit/cli/test_check_support_runtime.py tests/unit/cli/test_check_rendering_plain_runtime.py tests/unit/cli/test_run_command_runtime.py tests/unit/cli/test_check.py tests/unit/pipeline/test_ingest_batch.py` - `pytest -q -n0 tests/unit/cli/test_terminal_snapshots.py::TestCommandOutputs::test_check_output_snapshot tests/unit/cli/test_terminal_snapshots.py::TestCommandOutputs::test_run_help_output_snapshot tests/unit/cli/test_auth.py::TestAuthCommand::test_auth_unknown_service_fails tests/unit/cli/test_reset.py::TestResetCommandSubprocess::test_reset_database_requires_force` - `pytest -q tests/unit/proof/test_evidence_runners.py` - `devtools render-all --check` - `devtools verify-topology` - `devtools verify-layering` - `devtools affected-obligations --path docs/plans/topology-target.yaml` - `devtools affected-obligations --path docs/topology-status.md` - `devtools proof-pack --path ... --markdown` - `devtools verify --quick` - pre-push `devtools verify --quick` Ref #708
## Summary Handle `systemd-run --user --scope` launch failures as unavailable resource isolation rather than exiting the original command with the `systemd-run` status. ## Problem The resource boundary work from #711 made `auto` mode prefer transient systemd scopes for heavy foreground maintenance. A nonzero `systemd-run` exit is not the same as successful re-exec inside a scope: in `auto` mode it should fall through to process-local demotion, and in explicit `scope` mode it should report an unavailable scope with the diagnostic. ## Solution - Capture `systemd-run` output and treat nonzero return codes as `ScopeLaunchUnavailableError`. - Preserve the existing `SystemExit(0)` path when scope launch succeeds. - Add a focused test for explicit scope-mode launch failure and diagnostic propagation. ## Verification - `ruff check polylogue/maintenance/resources.py tests/unit/maintenance/test_resources.py` - `ruff format --check polylogue/maintenance/resources.py tests/unit/maintenance/test_resources.py` - `mypy tests/unit/maintenance/test_resources.py` - `pytest -q tests/unit/maintenance/test_resources.py` - `devtools verify --quick` - pre-push hook: `devtools verify --quick` Ref #708
|
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. |
|
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
Add Polylogue-owned resource isolation for mutating maintenance and heavy foreground run stages, and finish the reparse force-write plumbing that was started in the worktree by another agent.
Problem
polylogue doctor --repair --target session_insightsand similar foreground maintenance inherited interactive CPU and I/O priority. On a large archive this can saturate disk and make the desktop unusable. The same broad maintenance path also exposed an incompleteforce_writethread:run --reparsereset parse status, but same-hash conversation rows could still be skipped by sync ingest replacement.Solution
polylogue.maintenance.resourcesas the central classifier and applicator for heavy foreground workloads.doctormaintenance plus heavyrun/batch embed stages through that policy.systemd-run --scopewith low CPU/I/O weights, fall back to process-localnice/ionice, and expose--resource-mode auto|scope|process|off.force_writepropagation fromrun --reparsethrough run workflow, pipeline execution, parsing services, and sync ingest writes.Verification
ruff check polylogue/maintenance/resources.py polylogue/cli/commands/check.py polylogue/cli/commands/run.py polylogue/cli/shared/check_options.py polylogue/cli/shared/check_workflow.py polylogue/cli/shared/check_models.py polylogue/cli/shared/check_rendering_json.py polylogue/cli/shared/check_rendering_plain.py polylogue/cli/shared/run_workflow.py polylogue/pipeline/run_execution.py polylogue/pipeline/run_stages.py polylogue/pipeline/services/ingest_batch.py polylogue/pipeline/services/parsing.py polylogue/pipeline/services/parsing_workflow.py tests/unit/maintenance/test_resources.py tests/unit/cli/test_check.py tests/unit/cli/test_check_support_runtime.py tests/unit/cli/test_check_rendering_plain_runtime.py tests/unit/cli/test_run_command_runtime.py tests/unit/pipeline/test_ingest_batch.pyruff format --checkon the same filespytest -q tests/unit/maintenance/test_resources.py tests/unit/cli/test_check_support_runtime.py tests/unit/cli/test_check_rendering_plain_runtime.py tests/unit/cli/test_run_command_runtime.py tests/unit/cli/test_check.py tests/unit/pipeline/test_ingest_batch.pypytest -q -n0 tests/unit/cli/test_terminal_snapshots.py::TestCommandOutputs::test_check_output_snapshot tests/unit/cli/test_terminal_snapshots.py::TestCommandOutputs::test_run_help_output_snapshot tests/unit/cli/test_auth.py::TestAuthCommand::test_auth_unknown_service_fails tests/unit/cli/test_reset.py::TestResetCommandSubprocess::test_reset_database_requires_forcepytest -q tests/unit/proof/test_evidence_runners.pydevtools render-all --checkdevtools verify-topologydevtools verify-layeringdevtools proof-pack --path ... --markdowndevtools verify --quickdevtools verify --quickRef #708
Summary by CodeRabbit
New Features
--resource-modeoption torunanddoctorcommands for controlling resource isolation during maintenance and pipeline execution.run --previewdisplaying resolved sources and output paths.Documentation