Skip to content

feat(attestation): carry triage/adjudicate data in the AI security context - #3427

Merged
matiasinsaurralde merged 4 commits into
mainfrom
feat/ai-triage-index-material
Sep 11, 2026
Merged

feat(attestation): carry triage/adjudicate data in the AI security context#3427
matiasinsaurralde merged 4 commits into
mainfrom
feat/ai-triage-index-material

Conversation

@matiasinsaurralde

@matiasinsaurralde matiasinsaurralde commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Refs PFM-7229 / PFM-7271

Summary

Extends the CHAINLOOP_AI_SECURITY_CONTEXT material so a single material spans both an un-adjudicated (triage-only) context and a fully adjudicated one, rather than introducing a separate triage-index material kind.

The embedded security-context schema (kept at security-context-0.1) gains, as additive optional fields:

  • a top-level survivors array. The adjudication work queue that Phase-1 triage produces and an adjudicate run drains with a survivor definition
  • scan_stats counters: survivors_total, adjudicated_commits, triage_input_tokens, triage_output_tokens, and adjudication_complete

A combined-scan context that omits these still validates, and the schema keeps additionalProperties: false throughout. The aisecuritycontext wire struct mirrors the new fields.

@chainloop-platform

chainloop-platform Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

AI Session Checks — 🟡 74% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 74% 4 ✅ 0 27% AI / 73% Human 22 +3266 / -48 22h39m11s

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

Aug 26, 2026 21:49 UTC · 43m5s · $16.63 · 328 in / 138.2k out · claude-code 2.1.245 (claude-opus-5)

View session details ↗

Change Summary

  • Adds a single-source l0_class_path schema definition plus guard tests.
  • Publishes AI security-context tool metadata through shared tool annotations.
  • Enables AI security-context auto-detection and adds positive detection coverage.

AI Session Overall Score

🟢 88% — Mostly clean session; one user redirect, otherwise strong execution and verification.

AI Session Analysis Breakdown

🟢 92% · scope-discipline

🟢 It stopped editing when the user asked for evaluation only. · High Impact

🟢 91% · verification

🟢 Both main fixes were introduced with failing tests before implementation. · High Impact

🟡 One broad root build hit unrelated workspace noise before later targeted verification passed. · Low Severity

🟢 90% · solution-quality

🟢 The taxonomy fix removed duplication and added drift-catching guards. · High Impact

🟢 88% · alignment

No notes.

🟢 85% · context-and-planning

🟡 The multi-step review and fix sequence had no explicit saved plan artifact. · Low Severity

🟡 74% · user-trust-signal

🟠 The user had to explicitly switch the second thread to evaluation-only mode. · Medium Severity

💡 When a follow-up changes mode, restate the new constraint before acting.


File Attribution

████░░░░░░░░░░░░░░░░ 22% AI / 78% Human

Status Attribution File Lines
created human pkg/attestation/crafter/materials/testdata/ai-security-context-incomplete.json +859 / -0
modified ai internal/schemavalidators/schemavalidators_test.go +117 / -10
modified human internal/schemavalidators/testdata/ai_security_context_triage_only.json +87 / -2
modified ai internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json +87 / -0
modified human pkg/attestation/crafter/materials/aisecuritycontext/aisecuritycontext.go +59 / -0
modified ai pkg/attestation/crafter/materials/chainloop_ai_security_context_test.go +55 / -0
modified ai pkg/attestation/crafter/materials/chainloop_ai_security_context.go +19 / -0

Policies (4)

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

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

Sep 7, 2026 19:10 UTC · 20m8s · $11.02 · 196 in / 63.3k out · claude-code 2.1.263 (claude-opus-4-8)

View session details ↗

Change Summary

  • Adds trace_sessions to the AI security context schema and Go wire types.
  • Updates validator and crafter fixtures to carry the new field.
  • Expands schemavalidators coverage for trace_sessions, including the maxLength case.
  • Builds, runs package tests, and commits the schema change plus the follow-up test fix.

