Skip to content

fix: recoverable, exactly-once quiz preview starts and working live submit - #45

Merged
rabesss merged 5 commits into
mainfrom
fix/issue-24-preview-recovery
Sep 23, 2026
Merged

rabesss merged 5 commits into
mainfrom
fix/issue-24-preview-recovery

Conversation

@rabesss

@rabesss rabesss commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

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):

  • Start always ended "uncertain". The live question prompt is a single <d2l-html-block> without the legacy d2l_read_element_ wrapper. It is now parsed.
  • Submit always failed. Brightspace rejects the ProcessQuizSubmission RPC (error redirect) unless params is 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.
  • Refusals were unreadable. The hidden-quiz start showed "Network error. Check your connection". A question not on the page, unanswered questions, or submitting early showed "Command failed.". These are now 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):

  • The attempt id and page are sealed through an on_identity callback the moment the start reveals them, before the page readback.
  • Before dispatching a start, the account's existing attempts on the quiz are snapshotted, along with the start time. If that listing fails, the start is refused before any request.
  • New read-only preview reconcile:
    • A bound start is verified at its known cursor. A completed one goes through the receipt check. A different --attempt-id is refused.
    • An unbound start only lists candidates: new since the snapshot, own, in progress, started after the intent.
    • Binding needs an explicit --attempt-id from 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.
    • A failed check leaves the checkpoint unchanged, and an empty listing never clears uncertainty.
  • abandon keeps an unresolved-start marker, and start refuses until the start is reconciled. This includes checkpoints saved by older code.
  • reconcile --confirm-no-remote-attempt records 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.
  • Attempt-list paging stays on this quiz's attempts route (bookmark links only), and the listing is bounded.

Live validation (throwaway trial, authorized by the owner)

Scenario Attempt Result
One question per page, full flow, --retain 29226 2/2, receipt verified, retained
All on one page 29227 2/2, receipt verified
Known-ID uncertain start (simulated readback failure after a real start) 29228 start refused before/after abandon; wrong --attempt-id refused; reconcile resumed; 2/2
Lost start response, attempt advanced outside the CLI 29229 only the new attempt listed; bound at server page 2; 2/2
Lost start response, all-on-one-page 29231 confirm refused while a candidate existed; bound; 2/2

Observed and documented: requesting a page beyond a quiz's last page permanently breaks the preview attempt. No code path does this; next only 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 and check_secrets.py all 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 in 87bc3c0.

  • GPT-6-Astra — xhigh reasoning (re-review, 87bc3c0): SHIP WITH FOLLOW-UPS; its one P2 (listing limit on plain lists) fixed in a8a8007.

  • Hosted bots on a8a8007, all fixed in 4450f95:

    • Pullfrog (must-address): a bound start whose attempt advanced in the browser could not be resumed. It now falls back to the server-reported page on supported layouts. Pullfrog's re-review found no new issues.
    • Codex: a rich-text answer choice could be taken as the question prompt.
    • Codex: refusals that need only the local cursor now run before authentication.
  • 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 attempt command for real attempts.

🤖 Generated with Claude Code

rabesss and others added 4 commits September 23, 2026 17:04
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-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T12:13:35.618237Z a8a8007 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@factory-droid

factory-droid Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Droid encountered an error —— View job

Droid Exec exited with code 1:
Tool "Edit" skipped (GPT-5.2 uses ApplyPatch instead).
Tool "Create" skipped (GPT-5.2 uses ApplyPatch instead).

Security Review

@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no concrete correctness, security, or repository-rule violation remains.

Summary

This PR makes instructor quiz previews operational against the observed Brightspace layouts and adds durable, exactly-once recovery for uncertain starts.

  • Parses the live custom-element question prompt layout and provides actionable pre-write refusals.
  • Aligns final submission RPC encoding and page context with browser behavior.
  • Snapshots existing attempts, seals newly revealed identities, and blocks replay of unresolved starts.
  • Adds read-only remote reconciliation with explicit candidate binding and operator disposition.
  • Extensively tests recovery, pagination confinement, identity verification, JSON output, and submission behavior.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Start requested] --> B[Snapshot existing own attempts]
  B --> C[Persist uncertain start intent]
  C --> D[Dispatch start once]
  D --> E{Attempt identity revealed?}
  E -->|Yes| F[Seal attempt and page]
  E -->|No or readback fails| G[Keep unresolved checkpoint]
  F --> H{Page readback succeeds?}
  H -->|Yes| I[Activate preview]
  H -->|No| G
  G --> J[Reconcile]
  J --> K{Identity already bound?}
  K -->|Yes| L[Verify bound attempt and cursor]
  K -->|No| M[List new own in-progress candidates]
  M --> N{Explicit candidate selected?}
  N -->|Yes| O[Verify detail, layout, and preview page]
  N -->|No candidates and operator confirms| P[Record no remote attempt]
  L --> I
  O --> I
Loading

