Skip to content

feat(instructor): draft-only assignment feedback - #90

Merged
rabesss merged 6 commits into
mainfrom
feat/35-draft-assignment-feedback
Nov 8, 2026
Merged

rabesss merged 6 commits into
mainfrom
feat/35-draft-assignment-feedback

Conversation

@rabesss

@rabesss rabesss commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

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) and basic/conventions.html:

  • POST .../dropbox/folders/{f}/feedback/user/{u} (LE 1.82+; the CLI uses 1.93) takes DropboxFeedback {Score, Feedback: RichText, RubricAssessments, IsGraded, GradedSymbol}. The reference marks Feedback as RichText ({Text, Html}), not RichTextInput.
  • "If [IsGraded is] true, the feedback is in a graded state; otherwise, it's still in draft state." mysubmissions includes feedback "if published". ENTITYDROPBOXSTATUS_T is 0 Unsubmitted, 1 Submitted, 2 Draft, 3 Published.
  • Readback: GET .../feedback/user/{u} returns DropboxFeedbackOut and GET .../submissions/user/{u} (1.88+) returns EntityDropbox.
  • The docs do not say whether a draft score stays out of the gradebook, so this slice sends Score: null and has no score option.

Changes

  • lighthouse_cli/assignment_feedback.py (new):
    • payload: IsGraded: false, Score/GradedSymbol null, no rubric, RichText Text plus escaped Html
    • strict UTF-8 file input
    • folder read: refuses group-submission folders (GroupTypeId)
    • preflight validation: single user entity; status 1 or 2; existing feedback must be a complete DropboxFeedbackOut; refuses published, graded, scored, symbol, rubric, files or links; existing draft text needs --replace-draft
    • one POST followed by two readbacks with the same draft-only checks (Text, or Html exactly as sent; entity status Draft)
    • only 400/403/404 after the POST count as refusals ("outcome": "refused"); any other status is unknown, and a published or graded readback says so
  • assessment_api.py: the dispatch step of write is extracted into send_once, with the same unknown-outcome mapping (network, 401, 429, 5xx, redirect). Behaviour is unchanged.
  • assessment_commands.py: the command.
    • The client is built only after input validation. A non-TTY run without --yes cancels before any request.
    • The confirmation prompt goes to stderr and names the user, assignment, course, host and draft status.
    • A confirmed run re-checks the target just before the POST and compares a digest of the existing feedback, so any change made during the prompt means nothing is sent. CSRF is fetched before the preflight.
    • Ctrl-C at the prompt cancels; an interrupt during the save reports unknown.
    • --dry-run uses a read-only auth client and sends no POST and no CSRF request.
    • --file is a plain string checked inside the command, so its path is never echoed.
  • The feedback text and display names are never printed. Ambiguous outcomes print "outcome": "unknown" and are never retried.
  • Docs: README, docs/assignment-feedback.md (contract table and live check), and the Assignments row in docs/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.
  • Full suite on a cloud box (Python 3.11): 3160 passed on 0443f93.
  • Clean locally: ruff, mypy strict, lint-imports, deptry, xenon, scripts/check_secrets.py.
  • Plan reviewed by Terra xhigh.

Council record

Round Head Terra xhigh Muse Spark xhigh Opus high
1 28ea0a2 changes changes approve
2 6dabfd9 changes (3 P1) approve approve
3 61571b5 changes (2 P1) approve approve
4 8c4271a changes (2 P1) approve approve
5 0443f93 1 P1, downgraded to P2 (see below) approve approve
  • Round 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:

    • a record with no Feedback key is refused;
    • the second readback compares the comment;
    • any POST status other than 200 is unknown.
  • Round 3's P1s were fixed in 8c4271a:

    • existing feedback whose comment is null or {} needs --replace-draft;
    • a readback whose Text and Html disagree is unknown;
    • Html that 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, and Text (when present) matching exactly. A hidden comment is less visible, not more. Opus rated the same case P3. This shape reports saved-draft instead 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-review bot 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):

  1. Run --dry-run --json on a submission with no feedback. Note the record's Feedback (null or {}) and Status, and the HTTP status of the save in step 2 (only 200 is accepted).
  2. Save a draft. In the instructor UI, confirm it is a draft and that the text survives intact, including line breaks, <, & and quotes.
  3. As the learner, confirm the submission page and lighthouse student assignment-history show no feedback or grade.
  4. Confirm no grade is released and that an existing gradebook value is unchanged.
  5. If a save that worked reports "outcome": "unknown", record the readback Text/Html/Status, because the check then needs adjusting.
  6. Confirm a draft with a rubric assessment or attachment added in the UI is refused.

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:

  • draft score
  • publishing
  • rubric
  • group or attached feedback
  • bulk feedback

