Skip to content

fix(scenarios): a controlled-by-parent detail its own read policy narrows counts as kept to the persona's rows - #33443

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-2wcbef
Nov 14, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-2wcbef

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

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 明细对象,若角色自己权限集上对该明细的读策略能单独收窄它(至少一条生效、没有一条放行全部行、每条都能降为查询过滤),就判为已限定,不再只看主表。
  • 为什么改:gallery 构建 asset_lifecycle 里 demoasset_checkout 的主表 demoasset_employee 是 public_read,但员工权限集对 checkout 本身有 employee in current_user.my_employee_ids 读策略;引擎把明细自己的 RLS 与主表派生过滤 AND 在一起,员工只看得到自己的借用记录,评分器却判失败,挡住了 gallery 导出。
  • 风险与回滚:只改评分器一个分支,并把已有的「收窄」判断抽成一个小函数复用(行为不变);不碰任何引擎或插件代码。回滚即 revert 本 PR。
  • 先看: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:

  • New module-private 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_parent branch (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 existing dead check 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.
  • The function's doc comment now says a detail takes the read-policy route too, and why (the engine's AND, below).

packages/qa/scenarios/test/score/scenario-tags.test.ts: one new describe in the row-level-security block (L619), on the golden fixture's task (a controlled_by_parent detail of project) with project set to public_read:

  • (a) passes: a detail policy project in current_user.my_project_ids (the build's employee in current_user.my_employee_ids shape);
  • (b) still fails, master followed: no detail policy; a detail policy true; and a narrowing one beside a true one;
  • (c) still fails: a detail policy that does not lower to a filter (size(name) > 2), alone and beside a narrowing one.

.changeset/33414-scenario-grader-cbp-detail-own-policy.md: patch for @objectstack/scenarios, a file name unique to this card.

Why

The gallery debut refresh's build check row-level-security:demoasset_checkout->enforced failed 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.ts L2495–2535, the find path: for every read with an ast, it pushes andComposeLayers(layer0, layer1) from computeLayeredRlsFilter (tenant wall plus the authored RLS policies), then computeControlledByParentFilter for the same object, into one extra list; L2615–2620 composes extra with the caller's where as one $and.
  • security-plugin.ts L2985–2993 (getReadFilter's contract) states the same three-layer composition, and security-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 (after pnpm --filter @objectstack/scenarios build, which its two test/build/* suites need).
  • Ablation, through scripts/ablation-replace.mjs --delete on the new line if (narrowsOnItsOwn(policies)) return undefined; (mutation landed, blob 041868f9 → 191bdf4a; restored, blob == HEAD, git diff HEAD empty): test (a) red with Expected "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

  • Card Ask 3, re-grade: the recorded run lives in the filing seat's work dir and is not reachable from this container, so I replayed the build check instead with the smallest fixture that reaches it: the real asset_lifecycle card loaded and namespaced as the runner does (loadScenarios → namespacedScenario → scoreCardArtifact), against a two-object artifact (demoasset_employee public_read; demoasset_checkout controlled_by_parent with employee master-detail) and the two permission sets the card scopes checkout for (demoasset_employee with employee_own_checkouts on the detail; demoasset_dept_manager with a roster policy on the master, since the card scopes the roster itself for the manager). Result:
    • on origin/main 4ace1fa9: {"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;
    • on this branch: {"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.
  • Card Ask 4: no security finding (see Why).
  • The row-scope check (access-security.row-scope) already passed every CBP detail and is unchanged.

Verification

On head a1c994ee (branch claude/project-thread-2wcbef, off origin/main 4ace1fa9), the list from node 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
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-adoption.mjs :: exit 0
node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0
node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0
node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0
node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:cli-command-ids :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 3
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:issue-citations :: exit 0
pnpm check:keyed-text-bounds :: exit 0
pnpm check:lean-entry-closure :: exit 0
pnpm check:logger-receiver-detach :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:settings-bind-window :: exit 0
pnpm check:slot-lookup :: exit 0
pnpm check:sourcemap-no-sources-content :: exit 0
pnpm check:system-context-census :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:vouch-for-reference-callers :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
  • check-plugin-teardown-shape.mjs --self-test first answered exit 3 (shallow clone, its fixture commit absent); after git fetch --depth=1 origin 621a4876… the rerun is exit 0, recorded above.
  • check:dual-build-cjs-loads exit 3 is PREREQUISITE NOT MET (it needs every package's dist/): 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/scenarios and its dependency closure: pnpm --filter @objectstack/scenarios exec vitest run 32 files, 703/703; pnpm --filter @objectstack/scenarios typecheck exit 0; repo lint scoped to packages/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 --tier derives no path mandate (default tier); 72 changed lines.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (scoped to packages/qa/scenarios).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (the 维护者速读 block is the seat's required Chinese summary)
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5oXxZBdb7RnC13GV1z

…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
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 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
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 1 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 9499dcc530a3dd8c0eee872f9483b96127ac8bfe → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 0a03059ba34fee334b8360fc67ebb37272babe3e — the merge of head a1c994ee7220d8080d4ccd4bddecbe787f014029 into base 9499dcc530a3dd8c0eee872f9483b96127ac8bfe, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:devx#4 · os-project-manager · session_01FEkQ5ooRyyS95kdyC2dPEX

席位核对 · ACCEPT · head a1c994ee · 2026-11-14T21:42Z

  • 形态: draft → main, attribution first, Fixes #33414. Paths from the PR's file list: .changeset/33414-scenario-grader-cbp-detail-own-policy.md (+12/-0), packages/qa/scenarios/src/score/scenario-tags.ts (+15/-2), packages/qa/scenarios/test/score/scenario-tags.test.ts (+43/-0). No governed path, no packages/spec/src/**, Clause-②: no ⇒ no contract-review face; lane seat lands.
  • Diff read: Grader only. A new narrowsOnItsOwn predicate (at least one applying read policy, none admitting every row) replaces the two inline copies and is asked first in rowSecurityGap's controlled_by_parent branch, so a CBP detail whose persona policies narrow it returns no gap; otherwise the master is followed as before. The does-not-lower-to-a-filter refusal (dead) is still asked before the branch, so card case (c) keeps failing. Tests (a) pass, (b) and (c) fail as the card asks; ablation turns (a) red. The dev confirmed on main that the find path ANDs the authored RLS with the CBP filter (security-plugin-authz-middleware.ts L2495–2535, L2615–2620); no security finding.
  • 门禁 check-runs (head a1c994ee): 49 runs · 33 success · 16 skipped · 0 not green; TypeScript Type Check success, Lint & Repo Gates success. K = 13 merges behind main (< 15).
  • Changeset: one patch changeset for @objectstack/scenarios (published), .changeset/33414-scenario-grader-cbp-detail-own-policy.md, file name unique beside Scenario grader: "I didn't lend out AST-0041" is not read as a decline (WITHHELD_ACT's closed verb list lacks the cards' domain verbs) #33415.
  • 接受的偏差: re-grade done on a fixture (the recorded run is not reachable): fails on main with the recorded message word for word, passes on the branch.
  • 范围外去向: none. Skills-docs: not owed (Metadata-protocol: none).
  • 落地条款: non-governed, all checks green ⇒ the seat readies and arms auto-merge. Ruling-ref: the maintainer's standing authorisation 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (this account's project).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 14, 2026 21:42
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit dea36fa Nov 14, 2026
50 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-2wcbef branch November 14, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scenario grader: a controlled_by_parent detail narrowed by its own read policy fails row-level-security (rowSecurityGap follows the master only)

1 participant