test: add regression coverage for .github/agents/ root-relative import path#25636
test: add regression coverage for .github/agents/ root-relative import path#25636
.github/agents/ root-relative import path#25636Conversation
…lution (#25634) Agent-Logs-Url: https://github.com/github/gh-aw/sessions/42261129-85e6-455c-987c-773a99a16b33 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
.github/agents/ root-relative import path
There was a problem hiding this comment.
Pull request overview
Adds regression test coverage to ensure .github/agents/... imports are resolved repo-root-relative (and not relative to .github/workflows/) through the full BFS import-processing pipeline.
Changes:
- Adds
TestDotGithubAgentsImportto exercise BFS import traversal for agent-file imports. - Covers both documented
.github/agents/planner.mdand the slash-prefixed/.github/agents/planner.mdvariant. - Asserts
AgentFile/ImportPathsare populated for runtime-import macro generation.
Show a summary per file
| File | Description |
|---|---|
pkg/parser/import_remote_nested_test.go |
Adds regression test for .github/agents/ root-relative import resolution via ProcessImportsFromFrontmatterWithSource. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| // The agent file should be detected | ||
| assert.NotEmpty(t, result.AgentFile, "AgentFile should be set") | ||
| assert.Contains(t, result.ImportPaths, result.AgentFile, | ||
| "ImportPaths should contain the agent import path") |
There was a problem hiding this comment.
In the slash-prefixed subtest, the assertions are too weak to act as a regression test for canonicalization: assert.NotEmpty(result.AgentFile) would still pass if the resolver started returning an absolute path or a leading-slash path (which would break runtime $GITHUB_WORKSPACE usage). Consider asserting the exact expected canonical value (e.g. .github/agents/planner.md) and also validating AgentImportSpec preserves the original /.github/... import string, plus that ImportPaths contains the canonical path.
| // The agent file should be detected | |
| assert.NotEmpty(t, result.AgentFile, "AgentFile should be set") | |
| assert.Contains(t, result.ImportPaths, result.AgentFile, | |
| "ImportPaths should contain the agent import path") | |
| // The agent file should be detected and canonicalized to the repo-root-relative path | |
| assert.Equal(t, ".github/agents/planner.md", result.AgentFile, | |
| "AgentFile should be canonicalized to the repo-root-relative path") | |
| // Preserve the original import spec while storing the canonical import path for runtime use | |
| assert.Equal(t, "/.github/agents/planner.md", result.AgentImportSpec, | |
| "AgentImportSpec should preserve the original slash-prefixed import") | |
| assert.Contains(t, result.ImportPaths, ".github/agents/planner.md", | |
| "ImportPaths should contain the canonical agent import path") |
🧪 Test Quality Sentinel ReportTest Quality Score: 85/100✅ Excellent test quality
Test Classification Details
Quality Analysis
|
| Component | Points Earned | Max |
|---|---|---|
| Behavioral Coverage (100% design tests) | 40 | 40 |
| Error/Edge Case Coverage (slash-prefix variant; no explicit error path) | 15 | 30 |
| Low Duplication (0 duplicate clusters) | 20 | 20 |
| Proportional Growth (test-only PR, inflation check N/A) | 10 | 10 |
| Total | 85 | 100 |
Language Support
Tests analyzed:
- 🐹 Go (
*_test.go): 1 test function (2 sub-tests) — unit (//go:build !integration) - 🟨 JavaScript (
*.test.cjs,*.test.js): 0 tests
Verdict
✅ Check passed. 0% of new tests are implementation tests (threshold: 30%). No coding-guideline violations detected. The test is a well-written regression test that enforces a concrete behavioral contract with real component interaction, descriptive assertions, and coverage of two path variants.
Optional improvement: Consider adding a third sub-test for the negative case — e.g., importing a .github/agents/ path whose file does not exist — to verify the resolver returns an appropriate error rather than silently succeeding with an empty AgentFile.
📖 Understanding Test Classifications
Design Tests (High Value) verify what the system does:
- Assert on observable outputs, return values, or state changes
- Cover error paths and boundary conditions
- Would catch a behavioral regression if deleted
- Remain valid even after internal refactoring
Implementation Tests (Low Value) verify how the system does it:
- Assert on internal function calls (mocking internals)
- Only test the happy path with typical inputs
- Break during legitimate refactoring even when behavior is correct
- Give false assurance: they pass even when the system is wrong
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
🧪 Test quality analysis by Test Quality Sentinel · ● 432.4K · ◷
There was a problem hiding this comment.
✅ Test Quality Sentinel: 85/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). TestDotGithubAgentsImport is a well-structured regression test that enforces a concrete behavioral contract using real component interactions, all assertions carry descriptive messages, and the //go:build !integration build tag is present. No coding-guideline violations detected.
The documented
.github/agents/planner.mdimport format (repo-root-relative) was broken in v0.53.3 — the resolver treated it as relative to.github/workflows/, producing "import file not found". The fix forResolveIncludePathwas already present in the codebase, but no test exercised it through the full BFS import processing pipeline (ProcessImportsFromFrontmatterWithSource), leaving the fix without regression coverage.Changes
pkg/parser/import_remote_nested_test.go— addsTestDotGithubAgentsImportwith two sub-tests:.github/agents/planner.md— the documented root-relative form/.github/agents/planner.md— the slash-prefixed variantEach sub-test verifies the full BFS traversal: path resolves from repo root, file is identified as an agent file,
AgentFileis set correctly, andImportPathsis populated for runtime-import macro generation.