fix(cli): surface policy-group materials during attestation#3223
Conversation
Materials declared by a policy group attached to a contract were not shown during attestation for V2 contracts. Enrichment only mutated the V1 schema, but the crafter stores the V2 schema when present, discarding the enriched V1. Enrich the schema that the crafter actually stores (V2 when present, V1 otherwise) so policy-group materials appear in `attestation status`/`add` and are validated. When the same material is declared in both the contract and a policy group, it is now merged silently when the definitions are compatible, warning only on a genuine type conflict. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: db6acef0-3453-4c3f-ae8d-803dd2a677e7
AI Session Analysis
|
| Status | Attribution | File | Lines |
|---|---|---|---|
| modified | ai | app/cli/pkg/action/attestation_init.go |
+91 / -39 |
| modified | ai | app/cli/pkg/action/attestation_init_test.go |
+78 / -1 |
Policies (4)
| Status | Policy | Material | Messages |
|---|---|---|---|
| ✅ Passed | ai-config-ai-agents-allowed |
ai-coding-session-db6ace |
- |
| ✅ Passed | ai-config-no-dangerous-commands |
ai-coding-session-db6ace |
- |
| ✅ Passed | ai-config-no-secrets |
ai-coding-session-db6ace |
- |
| ✅ Passed | ai-config-mcp-servers-allowed |
ai-coding-session-db6ace |
- |
Powered by Chainloop and Chainloop Trace
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Move policy-group material enrichment back ahead of the control-plane Init call so a policy-group load failure fails fast, before a workflow run is created, avoiding orphaned/partially initialized attestations. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev> Chainloop-Trace-Sessions: db6acef0-3453-4c3f-ae8d-803dd2a677e7
|
Valid catch (identified by cubic). The previous ordering ran the V1 enrichment before the control-plane Fixed in a76ce6b's follow-up: enrichment now runs before 🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri |
Summary
Fixes #3222.
Materials declared by a policy group attached to a contract were not surfaced during attestation for V2 contracts. The CLI enriched the contract's expected-materials list only on the V1 schema, but the crafter stores the V2 schema when it is present, so the enriched V1 was discarded and the policy-group materials never appeared in
attestation status/add(nor were they validated as expected).This change enriches the schema that the crafter actually stores — the V2 schema when present, V1 otherwise — so policy-group materials are merged into the expected-materials list alongside the contract's own materials.
It also clarifies the duplicate-material handling: when the same material is declared in both the contract and an attached policy group, the definitions are now merged silently when compatible, and a clearer warning is emitted only when the material types genuinely conflict.
Tested locally, below is an example of a material called sbom that comes from the policy group
in previous versions of the CLI the material was not present nor enforced
AI disclosure
This change was produced with the assistance of Claude Code. Affected commits carry an
Assisted-by: Claude Codetrailer.🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri