Repository navigation
fix(plugin-sharing): two sharing rules that reach one user on one record keep one grant each, so the widest level wins - #33771
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
…part key Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
…-ozggbj Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
📓 Docs Drift CheckThis PR changes 1 package(s): ⛔ 3 release-owned page(s) name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 11 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 22a7dee8670c6fed9cd13f2510f0ef25106ffc97 && git checkout 22a7dee8670c6fed9cd13f2510f0ef25106ffc97
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b76df9a6980d935c194f778e7eb10aca382aac4c ba36b17255db4960e39ccfd89e2dde0101a10cf4 && git checkout -B drift-repro b76df9a6980d935c194f778e7eb10aca382aac4c && git merge --no-ff ba36b17255db4960e39ccfd89e2dde0101a10cf4
node scripts/docs-audit/affected-docs.mjs --json b76df9a6980d935c194f778e7eb10aca382aac4c
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #33771 · S1/A2 · Fixes #33683 · head 5b7a393 · 2026-11-15T10:05Z Release blocker (18.5.0): please review this first. Reviewer: review-a of seat |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — FAILHead-sha: Read at the head on GitHub, not from the report: the 6 PR files, What holds
Must-fix
Answer to the area's question (the 5000-row cap)
Gates
Next: fix item 1 on a new head; the delta review covers the new commits only. |
…system path Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — FAIL (delta)Head-sha: Code: item 1 of 6892781240 is fixed. Must-fix (prose only)
A head that moves only these prose lines keeps the code review above; I re-read only those sentences. Gates
|
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha:
Gates are not judged here. At review time this head had 17 check-runs in progress, 2 success and 5 skipped, plus one |
… (register + row 34) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTBcu34GSc4kdgsYKQ
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha:
Gates not judged. Landing needs every check green on this head, including the docs-anchor gate that was red at 4dc907e and the re-run PR-body guards. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv 席位核对 · ACCEPT · Head-sha: ba36b17 · 2026-11-15T11:49Z
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Re-arm · 2026-11-15T12:15Z · head ba36b17 unchanged; ACCEPT 6893869568 stands The PR was removed from the merge queue at 2026-11-15T12:11Z. Queue duty (review-a) classed it as a FLAKE. The one red job was Live E2E UI in merge_group run 43710890892: |
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43710890892 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
Requested by Steedos · project thread
Fixes #33683
Clause-②: no
Metadata-protocol: none
维护者速读
sys_record_share(按规则 id 区分),不再互相覆盖;用户最终拿到其中最高的权限。SharingService.grant查找已有行的条件(规则授权多带一个source_id);读写闸门本来就按多行取最宽,不用改。手工共享照旧一人一行。无迁移、无索引变更;历史上被合并的行会在该规则下次对账(启动回填或记录写入)时自动拆开。回滚即还原本 PR。packages/plugins/plugin-sharing/src/sharing-service.ts的grant查找条件那一段;src/field-recipient.test.ts末尾新增的 describe;src/record-share-organization-stamp.test.ts改动的那条钉子(跨组织 404 的剩余入口)。pnpm --filter @objectstack/plugin-sharing exec vitest run src/field-recipient.test.ts -t 'two rules reaching',预期 11 条全绿;把grant里的source_id那一行删掉再跑,预期 11 条全红。What changes
SharingService.grantlooked up an existing share row by(object_name, record_id, recipient_type, recipient_id, source)and, when it found one, overwrote itsaccess_levelandsource_id. Every sharing rule grants through it withsource: 'rule'andsourceId: rule.id, so two rules that reach one user on one record shared one row and the last rule written won, whatever its level. Each rule's reconcile and revoke read by its ownsource_id, so the merged row belonged to whichever rule wrote last: revoking that rule removed access the other rule still granted, revoking the other rule removed nothing, and every whole-rule pass of the other rule wrote the row back to its own level (access flapping between passes).A grant from the rule evaluator's system path (a system context, any
sourceother thanmanual, asourceId) is now looked up by that id too, so there is one row per rule and recipient. The read side needs no change:buildReadFiltercollects the record ids of every row the user holds, andcheckEdit/buildWriteFilterask for any row with a write level, so the effective access is already the highest level across rows, as thegrantjsdoc said for manual and rule rows side by side. Only that path supplies asource_idthat names a rule. A manual grant, and any grant made outside the rule evaluator's system path, keeps the four-part key, so a repeated direct grant still upserts its one row.This follows the triage ruling (comment 6890597594, "Merge to the highest access per (record, principal) and pin both write orders."): the merge is the read gates' maximum across rows; each rule keeps the row only it reconciles. The other shape (one row, level recomputed from every rule still reaching the user on each grant and revoke) was weighed on the four axes and not taken:
project_team_read+project_manager_editoncrm_project); the per-rule row also covers every other overlap (two position rules, a position and a field rule) with no extra work.source_idnames (ruleGrantScope), which every revoke path already relies on (revokeRuleGrants,reconcileRuleForUser,revokeRuleGrantsForRetiredRecipients, the declared-rule activation purge). One recomputed row would make every one of those paths ask every other rule whether it still reaches the user on that record, a criteria read and a recipient expansion per rule per revoke.sys_record_sharehas no unique index; its indexes are(object_name, recipient_type, recipient_id),(object_name, record_id)and(source, source_id)).Existing data: a row two rules already share carries the last writer's
source_id. The other rule's next reconcile (the boot backfill, a write to the record, a whole-rule pass) finds no row of its own and writes one, so the user regains its access with no migration. Pinned below.Tests
New pins, in
src/field-recipient.test.tsas one top-level describe (the harness that already drives field and position rules and the real gates):checkEditanswersallow, a team member who is not the manager answersdeny;checkEditanswersdeny;checkEditanswersallow;reconcileRuleForUser) revokes that rule's row only, the read stays;Three direct pins in
src/sharing-service.test.ts: a second rule's grant writes its own row and leaves the first rule's row and level alone, and the same rule granting again upserts its own row; a manual grant keeps one row per recipient whateversourceIdthe caller sends; a direct (non-system) grant with a non-manualsourceand two differentsourceIds keeps one row.Two existing pins held the merged row and are updated:
src/sharing-rule.test.ts(Does a DEACTIVATEDsys_positionstill receive sharing-rule shares?expandPositionUsersnever reads the catalogue row, so today it does #8710 ledger-read cache): "One share row, not two" now expects one row per rule (['u_cfo', 'u_cfo']); the pin's subject, one ledger read per pass, is unchanged.src/record-share-organization-stamp.test.ts(finding: every sys_record_share grant row lands organization_id NULL — SharingService writes under a bare system context and the row literal never carries the column #14484, the loudRECORD_NOT_FOUNDon an update the wall cannot reach): the pin reached the 404 through a grant from a DIFFERENT rule, which no longer finds the other organization's row. The remaining road in is a grant of the SAME rule id from another organization (a declared rule served under a wall is one projection per organization, all carrying the rule's name assource_id), so the pin now uses one rule id for both rows, and the comment says so. The measured shape it holds (throw 404, the stored row keeps its stamp, level and source) is unchanged.Runs (fix at 95c02cd; suites re-read after the main merge at 5b7a393 where noted)
@objectstack/plugin-sharingfull suite at 95c02cd: Test Files 74 passed (74), Tests 1524 passed (1524). The four touched test files again after the edits: 3 files 232 passed,sharing-service.test.ts155 passed.@objectstack/plugin-securityTest Files 267 passed, Tests 6681 passed and 45 skipped;@objectstack/service-automationTest Files 282 passed, Tests 3976 passed.runtime,cli,verify,qa/scenariosandqa/dogfoodare declared to CI: no exported signature or wire shape moves.pnpm --filter @objectstack/plugin-sharing typecheckexit 0 (tsc, scripts tsconfig, test-layer check: 3 pinned signatures held, unchanged).pnpm lintexit 0.Ablation 1, the
source_idkey spread deleted fromgrant(scripts/ablation-replace.mjs, anchor 1 to 0, blob beeff2f5 to 7290dfd7): all 11 new describe pins red, for exampleper-record pass, edit rule first, then read:expected [ 'srule_team_read:read' ] to deeply equal [ 'srule_manager_edit:edit', 'srule_team_read:read' ], the card's repro. The directsharing-service.test.tspin red too:expected 'shr_rule' not to be 'shr_rule'. Restored: blob equal to HEAD,git diff HEADempty.Ablation 3 (review fix, head b1aed3b), the system-path guard dropped (
context?.isSystem &&removed):a direct (non-system) grant keeps one row per recipient whatever non-manual source and sourceId it sendsred,expected 2 to be 1; the two system-path pins stay green. Restored: blob equal to HEAD,git diff HEADempty. plugin-sharing full suite at b1aed3b: 74/74 files, 1525/1525 tests; typecheck 0,pnpm lint0.Ablation 2, the manual exclusion dropped (
source !== 'manual' &&removed):a manual grant keeps one row per recipient whatever sourceId the caller sendsred,expected 2 to be 1. Restored: blob equal to HEAD,git diff HEADempty.Acceptance notes
buildReadFilter,buildWriteFilter,limit: 5000). Rows beyond the cap are dropped silently, before and after this change; with one row per rule, a user two rules reach on N records now holds 2N rows, so the cap is met sooner. No real deployment is measured near it. Noted for the lane, not changed here.Verification
Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, 63 commands at 95c02cd)
pnpm check:i18nanswered exit 3 (a build prerequisite missing) in the sweep and exit 0 on the re-run once the CLI build was present: 10 packages in sync.node scripts/check-plugin-teardown-shape.mjs --self-test: exit 3, the shallow clone cannot reach the pinned fixture commit. NOT MEASURED locally; CI runs it.pnpm check:dual-build-cjs-loads: exit 3, needs every package'sdist. NOT MEASURED locally; CI runs it.check-changeset-no-major --base origin/main,check-adr-0087-registration --base origin/main,check-closing-keyword-parity) were run against this body before the PR opened.Dogfood battery: not run, no
!in the title and no(narrowing)arm.Generated by Claude Code