Reviewer checklist

  • pytest -q passes (full suite green on a cloud box).
  • ruff check . is clean.
  • mypy (strict) is clean.
  • --json stdout contract preserved; prompts go to stderr.
  • No credentials, cookies or tokens in code, logs, tests or exception text.
  • MFA semantics untouched.
  • New behaviour has tests under tests/.
  • Dependencies unchanged.

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

@factory-droid

factory-droid Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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

@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Draft edits get silently overwritten ▶

Summary

Adds assignment-feedback to save one learner's draft comment without publishing or setting a score.

  • Instructors can save one learner’s assignment comment as a draft.
  • The secrets baseline still points to the same README entry.

Acknowledged limits: rabesss states that live verification remains pending and that D2L leaves a short gap between the final read and POST. The offline-only limitation and required live check are explicitly acknowledged by rabesss. The remaining gap is acknowledged because D2L has no conditional write; it is distinct from the ineffective comparison reported above.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read and check UTF-8 file] --> B[Read submission and check target]
  B --> C{Dry run?}
  C -->|Yes| D[Print safe summary]
  C -->|No| E{Confirmation needed?}
  E -->|Yes| F[Confirm, then read target again]
  F --> G[Compare target]
  G --> H[Send one draft POST]
  E -->|No| H
  H --> I[Read feedback and submission]
  I --> J{Draft and text match?}
  J -->|Yes| K[Report saved draft]
  J -->|No| L[Report unknown; do not retry]
Loading

Reviews (1) · Last reviewed commit: "feat(instructor): draft-only assignment ..." · Reviewed by Greptile

Comment thread lighthouse_cli/assignment_feedback.py Outdated
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()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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

Reviewed changes

  • New instructor assignment-feedback command (lighthouse_cli/assignment_feedback.py, _feedback in assessment_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-draft gating, 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_once extraction from write — 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 sole write() caller is unchanged.
  • Docs: README wiring, new docs/assignment-feedback.md contract 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.

Pullfrog  | View workflow run | Using 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.
@factory-droid

factory-droid Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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

Comment thread lighthouse_cli/assignment_feedback.py Outdated
block = _user_entity(api.client.get_json(submissions_route), user_id)
if _status(block) != _DRAFT:
raise _UnexpectedError()
_check_draft_only(block.get("Feedback"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Suggested change
_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>"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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

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 (GroupTypeId present 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/Links must 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_draft bool 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 \r is normalized, and Status is 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.md contract 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.

Pullfrog  | View workflow run | Using 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
@factory-droid

factory-droid Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Droid finished @rabesss's task —— View job


No candidate comments were supplied, so none are approved for posting. The full diff and existing comments were read; the whitespace issue is already reported, and the confirmation fingerprint and final readback fixes are present.

0 inline comments posted

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

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 = 200 in _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 a finally.
  • Required the Feedback key 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 Feedback must 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 _PublishedReadbackError triggers (status 3, IsGraded true, non-null Score/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).

Pullfrog  | View workflow run | Using 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
@factory-droid

factory-droid Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Droid encountered an error —— View job

Droid could not run because a usage limit was reached: You've reached your 5-hour Droid Core usage limit (resets in 3h 38min).
Reload Extra Usage credits or wait for your limits to reset.

- 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
@factory-droid

factory-droid Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Droid encountered an error —— View job

Droid could not run because a usage limit was reached: You've reached your 5-hour Droid Core usage limit (resets in 3h 29min).
Reload Extra Usage credits or wait for your limits to reset.

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

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_comment now returns str | None, distinguishing a readable empty comment ({"Text": "", "Html": ""} — no flag needed) from a complete-but-unreadable one (Feedback null, {}, or all parts null), which refuses without the flag with a distinct "comment could not be read" message while replaces_draft correctly reports true with it.
  • Enforced per-part comment agreement on both readbacks: Text and Html are each checked when present (Text modulo line-ending normalization, Html exact or plain-text-equivalent), so a Text/Html disagreement — 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 Html with the same plain text: the new _html_text extractor (<p>/<br> variants including attributes and &nbsp;) 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-Html variants) and updated the docs/assignment-feedback.md contract 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.

Pullfrog  | View workflow run | Using glm-5.3 | 𝕏

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

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_comment now treats Text: "" or Html: "" 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-Html fallback to paragraph/line-break-only markup: _html_text strips 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 _TAG helper is gone, closing the path where a saved comment with extra elements could pass on loose text extraction.
  • Tightened equivalence to exact: _comparable normalizes 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_comment rejection cases (outer/inner spaces, extra image, bold, div, empty parts, both-null), three equivalence acceptances (trailing newline dropped in Html only, html-only escaped text, &nbsp;), and four new unknown-outcome routes including the entity readback; the draft_feedback_out fixture default moved to Html: None because 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.

Pullfrog  | View workflow run | Using glm-5.3 | 𝕏

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.

[P2] Verify and implement draft-only instructor assignment feedback

1 participant