Skip to content

fix(source): rename --microseconds flag to --milliseconds#75

Merged
oritwoen merged 2 commits into
mainfrom
fix/rename-microseconds-to-milliseconds
Mar 13, 2026
Merged

fix(source): rename --microseconds flag to --milliseconds#75
oritwoen merged 2 commits into
mainfrom
fix/rename-microseconds-to-milliseconds

Conversation

@oritwoen

Copy link
Copy Markdown
Owner

Closes #68.

The --microseconds flag iterates 0..1000 per timestamp - that's millisecond granularity, not microsecond. Microseconds would be 0..1_000_000. The flag name was just wrong, so this renames it to --milliseconds to match what the code actually does.

Two files, pure rename, no behavior change.

The flag generates 1000 sub-second variants per timestamp (millisecond
granularity), not 1,000,000 (microsecond). The name was misleading.
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Rename --microseconds flag to --milliseconds for accuracy

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Rename --microseconds flag to --milliseconds for accuracy
• Flag generates 1000 sub-second variants (millisecond granularity), not microsecond
• Update all references in code, comments, and error messages
• Update test names and assertions to reflect correct terminology
Diagram
flowchart LR
  A["CLI Flag Definition"] -- "rename microseconds to milliseconds" --> B["main.rs"]
  C["TimestampSource struct"] -- "rename field and parameter" --> D["timestamps.rs"]
  E["Error messages & comments"] -- "update terminology" --> F["Consistency"]
  G["Test cases"] -- "rename and update assertions" --> H["Test accuracy"]
Loading

Grey Divider

File Changes

1. src/main.rs 🐞 Bug fix +3/-3

Rename CLI flag from microseconds to milliseconds

• Rename microseconds field to milliseconds in SourceCommand::Timestamps enum
• Update parameter name in create_source function call to TimestampSource::from_dates
• Update doc comment to clarify millisecond granularity

src/main.rs


2. src/source/timestamps.rs 🐞 Bug fix +13/-13

Rename struct field and update all references throughout

• Rename microseconds field to milliseconds in TimestampSource struct
• Rename parameter in from_dates constructor method
• Update all conditional checks from self.microseconds to self.milliseconds
• Update error messages and comments to reference milliseconds instead of microseconds
• Rename test function from process_counts_microseconds_mode_correctly to
 process_counts_milliseconds_mode_correctly
• Update test struct initialization to use milliseconds field

src/source/timestamps.rs


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Mar 13, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. No alias for old flag🐞 Bug ✓ Correctness
Description
The timestamps subcommand boolean option is defined with #[arg(long)] and was renamed to
milliseconds, which drops support for the previously-derived --microseconds flag and will cause
invocations using it to fail argument parsing. Add a backwards-compatible alias (or keep both flags)
to avoid breaking existing scripts.
Code

src/main.rs[R366-368]

       /// Also test milliseconds (1000x more keys)
       #[arg(long)]
-        microseconds: bool,
+        milliseconds: bool,
Evidence
The CLI flag is clap-derive generated from a field annotated with #[arg(long)]; the field is now
named milliseconds and has no alias configured, so the old long option name is no longer accepted.

src/main.rs[358-369]
Cargo.toml[21-25]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR renames the clap-derived long flag from `--microseconds` to `--milliseconds` by renaming the struct field, but it does not provide any backwards-compatible alias. This breaks any existing usage that still passes `--microseconds`.
### Issue Context
`clap` is used with the `derive` feature and the `timestamps` option is declared as `#[arg(long)]` without an explicit `alias`/`visible_alias`. With clap derive, the long option name is derived from the field name when not explicitly specified.
### Fix Focus Areas
- src/main.rs[358-369]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 890f36ca-4b68-490e-959d-c03af6b507f8

📥 Commits

Reviewing files that changed from the base of the PR and between e1e6ecf and c186e4d.

📒 Files selected for processing (1)
  • src/main.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main.rs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: benchmarks

📝 Walkthrough