Reviews (1) · Last reviewed commit: "fix: bound plain-list attempt listings; ..."

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread lighthouse_cli/quiz_attempt_page.py Resolved
Comment thread lighthouse_cli/quiz_preview_session.py Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_page now accepts a question prompt delivered as a single d2l-html-block (no legacy d2l_read_element_ id), which is what made every live start end "uncertain".
  • Working live submit: the ProcessQuizSubmission RPC now sends compact params JSON and names the actual current page (pg) in the RPC context and Referer, matching the browser capture.
  • Specific pre-dispatch refusals: new PreviewRefusedError with 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_at is sealed before dispatch; on_identity seals (attempt_id, page) before the page readback; the unresolved_start guard survives abandon (including legacy checkpoints) and blocks re-starting; a read-only reconcile lists/binds candidates with strictly validated, bounded attempt-list paging that can never leave the attempts route.
  • Server-page recovery: read_server_current_preview binds 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 makes abandon no longer release the guard and start refuse. The actionable advice is now reconcile; 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 check on the five changed lighthouse_cli modules → clean.
  • Full exception-matrix trace of PreviewWorkflow.run/reconcile/_resolve_start against start_preview's dispatch boundaries; cross-checked with a reviewfrog specialist pass (exactly-once lens).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

Comment thread lighthouse_cli/quiz_preview_session.py Resolved
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>
@factory-droid

factory-droid Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Droid encountered an error —— View job

Droid Exec exited with code 1:
Tool "Edit" skipped (GPT-5.2 uses ApplyPatch instead).
Tool "Create" skipped (GPT-5.2 uses ApplyPatch instead).

Security Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ 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 4450f95 and 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_start falls back to read_server_current_preview for that exact attempt (same strict ou/qi/ai/isprv identity), 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 at preview 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 page at reconcile: 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.

 Pullfrog | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

Pullfrog  | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@rabesss
rabesss merged commit 9f971ab into main Sep 23, 2026
15 of 16 checks passed
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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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"}:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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; "

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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":""}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[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.

@kilo-code-bot

kilo-code-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 16 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 14

Note: PR #45 is already merged; treat these as follow-ups. All findings were verified against head 4450f95. No secret-leakage, --json stdout-contract, or typing-convention violations were found.

Issue Details (click to expand)

WARNING

File Line Issue
lighthouse_cli/quiz_preview_session.py 219 Unparseable/missing Started silently drops candidates, enabling a premature --confirm-no-remote-attempt while a live attempt may exist
lighthouse_cli/quiz_attempt_page.py 71 Residual prompt-confusion: _inside_options exclusion set may miss div/list/custom-element choice wrappers

SUGGESTION

File Line Issue
lighthouse_cli/quiz_preview_session.py 117 disposition never cross-checked against status/unresolved_start in _load
lighthouse_cli/quiz_preview_session.py 171 Non-JSON 200 body bypasses the _LISTING_INVALID fail-closed contract
lighthouse_cli/quiz_preview_session.py 378 start skips the actor check; another account can overwrite the prior receipt/disposition checkpoint
lighthouse_cli/quiz_preview_session.py 380 Message dead-ends for uncertain answer/next (only preview page recovers there)
lighthouse_cli/quiz_attempt_page.py 208 Advance refusal blames unanswered questions when the blocker is an unsupported question
lighthouse_cli/quiz_attempt_page.py 259 Sole-block fallback runs even for containers with no radios (display confusion)
lighthouse_cli/quiz_preview_transport.py 161 BaseException from on_identity/readback escapes without attaching identity (docstring contract)
lighthouse_cli/quiz_preview_commands.py 43 Confirm-gate asymmetry: reconcile bypasses the prompt while local-only abandon requires one
docs/assessment-coverage.md 193 before any request / cursor unchanged overclaims (before any write request; cursor restored)
tests/test_quiz_attempt_page.py 87 Fallback exclusion pinned only via the label nesting shape; fieldset/table branches untested
tests/test_quiz_preview_finish.py 44 Byte-for-byte params assertion pins only the param5: true branch
tests/test_quiz_preview_session.py 217 _START_SKEW boundary and started is None-with-intent arm untested
tests/test_quiz_preview_session.py 259 Bind-path server readback call args unpinned
tests/test_quiz_preview_session.py 353 _MAX_ATTEMPT_PAGES 50-page exhaustion path untested

Fix these issues in Kilo Cloud

Files Reviewed (11 files)
  • lighthouse_cli/quiz_preview_session.py - 5 issues
  • lighthouse_cli/quiz_attempt_page.py - 3 issues
  • lighthouse_cli/quiz_preview_transport.py - 1 issue
  • lighthouse_cli/quiz_preview_commands.py - 1 issue
  • lighthouse_cli/quiz_preview_finish.py - clean
  • docs/assessment-coverage.md - 1 issue
  • README.md - clean
  • .secrets.baseline - clean (line-number drift only, no new allowlist entry)
  • tests/test_quiz_preview_session.py - 3 issues
  • tests/test_quiz_attempt_page.py - 1 issue
  • tests/test_quiz_preview_finish.py - 1 issue

Reviewed by glm-5.3-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

@rabesss
rabesss deleted the fix/issue-24-preview-recovery branch October 14, 2026 13:08
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.

[P1] Trial preview start can create a remote attempt while CLI reports unknown and blocks resume

1 participant