spec: issue-3644 convert a contract between organization level and project level

Merged
JI
1mo ago
+201-0

Summary

This spec lets an organization admin convert an existing workflow contract between organization level and project level, in both directions. The contract keeps its ID, name, revision history, and workflows. Today the only way to change the level is to delete the contract and create it again, and that loses the history and the workflow links.

The CLI gets two flags on chainloop wf contract update, and a user can give only one of them: --project <name> and --org. The update API gets an optional level field. When the field is not set, the level does not change.

Key points for review:

  • Only callers that can manage organization-level contracts today can convert: organization owners and admins, and organization-level API tokens (D-004).
  • The system rejects an organization-to-project conversion when workflows of other projects use the contract, and the error names them (D-005).
  • A level change does not create a contract revision (D-006).
  • The workflow update command gets the same project check as the workflow create command, so no workflow can use a contract of a different project (R-010, D-007). Conversions and workflow changes lock the contract to prevent a race (D-008).
  • Out of scope: a move from one project to a different project, chainloop apply, and the web UI.

Open questions for reviewers

None.

We would like two reviewers to approve this spec before it merges.

Refs #3644

AI disclosure: Claude Code assisted with the drafting of this spec.