Fix #52: name each Python script once per method - #108
Open
corgab wants to merge 4 commits into
Open
Conversation
…() helper
Five call sites in AbstractQuantumDriver repeated the same check on decoded
Python output: key present, value of the right type, else throw
QuantumExecutionException::malformedResponse() with a hand-written message.
expectKey() now performs the check and words the message once
("expected <subject> to have a \"<key>\" key holding <expected>"), so each
call site states only the script, the key, the predicate and the expected
shape. The count and length checks that are not shape checks stay inline.
Closes #53
…h item, and stop over-claiming counts types pollTask() now hands the status expectKey() validated to TaskSnapshot::fromResponse() instead of letting the snapshot re-parse the key. A batch item that is not an object gets its own message with its index, and the per-item counts check names the item too. The @var annotations on counts say array<mixed>, which is what is_array() proves; CircuitResult owns the value shape.
Every script name appeared two to four times in AbstractQuantumDriver: at the bridge call and again in each malformed-response message that could follow it. Each method now holds the name in one local, hands it to the new callScript() helper (execute() plus the payload envelope) and reuses the same variable for expectKey() and malformedResponse(), so a message can never name a script other than the one that ran. Closes #52
…ubclasses, fix a docblock example executeBatch() now array_values() the circuit payload, matching the two other places in the method that already normalise keys, so a driver called with an associative array no longer hands batch.py a JSON object. callScript() is protected so a custom driver's own script gets the same envelope, and expectKey()'s subject example matches the real call site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every Python script name appeared two to four times in
AbstractQuantumDriver: at the bridge call and again in each malformed-response message that could follow it. Each method now names its script once.Stacked on #107. This branch builds on
fix/53-response-shape-helperbecause both touch the same lines ofAbstractQuantumDriver. It targetsmainso CI runs (the workflow only runs for PRs againstmain), which means the diff shows #107's two commits as well until #107 merges; after that GitHub drops them and only the last two commits remain. Merge #107 first.Plan
callScript(string $script, array $data): arraythat wrapsexecute()plus thepayload()envelope, so the script name meets the bridge in one place and a custom driver with a script of its own gets the same treatment.$script, pass it tocallScript(), and reuse the same variable for theexpectKey()andmalformedResponse()calls that follow.Changes
src/Drivers/AbstractQuantumDriver.php:callScript()added next toexpectKey();executeBatch(),runDefinition(),submitTask(),pollTask()andgenerateEntropy()each hold their script name in one local. The five.pyliterals in the class are now exactly five, one per method. While there,executeBatch()sends the circuits as a list whatever keys the caller used (the method already normalised keys for validation and events, but not for the payload, so an associative array became a JSON objectbatch.pycould not iterate), and theexpectKey()docblock example matches its real call site.tests/Unit/Drivers/AbstractQuantumDriverTest.php: a test proves an associative batch reaches Python as a list.Tests
vendor/bin/pint --testpasses.vendor/bin/pest --compact: 798 tests, 1 skipped (797 on Fix #53: funnel response-shape checks through one expectKey() helper #107: +1).Closes #52