Skip to content

fix(review): serialize pending section approvals - #2111

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
ydflow:fix/review-serialize-approvals
Nov 27, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
ydflow:fix/review-serialize-approvals

Conversation

@ydflow

@ydflow ydflow commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Two approvals from the same review queue can each read the same version of the target Markdown file. Both commands report success and remove their entries, but the last write overwrites the other approved section.

Reuse the existing queue lock for the entire decision. Single and batch apply reload the pending entry while holding the lock, write the section, and remove the entry after a successful write. If another command already removed the entry, the apply reports it missing. Dry runs still preview changes without taking a write lock.

Type of Change

  • Bug fix

Test Plan

  • npm run typecheck and npm run build passed.
  • npx vitest run src/__tests__/iwiki-review-apply.test.ts src/__tests__/iwiki-dual.test.ts src/__tests__/review-store.test.ts src/__tests__/review-cmd.test.ts src/__tests__/review-cmd-output.test.ts passed all 41 tests. The added regression failed on da482cb because the glossary update was lost.
  • npx vitest run --config vitest.e2e.config.ts src/__tests__/review-dry-run-e2e.test.ts passed, including the checks that preview leaves document and queue contents and timestamps unchanged.
  • Type-aware oxlint passed on the four changed files. node scripts/check-docs.mjs and git diff --check passed.
  • Full lint passes on native Windows. Main and this branch report the same 26 teamai(family-facts) diagnostics in tool packages.
  • POSIX verify world. npm run verify:world refuses native Windows. The isolated Windows CLI record is below.
VERIFIED on Windows, Node 24.19.0, via workspace-local review
Build 3df45ef, teamai-cli 0.22.0, dist/cli.js SHA256 3526a42c54ea
Fixture: temporary HOME, USERPROFILE, app data and workspace
$ node dist/index.js import write-sections ... --review true
$ node dist/index.js review <business-api-id> --apply --json
$ node dist/index.js review <glossary-id> --apply --json
Main da482cb: both exit 0, ok:true, queue empty, only one update on disk.
PR build: the second process waits on the queue lock. Both exit 0,
ok:true, both updates on disk, queue empty.
$ node dist/index.js review --all-apply --max-risk high --json
Fresh queue: both items applied, both updates on disk, queue empty.

The concurrency probe pauses the first process after it reads the actual document. It releases that process after the second finishes on main or reaches the held lock on the PR build. The fixture used the CLI section writer with a supplied reply.

Related Issues

Fixes #2080.

Notes for Reviewers

The lock is scoped to a review queue and covers decisions against that queue. The entry point reads the workspace queue directly across team repo modes and does not depend on an AI tool, workflow driver, or resource layer. This extends the queue-write protection in #1786 to document application. The separate risk ceiling validation in #2105 applies cleanly alongside this diff.

Prepared with assistance from OpenAI Codex.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified on Linux (Node 20), stacked on main da482cb together with the other PRs merged in this pass: typecheck, build, lint, the targeted unit suites and the affected E2E files pass. The only failing CI jobs are the two fork-safe E2E jobs that fail on main itself (fixed in #2114).

@jeff-r2026
jeff-r2026 merged commit 6bd5e2b into Tencent:main Nov 27, 2026
15 of 17 checks passed
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.

[bug] Concurrent review --apply commands lose an approved document edit and remove both queue entries

2 participants