Fix #57: read package settings through a typed AetherConfig service - #104
Open
corgab wants to merge 3 commits into
Open
Fix #57: read package settings through a typed AetherConfig service#104corgab wants to merge 3 commits into
corgab wants to merge 3 commits into
Conversation
…service SubmitQuantumCircuit and PollQuantumTask called the global config() helper nine times between them, repeating the same default-resolution expressions, and the literal 'local' default for aether.default lived in four files. Config\AetherConfig now owns every aether.* default as a constant and exposes typed readers (defaultDriver(), queue(), pollInterval(), maxPollAttempts(), persistTasks(), pythonPath(), processTimeout(), driver()). It is a container singleton, injected into the jobs' handle() alongside QuantumManager; job constructors and tries(), which Laravel calls without injection, resolve it from the container. QuantumManager, the About section and the install command read through it too. Reads go to the repository on each call, so config()->set() in a test or a runtime change is still honoured. Closes #57
…e(), and keep the manager container-independent - defaultDriver(), pythonPath() and queue() return the trimmed value, so a padded env value no longer leaks whitespace into driver names or the Process command. - PollQuantumTask::handle() budgets attempts from the injected AetherConfig instead of re-resolving it through tries(). - QuantumManager::settings() falls back to building the reader over its own config repository when the container has no binding, so a bare container with only 'config' bound still resolves drivers. - local_task_ttl joins AetherConfig (localTaskTtl()); the extend() examples in the bridge() docblock and README read the driver array through it.
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
SubmitQuantumCircuitandPollQuantumTaskcalled the globalconfig('aether.*')helper nine times between them, repeating the same default-resolution expressions, and the literal'local'default foraether.defaultlived in four files. This PR centralises the package-level settings in one typed service.Plan
Config\AetherConfig, a thin typed reader over the config repository: every top-levelaether.*default becomes a constant, every reader returns the documented type, and reads hit the repository on each call soconfig()->set()in a test (or a runtime change) is still honoured.handle()alongsideQuantumManager, as the issue proposes. Job constructors andtries()get no method injection from Laravel, so those two spots resolve it from the container; the docblocks say why.QuantumManager(default driver, bridge wiring, per-driver arrays), thephp artisan aboutsection, the install command's Python path, and the local simulator's task TTL.Changes
src/Config/AetherConfig.php(new):defaultDriver(),pythonPath(),processTimeout(),queue(),pollInterval(),maxPollAttempts(),persistTasks(),localTaskTtl(),driver(name); constantsDEFAULT_DRIVER,DEFAULT_PYTHON_PATH,DEFAULT_PROCESS_TIMEOUT,DEFAULT_POLL_INTERVAL,DEFAULT_MAX_POLL_ATTEMPTS,DEFAULT_LOCAL_TASK_TTL. String settings come back trimmed; blank or non-numeric integers fall back to the default;persistTasks()understands the env spellings ("true","1", ...) and treats anything unrecognised as disabled.src/AetherServiceProvider.php: singleton binding; About section reads through the service.src/Jobs/SubmitQuantumCircuit.php,src/Jobs/PollQuantumTask.php:handle()takesAetherConfigand uses it for every setting, the attempt budget included;persistSubmission()/persist()receive it explicitly; noconfig()call left.src/QuantumManager.php:getDefaultDriver(),createLocalDriver(),createAwsDriver(),createBridge()read through a privatesettings()accessor. It takes the container binding when present and otherwise builds the reader over the repositoryManageralready holds, so a bare container with onlyconfigbound still resolves drivers. Thebridge()docblock example reads the driver array through the service.src/Drivers/LocalSimulatorDriver.php:taskTtl()readslocalTaskTtl().src/Commands/AetherInstallCommand.php:handle()injectsAetherConfigfor the Python path.README.md: theQuantum::extend()example reads the driver array through the service.CLAUDE.md: convention documented.tests/Unit/Config/AetherConfigTest.php(new, dataset-driven: defaults, typed reads, env string casts, trimming, blank handling, live reads); provider tests for the singleton, the default driver resolving through the service, and driver resolution on a bare container; a poll-job test provinghandle()budgets attempts from the injected instance; the job tests'handle()calls pass the service.Overlap
defaultDriver()carries the same blank-string guard that #99 (#50) adds toQuantumManager::getDefaultDriver(); whichever merges second resolves that method in favour of the one-line delegation here.Tests
vendor/bin/pint --testpasses.vendor/bin/pest --compact: 819 tests, 1 skipped (791 before: +28).Closes #57