Skip to content

fix(spec): avoid inferred metadata from included specs - #786

Merged
jdx merged 2 commits into
mainfrom
agent/remove-missing-name-lint
Aug 9, 2026
Merged

fix(spec): avoid inferred metadata from included specs#786
jdx merged 2 commits into
mainfrom
agent/remove-missing-name-lint

Conversation

@jdx

@jdx jdx commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • keep filename-derived name and bin metadata limited to the top-level spec
  • parse included fragments without inferring metadata from their filenames
  • remove the unreachable missing-name lint and accept omitted metadata consistently for files and stdin
  • add regression coverage for both behaviors

Root cause

Spec::parse_file() intentionally derives a missing bin from the filename and then derives name from bin. This caused two related inconsistencies:

  • file-based linting could never trigger missing-name, while stdin linting could because it has no filename
  • include also called parse_file(), so an empty included fragment acquired its own filename as metadata and overwrote the parent spec, producing a spurious missing-cmd-help

The fallback now applies only to the top-level file. Explicit metadata in included specs still merges normally.

Closes #784.
Closes #785.

Validation

  • cargo fmt --all -- --check
  • cargo test --all --all-features
  • cargo clippy --all --all-features -- -D warnings
  • reproduced both reported cases with metadata-free file/stdin input and an empty included override

AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.

Summary by CodeRabbit

  • Bug Fixes
    • Removed an unnecessary lint warning for specifications that omit both a name and a binary.
    • Such specifications are now accepted without lint issues.
    • Prevented included specification files from incorrectly inheriting their filenames as names or binary identifiers.
    • Preserved metadata inferred from the primary specification file while ignoring metadata from included files.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Filename metadata inference now applies to root specs but not included specs. The unreachable missing-name lint warning was removed. Regression tests cover both parsing behavior and argument-only specifications.

Changes

Spec metadata and lint behavior

Layer / File(s) Summary
Control filename metadata inference
lib/src/spec/mod.rs
Root parsing retains filename-based name and bin inference. Included specs disable this inference. A regression test verifies the root and included metadata behavior.
Remove unreachable lint warning
cli/src/cli/lint.rs
The missing-name warning is removed. A test confirms that an argument-only specification is lint-clean.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: gaojunran

Poem

A rabbit parses files with care,
Root names stay, includes stay bare.
The lint trail has no warning sign,
Tests hop through each changed line.
Clean specs greet the morning air.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR resolves issue #785 by removing the unreachable warning and testing specs without explicit name or bin.
Out of Scope Changes check ✅ Passed The parser adjustment and regression tests support consistent metadata and lint behavior described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main parser change that prevents metadata inference for included specs.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the missing-name lint and prevents included files from contributing filename-inferred metadata to their parent spec.

  • Accepts metadata-free specs consistently for file and stdin linting.
  • Parses included specs without inferring their names or binaries from included filenames.
  • Adds regression coverage for both behaviors.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
cli/src/cli/lint.rs Removes the metadata warning and adds coverage showing metadata-free specs are accepted.
lib/src/spec/mod.rs Separates file parsing from filename metadata inference so included files cannot overwrite root metadata with their filenames.

Reviews (2): Last reviewed commit: "fix(spec): avoid inferred metadata from ..." | Re-trigger Greptile

Comment thread cli/src/cli/lint.rs
let spec: Spec = r#"arg "<file>" help="The file to process""#.parse().unwrap();

let issues = lint_spec(&spec);
assert!(issues.is_empty());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Overbroad regression assertion

Requiring the entire issue list to be empty couples this regression test to every independent lint rule, so legitimate new diagnostics will break the test even when metadata-free specs remain accepted. Check specifically that missing-name is absent instead.

Suggested change
assert!(issues.is_empty());
assert!(!issues.iter().any(|i| i.code == "missing-name"));

Knowledge Base Used: CLI Command Dispatch (usage binary)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
markdown ▂▂▁▂▆▆▆▇▆▆█▇▇▇▇ 110,538,839 → 110,531,340 -0.01% 11.10 → 15.98ms +43.93%
startup ▁▂▃▂▂▂▂▃▃▂▄▅██▅ 1,204,352 → 1,200,480 -0.32% 0.95 → 1.08ms +13.89%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