Walkthrough

Renames the timestamps mode from "microseconds" to "milliseconds": CLI flag/field and TimestampSource API/field updated to milliseconds, and callers/tests adjusted to pass and assert the milliseconds mode while preserving behavior (1000 sub-values per second).

Changes

Cohort / File(s) Summary
CLI command definition
src/main.rs
Renamed SourceCommand::Timestamps field from microseconds: bool to milliseconds: bool; preserved --microseconds as an alias; updated call site to pass the renamed field to TimestampSource::from_dates.
Timestamp source implementation & tests
src/source/timestamps.rs, src/source/...tests*
Renamed parameter and struct field microsecondsmilliseconds; updated from_dates(...) signature and internal checks/messages to reference milliseconds mode; processing and workload multipliers remain the 1000x (milliseconds) behavior; tests updated accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A flag once promising micro delight,
Turned out to tick at thousandths each night.
Names now truthful, no more disguise,
Milliseconds reign — the CLI complies. ⏱️✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: renaming the --microseconds flag to --milliseconds for correctness.
Description check ✅ Passed The description clearly explains the mismatch (flag name vs actual behavior), references the closed issue, and confirms no behavior changes.
Linked Issues check ✅ Passed The PR directly addresses issue #68 by renaming the flag to --milliseconds, matching the actual implementation behavior (0..1000 iteration = milliseconds, not microseconds).
Out of Scope Changes check ✅ Passed All changes are strictly in scope: renamed field and parameter in two files, added deprecated alias, updated docs and tests. No unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rename-microseconds-to-milliseconds
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/rename-microseconds-to-milliseconds
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai

codeant-ai Bot commented Mar 13, 2026

Copy link
Copy Markdown

Sequence Diagram

This PR renames the timestamps CLI option from microseconds to milliseconds and propagates the new field name through source creation and processing. The runtime flow is unchanged: when enabled, each second timestamp is expanded into 1000 sub second variants.

sequenceDiagram
    participant User
    participant CLI
    participant SourceFactory
    participant TimestampSource

    User->>CLI: Run timestamps command with milliseconds option
    CLI->>SourceFactory: Parse command and pass milliseconds flag
    SourceFactory->>TimestampSource: Create source with date range and flag
    User->>TimestampSource: Start timestamp processing
    alt Milliseconds enabled
        TimestampSource->>TimestampSource: Process each second plus 1000 millisecond variants
    else Milliseconds disabled
        TimestampSource->>TimestampSource: Process each second once
    end
    TimestampSource-->>User: Return processing statistics
Loading

Generated by CodeAnt AI

Comment thread src/main.rs
@codspeed-hq

codspeed-hq Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing fix/rename-microseconds-to-milliseconds (c186e4d) with main (66ce127)

Open in CodSpeed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Renaming variables and CLI flags is a breaking change and considered a refactor, which requires human review according to the provided guidelines.

Architecture diagram
sequenceDiagram
    participant User
    participant CLI as CLI Parser (clap)
    participant Main as Main / Factory
    participant TS as TimestampSource

    User->>CLI: timestamps --milliseconds 2023-01-01 2023-01-02
    CLI->>Main: CHANGED: SourceCommand::Timestamps { milliseconds: true, ... }
    
    Main->>TS: CHANGED: from_dates(start, end, milliseconds)
    TS-->>Main: Instance (Box<dyn Source>)
    
    Main->>TS: run(transforms, output, stats)
    
    loop For each second in range
        TS->>TS: Calculate base unix timestamp (ts)
        
        alt CHANGED: milliseconds flag is true
            loop 0 to 999
                TS->>TS: Calculate sub-second key (ts * 1000 + ms)
                TS->>Main: process_timestamp(ts_ms, ...)
            end
        else flag is false
            TS->>Main: process_timestamp(ts, ...)
        end
    end

    Note over TS,Main: Total keys = (seconds * 1001) if milliseconds else seconds
