Repository navigation
feat(spec,security): OrgScopingEntitlement grows platform-global exemption + unbounded-admin suppression, consumed by Layer 0 arming - #12704
Conversation
…+ unbounded-admin suppression Part of objectstack-ai/cloud#1653 (Phase 1). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…cts type alias Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 129 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 f262c14437f5343972b5672e345b652f1824accb && git checkout f262c14437f5343972b5672e345b652f1824accb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 15bf9e859e56862e6ebe7b5c42404de103362457 b49ebc290c0161fe48e0a7940603620af85a70ad && git checkout -B drift-repro 15bf9e859e56862e6ebe7b5c42404de103362457 && git merge --no-ff b49ebc290c0161fe48e0a7940603620af85a70ad
node scripts/docs-audit/affected-docs.mjs --json 15bf9e859e56862e6ebe7b5c42404de103362457
|
|
Enqueue attribution note: the merge-queue enqueue mutation for this PR was fired with the |
os-regen-merge four-step: merge commit first (deferral recorded), then the deliberate manifest + surface-baseline deletions re-applied on the merged tree and the whole chain regenerated with repo tooling. Both sides' sources verified present (retirement tombstone + registry entries; #12704 OrgScopingEntitlement tenancy-posture + capabilities). Co-Authored-By: Claude <noreply@anthropic.com>
…g figures, centre in the card (objectstack-ai#32227) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBQJTzhd1vVrNNMHrh2CgZpe)_ Part of objectstack-ai#32165 (item 2, the KPI cards; item 1, one batched dataset query per render, stays open on objectstack-ai#32200) Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:仪表盘和大屏上的 KPI 卡片不再把标题再写一遍做副标题(「Avg Progress / 47.0 / Avg Progress」变成「Avg Progress / 47.0」),大屏上的长金额「$1,090,000.00」整串显示不再被截成「$1,090,0…」。卡片「高而空」不在本 PR 改:按 objectui#12704 的裁定,这是 showcase 元数据把 KPI 写成两行高(`h: 2`)造成的,修法是元数据改 `h: 1`,渲染器有意保留两行卡片的留白(E2E 用例守着)。 - 为什么改:QA(objectstack-ai#32135)在 showcase 上看到卡片高而空、副标题重复标题、Command Center 的预算被截断,用户读不到完整数字。 - 风险与回滚:只动 `@object-ui/plugin-dashboard` 一个包的渲染,无服务器、spec、元数据改动;卡片高度与网格完全不变;短数值保持原字号;回滚即 revert 本 PR。 - 先看:`ui/packages/plugin-dashboard/src/metricTile.ts`(唯一的副标题规则 `metricTileSubtitle` 与大屏字号阶梯 `METRIC_TILE_BARE_VALUE_LADDER`)、`ui/packages/plugin-dashboard/src/MetricWidget.tsx`(副标题与大屏数值改读它)、`ui/packages/plugin-dashboard/src/DatasetWidget.tsx`(数据集卡片的说明行改读同一规则)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-dashboard/src/__tests__/metricTileLayout-12623.test.tsx packages/plugin-dashboard/src/__tests__/metricTileValueScale-12942.test.tsx`,预期 29 个测试全绿。 - 需要你做的:无,席位落地。 ## What changes - **One subtitle rule** (`metricTileSubtitle` in `metricTile.ts`): the first candidate whose localized text is not the localized title, compared after trimming, collapsing spaces and folding case. Read by every tile that draws a subtitle, so there are no per-tile copies: - the dataset-bound tile (`DatasetWidget`): caption = description, else measure label, each only if it is not the title. This is where the Chart Gallery's "Avg Progress" came from: the widget title and the dataset measure label are both authored "Avg Progress" (`chart-gallery.dataset.ts` measure `avg_progress`, `chart-gallery.dashboard.ts` widget `kpi_avg_progress`). Delivery Operations' "Total Budget" and Chart Gallery's "Total Spent" had the same repeat. The example metadata is left as it is; the render rule fixes every app. - `MetricWidget` (and so `ObjectMetricWidget` / every `object-metric` block): description, else the trend label, both localized (a known trend phrase translated) before the comparison. A description that repeats the label gives way to the trend label. - `MetricCard`: its description. - The title tooltip (`metricTileTooltip`) no longer stacks the same line twice. - **The truncation was the `bare` face, not the card tile.** Command Center's six-across hero strip draws `object-metric` with `variant: 'bare'`, whose value was a fixed `text-[2rem] truncate`; the card tiles already had the objectui#12942 ladder. Measured at 1440×900: each hero tile is 166 px wide, `$1,090,000.00` is 7.36 em by `metricTileValueEm`, 235 px at 32 px. The bare value now reads `METRIC_TILE_BARE_VALUE_LADDER` against the tile's own box (`@container` on the bare root): short values keep `text-[2rem]` at every width; a longer value climbs 14 → 16 → 18 → 20 → 24 → 30 → 32 px, each step at `ceil(maxEm × px)`. The budget draws at 20 px, whole (`scrollWidth == clientWidth`), with the full figure as its tooltip. The line box is a fixed 32 px (`leading-8`, placed after the size classes because `cn` drops a line-height written before a font size), so the label under a scaled value lines up with its neighbours'. - **The height is not changed here (round 2).** A dataset-bound metric card authored `h: 2` spans two `minmax(5rem, auto)` grid rows (176 px measured) while its content is about 90 px. Round 1 centred the tile in the card; `Build & E2E UI` went red on `e2e/dashboard-metric-tile-height.spec.ts` (objectui#12704), whose CONTROL keeps "the empty lower half the metadata fix removes … for a tile that asks for it": per objectstack-ai#12704 the fix for a tall tile is the metadata (`h: 1`, the designer's default, which hugs its content), and the renderer's half is that a two-row tile stays two rows with its content at the top. The centring is reverted, so the card's "tall and mostly empty" is answered by objectstack-ai#12704's height-hugging alone. Every showcase metric widget is authored `h: 2` (12 of 12); changing that is a metadata edit, outside this card's "no metadata change" order, so it is reported as a finding, not done. - **Root changeset** `.changeset/32165-metric-tile-subtitle-fit.md`, `@object-ui/plugin-dashboard` patch, with the two declaration lines. `Clause-②: no` measured: `metricTile.ts` is not re-exported from the package entry (`index.tsx` names none of it), and no published prop or type changes. ## Tests - `metricTileLayout-12623.test.tsx` (the tile layout harness), new top-level describes: - *a subtitle equal to the title is not drawn (objectstack#32165)*: dataset tile with measure label = title draws no caption, tooltip names it once; equal up to case and spacing; description = title gives way to a distinct measure label; CONTROL distinct measure label kept; `MetricWidget` description = label hidden; localized (zh-CN) comparison; trend label kept and takes the place of a repeated description; CONTROL distinct description kept; `MetricCard` hidden + CONTROL; `object-metric` hidden. - `metricTileValueScale-12942.test.tsx` (the value ladder harness), new describe *the bare tile's value ladder*: every step re-derived from `ceil(maxEm × px)`; CONTROL a short value keeps 32 px and no tooltip; the exact Command Center value `$1,090,000.00` at the measured 166 px draws at 20 px and fits (and did not at 32 px), tooltip carries it, `leading-8`. <details><summary>Ablations (scripts/ablation-replace.mjs, each restored with blob == HEAD and git diff HEAD empty)</summary> 1. `metricTile.ts`: `if (title && metricTileSameText(title, candidate)) continue;` → `if (false /* ablated-32165 */) continue;` (the old subtitle choice): 8 failed / 3 passed in the subtitle describe (every hide pin red, the three CONTROLs green). 2. `MetricWidget.tsx`: the bare value's `metricTileValueClass(displayValue, METRIC_TILE_BARE_VALUE_LADDER)` → `'text-[2rem] truncate tabular-nums'` (the old face): the Command Center budget pin red, 2 passed. </details> ## Acceptance notes - QA's three readings are gone on a fresh showcase boot from this branch's source (shots below): no title-equal subtitle on Delivery Operations / Chart Gallery, and Command Center's budget whole. The tall-card reading is left to the metadata (see The height). - Delivery Operations' `$1,090,000.00` (dataset tile, 238 px) was never truncated: it fits at 24 px before and after. - **Finding, per-widget duplicate query (not fixed, item 1 is objectstack-ai#32200's):** on the dev boot every dataset widget posts its `/analytics/dataset/query` twice (Delivery Operations 9 dataset widgets → 18 posts; Chart Gallery and System Overview the same pattern, identical bodies). The Console mounts under `<StrictMode>` (`ui/apps/console/src/main.tsx`), which runs each mount effect twice in development, so this is most likely the dev double-effect, not a production double fetch; a production build was not measured here. No batching layer, queue or cache was added. - **System Overview skeletons (read only):** on a full page load of `/apps/setup/dashboard/system_overview` (dev Vite, warm server) the skeletons cleared at 7.1 s. The wait is the app shell, not this widget: the dev module graph took ~5.1 s before the first app request, then shell reads (`auth/me/permissions`, `meta/app`, `meta/app/setup/bundle`, `sys_user_preference`) to ~5.6 s, `meta/dashboard` + `meta/view` to ~5.65 s, `/packages` to ~6.23 s; the 14 dataset queries (7 widgets ×2) started at 6.09 s and all answered by 6.36 s (150–270 ms each); the remaining ~0.7 s is chart chunk load and paint. Nothing inside the metric widget holds the skeleton, so no fix here. ## Verification <details><summary>Browser: showcase dev boot from this branch (main 8523ef9 + this diff), Console Vite over branch source, 1440×900, shots in the project folder ui-orders/32165-shots/</summary> - The `after-*.png` shots were taken at round 1 and also show the since-reverted centring of the Chart Gallery and Delivery Operations KPI cards; the subtitle and Command Center readings are unchanged by the revert. - `before-*.png` taken with the four touched files restored to `main` (served-code marker count 0), `after-*.png` with the branch (marker count 3), Vite restarted with `--force` per leg. - Chart Gallery: before "Avg Progress / 47.0 / Avg Progress", "Total Spent / $616,000.00 / Total Spent"; after "Avg Progress / 47.0", "Total Spent / $616,000.00", "Total Tasks / 10 / Tasks" (distinct caption kept). - Delivery Operations: "Total Budget / $1,090,000.00 / Total Budget" → "Total Budget / $1,090,000.00"; "Active Projects / 2 / Projects" kept. - Command Center: budget at 32 px "$1,090,0…" → 20 px "$1,090,000.00", `scrollWidth == clientWidth` 166, title attribute the full figure; the five short values stay 32 px; every hero tile 52 px tall with a 32 px value line. </details> <details><summary>Gates</summary> At head `2a39b46a` (round 2; merge base `8523ef9a`): - `pnpm --dir ui exec vitest run packages/plugin-dashboard/` → 203 files, 1974 passed, 6 skipped; `pnpm --filter @object-ui/plugin-dashboard type-check` exit 0. - `pnpm --dir ui exec playwright test e2e/dashboard-metric-tile-height.spec.ts --trace off --project=chromium` → 2 passed (the objectui#12704 pin that went red at round 1; firefox/webkit are not installed in the dev container and fail at launch). - `node scripts/pm/dispatch-gates.mjs --commands`: 36 derived (the same set as round 1), 36 run, all exit 0; `--ran`: 36 accounted, 0 NOT-MEASURED, exit 0. Extra: `pnpm check:changeset-fixed` 0. - Round 1, unchanged since (no file they read moved): ADR-0060 ratchet 34 passed; `pnpm --dir ui run check:spec-symbols` 0; plugin-dashboard + console build 0, then `check:eager-closure` 0 (2214.0 KB of 2431.6 KB); eslint 0 errors on the touched files; `check:new-line-citations` 0 new. </details> _Generated by [Claude Code](https://claude.ai/code/session_01WGufzhXhSR1mxHQLxKoszd)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzhXhSR1mxHQLxKoszd <!-- signed: domain:ui#2 · os-support-ai · session_01WGufzhXhSR1mxHQLxKoszd --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Fixes #12699
Part of objectstack-ai/cloud#1653
What
OrgScopingEntitlement(packages/spec/src/security/tenancy-posture.ts) grows two per-deployment wall-shaping keys, both declared by the mountedorg-scopingservice (per-deployment, never authorable app metadata), both consumed by plugin-security when arming the Layer 0 organization wall, both fail closed — an absent (or junk) declaration leaves behaviour byte-identical to today:platformGlobalObjects— objects THIS deployment declares platform-global. Layer 0 does not wall them here, exactly as if the object had declaredtenancy: { enabled: false }itself — but only on this deployment. It composes with, never replaces, the per-object authoring channel, which stays wrong for these objects because they DO wall on tenant runtimes (same object, different deployments, different wall).suppressUnboundedOrgAdminGrant— arming a walled posture must not auto-grantorganization_admin's unboundedviewAllRecords/modifyAllRecordssuperbits: the membership-driven auto-grant hands outorganization_admin_no_bypassinstead (the epic's measured regression:sys_secret403-to-200, 17 objects regaining cross-tenant writes, cloud#1257's write gate voided by the posture flip).Dead seams stay dead, per the ruling: host self-declaration of the boundary is not revived (the org-create gate is untouched — only a mounted enterprise runtime can declare anything here), and nothing rides through
objectExtensions(the merge silently dropstenancy— objectstack#12680).Consumer contract — for cloud Phase 2 (objectstack-ai/cloud#1664)
Key names and TypeScript shapes (verbatim)
platformGlobalObjectsentries are exact object machine names (regex^[a-z_][a-z0-9_]*$) — no wildcards, no globs, no empty strings. One junk entry voids the whole key (refused loudly, never partially honoured), and refusal resolves to "absent" = everything walls.@objectstack/spec/security:OrgScopingEntitlementSchema(non-strict object — a live service instance's extra machinery never disqualifies its declaration) andPlatformGlobalObjectsSchema(+ type aliasPlatformGlobalObjects). Consumers validate per key: junk in one key never voids the other's valid declaration.Declaration-site pattern
The keys are readonly properties on the object registered as the
org-scopingservice — the same object that already declaressupportedPostures. The in-repo model isSimulatedOrgScopingPlugininpackages/verify/src/harness.ts; the cloud runtime declares the same way:Read-timing semantics
start().getService('org-scoping')at each consuming decision — mirroring the seam's one pre-existing consumer, plugin-auth'sprobeEntitledPostures(auth-plugin.ts:581, live per call because the provider registers after the reader's init). Validation is memoized per service instance (WeakMap); a junk key warns once per boot, naming the key and the declared value, and fails closed.getObjectSecurityMeta), which is cached per object and invalidated on metadata change or restart. Effective contract for the declarer: declare at registration and treat the declaration as immutable for the kernel's life; a re-registered service instance re-validates. Live resolution is ordering-robust by construction: a deployment where the wall is ARMED hadorg-scopingregistered beforestart()captured the posture, so the declaration is present from the first read; where it registered too late, posture resolvessingleand Layer 0 is inert, so the exemption decides nothing.sys_memberreconcile and at thekernel:readybackfill ("org-admin grant backfill complete" in boot logs). Toggling it converges standing grants in BOTH directions via the existing superseded-variant reconcile — proven in tests, so the fail-closed default protects any deployment that RELIES on today's auto-grant.[security/#12699].What the exemption reaches — and deliberately does not
Reaches, through the single meta fold (all proven or structurally derived in this PR):
computeTenantLayer0Filter'stenancyDisabledinput);computeWriteTenantCheckFilterIS the samelayer0, so read and write cannot disagree;organization_idpolicy drop (thesys_packagecross-org-catalog precedent — without it every read of an exempted catalog would return zero rows);posturePermitsCrossTenantand the superuser write-check bypass — an exempted object carries full platform-global posture semantics on this deployment.Deliberately NOT reached — boundaries Phase 2 must know:
buildDriverOptions(objectqlengine.ts) still threadstenantIdfor exempted objects (it reads schema-declared tenancy only), andSqlDriver's per-table scope is fail-open on NULL org (organization_idequals the active org OR IS NULL) — so NULL-org platform rows stay readable and behaviour is byte-identical to today. Session-context inserts still stamp the active org at the driver, also today's behaviour. Widening this would change behaviour beyond the ruling; if Phase 2 measures a need, that is a new card.system-write-organization.ts) keys on schema-declared tenancy, and thesys_/cloud_/ai_namespaces are excluded by construction — declare exempted platform tables in those namespaces (every control-plane table already is).postureStampsOrganizationhas no consumer in this repo; the D5 stamper is the enterprise runtime — the declarer itself, which holds the exemption list first-hand.Dispatch mechanism assumptions — verified
supportedPosturesconsumer found. The dispatch premise "no consumer inside plugin-security" is confirmed — and the seam is NOT dormant: plugin-auth consumes it (auth-plugin.ts:581feedingcreateTenancyService.probeEntitledPostures, evaluated live insideisolationActive()). SecurityPlugin reads the entitlement viagetService('org-scoping')directly, mirroring that pattern rather than wideningTenancyService(which stays posture-only — routing deployment declarations through it would grow a second interface for zero consumer benefit).security-plugin.ts~6383getObjectSecurityMetaand ~6677loadObjectFieldNames) merge into one local incomputeLayeredRlsFilter; the write path derives from the samelayer0. The fold lands ingetObjectSecurityMetaalone and every consumer follows. Genuinely separate wall-adjacent consumers (driver native scope, system-write refusal, D5 stamper) are enumerated above with the argument for leaving each untouched — none produces the "exempt from read wall but still refused/required to stamp" inconsistency: the only refusal seam (ADR-0123 D2) derives from the exempted layer0, and driver stamping never refuses.orgAdminSetNameForPosture(auto-org-admin-grant.ts), wired from SecurityPlugin'ssys_membermiddleware and thekernel:readybackfill (the "org-admin grant backfill" boot log). Suppression flips BOTH the granted and the superseded variant, so the existing convergence machinery revokes the stale one on the next reconcile — and the fail-closed default (absent = today's grant) is pinned by the untouched ADR-0105 D4 test block plus an explicitsuppressUnboundedOrgAdminGrant: falsecase.Tests
New/extended, all green at
b49ebc290:packages/plugins/plugin-security/src/deployment-platform-global-exemption.test.ts(12 cases): exempted object not walled (isolated+group, read AND the D2 write derivation) / non-exempted sibling still walled / absent declaration byte-identical (regression pin) / junk shapes refused loudly (bare string, wildcard entry poisoning the whole key, junk suppress flag not voiding the valid key, warn-once-per-boot) /tenancy.enabled:falsecomposition /singleposture inertness / arming-log surface.packages/plugins/plugin-security/src/auto-org-admin-grant.test.ts(+6 cases): suppression on (isolated+group) / explicit off byte-identical / convergence both directions / backfill threading incl. the orphan sweep.packages/spec/src/security/tenancy-posture.test.ts(19 cases): schema accepts valid declarations and live-service shapes, refuses junk; schema/interface parity witness.Suites: plugin-security full suite 87 files / 1578 tests passed; spec security domain 7 files / 197 tests passed;
pnpm --filter @objectstack/spec typecheckandpnpm --filter @objectstack/plugin-security typecheckgreen. plugin-security's test layer sits outside every tsc program (pre-existing:tsconfig.jsonexcludes test files and the package has no test-typecheck sibling), so the new test files' types are NOT MEASURED by tsc — same posture as every existing test there;check:type-check-coverageandcheck:type-check-debt --re-measureboth green.Ablation, one leg per key (vitest runs on
src/via relative imports — no dist resolution in the loop; mutation and restore both proven on disk by anchorgrep -c, restore additionally by an emptygit diff HEAD):platformGlobalObjects.has(object)anchor 1 to 0 on disk) — 4 of 12 exemption cases went red (both read postures, the write-choke case, the valid-exemption-standing case); restored (anchor back to 1, clean diff), 12/12 green.postureEnforcesWall(posture) && !suppressUnboundedanchor 1 to 0 on disk) — exactly the 4 suppression cases went red; restored (anchor 1, clean diff), 32/32 green.Gates
Derived from the real changeset via
node scripts/pm/dispatch-gates.mjs(answer taken from this worktree at1e61a0de5, re-checked at headb49ebc290). All derived families ran locally and green, including:check:generated("All 14 generated artifacts are up to date"),check:i18n("OK (9 package(s)…)" after building the CLI),check:type-check-debt --re-measure("none above its recorded number"),check:engine-double-contract,check:where-matcher,check:cross-package-test-inputs,check:test-source-alias,check-changeset-no-major,check:nul-bytes, and the docs family (the reference-doc regeneration in this diff is generator output).scripts/pm/check-half-states.mjsran authenticated and is report-only. The twodocs-drift-check.ymlscripts are PR-context CI jobs and run on this PR. Changeset-family gates re-ran on the final headb49ebc290.Verification mode declaration: this ran on a macOS host where
scripts/pm/os-verify-lock.shhas no usable flock — every build/test above went through the entry point in its DECLARED UNLOCKED MODE (its own VERDICT lines recordUNLOCKED (declared)); nothing was serialized against sibling agents.Generated-artifact churn in this diff (
api-surface/security.json,export-origins/security.json,authorable-surface/security.json,json-schema.manifest/security.json,content/docs/references/index.mdx,content/docs/references/security/misc.mdx) is generator output for the three new spec exports, proven stale-then-regenerated bycheck:generated --fix(never the whole set).Session: https://claude.ai/code/session_71836b57-5db6-459d-ae4d-c6d9d7dd2cc6
Generated by Claude Code