Skip to content

fix(plugin-sharing)!: refuse a sharing-rule criteria that compares a choice field with an option label - #39543

Merged
os-zhuang merged 5 commits into
mainfrom
claude/issue-39434-wip
Dec 4, 2026
Merged

os-zhuang merged 5 commits into
mainfrom
claude/issue-39434-wip

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

Fixes #39434
Refs #39418

Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #39583 — content/docs/permissions/sharing-rules.mdx (the page lists each save-time refusal on this door; outside this claim's file surface). No skills/** change owed: the skills teach declared stack.sharingRules CEL conditions, which are not sys_sharing_rule rows and never pass this door.

Metadata-protocol: none is provisional, as the ruling leaves it: narrowed versus none is the contract reviewer's. Both same-door precedents declared none (PR #30953, the object-enforcement refusal; PR #39361, the user-recipient refusal), because a sys_sharing_rule row is an organization's data, not package metadata.

维护者速读

  • 管理员或替他搭应用的 AI 在共享规则里把下拉、单选、多选字段的「显示名」当成值写(例如写「紧急」而记录里存的是内部值),以前照常保存却一条都不共享(取反写法则反过来共享给所有记录),现在保存时当场被拒,并告诉他该写哪个值。
  • 属于共享规则「存得进却永远不生效」这一类问题的收口,替报修单场景里发现规则静默失效的管理员解决(上一张卡已补界面上的选项选择器,这次补接口和手写条件)。
  • 只影响新保存或改了条件的规则;已存的旧规则照常加载、照常可以停用;如果误拦,撤回这一个改动即可恢复原样。
  • 需要你确认这是一个破坏性收紧(保存时拒绝)并在合并前给出同意。

What changes

A sharing rule's criteria that compares a choice field with one of its option labels, where the records hold the option's value, is refused at save, at both sys_sharing_rule doors, with one sentence naming the field, the label written and the value to write. Maintainer ruling recorded on the card (comment 7403149741, option A), verbatim:

「refuse a sys_sharing_rule save when a criteria literal on a choice field is an option label where the row holds the value. The refusal names the value to write. Judged only when the criteria change.」

  • New module plugin-sharing/src/rule-criteria-option-label.ts: the label reading (the one flow-condition-option-label defined for flows, read from the runtime registry via engine.getSchema), the refusal sentence, and sameCriteria (key order and string-or-object spelling aside).
  • /data door: bindRuleCriteriaGuard (rule-hooks.ts) refuses VALIDATION_FAILED (400) with one fields entry { field: 'criteria_json', code: 'invalid_option' }, after its existing match-all check.
  • POST /sharing/rules: defineRule (sharing-rule-service.ts) throws an error whose message is VALIDATION_FAILED: followed by the same sentence, which the route already maps to 400.
  • Judged on insert, and on update/upsert only when the supplied criteria differs from the stored one. System-context writes are judged too, like the match-all check in the same guard (and unlike the object and recipient guards): the verdict depends on the criteria alone. A first draft skipped system writes; check:system-context-census then required a new row on content/docs/permissions/system-context.mdx (outside this claim) for that elevation read, and judging every caller is the more consistent reading anyway. Pinned both ways (ablation 3).

Scope (as ruled). Fields: select, radio, multiselect, checkboxes of the rule's object, inline non-empty options, not readonly, not bound to a shared picklist. A literal equal to an option's label that is also some option's value is not a label-for-value mistake and is accepted (pinned: stage: 'open' where open is one option's label and another's value). A literal that is neither a value nor a label is accepted unchanged (the spec admits stored values outside the options, createMissingOptions).

Comparand shapes, enumerated from the filter grammar (FILTER_OPERATORS, LOGICAL_OPERATORS) and the drivers' multi-value semantics:

Shape Covered Why
bare F: L, $eq, $in (each member) on a single-value field yes positive: shares nothing (measured)
$ne, $nin (each member) on a single-value field yes negated: shares every record (measured, below)
$contains, $notContains on a multi-value field yes the membership tests the engine runs on a JSON-stored column
anywhere under $and / $or / $not yes walked at any depth
equality family on a multi-value field no the engine refuses equality on a JSON-stored column for a reason of its own; naming a value would not make the rule run
$contains/$notContains/$startsWith/$endsWith/$icontains/$like/$ilike on a single-value field no a pattern names no option, and its text may legitimately sit inside a value
$gt/$gte/$lt/$lte/$between no order text, claim no option
$null/$exists/$empty no no literal
array (AST) spelling ['F','=','L'] not reached both doors already refuse it first as a criteria that narrows nothing (isMatchAllCriteria), measured while writing the pins
dotted path (owner.status) no not a field of the rule's object
Carried item 2: negated comparands measured first (over-share)

Real ObjectQL + SqlDriver (better-sqlite3), five repair orders (three gao, two jinji), a rule row stored as before this guard, evaluateRule, then sys_record_share read off the driver:

  • {"jinji_chengdu":{"$ne":"紧急"}} → grants on all 5 records (the 2 urgent ones the author meant to exclude included); control $ne: "jinji" → the 3 non-urgent.
  • {"jinji_chengdu":{"$nin":["紧急"]}} → all 5; control $nin: ["jinji"] → the 3 non-urgent.
  • bare / $eq / $in on the label → 0; control on the value → the 2 urgent.

These eight cases are pinned in the first describe of the new test and passed both before and after the fix (they measure the evaluator, not the guard).

Tests

New file packages/plugins/plugin-sharing/src/sharing-rule-option-label-39434.test.ts (30 cases): the measurement above; the /data door refusing bare, $eq, $ne, $in, $nin, nested $and/$or/$not, multiselect $contains, checkboxes $notContains, each naming the value; controls (value; value under $ne/$in; a literal outside values and labels; a label that is also a value; a readonly choice field; a non-choice field; a substring operator); an update changing criteria to a label refused with the row kept; a criteria-untouched update on a legacy label row saved (also with the unchanged criteria re-sent); defineRule refusing with the /data door's sentence behind VALIDATION_FAILED: ; an upsert keeping a stored label criteria saved and one changing to a label refused; the system context judged at both doors.

Red-first, green, ablations
  • Red at 10ad9101 (test only): Tests 13 failed | 17 passed (30) — every refusal case red, every measurement and control green.
  • Green at da6cbc17: pnpm --filter @objectstack/plugin-sharing test → Test Files 84 passed (84) / Tests 1828 passed | 11 skipped (1839); pnpm --filter @objectstack/plugin-sharing typecheck → exit 0 (check:test-typecheck: OK).
  • Ablation 1 (scripts/ablation-replace.mjs, mutation landed anchor 1 → 0, restored blob == HEAD): $ne dropped from the single-value scalar set → Tests 3 failed | 26 passed (29) (run before the system-context case was added) (the $ne /data, the update-to-$ne, the $ne defineRule cases).
  • Ablation 2: the /data door's sameCriteria skip deleted → Tests 1 failed | 28 passed (29) (the criteria-untouched update on a legacy label row).
  • Ablation 3: an isSystem skip re-inserted in the /data guard → Tests 1 failed | 29 passed (30) (the system-context case); restored blob == HEAD, git diff HEAD empty.

Acceptance notes

  • content/docs/permissions/sharing-rules.mdx describes each save-time refusal on this door; this one is not added there (outside the claim's file surface) — filed as docs: sharing-rules.mdx does not list the save-time refusal of a criteria that compares a choice field with an option label #39583.
  • Picklist-bound fields are skipped as ruled (analysis 7399582338 scope). At runtime the registry folds a picklist's options into the field, so the same reading would be sound there; widening is a later decision, not taken here.
  • "Judged only when the criteria change" is read literally: an update that moves a rule to another object without touching criteria_json is not judged by this check.
  • The option reading duplicates selectOptionsOf in @objectstack/lint (flow-select-options.ts): plugin-sharing does not depend on @objectstack/lint, that helper is not exported from its index, and packages/lint/src/** is outside this claim.
  • A label in a declared stack.sharingRules CEL condition is not judged here (declared rules are not rows); the lint rule for it is the seat's follow-up after the claims holding packages/lint/src release.

Verification

Read first, by risk: packages/plugins/plugin-sharing/src/rule-hooks.ts (the bindRuleCriteriaGuard hunk: ordering after match-all, no system skip, the sameCriteria early return); packages/plugins/plugin-sharing/src/sharing-rule-service.ts (the defineRule hunk, judged for every caller before the non-system block); packages/plugins/plugin-sharing/src/rule-criteria-option-label.ts (choiceOptionsOf, judgeComparand).

Two-minute check: pnpm --filter @objectstack/plugin-sharing exec vitest run --maxWorkers=2 src/sharing-rule-option-label-39434.test.ts → expect Tests 30 passed (30).

Gates (local subset at da6cbc1)

Derived with node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at da6cbc17 (73 commands), each run with its exit code captured before any pipe; reconciliation:

Run reconciliation — 73 derived, 73 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 73 derived famil(ies) accounted for — 73 run, 0 NOT-MEASURED (a DERIVED zero — all 73 recorded an exit code and none of them is 3).

All 73 exited 0. ADR-0087 disposition:

✓ check-adr-0087-registration: 1 declared-breaking changeset(s), each carrying an ADR-0087 disposition.
    .changeset/39434-sharing-rule-option-label-criteria.md  [BREAKING+clause-②-narrowing]  not-required (no-migration-prescription)

Package: pnpm --filter @objectstack/plugin-sharing test / typecheck / build exit 0 at da6cbc17 (dependency closure built first with pnpm --filter '@objectstack/plugin-sharing^...' build). test:repo, pnpm lint and the whole-tree families are CI's.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9

…haring-rule save doors (red)

Measures a label comparand on the evaluator first: bare/$eq/$in share
nothing, $ne/$nin share every record.

Claude-Session: https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9
Co-authored-by: Claude <noreply@anthropic.com>
…hoice field with an option label

Both save doors (the /data criteria guard and defineRule / POST /sharing/rules)
refuse, with one sentence naming the field, the label and the value to write,
a criteria literal on a select/radio/multiselect/checkboxes field that is an
option's label and no option's value. Judged on insert and when the criteria
changes; a literal outside both values and labels saves as before.

Claude-Session: https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9
Co-authored-by: Claude <noreply@anthropic.com>
…, as the match-all check is

Claude-Session: https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l 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 Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-sharing, touching 22 documentable anchor(s).

8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/data-api.mdx (via /:object/change-owner/cascades (route, bridged from symbol getSchema — its route source's handler names it))
  • content/docs/api/error-catalog.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))
  • content/docs/concepts/architecture.mdx (via getSchema (symbol, a method of interface OptionLabelSchemaSource))
  • content/docs/kernel/runtime-services/sharing-service.mdx (via defineRule (symbol, a method of class SharingRuleService))
  • content/docs/permissions/system-context.mdx (via defineRule (symbol, a method of class SharingRuleService))
  • content/docs/protocol/kernel/error-handling.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))
  • content/docs/protocol/objectql/state-machine.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))
  • content/docs/ui/public-data-collection.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via defineRule (symbol, a method of class SharingRuleService), criteria_json (literal, a string literal in bindRuleCriteriaGuard))
  • content/docs/releases/v17/17-5.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))
  • content/docs/releases/v17/17-6.mdx (via invalid_option (literal, a string literal in bindRuleCriteriaGuard))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 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 — 12 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 eb947b665c4e3e0af9fb80231ec919ae7f62872a → packageMentionDocs.

Which tree this was computed on

This run read content/docs from af62477296c7217388f45b42874cacbbbd915929 — the merge of head da6cbc1751472d1f30b32e2bc70872714bac346f into base eb947b665c4e3e0af9fb80231ec919ae7f62872a, 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 af62477296c7217388f45b42874cacbbbd915929 && git checkout af62477296c7217388f45b42874cacbbbd915929
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin eb947b665c4e3e0af9fb80231ec919ae7f62872a da6cbc1751472d1f30b32e2bc70872714bac346f && git checkout -B drift-repro eb947b665c4e3e0af9fb80231ec919ae7f62872a && git merge --no-ff da6cbc1751472d1f30b32e2bc70872714bac346f

node scripts/docs-audit/affected-docs.mjs --json eb947b665c4e3e0af9fb80231ec919ae7f62872a

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs eb947b665c4e3e0af9fb80231ec919ae7f62872a → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9

Test Core (5/12) at da6cbc17 red · read 2026-12-04T07:59Z: not a test failure. Every suite in the shard passed (@objectstack/runtime:test 666 files, 12732 passed / 27 skipped; turbo Tasks: 43 successful, 43 total). The job went red at the artifact upload after the tests: Failed to CreateArtifact: Unable to make request: ECONNRESET (job 144896845389). That is a GitHub transport reset that does not touch this diff, so it gets one re-run of the failed job once run 47289850716 completes. A second red is treated as real.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9

Final green head · 2026-12-04T08:51Z · da6cbc1751472d1f30b32e2bc70872714bac346f · 42 success · 18 expected skip · 0 failed (Test Core 5/12 went red on an artifact-upload ECONNRESET after every suite passed, see 7405351418; one re-run was green). needs:dogfood-battery on, Dogfood battery (opt-in) success with 3/3 shards. Clause-②: yes (narrowing) per claim 7403189074, which applies ruling 7403149741 (option A). The L1 and the L2 contract review were requested from the seat's L1-b thread at this head. Flags for the reviewer: system-context writes are judged too (the dev report's deviation 2), and Metadata-protocol is narrowed vs none.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY

席位核对

L1 verdict (L1-b): ACCEPT at head da6cbc1751 (Fixes #39434, p1), on one condition before landing: the Skills-docs: follow-up card is filed and the PR body line is rewritten to follow-up #N. That is a body edit only and does not move the head. Read at 2026-12-04T08:53Z.

Face: l1-face --pr 39543: 12 ok, 1 flag (skills-docs: follow-up owed — content/docs/permissions/sharing-rules.mdx, which is the condition above). Check-runs: 44 success · 22 expected skip · 0 failed. Dogfood battery (opt-in) success (check run 144927361954), owed by both the title's ! and the (narrowing) arm. mergeable_state was unknown on my read, so re-read it at landing.

Against the ruling (7403149741, option A, the option-LABEL comparand only):

  • Only a literal that is a label and not also another option's value is refused. A literal outside both values and labels still saves (pinned as a control), so option E (refuse every literal outside the options) was not slipped in.
  • The negated forms ($ne/$nin, $notContains) are covered, after the measured section of the pin (measured: what a label comparand does on the evaluator). That follows the ruling's "measure, then cover".
  • "Judged only when the criteria change" is held at both doors: the /data hook compares with ctx.previous (sameCriteria), and defineRule compares with the stored row. The pin covers switching a label rule off.

Diff (5 files, +622/−3):

  • The logic sits in a new rule-criteria-option-label.ts (223 lines). rule-hooks.ts +28, sharing-rule-service.ts +14.
  • The refusal shapes match each door's existing convention: /data uses validationFailure with a criteria_json field entry, code invalid_option; defineRule uses the VALIDATION_FAILED: prefix that its required-field and match-all checks already use.
  • The pin asserts code on the /data refusal.
  • Changeset, read sentence by sentence: patch on @objectstack/plugin-sharing. The Before / Now / scope bullets (field types, operators, $and/$or/$not nesting, the shared-picklist and readonly exclusions) and the BREAKING line match the module. The ADR-0087 marker's reason (stored rows still load and evaluate; an untouched update saves) matches the hook's skip.

Left to the L2 contract review on this head (running now, the ruling assigns these to it): whether Metadata-protocol: should be none or narrowed; whether judging system-context writes is in scope and is safe for package seeding (defineRule's seedMode: a package that ships a label criteria would now be refused on redeploy); and whether Skills-docs: (no skills/** change owed) is true.

Landing: a declared narrowing, so it goes through the seat: seat record, pm:awaiting-merge, an authorized approval, then the seat lands it. The zone does not label-write --land it.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: da6cbc1751472d1f30b32e2bc70872714bac346f
Local-runs: none
Scope: packages/plugins/plugin-sharing/src/rule-criteria-option-label.ts, packages/plugins/plugin-sharing/src/rule-hooks.ts, packages/plugins/plugin-sharing/src/sharing-rule-option-label-39434.test.ts, packages/plugins/plugin-sharing/src/sharing-rule-service.ts + read, not reviewed: packages/plugins/plugin-sharing/src/rule-criteria.ts, packages/plugins/plugin-sharing/src/sharing-plugin.ts, packages/plugins/plugin-sharing/src/declared-sharing-rules.ts, packages/spec/src/data/filter.zod.ts, packages/spec/src/data/field-value.zod.ts, packages/objectql/src/engine-update.ts, packages/objectql/src/engine-hook-dispatch.ts, packages/objectql/src/validation/record-validator.ts, packages/drivers/driver-memory/src/filter-refusal.ts, content/docs/permissions/sharing-rules.mdx, AGENTS.md (Post-Task Checklist step 3), scripts/pm/clause2-line.mjs

Inputs read: card #39434 body and all 9 comments (ruling 7403149741, analysis 7399582338, dev reports 7399427182 and 7404804159); PR #39543 body, file list (5 files) and net diff against main; the check-runs on the head: every run success or skipped, 0 failed (Test Core 5/12 green on its one re-run; the first red was an artifact-upload reset after the suites passed, PR comment 7405351418).

① Derived judgments

  • Accept set, /data door (bindRuleCriteriaGuard, beforeInsert / beforeUpdate on sys_sharing_rule): a write whose criteria_json compares a select / radio / multiselect / checkboxes field of the rule's object with an option label that is no option's value is now refused VALIDATION_FAILED with one fields entry (criteria_json, invalid_option). Narrowed. Right: it is the ruled route, and the refused set is the ruled one (label only; inline options; not readonly; not picklist-bound; a label that is also a value passes; a literal outside both passes).
  • Accept set, POST /sharing/rules (defineRule): the same verdict, thrown as VALIDATION_FAILED: plus the same sentence, which the route already maps to 400. Narrowed. Right, and the two doors cannot disagree: one function, one sentence, pinned equal by test.
  • Update semantics: judged on insert, and on update or upsert only when the supplied criteria differs from the stored one (sameCriteria: key order and string-or-object spelling aside). Right, and it holds in the cited engine: a by-id update binds ctx.previous before beforeUpdate (engine-update.ts), a predicate update dispatches per row with that row's pre-image (engine-hook-dispatch.ts). A write that carries neither a pre-image nor object_name is not judged, which fails open, the safe side for a refusal.
  • Public surface: none added. rule-criteria-option-label.ts is not re-exported from the package index. bindRuleCriteriaGuard (exported) takes MinimalEngine & OptionLabelSchemaSource, whose one member getSchema is optional, so every existing caller still type-checks. No schema, no spec file, no REST answer member moves.
  • Stored rows: untouched. Nothing is judged at load or at evaluation; a rule stored with a label still loads, evaluates as before and can be switched off (pinned at both doors).

② Semver level

@objectstack/plugin-sharing: patch, with the BREAKING banner, the FROM and TO in the body, and the ADR-0087 marker not-required (no-migration-prescription). Correct: the level follows the Metadata-protocol: kind alone (AGENTS.md, Post-Task Checklist step 3), and the kind is none (settled below), so patch. Check Changeset is green on the head.

Clause-②: yes (narrowing), as declared on the PR body and the changeset, and as ruling 7403149741 words it. See N2: the value no is the accurate one, the arm is right, and the arm is what the gates and this face read.

Metadata-protocol, question (1), settled: none. Step 3 defines the line as "the change to what a metadata author can write": a key, an accepted value or a metadata type. What a metadata author writes for a sharing rule is stack.sharingRules with a CEL condition (SharingRuleSchema, packages/spec/src/security/sharing.zod.ts). That schema is not in the diff, and a declared rule never reaches either save door: since ADR-0131 D2 declared rules are read from the registry and are not rows (declared-sharing-rules.ts: "sys_sharing_rule holds only the rules an organization authors"). A sys_sharing_rule row's criteria_json is an organization's record, written through the data API by an administrator. The refusal is therefore a data-write narrowing on a platform table, which the (narrowing) arm and the BREAKING banner already carry; it is not a narrowing of the metadata protocol. Both same-door precedents read it the same way (PR #30953 and PR #39361: Metadata-protocol: none). The provisional none stands and is no longer provisional.

③ Boundary flags

  • Dev flag, deviation 2 (system-context writes are judged), question (2), answered: within the ruling, and it breaks no seed, install or upgrade path in the tree. The ruled route (7403149741) is "refuse a sys_sharing_rule save when a criteria literal on a choice field is an option label ... Judged only when the criteria change", with no carve-out by writer; the "system writes pass" sentence sits in the analysis's execution plan (7399582338, After the ruling, item 2), and the build departs from that plan, not from the tapped option. On the merits it is the right side: the verdict depends on the criteria alone, the negated form over-shares whoever writes it, and the match-all check in the same guard has judged system writes since it landed. System writers of sys_sharing_rule read on main: backfillRetiredAccessLevels (sharing-plugin.ts, patches access_level only), the package back-fill (package_id only), the position-rename carry (recipient_id only): none supplies criteria_json, so the guard returns before judging. defineRule writes under the system context after making the same check itself, so the guard re-reaches the same verdict. Declared rules are not rows and are not seeded. No seed in examples/, packages/apps or HotCRM writes a rule row. Not measured: an out-of-tree system insert of a stored label rule (a restore or a copy tool) would now be refused, exactly as a stored match-all row already is. The deviation is disclosed in the changeset and pinned by test; the maintainer's per-PR word on this BREAKING change should be given with it in view (N1).
  • Dev flag, deviation 4 (the array spelling pin dropped): accepted. isMatchAllCriteria refuses a pure ['F','=','L'] first at both doors (read in rule-criteria.ts: an array of scalars is match-all).
  • Carried item, negated comparands, question (3), answered: measured first, then covered. The first describe of the new test seeds rule rows through the driver (as stored before the guard), runs evaluateRule on a real engine and reads sys_record_share: $ne and $nin on the label grant all 5 records, the value controls grant 3. The diff then refuses $ne (scalar), $nin (each member), $not around any judged comparand at any depth, and $notContains on a multi-value field; pinned at the /data door ($ne, $nin, nested $not, checkboxes $notContains), on an update ($ne), and at defineRule ($ne, $nin on an upsert). $ne / $nin on a multi-value field need no arm: the drivers refuse the equality family on a JSON-stored column (filter-refusal.ts), so that rule errors at evaluation and shares nothing.
  • open_questions in report 7404804159: empty. The earlier report's fork (7399427182) is closed by the ruling.
  • SQL push-down: no finding. The diff adds no query, no id materialisation and no in-app join; it reads the in-memory registry (engine.getSchema) and reuses the existing row defineRule already fetched.
  • Skills-docs: follow-up owed — content/docs/permissions/sharing-rules.mdx: true. That page describes each save-time refusal on this door (object not under enforcement, unresolved user recipient, match-all criteria) and does not describe this one; the page is outside the claim's file surface. No skills/** change is owed: the skills name sys_sharing_rule once, as a catalog row, and teach rules as declared sharingRules; none teaches criteria_json or POST /sharing/rules. The line still reads owed — FILE and is the seat's to rewrite to a card number before ACCEPT (N3).

④ Design judgment

The narrowing makes an existing prohibition real; it takes no declared capability away. The spec declares that a choice field stores option values, and the record validator refuses a non-option value on a non-readonly select / radio write, so a label that is no option's value matches no row written through the engine under the current options. The positive forms are fully inert and the negated forms share every record: the state ADR-0078 Decision 1 prohibits, on the door whose own docblock already applies that ADR. The spec-declared states that could hold another value are each left alone: a readonly choice field (open vocabulary) is skipped, a literal outside both values and labels still saves (createMissingOptions, retired options), and a label that is also some option's value is never reported. So the refusal stops where the proof stops, which is the line the maintainer drew between option A and option E.

Attempts to break it, and what held:

  • Operator coverage against FILTER_OPERATORS and LOGICAL_OPERATORS on main: the judged set is the equality and membership family ($eq, $ne, $in, $nin, bare) on a single-value field and $contains / $notContains on a multi-value field, under $and / $or / $not. There is no field-level negation operator outside that set.
  • Multi-value routing follows isMultiValueField, the spec's one definition, so a select declared multiple: true is judged by membership and not by equality.
  • Prototype keys (constructor, __proto__) as criteria keys resolve to no judged field. A non-string literal is never matched. Numeric option values are compared as strings and only on the label side.
  • Two doors, one judge: the update skip is sameCriteria at both, the object comes from the supplied object_name or the pre-image, and defineRule's own system write passes the guard with the verdict it already reached.
  • The module's prose claims were read in the code they cite and hold: the driver refusal on JSON-stored columns, the readonly shape-only write, the match-all precedence over the array spelling.

No must-fix, no should-fix.

Nits (none affects correctness or the contract; none needs a change on this head):

  • N1 (nit) — the build judges system-context writes where the analysis's plan said they pass. Within the ruled route and safe in the tree (③); left as an accepted deviation, named here so the maintainer's BREAKING word covers it. The stated motive (a census gate asking for a doc row outside the file surface) would not carry it alone; the criteria-only reasoning does.
  • N2 (nit) — Clause-②: yes (narrowing) reads as "widens one surface and narrows another" (scripts/pm/clause2-line.mjs); this diff widens nothing, and both precedents wrote no (narrowing). The value follows the ruling comment's wording, the arm is correct, the level and the tier do not depend on the value. Accepted deviation; a changeset edit would move the head.
  • N3 (nit) — the Skills-docs: line names a file, not a card. Prose face: the seat files the docs card and rewrites the line to its number before ACCEPT.
  • N4 (nit) — residue outside the ruled operator list, for a follow-up card if pull appears: a negated substring on a single-value field ($notContains with a label) also shares every record and is not judged, because no value can be prescribed for a pattern; an array-spelled leg mixed into an object criteria ({"$and":[{...},["F","!=","L"]]}) is neither match-all nor walked; a label supplied only by a translation bundle is not judged; and a label that equals a value rows still hold from before an option was re-keyed is refused, with a pattern operator as the only way to write that rule. The last is the stated cost of option A ("under the current options").

Implemented-by: claude/issue-39434-wip
Reviewed-by: session_016WV4czzaKz49WLAvKtdyiY

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7

速读 · PR #39543 (Fixes #39434, p1) · head da6cbc1751472d1f30b32e2bc70872714bac346f

  • 改了什么:共享规则的条件里,如果把下拉/单选字段选项的「显示名」当成值来写(行里存的是值),保存时拒绝,并提示应写的值。这是 Elon 06:09Z 对 sharing rules: saving a condition whose literal is not one of a choice field's option values is warned about or refused (save-time half of #39418) #39434 的裁决 A(只管显示名这一种,不拒其他不在选项里的值)。
  • 收窄(请批的原因):以前这类写错的规则能存下但永远匹配不到记录,现在保存即拒。已声明 Clause-②: yes (narrowing),changeset 带 BREAKING;系统上下文的写入同样会被判(在裁决范围内,仓内无种子数据受影响,L2 N1)。
  • 要你做什么:批准本 PR。契约审核 PASS 7406643838(Head-sha da6cbc1751,无 must-fix/should-fix),批准后由座位落地。
  • 席位意见:接受。

席位核对 — ACCEPT · repo:objectstack@os-elon-musk · head da6cbc175147

  1. 形态:draft,base main,5 files +622 −3(plugin-sharing 新判定模块、rule-hooks、service、测试、changeset);Fixes #39434;Metadata-protocol: none(L2 定案,与同门先例 fix(plugin-sharing)!: a sharing rule on an object without record sharing is refused at save #30953、fix(plugin-sharing): refuse an unresolved user recipient on the sys_sharing_rule /data door #39361 一致);Skills-docs: follow-up #39583。
  2. 前提实测:裁决 7403149741 的范围(只拒显示名、$ne/$nin 覆盖)。L1-b ACCEPT 7406558663,L2 PASS 7406643838 于本 head。
  3. 门禁 check-runs(本 head,席位自读):45 success · 24 expected skip · 0 failed;Check Changeset 读时仍在跑,落地前复读。Test Core 5/12 一次 artifact 上传 ECONNRESET,重跑一次绿。
  4. 接受的偏差:N2,Clause-②: yes (narrowing) 更准确应为 no (narrowing),不改以免移 head;N1 见速读。
  5. 范围外去向:文档页 content/docs/permissions/sharing-rules.mdx → docs: sharing-rules.mdx does not list the save-time refusal of a criteria that compares a choice field with an option label #39583;sharing rules: the condition value for a single-choice (radio) field is free text, so the option label is stored and the rule shares nothing #39418 随本 PR 落地关闭(选择器半已在 fix(plugin-view): a single-choice (radio) field can group a kanban #39442 合并)。
  6. 落地条款:声明收窄 ⇒ 维护者授权批准后由座位落地(审批后的 Tier H PR 由座位自己合并,Elon 2026-12-03T23:43Z)。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7

维护者速读

  • 改了什么:保存共享规则时,如果条件把下拉或单选字段的选项「显示名」当成值来写,就拒绝保存,并提示应该写的值。以前这种规则能存下来,但永远匹配不到任何记录。依据是 Elon 对 sharing rules: saving a condition whose literal is not one of a choice field's option values is warned about or refused (save-time half of #39418) #39434 的裁决 A,只处理显示名这一种情况。
  • 收窄(请批的原因):声明为 Clause-②: yes (narrowing),changeset 带 BREAKING。系统上下文的写入同样会被判,这在裁决范围内,仓内没有种子数据受影响。
  • 要你做什么:批准本 PR。契约审核 PASS 7406643838,Head-sha da6cbc1751472d1f30b32e2bc70872714bac346f,没有 must-fix 或 should-fix。席位记录为 ACCEPT 7406674871。批准后由座位落地。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Dec 4, 2026
@objectstack-fleet
objectstack-fleet Bot requested a review from os-zhuang December 4, 2026 08:59
@os-zhuang
os-zhuang marked this pull request as ready for review December 4, 2026 09:05
@os-zhuang
os-zhuang added this pull request to the merge queue Dec 4, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7

2026-12-04T09:06Z · Landing PR #39543 at head da6cbc1751472d1f30b32e2bc70872714bac346f.

Probe Reading
Authorized approval os-zhuang APPROVED (review 6186246896) on this head
Check-runs on this head 0 failed; Dogfood battery (opt-in) success

pm:awaiting-merge removed → ready + auto-merge. Seat landing line: 「审批后的 Tier H PR 由座位自己合并」 (maintainer 2026-12-03T23:43Z).

@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Dec 4, 2026
Merged via the queue into main with commit 8feef82 Dec 4, 2026
111 of 113 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-39434-wip branch December 4, 2026 09:34
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 needs:dogfood-battery size/l 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.

sharing rules: saving a condition whose literal is not one of a choice field's option values is warned about or refused (save-time half of #39418)

3 participants