Loading

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/source/timestamps.rs (1)

156-170: This test misses loop off-by-one bugs.

inputs_processed is computed before the parallel loop starts, so this still passes if someone changes 0..1000 to 0..=1000 and actually processes 1002 values. A tiny stub transform plus an assertion on keys_generated would catch the real iteration count.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/source/timestamps.rs` around lines 156 - 170, The test
process_counts_milliseconds_mode_correctly currently only asserts
inputs_processed which is computed before the processing loop and thus won't
catch off-by-one in the actual iteration; add a tiny stub Transform
implementation (e.g., TestCountingTransform) that increments a shared counter or
records each processed key via keys_generated when its transform method is
called, include an instance of this stub in the transforms Vec passed to
TimestampSource::process, then assert that the stub's keys_generated count
equals the expected number (1001) after process returns to detect any off-by-one
in TimestampSource::process or its internal loop.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.rs`:
- Around line 366-368: The new CLI flag rename removed the old --microseconds
flag and breaks saved commands; restore backward compatibility by adding the old
spelling as a deprecated alias on the struct field that defines the flag (the
milliseconds field) — e.g. add an attribute like #[arg(long, alias =
"microseconds")] (or #[arg(long, aliases = ["microseconds"])] depending on your
clap version) and update the flag help text to mention the alias is deprecated
so callers see a warning; this keeps create_source() behavior unchanged while
accepting old saved commands.

---

Nitpick comments:
In `@src/source/timestamps.rs`:
- Around line 156-170: The test process_counts_milliseconds_mode_correctly
currently only asserts inputs_processed which is computed before the processing
loop and thus won't catch off-by-one in the actual iteration; add a tiny stub
Transform implementation (e.g., TestCountingTransform) that increments a shared
counter or records each processed key via keys_generated when its transform
method is called, include an instance of this stub in the transforms Vec passed
to TimestampSource::process, then assert that the stub's keys_generated count
equals the expected number (1001) after process returns to detect any off-by-one
in TimestampSource::process or its internal loop.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1bb60c60-7203-4bd8-97bd-c08f1efbbb93

📥 Commits

Reviewing files that changed from the base of the PR and between 66ce127 and e1e6ecf.

📒 Files selected for processing (2)
  • src/main.rs
  • src/source/timestamps.rs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: benchmarks
🧰 Additional context used
📓 Path-based instructions (9)
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Order imports as: external crates → std → blank line → super:: → blank line → crate::
Prefer ? operator over .unwrap() in new code
Use PascalCase for types and structs
Use snake_case for function and method names
Use SCREAMING_SNAKE_CASE for constants
Use snake_case for file and module names

Files:

  • src/main.rs
  • src/source/timestamps.rs
src/main.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/main.rs: Use anyhow::Result<T> and anyhow::bail!() for CLI and top-level error handling
CLI command and subcommand changes go in src/main.rs using clap derive macros

Files:

  • src/main.rs
src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.rs: Use indicatif::ProgressBar for long-running operations
Place inline tests in #[cfg(test)] mod tests at the end of each file, using standard assert! and assert_eq! macros
Use tempfile crate for file I/O tests

Files:

  • src/main.rs
  • src/source/timestamps.rs
