os-aidd-lint: harden new skill cops — Document#artifact_type unit tests, YAML-aware allowed-tools parsing #178

Closed
opened 2026-07-30 20:41:35 +00:00 by jared · 2 comments
Owner

Follow-ups from the 2026-07-30 cop implementation: artifact_type covered only via cop-level tests; BroadAllowedTools uses substring matching, not YAML flow-list parsing.

Follow-ups from the 2026-07-30 cop implementation: artifact_type covered only via cop-level tests; BroadAllowedTools uses substring matching, not YAML flow-list parsing.
Author
Owner

This was generated by AI during triage.

Problem: Document#artifact_type (plugins/os-aidd-lint/lib/aidd_lint/document.rb:38-46) returns one of :skill, :claude_md, :agent, :reference, :prompt, :other and is only exercised indirectly via cop tests; no dedicated unit test enumerates all six branches. BroadAllowedTools (plugins/os-aidd-lint/lib/aidd_lint/cops/broad_allowed_tools.rb:12,26-27) matches BARE_BASH against frontmatter.top_level_value('allowed-tools').to_s, a raw string — a YAML flow list like allowed-tools: [Bash(git status:*), Read] is stringified and substring-matched, not parsed, so a scoped Bash(...) entry inside a list can still false-positive/negative depending on formatting.

Solution: Add tests/document_test.rb (or extend existing) asserting artifact_type for one fixture per basename/path pattern (SKILL.md, CLAUDE.md, agents/.md, references/.md, prompts/*.md, other). For BroadAllowedTools, parse allowed-tools as YAML (flow or block list) and check each entry for a bare Bash/Bash(*) token instead of substring-matching the joined string.

Examples: Must still flag allowed-tools: Bash. Must NOT flag allowed-tools: [Bash(git status:*), Read] once YAML-parsed per-entry (current substring match may already handle this case correctly by accident — verify via fixture, don't assume).

> *This was generated by AI during triage.* **Problem:** `Document#artifact_type` (plugins/os-aidd-lint/lib/aidd_lint/document.rb:38-46) returns one of `:skill, :claude_md, :agent, :reference, :prompt, :other` and is only exercised indirectly via cop tests; no dedicated unit test enumerates all six branches. `BroadAllowedTools` (plugins/os-aidd-lint/lib/aidd_lint/cops/broad_allowed_tools.rb:12,26-27) matches `BARE_BASH` against `frontmatter.top_level_value('allowed-tools').to_s`, a raw string — a YAML flow list like `allowed-tools: [Bash(git status:*), Read]` is stringified and substring-matched, not parsed, so a scoped `Bash(...)` entry inside a list can still false-positive/negative depending on formatting. **Solution:** Add `tests/document_test.rb` (or extend existing) asserting `artifact_type` for one fixture per basename/path pattern (SKILL.md, CLAUDE.md, agents/*.md, references/*.md, prompts/*.md, other). For BroadAllowedTools, parse `allowed-tools` as YAML (flow or block list) and check each entry for a bare `Bash`/`Bash(*)` token instead of substring-matching the joined string. **Examples:** Must still flag `allowed-tools: Bash`. Must NOT flag `allowed-tools: [Bash(git status:*), Read]` once YAML-parsed per-entry (current substring match may already handle this case correctly by accident — verify via fixture, don't assume).
Author
Owner

Implemented via os-sdlc pipeline (test-writer -> red -> programmer -> green -> ac-lint -> lint -> reviewer APPROVE). Merged to main in d180310.

Implemented via os-sdlc pipeline (test-writer -> red -> programmer -> green -> ac-lint -> lint -> reviewer APPROVE). Merged to main in d180310.
jared 2026-08-01 18:12:59 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#178
No description provided.