Skip to content

feat(contracts): add managed flag#3108

Open
migmartri wants to merge 1 commit into
chainloop-dev:mainfrom
migmartri:feat/managed-contracts
Open

feat(contracts): add managed flag#3108
migmartri wants to merge 1 commit into
chainloop-dev:mainfrom
migmartri:feat/managed-contracts

Conversation

@migmartri
Copy link
Copy Markdown
Member

Summary

Adds a managed boolean to workflow contracts to mark resources provisioned and operated by Chainloop. Managed contracts cannot be updated or deleted by users.

Mirrors the same flag added for CAS backends in #3092:

  • New managed field on the workflow_contracts Ent schema (default false)
  • Managed exposed on biz.WorkflowContract; ContractCreateOpts accepts Managed *bool for internal callers
  • Update and Delete use cases return a validation error when the contract is managed
  • Surfaced read-only as is_managed on WorkflowContractItem in the API

Disclosure

Assisted by Claude Code.

Adds a managed boolean to workflow contracts to mark resources
provisioned and operated by Chainloop. Managed contracts cannot
be updated or deleted by users. Mirrors the same flag added for
CAS backends in chainloop-dev#3092.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 19 files

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/biz/workflowcontract.go">

<violation number="1" location="app/controlplane/pkg/biz/workflowcontract.go:416">
P2: Add tests for the new managed-contract guards in Update and Delete. These are new authorization/validation branches and currently have no matching test coverage.

(Based on your team's feedback about adding or updating tests for new paths.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

}

// Managed contracts are owned and operated by Chainloop and cannot be modified by users.
if wfContractPreUpdate.Managed {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot May 12, 2026

Choose a reason for hiding this comment

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

P2: Add tests for the new managed-contract guards in Update and Delete. These are new authorization/validation branches and currently have no matching test coverage.

(Based on your team's feedback about adding or updating tests for new paths.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At app/controlplane/pkg/biz/workflowcontract.go, line 416:

<comment>Add tests for the new managed-contract guards in Update and Delete. These are new authorization/validation branches and currently have no matching test coverage.

(Based on your team's feedback about adding or updating tests for new paths.) </comment>

<file context>
@@ -408,6 +412,11 @@ func (uc *WorkflowContractUseCase) Update(ctx context.Context, orgID, name strin
 	}
 
+	// Managed contracts are owned and operated by Chainloop and cannot be modified by users.
+	if wfContractPreUpdate.Managed {
+		return nil, NewErrValidationStr("managed contracts cannot be modified")
+	}
</file context>
Fix with Cubic

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.

1 participant