Skip to content

fix(validation): directory links are valid navigational targets (#126)#130

Open
ejdutton wants to merge 1 commit into
mainfrom
fix/126-directory-links-valid-targets
Open

fix(validation): directory links are valid navigational targets (#126)#130
ejdutton wants to merge 1 commit into
mainfrom
fix/126-directory-links-valid-targets

Conversation

@ejdutton

Copy link
Copy Markdown
Collaborator

Summary

Closes #126.

  • Navigational markdown/HTML links to directories (e.g. [docs](docs/)) are now valid — existence-checked like any other local link.
  • LINK_TARGETS_DIRECTORY narrows to fire only when a packaging files: source entry resolves to a directory (a typed single-file slot); net-new emission added in packaging-validator.validateFilesConfig.
  • HTML inherits the corrected rule through the shared validateLocalFileLink path — corrects the strict behavior that feat: first-class local HTML resources (#112) #116 shipped.

See the [Unreleased] section of CHANGELOG.md for the full D1–D7 breakdown and the validation.allow migration note: existing allow entries targeting LINK_TARGETS_DIRECTORY for navigational links will surface as ALLOW_UNUSED.

Test plan

  • Unit: classifyLink('docs/') === 'local_directory'; classifyLink('docs') === 'local_file'; classifyLink('https://example.com/docs/') === 'external'
  • Unit lock-in (D6): validateLink returns null for external trailing-slash URLs without any filesystem check
  • Integration: navigational /docs/, ../, /docs all valid when target exists; missing /missing-dir/ still emits LINK_BROKEN_FILE (regression guard)
  • Integration: SKILL.md [Concepts](./concepts/) no longer emits LINK_TARGETS_DIRECTORY
  • Integration (D3 affirmative): files: [{ source: 'scripts', dest: ... }] (directory source) emits LINK_TARGETS_DIRECTORY
  • bun run validate green locally: lint, typecheck, unit, integration, system, duplication (3 clones, baseline), vat resources validate, dogfood vat build + vat verify
  • CI matrix on Node 22/24 × Ubuntu/Windows

🤖 Generated with Claude Code

…rrows to typed slots (#126)

A directory link is a legitimate navigational target. `[docs](docs/)` renders as
a navigable tree on GitHub; making it a hard error pushed authors into awkward
workarounds (repointing to `docs/README.md` to dodge the rule).

The rule was mis-scoped, not wrong in spirit. A directory is only a problem
for a typed single-file slot — a reference contractually one file (e.g. a
packaging `files:` source entry). It leaked into the general link path.

Implements D1–D7 from the issue:

- D1+D2: Delete the directory-error branch in the resources link-validator.
  A resolved directory now passes existence-checking like any file. The
  misnamed LINK_BROKEN_FILE "Link target is a directory" is gone.
- D3: The bundling link walk (`walk-link-graph`) silently skips directory
  targets — no exclusion record, no surfaced issue. `LINK_TARGETS_DIRECTORY`
  now fires only when a typed single-file slot resolves to a directory;
  net-new emission added in `packaging-validator.validateFilesConfig`.
- D4: New `local_directory` value in the `LinkType` enum; `classifyLink`
  returns it for local hrefs ending in `/`. Diagnostic hint only —
  validation treats it identically to `local_file`.
- D5: HTML inherits the corrected rule through the shared `classifyLink` →
  `validateLocalFileLink` path (PR #116 had shipped the strict behavior;
  this corrects it).
- D6: Explicit test confirms external trailing-slash URLs never trigger
  directory determination — filesystem-only is locked in.
- D7: `docs/validation-codes.md` records that GitHub-style index resolution
  (`docs/` → `docs/README.md`) is deliberately out of scope.

Migration: `validation.allow` entries for `LINK_TARGETS_DIRECTORY` against
navigational links no longer match any emitted issue and will surface as
`ALLOW_UNUSED`. `allow` entries against `files:` source paths still apply.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
37.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.72%. Comparing base (7f81588) to head (2a4267c).

Files with missing lines Patch % Lines
...agent-skills/src/validators/packaging-validator.ts 93.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
+ Coverage   81.68%   81.72%   +0.04%     
==========================================
  Files         225      225              
  Lines       17440    17430      -10     
  Branches     3405     3404       -1     
==========================================
- Hits        14246    14245       -1     
+ Misses       3194     3185       -9     
Files with missing lines Coverage Δ
packages/agent-schema/src/validation-codes.ts 100.00% <100.00%> (ø)
packages/agent-skills/src/skill-packager.ts 79.63% <100.00%> (-0.26%) ⬇️
...es/agent-skills/src/validators/walker-to-issues.ts 100.00% <ø> (ø)
packages/agent-skills/src/walk-link-graph.ts 95.85% <ø> (-1.79%) ⬇️
packages/resources/src/link-parser.ts 96.75% <100.00%> (+0.51%) ⬆️
packages/resources/src/link-validator.ts 85.38% <100.00%> (+3.72%) ⬆️
...agent-skills/src/validators/packaging-validator.ts 94.85% <93.33%> (+0.38%) ⬆️
Files with missing lines Coverage Δ
packages/agent-schema/src/validation-codes.ts 100.00% <100.00%> (ø)
packages/agent-skills/src/skill-packager.ts 79.63% <100.00%> (-0.26%) ⬇️
...es/agent-skills/src/validators/walker-to-issues.ts 100.00% <ø> (ø)
packages/agent-skills/src/walk-link-graph.ts 95.85% <ø> (-1.79%) ⬇️
packages/resources/src/link-parser.ts 96.75% <100.00%> (+0.51%) ⬆️
packages/resources/src/link-validator.ts 85.38% <100.00%> (+3.72%) ⬆️
...agent-skills/src/validators/packaging-validator.ts 94.85% <93.33%> (+0.38%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Slice 1 of #129: directory links are valid targets (narrow LINK_TARGETS_DIRECTORY to typed single-file slots)

1 participant