Skip to content

config: generic commands.<report> overwrites commands."<source> <report>" #2000

Closed

Description

@viniciusdsandrade

What happened?

In ccusage.json, when both a generic report section (such as commands.daily) and a source-specific space-form command section (such as commands."codex daily") are defined, the generic report section overwrites the source-specific section:

{
  "commands": {
    "daily": {
      "mode": "display"
    },
    "codex daily": {
      "mode": "calculate"
    }
  }
}

When running ccusage codex daily or resolving codex in ccusage daily, mode is evaluated as display rather than calculate.

In rust/crates/ccusage-config/src/config.rs:136-150 (ConfigContext::option_maps), commands[&self.command.raw] ("codex daily") is pushed to maps before commands[&self.command.report] ("daily"). Because maps apply sequentially and later entries override earlier ones, commands.daily clobbers commands."codex daily".

In contrast, the colon form commands."codex:daily" is pushed after commands.daily, so codex:daily correctly wins over daily. Space-form commands should have the same precedence as colon-form commands and override the generic report section.

Steps to reproduce

  1. Create a ccusage.json with:
{
  "commands": {
    "daily": {
      "mode": "display",
      "since": "20260101"
    },
    "codex daily": {
      "mode": "calculate"
    }
  }
}
  1. Run ccusage codex daily --json --offline.
  2. Observed: the command runs in display mode instead of calculate mode.

Expected behavior

commands."codex daily" takes precedence over commands.daily, so ccusage codex daily runs in calculate mode with since = "20260101", matching the documented option precedence in docs/guide/config-files.md.

Version

20.0.46 (and commit 5aa9d3f on main)

Activity

  1. pullfrog commented on Oct 31, 2026

    @pullfrog
    Contributor
  2. added
    bugSomething isn't working
    priority:mediumA normal bug or meaningful improvement.
    triage:maintainableFits the repository's maintainable scope and needs review.
    on Oct 31, 2026
  3. github-actions commented on Oct 31, 2026

    @github-actions
    Contributor

    Pullfrog triage: priority:medium
    Kind: bug
    Maintenance fit: maintainable
    Confidence: high

    Specific space-form command config is overridden by generic report config because option_maps applies generic after specific, opposite to documented precedence and colon-form behavior. Code read confirms the ordering defect with clear reproduction.

    Decision: kept open.

  4. viniciusdsandrade commented on Oct 31, 2026

    @viniciusdsandrade
    ContributorAuthor

    The fix is ready on my fork. GitHub rejects pull request creation from outside accounts on this repository (GraphQL CreatePullRequest reports missing permissions), so I am leaving the branch and compare links here:

    What it does: ConfigContext::option_maps now pushes generic report options (commands[&self.command.report]) before source-specific command sections (commands[&self.command.raw] and colon-form commands[&colon_name]) when an agent command is invoked or resolved for a unified source. This ensures both space-form and colon-form command settings consistently take precedence over generic report settings in commands, matching the option precedence hierarchy documented in docs/guide/config-files.md.

    Tests cover focused and unified source resolution for space-form commands alongside generic report sections. I reviewed the changes by reading and have not run the suite locally, so CI would be the first run.

    If you can approve the PR or pull the branch as with #1959, the fix is ready to merge.

  5. added a commit that references this issue on Nov 4, 2026
    de83d19
  6. ryoppippi commented on Nov 10, 2026

    @ryoppippi
    Member

    Note

    🤖 Claude Opus 5.5 responding on behalf of @ryoppippi

    Your fix landed in #2006, which kept your commits and credits you as co-author, and shipped in v20.0.47. Space-form sections such as commands."claude daily" now override the generic commands.daily. Thanks for preparing the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:mediumA normal bug or meaningful improvement.triage:maintainableFits the repository's maintainable scope and needs review.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions