The gate now writes its offer to the task's review_gate document before it waits -- the scored findings, the head SHA, the pull request's identity and the resuming workflow -- because the engine cannot resume a run partway, so a resumed pipeline recomputes its findings and only the recorded document is the review the operator saw (docs/prds/pr-review-operator-response.md, "The review the operator answers"). The document lives with the task column it encodes (internal/domain/ workflow/task), the way EncodeInputs does, and carries each finding as opaque JSON beside the key an operator's selection names. That is what lets the dashboard render and answer a gate without linking the workflow engine -- cmd/archie-ui/architecture_test.go measures the linked binary, and an operator-domain service importing the finding's own type linked prreview into archie-ui. prreview owns the key derivation and the finding's encoding, and the MaxRereviewRounds constant lives in the task vocabulary beside the action names it answers with. Intake restores the document into the run: a re-review's instructions ride one labelled block in runLens's and runReviewer's missions only, and an approve's recorded review is posted by phase 9 filtered by the operator's selection, with the recomputed findings kept out of the output. The gate does not wait again on an answered approve. taskstate gains the rereview action the vocabulary needs -- offered for waiting_human beside approve and reject, routed to queued -- whose surfaces follow in the response channel.
55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
package prreview
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
|
|
)
|
|
|
|
// Key is a scored finding's stable identity inside one gate document: file,
|
|
// line and title. Findings carry no ID, so this is what an operator's
|
|
// selection names and what filtering matches on. The document stores the key
|
|
// beside the finding (task.ReviewGateFinding), because the operator surface
|
|
// never sees this type.
|
|
func (f ScoredFinding) Key() string {
|
|
return fmt.Sprintf("%s:%d:%s", f.File, f.LineStart, f.Title)
|
|
}
|
|
|
|
// GateFinding renders f as a document finding: the key an operator's
|
|
// selection names, beside the finding's own encoding.
|
|
func GateFinding(f ScoredFinding) task.ReviewGateFinding {
|
|
data, err := json.Marshal(f)
|
|
if err != nil {
|
|
// ScoredFinding holds only strings, numbers, bools and slices; a
|
|
// marshal failure would be a programming error.
|
|
return task.ReviewGateFinding{Key: f.Key()}
|
|
}
|
|
return task.ReviewGateFinding{Key: f.Key(), Finding: data}
|
|
}
|
|
|
|
// GateFindings renders a whole scored review for the document.
|
|
func GateFindings(findings []ScoredFinding) []task.ReviewGateFinding {
|
|
out := make([]task.ReviewGateFinding, len(findings))
|
|
for i, f := range findings {
|
|
out[i] = GateFinding(f)
|
|
}
|
|
return out
|
|
}
|
|
|
|
// PostedFindings decodes the findings an approve posts back into the review
|
|
// type. An entry whose finding does not decode is skipped rather than failing
|
|
// the post: the document's keys were produced by this package, so a
|
|
// decode failure means the row was not written by this code.
|
|
func PostedFindings(entries []task.ReviewGateFinding) []ScoredFinding {
|
|
out := make([]ScoredFinding, 0, len(entries))
|
|
for _, entry := range entries {
|
|
var f ScoredFinding
|
|
if err := json.Unmarshal(entry.Finding, &f); err != nil {
|
|
continue
|
|
}
|
|
out = append(out, f)
|
|
}
|
|
return out
|
|
}
|