23cb52a06f8d vs 996949938884 · measured on the runner, not pushed to the history.

@jdx jdx changed the title fix(cli): remove unreachable missing-name lint fix(spec): avoid inferred metadata from included specs Aug 9, 2026
@jdx
jdx merged commit 212b5e0 into main Aug 9, 2026
9 checks passed
@jdx
jdx deleted the agent/remove-missing-name-lint branch August 9, 2026 14:17
@jdx jdx mentioned this pull request Aug 9, 2026
@mise-en-dev mise-en-dev mentioned this pull request Aug 9, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 11, 2026
⚠️ **CAUTION: this is a major update, indicating a breaking change!** ⚠️

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [usage](https://github.com/jdx/usage) | tools | major | `3.5.6` → `5.1.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/usage (usage)</summary>

### [`v5.1.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#510---2026-08-09)

[Compare Source](jdx/usage@v5.0.0...v5.1.0)

##### 🚀 Features

- **(spec)** parse usage comments from strings by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;782](jdx/usage#782)

##### 🐛 Bug Fixes

- **(spec)** avoid inferred metadata from included specs by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;786](jdx/usage#786)

##### 🧪 Testing

- **(windows)** make the suite runnable on Windows by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;771](jdx/usage#771)

##### 📦️ Dependency Updates

- update rust crate rmcp to v3 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;780](jdx/usage#780)

### [`v5.0.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#500---2026-08-02)

[Compare Source](jdx/usage@v4.1.0...v5.0.0)

##### 🚀 Features

- **(cli)** allow overriding the shell program with USAGE\_SHELL\_<SHELL> by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;767](jdx/usage#767)

##### 🐛 Bug Fixes

- **(cli)** forward parsed args to WSL bash via WSLENV on windows by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;764](jdx/usage#764)
- **(cli)** let generate markdown write to stdout by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;766](jdx/usage#766)
- **(complete)** use `type -P` so the CLI-presence guard ignores shell functions by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;760](jdx/usage#760)
- **(parse)** enforce double\_dash="required" for positional args by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;762](jdx/usage#762)
- **(windows)** run `run=` scripts with sh when available by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;765](jdx/usage#765)

##### 🎨 Styling

- fix clippy and deprecation warnings in test and bench targets by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;763](jdx/usage#763)

### [`v4.1.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#410---2026-07-30)

[Compare Source](jdx/usage@v4.0.0...v4.1.0)

##### 🚀 Features

- **(cli)** declare what each usage command does to the world by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;751](jdx/usage#751)
- **(mcp)** serve a usage spec to an agent over stdio by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;746](jdx/usage#746)
- **(spec)** add a top-level `repository` field by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;747](jdx/usage#747)

##### 🐛 Bug Fixes

- **(parse)** keep a re-declared global's aliases on one flag by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;752](jdx/usage#752)
- complete repeated variadic args by [@&#8203;Jai-JAP](https://github.com/Jai-JAP) in [#&#8203;753](jdx/usage#753)

##### New Contributors

- [@&#8203;Jai-JAP](https://github.com/Jai-JAP) made their first contribution in [#&#8203;753](jdx/usage#753)

### [`v4.0.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#400---2026-07-25)

[Compare Source](jdx/usage@v3.6.0...v4.0.0)

##### 🚀 Features

- **(spec)** allow effect= on flags and args by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;742](jdx/usage#742)

### [`v3.6.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#360---2026-07-25)

[Compare Source](jdx/usage@v3.5.7...v3.6.0)

##### 🚀 Features

- **(spec)** add effect= to declare what a command does to the world by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;739](jdx/usage#739)

##### 🚜 Refactor

- **(spec)** make missed SpecCommand fields a compile error, and fix the four that were already missed by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;740](jdx/usage#740)

### [`v3.5.7`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#357---2026-07-25)

[Compare Source](jdx/usage@v3.5.6...v3.5.7)

##### 🐛 Bug Fixes

- **(parse)** don't leak the mounting CLI's flags into mounted commands; scan past non-global flags by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;738](jdx/usage#738)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWFqb3IiXX0=-->
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.

missing-name lint check never triggered includes file=<path> immediately violates missing-cmd-help lint check

1 participant