Skip to content

feat: attestation progress events, M2 custom events (#3825) - #3865

Merged
migmartri merged 4 commits into
mainfrom
issue-3825-m2-attestation-progress-events
Dec 1, 2026
Merged

migmartri merged 4 commits into
mainfrom
issue-3825-m2-attestation-progress-events

Conversation

@migmartri

@migmartri migmartri commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Implements milestone M2 ("Custom events") of the attestation progress events spec. Refs #3825. Builds on M1 (#3859).

What it adds

  • Custom event type (R-012). WorkflowRunEvent.Type gets TYPE_CUSTOM. RecordEvent accepts it with no attributes. A custom key uses the format of annotation names (letters, digits, _ and -), up to 64 characters. It cannot hold a dot, so it never matches an automatic chainloop. key. Custom events do not change the material progress.
  • chainloop attestation event --name <key> --status <started|succeeded|failed|canceled> [--message <text>]. It records a custom step on the run of the attestation in progress, from the local state or with --attestation-id. With remote state, the attestation ID is the run ID, so the command sends one call and does not download the state. Each failure shows a warning, and the command exits with success: no attestation in progress, a rejected key, an older control plane, and also a missing --name, an unexpected positional argument, or a wrong --status. A dry run records nothing.
  • chainloop workflow run describe. The timeline shows each custom step as a line, with the status of its last event. A finished step shows its duration, and a step that still runs on a run in progress shows how long it runs. The events of a repeated step fold below it, as for materials.
├─ 10:01:02  ✓ step `sast-scan`       took 2m3s
│  ├─ 10:01:02  ● Semgrep, ruleset p/ci
│  └─ 10:03:05  ✓ succeeded
├─ 10:03:22  ✗ step `unit-tests`      3 tests failed
├─ 10:05:02  ● step `approval`        running for 43s

Examples

The output below comes from the command and the timeline renderer in this PR, against a test control plane.

1. Record steps in the pipeline

Record a step between attestation init and attestation push. Events with the same --name are one step of the timeline.

$ chainloop attestation event --name sast-scan --status started --message "Semgrep, ruleset p/ci"
INF event recorded
$ semgrep scan --config p/ci --sarif -o scan.sarif
$ chainloop attestation event --name sast-scan --status succeeded
INF event recorded
$ chainloop attestation add --name sast-report --value scan.sarif

A failed step, and a step that waits on something outside the job:

$ chainloop attestation event --name unit-tests --status started
INF event recorded
$ chainloop attestation event --name unit-tests --status failed --message "3 tests failed"
INF event recorded
$ chainloop attestation event --name approval --status started --message "waiting for release approval"
INF event recorded

In GitHub Actions, wrap a job step, and keep the result of the step:

- name: Unit tests
  run: |
    chainloop attestation event --name unit-tests --status started
    go test ./... && status=succeeded || status=failed
    chainloop attestation event --name unit-tests --status "$status"
    test "$status" = succeeded

With remote state, add --attestation-id "$ATTESTATION_ID", as for the other attestation commands.

2. See the steps while the run is in progress

$ chainloop workflow run describe --id 4f8d2b7e-...
...
Timeline (reported progress) · started 10:00:02 · running for 5m43s · 0 of 1 required provided · attestation policies: 2 passed
├─ 10:00:02  ✓ initialized                   contract build rev 3 · GITHUB_ACTION · local state · policies: 2 passed
├─ 10:01:02  ✓ step `sast-scan`              took 2m3s
│  ├─ 10:01:02  ● Semgrep, ruleset p/ci
│  └─ 10:03:05  ✓ succeeded
├─ 10:03:12  ✓ added evidence `sast-report`  SARIF · scan.sarif · optional · policies: 1 passed
├─ 10:03:22  ✗ step `unit-tests`             took 1m2s
│  ├─ 10:03:22  ● started
│  └─ 10:04:24  ✗ 3 tests failed
├─ 10:05:02  ● step `approval`               running for 43s · waiting for release approval
├─           ○ missing evidence `sbom`       required
└─           ● waiting for push

3. See the steps as history after the push

$ chainloop workflow run describe --id 4f8d2b7e-...
...
Timeline · started 10:00:02 · finished 10:08:22 (8m20s) · stored
├─ 10:00:02  ✓ initialized                   contract build rev 3 · GITHUB_ACTION · local state · policies: 2 passed
├─ 10:01:02  ✓ step `sast-scan`              took 2m3s
│  ├─ 10:01:02  ● Semgrep, ruleset p/ci
│  └─ 10:03:05  ✓ succeeded
├─ 10:03:12  ✓ added evidence `sast-report`  SARIF · scan.sarif · policies: 1 passed
├─ 10:03:22  ✗ step `unit-tests`             took 1m2s
│  ├─ 10:03:22  ● started
│  └─ 10:04:24  ✗ 3 tests failed
├─ 10:05:02  ✓ step `approval`               took 2m0s
│  ├─ 10:05:02  ● waiting for release approval
│  └─ 10:07:02  ✓ succeeded
└─ 10:08:22  ✓ pushed and stored             policies: 3 passed · sha256:4de7a1b2c3d4…

4. A failure never breaks the pipeline

Each failure prints a warning, and the command exits with 0:

$ chainloop attestation event --name sast.scan --status started
WRN the event was not recorded error="rpc error: code = InvalidArgument desc = custom event key \"sast.scan\" must contain only letters, digits, _ and -"
$ echo $?
0
$ chainloop attestation event --name sast-scan --status done
WRN the event was not recorded error="invalid status \"done\", valid options are started, succeeded, failed, canceled"
$ chainloop attestation event --status started
WRN the event was not recorded: --name is required
$ chainloop attestation event --name sast-scan --status started   # no attestation in progress
WRN the event was not recorded error="attestation not yet initialized"

Spec changes

R-012 supersedes R-009: the command takes the step with the --name flag, not a positional argument, as chainloop attestation add --name does. A wrong call, for example a missing --name, is also a warning with exit 0. CLAUDE.md now records the convention: CLI commands identify what they act on with a flag, not a positional argument.

Differences from the plan

  • The key check is in the run events use case (biz/workflowrunevent.go), next to the other event checks, not in the attestation service.
  • The plan's M2 step does not name the timeline renderer of describe. Its "Done when" needs the custom step in describe, so this PR adds it.

AI assistance: this change was implemented with Claude Code.

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri

@chainloop-platform

chainloop-platform Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟢 90% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 90% 1 ✅ 0 99% AI / 1% Human 18 +844 / -29 1h20m9s

🟢 90% — 99% AI — ✅ All policies passing

Dec 1, 2026 11:40 UTC · 1h20m9s · $31.17 · 854 in / 362.0k out · claude-code 2.1.333 (claude-opus-5-5)

View session details ↗

Change Summary

Adds custom attestation events with four statuses, bounded annotation-name keys, and warning-only recording failures. Displays custom steps and durations in run timelines and regenerates command documentation.

AI Session Overall Score

🟢 90% — Focused custom-event implementation has observed behavioral tests and explicit handling of recording failures.

AI Session Analysis Breakdown

🟢 94% · scope-discipline

No notes.

🟢 92% · solution-quality

🟢 The action reuses the M1 recorder and propagates errors to explicit command warnings. · High Impact

🟢 91% · context-and-planning

No notes.

🟢 90% · user-trust-signal

No notes.

🟢 88% · verification

🟢 Four usage-error tests failed first, then all eight command cases passed after production changes. · High Impact

🟢 Named service integration results confirm rejection of dotted keys, oversized keys, and custom attributes. · High Impact

🟡 Command tests instantiate the event command alone, leaving inherited authentication and organization setup unexercised. · Low Severity

🟢 87% · alignment

No notes.


File Attribution

███████████████████░ 99% AI / 1% Human

Status Attribution File Lines
created ai app/cli/cmd/attestation_event_test.go +172 / -0
created ai app/cli/pkg/action/attestation_event_test.go +150 / -0
created ai app/cli/pkg/action/attestation_event.go +127 / -0
created ai app/cli/cmd/attestation_event.go +86 / -0
modified ai app/cli/cmd/workflow_run_timeline.go +52 / -13
modified ai app/cli/documentation/cli-reference.md +54 / -0
modified ai app/controlplane/pkg/biz/workflowrunevent.go +45 / -7
modified ai app/controlplane/internal/service/workflowrunevent_integration_test.go +46 / -0
modified ai app/controlplane/pkg/biz/workflowrunevent_test.go +41 / -3
modified ai app/cli/cmd/workflow_run_timeline_test.go +42 / -0
modified ai docs/specs/issue-3825-attestation-progress-events.md +9 / -3
modified ai app/controlplane/pkg/biz/workflowrunprogress_test.go +9 / -0
modified ai app/cli/cmd/attestation.go +2 / -1
modified ai app/cli/cmd/attestation_test.go +2 / -1
modified ai app/controlplane/api/controlplane/v1/workflow_run.proto +3 / -0
modified ai app/controlplane/internal/service/workflowrun.go +2 / -0
modified ai app/controlplane/pkg/data/ent/migrate/schema.go +1 / -1
modified ai CLAUDE.md +1 / -0

Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-e9b776 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-e9b776 -
✅ Passed ai-config-no-secrets ai-coding-session-e9b776 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-e9b776 -

Security Checks — ⚠️ 1 failing

⚠️ AI Security Analysis

The per-PR audit did not finish: 20 concerns went unreviewed (spend ceiling or time). No introduced risk was found in what it reviewed, but treat this as incomplete, not clean.

View in Chainloop ↗ · How this works ↗

✅ Secret Scan

Status Policy Messages
✅ Passed secrets-detection -

✅ SAST Scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -

✅ IaC Scan

Status Policy Messages
✅ Passed iac-misconfiguration -
Scans not applied (2)
Scan Reason
Vulnerability Scan no manifest/lockfile changed
GitHub Actions Scan no workflow files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 20 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread app/cli/cmd/attestation.go Resolved
Base automatically changed from issue-3825-m1-attestation-progress-events to main December 1, 2026 12:26
Add the custom run event type and the chainloop attestation event command,
so a pipeline can add its own steps to the timeline of its run (R-009).
workflow run describe shows each custom step with its status and duration.

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

Chainloop-Trace-Sessions: e9b77674-6796-46c7-9ae7-1cbe6cab9a87
@migmartri
migmartri force-pushed the issue-3825-m2-attestation-progress-events branch from d35ff35 to 4e8a1d9 Compare December 1, 2026 12:28
Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: e9b77674-6796-46c7-9ae7-1cbe6cab9a87

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 20 files

View guided diff | Re-trigger cubic

A wrong number of arguments or a wrong --status now shows a warning and
exits with success, as the other failures do, so a progress signal never
breaks a pipeline (R-009). Add tests that run the command end to end.

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

Chainloop-Trace-Sessions: e9b77674-6796-46c7-9ae7-1cbe6cab9a87

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 3 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. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="app/cli/cmd/attestation_event.go">

<violation number="1" location="app/cli/cmd/attestation_event.go:42">
P2: `Args: cobra.ArbitraryArgs` only lets positional-count errors reach `RunE`; Cobra still rejects unknown flags and malformed flag values before the warning handler runs, so those invalid calls exit non-zero. Handle Cobra parsing failures for this progress-only command through the same warning-and-success path.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread app/cli/cmd/attestation_event.go Resolved
The command takes the step with the --name flag, not a positional
argument, as attestation add does. R-012 supersedes R-009 in the spec.
CLAUDE.md records the convention: commands identify what they act on
with a flag.

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

Chainloop-Trace-Sessions: e9b77674-6796-46c7-9ae7-1cbe6cab9a87

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 existing issue remains and no new issues found across 5 files (changes from recent commits).

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread CLAUDE.md Resolved
@migmartri
migmartri requested a review from a team December 1, 2026 13:21
@migmartri
migmartri merged commit a1f2a03 into main Dec 1, 2026
16 checks passed
@migmartri
migmartri deleted the issue-3825-m2-attestation-progress-events branch December 1, 2026 13:34
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.

2 participants