Skip to content

fix(crafter): log material replacement once on auto-detected att add - #3864

Merged
migmartri merged 1 commit into
mainfrom
issue-3863-att-add-replace-log-once
Dec 1, 2026
Merged

migmartri merged 1 commit into
mainfrom
issue-3863-att-add-replace-log-once

Conversation

@migmartri

@migmartri migmartri commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

When a material is added with --replace and no --kind, the CLI printed "material already set, replacing it" once for every material kind that the auto-detection tried (more than 20 lines for one att add).

The cause is in stageMaterial. The kind auto-detection calls it once per probed kind, and it logged the line before it crafted the material. Now it logs the line only when it attaches the material to the crafting state. The line is printed once per att add, only for the material that is actually replaced. The early check that rejects a duplicate name without --replace does not change, so nothing is uploaded for a rejected material.

Tested with the existing duplicate-name table test. It now captures the logs of the second add and expects one replace line with --replace and none without it. Before the fix, the auto-detected case printed 33 lines.

AI disclosure: this change was made with the help of Claude Code.

Closes #3863

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri using the eng-autopilot skill

View guided diff

When a material is added with --replace and no --kind, the kind
auto-detection stages the material once per probed kind. stageMaterial
logged "material already set, replacing it" before crafting, so the line
was printed for every probed kind. Log it only when the material is
attached to the state.

Closes #3863

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

Chainloop-Trace-Sessions: 500fcf79-527f-4bcf-95ef-2c7033bcc590
@migmartri
migmartri requested a review from a team November 30, 2026 23:26
@chainloop-platform

chainloop-platform Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

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

View attestation ↗

AI Session Checks — 🟢 95% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟢 95% 1 ✅ 0 78% AI / 22% Human 2 +22 / -6 2m39s

🟢 95% — 78% AI — ✅ All policies passing

Nov 30, 2026 23:23 UTC · 2m39s · $3.53 · 117 in / 23.0k out · claude-code 2.1.333 (claude-opus-5-5)

View session details ↗

Change Summary

Moves replacement logging to successful material attachment, retaining early duplicate rejection. Extends existing duplicate-name tests to assert replacement log counts across add paths.

AI Session Overall Score

🟢 95% — Autonomous fix stays focused, addresses the logging cause, and passes regression tests.

AI Session Analysis Breakdown

🟢 98% · scope-discipline

🟢 Only the shared staging function and existing duplicate-name test changed, with no unrelated edits. · High Impact

🟢 96% · alignment

No notes.

🟢 96% · solution-quality

🟢 Moves the log to successful attachment while preserving the early duplicate rejection guard. · High Impact

🟢 95% · verification

🟢 Observed regression failure with 33 logs versus one, then reran the suite successfully after the final change. · High Impact

🟡 Autonomous run ends at pre-push capture; human confirmation is structurally absent. · Low Severity

🟢 93% · context-and-planning

No notes.

🟢 85% · user-trust-signal

No notes.


File Attribution

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

Status Attribution File Lines
modified ai pkg/attestation/crafter/crafter.go +8 / -6
modified ai pkg/attestation/crafter/crafter_test.go +14 / -0

Policies (4)

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

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 2 files

View guided diff | Re-trigger cubic

@migmartri
migmartri merged commit 63e8b97 into main Dec 1, 2026
16 checks passed
@migmartri
migmartri deleted the issue-3863-att-add-replace-log-once branch December 1, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: 'material already set, replacing it' is logged once per auto-detected kind on att add --replace

2 participants