Skip to content

fix(agent-rules): accept both scope-index headings in validation - #62

Merged
CybotTM merged 2 commits into
mainfrom
fix/scope-index-heading-drift
Jun 27, 2026
Merged

fix(agent-rules): accept both scope-index headings in validation#62
CybotTM merged 2 commits into
mainfrom
fix/scope-index-heading-drift

Conversation

@CybotTM

@CybotTM CybotTM commented Jun 27, 2026

Copy link
Copy Markdown
Member

Problem

generate-agents.sh emits the root scope index under the heading

## Scoped AGENTS.md (MUST read when working in these directories)

(strengthened from the legacy ## Index of scoped AGENTS.md in commit bbb6899), but validate-structure.sh still grepped for the legacy literal in three places. A freshly generated root longer than 50 lines therefore failed the skill's own structure validation:

❌ ERROR: Root is bloated: 111 lines and no scope index

Fixes #55.

Fix

Introduce one shared ERE — ^## (Index of scoped|Scoped) AGENTS\.md — and use it in all three checks (check_root_is_thin, the check_scope_links guard, and the sed block extraction). This keeps the validator in sync with the generator and backward-compatible with files produced by older versions and the reference examples, which still use the legacy heading (including this repo's own root AGENTS.md).

Regression guard

skills/agent-rules/scripts/tests/test-scope-index-heading.sh drives generate-agents.shvalidate-structure.sh end to end and asserts:

  1. a generated root (new heading, >50 lines) validates — the validate-structure.sh rejects the scope-index heading that generate-agents.sh emits #55 regression;
  2. a root rewritten to the legacy heading still validates — backward compatibility;
  3. a bloated root with no scope index is still rejected — no over-relaxation.

A new Test Scripts workflow (.github/workflows/test-scripts.yml) runs it on PRs touching skills/agent-rules/scripts/** or assets/**.

Verification

✅ PASS: generated root (111 lines, new heading) validates
✅ PASS: root with legacy heading still validates (backward compatible)
✅ PASS: bloated root without a scope index is still rejected

The test was confirmed to fail against the pre-fix validator (exits 1 at test 1) and pass against the fix — so it is a genuine guard, not a tautology. actionlint, shellcheck, and bash -n all clean.

generate-agents.sh emits the root scope index under the heading
"## Scoped AGENTS.md (MUST read when working in these directories)"
(strengthened from the legacy "## Index of scoped AGENTS.md" in
commit bbb6899), but validate-structure.sh still grepped for the
legacy literal. A freshly generated root longer than 50 lines therefore
failed the skill's own structure validation:

  ERROR: Root is bloated: N lines and no scope index

Match both headings via a shared ERE so validation stays in sync with
the generator and remains backward-compatible with files produced by
older versions and the reference examples (which use the legacy heading).

Add a regression test that drives generate-agents.sh -> validate-structure.sh
end to end and a workflow to run it, so the two cannot drift apart again.

Fixes #55

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings June 27, 2026 06:13
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
actions/actions/checkout 11bd71901bbe5b1630ceea73d27597364c9af683 🟢 6.9
Details
CheckScoreReason
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Code-Review🟢 10all changesets reviewed
Maintained🟢 1016 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Binary-Artifacts🟢 10no binaries found in the repo
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Packaging⚠️ -1packaging workflow not detected
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 9security policy file detected
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
SAST🟢 10SAST tool is run on all commits

Scanned Files

  • .github/workflows/test-scripts.yml

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a regression test script (test-scope-index-heading.sh) and updates validate-structure.sh to support both current and legacy scope-index headings via a regular expression, ensuring backward compatibility. The review feedback highlights portability issues with using sed -i without arguments in the test script on macOS versus Linux, suggesting a temporary file redirection approach instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread skills/agent-rules/scripts/tests/test-scope-index-heading.sh Outdated
Comment thread skills/agent-rules/scripts/tests/test-scope-index-heading.sh Outdated
Replace GNU-only `sed -i` with a temp-file + mv form so the regression
test runs on BSD sed (macOS) as well as GNU sed; this repo's CI also runs
the generator on macos-latest.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM merged commit f0f054f into main Jun 27, 2026
28 of 29 checks passed
@CybotTM
CybotTM deleted the fix/scope-index-heading-drift branch June 27, 2026 06:46
@sonarqubecloud

Copy link
Copy Markdown

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.

validate-structure.sh rejects the scope-index heading that generate-agents.sh emits

2 participants