← Back to Pull requests

fix: a thread the system refuses ends its job with an error, not the app; lint the rules #2752

Open
unknown opened this pull request with 546 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 22, 2026 23:55 UTC
Author

Summary

AGENTS.md › "Use the threads" says the thread count comes from rustgis_data::threads, never available_parallelism, and that a thread the system refuses costs speed, not the run. std::thread::spawn breaks the second rule: it panics when the system refuses a thread, which takes the app down with it. clippy.toml now refuses both std::thread::available_parallelism and std::thread::spawn, in the same disallowed-methods list as the spherical measures (#2730). A remaining use says why in its #[expect(clippy::disallowed_methods, reason = "…")].

Every non-test std::thread::spawn now uses std::thread::Builder and handles a refusal, in whatever way the surrounding code already ends a failed job:

| Site | What a refused thread does now |
|---|---|
| ui-egui/src/layerchooser.rs add_file | the file is added as when its layers can't be listed, through the new work_off_frame |
| ui-egui: repairsource::list_datasets, sqlpane (preview, names, run), update::install::start, pluginsui::fetch, assistantpane::dispatch, assistantpane::revoke_later | the job's slot gets the refusal as its error, through the new work_off_frame, and the pane shows it as it shows any failure |
| ui-egui/src/pluginsui.rs prepare_env | the environment job ends with the refusal as its error |
| ui-egui/src/assistantpane.rs read_sign_in | the sign-in stays as it is (not read is not signed out), and the refusal is said as a sign-in store error |
| ui-egui/src/localagents.rs Run::start (input, errors, output) | start returns the refusal, and dropping the run stops the agent's program, as when its first message can't be sent |
| assistant/src/chatgpt.rs login_inner, cancellable | the sign-in returns the refusal as its error |
| tiles/src/arcgis_auth.rs start_sign_in | the sign-in fails with the refusal, in its progress and its result |
| tiles/src/arcgis_auth.rs revoke_all | the revocations go unsent, as when a request fails (it was already best effort) |
| tiles/src/cache.rs head, post_fetched, download_fetched_within, download_fetched_public_within | the request's done hears the refusal as its error (a HEAD reads the file without asking, as past its limit), through the new answer_on_own_thread, which keeps done reachable when the thread never starts |
| data/src/source/external.rs run, geolibre/src/runner.rs output_until, plugins/src/pyenv.rs run_uv | the program is stopped and the refusal is the error, as external::run already did without a thread to write its input with |
| plugins/src/process.rs spawn (lines, errors, writer) | the plugin's program is stopped and spawn returns the refusal, as when its pipes can't be connected |

available_parallelism stays in one place, rustgis_data::threads::cores, with its reason. Tests keep std::thread::spawn, under one #[expect] per test module or file: there, a refused thread fails the test, as it should. No site needed a design decision. There is no new dependency, and nothing changes while the system grants threads.

AGENTS.md › "Use the threads" now says the lint enforces these rules.

Surfaces: the desktop app, and the command line and Python through the data, plugins, GeoLibre, tiles and Assistant crates. In the browser, Builder::spawn returns an error where std::thread::spawn panicked, but none of these paths runs there. The ribbon, the saved project and the command ids are unchanged.

Testing

  • The lint: with let _ = std::thread::spawn(|| ()).join(); and let _ = std::thread::available_parallelism(); added to geolibre::runner::output_until, cargo clippy -p rustgis-geolibre -- -D warnings fails twice. It gives `use of a disallowed method std::thread::spawn with the note "it panics when the system refuses a thread: use std::thread::Builder::spawn and handle the error", and use of a disallowed method std::thread::available_parallelism with its note.

  • A refused thread can't be brought about in a test without changing how the system starts threads, so the handling of each refusal is checked by review, not by a test. Each one reuses its function's existing error path.

  • cargo clippy --workspace --all-targets -- -D warnings`, the wasm build and the full CI on the fork.
  • Related issue

    None: this enforces AGENTS.md › "Use the threads".

    Diff: 546 lines (+409 / -137) across 6 files Reviewer: github-actions[bot] Review duration: 4m
    All Vouch review confidence checks passed
    Residual risk 0.38 = Change Risk (0.48) × (1 − Review Confidence (0.22)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 546 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 33% · Reviewer familiarity: 35%
    21%
    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.377
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2752"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 21.9% 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: 48% (MEDIUM) · Higher = larger blast radius
    48%
    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: 21.9% · Lower = rushed or shallow review
    21.9%
    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: 37.5% · Moderate risk
    37.5%