Repository navigation
fix(scenarios): a controlled-by-parent detail its own read policy narrows counts as kept to the persona's rows - #33443
Conversation
…rows counts as kept to the persona's rows The row-level-security grader followed the master for every controlled_by_parent detail. The engine ANDs the detail's own read policies with the master-derived filter, so a detail those policies narrow is scoped whatever the master admits. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oXxZBdb7RnC13GV1z
…parent detail reading Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oXxZBdb7RnC13GV1z
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 1 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 0a03059ba34fee334b8360fc67ebb37272babe3e && git checkout 0a03059ba34fee334b8360fc67ebb37272babe3e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9499dcc530a3dd8c0eee872f9483b96127ac8bfe a1c994ee7220d8080d4ccd4bddecbe787f014029 && git checkout -B drift-repro 9499dcc530a3dd8c0eee872f9483b96127ac8bfe && git merge --no-ff a1c994ee7220d8080d4ccd4bddecbe787f014029
node scripts/docs-audit/affected-docs.mjs --json 9499dcc530a3dd8c0eee872f9483b96127ac8bfe |
|
domain:devx#4 · os-project-manager · session_01FEkQ5ooRyyS95kdyC2dPEX 席位核对 · ACCEPT · head
|
Requested by Leehom · project thread
domain:devx#4 · os-project-manager · session_01FEkQ5oXxZBdb7RnC13GV1z
Fixes #33414
Clause-②: no
Metadata-protocol: none
维护者速读
@objectstack/scenarios的row-level-security构建检查:对controlled_by_parent明细对象,若角色自己权限集上对该明细的读策略能单独收窄它(至少一条生效、没有一条放行全部行、每条都能降为查询过滤),就判为已限定,不再只看主表。asset_lifecycle里demoasset_checkout的主表demoasset_employee是public_read,但员工权限集对 checkout 本身有employee in current_user.my_employee_ids读策略;引擎把明细自己的 RLS 与主表派生过滤 AND 在一起,员工只看得到自己的借用记录,评分器却判失败,挡住了 gallery 导出。packages/qa/scenarios/src/score/scenario-tags.ts的narrowsOnItsOwn(L402)和rowSecurityGap里新增的一行(L451)。pnpm --filter @objectstack/scenarios exec vitest run test/score/scenario-tags.test.ts,预期 88 条全绿。What changes
packages/qa/scenarios/src/score/scenario-tags.ts:narrowsOnItsOwn(policies)(L402): at least one read policy applies and none admits every row. This is the predicate the grader already applied to a non-CBP object's own policies, lifted out of its two copies (rowSecurityGap's last line, now L458, and the row-scope check, now L658) so all three sites ask one predicate. Those two sites behave exactly as before.rowSecurityGap,controlled_by_parentbranch (L451): when the persona's own read policies on the detail narrow it, return no gap before following the master. The "each lowers to a filter" leg is the existingdeadcheck at the top of the function, which already runs first for every object, CBP or not. When the detail's policies do not narrow it, the master is followed exactly as before.packages/qa/scenarios/test/score/scenario-tags.test.ts: one newdescribein the row-level-security block (L619), on the golden fixture'stask(acontrolled_by_parentdetail ofproject) withprojectset topublic_read:project in current_user.my_project_ids(the build'semployee in current_user.my_employee_idsshape);true; and a narrowing one beside atrueone;size(name) > 2), alone and beside a narrowing one..changeset/33414-scenario-grader-cbp-detail-own-policy.md:patchfor@objectstack/scenarios, a file name unique to this card.Why
The gallery debut refresh's build check
row-level-security:demoasset_checkout->enforcedfailed with "no read policy on demoasset_employee narrows demoasset_employee", although the build scopes the employee's checkouts with a read policy on the detail itself. I re-read the engine to confirm the card's premise before writing the grader around it:packages/plugins/plugin-security/src/security-plugin-authz-middleware.tsL2495–2535, the find path: for every read with anast, it pushesandComposeLayers(layer0, layer1)fromcomputeLayeredRlsFilter(tenant wall plus the authored RLS policies), thencomputeControlledByParentFilterfor the same object, into oneextralist; L2615–2620 composesextrawith the caller'swhereas one$and.security-plugin.tsL2985–2993 (getReadFilter's contract) states the same three-layer composition, andsecurity-plugin-rls-filter.ts(the commit 6feac91 note at L272) drops only the platform's wildcard WRITE ownership floor for a CBP detail, never an authored read policy.So an authored read policy on a CBP detail is ANDed with the master-derived filter, and a detail it narrows is kept to the persona's rows whatever the master admits. No path skipping the detail's authored RLS on a CBP read was found.
Tests
test/score/scenario-tags.test.ts: 88/88 pass; the whole package suite 32 files, 703/703 (afterpnpm --filter @objectstack/scenarios build, which its twotest/build/*suites need).scripts/ablation-replace.mjs --deleteon the new lineif (narrowsOnItsOwn(policies)) return undefined;(mutation landed, blob041868f9→191bdf4a; restored, blob == HEAD,git diff HEADempty): test (a) red withExpected "enforced for pm_contractor",Received "no read policy on pm_contractor narrows project"(the build's failure, on the fixture); (b) and (c) stay green, 1 failed / 2 passed.Acceptance notes
asset_lifecyclecard loaded and namespaced as the runner does (loadScenarios→namespacedScenario→scoreCardArtifact), against a two-object artifact (demoasset_employeepublic_read;demoasset_checkoutcontrolled_by_parentwithemployeemaster-detail) and the two permission sets the card scopes checkout for (demoasset_employeewithemployee_own_checkoutson the detail;demoasset_dept_managerwith a roster policy on the master, since the card scopes the roster itself for the manager). Result:origin/main4ace1fa9:{"check":"row-level-security:demoasset_checkout->enforced","pass":false,"detail":"no read policy on demoasset_employee narrows demoasset_employee"}, the recorded failure word for word;{"check":"row-level-security:demoasset_checkout->enforced","pass":true,"detail":"enforced for demoasset_employee, demoasset_dept_manager"}.The replay script is a scratch file, not committed; the new tests carry the same shape.
access-security.row-scope) already passed every CBP detail and is unchanged.Verification
On head
a1c994ee(branchclaude/project-thread-2wcbef, offorigin/main4ace1fa9), the list fromnode scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack(60 commands), each exit code captured before any pipe:60 derived: 59 exit 0, 1 NOT MEASURED; --ran reconciliation exit 0
check-plugin-teardown-shape.mjs --self-testfirst answered exit 3 (shallow clone, its fixture commit absent); aftergit fetch --depth=1 origin 621a4876…the rerun is exit 0, recorded above.check:dual-build-cjs-loadsexit 3 is PREREQUISITE NOT MET (it needs every package'sdist/): NOT MEASURED, CI runs it.dispatch-gates --ran: "60 derived famil(ies) accounted for — 59 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)", exit 0.Package checks, under the verify lock after building
@objectstack/scenariosand its dependency closure:pnpm --filter @objectstack/scenarios exec vitest run32 files, 703/703;pnpm --filter @objectstack/scenarios typecheckexit 0; repo lint scoped topackages/qa/scenarios(eslint packages/qa/scenarios --no-inline-config) exit 0. Every other family is CI's and is read from this PR's check-runs. Tier:dispatch-gates --tierderives no path mandate (default tier); 72 changed lines.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses (scoped topackages/qa/scenarios).main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5oXxZBdb7RnC13GV1z