Skip to content

Comments

fix(cli): skip policy evaluation during attestation init status display#2762

Closed
migmartri wants to merge 6 commits intochainloop-dev:mainfrom
migmartri:migmartri/attestation-policies
Closed

fix(cli): skip policy evaluation during attestation init status display#2762
migmartri wants to merge 6 commits intochainloop-dev:mainfrom
migmartri:migmartri/attestation-policies

Conversation

@migmartri
Copy link
Member

@migmartri migmartri commented Feb 19, 2026

Both attestation init and attestation push call AttestationStatus.Run() internally for display purposes. Previously, each of these calls triggered a full policy re-evaluation which was either unnecessary (init evaluating against an empty attestation) or redundant (push evaluating twice).

This change passes WithSkipPolicyEvaluation() to these internal status calls so they skip re-evaluation. Existing policy evaluations stored in the crafting state are always included in the result regardless of this flag. In the push flow, the status result is explicitly populated with policy evaluations after the push performs its own evaluation.

Fixes #2761

The init command calls attestation status immediately after initialization
to show the current state. This was triggering policy evaluation against an
empty attestation statement, which is unnecessary and confusing.

Fixes chainloop-dev#2761

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
…and push

The init command calls attestation status after initialization to display
state. This triggered policy evaluation against an empty attestation, which
is unnecessary. The push command also called status for display purposes and
then evaluated policies again separately with the final statement, causing
duplicate evaluations.

Pass WithSkipPolicyEvaluation() to both internal status calls since the
mechanism already existed but wasn't being used.

Fixes chainloop-dev#2761

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
The status call in push was skipping policy evaluation (to avoid
duplicate work), but this also skipped reading existing evaluations
from the crafting state.

Move GetPolicyEvaluations outside the skip block so status always
reads existing evaluations, and populate the status result in push
after the actual policy evaluation completes.

Fixes chainloop-dev#2761

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
All callers are within the action package, no need to export it.

Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
return nil, fmt.Errorf("creating status action: %w", err)
}
attestationStatus, err := statusAction.Run(ctx, attestationID)
attestationStatus, err := statusAction.Run(ctx, attestationID, WithSkipPolicyEvaluation())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code, it might not make sense to call StatusAction at this point, but doing it after it has been rendered and all evaluations have been done.

}

res, err := statusAction.Run(cmd.Context(), attestationID)
res, err := statusAction.Run(cmd.Context(), attestationID, action.WithSkipPolicyEvaluation())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we may be losing relevant evaluations (git commit signature, crafter checks, gather info, PR metadata, etc)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I am going to stop this PR and instead work on a lifecycle management per-policy.

Thanks

@migmartri
Copy link
Member Author

replaced by #2765

@migmartri migmartri closed this Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: skip policy evaluation when status is called from attestation init

3 participants