feat(vg-helper): canonical command registry with split exit codes#104
Open
majiayu000 wants to merge 2 commits intomainfrom
Open
feat(vg-helper): canonical command registry with split exit codes#104majiayu000 wants to merge 2 commits intomainfrom
majiayu000 wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Hook Latency (P95)
Details
| Benchmark suite | Current: 796eec9 | Previous: 075c3ed | Ratio |
|---|---|---|---|
pre-edit-guard (P95) |
196 ms |
188 ms |
1.04 |
pre-write-guard (P95) |
229 ms |
213 ms |
1.08 |
pre-bash-guard (P95) |
277 ms |
255 ms |
1.09 |
post-edit-guard (100) (P95) |
324 ms |
298 ms |
1.09 |
post-write-guard (100) (P95) |
223 ms |
208 ms |
1.07 |
post-edit-guard (5000) (P95) |
333 ms |
314 ms |
1.06 |
post-write-guard (5000) (P95) |
238 ms |
209 ms |
1.14 |
stop-guard (5000) (P95) |
140 ms |
132 ms |
1.06 |
learn-evaluator (5000) (P95) |
141 ms |
132 ms |
1.07 |
This comment was automatically generated by workflow using github-action-benchmark.
Replace the duplicated help-text + dispatch match in main.rs with a static COMMANDS table (name, usage, handler fn-ptr). Help is now generated from the registry, so adding a command cannot silently drift the help text. Exit codes are split at the CLI boundary: unknown/missing command → 2 (user-input error), handler Err → 1 (execution error). Also fix a pre-existing test flakiness in session_metrics: parse the last JSONL line rather than the whole file content, which failed on repeated test runs due to file appending in a persistent temp dir. Integration tests in tests/cli.rs cover all five contract cases and double as a registry-completeness assertion (all 8 command names in help). Signed-off-by: majiayu000 <1835304752@qq.com>
The command registry split exit codes at the main entrypoint, but json-field and json-two-fields still treated malformed stdin JSON as a blank result. Return parse errors instead so invalid input exits 1 while missing fields remain blank. Signed-off-by: majiayu000 <1835304752@qq.com>
8077f63 to
796eec9
Compare
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.
Summary
matchinmain.rswith a staticCOMMANDStable (name, usage, handler fn-ptr); help is generated from the registry, eliminating drift between help text and dispatch logicErr→ exit 1 (execution error)vg-helper/tests/cli.rswith 5 integration tests; thehelp_lists_all_8_commandstest acts as a registry-completeness assertionTest plan
cargo check— clean (verified locally)cargo test— 28/28 pass: 23 unit tests + 5 new integration tests (verified locally)test_run_produces_learn_suggested_and_appends_metricsfixed (parse last JSONL line, not whole file)Closes #102