Repository navigation
refactor(slash_commands): split parse and the module, no behaviour change - #60
Merged
Merged
Conversation
…ange The code auditor measured src/cli/slash_commands.rs at 2399 lines, fan-out 394, `SlashCommand::parse` at cyclomatic complexity 57 and `handle_roadmap` at 112 lines. - `parse` is now a lookup in `SPELLINGS`, a table of every spelling with the parser for its argument; the commands that need more than "keep the argument" (/rewind, /remember, /forget, /kill, /bg, /image) each have a named helper. No function in the module now exceeds complexity 20 or 100 lines. - `handle_roadmap` reads as its steps: `ready_brief` (the four gate outcomes, four messages), `mark_proven_done`, `say_what_cannot_prove`. - The file is a module directory, one file per command family: parse, session, status, memory, agents, workspace, tools; mod.rs keeps the enum, COMMANDS and /help and re-exports every handler, so no caller changed. The largest file is agents.rs at 718 lines. Equivalence: a table pinning every spelling of every command, with and without its argument and each usage text, was added and passed on the original code first, then on the split. A second test holds that no spelling is listed twice, which the old `match` got from the compiler. Every existing test moved with its code, unchanged.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Answers code-auditor findings 8626e7d823e143d3, 2e6d084023ccf97a, 847a3ecc41a89f98 and 3abe5c8d5c43e040 on
src/cli/slash_commands.rs.Measured before
SlashCommand::parse: cyclomatic complexity 57 (threshold 20)handle_roadmap: 112 lines (threshold 100)What changed
parselooks the command word up inSPELLINGS, a table of every spelling with the parser for its argument./rewind,/remember,/forget,/kill,/bgand/imageeach get a named helper.handle_roadmapnow calls three steps in order:ready_brief,mark_proven_done,say_what_cannot_prove. The text and the order of what it prints are the same.slash_commands.rsbecameslash_commands/with one file per command family.mod.rskeeps the enum,COMMANDSand/help, and glob re-exports every handler, so no caller changed.Measured after (same auditor)
No function in the module is over complexity 20 or 100 lines, and no file is over 1000 lines. The longest function is
roles_commandat 98 lines, which this PR does not change. The only findings left are fan-out, now 34 to 157 per file instead of 394 for the one file.Equivalence
no_spelling_is_listed_twice. The oldmatchgot this check from the compiler as an unreachable-pattern warning; a table does not.wiringratchet passes at the same count.Local gate (Windows):
cargo fmt --all -- --check,cargo clippy --all-targets -q -- -D warnings,cargo test -qall pass.