← Back to Pull requests

fix: report unreadable LoopX state directories instead of crashing #9689

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Dec 01, 2026 00:04 UTC
Author

Goal And Delivered Outcome

  • Outcome basis / optional anchor: reproduced defect; no existing issue or PR found.

  • Goal/source and gap: default_runtime_route() stats and lists ~/.loopx and ~/.codex/loopx to choose the default route. When a root can be seen but not searched or listed (for example, a host sandbox that denies listing ~/.loopx), Path.exists() or iterdir() raises PermissionError. Every command without an explicit --runtime-root/--registry then fails with a raw traceback. Separately, resolve_cli_registry() probes the default .loopx/registry.json with Path.exists(): when a project .loopx cannot be searched, Python 3.11–3.13 raise PermissionError while Python 3.14+ returns False and silently falls back to the global registry (ok: true against the wrong registry).

  • Observable before → after, with the validation row that proves it:

  • - With the default root at 0o111 or 0o000, loopx status previously crashed with PermissionError; it now exits 1 with A default runtime root cannot be inspected (Permission denied: <path>). Allow read access to it, or pass --runtime-root or --registry explicitly., while --runtime-root keeps working (unit and real_entrypoint rows below).
    - With a project .loopx at 0o000 and a readable global registry present, resolve_cli_registry() now probes via stat() consistently across Python 3.11–3.14+ and stops with Cannot inspect registry .loopx/registry.json (Permission denied). Allow read access to it, or pass --registry explicitly. instead of crashing or falling back (unit row below).
  • Issue/task and intended base: none; main.
  • Author Declaration

  • Written by: model_agent (Claude, Anthropic), reviewed by the submitting human operator.
  • Implemented against

  • Specification and revision: no written specification; the request in this PR is the basis.

  • Criteria:
  • | Criterion (spec clause) | Disposition | Symbol / path | Test or command |
    | --- | --- | --- | --- |
    | An unreadable default root is reported as invalid, not raised | implemented | loopx/paths.py::default_runtime_route | tests/test_local_state_migration.py::test_default_route_reports_a_runtime_root_it_cannot_list |
    | An unsearchable project registry directory stops without silent fallback across Python 3.11–3.14+ | implemented | loopx/cli_runtime.py::_registry_path_exists | tests/test_local_state_migration.py::test_unsearchable_project_registry_directory_stops_instead_of_falling_back |

  • Self-check before submission: reproduced both permission modes (0o111, 0o000) and confirmed both new tests fail on base (including silent global fallback on Python 3.14). Readable roots keep their existing classification.
  • Scope And Continuation

  • Completed scope and remaining work: complete within this scope.

  • Slice boundary / successor: N/A — self-contained bug fix.
  • Validation

  • Tested revision: ba466d39a

  • Run state: finished

  • Input classes: synthetic
  • | Check kind | Result | Public-safe evidence / limitation |
    | --- | --- | --- |
    | unit | passed | tests/test_local_state_migration.py (both new tests passed on Python 3.13 and 3.14; full file + tests/test_cli_argument_diagnostics.py 198 passed, 3 skipped; both new tests fail on base). |
    | unit | passed | Neighboring default-route suites (test_doctor_installation_scope.py, test_state_backup.py, test_turn_default_host_binding.py, test_support_control_update_ownership.py): 98 passed. |
    | static | passed | ruff check and git diff --check clean on all changed files. |
    | real_entrypoint | passed | python -m loopx.cli status with synthetic HOME .loopx at 0o111/0o000: clean exit 1 without traceback; --runtime-root still succeeds. |

  • Coverage and gaps: verified on macOS with Python 3.13 and 3.14. Permission tests skip on Windows and root where POSIX permission bits do not apply.
  • Frontend / Visual Evidence

  • UI impact: none

  • Before: N/A

  • After: N/A

  • First viewport and preview: N/A

  • States and viewports shown: N/A

  • Source data: none

  • Attention review: N/A

  • Craft review: N/A
  • Type of Change

  • Bug fix
  • LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening
  • Shared-authority RFC fixture impact

    N/A

    Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).

  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.

  • I kept the change scoped to the linked issue/task.

  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.

  • I completed the visual evidence section for UI changes, or marked UI impact none.

  • Every commit includes a DCO Signed-off-by trailer (git commit -s).
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: loopx-agent Review duration: 256m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #9689"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%