feat: attestation progress events, M1 automatic progress (#3825)

Merged
MI
5d ago
+13624-764

Implements milestone M1 ("Automatic progress") of the attestation progress events spec. Refs #3825. Spec and plan: #3857.

What it adds

  • Run events in the control plane (R-006, R-007, R-008, R-011). A new workflow_run_events table stores short, timestamped progress events with the workflow run.

    • AttestationService/RecordEvent writes events. It applies the same checks as Store.
    • WorkflowRunService/GetProgress returns the events of the run, oldest first, with the same checks as View. For a run in progress, it also returns its progress, which the control plane builds: one row for each expected material with its requirement and status (missing, provided, or failed), the required counts, and the attestation policy results of init. Clients render it as is.
    • The expected materials are the ones that init resolves, from the contract and its policy groups. The start event lists them. A run of an older CLI uses the materials of its contract.
    • No new policy is added. RecordEvent is exempt from the authz middleware next to Store and Cancel, and GetProgress maps to PolicyWorkflowRunRead, as View does. View does not change.
    • Events are accepted only while the run is in progress, up to 1,000 events for each run.
    • The control plane records the closing event in the same transaction as the run status change, on store, reset, and expiry. Expire now skips a run that is no longer in progress.
    • The run expiry job deletes events older than workflow_run_events_retention, 90 days by default. The Helm value is controlplane.attestations.workflowRunEventsRetention.
  • Automatic events from the CLI (R-010, R-002, R-005). The attestation commands record best-effort events:

    • the start of the attestation, at the end of init, with the init policy results and the expected materials
    • each material that collectors add
    • each add that succeeds or fails, with the error text cut to 1 KB

    The push records no event. The closing event of the store ends the push, and the signed attestation holds its policy results (D-011).

    Material policy results go in the material events. Events hold only names, types, statuses, counts, digests, and the material value cut to 256 characters. Each call has a 2-second timeout, and the recorder turns off with no warning against a control plane without the new calls.

  • chainloop workflow run describe (R-004). It calls GetProgress after View and shows the progress and the events it returns. For a run in progress, it shows:

    • the elapsed time
    • each expected material as required, optional, or one of a group, and as provided, missing, or failed, with the error of a failed add. A failed add after a successful one keeps the material as provided.
    • the materials that are not in the contract
    • the attestation policy results so far
    • a timeline tree: one line for each step, with the attempts of a repeated step folded below it

    For a finished run, the timeline shows as history after the signed attestation. Its last line, "pushed and stored", shows the policy status of the signed attestation and the short digest. Against an older control plane, which does not have GetProgress, describe shows the run as before. A run from an older CLI, which records no events, shows no timeline. JSON output gets events and progress fields.

Example of describe output

image

Spec changes

The spec merged in #3857. This PR supersedes two entries:

  • R-001 with R-010: the CLI records no push event. D-011 records the decision: the push and the store are one step, and the signed attestation is the source of the policy results.
  • R-003 with R-011, and D-007 with D-012: a new read call, GetProgress, returns the events and the progress, and the control plane builds the progress. The run view does not change. This also makes the progress count the materials that policy groups require.

The plan steps are updated to match.

AI assistance: this change was implemented with Claude Code.

๐Ÿค– Posted by Maximus bot (Claude Code) on behalf of @migmartri