feat(attestation): add --mark-latest flag to attestation init#3151
feat(attestation): add --mark-latest flag to attestation init#3151javirln wants to merge 3 commits into
Conversation
Add tri-state --mark-latest flag to control whether a project version is promoted to latest during attestation initialization. Omitting the flag preserves current behavior, --mark-latest=true forces promotion of existing pre-release versions, and --mark-latest=false skips promotion entirely. Also adds MarkAsLatest biz/data method for the platform repo to build the standalone "project version mark-latest" command on top of. Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: c9c4aac1-2015-43c3-bf26-47621b425735
AI Session Analysis
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | app/controlplane/pkg/biz/workflowrun_integration_test.go |
+359 / -0 |
| modified | ai | app/controlplane/pkg/biz/projectversion_integration_test.go |
+86 / -1 |
| modified | ai | app/controlplane/pkg/data/projectversion.go |
+54 / -9 |
| modified | ai | app/controlplane/pkg/data/workflowrun.go |
+22 / -3 |
| modified | ai | app/controlplane/pkg/biz/projectversion.go |
+22 / -0 |
| modified | ai | app/cli/cmd/attestation_init.go |
+13 / -1 |
| modified | ai | app/controlplane/pkg/biz/workflowrun.go |
+7 / -0 |
| modified | ai | app/controlplane/api/controlplane/v1/workflow_run.proto |
+6 / -0 |
| modified | ai | app/cli/pkg/action/attestation_init.go |
+3 / -1 |
| modified | ai | app/controlplane/pkg/data/workflow.go |
+1 / -1 |
| modified | ai | app/controlplane/api/controlplane/v1/response_messages.proto |
+1 / -0 |
| modified | ai | app/controlplane/internal/service/attestation.go |
+1 / -0 |
| modified | ai | app/controlplane/internal/service/workflowrun.go |
+1 / -0 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-c9c4aa |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-c9c4aa |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-c9c4aa |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-c9c4aa |
- |
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
1 issue found across 21 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…romotion The pre-transaction version lookup could be stale if a concurrent request released the version between the lookup and the transaction start. Re-read the version inside the transaction to ensure the prerelease check uses current data. Assisted-by: Claude Code Signed-off-by: Javier Rodriguez <javier@chainloop.dev> Chainloop-Trace-Sessions: c9c4aac1-2015-43c3-bf26-47621b425735
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/controlplane/pkg/data/workflowrun.go">
<violation number="1" location="app/controlplane/pkg/data/workflowrun.go:102">
P2: The new prerelease check is still race-prone because the version row is read without a lock before promotion. A concurrent update can release the version after this check and still be promoted to latest.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| versionCreated = true | ||
| } else if opts.MarkAsLatest != nil && *opts.MarkAsLatest { | ||
| // Re-read version inside the transaction to avoid promoting a concurrently released version | ||
| fresh, err := tx.ProjectVersion.Query(). |
There was a problem hiding this comment.
P2: The new prerelease check is still race-prone because the version row is read without a lock before promotion. A concurrent update can release the version after this check and still be promoted to latest.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/controlplane/pkg/data/workflowrun.go, line 102:
<comment>The new prerelease check is still race-prone because the version row is read without a lock before promotion. A concurrent update can release the version after this check and still be promoted to latest.</comment>
<file context>
@@ -98,11 +98,22 @@ func (r *WorkflowRunRepo) Create(ctx context.Context, opts *biz.WorkflowRunRepoC
} else if opts.MarkAsLatest != nil && *opts.MarkAsLatest {
- if !version.Prerelease {
+ // Re-read version inside the transaction to avoid promoting a concurrently released version
+ fresh, err := tx.ProjectVersion.Query().
+ Where(projectversion.ID(version.ID), projectversion.ProjectID(wf.ProjectID), projectversion.DeletedAtIsNil()).
+ Only(ctx)
</file context>
| fresh, err := tx.ProjectVersion.Query(). | |
| fresh, err := tx.ProjectVersion.Query().ForUpdate(). |
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
Summary
--mark-latestflag toattestation initto control whether a project version is promoted to latest (omitted = default behavior,true= force promote,false= skip promotion)MarkAsLatestbiz/data method for the platform repo to build the standaloneproject version mark-latestcommand on top oflatestfield on theProjectVersionproto response messagepromoteVersionToLatestWithTxhelper to avoid duplication between standalone promotion and workflow run creation pathsTest plan
--latest-version,require-existing-versioncombinations