Skip to content

Comments

fix: add missing boolean flags to telemetry command extraction#438

Merged
stack72 merged 1 commit intomainfrom
fix-telemetry-boolean-flag-parsing
Feb 24, 2026
Merged

fix: add missing boolean flags to telemetry command extraction#438
stack72 merged 1 commit intomainfrom
fix-telemetry-boolean-flag-parsing

Conversation

@stack72
Copy link
Contributor

@stack72 stack72 commented Feb 24, 2026

Summary

  • Fixed telemetry misreporting caused by missing boolean flags in extractCommandInfo's isKnownFlag() function
  • Added 7 regression tests covering all previously-missing flags
  • Removed stale --stream option that doesn't exist in the CLI

Problem

The telemetry pre-parser (extractCommandInfo in telemetry_integration.ts) uses isKnownFlag() to determine whether a CLI flag is boolean (takes no value) or expects a value argument. When a boolean flag is not listed in isKnownFlag(), 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 in mod.ts)
  • --show-properties (global option defined in mod.ts)

Because global flags appear before the command name in the argument list, these caused the command itself to be misidentified:

swamp --no-color model create prompt my-thing

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 model to 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 (update command)
  • --verify (repo index command)
  • --prune (repo index command)
  • --streaming (data search command)
  • --last-evaluated (workflow run and model method run commands)

Cleanup

Removed stale --stream from both GLOBAL_OPTIONS and isKnownFlag — it is not an actual CLI option defined anywhere.

Test plan

  • Added regression tests for --no-color before command (the critical case)
  • Added regression tests for --show-properties before command
  • Added regression test for --no-color combined with --json
  • Added regression tests for --last-evaluated, --check, --verify, --prune, --streaming
  • All 23 telemetry integration tests pass
  • deno check passes
  • deno lint passes
  • deno fmt passes

🤖 Generated with Claude Code

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>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

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 any types - follows TypeScript strict mode
  • ✅ Uses named exports correctly
  • ✅ Test file lives next to source (telemetry_integration_test.ts)
  • ✅ Uses @std/assert for 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.

@stack72 stack72 merged commit 69631cc into main Feb 24, 2026
4 checks passed
@stack72 stack72 deleted the fix-telemetry-boolean-flag-parsing branch February 24, 2026 00:38
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.

1 participant