feat(contract): support "at least one of" material choke groups#3235
Conversation
matiasinsaurralde
left a comment
There was a problem hiding this comment.
LGTM - A test failed though
AI Session Analysis
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | pkg/attestation/crafter/api/attestation/v1/crafting_state_validations_test.go |
+123 / -1 |
| modified | ai | app/controlplane/pkg/unmarshal/unmarshal_test.go |
+95 / -1 |
| modified | ai | app/cli/pkg/action/attestation_status_test.go |
+40 / -1 |
| modified | ai | pkg/attestation/crafter/api/attestation/v1/crafting_state_validations.go |
+36 / -2 |
| created | ai | docs/examples/contracts/material-groups/contract.yaml |
+27 / -0 |
| modified | ai | app/controlplane/pkg/unmarshal/unmarshal.go |
+8 / -3 |
| modified | ai | app/cli/pkg/action/attestation_status.go |
+7 / -1 |
| modified | ai | app/controlplane/api/workflowcontract/v1/crafting_schema.proto |
+8 / -0 |
| modified | ai | app/cli/cmd/attestation_add.go |
+4 / -0 |
| modified | ai | app/controlplane/pkg/biz/testdata/contracts/invalid_contract.yaml |
+3 / -1 |
| modified | ai | app/cli/cmd/attestation_status.go |
+3 / -0 |
Policies (4, 1 failing)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-ec69dd |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-ec69dd |
- |
ai-config-no-secrets |
ai-coding-session-ec69dd |
|
|
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-ec69dd |
- |
Powered by Chainloop and Chainloop Trace
Add a per-material `group` field to workflow contracts. Materials sharing the same non-empty group value form a choke group: at least one member must be present in the attestation, otherwise it cannot be pushed. Materials without a group keep their existing required/optional behavior. Enforcement happens at attestation completion with a clear error listing the group and its members. The CLI surfaces the group in `attestation status` and `attestation add`. Contract parsing now ignores unknown fields so contracts authored with fields from newer releases do not break older clients. Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev> Chainloop-Trace-Sessions: ec69dde4-acef-48c8-b319-76774e77c877
fbe6ab8 to
891c1c9
Compare
…nknown field With unknown-field tolerance (DiscardUnknown) in contract parsing, a contract whose only problem was an unknown field is now valid. Update the invalid YAML fixture to fail validation for a real reason (invalid material name) so TestIdentifyAndValidateRawContract keeps asserting a validation error. Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev> Chainloop-Trace-Sessions: ec69dde4-acef-48c8-b319-76774e77c877
|
Can we visualize this differently? As in gruping them, etc? |
|
+1 to try to show them in a different way like a box surrounding them or something. Not a blocker though but nice to have |
Do you mean in the CLI output? I'll check what we can do. |
|
Yes it's only the CLI output, at least on my side |
same here |
Group attestation materials together in "attestation status" under a header that states the "at least one of" rule and whether the group is satisfied, with members indented beneath it, instead of repeating the requirement on each material as if they were independent. Apply the same group/rule wording to "attestation add". Assisted-by: Claude Code Signed-off-by: Jose I. Paris <jiparis@chainloop.dev> Chainloop-Trace-Sessions: ec69dde4-acef-48c8-b319-76774e77c877
|
done, I've updated the description |
Add new
groupfield to contract materials to denote oneOf behaviour and validationUngrouped materials (group == ""): unchanged — required unless optional.
Grouped materials: partition by group value. For each group, at least one member
must be present in the crafted materials; otherwise the group is reported missing
(e.g. at least one material from group "sbom-source" is required: cyclonedx-sbom, spdx-sbom).
A member’s individual optional flag is ignored for grouped materials (the group rule governs).
Closes #3234
Example:
AI assistance: this contribution was produced with assistance from Claude Code (disclosed via the Assisted-by trailer on the commits).