AI Session Overall Score

🟢 90% — Well-executed, well-verified change with only a mild planning gap.

AI Session Analysis Breakdown

🟢 94% · scope-discipline

🟢 It staged only the task-related files despite unrelated dirty files. · High Impact

🟢 93% · solution-quality

No notes.

🟢 92% · alignment

🟢 Its final branch, commit, and test claims matched the recorded commands. · Medium Impact

🟢 91% · user-trust-signal

No notes.

🟢 89% · verification

🟢 It ran focused trace_sessions tests and saw the named cases pass. · High Impact

🟡 72% · context-and-planning

🟠 No visible plan artifact preceded the multi-file implementation phase. · Medium Severity

💡 For multi-file changes, write a short visible plan before editing so the setup matches the task scope.


File Attribution

██████░░░░░░░░░░░░░░ 34% AI / 66% Human

Status Attribution File Lines
modified ai internal/schemavalidators/schemavalidators_test.go +117 / -10
modified human internal/schemavalidators/testdata/ai_security_context_triage_only.json +87 / -2
modified ai internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json +87 / -0
modified ai pkg/attestation/crafter/materials/aisecuritycontext/aisecuritycontext.go +59 / -0

Policies (4)

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

🟡 60% — 26% AI — ✅ All policies passing

Aug 26, 2026 00:21 UTC · 20h45m45s · $62.15 · 692 in / 374.5k out · claude-code 2.1.245 (claude-opus-5)

View session details ↗

Change Summary

  • Adds CHAINLOOP_AI_SECURITY_CONTEXT as a new material type with schema, validator, crafter, and generated API bindings.
  • Adds crafter and validator tests plus valid and negative security-context fixtures.
  • Follow-up commits scrub fixture repository references without changing validation behavior.

AI Session Overall Score

🟡 60% — Well-tested delivery, but two corrected claim-vs-reality misses keep alignment red.

AI Session Analysis Breakdown

🟢 95% · verification

🟢 AI added and reran focused tests before broader package suites passed. · High Impact

🟢 90% · scope-discipline

🟢 Follow-up scrub commits stayed confined to the requested fixture files. · Medium Impact

🟢 88% · context-and-planning

🟢 Implementation started from a written plan with named fixtures and scope boundaries. · High Impact

🟢 86% · solution-quality

No notes.

🟢 84% · user-trust-signal

No notes.

🔴 35% · alignment

🔴 AI twice overstated repo behavior, first on schema patterns and later on whether fixture relabeling mattered. · High Severity

💡 Before making repo-wide claims, check the exact code path and label hypotheticals as hypotheticals.


File Attribution

█████░░░░░░░░░░░░░░░ 26% AI / 74% Human

Status Attribution File Lines
created human pkg/attestation/crafter/materials/testdata/ai-security-context-incomplete.json +859 / -0
modified ai internal/schemavalidators/schemavalidators_test.go +117 / -10
modified human internal/schemavalidators/testdata/ai_security_context_triage_only.json +87 / -2
modified ai internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json +87 / -0
modified ai pkg/attestation/crafter/materials/aisecuritycontext/aisecuritycontext.go +59 / -0
modified ai pkg/attestation/crafter/materials/chainloop_ai_security_context_test.go +55 / -0
modified ai pkg/attestation/crafter/materials/chainloop_ai_security_context.go +19 / -0

Policies (4)

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

🟡 60% — 40% AI — ✅ All policies passing

Sep 10, 2026 05:03 UTC · 50m13s · $59.50 · 752 in / 492.0k out · claude-code 2.1.267 (claude-opus-4-8)

View session details ↗

Change Summary

  • Adds CHAINLOOP_AI_TRIAGE_INDEX material support with crafter, tests, and auto-detection.
  • Adds the embedded triage-index JSON schema and validator wiring.
  • Extends AI security-context scan_stats with adjudicate fields and validation coverage.

AI Session Overall Score

