Repository navigation
feat(instructor): draft-only assignment feedback - #90
Conversation
Add 'instructor assignment-feedback', a comment-only draft write: preflight reads the user's EntityDropbox and refuses published, graded, scored, rubric, attached or group feedback; a confirmed run re-checks the target just before one POST; readback must prove the draft. Ambiguous outcomes report unknown and are never retried. Feedback text is never printed. Refs #35, #26
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
|
Droid finished @rabesss's task —— View job Validated the finding: edits to an existing draft during confirmation are not detected and can be overwritten. A new isolated check using the actual preflight definitions reproduced the equality failure; the existing confirmation tests could not run because pytest is not installed. 1 inline comment posted |
[Medium impact] The PR adds a bounded write for one learner’s assignment feedback. Fix the confirmation comparison before merging so it cannot silently overwrite another assessor's edits. Findings
SummaryAdds
Acknowledged limits:
|
| if existing.strip() and not replace_draft: | ||
| raise FeedbackRefusedError( | ||
| "This submission already has a draft comment. Pass --replace-draft to replace it. Nothing was sent.") | ||
| return FeedbackTarget(replaces_draft=bool(existing.strip())) |
There was a problem hiding this comment.
Draft edits get silently overwritten
With --replace-draft, another assessor can edit an existing draft while the confirmation prompt is open. Both reads return FeedbackTarget(replaces_draft=True), so the comparison passes and the POST silently overwrites their new comment.
Keep the existing feedback content in FeedbackTarget and compare it on the second read. Add a test where both reads contain different nonempty drafts; the current replacement test starts without feedback.
| ): | ||
| fail("Feedback cancelled.", json_output, {"cancelled": True}) | ||
| # The prompt can take minutes; check again just before the write. | ||
| if preflight(api, ids["folder_id"], ids["user_id"], replace_draft=replace_draft) != target: |
There was a problem hiding this comment.
[P1] Compare draft contents during the confirmation recheck
With --replace-draft, another assessor can edit the existing draft while the confirmation prompt is open, but this comparison still passes: FeedbackTarget contains only replaces_draft, so both preflights return FeedbackTarget(True) regardless of the comment's contents. The POST then silently overwrites the intervening edit, contrary to the documented changed-target refusal. Preserve and compare the existing feedback contents or a fingerprint, not just whether a draft exists. The current regression test only exercises a transition from no comment to an existing comment.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- New
instructor assignment-feedbackcommand (lighthouse_cli/assignment_feedback.py,_feedbackinassessment_commands.py): saves a draft, comment-only RichText feedback on one learner's individual submission — strict input validation before any client construction, preflight refusal of published/graded/scored/rubric/attached/group targets,--replace-draftgating, an interactive confirm on stderr that names only ids/host, a post-confirm re-preflight, and a single never-replayed POST proven through two readbacks with ambiguous outcomes reported as"outcome": "unknown"and never retried. AssessmentAPI.send_onceextraction fromwrite— verified behavior-preserving (same unknown-outcome mapping for network/401/429/5xx/redirect, documented refusals keep their status, CSRF-bootstrap failure stays a pre-dispatch clean refusal); the solewrite()caller is unchanged.- Docs: README wiring, new
docs/assignment-feedback.mdcontract table + owner live check, quiz-protocol gap table update; import-linter layer registration for the new module. tests/test_assignment_feedback.py: 108 synthetic-fixture tests covering payload shape, refusals, confirmation flow, transport/ambiguous-status taxonomy, readback mismatches, and secret non-leakage.
I verified the D2L contract against the live developer reference (November 2026 edition): POST/GET .../dropbox/folders/(folderId)/feedback/(entityType)/(entityId) (LE 1.82+, no trailing slash) with Feedback as RichText {Text, Html} (correctly not RichTextInput), GET .../submissions/user/(userId) (1.88+), DropboxFeedbackOut shape, ENTITYDROPBOXSTATUS_T semantics, and the 403/404-vs-429 status mapping — all match the implementation. Locally: the 108 new tests pass, full suite 3088 passed with only the 4 known runner-environmental failures (3× test_quiz_media chardet mojibake, 1× test_session_renewal python3 -I), and ruff / mypy / lint-imports / deptry / xenon are clean. The offline-only status is honestly documented in the README, the docs, and the command docstring, with the residual live risks (entity Status staying 1, Text rewriting) already enumerated in the owner live check.
glm-5.3 | 𝕏
- Re-check compares a digest of the record's status and feedback, so a draft rewritten during confirmation is refused. - Existing and read-back feedback must be a complete DropboxFeedbackOut; readback applies the same draft-only checks (rubric, files, links). - Read the folder and refuse group-submission folders (GroupTypeId). - Only 400/403/404 after the POST are refusals (outcome refused); any other status is unknown. A published or graded readback says so. - Fetch CSRF before the preflight; Ctrl-C at the prompt cancels; an interrupt during the save reports unknown. - Accept Status as a digit string (the reference types it as a string); non-blocking open refuses FIFOs; normalize lone CRs.
|
Droid finished @rabesss's task —— View job Both candidates are validated: inconsistent final readbacks can report false success, and generated HTML collapses comment whitespace. New isolated checks using the actual function definitions reproduced the readback issue, verified its exact suggestion, and confirmed the whitespace-collapsing markup. The existing assignment-feedback tests could not run because pytest is unavailable; importing the full module also requires the missing bs4 dependency. 2 inline comments posted |
| block = _user_entity(api.client.get_json(submissions_route), user_id) | ||
| if _status(block) != _DRAFT: | ||
| raise _UnexpectedError() | ||
| _check_draft_only(block.get("Feedback")) |
There was a problem hiding this comment.
[P2] Compare the comment in the final submission readback
If another assessor replaces the draft between the two verification GETs, the feedback GET can contain the requested comment while the subsequent submission GET contains a different one. This final check validates only draft metadata, so the command reports saved-draft despite observing that the requested comment is no longer present. Apply the same text/HTML comparison to the submission's feedback and report unknown when neither representation matches.
| _check_draft_only(block.get("Feedback")) | |
| feedback = _check_draft_only(block.get("Feedback")) | |
| saved_text, saved_html = _rich_text(feedback) | |
| if _normalize(saved_text) != text and saved_html != _html(text): | |
| raise _UnexpectedError() |
|
|
||
|
|
||
| def _html(text: str) -> str: | ||
| return "<p>" + html.escape(text, quote=True).replace("\n", "<br />") + "</p>" |
There was a problem hiding this comment.
[P2] Preserve plain-text whitespace in the generated HTML
A valid UTF-8 comment containing indented code, tabs, or repeated spaces loses that formatting when the generated HTML is displayed: wrapping escaped text in <p> and replacing only newlines leaves ordinary HTML whitespace collapsing enabled. For example, the indentation in if ready:\n return value disappears, although verification still succeeds because the generated HTML matches what was sent. Generate whitespace-preserving HTML so the displayed comment retains the file's formatting.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new commit 6dabfd9 closes the council round-1 gaps on top of the previously approved 28ea0a2; I re-verified each fix against the code and its new tests.
- Added a folder preflight (
GET .../dropbox/folders/{folder}) that refuses group-submission folders (GroupTypeIdpresent and non-null) and unreadable folder objects before any submission read. - Tightened existing-feedback validation to require a complete
DropboxFeedbackOut(all seven keys,RubricAssessments/Files/Linksmust be lists), applied identically to the preflight and both readbacks — a partial block can no longer hide a score or attachment. - Strengthened the post-confirm re-check from a
replaces_draftbool to a sha256 fingerprint of{Status, Feedback}, so a draft whose text was changed by another assessor during the prompt now aborts before the POST. - Split the POST outcome taxonomy: only 400/403/404 after dispatch are
\"outcome\": \"refused\"; every other status (405/408/409/412/422, …) is\"unknown\", and a readback showing published/graded feedback gets a distinct "check it now; do not retry" message. - Bootstrapped CSRF before the preflight (the token is cached in
LighthouseClient, so the last read genuinely sits right before the POST) and hardened the command edges: Ctrl-C at the prompt is a clean cancel, an interrupt during the save reports unknown, the file read refuses FIFOs/non-regular files without hanging (O_NONBLOCK+S_ISREG), lone\ris normalized, andStatusis accepted as a digit string. - Extended the suite by 31 tests (139 total) covering every one of the above, and updated the
docs/assignment-feedback.mdcontract table and owner live check to match.
Verification on this delta: tests/test_assignment_feedback.py 139/139 green; full suite 3119 passed with only the 4 known runner-environmental failures (3× test_quiz_media chardet, 1× test_session_renewal python3 -I), identical signature to the pre-delta baseline; ruff, mypy (strict, changed modules), xenon, and lint-imports all clean; no stale references to the renamed symbols and no path that prints feedback text or credentials (the fingerprint is a hash, and the new fixed messages route through str(exc), not the display formatter).
The remaining unknowns are exactly the ones the PR already gates on: whether the live LMS returns complete DropboxFeedbackOut blocks for fresh submissions and digit-string statuses is what the documented owner live check exists to answer.
glm-5.3 | 𝕏
- refuse a submission record with no Feedback key - compare the comment in the second (submission) readback too - treat any POST status other than the documented 200 as unknown - name scored readbacks in the published warning
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new commit 61571b5 tightens the save/verification contract on top of the previously approved 6dabfd9; each change matches the D2L reference and carries its own test.
- Tightened the POST outcome to the documented success only:
_SAVED_STATUS = 200in_send— any other 2xx/3xx the transport passes through now reports"outcome": "unknown"instead of falling through to the readbacks, with the response still closed in afinally. - Required the
Feedbackkey to be present on the preflight entity record (null or an object); an absent key is now a clean "record is incomplete" refusal rather than silently reading as no feedback. - Closed the readback-2 gap: the entity record's
Feedbackmust now pass the same complete-shape draft-only check and match the saved comment (Text, or exact Html) as the feedback-endpoint readback, via the extracted_check_saved_comment. - Updated the appears-published message to "published, graded or scored", which now accurately names all three
_PublishedReadbackErrortriggers (status 3,IsGradedtrue, non-nullScore/GradedSymbol). - Extended the suite from 139 to 147 tests: non-200 POST statuses (201/202/204/300/304) → unknown,
Feedback-key-absent preflight refusal, and entity-text-mismatch / key-absent readbacks → unknown; the docs contract table and owner live check were updated to match.
I verified the central claim against the live reference (November 2026 edition): the feedback POST documents exactly four statuses — 200 OK, 403, 404, 429 — so 200 is the only documented success, and 429 was already mapped to unknown inside send_once. In production a 3xx never actually reaches the new check (_do_request raises on redirects for writes), which makes it a correct backstop for the other-2xx window that raise_for_status passes through. Locally: 147/147 in tests/test_assignment_feedback.py, ruff clean, mypy clean on the touched modules (the remaining errors are the known environmental ones in ms_auth.py plus a newer-mypy-only diagnostic in api.py — both files untouched by this PR).
glm-5.3 | 𝕏
- existing feedback whose comment is null or {} needs --replace-draft
- a readback whose Text and Html disagree is unknown, not saved
- accept Html that D2L reformats when its plain text matches
|
Droid encountered an error —— View job |
- an empty Text or Html part in a readback is present and must match - Html matches only as sent or as <p>/<br>-only markup with the same text; any other tag, or changed spaces, is unknown - treat non-breaking spaces alike on both sides
|
Droid encountered an error —— View job |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new commit 8c4271a closes the council round-3 RichText gaps on top of the previously approved 61571b5; I re-verified each fix against the code, its tests, and an independent execution of the match matrix.
- Gated unreadable existing comments behind
--replace-draft:_existing_commentnow returnsstr | None, distinguishing a readable empty comment ({"Text": "", "Html": ""}— no flag needed) from a complete-but-unreadable one (Feedbacknull,{}, or all parts null), which refuses without the flag with a distinct "comment could not be read" message whilereplaces_draftcorrectly reportstruewith it. - Enforced per-part comment agreement on both readbacks:
TextandHtmlare each checked when present (Textmodulo line-ending normalization,Htmlexact or plain-text-equivalent), so aText/Htmldisagreement — or a present-but-mismatched single part — is"outcome": "unknown"instead of passing on one matching part, with absent parts left unconstrained. - Accepted D2L-reformatted
Htmlwith the same plain text: the new_html_textextractor (<p>/<br>variants including attributes and ) recognizes paragraph splits and<br>rewrites of the sent<br />line breaks as the same comment. - Extended the suite from 147 to 156 tests covering each rule (three unreadable shapes, both disagreement directions on both readback routes, three reformatted-
Htmlvariants) and updated thedocs/assignment-feedback.mdcontract rows to match.
Verification on this delta: 156/156 in tests/test_assignment_feedback.py; full suite 2995 passed with only the known runner-environmental failures (1× test_session_renewal python -I, 3× test_quiz_media chardet — identical signature to the prior baselines); ruff, mypy (strict), xenon, lint-imports and scripts/check_secrets.py all clean. I also spot-checked the match matrix beyond the suite (absent parts, whitespace-only comments, non-dict and non-string Feedback shapes, entity-id guards) — behavior matches the documented contract in every case, and no path prints the comment text.
The residual strictness (a live D2L that trims a trailing newline from Text, or emits attribute-bearing <br> tags, would report "unknown") is the safe, never-retried direction and is exactly what owner-live-check step 5 and #91 exist to calibrate — nothing to change before that run.
glm-5.3 | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The new commit 0443f93 ("exact comment readback") tightens the readback comparison introduced in 8c4271a; it landed while the previous review was being submitted, so this covers only that delta.
- Made every present comment part authoritative, even an empty string:
_check_saved_commentnow treatsText: ""orHtml: ""as present-and-must-match (previously empty strings slipped through as falsy), so a readback mixing an empty part with a matching one is"outcome": "unknown"— matching the updated "any other markup is a mismatch" contract row. - Restricted the reformatted-
Htmlfallback to paragraph/line-break-only markup:_html_textstrips exactly one outer<p …>/</p>, converts bare<br>variants and interior paragraph boundaries, and returns a mismatch for any other tag (<b>,<div>,<img>,<pre>, attribute-bearing<br>); the strip-all-tags_TAGhelper is gone, closing the path where a saved comment with extra elements could pass on loose text extraction. - Tightened equivalence to exact:
_comparablenormalizes only non-breaking spaces and strips only outer line breaks — outer spaces and inner whitespace collapse are now mismatches (previously tolerated by.strip()), while entity-decoded text and<p>/<br>reflowing of the same content still verifies. - Extended the suite from 156 to 171 tests: eight direct
_check_saved_commentrejection cases (outer/inner spaces, extra image, bold,div, empty parts, both-null), three equivalence acceptances (trailing newline dropped inHtmlonly, html-only escaped text, ), and four new unknown-outcome routes including the entity readback; thedraft_feedback_outfixture default moved toHtml: Nonebecause a present-empty part now matters.
Verification on this delta: 171/171 in tests/test_assignment_feedback.py; full suite 3010 passed with only the known runner-environmental failures (1× test_session_renewal python -I, 3× test_quiz_media chardet — identical signature to every prior baseline); ruff, mypy (strict), xenon, lint-imports and scripts/check_secrets.py all clean. I also ran an adversarial sweep of the new matcher beyond the suite — <pre> vs <p\b, attribute-bearing <br>, double-wrapped paragraphs, wrapper-free fragments, empty-part combinations, and a Text-side trailing-newline trim — every case lands on the documented side of the contract, and no path prints the comment text or any credential.
glm-5.3 | 𝕏

