fix: add missing boolean flags to telemetry command extraction#438
Merged
fix: add missing boolean flags to telemetry command extraction#438
Conversation
The `extractCommandInfo` pre-parser uses `isKnownFlag()` to identify boolean flags (flags that don't take a value argument). When a boolean flag is missing from this list, the parser assumes it takes a value and consumes the next positional argument as that value — silently swallowing the command or subcommand name. Two global flags were missing (`--no-color`, `--show-properties`), causing commands like `swamp --no-color model create` to misidentify "model" as the value of `--no-color` and record a wrong or empty command in telemetry. Five per-command boolean flags were also missing (`--check`, `--verify`, `--prune`, `--streaming`, `--last-evaluated`), which could cause positional argument misclassification after the command/subcommand. Also removes stale `--stream` from both `GLOBAL_OPTIONS` and `isKnownFlag` — it is not an actual CLI option. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
PR Review: fix: add missing boolean flags to telemetry command extraction
Decision: Approved ✅
This is a well-executed bug fix that addresses a real telemetry misreporting issue.
Code Quality & CLAUDE.md Compliance
- ✅ No
anytypes - follows TypeScript strict mode - ✅ Uses named exports correctly
- ✅ Test file lives next to source (
telemetry_integration_test.ts) - ✅ Uses
@std/assertfor assertions as required - ✅ AGPLv3 copyright header present in both files
- ✅ CI passes (
deno check,deno lint,deno fmt, tests)
Domain-Driven Design Review
The changes are appropriately scoped to the CLI adapter layer. The telemetry pre-parser (extractCommandInfo) is infrastructure code that transforms CLI args into the domain's CommandInvocationData type. This separation is correct - the domain defines the data structure, and the CLI adapter handles parsing.
Test Coverage
- 7 new regression tests added covering all previously-missing flags
- Tests verify both global options (
--no-color,--show-properties) and command-specific options (--check,--verify,--prune,--streaming,--last-evaluated) - Test for critical case (global flag consuming command name) is properly covered
Security
- ✅ Telemetry properly redacts user-identifiable values with
<REDACTED> - ✅ Only categorical/safe values are recorded
- No PII leakage concerns
Verification
I verified all added flags exist in the CLI:
--no-color:src/cli/mod.ts:267--show-properties:src/cli/mod.ts:264--check:src/cli/commands/update.ts:33--verify:src/cli/commands/repo_index.ts:38--prune:src/cli/commands/repo_index.ts:39--streaming:src/cli/commands/data_search.ts:330--last-evaluated:src/cli/commands/workflow_run.ts:158,model_method_run.ts:67
Confirmed --stream removal is correct - no such flag exists anywhere in src/.
No Blocking Issues
Suggestions (non-blocking)
None - this is a clean, focused fix with appropriate tests. The PR description is thorough and explains the problem well.
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
extractCommandInfo'sisKnownFlag()function--streamoption that doesn't exist in the CLIProblem
The telemetry pre-parser (
extractCommandInfointelemetry_integration.ts) usesisKnownFlag()to determine whether a CLI flag is boolean (takes no value) or expects a value argument. When a boolean flag is not listed inisKnownFlag(), the parser assumes it takes a value and consumes the next positional argument as that value — silently swallowing the command or subcommand name from the telemetry record.Critical: Global flags
Two global flags were missing from
isKnownFlag():--no-color(global option defined inmod.ts)--show-properties(global option defined inmod.ts)Because global flags appear before the command name in the argument list, these caused the command itself to be misidentified:
Before fix:
command: "create",subcommand: "prompt"(wrong — "model" was consumed as--no-color's value)After fix:
command: "model",subcommand: "create"(correct)In the worst case (
swamp --no-color modelto view help), the command would be recorded as an empty string with no subcommand — explaining the "swamp with no subcommand" entries seen in Mixpanel.Lower impact: Per-command flags
Five per-command boolean flags were also missing. These appear after the command/subcommand are identified, so they don't break command identification, but they cause positional arguments to be swallowed:
--check(updatecommand)--verify(repo indexcommand)--prune(repo indexcommand)--streaming(data searchcommand)--last-evaluated(workflow runandmodel method runcommands)Cleanup
Removed stale
--streamfrom bothGLOBAL_OPTIONSandisKnownFlag— it is not an actual CLI option defined anywhere.Test plan
--no-colorbefore command (the critical case)--show-propertiesbefore command--no-colorcombined with--json--last-evaluated,--check,--verify,--prune,--streamingdeno checkpassesdeno lintpassesdeno fmtpasses🤖 Generated with Claude Code