← Back to Pull requests

test: make random component execution safer #10169

Closed
unknown closed this pull request without merging on May 11, 2026 17:26 UTC
View on GitHub
unknown unknown commented on May 06, 2026 22:40 UTC
Author

Description

Related to #9968.

This one took a few rounds: every time the Commands suite looked settled, another bit of shared test state quietly raised its hand. The result is a more random-order-safe Commands component, plus a few small shared-state hardening fixes that the parallel random component runs exposed along the way.

This enables Commands in the random test config and updates the affected tests so they own their setup/cleanup instead of depending on earlier tests running first.

Main changes:

  • reset scaffold test CLI state and make generated command/scaffold cleanup reliable between tests

  • isolate migration command tests from generated App migrations and leftover tables

  • make database command tests seed and select their own expected state

  • close/reset shared database connections before deleting SQLite test databases

  • restore locale/config state in translation command tests

  • reset mocked cache services after cache command tests

  • make the Unsuffixable support command provide its own template data

  • scope CreateNewChangelogTest cleanup in AutoReview so it no longer runs repository-wide git restore / git clean while random component jobs are running in parallel
  • This PR also touches a few areas outside tests/system/Commands because the failures were not purely local to one test class:

  • system/Commands/Database/ShowTableInfo.php now keeps db:table --show display IDs sequential even when table arrays have sparse keys

  • system/HotReloader/DirectoryHasher.php now hashes files in a stable order, which avoids filesystem traversal order differences

  • system/Cache/FactoriesCache/FileVarExportHandler.php now guards cache writes against concurrent cleanup/recreation races

  • tests/system/HotReloader/DirectoryHasherTest.php now uses isolated writable fixtures instead of shared app/system directories

  • system/Log/Handlers/FileHandler.php now treats the final chmod after creating a log file as best-effort, so concurrent log cleanup cannot turn logging into a test/app error
  • Verified locally:

  • repeated random-order Commands runs, including failed CI seeds

  • HotReloader, Cookie random-order runs

  • composer phpstan:check

  • vendor/bin/rector process --dry-run

  • composer cs
  • Checklist:

  • Securely signed commits

  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)

  • Unit testing, with >80% coverage

  • User guide updated

  • Conforms to style guide
  • Diff: 316 lines (+237 / -79) across 3 files Reviewer: neznaika0 Review duration: 6885m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 316 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.345
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #10169"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.0% · Safe to merge
    16.0%