Skip to content

Fix #58: record task persistence through a single QuantumTaskRecorder - #105

Open
corgab wants to merge 3 commits into
mainfrom
fix/58-task-recorder
Open

Fix #58: record task persistence through a single QuantumTaskRecorder#105
corgab wants to merge 3 commits into
mainfrom
fix/58-task-recorder

Conversation

@corgab

@corgab corgab commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

SubmitQuantumCircuit::persistSubmission() and PollQuantumTask::persist() repeated the same shape: return early unless aether.persist_tasks is on, try a database write, report() and swallow any Throwable. Only the write itself differed. This PR moves the guard and the safety net into one collaborator, as the issue proposes.

Plan

  1. Add Tasks\QuantumTaskRecorder with recordSubmission(taskArn, driver, circuit) and recordProgress(taskArn, status, counts, error); a private write() applies the persist_tasks gate and the report-and-swallow once for both.
  2. Inject the recorder into both jobs' handle(), next to QuantumManager and the event Dispatcher, and delete the jobs' private persistence methods.
  3. Test the recorder on its own, including the failure path, and keep PersistenceTest for what the jobs record and when.

Changes

  • src/Tasks/QuantumTaskRecorder.php (new): the two record methods, enabled(), and the shared write() wrapper. The docblocks carry the reasoning that used to sit on the job methods (the remote task already exists, so a failed write must never fail the job, retry a billable submission or suppress CircuitCompleted).
  • src/Jobs/SubmitQuantumCircuit.php: handle(QuantumManager, QuantumTaskRecorder); persistSubmission() removed; one recorder call after submitCircuit().
  • src/Jobs/PollQuantumTask.php: handle(QuantumManager, Dispatcher, QuantumTaskRecorder); persist() removed; the five call sites call recordProgress().
  • CLAUDE.md: convention noted.
  • tests/Feature/Tasks/QuantumTaskRecorderTest.php (new): gate on/off with a query-log check, the insert, intermediate status, success, error, unknown task left alone, and a dropped table proving both writes report through the exception handler and throw nothing.
  • tests/Feature/PersistenceTest.php: the two cases that only exercised the persist_tasks gate are gone (the recorder tests own that rule); the job-level cases stay. The job tests' handle() calls pass the recorder.

Overlap

#104 (#57) also adds a handle() parameter to both jobs and rewrites the same persistence methods to read persist_tasks through AetherConfig. Whichever merges second keeps both parameters, deletes the methods in favour of the recorder, and has the recorder's enabled() read AetherConfig::persistTasks() instead of the config() helper.

Tests

  • vendor/bin/pint --test passes.
  • vendor/bin/pest --compact: 797 tests, 1 skipped (791 before: +8 recorder tests, −2 duplicated gate tests).

Closes #58

…ecorder

SubmitQuantumCircuit::persistSubmission() and PollQuantumTask::persist()
repeated the same shape: return early unless aether.persist_tasks is on, try
a write, report() and swallow any Throwable. Only the write differed.

Tasks\QuantumTaskRecorder now owns that guard and safety net once, with
recordSubmission() for the insert and recordProgress() for the status,
counts and error mirror. Both jobs resolve it from the container and call
it, so the persistence rules live in one class with their own tests.

Closes #58
…the duplicated persistence tests

The recorder is now a handle() dependency like QuantumManager and the event
Dispatcher, instead of being located with app() inside the method. The two
PersistenceTest cases that only exercised the persist_tasks gate are gone:
that rule is pinned by the recorder's own tests, and PersistenceTest keeps
the job-level cases (what each job records, and when).
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.

[maintainability] Task persistence (guard + try/write/report) is duplicated between SubmitQuantumCircuit and PollQuantumTask

1 participant