Skip to content

Implement tech-debt-backlog items 1.1 and 2.1 (parser rename + CUDA-Q invariant) - #23

Merged
jascal merged 1 commit into
mainfrom
tech-debt-backlog-batch-1
Apr 21, 2026
Merged

Implement tech-debt-backlog items 1.1 and 2.1 (parser rename + CUDA-Q invariant)#23
jascal merged 1 commit into
mainfrom
tech-debt-backlog-batch-1

Conversation

@jascal

@jascal jascal commented Apr 21, 2026

Copy link
Copy Markdown
Owner

Summary

Picks up two Hermes QA items filed against PR #21 in the
tech-debt-backlog OpenSpec change.

  • 1.1 — Rename _has_trailing_mutation: misleading name. The
    regex matches any mutation op at the start of a ;-separated
    segment, not specifically trailing. Renamed to
    _contains_mutation_segment with an updated docstring that
    documents the segment-boundary anchor.
  • 2.1 — CUDA-Q severity/valid consistency: the only live
    mutation site was CudaQBackend.verify calling
    result.errors.insert(0, warning) without re-deriving valid.
    The invariant (valid iff no error-level entries) held today
    because the inserted entry was a warning, but the pattern was
    fragile. Switched to building a fresh QVerificationResult from
    the merged error list. Added
    test_severity_valid_invariant_holds as a regression test.

Both tasks in openspec/changes/tech-debt-backlog/tasks.md are
now checked with audit notes inline per the file's meta rule
(leave completed items in place — the archived copy is our
record).

Test plan

  • .venv/bin/python -m pytest tests/test_backends.py tests/test_context_updates.py tests/test_parser.py -q — 126 passed, 6 skipped
  • Full suite: .venv/bin/python -m pytest tests/ -q --ignore=tests/test_cuquantum_backend.py --ignore=tests/test_cudaq_backend.py — 468 passed, 6 skipped
  • Grep for any other references to _has_trailing_mutation — only the (now-checked) backlog task text remains

🤖 Generated with Claude Code

- Rename `_has_trailing_mutation` in `q_orca/parser/markdown_parser.py`
  to `_contains_mutation_segment`. The regex is anchored at segment
  starts (string start or after `;`), so the old name was misleading
  — it wasn't about trailing position, just about detecting a
  mutation op in any non-initial segment of a mixed effect string.

- Harden CUDA-Q backend severity/valid consistency in
  `q_orca/backends/cudaq_backend.py::CudaQBackend.verify`. It used
  to mutate `result.errors` via `insert(0, ...)` without
  re-deriving `valid`. The inserted error is a warning today so
  the invariant (valid iff no error-level entries) held, but the
  pattern was fragile. Now we build a new `QVerificationResult`
  from the merged error list with `valid` recomputed. Added
  `test_severity_valid_invariant_holds` as a regression test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jascal
jascal merged commit 4b5dcfd into main Apr 21, 2026
6 checks passed
@jascal
jascal deleted the tech-debt-backlog-batch-1 branch April 21, 2026 10:51
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