Skip to content

ci: add actionlint and a test-environment guard - #100

Merged
imran-siddique merged 3 commits into
mainfrom
ci/guardrails
Sep 7, 2026
Merged

ci: add actionlint and a test-environment guard#100
imran-siddique merged 3 commits into
mainfrom
ci/guardrails

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Two guardrails, each for a silent failure that actually happened during this security sweep.

1. actionlint

I introduced a duplicate env: key in cmcp's release.yml while hardening tag interpolation. GitHub Actions refuses to load a workflow with a duplicate key, reported it as a "workflow file issue" on unrelated pushes, ran nothing for the release event, and left a version unpublished for hours.

It got through because yaml.safe_load keeps the last value for a duplicate key without complaining. actionlint says it plainly:

.github/workflows/repro.yml:16:9: key "env" is duplicated in element of "steps" section.
previously defined at line:13,col:9 [syntax-check]

Verified against a reproduction of the exact broken file before adding it.

On how it's installed: fetched by pinned version with a checksum verification, not run as a third-party action. actionlint publishes no official action, and a check whose whole purpose is guarding the workflow supply chain should not add a new dependency to it.

Triggered only on changes under .github/workflows, so it costs nothing on ordinary PRs. Every repo in the org is clean against it today, so this adds no backlog.

2. Test-environment guard

pytest puts the source tree on the path, so an in-process import always finds this tree and looks right. A test that shells out gets no such help: subprocess.run([sys.executable, ...]) resolves the distribution normally, and with a released wheel also installed it finds site-packages.

The subprocess then exercises a published version while the suite reports a pass. That is exactly how trace-spec's tutorial test graded against the previous schema and still looked green, and why cmcp's distribution smoke test reported a version that had nothing to do with the tree.

The guard probes a subprocess once per session and fails with an actionable message:

ERROR: agentrust_trace resolves to ...\site-packages\agentrust_trace\__init__.py
in a subprocess, outside C:\Users\imran\source\trace-spec. Any test that shells
out would exercise that installed distribution instead of this working tree.
Install editable (pip install -e .) or uninstall the shadowing agentrust_trace.

It is a no-op in CI, which installs editable, and verified as such against a correctly configured local venv. A package that is not importable from a subprocess at all is deliberately allowed: that is a path-only setup, not a shadowing install, so nobody gets locked out of running the suite.

Applied to the seven repos that install their own package editable in CI. examples, integrations and demos test against third-party distributions on purpose and get actionlint only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t

Two guardrails for two silent failures that both happened here.

actionlint. A duplicate env: key in cmcp's release.yml made GitHub
refuse to load the workflow. It reported that as a "workflow file issue"
on unrelated pushes, the release event ran nothing, and a version sat
unpublished for hours. yaml.safe_load keeps the last value for a
duplicate key without complaining, so local validation passed.
actionlint reports it directly:

    key "env" is duplicated in element of "steps" section

Fetched by pinned version and checksum-verified rather than run as a
third-party action, so a check that exists to guard the workflow supply
chain does not add to it. Runs only when .github/workflows changes.
Every repo is clean against it today.

Test-environment guard. pytest puts the source tree on the path, so an
in-process import always finds it. A test that shells out does not get
that: a plain subprocess resolves the distribution normally and, with a
released wheel also installed, finds site-packages. The subprocess then
exercises a published version while the suite reports a pass. That is
how a tutorial test graded against an old schema and looked green.

conftest probes a subprocess once per session and fails loudly if the
package resolves outside the repository. CI installs editable, so it is
a no-op there. A package not importable from a subprocess at all is
fine: that is a path-only setup, not a shadowing install.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t
@imran-siddique
imran-siddique requested a review from a team as a code owner September 6, 2026 22:58
imran-siddique and others added 2 commits September 6, 2026 17:24
The guard was appended after the module body, carrying its own
"from __future__ import annotations". Python requires that line to come
first, so the conftest failed to import and took every test job with it.

The appended block now reuses the imports the file already has and adds
only what it needs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t
The conftest tripped this repo family's own gates: ruff format on the
tuple layout, PLW1510 on subprocess.run without an explicit check, and
E402 where the guard was appended below the module body. check=False is
the honest value here, since a non-zero exit only means the package is
not importable from a subprocess, which the caller already handles.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbDBXDWWvMFa7c2jGgyq9t
@imran-siddique
imran-siddique merged commit cb41ab5 into main Sep 7, 2026
7 checks passed
@imran-siddique
imran-siddique deleted the ci/guardrails branch September 7, 2026 00:35
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.

1 participant