Skip to content

fix(cli): use the run's organization after attestation init - #3862

Merged
migmartri merged 3 commits into
mainfrom
fix/attestation-run-org-precedence
Dec 1, 2026
Merged

migmartri merged 3 commits into
mainfrom
fix/attestation-run-org-precedence

Conversation

@migmartri

@migmartri migmartri commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Closes #3861

After chainloop attestation init --org org-a, the commands add, push, status, and reset sent the organization of the repository .chainloop.yml instead of the organization of the run. When the file named another organization, they failed with "workflow run not found".

The organization stored in the local attestation state now comes before the repository config. The order is: --org > CHAINLOOP_ORGANIZATION > local attestation state > .chainloop.yml > saved CLI default. init still reads the repository config, and remote state (--attestation-id) does not change. When the file names a different organization than the local state, the CLI logs which one it uses. The API token check runs for the repository organization only when the CLI uses that organization.

This is an implementation fix within R-003 and R-004 of spec issue-3063-attestation-repo-config. R-003 puts the file before the saved CLI default, not before the organization of an attestation that is already initialized. The spec does not change. The fix keeps the behavior of #2823 and corrects the order that #3518 introduced.

Decision record: adds ATT-006 to docs/decisions/attestation-process.md. It partly replaces ATT-001 (the place of the local attestation state in the order) and ATT-004 (after init, the file does not act as --org).

This PR was prepared with AI assistance (Claude Code).

🤖 Posted by Maximus bot (Claude Code) on behalf of @migmartri

View guided diff

After `attestation init --org org-a`, the commands add, push, status,
and reset sent the organization of the repository `.chainloop.yml`
before the organization stored in the local attestation state. When the
file named another organization, they failed with "workflow run not
found".

The local attestation state now comes before the repository config:
--org > CHAINLOOP_ORGANIZATION > local attestation state >
.chainloop.yml > saved CLI default. init keeps reading the repository
config, and remote state does not change. When the file names a
different organization than the local state, the CLI logs which one it
uses. The API token check applies to the repository organization only
when that organization is used.

This is within R-003 and R-004 of spec issue-3063-attestation-repo-config.
Records the decision as ATT-006, which partly replaces ATT-001 and ATT-004.

Closes #3861

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

Chainloop-Trace-Sessions: f8788f1a-57ad-450c-a7cf-229ee5f1e2d9
Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: f8788f1a-57ad-450c-a7cf-229ee5f1e2d9
@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 — 🟡 85% · ✅ 0 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 85% 1 ✅ 0 87% AI / 13% Human 3 +127 / -32 18m0s

🟡 85% — 87% AI — ✅ All policies passing

Nov 30, 2026 21:52 UTC · 18m0s · $9.74 · 332 in / 115.2k out · claude-code 2.1.332 (claude-opus-5-5)

View session details ↗

Change Summary

Prioritizes the local attestation organization over repository configuration after init, with a notice when they differ. Excludes remote attestation IDs from stale local-state selection and records the decision with regression tests.

AI Session Overall Score

🟡 85% — Focused, tested fix required a remote-state correction; end-to-end user confirmation remains absent.

AI Session Analysis Breakdown

🟢 96% · scope-discipline

🟢 The agent declined a configuration-test helper that would rewrite tests outside the fix. · High Impact

🟢 95% · solution-quality

🟢 The shared resolver selects local state before repository configuration, addressing organization selection at its source. · High Impact

🟢 94% · context-and-planning

No notes.

🟢 91% · user-trust-signal

No notes.

🟡 76% · verification

🟢 Remote-state regressions failed first, then the targeted tests and full 26-package suite passed after the guard fix. · High Impact

🟠 The user approved changes but never reported exercising the corrected attestation behavior. · Medium Severity

💡 Confirm the original failing attestation sequence after the regression suite passes.

🟡 72% · alignment

🟠 The initial report claimed remote state was unchanged; review found stale local state selected the wrong organization. · Medium Severity

💡 Check remote-state boundaries before claiming behavior is preserved.


File Attribution

█████████████████░░░ 87% AI / 13% Human

Status Attribution File Lines
modified ai app/cli/cmd/attestation_test.go +75 / -10
modified ai app/cli/cmd/attestation.go +40 / -21
modified ai docs/decisions/attestation-process.md +12 / -1

Policies (4)

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

Security Checks — ✅ 6 passing

✅ AI Security Analysis

Nothing this change touches re-opens a recorded security fix.

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

@migmartri
migmartri requested a review from a team November 30, 2026 22:02

@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.

All reported issues were addressed

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

View guided diff | Re-trigger cubic

Comment thread app/cli/cmd/attestation.go Resolved

@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.

All reported issues were addressed across 3 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread docs/decisions/attestation-process.md Resolved
Comment thread docs/decisions/attestation-process.md Resolved
With remote state, a local state file is a leftover of another run, so it must not select the organization. Also mark ATT-002 as partly replaced by ATT-006.

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

Chainloop-Trace-Sessions: f8788f1a-57ad-450c-a7cf-229ee5f1e2d9

@jiparis jiparis 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!

@migmartri
migmartri merged commit 04577e1 into main Dec 1, 2026
16 checks passed
@migmartri
migmartri deleted the fix/attestation-run-org-precedence branch December 1, 2026 09:50
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.

fix(cli): attestation commands after init use the .chainloop.yml organization instead of the run's organization

2 participants