Repository navigation
Conversation
… read and write API paths
…n lock, and reject non-int ids
Every ObjectTag delete path now archives an association that is locked against deletion instead of removing it, so learner mastery recorded against it stays resolvable. Unlocked associations are deleted exactly as before. ObjectTagQuerySet.delete() and ObjectTag.delete() carry the branch, so tag_object(), delete_object_tags(), copy_tags() and direct ORM deletes all follow it. The queryset delete locks the rows with select_for_update() before splitting them, so a concurrent lock waits and then sees the row archived. Archived rows are counted as deleted in the return value. Re-applying a tag through tag_object() or copy_tags() un-archives the same row and leaves deletion_locked unchanged. Closes openedx#779 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RvKuzWKYPVGRThGKydF2Wf
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RvKuzWKYPVGRThGKydF2Wf
dc364e1 to
c51d3bf
Compare
feb36b1 to
dcaec9a
Compare
|
This PR had an extensive self-code review session using our backend-code-review skill with multiple rounds of back and forth. Below is a summary of those rounds over a course of days. If need be I can provide the step-by-step findings and results, but since the review ended up taking so long and being so verbose as a result, a summary seemed more prudent than posting a few days worth of back and forth discourse between two agents and myself. Summary of self-code review process: Code review summaryThis pull request went through three full AI-assisted code reviews and three shorter re-reviews between 2026-11-13 and 2026-11-16, against the acceptance criteria of openedx#780. The final head, How each review was runEach full review pinned the head commit, diffed it against the base branch of #3, and read the ticket's acceptance criteria. Six reviewers then ran in parallel: a code locator, a context and prose reviewer, a mechanical checker (lint, types, import contracts, migrations, the description's commands and counts), a test reviewer that broke each guarded line and confirmed a test fails, an architecture reviewer, and an independent reviewer on a model from a different vendor (GPT). Concurrency claims were tested on a throwaway MySQL server at READ COMMITTED with two connections, one paused mid-operation while the other committed a conflicting write, because SQLite cannot show these races. Each written review passed an independent accuracy check before delivery. The re-reviews checked only whether the previous findings were fixed and whether the new commit broke anything. What each round found and what changed
Closing independent passBecause the three post-write checks added in Verification at the final head
Still open after the reviewQuestions that need the ticket owner, not code:
Deferred to follow-up issues, and listed under "Known gaps" in the description:
What the process showedThe reviews converged only after the scope was pinned. The concurrency mechanism was replaced once and tightened twice, and every change to it opened a window that the next MySQL probe found, including one caused by a review recommendation (the narrow |
…fixing two found implementation issues and various nits
Deleting a tag or a taxonomy archives it when a deletion-locked tag association depends on it, and deletes it otherwise. Squashes the seven commits of this branch onto the updated tbain/779_archive_locked_object_tag_deletes. Closes openedx#780 Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01VjwKFwFSEi3U6a4RsTKQuo
0fd3a85 to
b4b0d3d
Compare
|
Claude and I have not done a full review of this PR yet. This is one note from reviewing openedx#927, left here so it is not lost.
This PR is where that becomes possible, because The impact is smaller than it could be, since the new tag is hidden along with the archived taxonomy or parent. CodeRabbit raised it first, as an unverified finding on the code that openedx#940 added: openedx#927 (review) |
dcf535a to
ee0e973
Compare
Description
Deleting a tag or a taxonomy now archives it (
archived=True) when a tag association that is locked against deletion (ObjectTag.deletion_locked=True) depends on it, so learner mastery recorded against that association keeps a tag and a taxonomy to resolve through. Everything else is deleted as before, with the same response. Nothing in production sets the lock until openedx#782 lands, so ordinary deletes behave as they do today.What changed
Taxonomy.delete_tags(). A tag is archived if it, or any tag beneath it, has a deletion-locked association. Every other requested tag is deleted. Sub-tags are found byparent_id, the relation the cascade follows.api.delete_taxonomy(), called byTaxonomyView.perform_destroy(). The taxonomy is archived if any of its associations is deletion-locked, and deleted otherwise. Thearchivedvalues of its tags are not changed.select_for_update(). Each delete writes first, then checks inside the same transaction for a concurrent write, and rolls back and tries again, up to three times. A tag delete checks that it deleted as many tags as it read and that no deletion-locked association lost its tag, or, when it only archived, that the same tags are still beneath the ones requested. A taxonomy delete checks that no deletion-locked association lost its taxonomy. If the third attempt still fails its check,delete_tags_from_taxonomy()ordelete_taxonomy()raises the newConcurrentDeleteError(exported fromopenedx_tagging.api), and both endpoints return it as409 Conflict. A database refusal is also retried, and is raised unchanged after the third attempt, which either endpoint returns as a 500.lock_object_tags_for_deletion()re-reads the associations it has just locked and raisesObjectTag.DoesNotExistif a tag or taxonomy that was set is gone.resync_object_tags(),tag_object()andTaxonomy.update_tag()now passupdate_fields, so saving a row read earlier cannot write a staledeletion_locked=Falseorarchived=Falseback.resync_object_tags()writes only the columns it changed.update_tag()writesvalue,lineage,depth,parent, andexternal_id, then checksarchivedagain and rolls the rename back with aValueErrorif the tag was archived meanwhile. All three raiseDatabaseErrorif the row they save was deleted meanwhile, where they used to re-create it; the tag update endpoint returns that as a 500.Choices that differ from the ticket
perform_destroy()api.delete_taxonomy()AGENTS.mdroutes all mutation throughapi.py.lineageparent_idlineagewould be missed and then cascaded.Supporting information
tbain/779_archive_locked_object_tag_deletes.Testing instructions
The new tests (45 tests, 51 cases):
pytest --no-cov tests/openedx_tagging tests/openedx_learning(1434 pass and 10 are skipped), thenpylint,mypy,pycodestyle,isort --check-only,lint-imports, andpython manage.py makemigrations --check --dry-run.Manual, in
python manage.py shell(creates rows in your dev database):Other information
Tag.delete(),taxonomy.delete()called directly, the tag import's delete action, and the Django admin still hard-delete. The import's own Tag saves still write full rows.ProtectedError) from both endpoints. Open question for the ticket owner.OperationalError, which is not retried. Inside a caller's transaction it rolls that whole transaction back.ObjectTagquery when a call newly locks an association, and a newObjectTag.DoesNotExistcase to document.🤖 Generated with Claude Code