From 691d08b0f270d00b53600362c001d41310a5e7f1 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 18:59:07 +0100 Subject: [PATCH 1/7] spec: issue-3825 attestation progress events Design spec for run events: a timeline of attestation progress that the CLI records and the control plane keeps with the workflow run, shown by workflow run describe, plus a custom event command. Refs #3825 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- .../issue-3825-attestation-progress-events.md | 235 ++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 docs/specs/issue-3825-attestation-progress-events.md diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md new file mode 100644 index 000000000..4f410d415 --- /dev/null +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -0,0 +1,235 @@ +--- +owner: migmartri +ticket: https://github.com/chainloop-dev/chainloop/issues/3825 +prd: +--- + + + +# Spec issue-3825: Attestation progress events + +## Summary + +While an attestation is in progress, the control plane knows only that its workflow run is initialized. This spec adds run events: short, timestamped entries that the CLI records on each action of the attestation. The control plane keeps them with the run. `chainloop workflow run describe` uses them to show the evidence that is in, the evidence that is missing, and the policy results so far. A second milestone adds `chainloop attestation event`. With it, a pipeline can record its own steps, for example a security scan. Run events are operational progress data. They are not part of the signed attestation, and they are not an audit trail. + +## Problem + +- The control plane has no readable record of an attestation in progress. Local state, the default, never reaches it. Remote state is encrypted at rest with a key from the token of the CI job, so only that job can read it. +- So no API client can show which evidence is in, which evidence is missing, or how the policies went. The CLI and the UI show only "initialized" until the push. +- A user who watches a long pipeline, or who debugs a stuck or failed run, must read the CI logs. +- A pipeline cannot show its own steps (a scan, a test suite, a wait for approval) next to the attestation. The ticket does not name this gap. See the "In scope" line. + +## Goals and Non-Goals + +- Goal: a user sees the progress of a run in progress from the CLI, with no access to the CI logs. +- Goal: a pipeline can add its own steps to the timeline of its run. +- Non-goal: build the UI view. This spec describes what the UI shows. The UI is in a different repository. Follow-up: a ticket in the UI repository. +- Non-goal: `chainloop attestation status` reads progress from the control plane. Remote state already lets the command run from a different machine or CI step. +- Non-goal: expire runs on inactivity instead of on creation time. Expiry does not change. Follow-up: a ticket if a team asks for it. +- Non-goal: an audit-grade record of a run. Run events are unsigned, deletable after the retention period, and readable by run viewers. The signed attestation and the existing audit log stay the audit record. +- Non-goal: send run events to the audit log, the event bus, or a SIEM. The volume is high, and the ticket does not ask for it. +- Non-goal: identify the caller on each event. The attestation already records who authenticated, and all events of a run come from the same attestation. +- Non-goal: custom attributes on custom events. A custom event has a key, a status, and a message only. +- Non-goal: streaming or push updates. The control plane rejects streaming calls, so clients poll. +- In scope: the custom event command (R-009). It can ship after the automatic events, but it uses the same event model. One spec decides that model once, so that the custom events fit it. + +## Requirements + +### R-001: Automatic events for every attestation +The CLI MUST record a run event at each action of the attestation, with no new flags, in local and remote state modes. The actions are: +- the start of the attestation at `init` +- each material that a collector adds at `init` +- the attestation policy evaluation at `init` and at `push` +- each `add` that succeeds or fails +- a `push` that a policy gate blocks. The run stays in progress, so this event has its own key and does not close the attestation (R-006). +- Done when: the run of a regular attestation (init, three adds, push) has the events of the Appendix example. + +### R-002: Event recording never breaks the attestation +A failure to record an event MUST NOT fail or stop the attestation. Each call has a timeout of 2 seconds. When the control plane does not know the call, the CLI stops sending events for the rest of the command, with no warning. +- Done when: an attestation against a control plane that rejects or does not support events completes with the same result as today. + +### R-003: Read the events of a run +The control plane MUST return the events of a run, oldest first. It uses the same permissions as the run view. A caller can ask only for events newer than one that it already has, so the UI follow-up needs no later control plane change. + +### R-004: Describe a run in progress +For a run in progress, `chainloop workflow run describe` MUST show: +- that the run is in progress, and the elapsed time +- each contract material as required or optional, and as provided or missing +- the materials that are not in the contract +- the policy results so far: passed, violated, and skipped +- the timeline, with the events of one key grouped into one step with its duration + +It labels the material and policy data as reported progress. For a finished run, the materials and policy results come from the signed attestation, as today. The timeline shows as history. +- Done when: a run with a failed `add` shows that material as missing, with the error, until a later `add` of it succeeds. + +### R-005: Only safe data in automatic events +An automatic event MUST contain only names, types, statuses, counts, digests, timestamps, and the error text of a failed action. It also holds the material value that `attestation status` shows, cut to 256 characters. That is the text of a string material, and the reference or file name of other materials. It MUST NOT contain environment variables, annotations, commit data, file content, policy arguments, or raw policy input and output. + +### R-006: The run closes its timeline +The control plane MUST record the closing event of the attestation when it stores, cancels, or expires the run. The status is succeeded on store. On `attestation reset`, it is canceled for a cancellation and failed for a failure. It is failed on expiry. The CLI never records it. It writes the event in the same place as the change of run status. It MUST accept new events for a run only while the run is in progress. +- Done when: the last event of each finished run agrees with the status of the run, also for an expired run. + +### R-007: Retention +The control plane MUST delete run events that are older than a retention period. The default is 90 days. An operator can change it in the control plane configuration. The age comes from the time of each event. The run and its attestation stay. A periodic job deletes the events, with the same pattern as the run expiry job. + +### R-008: Limits +The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a key, and 1 KB for a message. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). + +### R-009: Custom events +`chainloop attestation event --status --message ` MUST record a custom event on the run of the attestation in progress. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. The control plane MUST reject a custom key that starts with `chainloop.`, the prefix of the automatic events. When the command cannot record the event, for example against an older control plane, it shows a warning and exits with success. A progress signal never breaks a pipeline. + +## Constraints + +- Open source: the feature works in the control plane and the CLI alone. It does not need the event bus or any commercial component. +- Compatibility: an older CLI sends no events. Its runs show as today. +- Access: the write call uses the check of the other attestation API calls. The run must belong to the workflow of the caller's token. + +## Proposal + +**What the user sees.** A CI job runs `chainloop attestation init`, some `add` commands, and `push`, as today. While the job runs, a user runs `chainloop workflow run describe --id `. The output shows the run as in progress for 5 minutes. Two of two required materials are in, and one material is not in the contract. One policy failed on the SARIF report. The timeline shows `init`, a failed `add` of the SBOM with its error, the next `add` that succeeded, and the image. After the push, the same command shows the signed attestation, as today, with the timeline as history. A pipeline can also run `chainloop attestation event sast-scan --status started`, and later `--status succeeded`. The timeline then shows a step "sast-scan" with its duration. + +**Run events.** A run event has these fields: +- a time, set by the control plane when it receives the event +- a source: the CLI or the control plane +- a type: attestation, material, policies, or custom +- a key +- a status: started, succeeded, failed, or canceled +- an optional message +- typed attributes for its type + +The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. `chainloop.policies.init` and `chainloop.policies.push` hold the attestation policy evaluations. `chainloop.push` holds a push that a policy gate blocks, with the name of the gate. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. + +**CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. `chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data. + +**Control plane.** The control plane stores events with the run, in its own database (D-002). It closes the timeline (R-006), deletes old events (R-007), and returns events through a new read call (R-003, D-007). + +**UI (described, built in a follow-up).** The run page shows the same data as `describe` in place of its spinner. It polls the read call while the run is in progress. + +```mermaid +sequenceDiagram + participant CI as CI job (CLI) + participant CP as Control plane + participant U as User (describe or UI) + CI->>CP: init (creates the run) + CI-->>CP: event: attestation started, init policies + CI-->>CP: event: material added or failed (each add) + U->>CP: view run + list events + CP-->>U: in progress: contract, events + Note over U: provided and missing materials from contract + events + CI-->>CP: event: push policies + CI->>CP: store attestation + CP->>CP: event: attestation succeeded (closing) + U->>CP: view run + list events + CP-->>U: signed attestation + timeline as history +``` + +Dashed arrows are best effort. A failed event does not stop the attestation. + +## Decision Record + +### D-001: A separate readable event timeline +Progress is a new list of run events with their own write call. It does not reuse the attestation state, and it is not a single "latest progress" record. +- Why: local state never reaches the control plane. The control plane encrypts remote state with the token of the job, so only the job can read it. A list keeps the history, for example a failed `add` before a good one. A single record loses it. +- Alternatives considered: + - Read progress from remote state: works only with remote state, and the control plane cannot read it outside the job's requests. + - One progress record for each run, replaced on each step: no history and no step durations, and the custom events do not fit it. +- Source: drafting + +### D-002: Store events with the run, not in the audit log +The control plane stores run events with the run, in the open source control plane. +- Why: the audit log is available only in the commercial platform, and only organization admins can read it. No client can write to it, its delivery can lose events, and it has no retention. Run viewers must read run events, the CI token must write them, and a job must delete them after a period. +- Alternatives considered: + - Add a run target and client events to the audit log: wrong readers, platform only, and CI volume in a log for compliance. +- Source: drafting + +### D-003: Run events are never part of the signed attestation +Automatic and custom events are unsigned, informational data about the run. After the run is stored, the signed attestation is the source of truth for materials and policies. +- Why: the client reports events with no signature, and a send can fail (R-002), so the timeline can have gaps. If events were in the attestation, a progress signal would change the evidence. +- Alternatives considered: + - Add the timeline to the attestation at push: visible only after the push, and it makes the attestation depend on best-effort data. +- Source: drafting + +### D-004: Keyed events, with the time set by the control plane +Each event is one point in time with a key and a status. A step is the group of events with the same key, and its duration comes from their times. +- Why: one append-only list serves automatic steps, repeated `add` commands, and custom steps. A server time gives one order for CI jobs on different machines. +- Alternatives considered: + - Explicit step objects that a client opens and closes: more state on the server, and a step that a client never closes needs cleanup. + - Events with no key: no grouping, so no durations. + - A client time on each event: clocks of CI machines differ. +- Source: drafting + +### D-005: The custom event command is in the attestation group +The command (`chainloop attestation event`) records on the run of the attestation in progress. +- Why: only the attestation commands know the run in progress, from the local state or the attestation ID. Only they have the CI token that can write to it. D-003, not the group, keeps the events out of the evidence. +- Alternatives considered: + - The workflow run group: the user must give the run ID, and the group runs with user tokens. +- Source: drafting + +### D-006: Typed attributes for each event type +Each event type has a fixed set of attributes that the control plane checks. They are not a free key-value map. +- Why: the check keeps data that R-005 does not allow out of the events, and clients know which fields to show. A new event type needs an API change. +- Alternatives considered: + - A free JSON map: no API change for new types, but no check of the content. +- Source: drafting + +### D-007: A separate read call for events +The run read API gets a new call for the events of a run (R-003). The run view call does not change. +- Why: the run view also returns the full attestation. A client that polls every few seconds while a run is in progress must not get the attestation again each time. +- Alternatives considered: + - Add the events to the run view: one call, but heavy polling. +- Source: drafting + +## Open Questions + +- [ ] **Do the limits of R-008 fit real pipelines?** Proposed: yes. A regular attestation records about 10 events, and a large one about 100, so 1,000 leaves space for custom events. +- [ ] **Does the error text of a failed `add` stay in the event?** Proposed: yes, cut to 1 KB (R-008). It is the main help to debug a run. Some validation errors can quote a part of the file. The alternative is a fixed error class with no detail. + +## Milestones + +1. **Automatic progress.** Automatic events (R-001, R-002, R-005, R-006), the read call (R-003), `describe` for runs in progress (R-004), retention (R-007), and limits (R-008). +2. **Custom events.** `chainloop attestation event` (R-009). + +## Risks + +| Risk | Mitigation | +|------|------------| +| A failed send leaves a gap, so `describe` shows a material as missing that is in the attestation state. | `describe` labels the data as reported progress. After the run is stored, the signed attestation is the source (D-003). | +| Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters and deleted after the retention period. Run viewers can already read the same values in stored attestations. | +| The error text of a failed `add` quotes part of a file. | The 1 KB message limit. See Open Questions. | +| Event volume grows the database. | The limit for each run and the retention period. | + +## Appendix: Events of a regular attestation + +Contract: `image` (container image, required), `sbom` (CycloneDX, required), and `sast-report` (SARIF, optional). The first `add` of the SBOM fails. + +| Time | Source | Type | Key | Status | Message | Attributes | +|------|--------|------|-----|--------|---------|-----------| +| 10:00:00 | cli | attestation | `chainloop.attestation` | started | | contract `build-contract` rev 3, runner GitHub Actions, local state, CLI version | +| 10:00:02 | cli | policies | `chainloop.policies.init` | succeeded | | phase init, 2 evaluated, 2 passed, 0 violated, 0 skipped | +| 10:02:21 | cli | material | `chainloop.material.sast-report` | succeeded | | SARIF, value `scan.sarif`, digest, in contract, 2 evaluated, 1 passed, 1 violated (`sast-no-critical`), 0 skipped | +| 10:03:10 | cli | material | `chainloop.material.sbom` | failed | invalid CycloneDX document: missing bomFormat | CycloneDX, value `sbom.json` | +| 10:04:05 | cli | material | `chainloop.material.sbom` | succeeded | | CycloneDX, value `sbom.json`, digest, in contract, 2 evaluated, 2 passed, 0 violated, 0 skipped | +| 10:05:40 | cli | material | `chainloop.material.image` | succeeded | | container image, value `ghcr.io/example/app:1.4.2`, digest, in contract, 1 evaluated, 1 passed, 0 violated, 0 skipped | +| 10:06:00 | cli | policies | `chainloop.policies.push` | succeeded | | phase push, 1 evaluated, 1 passed, 0 violated, 0 skipped | +| 10:06:03 | control plane | attestation | `chainloop.attestation` | succeeded | | attestation digest | + +Other endings follow R-001 (a blocked push) and R-006 (reset and expiry). From 240c54ac09e0499a034f4ff5276ef0464796c51a Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 19:36:08 +0100 Subject: [PATCH 2/7] docs: add implementation plan for issue-3825 attestation progress events Add the implementation plan in docs/plans with two milestones: automatic progress events with describe output and retention (R-001 to R-008), and the custom event command (R-009). Run events reuse the access checks of storing and viewing the run, so no new permission is added. Spec updates: the 64-character key limit applies to custom keys only (R-008), custom keys use the annotation name format (R-009), and the Access constraint states the real store and view checks. Refs #3825 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- .../issue-3825-attestation-progress-events.md | 394 ++++++++++++++++++ .../issue-3825-attestation-progress-events.md | 6 +- 2 files changed, 397 insertions(+), 3 deletions(-) create mode 100644 docs/plans/issue-3825-attestation-progress-events.md diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md new file mode 100644 index 000000000..a1a0586ce --- /dev/null +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -0,0 +1,394 @@ +--- +owner: migmartri +ticket: https://github.com/chainloop-dev/chainloop/issues/3825 +spec: docs/specs/issue-3825-attestation-progress-events.md +skill: br:eng-plan 1.70.0 +--- + + + +# Plan issue-3825: Attestation progress events + +## Overview + +### Today + +While an attestation is in progress, `chainloop workflow run describe` shows only that the run is initialized. It says "the attestation crafting process is in progress". Users read the CI logs to see which evidence is in and how the policies went. + +### After this plan + +`chainloop workflow run describe` on a run in progress shows the elapsed time and each contract material as provided or missing. It also shows the policy counts so far and a timeline of steps. A pipeline can add its own steps with `chainloop attestation event`. After the push, the same command shows the signed attestation, with the timeline as history. + +### How + +The CLI records a run event after each attestation action, through a new call in the attestation API. The call is best effort, as other optional CLI calls are. The control plane stores the events in a new table next to the workflow run. It closes the timeline when it stores, cancels, or expires the run, and the run expiry job also deletes old events. A new call in the workflow run API returns the events, with the same project access rules as the run view. + +### Rollout + +The automatic events and `describe` ship first, then the custom event command. + +## Architecture and impact + +**Behavior (containers)** + +```mermaid +flowchart LR + subgraph CLI["CLI (CI job)"] + att["attestation init, add, push"]:::changed + rec["run event recorder"]:::new + evt["attestation event (M2)"]:::new + desc["workflow run describe"]:::changed + end + subgraph CP["Control plane"] + svcA["attestation API: RecordEvent"]:::new + svcR["workflow run API: ListEvents"]:::new + biz["run events use case"]:::new + fin["store, cancel, expire"]:::changed + exp["run expiry job"]:::changed + end + db[("workflow_run_events")]:::new + att -->|action result| rec + rec -->|event| svcA + evt -->|custom event| svcA + svcA -->|event| biz + biz -->|event row| db + fin -->|closing event row| db + exp -->|old event rows, deleted| db + db -->|event rows| biz + biz -->|events| svcR + svcR -->|events| desc + classDef new fill:#d4f7d4,stroke:#2e7d32 + classDef changed fill:#fff4c2,stroke:#b8860b +``` + +Green: new. Yellow: changed. No color: unchanged. + +Where does an event go from the CI job to the user? The CLI sends it to the attestation API. The control plane stores it with the run, and `describe` gets it through the run API. + +**Data model** + +```mermaid +erDiagram + workflow_runs ||--o{ workflow_run_events : "has" + workflow_run_events { + uuid id "new" + uuid workflow_run_id "new" + timestamp created_at "new" + string source "new" + string type "new" + string key "new" + string status "new" + string message "new" + json attributes "new" + } +``` + +One new table. A deleted run deletes its events. An index on the run and the time serves the reads, and an index on the time serves the deletion of old events. + +| Impact on | What changes | Where | +|-----------|--------------|-------| +| Users | CI users see progress in `describe` (see User-facing changes). Operators get one new retention value. | `app/cli/cmd/`, `deployment/chainloop/` | +| Other parts of the product | The platform UI can poll the new read call. No change to it in this plan. The run store, cancel, and expiry paths write one more row, and the expiry job also deletes old events. | `app/controlplane/pkg/data/`, `app/controlplane/pkg/biz/` | +| Data and migrations | New table `workflow_run_events`, with a foreign key to `workflow_runs` (cascade delete). The same migration creates its two indexes. The table is new and empty, so the migration locks no existing rows. | `app/controlplane/pkg/data/ent/schema/`, `app/controlplane/pkg/data/ent/migrate/migrations/` | +| Rollout | Deploy the control plane before the CLI release. A CLI that comes first gets "not supported" and stops sending for the rest of each command. | none outside this repository | +| Compatibility | An older CLI sends no events, and `describe` shows its runs as today. A new CLI against an older control plane stops sending for the rest of each command, with no warning. `describe` against an older control plane shows the run as today. | `app/cli/pkg/action/` | +| Rollback | Roll back the control plane. The table stays, unused, and no job deletes from it. The CLI gets "not supported" and shows no warning. | `app/controlplane/` | + +## User-facing changes + +### API + +R-003, R-005, R-008 (M1) and R-009 (M2). `app/controlplane/api/controlplane/v1/workflow_run.proto`: + +```diff + service AttestationService { + rpc Cancel(AttestationServiceCancelRequest) returns (AttestationServiceCancelResponse); ++ // Record a progress event on a run that is in progress. Informational only. ++ rpc RecordEvent(AttestationServiceRecordEventRequest) returns (AttestationServiceRecordEventResponse); + } + + service WorkflowRunService { + rpc View(WorkflowRunServiceViewRequest) returns (WorkflowRunServiceViewResponse); ++ // Events of a run, oldest first. Optional after_event_id returns only newer events. ++ rpc ListEvents(WorkflowRunServiceListEventsRequest) returns (WorkflowRunServiceListEventsResponse); + } ++ ++message AttestationServiceRecordEventRequest { ++ string workflow_run_id = 1 [(buf.validate.field).string.uuid = true]; ++ // id, created_at, and source are set by the server and ignored here. ++ WorkflowRunEvent event = 2 [(buf.validate.field).required = true]; ++} ++message AttestationServiceRecordEventResponse {} ++ ++message WorkflowRunServiceListEventsRequest { ++ string workflow_run_id = 1 [(buf.validate.field).string.uuid = true]; ++ string after_event_id = 2 [(buf.validate.field) = {ignore: IGNORE_IF_ZERO_VALUE, string: {uuid: true}}]; ++} ++message WorkflowRunServiceListEventsResponse { ++ repeated WorkflowRunEvent events = 1; ++} ++ ++message WorkflowRunEvent { ++ string id = 1; ++ google.protobuf.Timestamp created_at = 2; ++ Source source = 3; ++ Type type = 4 [(buf.validate.field).enum = {not_in: [0], defined_only: true}]; ++ string key = 5 [(buf.validate.field).string.min_len = 1]; ++ Status status = 6 [(buf.validate.field).enum = {not_in: [0], defined_only: true}]; ++ string message = 7 [(buf.validate.field).string.max_bytes = 1024]; ++ oneof attributes { AttestationAttributes attestation = 10; MaterialAttributes material = 11; PoliciesAttributes policies = 12; } ++ ++ enum Source { SOURCE_UNSPECIFIED = 0; SOURCE_CLI = 1; SOURCE_CONTROL_PLANE = 2; } ++ enum Type { TYPE_UNSPECIFIED = 0; TYPE_ATTESTATION = 1; TYPE_MATERIAL = 2; TYPE_POLICIES = 3; } // TYPE_CUSTOM = 4 in M2 ++ enum Status { STATUS_UNSPECIFIED = 0; STATUS_STARTED = 1; STATUS_SUCCEEDED = 2; STATUS_FAILED = 3; STATUS_CANCELED = 4; } ++ message AttestationAttributes { string contract_name = 1; int32 contract_revision = 2; string runner_type = 3; bool remote_state = 4; string cli_version = 5; string attestation_digest = 6; repeated string blocking_policies = 7; } ++ message MaterialAttributes { string name = 1; string material_type = 2; string value = 3 [(buf.validate.field).string.max_len = 256]; string digest = 4; bool in_contract = 5; bool added_by_collector = 6; PolicyCounts policies = 7; } ++ message PoliciesAttributes { string phase = 1; PolicyCounts policies = 2; } ++ message PolicyCounts { int32 evaluated = 1; int32 passed = 2; int32 violated = 3; int32 skipped = 4; repeated string violated_policies = 5; } ++} +``` + +### CLI + +R-004. `chainloop workflow run describe` on a run in progress, before: + +```console +$ chainloop workflow run describe --id 7c1e... +│ State │ initialized │ +INF the attestation crafting process is in progress, it has not been received yet +``` + +After. JSON output (`-o json`) gets an `events` list with the fields of the API message. + +```console +$ chainloop workflow run describe --id 7c1e... +│ State │ initialized │ +│ Running for │ 5m45s │ +Materials (reported progress) 1 of 2 required provided + sbom SBOM_CYCLONEDX_JSON required provided 2 passed (1 failed add) + image CONTAINER_IMAGE required missing + sast-report SARIF optional provided 1 passed, 1 violated + build-log ARTIFACT not in contract +Policies (reported progress) attestation: 2 passed +Timeline + 10:00:00 attestation started 5m45s + 10:02:21 sast-report succeeded + 10:03:10 sbom failed invalid CycloneDX document: missing bomFormat + 10:04:05 sbom succeeded + 10:05:30 build-log succeeded +``` + +R-009 (M2). New command: + +```console +$ chainloop attestation event sast-scan --status started --message "Semgrep, ruleset p/ci" +INF event recorded +``` + +### Deployment + +R-007. `deployment/chainloop/values.yaml`, rendered into the control plane config map. No operator action on upgrade: + +```yaml + ## @param controlplane.attestations.workflowRunEventsRetention Age after which workflow run events are deleted. Use seconds with an "s" suffix, for example "7776000s" + attestations: + workflowRunExpirationWindow: "3600s" + workflowRunExpirationCheckInterval: "60s" + workflowRunEventsRetention: "7776000s" # new, 90 days +``` + +## Milestones + +| # | Milestone | You get | Requirements | Depends on | +|---|-----------|---------|--------------|------------| +| M1 | Automatic progress | `describe` shows a run in progress: elapsed time, provided and missing materials, policy counts, and the timeline | R-001 to R-008 | none | +| M2 | Custom events | A pipeline adds its own steps to the timeline with `chainloop attestation event` | R-009 | M1 | + +### M1: Automatic progress + +The control plane gets the event table, the write and read calls, the closing events, and the deletion of old events. The CLI records events from `init`, `add`, and `push`, and `describe` shows them. The write call copies `Store`, the read call copies the run view, and the run expiry job also deletes old events. + +**Done when:** a CI attestation with a failed and a repeated `add` shows in `describe` as in User-facing changes. The closing event matches the run status after store, reset, and expiry. Tested by the CLI action tests and the control plane integration tests. + +**Steps**, in build order. Open a step to see what changes and the files it touches. + +
+01 / 07 · Add the event calls and messages to the API, with the access rules of the run (R-003, R-005) + +Add the calls and messages of the API snippet, without the custom type. Classify each call as shown, so each role and API token has the same access to events as to the run. No new policy is added, so no token policy migration is needed. + +| New call | Classified as | Copies | +|----------|---------------|--------| +| `RecordEvent` | exempt from the authz middleware. The existing `AttestationService` rules apply the attestation auth, with no change to the gRPC server. | the classification of `Store` and `Cancel` | +| `ListEvents` | operations map entry with `PolicyWorkflowRunRead` | `View` | + +| File | Change | +|------|--------| +| `app/controlplane/api/controlplane/v1/workflow_run.proto` | Add the calls and messages. Run `buf format -w` and `make api`. | +| `app/controlplane/api/gen/` | Generated code. Keep `frontend/google/protobuf/descriptor.ts` as on main. | +| `app/controlplane/pkg/authz/authz.go` | Map `/controlplane.v1.WorkflowRunService/ListEvents` to `PolicyWorkflowRunRead`. | +| `app/controlplane/pkg/authz/authz_consistency_test.go` | Add `RecordEvent` to the exempt list next to `Store` and `Cancel`. | + +
+ +
+02 / 07 · Store events with the run, only while the run is in progress (R-006, R-008) + +Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete. Follow the repository rule for indexes: `CREATE INDEX CONCURRENTLY` and `atlas:txmode none`. Add a use case with `Record(ctx, runID, event) error`, `List(ctx, runID, afterID)`, and `DeleteOlderThan(ctx, t, limit)`. `Record` locks the run row in a transaction. It rejects a run that is not initialized or that has 1,000 events, then inserts. So no event lands after the closing event. `List` finds the `afterID` event only inside the same run, and returns the oldest first. Run `make generate`, `make migration_sync`, and `wire ./...`. + +| File | Change | +|------|--------| +| `app/controlplane/pkg/data/ent/schema/workflowrunevent.go` | New schema, indexes on (run, created_at) and (created_at). | +| `app/controlplane/pkg/data/ent/schema/workflowrun.go` | Add the edge to the events. | +| `app/controlplane/pkg/data/workflowrunevent.go` | New repository. | +| `app/controlplane/pkg/biz/workflowrunevent.go` | New use case and repository interface. | +| `app/controlplane/pkg/biz/biz.go`, `app/controlplane/pkg/data/data.go`, `app/controlplane/cmd/wire_gen.go` | Add the providers, run `wire ./...`. | +| `app/controlplane/pkg/data/workflowrunevent_integration_test.go` | Add tests: finished run rejected, limit reached, order, `afterID` of another run returns nothing, cascade delete. | + +
+ +
+03 / 07 · Close the timeline when the run is stored, canceled, or expired (R-006) + +Wrap the status update and the insert of the closing `chainloop.attestation` event in one transaction, with source CONTROL_PLANE. `Expire` locks the run row and skips the update and the insert when the run is no longer initialized. So a run that a store finishes during the sweep gets one closing event. On store, read the attestation digest from the run row, because the store path saves it before it finishes the run. Do not change the signature. + +| Run change | Closing status | Code | +|------------|----------------|------| +| Store | succeeded, with the digest | `MarkAsFinished` | +| Reset, trigger CANCELLATION | canceled | `MarkAsFinished` | +| Reset, trigger FAILURE | failed | `MarkAsFinished` | +| Expiry | failed, message "expired" | `Expire` | + +| File | Change | +|------|--------| +| `app/controlplane/pkg/data/workflowrun.go` | Use a transaction in `MarkAsFinished` and `Expire`, and insert the event. | +| `app/controlplane/pkg/data/workflowrun_integration_test.go` | Add a table test for the four rows, and a test that expiry skips a stored run. | + +
+ +
+04 / 07 · Serve the write and read calls with the checks of Store and View (R-003) + +`RecordEvent` copies the checks of `Store` in the same order. Then it sets the source to CLI. It accepts the types ATTESTATION, MATERIAL, and POLICIES, with a key that starts with `chainloop.`, and an attributes field that matches the type. `ListEvents` copies the checks of `View`. + +| Caller | `RecordEvent` | `ListEvents` | +|--------|---------------|--------------| +| Any caller that `Store` accepts for the run | allowed | allowed | +| Token pinned to another workflow | denied | as for `View` | +| API token scoped to another project | denied | denied | +| User who can only view the project | denied | allowed | +| User with no access to the project | denied | denied | +| Any caller, run in another organization | not found | not found | + +| File | Change | +|------|--------| +| `app/controlplane/internal/service/attestation.go` | Add `RecordEvent`. | +| `app/controlplane/internal/service/workflowrun.go` | Add `ListEvents`. | +| `app/controlplane/internal/service/attestation_test.go`, `workflowrun_test.go` | Add a table test for each row, and for a type that does not match its attributes. | + +
+ +
+05 / 07 · Delete events after the retention period, in the run expiry job (R-007) + +Add a retention duration to the attestations section of the config, with a default of 90 days. Give the expirer the run events use case of step 02. In the existing expiry loop, after it expires runs, call `DeleteOlderThan` in batches. Add the Helm value, regenerate the chart README, and bump the chart patch version. + +| File | Change | +|------|--------| +| `app/controlplane/internal/conf/controlplane/config/v1/conf.proto` | Add `workflow_run_events_retention`. | +| `app/controlplane/pkg/biz/workflowrun.go` | Add the use case to the expirer constructor, and delete old events in the sweep. | +| `app/controlplane/pkg/data/workflowrunevent.go` | Add the batched delete. | +| `app/controlplane/cmd/main.go`, `wire_gen.go`, `main_test.go` | Pass the retention to the expirer options, run `wire ./...`, add the field to the options mapping test. | +| `deployment/chainloop/values.yaml`, `README.md`, `templates/controlplane/configmap.yaml`, `Chart.yaml` | Add the value and its `@param` line, regenerate the README, render the value, bump the patch version. | +| `app/controlplane/pkg/biz/workflowrun_test.go` | Add a test: only events older than the period go. | + +
+ +
+06 / 07 · Record events from init, add, and push, so the run shows its progress (R-001, R-002, R-005) + +Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout, and cuts the message to 1 KB and the value to 256 characters. The callers in M1 do not stop on its error. `init` records the start, the materials that collectors added, and the init policies. `add` records success or the error. `push` records the push policies, and the push command records `chainloop.push` failed when a gate blocks it. The policy counts come from the evaluations in the crafting state. + +| Answer of the control plane | Recorder | +|-----------------------------|----------| +| `Unimplemented` | turns off for the rest of the command. M1 callers show no warning. `Record` still returns the error, so the M2 command can warn. | +| `InvalidArgument`, `FailedPrecondition` | warning | +| timeout or network error | debug log | + +| File | Change | +|------|--------| +| `app/cli/pkg/action/runevents.go` | New recorder and the builders for each event type. | +| `app/cli/pkg/action/attestation_init.go`, `attestation_add.go`, `attestation_push.go` | Record after each action. | +| `app/cli/cmd/attestation_push.go` | Record a blocked push. | +| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. | + +
+ +
+07 / 07 · Show the progress in workflow run describe (R-004) + +`describe` calls `ListEvents` for each run. When the run state is initialized, it joins the contract materials of the run view with the latest material event for each `MaterialAttributes.name`. It adds the other materials as not in the contract. It groups the timeline by key, with durations. For a finished run, it prints the timeline after the attestation. An `Unimplemented` answer keeps the current output. + +| File | Change | +|------|--------| +| `app/cli/pkg/action/workflow_run_describe.go` | Call `ListEvents`, build the checklist and the steps. | +| `app/cli/cmd/workflow_workflow_run_describe.go` | Print the materials, policies, and timeline. | +| `app/cli/pkg/action/workflow_run_describe_test.go` | Add table tests: failed then repeated add, material not in the contract, required material missing, expired run, `Unimplemented`. | + +
+ +Verify: `make -C app/controlplane test && make -C app/cli test && make -C app/controlplane lint && make -C app/cli lint` + +### M2: Custom events + +The control plane accepts the custom type, and the CLI gets `chainloop attestation event`. The command finds the run in the same way as `attestation status`, and uses the recorder of M1. + +**Done when:** `chainloop attestation event` between `init` and `push` shows its step in `describe`. A key that is not in the annotation name format is rejected, and a failure exits with success. Tested by the service and CLI tests. + +**Steps**, in build order. Open a step to see what changes and the files it touches. + +
+01 / 01 · Add chainloop attestation event, so a pipeline records its own steps (R-009) + +Add `TYPE_CUSTOM`. `RecordEvent` accepts it with no attributes, and a key in the annotation name format (`^[\w-]+$`), up to 64 characters. Add the command with `--status` (started, succeeded, failed, canceled) and `--message`. It loads the run from the attestation state, local or with `--attestation-id`, and calls the recorder. On an error it prints a warning and exits with success. Regenerate the CLI docs with `make generate`. + +| File | Change | +|------|--------| +| `app/controlplane/api/controlplane/v1/workflow_run.proto` | Add `TYPE_CUSTOM`. Run `buf format -w` and `make api`. | +| `app/controlplane/internal/service/attestation.go` | Check the key format for each type. | +| `app/controlplane/internal/service/attestation_test.go` | Add table tests: key with a dot, key over 64 characters, custom type with attributes. | +| `app/cli/cmd/attestation_event.go`, `app/cli/pkg/action/attestation_event.go` | New command and action. | +| `app/cli/pkg/action/attestation_event_test.go` | Add tests: no attestation in progress, a failure exits with success. | +| `app/cli/documentation/` | Generated docs. | + +
+ +Verify: `make -C app/controlplane test && make -C app/cli test` + +## Open Questions + +None. + +## Skipped and risks + +| Skipped step | Reason | Follow-up | +|--------------|--------|-----------| +| The run page in the UI | The UI is in another repository (spec Non-Goal). | A ticket in the platform repository | +| Expiry on inactivity, events on the audit bus | Spec Non-Goals. | none | + +Not checked: the load of 1,000 events for each run on the largest installs. Also not checked: whether the new call can serve the poll rate of the platform UI. + +| Risk | Mitigation | +|------|------------| +| The spec has two open questions (the limits, and the error text in an event). M1 builds on their proposed answers. | Settle them in the spec PR before M1 starts. | +| The run row lock in `Record` adds wait on a busy run. | One short transaction for each event, and at most 1,000 events for each run. | +| One more call on each `add` slows the CI job. | The 2-second timeout, and the recorder turns off after "not supported". | +| `describe` shows a material as missing after a lost event. | It labels the data as reported progress (spec D-003). | diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index 4f410d415..0782a231f 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -92,16 +92,16 @@ The control plane MUST record the closing event of the attestation when it store The control plane MUST delete run events that are older than a retention period. The default is 90 days. An operator can change it in the control plane configuration. The age comes from the time of each event. The run and its attestation stay. A periodic job deletes the events, with the same pattern as the run expiry job. ### R-008: Limits -The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a key, and 1 KB for a message. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). +The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a custom key, and 1 KB for a message. The CLI builds automatic keys from material names that the contract already accepts, so the key limit does not apply to them. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). ### R-009: Custom events -`chainloop attestation event --status --message ` MUST record a custom event on the run of the attestation in progress. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. The control plane MUST reject a custom key that starts with `chainloop.`, the prefix of the automatic events. When the command cannot record the event, for example against an older control plane, it shows a warning and exits with success. A progress signal never breaks a pipeline. +`chainloop attestation event --status --message ` MUST record a custom event on the run of the attestation in progress. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, for example against an older control plane, it shows a warning and exits with success. A progress signal never breaks a pipeline. ## Constraints - Open source: the feature works in the control plane and the CLI alone. It does not need the event bus or any commercial component. - Compatibility: an older CLI sends no events. Its runs show as today. -- Access: the write call uses the check of the other attestation API calls. The run must belong to the workflow of the caller's token. +- Access: run events add no new permission. The write call needs the permission that storing the attestation of the run needs. The read call needs the permission of the run view (R-003). A run of another organization is not found. ## Proposal From eab9bc55ec2d1c9b20d0d7066754bd1ea34dd47d Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 20:01:12 +0100 Subject: [PATCH 3/7] docs: issue-3825 keep describe working against older control planes R-004: when the control plane cannot return events, describe shows the run as today and does not fail. The plan adds a compatibility test with an in-process gRPC server that lacks the new calls. Refs #3825 Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- docs/plans/issue-3825-attestation-progress-events.md | 5 +++-- docs/specs/issue-3825-attestation-progress-events.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md index a1a0586ce..1d805944d 100644 --- a/docs/plans/issue-3825-attestation-progress-events.md +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -335,13 +335,14 @@ Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-sec
07 / 07 · Show the progress in workflow run describe (R-004) -`describe` calls `ListEvents` for each run. When the run state is initialized, it joins the contract materials of the run view with the latest material event for each `MaterialAttributes.name`. It adds the other materials as not in the contract. It groups the timeline by key, with durations. For a finished run, it prints the timeline after the attestation. An `Unimplemented` answer keeps the current output. +`describe` calls `ListEvents` for each run. When the run state is initialized, it joins the contract materials of the run view with the latest material event for each `MaterialAttributes.name`. It adds the other materials as not in the contract. It groups the timeline by key, with durations. For a finished run, it prints the timeline after the attestation. Any error from `ListEvents` keeps the current output, and `describe` does not fail. `Unimplemented` gives a debug log, and other errors give a warning. | File | Change | |------|--------| | `app/cli/pkg/action/workflow_run_describe.go` | Call `ListEvents`, build the checklist and the steps. | | `app/cli/cmd/workflow_workflow_run_describe.go` | Print the materials, policies, and timeline. | -| `app/cli/pkg/action/workflow_run_describe_test.go` | Add table tests: failed then repeated add, material not in the contract, required material missing, expired run, `Unimplemented`. | +| `app/cli/pkg/action/workflow_run_describe_test.go` | Add table tests: failed then repeated add, material not in the contract, required material missing, expired run, `Unimplemented`, other error. | +| `app/cli/pkg/action/runevents_compat_test.go` | Add a test with an in-process gRPC server that has the services but not the new calls, as an older control plane. `Record` and `describe` get `Unimplemented`, and neither fails nor panics. |
diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index 0782a231f..8d852ed70 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -78,7 +78,7 @@ For a run in progress, `chainloop workflow run describe` MUST show: - the policy results so far: passed, violated, and skipped - the timeline, with the events of one key grouped into one step with its duration -It labels the material and policy data as reported progress. For a finished run, the materials and policy results come from the signed attestation, as today. The timeline shows as history. +It labels the material and policy data as reported progress. For a finished run, the materials and policy results come from the signed attestation, as today. The timeline shows as history. When the control plane cannot return events, for example an older control plane, `describe` MUST show the run as today and MUST NOT fail. - Done when: a run with a failed `add` shows that material as missing, with the error, until a later `add` of it succeeds. ### R-005: Only safe data in automatic events From 30c7852da0d315ca6578ced0089cdab3dd8b540d Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 21:38:45 +0100 Subject: [PATCH 4/7] docs: issue-3825 record attestation policies in the start and push events Remove the policies event type and the chainloop.policies.init and chainloop.policies.push keys. The chainloop.attestation start event at the end of init carries the init attestation policy counts. A new chainloop.push event, sent before Store, carries all attestation policy counts and the blocking policies. A gated push is still stored, so it shows push failed followed by the closing attestation succeeded. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- .../issue-3825-attestation-progress-events.md | 26 +++++++++---------- .../issue-3825-attestation-progress-events.md | 22 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md index 1d805944d..117d72bdd 100644 --- a/docs/plans/issue-3825-attestation-progress-events.md +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -144,14 +144,14 @@ R-003, R-005, R-008 (M1) and R-009 (M2). `app/controlplane/api/controlplane/v1/w + string key = 5 [(buf.validate.field).string.min_len = 1]; + Status status = 6 [(buf.validate.field).enum = {not_in: [0], defined_only: true}]; + string message = 7 [(buf.validate.field).string.max_bytes = 1024]; -+ oneof attributes { AttestationAttributes attestation = 10; MaterialAttributes material = 11; PoliciesAttributes policies = 12; } ++ oneof attributes { AttestationAttributes attestation = 10; MaterialAttributes material = 11; PushAttributes push = 12; } + + enum Source { SOURCE_UNSPECIFIED = 0; SOURCE_CLI = 1; SOURCE_CONTROL_PLANE = 2; } -+ enum Type { TYPE_UNSPECIFIED = 0; TYPE_ATTESTATION = 1; TYPE_MATERIAL = 2; TYPE_POLICIES = 3; } // TYPE_CUSTOM = 4 in M2 ++ enum Type { TYPE_UNSPECIFIED = 0; TYPE_ATTESTATION = 1; TYPE_MATERIAL = 2; TYPE_PUSH = 3; } // TYPE_CUSTOM = 4 in M2 + enum Status { STATUS_UNSPECIFIED = 0; STATUS_STARTED = 1; STATUS_SUCCEEDED = 2; STATUS_FAILED = 3; STATUS_CANCELED = 4; } -+ message AttestationAttributes { string contract_name = 1; int32 contract_revision = 2; string runner_type = 3; bool remote_state = 4; string cli_version = 5; string attestation_digest = 6; repeated string blocking_policies = 7; } ++ message AttestationAttributes { string contract_name = 1; int32 contract_revision = 2; string runner_type = 3; bool remote_state = 4; string cli_version = 5; string attestation_digest = 6; PolicyCounts policies = 7; } + message MaterialAttributes { string name = 1; string material_type = 2; string value = 3 [(buf.validate.field).string.max_len = 256]; string digest = 4; bool in_contract = 5; bool added_by_collector = 6; PolicyCounts policies = 7; } -+ message PoliciesAttributes { string phase = 1; PolicyCounts policies = 2; } ++ message PushAttributes { PolicyCounts policies = 1; repeated string blocking_policies = 2; } + message PolicyCounts { int32 evaluated = 1; int32 passed = 2; int32 violated = 3; int32 skipped = 4; repeated string violated_policies = 5; } +} ``` @@ -179,7 +179,7 @@ Materials (reported progress) 1 of 2 required provided build-log ARTIFACT not in contract Policies (reported progress) attestation: 2 passed Timeline - 10:00:00 attestation started 5m45s + 10:00:02 attestation started 5m43s 10:02:21 sast-report succeeded 10:03:10 sbom failed invalid CycloneDX document: missing bomFormat 10:04:05 sbom succeeded @@ -270,14 +270,14 @@ Wrap the status update and the insert of the closing `chainloop.attestation` eve | File | Change | |------|--------| | `app/controlplane/pkg/data/workflowrun.go` | Use a transaction in `MarkAsFinished` and `Expire`, and insert the event. | -| `app/controlplane/pkg/data/workflowrun_integration_test.go` | Add a table test for the four rows, and a test that expiry skips a stored run. | +| `app/controlplane/pkg/data/workflowrun_integration_test.go` | Add a table test for the four rows, and a test that expiry skips a stored run. Change the existing test that expires a finished run, because expiry now skips it. |
04 / 07 · Serve the write and read calls with the checks of Store and View (R-003) -`RecordEvent` copies the checks of `Store` in the same order. Then it sets the source to CLI. It accepts the types ATTESTATION, MATERIAL, and POLICIES, with a key that starts with `chainloop.`, and an attributes field that matches the type. `ListEvents` copies the checks of `View`. +`RecordEvent` copies the checks of `Store` in the same order. Then it sets the source to CLI. It accepts the types ATTESTATION, MATERIAL, and PUSH, with a key that starts with `chainloop.`, and an attributes field that matches the type. `ListEvents` copies the checks of `View`. | Caller | `RecordEvent` | `ListEvents` | |--------|---------------|--------------| @@ -315,7 +315,7 @@ Add a retention duration to the attestations section of the config, with a defau
06 / 07 · Record events from init, add, and push, so the run shows its progress (R-001, R-002, R-005) -Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout, and cuts the message to 1 KB and the value to 256 characters. The callers in M1 do not stop on its error. `init` records the start, the materials that collectors added, and the init policies. `add` records success or the error. `push` records the push policies, and the push command records `chainloop.push` failed when a gate blocks it. The policy counts come from the evaluations in the crafting state. +Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout, and cuts the message to 1 KB and the value to 256 characters. The callers in M1 do not stop on its error. At the end of `init`, after the collectors and the init policies, `init` records the start with the init policy counts. Then it records the materials that collectors added. `add` records success or the error. After the push policies and the dry-run return, and before `Store`, `push` records `chainloop.push`. It counts all attestation evaluations in the state, from `init` and from `push`. The status is failed when a gate that is not bypassed blocks the push, with the blocking policies. Else it is succeeded. Move the gate check from the push command into the push action, as a function that returns the blocking policies. The action and the command then use the same check. A dry run records no push event. The policy counts come from the evaluations in the crafting state. | Answer of the control plane | Recorder | |-----------------------------|----------| @@ -326,23 +326,23 @@ Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-sec | File | Change | |------|--------| | `app/cli/pkg/action/runevents.go` | New recorder and the builders for each event type. | -| `app/cli/pkg/action/attestation_init.go`, `attestation_add.go`, `attestation_push.go` | Record after each action. | -| `app/cli/cmd/attestation_push.go` | Record a blocked push. | -| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. | +| `app/cli/pkg/action/attestation_init.go`, `attestation_add.go`, `attestation_push.go` | Record after each action, and the push event before `Store`. Add the gate function to `attestation_push.go`. | +| `app/cli/cmd/attestation_push.go` | Call the gate function of the action in `validatePolicyEnforcement`. | +| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. Also test a blocked push, a bypassed gate, and a dry run. |
07 / 07 · Show the progress in workflow run describe (R-004) -`describe` calls `ListEvents` for each run. When the run state is initialized, it joins the contract materials of the run view with the latest material event for each `MaterialAttributes.name`. It adds the other materials as not in the contract. It groups the timeline by key, with durations. For a finished run, it prints the timeline after the attestation. Any error from `ListEvents` keeps the current output, and `describe` does not fail. `Unimplemented` gives a debug log, and other errors give a warning. +`describe` calls `ListEvents` for each run. When the run state is initialized, it joins the contract materials of the run view with the latest material event for each `MaterialAttributes.name`. It adds the other materials as not in the contract. It takes the attestation policy counts from the latest `chainloop.push` event, or else from the start event. It groups the timeline by key, with durations. For a finished run, it prints the timeline after the attestation. Any error from `ListEvents` keeps the current output, and `describe` does not fail. `Unimplemented` gives a debug log, and other errors give a warning. | File | Change | |------|--------| | `app/cli/pkg/action/workflow_run_describe.go` | Call `ListEvents`, build the checklist and the steps. | | `app/cli/cmd/workflow_workflow_run_describe.go` | Print the materials, policies, and timeline. | | `app/cli/pkg/action/workflow_run_describe_test.go` | Add table tests: failed then repeated add, material not in the contract, required material missing, expired run, `Unimplemented`, other error. | -| `app/cli/pkg/action/runevents_compat_test.go` | Add a test with an in-process gRPC server that has the services but not the new calls, as an older control plane. `Record` and `describe` get `Unimplemented`, and neither fails nor panics. | +| `app/cli/pkg/action/runevents_compat_test.go` | Add a test with an in-process gRPC server that has the services but not the new calls, as an older control plane. `Record` returns `Unimplemented`, and the `add` and `describe` callers succeed. |
diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index 8d852ed70..cafc6ccfe 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -56,11 +56,10 @@ While an attestation is in progress, the control plane knows only that its workf ### R-001: Automatic events for every attestation The CLI MUST record a run event at each action of the attestation, with no new flags, in local and remote state modes. The actions are: -- the start of the attestation at `init` +- the start of the attestation, at the end of `init`, with the results of the attestation policies of `init` - each material that a collector adds at `init` -- the attestation policy evaluation at `init` and at `push` - each `add` that succeeds or fails -- a `push` that a policy gate blocks. The run stays in progress, so this event has its own key and does not close the attestation (R-006). +- the `push`, before the control plane stores the attestation. It has the results of all attestation policies of the run, from `init` and from `push`. The event fails when a policy gate blocks the push. The control plane stores a blocked push as today, and then closes the attestation (R-006). - Done when: the run of a regular attestation (init, three adds, push) has the events of the Appendix example. ### R-002: Event recording never breaks the attestation @@ -110,13 +109,13 @@ The control plane MUST reject an event that goes past a limit. The limits are 1, **Run events.** A run event has these fields: - a time, set by the control plane when it receives the event - a source: the CLI or the control plane -- a type: attestation, material, policies, or custom +- a type: attestation, material, push, or custom - a key - a status: started, succeeded, failed, or canceled - an optional message - typed attributes for its type -The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. `chainloop.policies.init` and `chainloop.policies.push` hold the attestation policy evaluations. `chainloop.push` holds a push that a policy gate blocks, with the name of the gate. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. +The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. `chainloop.push` holds the push, with the names of the gates that block it. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. **CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. `chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data. @@ -130,12 +129,12 @@ sequenceDiagram participant CP as Control plane participant U as User (describe or UI) CI->>CP: init (creates the run) - CI-->>CP: event: attestation started, init policies + CI-->>CP: event: attestation started, with init policies CI-->>CP: event: material added or failed (each add) U->>CP: view run + list events CP-->>U: in progress: contract, events Note over U: provided and missing materials from contract + events - CI-->>CP: event: push policies + CI-->>CP: event: push succeeded or failed, with all attestation policies CI->>CP: store attestation CP->>CP: event: attestation succeeded (closing) U->>CP: view run + list events @@ -216,6 +215,8 @@ The run read API gets a new call for the events of a run (R-003). The run view c | Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters and deleted after the retention period. Run viewers can already read the same values in stored attestations. | | The error text of a failed `add` quotes part of a file. | The 1 KB message limit. See Open Questions. | | Event volume grows the database. | The limit for each run and the retention period. | +| The start event comes at the end of `init`, so its time is a few seconds after the start of the run. | The run keeps its exact creation time. | +| The push event shows the gate result, not the store result. A retry of the push records it again. A store that fails leaves a succeeded push event on a run in progress. | `describe` uses the latest push event. The closing event of the control plane shows the store (R-006). | ## Appendix: Events of a regular attestation @@ -223,13 +224,12 @@ Contract: `image` (container image, required), `sbom` (CycloneDX, required), and | Time | Source | Type | Key | Status | Message | Attributes | |------|--------|------|-----|--------|---------|-----------| -| 10:00:00 | cli | attestation | `chainloop.attestation` | started | | contract `build-contract` rev 3, runner GitHub Actions, local state, CLI version | -| 10:00:02 | cli | policies | `chainloop.policies.init` | succeeded | | phase init, 2 evaluated, 2 passed, 0 violated, 0 skipped | +| 10:00:02 | cli | attestation | `chainloop.attestation` | started | | contract `build-contract` rev 3, runner GitHub Actions, local state, CLI version, 2 evaluated, 2 passed, 0 violated, 0 skipped | | 10:02:21 | cli | material | `chainloop.material.sast-report` | succeeded | | SARIF, value `scan.sarif`, digest, in contract, 2 evaluated, 1 passed, 1 violated (`sast-no-critical`), 0 skipped | | 10:03:10 | cli | material | `chainloop.material.sbom` | failed | invalid CycloneDX document: missing bomFormat | CycloneDX, value `sbom.json` | | 10:04:05 | cli | material | `chainloop.material.sbom` | succeeded | | CycloneDX, value `sbom.json`, digest, in contract, 2 evaluated, 2 passed, 0 violated, 0 skipped | | 10:05:40 | cli | material | `chainloop.material.image` | succeeded | | container image, value `ghcr.io/example/app:1.4.2`, digest, in contract, 1 evaluated, 1 passed, 0 violated, 0 skipped | -| 10:06:00 | cli | policies | `chainloop.policies.push` | succeeded | | phase push, 1 evaluated, 1 passed, 0 violated, 0 skipped | +| 10:06:00 | cli | push | `chainloop.push` | succeeded | | 3 evaluated, 3 passed, 0 violated, 0 skipped | | 10:06:03 | control plane | attestation | `chainloop.attestation` | succeeded | | attestation digest | -Other endings follow R-001 (a blocked push) and R-006 (reset and expiry). +When a policy gate blocks the push, the push event is failed, with the blocking policies. The control plane still stores the attestation, so the closing event is succeeded (R-006). Reset and expiry follow R-006. From 85c801ff828366b05396fe4fdb42bfc850aed591 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 22:01:47 +0100 Subject: [PATCH 5/7] docs: issue-3825 align spec and plan with the M1 implementation Close the two open questions with the proposed answers (D-008 limits, D-009 error text in failed add events). State the key of a failed add with no name, the closing event messages, and the blocked push message. Fix the plan's test file names, the Record signature and its error, the step 05 files, and the describe example. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- .../issue-3825-attestation-progress-events.md | 22 ++++++++++-------- .../issue-3825-attestation-progress-events.md | 23 +++++++++++++++---- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md index 117d72bdd..1dc27bad2 100644 --- a/docs/plans/issue-3825-attestation-progress-events.md +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -166,11 +166,11 @@ $ chainloop workflow run describe --id 7c1e... INF the attestation crafting process is in progress, it has not been received yet ``` -After. JSON output (`-o json`) gets an `events` list with the fields of the API message. +After. JSON output (`-o json`) gets an `events` list with the fields of the API message. It also gets a `progress` object with the materials, the required counts, the attestation policy counts, and the steps. ```console $ chainloop workflow run describe --id 7c1e... -│ State │ initialized │ +│ State │ in progress │ │ Running for │ 5m45s │ Materials (reported progress) 1 of 2 required provided sbom SBOM_CYCLONEDX_JSON required provided 2 passed (1 failed add) @@ -179,9 +179,9 @@ Materials (reported progress) 1 of 2 required provided build-log ARTIFACT not in contract Policies (reported progress) attestation: 2 passed Timeline - 10:00:02 attestation started 5m43s + 10:00:02 attestation started 5m43s 10:02:21 sast-report succeeded - 10:03:10 sbom failed invalid CycloneDX document: missing bomFormat + 10:03:10 sbom failed 55s invalid CycloneDX document: missing bomFormat 10:04:05 sbom succeeded 10:05:30 build-log succeeded ``` @@ -242,7 +242,7 @@ Add the calls and messages of the API snippet, without the custom type. Classify
02 / 07 · Store events with the run, only while the run is in progress (R-006, R-008) -Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete. Follow the repository rule for indexes: `CREATE INDEX CONCURRENTLY` and `atlas:txmode none`. Add a use case with `Record(ctx, runID, event) error`, `List(ctx, runID, afterID)`, and `DeleteOlderThan(ctx, t, limit)`. `Record` locks the run row in a transaction. It rejects a run that is not initialized or that has 1,000 events, then inserts. So no event lands after the closing event. `List` finds the `afterID` event only inside the same run, and returns the oldest first. Run `make generate`, `make migration_sync`, and `wire ./...`. +Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete. Follow the repository rule for indexes: `CREATE INDEX CONCURRENTLY` and `atlas:txmode none`. Add a use case with `Record(ctx, runID, event) (*WorkflowRunEvent, error)`, `List(ctx, runID, afterID)`, and `DeleteOlderThan(ctx, t, limit)`. `Record` locks the run row in a transaction. It rejects a run that is not initialized or that has 1,000 events, then inserts. Both rejections return a new biz `ErrFailedPrecondition`, which maps to the gRPC code `FailedPrecondition`. So no event lands after the closing event. `List` finds the `afterID` event only inside the same run, and returns the oldest first. Run `make generate`, `make migration_sync`, and `wire ./...`. | File | Change | |------|--------| @@ -270,7 +270,8 @@ Wrap the status update and the insert of the closing `chainloop.attestation` eve | File | Change | |------|--------| | `app/controlplane/pkg/data/workflowrun.go` | Use a transaction in `MarkAsFinished` and `Expire`, and insert the event. | -| `app/controlplane/pkg/data/workflowrun_integration_test.go` | Add a table test for the four rows, and a test that expiry skips a stored run. Change the existing test that expires a finished run, because expiry now skips it. | +| `app/controlplane/pkg/data/workflowrunevent_integration_test.go` | Add a table test for the four rows, and a test that expiry skips a stored run. | +| `app/controlplane/pkg/biz/attestationstate_integration_test.go` | Change the existing test that expires a finished run to use a run in progress, because expiry now skips a finished run. |
@@ -292,14 +293,14 @@ Wrap the status update and the insert of the closing `chainloop.attestation` eve |------|--------| | `app/controlplane/internal/service/attestation.go` | Add `RecordEvent`. | | `app/controlplane/internal/service/workflowrun.go` | Add `ListEvents`. | -| `app/controlplane/internal/service/attestation_test.go`, `workflowrun_test.go` | Add a table test for each row, and for a type that does not match its attributes. | +| `app/controlplane/internal/service/workflowrunevent_integration_test.go` | Add an integration table test for each row, and for a type that does not match its attributes. For each row, check that `Store` and `View` give the same result. |
05 / 07 · Delete events after the retention period, in the run expiry job (R-007) -Add a retention duration to the attestations section of the config, with a default of 90 days. Give the expirer the run events use case of step 02. In the existing expiry loop, after it expires runs, call `DeleteOlderThan` in batches. Add the Helm value, regenerate the chart README, and bump the chart patch version. +Add a retention duration to the attestations section of the config, with a default of 90 days. Give the expirer the run events use case of step 02. In the existing expiry loop, after it expires runs, call `DeleteOlderThan` in batches. Add the Helm value, add its row to the chart README by hand, and bump the chart patch version. | File | Change | |------|--------| @@ -307,8 +308,10 @@ Add a retention duration to the attestations section of the config, with a defau | `app/controlplane/pkg/biz/workflowrun.go` | Add the use case to the expirer constructor, and delete old events in the sweep. | | `app/controlplane/pkg/data/workflowrunevent.go` | Add the batched delete. | | `app/controlplane/cmd/main.go`, `wire_gen.go`, `main_test.go` | Pass the retention to the expirer options, run `wire ./...`, add the field to the options mapping test. | -| `deployment/chainloop/values.yaml`, `README.md`, `templates/controlplane/configmap.yaml`, `Chart.yaml` | Add the value and its `@param` line, regenerate the README, render the value, bump the patch version. | +| `deployment/chainloop/values.yaml`, `README.md`, `templates/controlplane/configmap.yaml`, `Chart.yaml` | Add the value and its `@param` line, add the README row by hand (the repository has no README generator), render the value, bump the patch version. | +| `app/controlplane/pkg/biz/mocks/WorkflowRunEventRepo.go`, `.mockery.yml` | Add the repository interface to mockery, and generate the mock. | | `app/controlplane/pkg/biz/workflowrun_test.go` | Add a test: only events older than the period go. | +| `app/controlplane/pkg/biz/workflowrun_options_test.go` | Add a test of the retention default. |
@@ -389,7 +392,6 @@ Not checked: the load of 1,000 events for each run on the largest installs. Also | Risk | Mitigation | |------|------------| -| The spec has two open questions (the limits, and the error text in an event). M1 builds on their proposed answers. | Settle them in the spec PR before M1 starts. | | The run row lock in `Record` adds wait on a busy run. | One short transaction for each event, and at most 1,000 events for each run. | | One more call on each `add` slows the CI job. | The 2-second timeout, and the recorder turns off after "not supported". | | `describe` shows a material as missing after a lost event. | It labels the data as reported progress (spec D-003). | diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index cafc6ccfe..cad48916c 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -84,7 +84,7 @@ It labels the material and policy data as reported progress. For a finished run, An automatic event MUST contain only names, types, statuses, counts, digests, timestamps, and the error text of a failed action. It also holds the material value that `attestation status` shows, cut to 256 characters. That is the text of a string material, and the reference or file name of other materials. It MUST NOT contain environment variables, annotations, commit data, file content, policy arguments, or raw policy input and output. ### R-006: The run closes its timeline -The control plane MUST record the closing event of the attestation when it stores, cancels, or expires the run. The status is succeeded on store. On `attestation reset`, it is canceled for a cancellation and failed for a failure. It is failed on expiry. The CLI never records it. It writes the event in the same place as the change of run status. It MUST accept new events for a run only while the run is in progress. +The control plane MUST record the closing event of the attestation when it stores, cancels, or expires the run. The status is succeeded on store, with the attestation digest and no message. On `attestation reset`, it is canceled for a cancellation and failed for a failure, with the reset reason as the message, cut to 1 KB. It is failed on expiry, with the message "expired". The CLI never records it. It writes the event in the same place as the change of run status. It MUST accept new events for a run only while the run is in progress. - Done when: the last event of each finished run agrees with the status of the run, also for an expired run. ### R-007: Retention @@ -115,7 +115,7 @@ The control plane MUST reject an event that goes past a limit. The limits are 1, - an optional message - typed attributes for its type -The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. `chainloop.push` holds the push, with the names of the gates that block it. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. +The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. A failed `add` with no material name uses the key `chainloop.material`. `chainloop.push` holds the push. A blocked push has the names of the blocking policies, and the message `blocked by policy gates: `. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. **CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. `chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data. @@ -197,10 +197,23 @@ The run read API gets a new call for the events of a run (R-003). The run view c - Add the events to the run view: one call, but heavy polling. - Source: drafting +### D-008: The limits of R-008 stay as proposed +The limits are 1,000 events for each run, 64 characters for a custom key, and 1 KB for a message. +- Why: this answers an open question of the spec review. A regular attestation records about 10 events, and a large one about 100. So 1,000 leaves space for custom events. +- Alternatives considered: + - Higher limits: more storage for each run, and no known pipeline needs them. +- Source: drafting + +### D-009: The error text of a failed `add` stays in the event +The CLI keeps the error text as the message of the failed event, cut to 1 KB (R-008). +- Why: this answers an open question of the spec review. The error text is the main help to debug a run. Some validation errors can quote a part of the file, and the 1 KB limit caps that. +- Alternatives considered: + - A fixed error class with no detail: safer, but a user cannot see why the `add` failed. +- Source: drafting + ## Open Questions -- [ ] **Do the limits of R-008 fit real pipelines?** Proposed: yes. A regular attestation records about 10 events, and a large one about 100, so 1,000 leaves space for custom events. -- [ ] **Does the error text of a failed `add` stay in the event?** Proposed: yes, cut to 1 KB (R-008). It is the main help to debug a run. Some validation errors can quote a part of the file. The alternative is a fixed error class with no detail. +None. ## Milestones @@ -213,7 +226,7 @@ The run read API gets a new call for the events of a run (R-003). The run view c |------|------------| | A failed send leaves a gap, so `describe` shows a material as missing that is in the attestation state. | `describe` labels the data as reported progress. After the run is stored, the signed attestation is the source (D-003). | | Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters and deleted after the retention period. Run viewers can already read the same values in stored attestations. | -| The error text of a failed `add` quotes part of a file. | The 1 KB message limit. See Open Questions. | +| The error text of a failed `add` quotes part of a file. | The 1 KB message limit (D-009). | | Event volume grows the database. | The limit for each run and the retention period. | | The start event comes at the end of `init`, so its time is a few seconds after the start of the run. | The run keeps its exact creation time. | | The push event shows the gate result, not the store result. A retry of the push records it again. A store that fails leaves a succeeded push event on a run in progress. | `describe` uses the latest push event. The closing event of the control plane shows the store (R-006). | From 1c4641334b40200cd08361b29179c97b673aeca4 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 22:37:09 +0100 Subject: [PATCH 6/7] docs: issue-3825 field bounds, archive summary event, review fixes Add D-010 with a size bound on each run event field (R-008), and the summary event for an add that expands an archive into more than 20 materials (R-001). Record the accepted risk of filling the 1,000-event cap. In the plan, compare RecordEvent with Store and ListEvents with View, and list the FailedPrecondition mapping in the shared handler. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- .../issue-3825-attestation-progress-events.md | 20 +++++++++++-------- .../issue-3825-attestation-progress-events.md | 14 ++++++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md index 1dc27bad2..a53fd64bd 100644 --- a/docs/plans/issue-3825-attestation-progress-events.md +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -141,7 +141,7 @@ R-003, R-005, R-008 (M1) and R-009 (M2). `app/controlplane/api/controlplane/v1/w + google.protobuf.Timestamp created_at = 2; + Source source = 3; + Type type = 4 [(buf.validate.field).enum = {not_in: [0], defined_only: true}]; -+ string key = 5 [(buf.validate.field).string.min_len = 1]; ++ string key = 5 [(buf.validate.field).string = {min_len: 1, max_len: 128}]; + Status status = 6 [(buf.validate.field).enum = {not_in: [0], defined_only: true}]; + string message = 7 [(buf.validate.field).string.max_bytes = 1024]; + oneof attributes { AttestationAttributes attestation = 10; MaterialAttributes material = 11; PushAttributes push = 12; } @@ -149,8 +149,10 @@ R-003, R-005, R-008 (M1) and R-009 (M2). `app/controlplane/api/controlplane/v1/w + enum Source { SOURCE_UNSPECIFIED = 0; SOURCE_CLI = 1; SOURCE_CONTROL_PLANE = 2; } + enum Type { TYPE_UNSPECIFIED = 0; TYPE_ATTESTATION = 1; TYPE_MATERIAL = 2; TYPE_PUSH = 3; } // TYPE_CUSTOM = 4 in M2 + enum Status { STATUS_UNSPECIFIED = 0; STATUS_STARTED = 1; STATUS_SUCCEEDED = 2; STATUS_FAILED = 3; STATUS_CANCELED = 4; } ++ // Every string attribute below has [(buf.validate.field).string.max_len = 256] (D-010). ++ // Every policy name list has [(buf.validate.field).repeated = {max_items: 100, items: {string: {max_len: 256}}}]. + message AttestationAttributes { string contract_name = 1; int32 contract_revision = 2; string runner_type = 3; bool remote_state = 4; string cli_version = 5; string attestation_digest = 6; PolicyCounts policies = 7; } -+ message MaterialAttributes { string name = 1; string material_type = 2; string value = 3 [(buf.validate.field).string.max_len = 256]; string digest = 4; bool in_contract = 5; bool added_by_collector = 6; PolicyCounts policies = 7; } ++ message MaterialAttributes { string name = 1; string material_type = 2; string value = 3; string digest = 4; bool in_contract = 5; bool added_by_collector = 6; PolicyCounts policies = 7; } + message PushAttributes { PolicyCounts policies = 1; repeated string blocking_policies = 2; } + message PolicyCounts { int32 evaluated = 1; int32 passed = 2; int32 violated = 3; int32 skipped = 4; repeated string violated_policies = 5; } +} @@ -221,9 +223,9 @@ The control plane gets the event table, the write and read calls, the closing ev **Steps**, in build order. Open a step to see what changes and the files it touches.
-01 / 07 · Add the event calls and messages to the API, with the access rules of the run (R-003, R-005) +01 / 07 · Add the event calls and messages to the API, with the access rules of the run (R-003, R-005, R-008) -Add the calls and messages of the API snippet, without the custom type. Classify each call as shown, so each role and API token has the same access to events as to the run. No new policy is added, so no token policy migration is needed. +Add the calls and messages of the API snippet, without the custom type, and with the bounds of each field (spec D-010). Classify each call as shown, so each role and API token has the same access to events as to the run. No new policy is added, so no token policy migration is needed. | New call | Classified as | Copies | |----------|---------------|--------| @@ -242,7 +244,7 @@ Add the calls and messages of the API snippet, without the custom type. Classify
02 / 07 · Store events with the run, only while the run is in progress (R-006, R-008) -Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete. Follow the repository rule for indexes: `CREATE INDEX CONCURRENTLY` and `atlas:txmode none`. Add a use case with `Record(ctx, runID, event) (*WorkflowRunEvent, error)`, `List(ctx, runID, afterID)`, and `DeleteOlderThan(ctx, t, limit)`. `Record` locks the run row in a transaction. It rejects a run that is not initialized or that has 1,000 events, then inserts. Both rejections return a new biz `ErrFailedPrecondition`, which maps to the gRPC code `FailedPrecondition`. So no event lands after the closing event. `List` finds the `afterID` event only inside the same run, and returns the oldest first. Run `make generate`, `make migration_sync`, and `wire ./...`. +Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete. Follow the repository rule for indexes: `CREATE INDEX CONCURRENTLY` and `atlas:txmode none`. Add a use case with `Record(ctx, runID, event) (*WorkflowRunEvent, error)`, `List(ctx, runID, afterID)`, and `DeleteOlderThan(ctx, t, limit)`. `Record` locks the run row in a transaction. It rejects a run that is not initialized or that has 1,000 events, then inserts. Both rejections return a new biz `ErrFailedPrecondition`. Add it to the shared error handler of the service layer, so that it maps to the gRPC code `FailedPrecondition`. So no event lands after the closing event. `List` finds the `afterID` event only inside the same run, and returns the oldest first. Run `make generate`, `make migration_sync`, and `wire ./...`. | File | Change | |------|--------| @@ -250,6 +252,8 @@ Add the `WorkflowRunEvent` Ent schema with an edge to the run and cascade delete | `app/controlplane/pkg/data/ent/schema/workflowrun.go` | Add the edge to the events. | | `app/controlplane/pkg/data/workflowrunevent.go` | New repository. | | `app/controlplane/pkg/biz/workflowrunevent.go` | New use case and repository interface. | +| `app/controlplane/pkg/biz/errors.go` | Add `ErrFailedPrecondition` and `IsErrFailedPrecondition`. | +| `app/controlplane/internal/service/service.go` | Map `IsErrFailedPrecondition` to `codes.FailedPrecondition` in the shared error handler. | | `app/controlplane/pkg/biz/biz.go`, `app/controlplane/pkg/data/data.go`, `app/controlplane/cmd/wire_gen.go` | Add the providers, run `wire ./...`. | | `app/controlplane/pkg/data/workflowrunevent_integration_test.go` | Add tests: finished run rejected, limit reached, order, `afterID` of another run returns nothing, cascade delete. | @@ -293,7 +297,7 @@ Wrap the status update and the insert of the closing `chainloop.attestation` eve |------|--------| | `app/controlplane/internal/service/attestation.go` | Add `RecordEvent`. | | `app/controlplane/internal/service/workflowrun.go` | Add `ListEvents`. | -| `app/controlplane/internal/service/workflowrunevent_integration_test.go` | Add an integration table test for each row, and for a type that does not match its attributes. For each row, check that `Store` and `View` give the same result. | +| `app/controlplane/internal/service/workflowrunevent_integration_test.go` | Add an integration table test for each row, and for a type that does not match its attributes. For each row, check that `RecordEvent` gives the same result as `Store`, and `ListEvents` the same result as `View`. |
@@ -318,7 +322,7 @@ Add a retention duration to the attestations section of the config, with a defau
06 / 07 · Record events from init, add, and push, so the run shows its progress (R-001, R-002, R-005) -Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout, and cuts the message to 1 KB and the value to 256 characters. The callers in M1 do not stop on its error. At the end of `init`, after the collectors and the init policies, `init` records the start with the init policy counts. Then it records the materials that collectors added. `add` records success or the error. After the push policies and the dry-run return, and before `Store`, `push` records `chainloop.push`. It counts all attestation evaluations in the state, from `init` and from `push`. The status is failed when a gate that is not bypassed blocks the push, with the blocking policies. Else it is succeeded. Move the gate check from the push command into the push action, as a function that returns the blocking policies. The action and the command then use the same check. A dry run records no push event. The policy counts come from the evaluations in the crafting state. +Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout. It cuts the message to 1 KB, the value to 256 characters, and each list of policy names to 100 names. The callers in M1 do not stop on its error. At the end of `init`, after the collectors and the init policies, `init` records the start with the init policy counts. Then it records the materials that collectors added. `add` records success or the error. An `add` that expands an archive into more than 20 materials records one summary event, as the spec describes. A smaller archive records one event for each material. After the push policies and the dry-run return, and before `Store`, `push` records `chainloop.push`. It counts all attestation evaluations in the state, from `init` and from `push`. The status is failed when a gate that is not bypassed blocks the push, with the blocking policies. Else it is succeeded. Move the gate check from the push command into the push action, as a function that returns the blocking policies. The action and the command then use the same check. A dry run records no push event. The policy counts come from the evaluations in the crafting state. | Answer of the control plane | Recorder | |-----------------------------|----------| @@ -331,7 +335,7 @@ Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-sec | `app/cli/pkg/action/runevents.go` | New recorder and the builders for each event type. | | `app/cli/pkg/action/attestation_init.go`, `attestation_add.go`, `attestation_push.go` | Record after each action, and the push event before `Store`. Add the gate function to `attestation_push.go`. | | `app/cli/cmd/attestation_push.go` | Call the gate function of the action in `validatePolicyEnforcement`. | -| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. Also test a blocked push, a bypassed gate, and a dry run. | +| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. Also test a blocked push, a bypassed gate, a dry run, and an archive above and at 20 materials. |
diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index cad48916c..1b57db692 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -58,7 +58,7 @@ While an attestation is in progress, the control plane knows only that its workf The CLI MUST record a run event at each action of the attestation, with no new flags, in local and remote state modes. The actions are: - the start of the attestation, at the end of `init`, with the results of the attestation policies of `init` - each material that a collector adds at `init` -- each `add` that succeeds or fails +- each `add` that succeeds or fails. An `add` that expands an archive into more than 20 materials records one summary event (see Proposal). - the `push`, before the control plane stores the attestation. It has the results of all attestation policies of the run, from `init` and from `push`. The event fails when a policy gate blocks the push. The control plane stores a blocked push as today, and then closes the attestation (R-006). - Done when: the run of a regular attestation (init, three adds, push) has the events of the Appendix example. @@ -91,7 +91,7 @@ The control plane MUST record the closing event of the attestation when it store The control plane MUST delete run events that are older than a retention period. The default is 90 days. An operator can change it in the control plane configuration. The age comes from the time of each event. The run and its attestation stay. A periodic job deletes the events, with the same pattern as the run expiry job. ### R-008: Limits -The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a custom key, and 1 KB for a message. The CLI builds automatic keys from material names that the contract already accepts, so the key limit does not apply to them. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). +The control plane MUST reject an event that goes past a limit. The limits are 1,000 events for each run, 64 characters for a custom key, and 1 KB for a message. The CLI builds automatic keys from material names that the contract already accepts, so the custom key limit does not apply to them. Each field of an event also has a bound (D-010). Any key has at most 128 characters, and each attribute text at most 256 characters. Each list of policy names has at most 100 names of 256 characters. The CLI cuts a list of policy names to 100 before it sends it, and the policy counts stay complete. The CLI cuts a message to 1 KB before it sends it, so the error text of a failed action is not lost. When the control plane rejects an event, the CLI shows a warning and continues (R-002). ### R-009: Custom events `chainloop attestation event --status --message ` MUST record a custom event on the run of the attestation in progress. The status is started, succeeded, failed, or canceled. The command finds the run in the same way as the other attestation commands. A custom key MUST use the format of annotation names: letters, digits, `_`, and `-`. A custom key cannot hold a dot, so it never matches an automatic `chainloop.` key. When the command cannot record the event, for example against an older control plane, it shows a warning and exits with success. A progress signal never breaks a pipeline. @@ -115,7 +115,7 @@ The control plane MUST reject an event that goes past a limit. The limits are 1, - an optional message - typed attributes for its type -The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. A failed `add` with no material name uses the key `chainloop.material`. `chainloop.push` holds the push. A blocked push has the names of the blocking policies, and the message `blocked by policy gates: `. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message. The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. +The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. A failed `add` with no material name uses the key `chainloop.material`. `chainloop.push` holds the push. A blocked push has the names of the blocking policies, and the message `blocked by policy gates: `. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message, with one exception. An `add` can expand an archive (an SBOM or SARIF zip or tar) into more than 20 materials. It then records one succeeded event on `chainloop.material.`, with the message " materials from the archive". With no `--name`, the name is the archive file name without its archive extension (`.zip`, `.tar`, `.tar.gz`, or `.tgz`). The value is the archive file name, and the type is the kind of the `add`. The policy counts are the sum for all the materials, and each violated policy shows once. An archive with 20 materials or fewer records one event for each material. A large archive can have up to 10,000 entries, so one event for each would use up the limit of the run (R-008). The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. **CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. `chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data. @@ -211,6 +211,13 @@ The CLI keeps the error text as the message of the failed event, cut to 1 KB (R- - A fixed error class with no detail: safer, but a user cannot see why the `add` failed. - Source: drafting +### D-010: A size bound on each field of an event +The control plane rejects an event with a field that goes past its bound (R-008). Any key has at most 128 characters. Each attribute text has at most 256 characters, as the material value. Each list of policy names has at most 100 names of 256 characters. +- Why: before, only the message and the material value had a bound. One authenticated client could then store large data in each of the 1,000 events of a run. The CLI builds automatic keys from material names, which are short in practice. When a key goes past 128 characters, the control plane rejects the event, and the CLI shows a warning (R-002). +- Alternatives considered: + - A bound on the size of the full event only: one check, but the client cannot see which field goes past it. +- Source: implementation review of #3859 + ## Open Questions None. @@ -228,6 +235,7 @@ None. | Material values stay in events of runs that never finish. Today the control plane clears their state. | Values are cut to 256 characters and deleted after the retention period. Run viewers can already read the same values in stored attestations. | | The error text of a failed `add` quotes part of a file. | The 1 KB message limit (D-009). | | Event volume grows the database. | The limit for each run and the retention period. | +| A run with about 1,000 separate `add` commands fills the limit of 1,000 events. The control plane then rejects the later events, also the push event, and the CLI shows a warning. | Accepted. The limit applies only to the events of the client. The store and the closing event of the control plane do not depend on events. | | The start event comes at the end of `init`, so its time is a few seconds after the start of the run. | The run keeps its exact creation time. | | The push event shows the gate result, not the store result. A retry of the push records it again. A store that fails leaves a succeeded push event on a run in progress. | `describe` uses the latest push event. The closing event of the control plane shows the store (R-006). | From 7e45945affd483459b98947ec44b25eafeb0b8a2 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Mon, 30 Nov 2026 22:43:36 +0100 Subject: [PATCH 7/7] docs: issue-3825 record an event for the archive file material An add that expands an archive also records an event for the archive file itself, which the CLI keeps as an evidence material. The summary count stays the number of expanded materials. Assisted-by: Claude Code Signed-off-by: Miguel Martinez Trivino Chainloop-Trace-Sessions: 3eeeeacd-8df3-4b29-bf84-7ab6e5c86691 --- docs/plans/issue-3825-attestation-progress-events.md | 4 ++-- docs/specs/issue-3825-attestation-progress-events.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/plans/issue-3825-attestation-progress-events.md b/docs/plans/issue-3825-attestation-progress-events.md index a53fd64bd..96f07d9be 100644 --- a/docs/plans/issue-3825-attestation-progress-events.md +++ b/docs/plans/issue-3825-attestation-progress-events.md @@ -322,7 +322,7 @@ Add a retention duration to the attestations section of the config, with a defau
06 / 07 · Record events from init, add, and push, so the run shows its progress (R-001, R-002, R-005) -Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout. It cuts the message to 1 KB, the value to 256 characters, and each list of policy names to 100 names. The callers in M1 do not stop on its error. At the end of `init`, after the collectors and the init policies, `init` records the start with the init policy counts. Then it records the materials that collectors added. `add` records success or the error. An `add` that expands an archive into more than 20 materials records one summary event, as the spec describes. A smaller archive records one event for each material. After the push policies and the dry-run return, and before `Store`, `push` records `chainloop.push`. It counts all attestation evaluations in the state, from `init` and from `push`. The status is failed when a gate that is not bypassed blocks the push, with the blocking policies. Else it is succeeded. Move the gate check from the push command into the push action, as a function that returns the blocking policies. The action and the command then use the same check. A dry run records no push event. The policy counts come from the evaluations in the crafting state. +Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-second timeout. It cuts the message to 1 KB, the value to 256 characters, and each list of policy names to 100 names. The callers in M1 do not stop on its error. At the end of `init`, after the collectors and the init policies, `init` records the start with the init policy counts. Then it records the materials that collectors added. `add` records success or the error. An `add` that expands an archive into more than 20 materials records one summary event, as the spec describes. A smaller archive records one event for each material. Both also record an event for the evidence material of the archive file (`-archive`). After the push policies and the dry-run return, and before `Store`, `push` records `chainloop.push`. It counts all attestation evaluations in the state, from `init` and from `push`. The status is failed when a gate that is not bypassed blocks the push, with the blocking policies. Else it is succeeded. Move the gate check from the push command into the push action, as a function that returns the blocking policies. The action and the command then use the same check. A dry run records no push event. The policy counts come from the evaluations in the crafting state. | Answer of the control plane | Recorder | |-----------------------------|----------| @@ -335,7 +335,7 @@ Add a recorder to the CLI actions: `Record(ctx, event) error` sends with a 2-sec | `app/cli/pkg/action/runevents.go` | New recorder and the builders for each event type. | | `app/cli/pkg/action/attestation_init.go`, `attestation_add.go`, `attestation_push.go` | Record after each action, and the push event before `Store`. Add the gate function to `attestation_push.go`. | | `app/cli/cmd/attestation_push.go` | Call the gate function of the action in `validatePolicyEnforcement`. | -| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. Also test a blocked push, a bypassed gate, a dry run, and an archive above and at 20 materials. | +| `app/cli/pkg/action/runevents_test.go` | Add table tests: limits cut, each answer row, a failed send keeps the result, no env vars or annotations in the event. Also test a blocked push, a bypassed gate, and a dry run. Test an archive above and at 20 materials, each with the event of the archive file. |
diff --git a/docs/specs/issue-3825-attestation-progress-events.md b/docs/specs/issue-3825-attestation-progress-events.md index 1b57db692..8ca4c9278 100644 --- a/docs/specs/issue-3825-attestation-progress-events.md +++ b/docs/specs/issue-3825-attestation-progress-events.md @@ -58,7 +58,7 @@ While an attestation is in progress, the control plane knows only that its workf The CLI MUST record a run event at each action of the attestation, with no new flags, in local and remote state modes. The actions are: - the start of the attestation, at the end of `init`, with the results of the attestation policies of `init` - each material that a collector adds at `init` -- each `add` that succeeds or fails. An `add` that expands an archive into more than 20 materials records one summary event (see Proposal). +- each `add` that succeeds or fails. An `add` that expands an archive into more than 20 materials records one summary event and the event of the archive file (see Proposal). - the `push`, before the control plane stores the attestation. It has the results of all attestation policies of the run, from `init` and from `push`. The event fails when a policy gate blocks the push. The control plane stores a blocked push as today, and then closes the attestation (R-006). - Done when: the run of a regular attestation (init, three adds, push) has the events of the Appendix example. @@ -115,7 +115,7 @@ The control plane MUST reject an event that goes past a limit. The limits are 1, - an optional message - typed attributes for its type -The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. A failed `add` with no material name uses the key `chainloop.material`. `chainloop.push` holds the push. A blocked push has the names of the blocking policies, and the message `blocked by policy gates: `. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message, with one exception. An `add` can expand an archive (an SBOM or SARIF zip or tar) into more than 20 materials. It then records one succeeded event on `chainloop.material.`, with the message " materials from the archive". With no `--name`, the name is the archive file name without its archive extension (`.zip`, `.tar`, `.tar.gz`, or `.tgz`). The value is the archive file name, and the type is the kind of the `add`. The policy counts are the sum for all the materials, and each violated policy shows once. An archive with 20 materials or fewer records one event for each material. A large archive can have up to 10,000 entries, so one event for each would use up the limit of the run (R-008). The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. +The key groups events into a step. `chainloop.attestation` runs from `init` to the end of the run. `chainloop.material.` holds each `add` of one material. A failed `add` with no material name uses the key `chainloop.material`. `chainloop.push` holds the push. A blocked push has the names of the blocking policies, and the message `blocked by policy gates: `. The policy results go in the event of the action that evaluates them. Material policies go in the material event. The start event holds the attestation policies of `init`. The push event holds all attestation policies of the run. The status describes the step, not the policy result. When the CLI adds a material that has a policy violation, the status is succeeded, and the attributes hold the policy counts. Automatic events that succeed have no message, with one exception. An `add` can expand an archive (an SBOM or SARIF zip or tar) into more than 20 materials. It then records one succeeded event on `chainloop.material.`, with the message " materials from the archive". N counts the expanded materials, not the archive file. With no `--name`, the name is the archive file name without its archive extension (`.zip`, `.tar`, `.tar.gz`, or `.tgz`). The value is the archive file name, and the type is the kind of the `add`. The policy counts are the sum for all the materials, and each violated policy shows once. An archive with 20 materials or fewer records one event for each material. In both cases, the CLI also records one event for the archive file itself, which the CLI keeps as an evidence material. A large archive can have up to 10,000 entries, so one event for each would use up the limit of the run (R-008). The CLI and the UI build the text from the type and the attributes. The Appendix lists the events of a regular attestation. **CLI.** The attestation commands record events through the new write call of the attestation API. That API already holds the run-scoped authentication of the CI token. Each call is best effort (R-002). The CLI sends each event when the action happens. It does not batch events, so the receive time stays close to the action time. `chainloop workflow run describe` reads the run, its contract, and its events. It builds the list of provided and missing materials from the contract (the run view already returns it) and the material events. So the events are the only new data.