← Back to Pull requests

perf: the claim's mirror affinity and the batch assessment/ref/summary routes (wave f, F3-F5) #433

Closed
unknown closed this pull request without merging on Nov 13, 2026 12:44 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 18:37 UTC
Author

What

Wave (f) of the performance lane (traust-foundry#56), the core half of the audit's F3-F5:

F3 — the claim answers the mirror-affinity question itself. The engine's claim runners decided what to lease by reading every open order each poll and filtering client-side — at production's 7,300 open orders, ~10⁸ row-materializations a day against core. claim gains mirror_affinity (the REST request carries the flag): the next-order selection skips a queued order whose repository another worker's live lease holds (its node already fetched the repository's mirror; the queued orders wait for the holder) and one whose (asset, repository) pair an open order still gates (planned or awaiting approval). A leased sibling is no gate — the holder's own lease never blocks it. A named order_id is claimed as asked. Each exclusion is a shape its own index serves, so the claim stays a single-digit-millisecond index walk.

F4/F5 — the batch assessment, ref and summary routes. The SCI listings' core observations fanned out per repository (the latest-scan assessment and the ref SHA behind each inventory row, and the per-repository findings census) — 3+ REST calls per row at estate scale. The service layer already owned the batched reads (list_for_repositories, list_refs_of); three routes expose them in the batch findings family's own shape (a named repository set, a page's worth per call, no set a refusal):

  • GET /v1/assessments/in — several repositories' assessments, oldest first, one kind optional

  • GET /v1/refs/in — every recorded ref of the set, in bounded batches

  • GET /v1/findings/summaries — the set's findings counted by state per repository (summary_in: the per-repository summary's own rule — never-reported findings count nowhere — folded one bounded batch of whole repositories at a time)
  • Stacks under: the SDK regen (perf/wave-f-batch-client) and the engine/SCI consumers.

    Measured

  • make lint-fix, make test: 13,774 passed; make test-integration: 4,012 passed (SQLite and PostgreSQL).

  • make perf: the affinity claim walks idx_ops_run_order_claim at 0.61 ms (the unflagged claim: 0.21 ms). Two pre-existing perf flakes fail identically on development (test_an_assets_open_orders_by_index[page], and test_spend_by_repository_joins_the_month_to_its_orders_by_key intermittently) — timing-budget misses on the shared perf database under a loaded machine, not touched by this change.
  • Tests

    Changed tests (flagged per the standing rule):

  • Claim (F3): seven cases in test_operations.py — a held repository skipped for a later free order, the holder's own next order taken, the head claimed when nothing is held, the unflagged claim unchanged, a gated pair waiting, a named order claimed despite the flag, fleet-wide orders never held, and a fleet-wide order taken past the worker's own leased sibling (the shape the engine's feed flow rides). The perf case for the affinity query's index.

  • Batch routes (F4/F5): the routes' in-process identity, one-kind cut, refusal bounds and token requirement; summary_in's identity with each repository's own summary, its no-row-for-no-findings rule, and its grouping across the fold's batch boundary.
  • Dev validation

    Blocked at open time: the dev-20261104 cluster's credentials have expired (the refresh needs an interactive oc login --web) and the cluster's *.apps wildcard DNS currently answers NXDOMAIN while the API endpoint resolves — the environment needs its owner's attention before the wave-f receipts can run. The integration suites above pin the same identities and call shapes; the dev pass (byte-identical bodies before/after, the one-batched-call shapes in core's access log) is the follow-up once the environment is reachable, before merge.

    Foundry: traust-foundry#56 (wave f, F3 + F4/F5).

    💘 Generated with Crush

    Diff: 484 lines (+363 / -121) across 6 files Reviewer: chubirka Review duration: 1086m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 484 lines diff across 6 files
    0.47
    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.370
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #433"
    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: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    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: 18.7% · Safe to merge
    18.7%