Skip to content

fix(isms): lock control-link edits before write (CS-701)#3369

Merged
tofikwest merged 1 commit into
mainfrom
tofik/isms-control-lock-order
Jul 7, 2026
Merged

fix(isms): lock control-link edits before write (CS-701)#3369
tofikwest merged 1 commit into
mainfrom
tofik/isms-control-lock-order

Conversation

@tofikwest

@tofikwest tofikwest commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Why

Flagged on the production-deploy PR #3364 (P2): addControls/removeControl wrote the control-link rows first and only then called invalidateApprovalIfNeeded (which holds the per-document lock). So the link write ran outside the lock and could interleave with approve() before serialization kicked in.

Impact was limited — control links are not part of the frozen version snapshot, so no published version could be corrupted — but the mutation should still be serialized like every other content edit, and the lock-before-write pattern is the correct one.

Fix

Both control transactions now take lockDocument() as their first statement, before createMany/deleteMany. The conditional invalidateApprovalIfNeeded (real-change-only) is unchanged, and the advisory lock is transaction-scoped + re-entrant, so re-taking it there is a no-op. Added an ordering test asserting the lock precedes the write.

Tests

  • 325 API ISMS tests passing, typecheck clean, on top of current main.

Completes the ISMS concurrency hardening (#3366, #3367). Flagged in #3364.

🤖 Generated with Claude Code

https://claude.ai/code/session_012CweXoSSEP89mX93u3Bdcp


Summary by cubic

Lock control-link edits before writes so addControls/removeControl run inside the per-document lock and serialize with approve(). Implements CS-701.

  • Bug Fixes
    • Call lockDocument first in both transactions, before createMany/deleteMany, to prevent interleaving with approve().
    • Keep invalidateApprovalIfNeeded conditional; the lock is re-entrant so re-taking it is a no-op. Added a test asserting the lock precedes the write.

Written for commit b075f7c. Summary will update on new commits.

Review in cubic

…approve

Follow-up flagged on #3364: addControls/removeControl wrote the control-link rows
and only then called invalidateApprovalIfNeeded (which holds the per-document
lock), so the write itself ran outside the lock — it could interleave with
approve() before the lock was taken. (Impact was limited because control links
are not part of the frozen version snapshot, but the mutation should still be
serialized like every other content edit.)

Both transactions now take lockDocument() as their first statement, before the
createMany/deleteMany. The conditional invalidate is unchanged (real-change-only),
and the lock is re-entrant so re-taking it there is a no-op. Adds an ordering test.

Tests: 325 api ISMS tests passing; typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CweXoSSEP89mX93u3Bdcp
@linear

linear Bot commented Jul 7, 2026

Copy link
Copy Markdown

CS-701

@vercel vercel Bot temporarily deployed to Preview – app July 7, 2026 20:54 Inactive
@vercel vercel Bot temporarily deployed to Preview – portal July 7, 2026 20:54 Inactive
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comp-framework-editor Ready Ready Preview, Comment Jul 7, 2026 8:56pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
app Skipped Skipped Jul 7, 2026 8:56pm
portal Skipped Skipped Jul 7, 2026 8:56pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@tofikwest tofikwest merged commit a21f866 into main Jul 7, 2026
11 checks passed
@tofikwest tofikwest deleted the tofik/isms-control-lock-order branch July 7, 2026 20:58
claudfuen pushed a commit that referenced this pull request Jul 7, 2026
# [3.99.0](v3.98.1...v3.99.0) (2026-07-07)

### Bug Fixes

* **integrations:** don't persist unverified GitHub installation_id ([#3370](#3370)) ([9c6f6fa](9c6f6fa))
* **isms:** lock before writing control links so edits serialize with approve ([#3369](#3369)) ([a21f866](a21f866))
* **isms:** production-deploy review follow-ups (CS-701) ([#3365](#3365)) ([d756d4a](d756d4a)), closes [#3364](#3364)
* **isms:** serialize approve against ALL register/content edits (central lock) ([#3367](#3367)) ([5c88a3d](5c88a3d))
* **isms:** serialize approve/decline to prevent concurrent double-publish (CS-701) ([#3366](#3366)) ([b158bc9](b158bc9)), closes [#3364](#3364)

### Features

* **integrations:** add read-only GitHub App integration (CS-710) ([#3363](#3363)) ([a5a9243](a5a9243))
* **isms:** document versioning and history (CS-701) ([#3361](#3361)) ([d95dc2e](d95dc2e))
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.99.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants