Repository navigation
fix(plugin-sharing)!: refuse a sharing-rule criteria that compares a choice field with an option label - #39543
Conversation
…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>
…ING, patch) 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>
Claude-Session: https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 12 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 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
|
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9 Test Core (5/12) at Generated by Claude Code |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czHUJLmdQAqm4fdDs9 Final green head · 2026-12-04T08:51Z · |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY 席位核对L1 verdict (L1-b): ACCEPT at head Face: Against the ruling (7403149741, option A, the option-LABEL comparand only):
Diff (5 files, +622/−3):
Left to the L2 contract review on this head (running now, the ruling assigns these to it): whether Landing: a declared narrowing, so it goes through the seat: seat record, Generated by Claude Code |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4czzaKz49WLAvKtdyiY Contract reviewServed-tier: 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 ① Derived judgments
② Semver level
Clause-②: yes (narrowing), as declared on the PR body and the changeset, and as ruling 7403149741 words it. See N2: the value Metadata-protocol, question (1), settled: ③ Boundary flags
④ Design judgmentThe 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 Attempts to break it, and what held:
No must-fix, no should-fix. Nits (none affects correctness or the contract; none needs a change on this head):
Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7 速读 · PR #39543 (Fixes #39434, p1) · head
席位核对 — ACCEPT · repo:objectstack@os-elon-musk · head
|
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7 维护者速读
|
|
repo:objectstack@os-elon-musk · os-elon-musk · session_016WV4cxiJF5PkqquFk98Bh7 2026-12-04T09:06Z · Landing PR #39543 at head
|
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 declaredstack.sharingRulesCEL conditions, which are notsys_sharing_rulerows and never pass this door.Metadata-protocol: noneis provisional, as the ruling leaves it: narrowed versus none is the contract reviewer's. Both same-door precedents declarednone(PR #30953, the object-enforcement refusal; PR #39361, the user-recipient refusal), because asys_sharing_rulerow is an organization's data, not package metadata.维护者速读
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_ruledoors, 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:plugin-sharing/src/rule-criteria-option-label.ts: the label reading (the oneflow-condition-option-labeldefined for flows, read from the runtime registry viaengine.getSchema), the refusal sentence, andsameCriteria(key order and string-or-object spelling aside)./datadoor:bindRuleCriteriaGuard(rule-hooks.ts) refusesVALIDATION_FAILED(400) with onefieldsentry{ 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 isVALIDATION_FAILED:followed by the same sentence, which the route already maps to 400.check:system-context-censusthen required a new row oncontent/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,checkboxesof the rule's object, inline non-empty options, notreadonly, not bound to a sharedpicklist. 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'whereopenis 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:F: L,$eq,$in(each member) on a single-value field$ne,$nin(each member) on a single-value field$contains,$notContainson a multi-value field$and/$or/$not$contains/$notContains/$startsWith/$endsWith/$icontains/$like/$ilikeon a single-value field$gt/$gte/$lt/$lte/$between$null/$exists/$empty['F','=','L']isMatchAllCriteria), measured while writing the pinsowner.status)Carried item 2: negated comparands measured first (over-share)
Real
ObjectQL+SqlDriver(better-sqlite3), five repair orders (threegao, twojinji), a rule row stored as before this guard,evaluateRule, thensys_record_shareread 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.$eq/$inon the label → 0; control on the value → the 2 urgent.These eight cases are pinned in the first
describeof 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);defineRulerefusing with the /data door's sentence behindVALIDATION_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
10ad9101(test only):Tests 13 failed | 17 passed (30)— every refusal case red, every measurement and control green.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).scripts/ablation-replace.mjs, mutation landed anchor 1 → 0, restored blob == HEAD):$nedropped 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$nedefineRule cases).sameCriteriaskip deleted →Tests 1 failed | 28 passed (29)(the criteria-untouched update on a legacy label row).isSystemskip re-inserted in the /data guard →Tests 1 failed | 29 passed (30)(the system-context case); restored blob == HEAD,git diff HEADempty.Acceptance notes
content/docs/permissions/sharing-rules.mdxdescribes 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.criteria_jsonis not judged by this check.selectOptionsOfin@objectstack/lint(flow-select-options.ts): plugin-sharing does not depend on@objectstack/lint, that helper is not exported from its index, andpackages/lint/src/**is outside this claim.stack.sharingRulesCEL condition is not judged here (declared rules are not rows); the lint rule for it is the seat's follow-up after the claims holdingpackages/lint/srcrelease.Verification
Read first, by risk:
packages/plugins/plugin-sharing/src/rule-hooks.ts(thebindRuleCriteriaGuardhunk: ordering after match-all, no system skip, thesameCriteriaearly return);packages/plugins/plugin-sharing/src/sharing-rule-service.ts(thedefineRulehunk, 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→ expectTests 30 passed (30).Gates (local subset at da6cbc1)
Derived with
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackatda6cbc17(73 commands), each run with its exit code captured before any pipe; reconciliation:All 73 exited 0. ADR-0087 disposition:
Package:
pnpm --filter @objectstack/plugin-sharing test/typecheck/buildexit 0 atda6cbc17(dependency closure built first withpnpm --filter '@objectstack/plugin-sharing^...' build).test:repo,pnpm lintand the whole-tree families are CI's.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4czHUJLmdQAqm4fdDs9