← Back to Pull requests

feat(remediation): the scheduling service reports effort states #400

Closed
unknown closed this pull request without merging on Nov 08, 2026 21:23 UTC
View on GitHub
unknown unknown commented on Nov 08, 2026 04:05 UTC
Author

What

The remediation domain's state-report surface, in the scheduling service — the reads the
engine's trigger plans off. Shaun's design direction (2026-11-08, traust-foundry#11 wave
(g), commit 9c14af7):

src/traust_engine/ops/remediation.py is an anti-pattern — it mixes domain concepts

into the engine. The engine stays a generic planning loop; the remediation domain (the

Remediations protocol, the trigger's status mappings, the work-item vocabulary)

belongs in core's domain surface or a domain layer the engine consumes.

engine#146/#147 landed that anti-pattern knowingly (the trigger needed the reads); this
PR is core's half of the extraction — the engine's half deletes its re-statement and
consumes this surface directly (stacked on this branch's pin).

  • RemediationState (beside ScheduledEffort, models/remediation_scheduling.py):

  • the slim projection a planner needs — the work-item handle (the assessment, so feed
    events name it directly, contracts#117), the repository, the folded status, and the
    lineage's over attempts as reattempts. A consumer needing fork facts or the work
    item's detail reads the effort itself.
  • RemediationSchedulingService.state_of / states_of: the keyed read and the

  • repository listing, over the fold the service already reads (_efforts →
    work_item_orders → the work items). The lineage semantics moved from the engine's
    CLI adapter verbatim: one report per finding-set lineage, its head reporting with the
    lineage's over attempts as reattempts (an over attempt is retried as a NEW work item
    over the same findings); an over attempt a newer one over the same findings supersedes
    is not reported; a still-vulnerable effort a newer one supersedes reads as no effort,
    so a replayed feed event cannot bypass the reattempt limit.
  • The trigger's rule vocabulary (remediation: / verify-remediation: prefixes,

  • with is_remediation_rule) beside REMEDIATE_FINDING in models/operations.py —
    where core names the door's order vocabulary today; the rules ride the same orders.

    This resolves the two standing escalations from engine#146/#147's reviews in one move:

    1. The reattempts derivation — "core's to offer": the derivation now lives here,
    over the orders and work items the service already reads, instead of the engine's
    adapter folding lineages client-side (where reattempts read 0 from the keyed get
    and the limit never bound).
    2. The by-assessment read's shape — "core's read decides": the keyed read misses
    softly (None), so a feed-driven consumer replaying events that name unscheduled
    assessments suppresses no 404 of its own.

    The keyed read stays on get except for the one status a reattempt limit gates on: a
    still-vulnerable effort resolves through its repository's lineages so its priors and any
    superseding effort are read with it; every other status carries no count the limit asks
    for.

    Changed tests

    New service tests over SQLite (+ the Postgres integration backend where available):
    the keyed read's mapping and soft miss, the lineage fold (head with priors, superseded
    prior unreported, overlapping-but-different findings as another lineage, a live effort
    never displaced), the superseded still-vulnerable effort reading as no effort with the
    retry reporting its priors, and the repository isolation. The engine's adapter tests
    (engine#147's FakeScheduling/_CoreRemediations suite) move here as these — over the
    real doors instead of fakes.

    make lint-fix && make test: green — 11661 passed. (Three
    tests/v1/context/test_services.py tests fail on this workstation's default HOME
    from a stale local ~/.traust/traust.db predating the fork columns; they fail
    identically on untouched development and pass with a clean HOME, so they are
    environmental, not this change.)

    stacked-PR: the engine half pins this branch's head and deletes its re-statement

    💘 Generated with Crush

    Assisted-by: Crush:rits/zai-org/glm-5-3

    Diff: 499 lines (+374 / -125) across 6 files Reviewer: chubirka Review duration: 1038m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.47) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 499 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%
    56%
    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.372
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #400"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 20.5% · Safe to merge
    20.5%