-
-
Notifications
You must be signed in to change notification settings - Fork 31
feat(claude-code): add output-style validator (CC-OS-001..005) #757
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
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "task": { | ||
| "id": "output-style-validator", | ||
| "source": "manual", | ||
| "title": "PR2: output-style validator (post-#745 follow-on)" | ||
| }, | ||
| "workflow": { | ||
| "id": "output-style-validator", | ||
| "status": "active", | ||
| "currentPhase": "setup", | ||
| "createdAt": "2026-04-22T00:00:00Z", | ||
| "updatedAt": "2026-04-22T00:00:00Z" | ||
| }, | ||
| "git": { | ||
| "branch": "feat/output-style-validator", | ||
| "baseBranch": "main", | ||
| "baseSha": "3c4a3a9", | ||
| "mainRepoPath": "C:/Users/avife/agent-sh/agnix", | ||
| "isWorktree": true | ||
| }, | ||
| "context": { | ||
| "description": "Add output-style validator for Claude Code output-style files (.claude/output-styles/*.md) - new FileType in agnix-core. Follow-on from triage of issue #745 which merged as PR #756. The keep-coding-instructions field was surfaced during #745 triage.", | ||
| "relatedIssue": "#745", | ||
| "relatedMergedPR": "#756" | ||
| } | ||
| } |
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,78 @@ | ||
| # PR2 Exploration Report - Output-Style Validator | ||
|
|
||
| ## A. Reference template | ||
|
|
||
| Picked: ClaudeRule (FileType::ClaudeRule, validator ClaudeRulesValidator, schema ClaudeRuleSchema) | ||
|
|
||
| Why: | ||
| - Same tool family (Claude Code), same path pattern (.claude/<subdir>/*.md) | ||
| - Only 2 rules (CC-MEM-011, CC-MEM-012) - simplest possible CC-family validator | ||
| - Self-contained YAML frontmatter schema using serde_yaml + heuristic unknown-key detection | ||
| - Valid and invalid fixtures exist under tests/fixtures/valid/claude-rules/ and invalid/claude-rules/ | ||
| - No extra crate dependencies beyond serde_yaml | ||
| # Step map | ||
|
|
||
| 1. types.rs - add ClaudeOutputStyle variant after ClaudeRule (line 42) | ||
| 2. detection.rs - add output-styles arm after ClaudeRule arm (lines 381-386) | ||
| 3. schemas/output_style.rs - new file, mirror claude_rules.rs | ||
| 4. schemas/mod.rs - add pub mod output_style at line 33 | ||
| 5. rules/output_style.rs - new file, mirror claude_rules.rs | ||
| 6. rules/mod.rs - add pub mod output_style at line 32 | ||
| 7. registry.rs - EXPECTED_BUILTIN_COUNT 73->74, new factory fn, ClaudeProvider entry, test array 42->43 | ||
| 8. knowledge-base/rules.json - increment total_rules, add N CC-OS entries | ||
| 9. crates/agnix-rules/rules.json - cp from knowledge-base/rules.json | ||
| 10. knowledge-base/VALIDATION-RULES.md - new section, footer count | ||
| 11. tests/fixtures/ - valid and invalid output-style fixtures | ||
| 12. output_style.rs tests - co-located #[cfg(test)] mod tests | ||
|
|
||
| # Additional files | ||
|
|
||
| - config/rule_filter.rs: add CC-OS- branch to is_category_enabled() | ||
| - config.rs: add output_styles: bool to RuleConfig | ||
| - rule_parity.rs: add CC-OS- to valid_prefixes, claude-output-styles to valid_categories, fixture mapping | ||
| # B. Naming confirmations | ||
|
|
||
| CC-OS- prefix: Zero existing rules, no collision confirmed. | ||
| FileType::ClaudeOutputStyle: Matches convention (ClaudeRule, ClaudeMd). | ||
| OutputStyleSchema: Consistent with ClaudeRuleSchema. | ||
| OutputStyleValidator: Consistent with ClaudeRulesValidator. | ||
|
|
||
| # C. Implementation gotchas | ||
|
|
||
| 1. EXPECTED_BUILTIN_COUNT sentinel (registry.rs line 401): +1 per validator entry. 73->74. Test array [FileType; 42] -> [FileType; 43]. | ||
|
|
||
| 2. Exhaustive match arrays in types.rs tests: three functions list every FileType variant in typed arrays; all must include ClaudeOutputStyle or compile fails. | ||
|
|
||
| 3. rule_parity.rs valid_prefixes (line 167): CC-OS- must be listed or test_all_rules_implemented fails. | ||
|
|
||
| 4. rule_parity.rs valid_categories (line 509): test_rules_json_integrity panics on unknown category; add claude-output-styles. | ||
|
|
||
| 5. rule_parity.rs infer_fixture_coverage (line 280): test_fixture_coverage_exists fails without claude-output-styles -> directory mapping. | ||
|
|
||
| 6. i18n locale files: Avoid rust_i18n::t!() for CC-OS rules; use inline strings to skip editing en.yml, es.yml, zh-CN.yml. | ||
|
|
||
| 7. Hyphenated YAML key keep-coding-instructions: Cannot use #[serde(rename)] with hyphens. Extract manually from serde_yaml::Mapping as done for paths in claude_rules.rs. | ||
|
|
||
| 8. VALIDATION-RULES.md anchor: Parity test looks for <a id=cc-os-001></a> (lowercase ID). | ||
|
|
||
| 9. Autofix footer count: stays at 126 if no CC-OS rules have autofix:true. | ||
|
|
||
| 10. Clippy Rust 1.95 -D warnings (CI stricter than local 1.92): avoid unnecessary_sort_by (use .sort()), needless_borrows_for_generic_args, unnecessary_literal_unwrap (use .expect()), gate unix-only imports with #[cfg(unix)]. | ||
|
|
||
| 11. total_rules in rules.json: test_rules_json_integrity asserts total_rules == rules.len(); always sync. | ||
|
|
||
| 12. test_sum_of_category_providers_equals_expected (registry.rs line 1947): Must match EXPECTED_BUILTIN_COUNT; ClaudeProvider entry and constant must change together. | ||
|
|
||
| 13. Safe execution order: schema -> validator -> file_types -> registry -> config.rs -> rule_filter.rs -> rules.json (both copies) -> VALIDATION-RULES.md -> fixtures -> rule_parity.rs. Run cargo test --workspace before adding fixtures. | ||
|
|
||
| # D. Proposed rule set (CC-OS-001 through CC-OS-005) | ||
|
|
||
| | ID | Name | Severity | Normative | Checks | Bad example | | ||
| |---|---|---|---|---|---| | ||
| | CC-OS-001 | Missing Output Style Description | LOW | SHOULD | description absent or empty; needed for /config picker label | name without description in frontmatter | | ||
| | CC-OS-002 | Invalid keep-coding-instructions Type | HIGH | MUST | keep-coding-instructions present but not YAML boolean; e.g. string yes, number 1, null | keep-coding-instructions: yes (quoted string) | | ||
| | CC-OS-003 | Unknown Output Style Frontmatter Key | MEDIUM | SHOULD | Top-level key not in {name, description, keep-coding-instructions}; signals typo or wrong file type | paths: - src/** (a rules field, not output-style) | | ||
| | CC-OS-004 | Empty Output Style Body | MEDIUM | SHOULD | Body after closing --- (or entire file if no frontmatter) is blank/whitespace-only; dead config | frontmatter with blank body | | ||
| | CC-OS-005 | Output Style Name Too Long | LOW | SHOULD | name value exceeds 64 chars; truncates in /config picker UI | name: this-is-a-very-long-style-name-exceeding-64-chars | | ||
|
|
||
| Omissions: name format constraints not documented; name not required (defaults to filename); CC-OS-006 (name+filename) over-specified for optional field. |
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion upper bound was bumped here, but the nearby comment still says “~385 rules” (it’s now 404). Please update that comment to match current reality so the threshold rationale stays accurate.