Skip to content

Circuit-Editor Classical-Control Support - #3596

Merged
Scott Carda (ScottCarda-MS) merged 21 commits into
mainfrom
sccarda/ce-classical-control
Aug 24, 2026
Merged

Circuit-Editor Classical-Control Support#3596
Scott Carda (ScottCarda-MS) merged 21 commits into
mainfrom
sccarda/ce-classical-control

Conversation

@ScottCarda-MS

@ScottCarda-MS Scott Carda (ScottCarda-MS) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Circuit Editor: support classical dependencies across structural edits

Summary

Adds classical-dependency support to circuit-editor add, remove, move, and clone operations.

Because classical result addresses are positional, structural edits can change a producer's
(qubit, result) address. This PR adds an edit algorithm that replaces those addresses with stable
identities while an edit is in progress, then assigns final addresses after the circuit reaches its
new shape.

What changed

  • Encodes producers and consumers with unique negative tokens before a structural edit, then decodes
    them into contiguous per-wire result indices afterward.
  • Uses preserve semantics for moves and fork semantics for adds and clones, so consumers
    follow the intended producer in both cases.
  • Centralizes validation, mutation, structural reconciliation, classical reconciliation, and qubit
    cleanup in the shared _editOperation transaction.
  • Prompts before a move or delete would strand dependent operations, then cascade-deletes only the
    invalid consumers on confirmation. Canceling leaves the model unchanged, while safe moves proceed
    without a prompt.
  • Keeps moves that would place an operation before an external producer invalid.

This also supports same-wire producer-consumer cloning and group moves involving multiple internal
or external producers.

The temporary tokens do not change the circuit data model or serialized format.

Testing

Adds 48 focused regression tests for add/remove resequencing, move and clone identity handling,
dependent-operation cascades, prompt behavior, and result-count updates.

npm run build:ux
npm test -- test/circuit-editor/circuit-actions/addRemove.test.mjs test/circuit-editor/circuit-actions/groupClone.test.mjs test/circuit-editor/circuit-actions/groupMove.test.mjs test/circuit-editor/circuit-actions/measurementCascade.test.mjs test/circuit-editor/prompts.test.mjs

Result: 128 tests passed, 0 failed across all changed test suites.

@ScottCarda-MS Scott Carda (ScottCarda-MS) changed the title Sccarda/ce classical control Circuit-Editor Classical-Control Support Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds robust classical-dependency handling to the circuit editor’s structural edits (add/remove/move/clone) by temporarily replacing positional (qubit, result) addresses with stable identities during an edit, then reassigning final contiguous result indices once the circuit reaches its new shape.

Changes:

  • Centralizes structural edits into a shared _editOperation transaction that performs validation, structural reconciliation, classical ref encoding/decoding, and qubit cleanup.
  • Generalizes consumer detection/cascade behavior from measurement-only to subtree-wide producer/consumer relationships, with prompt support for stranded dependents on move/delete.
  • Adds extensive regression coverage across prompts and edit operations, including multi-producer groups, same-wire clones, and preview-vs-commit agreement.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
source/npm/qsharp/ux/circuit-vis/editor/prompts.ts Updates move/delete confirmation flows to use subtree-wide consumer detection and dependency-aware commit paths.
source/npm/qsharp/ux/circuit-vis/actions/circuitActions.ts Introduces _editOperation, dependency-aware move/delete helpers, and a stranded-consumer preview counter.
source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/move.ts Ensures measurement .results[*].qubit stays consistent with .qubits during vertical moves.
source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/gridPrimitives.ts Extracts column-injection decision logic into willInsertNewColumn and removes direct measurement-line renumbering.
source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/classicalRefs.ts Implements classical ref token encode/decode, subtree consumer collection, and post-move invalidation detection.
source/npm/qsharp/test/circuit-editor/prompts.test.mjs Updates and expands prompt behavior tests for the new stranded-consumer logic and unified messaging.
source/npm/qsharp/test/circuit-editor/circuit-actions/measurementCascade.test.mjs Reworks cascade tests around the new identity/token approach; adds preview-vs-commit agreement coverage.
source/npm/qsharp/test/circuit-editor/circuit-actions/groupMove.test.mjs Adds broader invariants for multi-producer group moves and consumer/producers relinking across wire shifts.
source/npm/qsharp/test/circuit-editor/circuit-actions/groupClone.test.mjs Adds cloning tests ensuring cloned consumers bind to cloned producers, including same-wire cloning.
source/npm/qsharp/test/circuit-editor/circuit-actions/addRemove.test.mjs Adds add/remove renumbering + repointing tests and a toolbox-measurement initialization test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread source/npm/qsharp/ux/circuit-vis/actions/circuitActions.ts Outdated
@ScottCarda-MS
Scott Carda (ScottCarda-MS) added this pull request to the merge queue Aug 24, 2026
Base automatically changed from sccarda/ce-multitarget to main August 24, 2026 16:32
Merged via the queue into main with commit d05cb67 Aug 24, 2026
14 checks passed
@ScottCarda-MS
Scott Carda (ScottCarda-MS) deleted the sccarda/ce-classical-control branch August 24, 2026 16:45
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.

3 participants