Repository navigation
Commit a0b01fa
feat(platform-objects): an organization sets the display decimal places of each standard unit of measure (ADR-0158 U6) (#37389)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8ZBQe4UHadd2fGHGeWRW9V)_
repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS
Fixes #35498
Refs #35339
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 管理员在设置的「配置」下、「计量单位」下面多一个「标准单位设置」页,可以给千克、克、件等国际标准单位各设一个显示小数位(比如珠宝行把克设成
3 位,砂石场把千克设成 0 位);所有成员都能看到这些设置,别的组织看不到。
- 这是「计量单位」第一期里你选的「组织可改,新开一处设置」那一项;数量按单位显示的卡片会读它,本改动本身还不改变任何页面上数字的显示。
-
只有组织管理员能新增、修改或删除,删除即清除;每次改动都记审计;组织里还留着设置时不能删除该组织,要先删掉设置,和汇率一样;可以直接撤回,因为还没有地方读取它。
- 需要你做的:无。
## What changes
- **`@objectstack/platform-objects`**: new organization-owned object
`sys_standard_unit_setting` (ADR-0158 U6; Open item 10 option A),
registered in the first manifest beside `sys_unit`.
- `code`: text, max 3. A format rule admits exactly the `STANDARD_UNITS`
codes in exact uppercase (`STANDARD_UNIT_SETTING_CODE_PATTERN`). Unique
per organization, immutable after create.
- `decimal_places`: 0 to 12, scale 0, required.
- Field history on both columns. No tenancy opt-out, so
`organization_id` is injected.
- Setup → Configuration → Standard Unit Settings, directly under Units
of Measure, with all eleven nav labels translated. The translation
bundles are regenerated; the zh-CN object strings are translated.
- **`@objectstack/plugin-security`**:
- `member_default` reads it (read only).
- `organization_admin` gets an explicit line: create, edit and delete.
Clearing a setting is deleting its row.
- **`@objectstack/spec`**: `sys_standard_unit_setting` joins
`PLATFORM_OBJECTS_BY_PACKAGE['platform-objects']`.
- **`@objectstack/cli`**:
- The organization-ownership inventory lists the object as attributed.
- The Setup nav count pin goes from 36 to 37.
- `scripts/platform-object-tenancy-census.json` is regenerated.
**Precedent: `sys_unit.decimal_places`.** The setting follows the same
concept as an org unit's own decimal places: range 0 to 12, field
history, member read, organization-admin write. The settings-key route
(ADR-0144 D4's `localization.currency`) was measured and not followed,
for four reasons. It is one org-wide scalar. Members read it only
through a server projection. Its audit keeps hashes, not values. A
per-code map would need a new settings column kind. The area approved
this on claim amendments 7178077326 and 7178144166.
**Deviations from the first shape, all on the card (amendments
7178077326, 7178144166, 7179529249):**
- **No reader in this PR (amendment 7178077326).** The display card
#35490 adds the reader with its first caller, and the ADR-0158 L4 clamp
to the field's `scale` goes there. "A member can read them" is met by
`member_default` read over the data API.
- **Clear = delete, not set-to-null (amendment 7178144166).** An
organization delete refuses `DELETE_RESTRICTED` while any
organization-owned row remains. Only `sys_unit` is exempt, through the
engine's own cascade. So a row with no delete would block the
organization delete forever. This follows `sys_exchange_rate`'s posture:
an admin deletes the setting, then the organization delete goes through.
Pinned below.
**Why `code` is text plus a format rule, not a select.** A select's
option values are stored lowercase (`kgm`), while a unit code is stored
in exact uppercase everywhere (U4). The rule's pattern is built from the
`STANDARD_UNITS` keys, so a code the table gains is admitted with no
second edit.
First files to read, by risk:
1.
`packages/plugins/plugin-security/src/objects/default-permission-sets.ts`:
the two `sys_standard_unit_setting` lines.
2.
`packages/platform-objects/src/system/sys-standard-unit-setting.object.ts`:
the format rule and the immutable-code rule.
3.
`packages/plugins/plugin-security/src/default-permission-sets.standard-unit-setting.integration.test.ts`:
the tenancy posture it boots under.
Two-minute check: `pnpm --filter @objectstack/plugin-security exec
vitest run --maxWorkers=2
src/default-permission-sets.standard-unit-setting.integration.test.ts`
prints 15 passed. It boots a real stack under the `isolated` tenancy
posture. It shows each of these:
- an admin and an owner set, change and clear a setting, each act
landing in `sys_audit_log` with old and new values;
- an admin changes and deletes a setting the owner created, and the
owner one the admin created (the `organization_admin` line, no superuser
bits);
- a member reads, and is refused 403 `PERMISSION_DENIED` on every write;
- another organization's setting is never read, changed or cleared;
- a non-standard or lowercase code, an out-of-range value, a duplicate
code and a changed code are each refused;
- an organization delete refuses 409 `DELETE_RESTRICTED` naming this
object, and succeeds once the setting is deleted.
## Tests
**Rework round 1 (L1 7180149059, contract record 7180135740), head
`98cbc47602`.** S1: the changeset sentence and the object's docblock now
state the posture the isolation holds under (`isolated`; `single` raises
no wall, `group` walls by membership, ADR-0105 D1), and N1 says the
display card #35490 *will* read the value. S2: new cases where an admin
and an owner each change and delete a setting the other created, plus
the effective-permission map (delete kept, no `modifyAllRecords`).
Affected tests re-run: the real-stack suite 15 passed (15), the
declaration suite 14 passed (14). Ablation of the `organization_admin`
line to `allowEdit: false, allowDelete: false` turned 8 of 15 red, the
new cross-creator cases among them; restored, with the blob equal to
HEAD and `git diff HEAD` empty.
All readings below are on head `03e453e3`, and the tree is
byte-identical to the commit.
<details><summary>Package suites and typecheck (under the verify
lock)</summary>
- `@objectstack/plugin-security`,
`src/default-permission-sets.standard-unit-setting.integration.test.ts`:
Test Files 1 passed (1), Tests 12 passed (12).
- `@objectstack/platform-objects`, full suite: Test Files 127 passed
(127), Tests 2176 passed (2176). This includes the new
`sys-standard-unit-setting.object.test.ts`.
- `@objectstack/cli` unit layer,
`src/utils/organization-ownership-inventory.test.ts` and
`test/connect-agent-both-halves-wire.pin.test.ts`: Test Files 2 passed
(2), Tests 28 passed (28). The CLI integration layer is left to CI.
- `@objectstack/spec`,
`src/system/constants/platform-object-names.test.ts`: Test Files 1
passed (1), Tests 14 passed (14).
- Typecheck of `platform-objects`, `plugin-security`, `cli` and `spec`:
run in one `set -e` batch that reached its last part, so each exited 0.
`platform-objects` reports `check:test-typecheck: OK`.
- The full `plugin-security` suite and `test:repo` are left to CI.
</details>
<details><summary>Ablation: the member read grant</summary>
- `node scripts/ablation-replace.mjs` changed `member_default`'s
`sys_standard_unit_setting` line to `allowRead: false`. Evidence: anchor
x1 → x0, blob `d4a112e3` → `87691407`.
- The suite went 2 failed | 10 passed. The member read test and the
cross-organization read test both failed with `PermissionDeniedError`.
- Restored: the blob equals HEAD (`d4a112e3`) and `git diff HEAD` is
empty.
</details>
## Acceptance notes
- **The cross-organization pins need the `isolated` posture.** Under the
default `single` posture no tenant wall stands, so another
organization's row is visible. That is ADR-0105 D1's design, and every
organization-owned object behaves the same way. The suite registers
`tenancy: { posture: 'isolated' }`, as a deployment with organizations
runs. The first run without it showed the other organization's row,
which is how this was found. The `sys_unit` suite pins no
cross-organization read.
- **External members get no read**, the same as `sys_unit`. The display
card #35490 already owes what an external member sees (comment
7030066814).
- **No ADR text in this diff.** The ADR-0158 amendment (U3, U6 and L4
notes, and the Open item 10 answer) is drafted in the card report; the
area lands it as row 7179515770 on the weekly ADR revisions card #37245
after this PR merges.
- **Locale fill.** zh-CN carries translated object strings. The other
nine locales carry the generator's English fill; nav labels are
translated in all eleven.
## Verification
<details><summary>Derived gate families (106 families, 212 commands) and
the --ran reconciliation</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 212 commands from the tree at
`03e453e3`. Each was run, with its exit code captured before any pipe.
- 211 exited 0. Five of those first exited 3 because a build
prerequisite was missing: `check-plugin-teardown-shape --self-test`
needed an unshallowed clone, and `check:skill-examples`,
`check:dual-build-cjs-loads`, `check:i18n-coverage` and
`check:published-readme-exports` needed a full build. All five exited 0
after `git fetch --unshallow` and a full turbo build (122 of 122 tasks).
- `pnpm check:platform-checklist` exited 1 on one problem:
`areas/automation.json` cites `FlowItemMoreMenu.tsx#FlowItemMoreMenu`, a
symbol the `ui/` file no longer declares. That is the base tree's own
state: this diff touches neither `ui/` nor `docs/qa/`, and the cited
file is the same on `origin/main`.
- `--ran` printed: "106 derived famil(ies) accounted for — 106 run, 0
NOT-MEASURED (a DERIVED zero — all 106 recorded an exit code and none of
them is 3)".
</details>
<details><summary>Overlap check</summary>
- `node scripts/pm/overlap-check.mjs --branch=HEAD` against origin/main
`02520ab480` printed "VERDICT clean exit 0". Two open PRs share a file,
#37371 (`default-permission-sets.ts`) and #37366
(`platform-objects/src/plugin.ts`); both merge cleanly with this branch.
</details>
<details><summary>Not measured locally</summary>
- The CLI `integration` layer, `test:repo`, the full `plugin-security`
suite and the repo-wide lint are left to CI.
- Dogfood: n/a. The title has no `!`, and Clause-② is a widening.
</details>
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CXM7nqtiQ3M9JqGAqL)_
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbdHk3orAeensH6EzS -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8061d83 commit a0b01fa
48 files changed
Lines changed: 1288 additions & 13 deletions
File tree
- .changeset
- packages
- cli
- src/utils
- test
- platform-objects
- scripts
- src
- apps
- translations
- system
- plugins/plugin-security/src
- objects
- spec/src/system/constants
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
863 | 868 | | |
864 | 869 | | |
865 | 870 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
292 | | - | |
| 294 | + | |
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| |||
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
| 305 | + | |
303 | 306 | | |
304 | 307 | | |
305 | 308 | | |
| |||
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
325 | | - | |
326 | | - | |
| 328 | + | |
| 329 | + | |
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
| 372 | + | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4505 | 4505 | | |
4506 | 4506 | | |
4507 | 4507 | | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
4508 | 4544 | | |
4509 | 4545 | | |
4510 | 4546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4505 | 4505 | | |
4506 | 4506 | | |
4507 | 4507 | | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
4508 | 4544 | | |
4509 | 4545 | | |
4510 | 4546 | | |
| |||
0 commit comments