🟡 60% — Strong validation, but two premature completion claims keep alignment in the red.

AI Session Analysis Breakdown

🟢 93% · verification

🟢 The AI repeatedly ran focused tests, suites, builds, and a real sec.json check. · High Impact

🟢 90% · scope-discipline

🟢 Committed changes stayed in the triage/security-context areas and left unrelated edits alone. · High Impact

🟢 90% · solution-quality

No notes.

🟢 84% · user-trust-signal

🟡 The user had to add two calm follow-up asks to surface missed requirements. · Low Severity

🟡 68% · context-and-planning

🟢 The opening ask anchored work in oss.md plus concrete validation inputs. · Medium Impact

🟠 A multi-phase spec change ran without any visible plan, TODO, or PlanMode checkpoint. · Medium Severity

💡 For spec-driven multi-file work, publish a short plan before the first edit.

🔴 38% · alignment

🔴 AI twice declared oss.md complete before later required work surfaced. · High Severity

💡 Before calling spec work complete, re-read the spec against the changed artifacts and final summary.


File Attribution

████████░░░░░░░░░░░░ 40% AI / 60% Human

Status Attribution File Lines
modified ai internal/schemavalidators/schemavalidators_test.go +117 / -10
modified human internal/schemavalidators/testdata/ai_security_context_triage_only.json +87 / -2
modified ai internal/schemavalidators/internal_schemas/aisecuritycontext/ai-security-context-0.1.schema.json +87 / -0
modified ai pkg/attestation/crafter/materials/aisecuritycontext/aisecuritycontext.go +59 / -0

Policies (4)

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

Security Checks — ✅ 9 passing

secret-scan

Status Policy Messages
✅ Passed secrets-detection -

sast-scan

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

iac-scan

Status Policy Messages
✅ Passed iac-misconfiguration -

PR info

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

⏭️ 2 scans not applied

Scan Reason
vulnerability-scan no manifest/lockfile changed
github-actions-scan no workflow files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

@matiasinsaurralde matiasinsaurralde changed the title feat(attestation): add CHAINLOOP_AI_TRIAGE_INDEX material kind feat(attestation): add CHAINLOOP_AI_TRIAGE_INDEX material and security-context adjudicate fields Sep 10, 2026
@matiasinsaurralde
matiasinsaurralde marked this pull request as ready for review September 10, 2026 05:56
@matiasinsaurralde
matiasinsaurralde requested a review from a team September 10, 2026 05:56

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 33 files

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

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

Re-trigger cubic

Comment thread pkg/attestation/crafter/materials/chainloop_ai_triage_index.go Outdated
migmartri
migmartri previously approved these changes Sep 10, 2026

@migmartri migmartri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @matiasinsaurralde I'd like to understand wether since evidenc has value by itself.

Fold the triage work queue and the triage/adjudicate funnel into the
existing CHAINLOOP_AI_SECURITY_CONTEXT material, so one material spans
both an un-adjudicated (triage-only) context and a fully adjudicated one
instead of a separate triage-index kind.

Kept at security-context-0.1 as additive, optional fields, so a
combined-scan context that omits them still validates:

- top-level `survivors` array (the adjudication work queue) with a
  `survivor` definition (only commit_sha required)
- scan_stats: survivors_total, adjudicated_commits, triage_input_tokens,
  triage_output_tokens, adjudication_complete

The embedded schema keeps additionalProperties: false throughout; the
aisecuritycontext wire struct mirrors the new fields for annotation
extraction.

Assisted-by: Claude Code
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>

Chainloop-Trace-Sessions: 3f365023-61a3-4af3-bbe9-03688f152834, 7cf89fb4-1736-425d-bafb-bfb8b59155a4, df945bde-e982-472c-bb81-50055df403bb, fd98553a-50f9-41e6-abf6-f03f0b9f1f4e
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
@matiasinsaurralde
matiasinsaurralde force-pushed the feat/ai-triage-index-material branch from fb0c1d5 to 2f874a5 Compare September 10, 2026 20:06
@matiasinsaurralde matiasinsaurralde changed the title feat(attestation): add CHAINLOOP_AI_TRIAGE_INDEX material and security-context adjudicate fields feat(attestation): carry triage/adjudicate data in the AI security context Sep 10, 2026
@matiasinsaurralde
matiasinsaurralde requested a review from a team September 10, 2026 20:42
migmartri
migmartri previously approved these changes Sep 10, 2026
@migmartri

