Skip to content

feat(trace): record AI coding session ids as an attestation annotation - #3885

Open
migmartri wants to merge 1 commit into
chainloop-dev:mainfrom
migmartri:feat/trace-aisession-ids-annotation
Open

migmartri wants to merge 1 commit into
chainloop-dev:mainfrom
migmartri:feat/trace-aisession-ids-annotation

Conversation

@migmartri

@migmartri migmartri commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Refs PFM-8484

When chainloop trace pushes a session attestation, it now adds the attestation annotation chainloop.aisession.ids. The value lists the data.session.id of each CHAINLOOP_AI_CODING_SESSION material that the attestation holds, sorted and comma-joined.

The annotation is on the attestation, not on the material. The control plane stores attestation annotations on the attestation referrer, so chainloop discover on the attestation returns the session ids. Today a consumer such as strata must download the full session material from CAS to read the id. A material annotation would not help, because a material referrer does not keep its annotations.

One attestation can hold more than one session material: a single push attests every session that contributed to the pushed commits. For this reason the annotation is a list (ses_a,ses_b) and not a single id. An id that is empty or that contains a comma is left out of the list. No current provider makes such an id. A consumer can still download that material.

The annotation key is exported as AnnotationAISessionIDs in pkg/attestation/crafter/api/attestation/v1. Attestations pushed before this change do not have the annotation.

This change was made with AI assistance (Claude Code).

View guided diff

The trace push adds the chainloop.aisession.ids annotation to the session
attestation. Its value is the data.session.id of each
CHAINLOOP_AI_CODING_SESSION material in the attestation, sorted and
comma-joined. The control plane stores attestation annotations on the
attestation referrer, so discover returns the ids and a consumer no
longer has to download the session materials to read them.

Refs: PFM-8484

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

Chainloop-Trace-Sessions: ad02680a-2ab6-4980-aa71-d685c2c57fb5
@chainloop-platform

chainloop-platform Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ⚠️ 1 failing

Status Policy Material Messages
⚠️ Failed pr-min-approvals pr-info PR/MR #3885 has 0 approving reviews, 1 required.
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟢 88% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 88% 1 ✅ 0 100% AI / 0% Human 5 +244 / -5 3m56s

🟢 88% — 100% AI — ✅ All policies passing

Dec 4, 2026 23:59 UTC · 3m56s · $3.29 · 120 in / 33.8k out · claude-code 2.1.337 (claude-opus-5-5)

View session details ↗

Change Summary

Adds material-derived session ids as runtime attestation annotations during trace push. Sorts and deduplicates multiple ids, omitting unusable values, and adds builder and push-forwarding tests.

AI Session Overall Score

🟢 88% — Focused annotation delivery with passing builder tests; real push verification remains limited.

AI Session Analysis Breakdown

🟢 97% · scope-discipline

No notes.

🟢 93% · context-and-planning

🟢 Opening request specifies annotation placement, source value, multi-session handling, tests, and downstream exclusions. · High Impact

🟢 92% · solution-quality

🟢 Ids come from evidence, exclude unattested sessions, and are sorted and deduplicated before using existing push machinery. · High Impact

🟢 91% · alignment

No notes.

🟡 75% · verification

🟢 Builder tests assert material-derived ids, multiple sessions, filtering, deduplication, and invalid-id handling. · High Impact

🟠 Push test records annotations on a fake pusher; it does not inspect the serialized attestation produced by the real executor. · Medium Severity

💡 Add a push-path test that inspects the resulting attestation annotations, beyond the fake executor boundary.

abstained · user-trust-signal

🟡 user-trust-signal not assessed — reviewer should confirm coverage · Low Severity


File Attribution

████████████████████ 100% AI / 0% Human

Status Attribution File Lines
created ai app/cli/pkg/action/trace_session_annotations_test.go +159 / -0
created ai app/cli/pkg/action/trace_session_annotations.go +68 / -0
modified ai pkg/attestation/crafter/api/attestation/v1/crafting_state.go +9 / -0
modified ai app/cli/pkg/action/trace_attestation.go +5 / -3
modified ai app/cli/pkg/action/trace_hook_handler.go +3 / -2

Policies (4)

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

Security Checks — ✅ 6 passing

✅ AI Security Analysis

Reviewed this change against the project's security context (1 concern hunted) — no introduced risk found.

View in Chainloop ↗ · How this works ↗

✅ Secret Scan

Status Policy Messages
✅ Passed secrets-detection -

✅ SAST Scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -
Scans not applied (3)
Scan Reason
Vulnerability Scan no manifest/lockfile changed
GitHub Actions Scan no workflow files changed
IaC Scan no IaC files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

View guided diff | Re-trigger cubic

@migmartri
migmartri requested a review from a team December 5, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant