Repository navigation
fix: recoverable, exactly-once quiz preview starts and working live submit - #45
Conversation
Port the 2026-09-18 branch work onto current main (net of 9e497bd and 07a5c0d; conflicts were import wrapping only): - PreviewStartUnknownError carries the validated attempt id and page once the start callback reveals them, and the session persists them while the checkpoint stays uncertain, so a start that reached the LMS no longer discards its known identity. - 'preview page' recovers an uncertain start with a bound attempt through a read-only readback. - 'preview reconcile COURSE QUIZ --attempt-id N' binds an explicitly chosen incomplete attempt after actor/course/quiz identity checks (read-only). - Parse the live question prompt from a single d2l-html-block when the legacy d2l_read_element_ wrapper is absent (the live trial markup). Refs #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recovery (issue #24, per the 2026-09-22 handoff and plan review): - Seal the validated attempt id and page through an on_identity callback as soon as the start callback reveals them, before the page readback, so an interrupted or failed readback cannot lose a known identity. - Snapshot this account's attempt ids and the start intent time before dispatching a start; refuse before any request if the listing fails. - 'preview reconcile' is read-only: a bound start is verified at its known cursor (a different --attempt-id is refused) or, if completed, through the receipt check. An unbound start only lists candidates (new since the snapshot, own, incomplete, started after the intent); binding needs an explicit --attempt-id that is one of them and uses the server's current page for that exact preview attempt. Any failed check leaves the checkpoint unchanged; an empty listing never clears uncertainty. - 'preview abandon' keeps an unresolved-start marker, and 'start' refuses until reconcile resolves it, so abandon is no retry bypass. - Optional checkpoint fields are validated; v1 checkpoints still load. Live trial fixes: - Submit: send ProcessQuizSubmission params as compact JSON and the current page in the RPC context (Brightspace returned an error redirect for spaced JSON; verified against the browser's request). - Pre-send refusals (hidden quiz needs --bypass-availability, question not on this page, unanswered questions, not the last page) raise PreviewRefusedError with fixed messages shown verbatim instead of 'Network error' / 'Command failed.'. Refs #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the GPT-6-Astra (xhigh) review of 823f376: - An unbound candidate must be an in-progress attempt on a supported layout before binding; a record that is already completed no longer takes the receipt shortcut and clears the guard. - Page through the attempt listing only on this quiz's exact attempts route with a bookmark; any other Next link is refused before request. - Treat pre-marker abandoned checkpoints without an attempt as an unresolved start; require a real boolean for unresolved_start. - Emit candidate start times only as parsed, normalized timestamps. - Add 'reconcile --confirm-no-remote-attempt': an operator disposition after checking the browser, allowed only for an unbound start with no listed candidate, so the guard cannot deadlock a quiz forever. - Share the supported-layout check between start and reconcile. - Document that requesting a page past the quiz's last page permanently breaks a trial preview attempt (observed live); no code path does so. - Tests: bound cursor beyond page 1, completed unbound candidate, unsupported layout, restricted paging, legacy guard, strict booleans, normalized output, confirm-disposition rules (mutation-checked). Refs #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Enforce the attempt-count limit for plain-list listing responses too, so an oversized listing refuses the start before any request instead of sealing a baseline the checkpoint loader later rejects (from the GPT-6-Astra re-review of 87bc3c0). - README: hidden quizzes need --bypass-availability; the reconcile flow. - Coverage report: 2026-09-23 end-to-end CLI results on both layouts, the known-ID and lost-response recoveries, and the observed page-range hazard. Refs #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Droid encountered an error —— View job |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a8a8007ad3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Important
One must-address finding: a bound uncertain start whose own attempt was advanced in the browser has no resume path — reconcile refuses forever and the only exit (finish the preview in the browser) is undiscoverable. Everything else checks out, including the exactly-once invariant.
Reviewed changes
- Prompt parsing for the live trial:
parse_preview_pagenow accepts a question prompt delivered as a singled2l-html-block(no legacyd2l_read_element_id), which is what made every live start end "uncertain". - Working live submit: the
ProcessQuizSubmissionRPC now sends compactparamsJSON and names the actual current page (pg) in the RPC context and Referer, matching the browser capture. - Specific pre-dispatch refusals: new
PreviewRefusedErrorwith fixed constants (unsupported type, question/choice not on page, unanswered, last/not-last page, start unavailable) raised before any state-changing request and surfaced verbatim; everything else stays sanitized. - Exactly-once starts: a pre-start baseline of the account's attempts plus
start_intent_atis sealed before dispatch;on_identityseals(attempt_id, page)before the page readback; theunresolved_startguard survivesabandon(including legacy checkpoints) and blocks re-starting; a read-onlyreconcilelists/binds candidates with strictly validated, bounded attempt-list paging that can never leave the attempts route. - Server-page recovery:
read_server_current_previewbinds an unbound start at the server-reported current page after full identity verification, with the observed tenant quirks documented.
Verified locally: the 120 tests in the three changed test files pass and ruff is clean on the changed modules. The exactly-once invariant was traced end-to-end across the full exception matrix (seal failures, KeyboardInterrupt mid-readback, generic-exception restore, save-point failures, legacy checkpoints) — every post-dispatch failure leaves the guard durable, and the only guard-clearing writes are provably pre-dispatch or verified commits. Test quality is strong: exact-value assertions throughout (compact-JSON byte-for-byte, request-order counts, sentinel-based leak checks), and the acceptance-matrix tests would fail with each safety behavior removed.
ℹ️ Nitpicks
PreviewWorkflow._identity(lighthouse_cli/quiz_preview_session.py:484) still advises "Inspect the browser before abandoning or starting again" for an unbound uncertain start — but this PR makesabandonno longer release the guard andstartrefuse. The actionable advice is nowreconcile; worth rewording while touching this area.
Verification log
pytest tests/test_quiz_preview_session.py tests/test_quiz_attempt_page.py tests/test_quiz_preview_finish.py -q→ 120 passed.ruff checkon the five changedlighthouse_climodules → clean.- Full exception-matrix trace of
PreviewWorkflow.run/reconcile/_resolve_startagainststart_preview's dispatch boundaries; cross-checked with areviewfrogspecialist pass (exactly-once lens).
openai-compatible/glm-5.3 | 𝕏
From hosted reviews of a8a8007: - Pullfrog: a bound uncertain start whose attempt was advanced in the browser could never be resumed. reconcile now falls back to the server-reported page of that exact attempt when the saved page no longer reads back, on supported layouts only; 'page' points to reconcile when the start's page cannot be verified. - Codex: take the question prompt only from a d2l-html-block outside the answer options, so a rich-text choice is never shown as the prompt. - Codex: refusals that depend only on the local cursor (no active preview, unresolved start, uncertain write) run before authentication, so a missing session no longer masks them. Refs #24 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Droid encountered an error —— View job |
There was a problem hiding this comment.
✅ No new issues found. The prior review's must-address finding — a bound start advanced in the browser had no resume path — is fixed in
4450f95and covered by tests in both directions (resume at the server page; refusal with the checkpoint unchanged on an unsupported layout).
Reviewed changes
The delta since the last pullfrog review (a8a8007) is one commit, 4450f95.
- Resumed advanced bound starts in
reconcile: when a bound start's sealed cursor no longer reads back,_resolve_startfalls back toread_server_current_previewfor that exact attempt (same strictou/qi/ai/isprvidentity), gated on the supported layouts — the same guarantee the unbound branch already had. - Kept cursor refusals local:
run's unresolved-start, existing-preview and no-active-preview refusals now fire before any client construction or authentication, and an uncertain-start write gets a dedicated fixed message pointing atpreview reconcile. - Hardened the html-block prompt fallback: rich-text answer choices (blocks nested inside
fieldset/table/label) are excluded from prompt detection, so an answer choice can no longer be misread as the prompt; a page left with no prompt fails closed. - Pointed
preview pageatreconcile: an uncertain start whose page cannot be strictly verified now surfaces a fixed "Run preview reconcile" error instead of a raw page failure.
Verification log
pytest tests/test_quiz_preview_session.py tests/test_quiz_attempt_page.py tests/test_quiz_preview_finish.py -q→ 126 passed (6 new).ruff check lighthouse_cli/ tests/→ clean.- Traced the refusal reordering against the previous commit's flow: only pure-local checks moved earlier inside the same lock, so no write path or actor check was lost, and the new tests pin that no authentication happens for purely local refusals.
- Confirmed the bound fallback is read-only, layout-gated, and converts any residual failure to a refusal with the checkpoint unchanged.
| View workflow run | Using openai-compatible/glm-5.3 | 𝕏
openai-compatible/glm-5.3 | 𝕏
| if item["Completed"] is not None or item["AttemptId"] in known: | ||
| continue | ||
| started = _utc(item.get("Started")) | ||
| if intent is not None and (started is None or started < intent - _START_SKEW): |
There was a problem hiding this comment.
[WARNING]: Unparseable/missing Started silently drops real candidates, enabling a premature --confirm-no-remote-attempt
When start_intent_at exists, an attempt whose Started field is absent or fails _utc (unexpected server format) is skipped, so it can never be listed nor bound via --attempt-id (the membership check in reconcile refuses it). Worse, reconcile --confirm-no-remote-attempt then sees an empty candidate list and permanently records the no-remote-attempt disposition while a live remote attempt may exist - the exact outcome this guard exists to prevent. Excluding provably-too-old attempts is sufficient; keeping started is None items would be safe, since any binding is re-verified anyway by _remote_attempt plus the identity-checked preview-page readback.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| if url in seen: | ||
| raise PreviewWorkflowError(_LISTING_INVALID) | ||
| seen.add(url) | ||
| data = client.get_json(url) |
There was a problem hiding this comment.
[SUGGESTION]: A 200 response with a non-JSON body bypasses the _LISTING_INVALID fail-closed contract
get_json is self.get(...).json(), so an HTML interstitial raises requests.exceptions.JSONDecodeError, which escapes as an unknown error (generic sanitized message) instead of the fixed, actionable _LISTING_INVALID refusal used for every other malformed listing shape here. Wrapping the fetch the way run wraps the baseline listing (converting any failure into a clean PreviewWorkflowError) would keep reconcile's failure class consistent.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| raise PreviewWorkflowError("The saved preview checkpoint is invalid.") | ||
| baseline = state.get("baseline_attempt_ids") | ||
| if (("unresolved_start" in state and type(state["unresolved_start"]) is not bool) | ||
| or state.get("disposition") not in (None, _NO_REMOTE_ATTEMPT) |
There was a problem hiding this comment.
[SUGGESTION]: disposition is type-checked but never cross-checked against the checkpoint state
_load accepts, e.g., disposition set to the no-remote-attempt marker alongside unresolved_start: true or status: uncertain - a combination no writer produces (the only writer sets status to abandoned with unresolved_start false). Harmless today (disposition is only echoed, and a forged unresolved start still resolves safely through remote re-verification), but a cross-field invariant would make the sealed-store validation match the writer contract.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| # authentication or network request, so they stay actionable. | ||
| if operation == "start" and previous and self._unresolved_start(previous): | ||
| raise PreviewWorkflowError(_UNRESOLVED_START) | ||
| if operation == "start" and previous and previous["status"] not in {"submitted", "abandoned"}: |
There was a problem hiding this comment.
[SUGGESTION]: start skips the actor check, so a different signed-in account overwrites the prior account's receipt/disposition
The new guard admits a start when previous[status] is submitted/abandoned, and the only actor comparison (a few lines below) excludes operation == start. Another account signing in on this machine can therefore start and permanently replace the previous account's saved receipt or no-remote-attempt disposition - reconcile, by contrast, refuses a different account first. Requiring the same actor whenever previous exists would match reconcile's behavior.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| raise PreviewWorkflowError(_UNRESOLVED_START) | ||
| if operation == "start" and previous and previous["status"] not in {"submitted", "abandoned"}: | ||
| raise PreviewWorkflowError( | ||
| "A preview already exists. Inspect it with preview page or reconcile; " |
There was a problem hiding this comment.
[SUGGESTION]: This message dead-ends for an uncertain answer/next
It fires for any non-startable previous status, including uncertain with operation of answer/next, where reconcile refuses (it applies only to an unresolved start) - of the two suggested commands only preview page (readback recovery via _recover) actually works there. Consider pointing uncertain non-start operations at preview page and reserving reconcile for the start case, which the following branch already handles.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| ] | ||
|
|
||
|
|
||
| def test_rich_text_choice_is_never_taken_as_the_prompt(): |
There was a problem hiding this comment.
[SUGGESTION]: The exclusion is pinned only through the label nesting shape
The fixture nests the rich-text choice at fieldset > table > tr > td > label, so only the label branch of _inside_options is exercised: narrowing that set to just label keeps both new tests green while a block in a <td> (or direct <fieldset> child) without a <label> would again be mislabeled the prompt. One more case with the block inside <table>/<fieldset> but outside any <label> would pin the other branches.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| rpc_call = client._request.call_args_list[1] | ||
| # Brightspace rejects the RPC unless params is compact JSON (browser form). | ||
| assert rpc_call.kwargs["data"]["params"] == ( | ||
| '{"param1":"20","param2":"30","param3":true,"param4":true,"param5":true,"param6":false,"param7":""}' |
There was a problem hiding this comment.
[SUGGESTION]: The byte-for-byte assertion pins only the param5: true branch of the Boolean(string) conversion
The fixture's HDN_isRldbUse=False string yields a truthy bool(...), so a refactor to compare against the literal true string (breaking the documented JS Boolean(string) semantics) would still pass. A second case with an empty HDN_isRldbUse expecting param5 false would pin the falsy branch too.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| _attempt(31), # new, own, incomplete | ||
| _attempt(32, completed="2999-01-01T00:05:00Z"), # completed | ||
| _attempt(33, actor_id=8), # another account | ||
| _attempt(29, started="2000-01-01T00:00:00Z"), # started long before this start |
There was a problem hiding this comment.
[SUGGESTION]: The _START_SKEW boundary and the started is None drop arm are untested
The skew filter is only exercised at extremes (2999 kept, year 2000 dropped), so a mutant changing the 10-minute window to 0 or to hours passes; and no test exercises a missing Started value with an intent present (test_candidate_output_never_echoes_server_text hits a null Started only on a checkpoint without start_intent_at, where the filter is bypassed). A candidate at exactly intent - 10:00 (kept) and one with Started absent plus intent present (dropped) would pin both arms.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| unknown_start(workflow) | ||
| workflow.abandon() | ||
| state["attempts"] = [_attempt(31)] | ||
| with patch("lighthouse_cli.quiz_preview_session.read_server_current_preview", |
There was a problem hiding this comment.
[SUGGESTION]: The bind-path server readback is never asserted against its arguments
The read mock ignores its inputs and nothing checks read.call_args, so this test would still pass if _resolve_start requested the server page for the wrong attempt or page - the fixed return value masks it. Sibling tests pin this correctly (server.call_args.kwargs[attempt_id] == 31, strict.call_args.kwargs[page] == 1); asserting read.call_args.kwargs[attempt_id] == 31 here would match.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
|
|
||
|
|
||
| @pytest.mark.parametrize("plain", [True, False]) | ||
| def test_oversized_attempt_listing_refuses_start_before_dispatch(remote, plain): |
There was a problem hiding this comment.
[SUGGESTION]: The _MAX_ATTEMPT_PAGES (50-page) exhaustion path has no test
Both parametrizations trip the 10_001-item cap, which only needs two wrapped pages; the separate loop bound that raises Too many attempt pages to reconcile safely. after 50 bookmark hops of small pages is never reached, so a regression in that counter would go undetected.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 16 Issues Found | Recommendation: Address before merge Overview
Note: PR #45 is already merged; treat these as follow-ups. All findings were verified against head Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (11 files)
Reviewed by glm-5.3-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |

Summary
Makes trial quiz previews work end to end from the CLI, and makes an uncertain preview start recoverable without ever replaying it. Closes #24.
Live defects fixed (found by running the CLI against the throwaway trial):
<d2l-html-block>without the legacyd2l_read_element_wrapper. It is now parsed.ProcessQuizSubmissionRPC (error redirect) unlessparamsis compact JSON, and the browser sends the current page in the RPC context. Both now match the browser's request, verified against a capture of the real UI submit.PreviewRefusedErrors with specific fixed messages, raised only before the first state-changing request.#24 recovery (per the 2026-09-22 handoff, a Codex plan review and two code reviews):
on_identitycallback the moment the start reveals them, before the page readback.preview reconcile:--attempt-idis refused.--attempt-idfrom that list. The attempt must also be in progress, on a supported layout, and on a verified preview page; it is then bound at the server's current page.abandonkeeps an unresolved-start marker, andstartrefuses until the start is reconciled. This includes checkpoints saved by older code.reconcile --confirm-no-remote-attemptrecords an operator disposition after a browser check. It is allowed only for an unbound start with no listed candidate, so the guard cannot deadlock a quiz.Live validation (throwaway trial, authorized by the owner)
--retain--attempt-idrefused; reconcile resumed; 2/2Observed and documented: requesting a page beyond a quiz's last page permanently breaks the preview attempt. No code path does this;
nextonly reads a page that exists.Size
Source +471/−46, tests +647/−15. Most of the source is the reconcile/snapshot logic in
quiz_preview_session.py. The session tests follow #24's acceptance matrix and were mutation-checked: each safety behavior was removed in turn and a test failed every time.Validation
Local gate at
4450f95: ruff, mypy, lint-imports, deptry, xenon andcheck_secrets.pyall pass. Pytest: 1575 passed.Review evidence
GPT-6-Astra — xhigh reasoning (plan): GO WITH CHANGES; all changes adopted.
GPT-6-Astra — xhigh reasoning (code,
823f376): BLOCK; all 7 findings fixed in87bc3c0.GPT-6-Astra — xhigh reasoning (re-review,
87bc3c0): SHIP WITH FOLLOW-UPS; its one P2 (listing limit on plain lists) fixed ina8a8007.Hosted bots on
a8a8007, all fixed in4450f95:Kilo did not finish; it had been pending for over 45 minutes at merge time.
Other local reviewers were skipped for this PR at the owner's request.
Scope note: this is the preview engine and trial test harness. The MAHE-only follow-ups are planned separately: removing trial code, and a
student attemptcommand for real attempts.🤖 Generated with Claude Code