Summary
First bounded instructor write for #35:
lighthouse instructor assignment-feedback COURSE_ID FOLDER_ID USER_ID --file PATH [--replace-draft] [--yes] [--dry-run] [--json]saves a draft, comment-only feedback on one learner's individual submission. It is not published, the learner cannot see it, and no score is set.Refs #35, #26. This does not close #35: the live check below still needs the owner's account.
Contract evidence (offline)
From the D2L developer reference (
res/dropbox.html, November 2026 edition) andbasic/conventions.html:POST .../dropbox/folders/{f}/feedback/user/{u}(LE 1.82+; the CLI uses 1.93) takesDropboxFeedback {Score, Feedback: RichText, RubricAssessments, IsGraded, GradedSymbol}. The reference marksFeedbackas RichText ({Text, Html}), not RichTextInput.mysubmissionsincludes feedback "if published". ENTITYDROPBOXSTATUS_T is 0 Unsubmitted, 1 Submitted, 2 Draft, 3 Published.GET .../feedback/user/{u}returns DropboxFeedbackOut andGET .../submissions/user/{u}(1.88+) returns EntityDropbox.Score: nulland has no score option.Changes
lighthouse_cli/assignment_feedback.py(new):IsGraded: false,Score/GradedSymbolnull, no rubric, RichText Text plus escaped HtmlGroupTypeId)--replace-draft"outcome": "refused"); any other status is unknown, and a published or graded readback says soassessment_api.py: the dispatch step ofwriteis extracted intosend_once, with the same unknown-outcome mapping (network, 401, 429, 5xx, redirect). Behaviour is unchanged.assessment_commands.py: the command.--yescancels before any request.--dry-runuses a read-only auth client and sends no POST and no CSRF request.--fileis a plain string checked inside the command, so its path is never echoed."outcome": "unknown"and are never retried.docs/assignment-feedback.md(contract table and live check), and the Assignments row indocs/quiz-protocol.md..secrets.baseline: only the line number of an already-audited README entry moved.Verification
tests/test_assignment_feedback.py: 171 tests on synthetic fixtures.0443f93.scripts/check_secrets.py.Council record
28ea0a26dabfd961571b58c4271a0443f93Round 1's P1s were fixed in
6dabfd9: the draft-change re-check, the complete feedback shape, group folders and undocumented POST statuses.Round 2's P1s were fixed in
61571b5:Feedbackkey is refused;Round 3's P1s were fixed in
8c4271a:{}needs--replace-draft;TextandHtmldisagree is unknown;Htmlthat D2L reformats is accepted only when its plain text matches.Round 4's P1s were fixed in
0443f93. An empty readback part now has to match, and Html matches only when its markup is made of<p>and<br>alone and its text is exactly the comment.Round 5, Terra's P1 downgraded to P2. An Html readback whose
<p>carries attributes, such as<p hidden>, is still accepted when its text matches. The command sends<p>with no attributes, so this would need Brightspace to add a visibility attribute when storing it, or another writer acting in the TOCTOU window. Every safety check still holds in both readbacks: not published or graded, no score, files or rubric, Status Draft, the same user, andText(when present) matching exactly. A hidden comment is less visible, not more. Opus rated the same case P3. This shape reportssaved-draftinstead of failing closed, so it is tracked in [P3] assignment-feedback follow-ups from the #90 council #91 with a fix.Rounds 4 and 5 were authorized by the owner's standing grant for today's runs. The
droid-reviewbot check failed on its usage limit, not on a finding.Follow-ups: [P3] assignment-feedback follow-ups from the #90 council #91.
Owner live check (not run by the agent; needs your account)
With a synthetic course, assignment and test learner you own (also in
docs/assignment-feedback.md):--dry-run --jsonon a submission with no feedback. Note the record'sFeedback(null or{}) andStatus, and the HTTP status of the save in step 2 (only 200 is accepted).<,&and quotes.lighthouse student assignment-historyshow no feedback or grade."outcome": "unknown", record the readbackText/Html/Status, because the check then needs adjusting.Known limits
D2L has no conditional write, so a small window remains between the last preflight read and the POST. Follow-ups: #91. Out of scope:
Reviewer checklist
pytest -qpasses (full suite green on a cloud box).ruff check .is clean.mypy(strict) is clean.--jsonstdout contract preserved; prompts go to stderr.tests/.