src/source/*.rs

📄 CodeRabbit inference engine (src/source/AGENTS.md)

Create new source in src/source/{name}.rs file

Files:

  • src/source/timestamps.rs
src/source/!(mod).rs

📄 CodeRabbit inference engine (src/source/AGENTS.md)

src/source/!(mod).rs: Implement Source trait with process() method accepting transforms, deriver, matcher, and output parameters
Use Rayon par_chunks() for batch processing and parallelism in source implementations
Report progress via optional ProgressBar using indicatif::ProgressBar in process() method
All sources must implement Send + Sync traits for thread safety

Files:

  • src/source/timestamps.rs
src/{derive,matcher,network,benchmark,provider,transform,analyze,source,output,gpu,storage}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Implement custom error enums with Display and Error trait implementations for domain modules

Files:

  • src/source/timestamps.rs
src/{transform,analyze,source}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Suffix struct names by role: {Name}Transform, {Name}Analyzer, {Name}Source

Files:

  • src/source/timestamps.rs
src/{transform,source}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Implement batch processing for transforms and sources using &[Input] batches via Rayon par_chunks()

Files:

  • src/source/timestamps.rs
src/{transform,source,analyze}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Use AtomicBool for early termination signaling across Rayon threads

Files:

  • src/source/timestamps.rs
🧠 Learnings (7)
📚 Learning: 2026-03-12T18:24:52.371Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-12T18:24:52.371Z
Learning: Applies to src/main.rs : CLI command and subcommand changes go in `src/main.rs` using clap derive macros

Applied to files:

  • src/main.rs
📚 Learning: 2026-03-05T12:48:44.245Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/source/AGENTS.md:0-0
Timestamp: 2026-03-05T12:48:44.245Z
Learning: Applies to src/source/src/main.rs : Update `SourceCommand` enum in `src/main.rs` when adding a new source type

Applied to files:

  • src/main.rs
📚 Learning: 2026-03-05T12:48:44.245Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/source/AGENTS.md:0-0
Timestamp: 2026-03-05T12:48:44.245Z
Learning: Applies to src/source/src/main.rs : Update `create_source()` function in `src/main.rs` to handle new source variants

Applied to files:

  • src/main.rs
  • src/source/timestamps.rs
📚 Learning: 2026-03-05T12:48:44.245Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/source/AGENTS.md:0-0
Timestamp: 2026-03-05T12:48:44.245Z
Learning: Applies to src/source/stdin.rs : Implement line-by-line streaming in `StdinSource` for memory efficiency

Applied to files:

  • src/main.rs
📚 Learning: 2026-03-05T12:48:44.245Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/source/AGENTS.md:0-0
Timestamp: 2026-03-05T12:48:44.245Z
Learning: Applies to src/source/mod.rs : Add variant to `SourceType` enum with `create()` and `from_str()` methods for new sources

Applied to files:

  • src/main.rs
📚 Learning: 2026-03-05T12:48:44.245Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/source/AGENTS.md:0-0
Timestamp: 2026-03-05T12:48:44.245Z
Learning: Applies to src/source/!(mod).rs : Implement `Source` trait with `process()` method accepting `transforms`, `deriver`, `matcher`, and `output` parameters

Applied to files:

  • src/source/timestamps.rs
📚 Learning: 2026-03-12T18:25:01.029Z
Learnt from: CR
Repo: oritwoen/vuke PR: 0
File: src/output/AGENTS.md:0-0
Timestamp: 2026-03-12T18:25:01.029Z
Learning: Applies to src/output/console.rs : Compact CSV format for file output should be: `source,transform,privkey_hex,address`

Applied to files:

  • src/source/timestamps.rs
🧬 Code graph analysis (1)
src/main.rs (1)
src/source/timestamps.rs (1)
  • from_dates (22-55)
🔇 Additional comments (2)
src/main.rs (1)

1149-1157: The rename is wired through cleanly.

create_source() forwards the renamed field straight into TimestampSource::from_dates(), so the CLI spelling and source mode stay aligned.

src/source/timestamps.rs (1)

15-18: Milliseconds now matches the actual work path.

Stored flag, constructor arg, overflow check, count * 1001, and the 0..1000 expansion all describe the same unit now.

Also applies to: 22-23, 50-53, 74-96, 113-121

Comment thread src/main.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Auto-approved: Renaming --microseconds to --milliseconds for correctness. Includes a CLI alias for backward compatibility and involves no logic changes.

@oritwoen oritwoen merged commit afb45b5 into main Mar 13, 2026
4 checks passed
@oritwoen oritwoen deleted the fix/rename-microseconds-to-milliseconds branch March 13, 2026 13:00
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.

--microseconds flag actually tests milliseconds

1 participant