Report recorded decision evidence and harden the Pi artifacts env
Refinements on top of the human decision stage (a6aff47):
- `pipelines decide` now reports the feedback the server actually stored for
the chosen option, so a repeated (idempotent) decision shows the recorded
evidence instead of the ignored request text. A repeated decision is covered
by a new assertion that also checks the step output does not change.
- The decision option/feedback output keys are defined once in protocol
(DecisionOptionKey/DecisionFeedbackKey) with a DecisionEvidence reader, and
the store and CLI use them instead of bare string literals.
- piEnvironment drops any inherited PIPELINES_ARTIFACTS_DIR before spawning Pi,
so the artifactsDir argument is authoritative and an ambient directory (for
example Pipelines' own when a stage runs inside another stage) never leaks
into a child that was given none. Covered by a test with an ambient value set.
This commit is contained in:
+13
-1
@@ -146,6 +146,18 @@ func envOr(key, value string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
// recordedFeedback returns the feedback the server actually stored for the
|
||||
// decided step that carries the chosen option, so a repeated (idempotent)
|
||||
// decision reports the recorded evidence rather than the ignored request text.
|
||||
func recordedFeedback(detail *protocol.RunDetail, option string) string {
|
||||
for i := len(detail.Steps) - 1; i >= 0; i-- {
|
||||
if chosen, feedback := protocol.DecisionEvidence(detail.Steps[i].Output); chosen == option {
|
||||
return strings.TrimSpace(feedback)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// parse allows flags before or after positional arguments without reinterpreting values.
|
||||
func parse(f *flag.FlagSet, args []string) error {
|
||||
var flags, positionals []string
|
||||
@@ -809,7 +821,7 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
return a.output(r.RunDetail)
|
||||
}
|
||||
line := fmt.Sprintf("Decided run #%d: %s · %s", r.RunDetail.ID, option, r.RunDetail.Status)
|
||||
if feedback := strings.TrimSpace(o.feedback); feedback != "" {
|
||||
if feedback := recordedFeedback(r.RunDetail, option); feedback != "" {
|
||||
line += " · feedback: " + feedback
|
||||
}
|
||||
_, err = fmt.Fprintln(a.Out, line)
|
||||
|
||||
Reference in New Issue
Block a user