Skip to content

feat(cli): add commute subcommand - #4

Merged
GiggleLiu merged 3 commits into
QuantumBFS:mainfrom
hzgpmc:issue-1-commute
Jul 27, 2026
Merged

feat(cli): add commute subcommand#4
GiggleLiu merged 3 commits into
QuantumBFS:mainfrom
hzgpmc:issue-1-commute

Conversation

@hzgpmc

@hzgpmc hzgpmc commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add qsym commute <A> <B> to the CLI
  • reuse the existing parse_pair validation and PauliString::commutes
  • add black-box CLI tests for commuting, anticommuting, length-mismatch, and invalid-letter cases

Why

The engine already knows whether two equal-length Pauli strings commute, but
that operation was not available from the command line. This exposes the
existing capability without changing the library API or duplicating
validation logic.

User impact

Users can now run:

qsym commute X Z     # anticommute
qsym commute XX ZZ   # commute

Invalid Pauli letters and unequal lengths continue to use the CLI's existing
nonzero error: <message> path.

Validation

  • conda run -n qsym-rs make check
  • formatting and clippy passed with warnings denied
  • 15 CLI tests passed
  • 6 engine tests passed
  • documentation tests passed

Closes #1

@hzgpmc

hzgpmc commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Self-review record

What was checked

  • Issue and design compliance: qsym commute <A> <B> uses the existing
    parse_pair validation and PauliString::commutes, prints exactly
    commute or anticommute, and does not change src/lib.rs.
  • Scope: the production change is limited to src/main.rs; the only other
    code change is black-box CLI coverage in tests/cli.rs.
  • Success cases: commute X Z reports anticommute, while
    commute XX ZZ reports commute.
  • Failure cases: unequal lengths and invalid Pauli letters exit nonzero,
    use the existing error: <message> path, and print no success token.
  • Regression: mul XZ ZX remains +YY.
  • TDD evidence: all four new tests failed first because commute was an
    unknown subcommand, then passed after the minimal implementation.
  • Quality: a task-scoped review and a separate whole-branch review found
    no Critical, Important, or Minor issues.

What was fixed

No review fixes were required; both independent reviews approved the original
implementation.

Verification

conda run -n qsym-rs make check passed:

  • formatting check
  • clippy with warnings denied
  • 15 CLI tests
  • 6 engine tests
  • documentation tests

@hzgpmc
hzgpmc marked this pull request as ready for review July 26, 2026 16:15
@GiggleLiu
GiggleLiu merged commit d2fbd68 into QuantumBFS:main Jul 27, 2026
1 check passed
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.

Add a commute subcommand to the qsym CLI

2 participants