feat(remediation): the machine-principal progress door #416
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.289
Real PR Conversation Timeline
1 comments
"Review active on #416"
general
weight: 0.35
gurnben
What
Merged and abandoned had no REST write path. The ask-B design proposed machine-principal doors for
record_progress; what landed was the person-only PR door (POST /v1/remediations/{work_item_id}/pull-request→record_pull_request, verified humans only,pr_openedonly).record_progressitself — merged/abandoned, where a PR-filing loop's tracking ends an attempt — had no route, so SCI's auto-filing loop (a machine, outside any order lease) could never drain its pending outbox for the terminal statuses. This adds the machine-principal half of that door:rest/remediation/remediations.py):POST /v1/remediations/{work_item_id}/progress, body the new core modelProgressReport(status: merged | abandoned, optionalmerge_sha, optionalactor), responding with the movedWorkItem— the same shape as the sibling PR door.OpsService.authorize_write, new besideauthorize_request): a verified person, or a verified machine inside arecording.startgrant namingremediate_findingon the work item's repository — the same grant/allowlist the scheduling door and the record doors key on (_may_request, one rule now with two doors). Unverified, ungranted, and out-of-scope machines are refused (403); filing happens outside order leases, so no lease is bound.RemediationService.record_outcome): locks the item's findings, thenrecord_progress(which now accepts arationale) moves the fold — one decision per finding,merged/abandonedas its reason, the merge SHA and actor as its rationale, resolution stillopen(remediation progress never establishes that a finding is fixed). Replays are no-ops (statement-key idempotency); a status the forward-only state machine refuses answers 409; a retry after an ended attempt is a new work item, as before.ProgressReportrefuses a run's own statuses (patched,forked, … — those come from the report) and amerge_shathat is not a full git SHA or that rides anabandonedreport.SCI's consumption is the follow-up, deliberately not here: once this merges, traust-sdk regenerates from the OpenAPI and SCI's filing loop drains its pending outbox through the door (
RecordPRMerged/RecordPRClosedininternal/filing/recorder.go, todayUnavailableRecorder). Noted in the companion SCI PR (source-code-intelligencedocs/remediation-retirement-slice).Checklist
developmentOpsService.authorize_writeextends the existing grant owner)rationale; a dedicated column is a contracts question, not worked around silentlyObjectStore; no in-memory stand-ins insrc/authorize_writeshares_may_requestwithauthorize_requestrather than restating the grant rule)uow/seedsrc/); shared logic is one helpermake lint-fix && make testgreen (12,766 passed / 2 skipped at both heads; pre-push lint+coverage gate passed on each push)Changed tests
New coverage only, no existing test changed:
ProgressReportmodel tests (terminal-status-only, sha/actor validation, rationale) intests/v1/models/test_remediation.py; the door's authorization matrix (person, unverified, machine-without-grant, machine-granted-on-another-repository, machine-with-grant) and the merged-with-sha / abandoned transitions with the decision fold and replay idempotency intests/v1/services/test_remediation.py; the same matrix plus body validation (422s), 404/409 answers and the reads' fold (GET /v1/remediations/{id}, listing atstatus=merged) over a real HTTP client intests/v1/rest/remediation/test_remediations.py.Qodo corrections —
1eadc537furthest()over the decisions' reasons, so a terminal status is never displaced by a run's own (mergedranks above every run status);_reported_itemrefuses a terminal item whenever it reads after the outcome; and in the read-before-outcome window a late-attaching report leaves an ended attempt showing its full life (report + terminal status), which is the domain's answer, not an inconsistency. The same interleaving already exists with the person-only PR door; re-locking the run path is out of scope for this slice._reported_itemrefuses), so a run whose attempt ended records its refusal and completes — the identical behavior the in-processrecord_progress(CLI) path has always had. Retiring a queued or leased order from a data door is a scheduling/ops concern with its own races, deliberately not smuggled into this door.record_resolution's own contract: "Restating the same step changes nothing"): the first accepted report's rationale (merge SHA, forge actor) is what persists; a richer later delivery is a no-op, exactly like every other decision restatement. Requiring the SHA up front would break the door's optional body; enrichment would fight append-only decisions. SCI's loop reports merged carrying the SHA it polled.Decision.actoron the ending decisions fails the contracts ruleCHECK (assessment_id IS NULL OR actor IS NULL): a decision is either a person's statement (actor, no assessment) or an attempt's (assessment, no actor) — the attempt is the author of its own statuses, by design. Reverted; the tests now state that rule where they read the ending decisions (1eadc537). The caller is not lost: the door's authorization names them and the REST access log carries the caller on every request; the forge actor rides the rationale as an explicit claim.Review fixes —
a1e3154f,cef97c51(the changes-requested findings):ProgressReport.actoris capped at intake at the verification rationale's bound (ACTOR_CAP = 500, refused with the door's usual 422 for a bad body), and the caller is gated before the work item is read —OpsService.authorize_recorder: a verified person, or a machine holding aremediate_findinggrant somewhere, so an ungranted machine hears a uniform 403 and learns nothing about existence; the repository scope still follows the read, since it lives on the item. Regression tests at the model, service and REST levels.Verification:
make lint-fixandmake testgreen atcef97c51(12,768 passed / 2 skipped; coverage 95.2%); CI green on all four commits (lint, test 3.11/3.12, postgres, api-check, ratchet). Qodo re-review atcef97c51raises the same four findings — answered in the Qodo corrections section above — plus one new against the review fixes (a granted machine's residual 404-vs-403 across repositories), refuted in the thread: the repository scope cannot precede the read it depends on, and what it would distinguish is fully enumerable by any verified caller throughGET /v1/remediations.💘 Generated with Crush