Copy link
Copy Markdown
Member

Thanks @matiasinsaurralde

So we are going to record all the commits that were triaged as part of the index, not just the ones that failed correct?

Complete the triage/adjudicate fields in CHAINLOOP_AI_SECURITY_CONTEXT with the
two a producer emits but the schema still rejected:

- top-level `discarded`: the commits Phase-1 triage classified and REJECTED,
  typed as sha_list. Together with `survivors` and `scan.unresolved` it states
  the full set of commits ever handed to the classifier, rather than leaving it
  to be inferred from the window bounds — which is wrong once merges are
  involved, since a bounded reverse-chronological walk does not cover exactly
  from_sha..to_sha. Stated explicitly, a walk that deliberately re-covers that
  ground can skip it instead of paying for it again.
- `scan_stats.pending_survivors`: how many survivors still await adjudication.
  A count rather than a list, because the list is already determined by
  `survivors` and `adjudicated_commits`, and storing it would denormalize the
  artifact against itself.

Signed-off-by: Matías Insaurralde <matias@chainloop.dev>

Chainloop-Trace-Sessions: 3f365023-61a3-4af3-bbe9-03688f152834, 7cf89fb4-1736-425d-bafb-bfb8b59155a4, df945bde-e982-472c-bb81-50055df403bb, fd98553a-50f9-41e6-abf6-f03f0b9f1f4e
Add optional `scan.triage_budget_hit` to the security context: the most recent
triage run stopped because it reached its survivor cap rather than because it
exhausted its window, so known-untriaged history sits immediately behind
scan.window.from_sha. A later run that exhausts its window clears it.

It cannot be derived. commits_triaged < last_n is equally true of a repository
smaller than the window, which is complete coverage, and of a budget stop, which
is not — and separating them otherwise means resolving from_sha's ancestry in
git, which a consumer reading the material out of CAS does not have. The producer
is the only party that knows whether it chose to stop or ran out of history.

Distinct from its neighbours: it says nothing about the adjudication queue, and
it is not "the window does not reach the repository root" — a --last-bounded run
does not either.

Signed-off-by: Matías Insaurralde <matias@chainloop.dev>

Chainloop-Trace-Sessions: 3f365023-61a3-4af3-bbe9-03688f152834, 7cf89fb4-1736-425d-bafb-bfb8b59155a4, df945bde-e982-472c-bb81-50055df403bb, fd98553a-50f9-41e6-abf6-f03f0b9f1f4e
Annotate CHAINLOOP_AI_SECURITY_CONTEXT with whether another run over the same
HEAD would still make progress: survivors queued but not adjudicated, or triage
stopped on its survivor budget with history left inside its window.

Published as one derived boolean because an annotation query is an exact
key/value match and cannot express "pending_survivors > 0". Without it a
scheduler cannot tell a bounded run that is still catching up from a finished
one without downloading the payload for every workflow on every sweep. The two
underlying fields are annotated alongside it for observability, not filtering.

An incomplete context is not a failed one — the bounded cold-start run publishes
exactly this state on purpose.

Signed-off-by: Matías Insaurralde <matias@chainloop.dev>

Chainloop-Trace-Sessions: 3f365023-61a3-4af3-bbe9-03688f152834, df945bde-e982-472c-bb81-50055df403bb
@matiasinsaurralde
matiasinsaurralde merged commit 12eaf6d into main Sep 11, 2026
17 checks passed
@matiasinsaurralde
matiasinsaurralde deleted the feat/ai-triage-index-material branch September 11, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants