Repository navigation
Commit 13057ce
feat(spec, lint): a permission set can acknowledge a meant roll-up read with rollupSourceUnreadableReason (#34775)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi94c3JZDWgKZEMu2AsnddNtK)_
Fixes #34664
Clause-②: yes (widening) — one new optional authorable key,
`rollupSourceUnreadableReason` on `FieldPermissionSchema` (a permission
set's `fields` entry); nothing that parsed before is refused
Metadata-protocol: added
Skills-docs: follow-up #34742
## 维护者速读
- 改了什么:权限集里某个汇总列的字段条目可以写 `rollupSourceUnreadableReason:
'理由'`,声明「这个集本就该看汇总、不看明细」;写了之后,这个集这一列的
`security-rollup-source-unreadable` 由 warning 降为 info 并引出理由,`os lint
--strict` 不再因它失败。
- 为什么改:这条规则自己说「这种组合合法且常是有意的」,但 `--strict` 把 warning
判失败、又没有任何确认办法,HotCRM(hotcrm#2557/#2560,账户下挂发票与收款)只能二选一:给子对象开读权限(会放开所有行)或藏掉总额。键名与落位由席位定(卡上
6943835606)。
- 风险与回滚:纯新增可选键,运行时不读这个键;但理由只能写在字段条目上,而条目本身在字段合并里投 `readable: true`
一票(最宽者胜),原本没有该列条目的集为挂理由新加条目,会让同时持有屏蔽集的用户重新看到这一列,文档与 describe 已写明(L2
S1)。空白理由、`readable: false` 旁带理由在解析时拒收。其它集、其它列和 row-scoped 提示不受影响。回滚即还原本
PR。
- 先看:`packages/lint/src/validate-rollup-source-visibility.ts` 的
`acknowledgedReason` 与 `unreadable`
闭包;`packages/spec/src/security/permission.zod.ts` 新键与第二个
`.refine`;`packages/lint/src/validate-rollup-source-visibility-acknowledged-34664.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run
src/validate-rollup-source-visibility-acknowledged-34664.test.ts`,预期 9
例全绿。
- 需要你做的:契约改动(packages/spec/src),L1 与 L2 通过后由席位请 os-zhuang 批准。
## What changes
`security-rollup-source-unreadable` is advisory by its own header ("the
pair is legal and is often meant"), but it emits a `warning`, `os lint
--strict` fails on any warning
(`packages/cli/src/commands/lint.ts:1175-1179`), and `packages/lint` /
the CLI had no per-finding acknowledgement. The seat named the key and
its placement (card comment 6943835606): option A of the three offered.
- **Spec (`packages/spec/src/security/permission.zod.ts`).**
`FieldPermissionSchema` gains `rollupSourceUnreadableReason: string`
(optional). Two parse refusals: a blank reason (`NON_BLANK_STRING`,
which projects into the JSON Schema), and a reason beside `readable:
false` (a second object `.refine` on path
`rollupSourceUnreadableReason`; the column is hidden, so there is no
read to acknowledge). The describe says the key is read only at
authoring time, and (contract review S1) that the entry carrying it is
an ordinary declaring entry: it votes `readable: true` in the field
merge, so on a set with no entry for the column, adding one restores the
column for holders whose other sets mask it. The same sentence is in the
jsdoc, `rule-explanations.ts`, `fields.mdx` and `security.mdx`.
`FieldPermissionSchema` is also reused by
`GetObjectPermissionsResponseSchema.fieldPermissions`; per the seat the
type is not split, and the server never sends the key.
- **Lint (`packages/lint/src/validate-rollup-source-visibility.ts`).**
`acknowledgedReason(set, column)` reads the set's OWN entry for the
summary column. When it carries a non-blank reason, every
`security-rollup-source-unreadable` finding for that set and column
(object, aggregated-field and filter-field arms) is emitted at `info`,
same rule id, message ending `Acknowledged on the set: ` plus the reason
as a JSON string literal (quotes and line breaks stay escaped), path
`permissions[i].fields["OBJECT.SUMMARY"].rollupSourceUnreadableReason`,
and a hint saying how to restore the warning. Other sets, other columns,
and `security-rollup-source-row-scoped` are unchanged. Docblock table
and a new section document it.
- **Docs.** `rule-explanations.ts` (the rule's explanation gains the
acknowledgement paragraph), `content/docs/data-modeling/fields.mdx`
(roll-up section, with an example),
`content/docs/deployment/validating-metadata.mdx` (the advisory row),
`content/docs/protocol/objectql/security.mdx` (the field permission
reference, which enumerates the entry's keys; added after the docs-drift
comment named the page).
- **Ledgers and generated.** `packages/spec/liveness/permission.json`
gains `fields.children.rollupSourceUnreadableReason` = `live` (lint is
the whole feature, the same posture as dashboard
`widgets.suppressWarnings`); regenerated
`authorable-surface/security.json`,
`liveness/state-counts/permission.md`,
`content/docs/references/security/permission.mdx`,
`content/docs/references/api/protocol.mdx`.
- **Changeset** `.changeset/34664-rollup-source-unreadable-reason.md`:
`@objectstack/spec` minor, `@objectstack/lint` minor.
## Tests
- New
`packages/lint/src/validate-rollup-source-visibility-acknowledged-34664.test.ts`
(9 cases, through `runAuthoringRules`): control without the key (both
roll-ups warn); key on one column ⇒ that finding `info`, reason quoted,
path at the key, the other column still `warning`; every column
acknowledged ⇒ no warning left; another set reading the same column
still warns; a blank reason on the raw door acknowledges nothing; the
row-scoped note is untouched; the aggregated-field and filter-field arms
are acknowledged the same way; a quote and a line break in the reason
stay inside the quoted literal; a parsed set answers what the raw one
does.
- `packages/spec/src/security/permission.test.ts`: 5 new cases under
`rollupSourceUnreadableReason` (accepts and keeps it; absent key does
not materialise; blank and non-string refused; refused beside `readable:
false`; rides a permission set's `fields`).
- No existing test was changed.
## Acceptance notes
- **Same rule id at `info`.** The acknowledged finding keeps
`security-rollup-source-unreadable` (only its severity moves), so
`--json` consumers filtering by id still see the pair. One consumer
filters by id without severity:
`packages/qa/scenarios/src/runner/orchestrate.ts#rollupSourceCharges`
still charges an acknowledged pair when the card withholds the child
from that persona. That is intended: an acknowledgement does not make a
withheld total un-leaked, and its message regex still reads the new
message (no `$` anchor). Not changed here.
- **A stale acknowledgement is not reported.** A reason on an entry
whose set and column raise no finding (or on a non-summary field's
entry) is silent, and it pre-acknowledges: if the child read is later
removed, the finding first appears at `info`. The seat chose not to add
that in this PR (contract review N3).
- **Console permission matrix (contract review S2) → #34786.**
`ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.tsx#updateFieldPerm`
clears only `when` on Read off, so an entry carrying a reason turns into
the refused `readable: false` + reason shape;
`permission-slice.ts#withFieldBits` drops the reason silently. Out of
this card's file surface; filed by the seat as #34786 (Blocked-by
#34664).
- **Skills** are out of this card's file surface (seat ruling, relayed
by the area); the skill line and an eval go on #34742.
## Verification
<details><summary>Premise on origin/main f6f5b50</summary>
- The rule header calls the pair "legal and often meant" and emits
`severity: 'warning'`.
- `packages/cli/src/commands/lint.ts:1175-1179`: `failing =
errors.length + (strict ? warnings.length : 0)`.
- No acknowledgement or suppression in `packages/lint/src` or the CLI;
the only metadata suppression key is the dashboard widget's
`suppressWarnings` (`packages/spec/src/ui/dashboard.zod.ts:1415`);
`packages/lint/src/index.ts:1127` states "the CLI has no per-rule
suppression".
- `node scripts/pm/check-prior-rulings.mjs --card 34664`:
ADR-0035/0061/0063/0071/0074/0079 hits; none rules on acknowledging an
advisory finding. ADR-0035's roll-up semantics are unchanged.
</details>
<details><summary>Package tests and typecheck</summary>
- `pnpm --filter @objectstack/lint test`: Test Files 216 passed (216),
Tests 9124 passed (9124).
- `pnpm --filter @objectstack/spec test`: Test Files 848 passed (848),
Tests 27174 passed, 1 todo.
- `pnpm --filter @objectstack/lint typecheck` and `pnpm --filter
@objectstack/spec typecheck` (with
`NODE_OPTIONS=--max-old-space-size=4096`): exit 0, test-typecheck debt
held.
</details>
<details><summary>Ablations (both legs restored, `git diff HEAD`
empty)</summary>
- Lint: `acknowledgedReason` made to return `undefined` (anchor `return
nonBlank(reason) ? reason.trim() : undefined;`, 1 → 0, via
`scripts/ablation-replace.mjs`) ⇒ the new suite goes red, 4 failed / 3
passed (the four acknowledged cases; the control, blank-reason and
row-scoped cases stay green, as expected).
- Spec: the `readable: false` refine made vacuous (`(p) => true || …`) ⇒
`refuses a reason beside readable: false` goes red, 1 failed / 4 passed.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, each command run with `< /dev/null`, exit
captured before any pipe; reconciliation `--ran`: **115 derived, 114
run, 1 NOT-MEASURED, 0 UNRUN**, every run family exit 0. After the
security.mdx commit (head 7a8180f) the derived set is unchanged; the
docs families re-run on it (`check:doc-anchors`, `check:doc-authoring`,
`check-affected-docs`, `check-drift-comment`,
`check:docs-transcript-drift`, `check:nul-bytes`) exit 0.
- First pass red only on generated artefacts (`check:docs`,
`check:liveness` counts) and on prerequisites (lint dist not built; a
shallow clone for `check-plugin-teardown-shape --self-test`).
Regenerated with `gen:schema`, `gen:docs`, `gen:liveness-counts`, built
`@objectstack/lint`, unshallowed, and re-ran those families: all exit 0.
- `check:generated` (derived after merging origin/main) exit 0 with
`NODE_OPTIONS=--max-old-space-size=4096` (without it the test-typecheck
step runs out of heap, not a finding).
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, which needs every
package's `dist/` (a full `pnpm build`); CI runs it.
- Record: `/mnt/project-files/objectstack-seat2/34664-gates-ran.txt`
(project file).
</details>
<details><summary>Rework round (contract review 6945280556: S1, N1, N2,
N4, N5)</summary>
- Head after the round: b61b6d7 (commit
f592705 plus a merge of origin/main).
- Lint: the two rule suites + `rule-explanations` tests, 60/60;
`@objectstack/lint` typecheck exit 0. Spec: `permission.test.ts`
127/127.
- After the merge: `@objectstack/spec` rebuilt; `check:generated` exit 0
(with `NODE_OPTIONS=--max-old-space-size=4096`). Re-run, all exit 0:
`check:docs`, `check:authorable-surface`, `check:liveness`,
`check:doc-anchors`, `check:doc-authoring`, `check-affected-docs`,
`check:docs-transcript-drift`, `check:nul-bytes`,
`check:doc-security-posture`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQbFKVWVEYrgUsNnfJ
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmQbFKVWVEYrgUsNnfJ)_
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmQbFKVWVEYrgUsNnfJ -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c513d62 commit 13057ce
14 files changed
Lines changed: 377 additions & 13 deletions
File tree
- .changeset
- content/docs
- data-modeling
- deployment
- protocol/objectql
- references
- api
- security
- packages
- lint/src
- spec
- authorable-surface
- liveness
- state-counts
- src/security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
418 | 437 | | |
419 | 438 | | |
420 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
| 531 | + | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| 269 | + | |
| 270 | + | |
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1711 | 1711 | | |
1712 | 1712 | | |
1713 | 1713 | | |
1714 | | - | |
| 1714 | + | |
1715 | 1715 | | |
1716 | 1716 | | |
1717 | 1717 | | |
| |||
1739 | 1739 | | |
1740 | 1740 | | |
1741 | 1741 | | |
| 1742 | + | |
1742 | 1743 | | |
1743 | 1744 | | |
1744 | 1745 | | |
| |||
0 commit comments