Repository navigation
feat: implement issue #646 — [Phase 3] Add local canonical-AGENTS.md self-validation to CI (informational) #1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5e284aa
feat: implement issue #646 — [Phase 3] Add local canonical-AGENTS.md …
donpetry-bot db04b2f
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 7f34f90
fix(tests): tighten agents-md-selfcheck assertions against comment fa…
donpetry-bot 1e88f40
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry e1ba823
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry d388c68
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry 1a186b7
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry a7c0249
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry b66127e
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry 6939ef3
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry 2ad4dff
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry 5783c73
Merge branch 'main' into dev-lead/issue-646-20260901-0601
don-petry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| #!/usr/bin/env bats | ||
| # Regression guard for the informational AGENTS.md self-check wired into | ||
| # .github/workflows/ci.yml (issue #646, Phase 3 of epic #642). | ||
| # | ||
| # Phase 3 runs the standalone structural linter (scripts/agents-md-lint.sh) | ||
| # against THIS repo's own canonical AGENTS.md on every pull request, in | ||
| # INFORMATIONAL mode: it annotates each structural finding with a GitHub | ||
| # ::warning:: but must never fail the build (promotion to a failing/required | ||
| # check is deferred to Phase 4). These tests pin that contract so a future edit | ||
| # cannot silently (a) drop the self-check, (b) point it at the wrong file, or | ||
| # (c) flip it to failing mode and turn it into a de-facto blocking gate before | ||
| # Phase 4 sign-off. | ||
|
|
||
| load 'helpers/setup' | ||
|
|
||
| # Emit the `run:` step block whose text contains the given marker substring. | ||
| # Steps in ci.yml start at a 6-space "- " (the `steps:` child indent); every | ||
| # deeper-indented line belongs to that step. (Mirrors secret-scan-config.bats.) | ||
| step_block_with() { | ||
| local marker="$1" | ||
| local block="" out="" line="" | ||
| while IFS= read -r line || [[ -n "$line" ]]; do | ||
| line="${line%$'\r'}" | ||
| if [[ "$line" == " - "* ]]; then | ||
| if [[ "$block" == " - "* ]]; then | ||
| [[ "$block" == *"$marker"* ]] && out="$block" | ||
| fi | ||
| block="$line"$'\n' | ||
| elif [[ "$line" =~ ^[[:space:]]{8} ]] || [[ "$line" =~ ^[[:space:]]*$ ]]; then | ||
| if [[ -n "$block" ]]; then | ||
| block+="$line"$'\n' | ||
| fi | ||
| else | ||
| if [[ "$block" == " - "* ]]; then | ||
| [[ "$block" == *"$marker"* ]] && out="$block" | ||
| fi | ||
| block="" | ||
| fi | ||
| done < "$TT_WORKFLOW" | ||
| if [[ "$block" == " - "* ]]; then | ||
| [[ "$block" == *"$marker"* ]] && out="$block" | ||
| fi | ||
| printf '%s' "$out" | ||
| } | ||
|
|
||
| @test "agents-md-selfcheck: the ci workflow exists" { | ||
| [[ -f "$TT_WORKFLOW" ]] | ||
| } | ||
|
|
||
| @test "agents-md-selfcheck: the linter script it invokes exists and is executable" { | ||
| # The self-check runs the Phase-2 standalone linter; if the path drifts the | ||
| # step would fail with file-not-found and red an otherwise-informational job. | ||
| [[ -x "${TT_REPO_ROOT}/scripts/agents-md-lint.sh" ]] | ||
| } | ||
|
|
||
| @test "agents-md-selfcheck: ci runs the structural linter against this repo's AGENTS.md" { | ||
| local block code | ||
| block="$(step_block_with 'scripts/agents-md-lint.sh')" | ||
| [[ -n "$block" ]] | ||
| # Strip comments so a comment mentioning AGENTS.md cannot satisfy the assertion. | ||
| code="$(printf '%s\n' "$block" | grep -vE '^[[:space:]]*#')" | ||
| [[ "$code" == *"AGENTS.md"* ]] | ||
| } | ||
|
|
||
| @test "agents-md-selfcheck: the self-check stays informational (no --mode failing)" { | ||
| # Informational default mode always exits 0; passing --mode failing would turn | ||
| # a REQUIRED-level finding into a build failure — that promotion is Phase 4. | ||
| # Strip comment lines first: a header comment saying "do NOT pass --mode | ||
| # failing" is good documentation and must not trip this assertion, which is | ||
| # about the actual invocation. | ||
| local block code | ||
| block="$(step_block_with 'scripts/agents-md-lint.sh')" | ||
| [[ -n "$block" ]] | ||
| code="$(printf '%s\n' "$block" | grep -vE '^[[:space:]]*#')" | ||
| # Verify the linter is invoked with AGENTS.md as its argument, not just mentioned. | ||
| [[ "$code" == *"scripts/agents-md-lint.sh"*"AGENTS.md"* ]] | ||
| [[ "$code" != *"--mode failing"* ]] | ||
| [[ "$code" != *"--mode=failing"* ]] | ||
|
don-petry marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @test "agents-md-selfcheck: findings surface as ::warning:: annotations" { | ||
| # Mirror run-bats.sh's non-fatal-signal convention: findings annotate without | ||
| # failing the build. | ||
| local block | ||
| block="$(step_block_with 'scripts/agents-md-lint.sh')" | ||
| [[ -n "$block" ]] | ||
| [[ "$block" == *"::warning"* ]] | ||
| } | ||
|
|
||
| @test "agents-md-selfcheck: the self-check itself documents its informational, deferred-to-Phase-4 status" { | ||
| # AC #3: no new branch-protection required check while informational. The | ||
| # self-check's OWN step block must document that it is informational and that | ||
| # promotion to a blocking/required check is deferred to Phase 4, so a reviewer | ||
| # editing it later knows the non-blocking behaviour is deliberate. Scoping the | ||
| # assertion to the step block (not the whole file) keeps it from passing on an | ||
| # unrelated "informational" comment elsewhere in ci.yml. | ||
| local block | ||
| block="$(step_block_with 'scripts/agents-md-lint.sh')" | ||
| [[ -n "$block" ]] | ||
| [[ "$block" == *"informational"* ]] | ||
| [[ "$block" == *"Phase 4"* ]] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.