Repository navigation
fix(setup)!: serve the Audit Log entry to a view_all_audit_log holder who lacks manage_platform_settings - #33349
Conversation
…who lacks manage_platform_settings group_diagnostics no longer carries a group gate; its entries carry their own: Sessions and Notification Events keep manage_platform_settings, and Audit Log is gated on view_all_audit_log, the ledger's own read capability. Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 21 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 14 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 f7613660d16840598b473c66f9605f83f6ea4552 && git checkout f7613660d16840598b473c66f9605f83f6ea4552
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e0ce1b523c9cdb625211fc866593f57aee9223ee d0bbf71f7055f889e6343eec78984df456227c6f && git checkout -B drift-repro e0ce1b523c9cdb625211fc866593f57aee9223ee && git merge --no-ff d0bbf71f7055f889e6343eec78984df456227c6f
node scripts/docs-audit/affected-docs.mjs --json e0ce1b523c9cdb625211fc866593f57aee9223ee
|
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 136a7b6 · 2026-11-14T17:16:40Z review#3. |
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentGating an entry on the capability that governs its data, rather than on its container's admin power, is the right model for separation of duties. It matches Implemented-by: VERDICT: FAIL M1 is text only (changeset arm, banner, marker, PR body). Same reviewer takes the delta. |
…tup audit log entry Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM Co-Authored-By: Claude <noreply@anthropic.com>
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 63d6af9 · 2026-11-14T17:25:50Z review#3 (delta). |
Contract reviewServed-tier: Delta over my FAIL at ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentUnchanged: gating the entry on the capability that governs its data is the right separation-of-duties model, and the one custom-set narrowing is now declared with its remedy. Implemented-by: VERDICT: PASS |
|
domain:server#5 · os-elon-musk · session_016WV4cz2MxDkQYCC4U8indM Dogfood battery (owed by the
Also re-run on this head: |
|
domain:server#5 · os-elon-musk · session_016WV4cz2MxDkQYCC4U8indM ACCEPT · area A2 · Part of #33224 (navigation half; no Fixes) · head d0bbf71 · 2026-11-14T19:10Z
|
…n entry they can open, not on Packaged Actions (objectstack-ai#33410) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DXuamRUC67fx2TTYrFfyuSH)_ Fixes objectstack-ai#33224 — the Setup landing half (the navigation half is objectstack-ai#33349). Route A, as the seat ruled. Clause-②: no — the served `GET /meta/app/setup` tree is unchanged for every caller except that `nav_packaged_actions` now carries `visible: current_user.can('sys_metadata_activation', 'read')`, which the console asks with the member's `/auth/me/permissions` map. A member who may read the ledger is shown the entry and lands as before (the platform administrator still lands on System Overview). A member who may not read it stops being shown an entry whose page rendered only `activation ledger HTTP 403`; nothing they could use is withdrawn. Metadata-protocol: none ## Maintainer quick read - What changes: Setup's Packaged Actions entry is shown only to a member who may read the activation ledger its page reads. Everyone else lands on the first Setup entry they can open. - Why: Packaged Actions is the first entry Setup serves, and the console's object-read prune judges `type: 'object'` entries only. So every member landed on it, including a separation-of-duties officer (an auditor holding `view_all_audit_log`) whose ledger read answers 403, and their Setup opened on `activation ledger HTTP 403`. - Risk and rollback: low. Admins (who read the ledger) see the same menu and landing as before. The entry still carries no `requiredPermissions` and no `requiresService`; the activation write doors keep their server-side gates. Rollback is a revert. - Read first: `packages/platform-objects/src/apps/setup-nav.contributions.ts` (the `visible` and its comment). - Two-minute check: `pnpm --filter @objectstack/cli exec vitest run test/setup-landing-audience.pin.test.ts`; expect 4 green cases. - Needed from you: nothing. ## What changes - `packages/platform-objects/src/apps/setup-nav.contributions.ts` — `nav_packaged_actions` gains `visible: "current_user.can('sys_metadata_activation', 'read')"`. The console asks a nav entry's `visible` in both its sidebar and its landing walk (`AppRootLanding` → `findFirstRoute` over the tree `useNavMemberGates` gates, `ui/packages/app-shell/src/console/AppContent.tsx`), with `can` bound to `/auth/me/permissions` (pinned in ui/ by `UnifiedSidebar.navCanPermissions-12700.test.tsx`). No Setup entry used `can` before; HotCRM and `examples/app-crm` already do. - `packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts` — the pin header no longer calls the entry deliberately ungated. It says the earlier "no audience" was a developer choice (objectstack-ai#12491), not a ruling, and why the entry now carries the ledger-read audience. A new case pins the predicate exactly. The "no `requiresService`" and "no `requiredPermissions`" cases stay, with their reasons. - `packages/platform-objects/src/system/sys-metadata-activation.object.test.ts` — the "no shipped app or nav names the ledger" pin now allows exactly this one predicate (a permission question no row changes) and still refuses any other mention. - Changeset: `@objectstack/platform-objects` patch. ## Tests - New `packages/cli/test/setup-landing-audience.pin.test.ts` (unit tier): composes `SETUP_APP`, `SETUP_NAV_CONTRIBUTIONS` and `AuditPlugin`'s contribution through the real `SchemaRegistry`, reads `GET /api/v1/meta/apps/setup` through the real `RestServer` route, and walks the served tree the way the console lands (groups walked, `url` skipped, first `object`/`page`/`dashboard`/`report`/`component` wins; `visible` asked with the real CEL engine and the member's object map; an `object` entry pruned without read on its object): - Packaged Actions is served with the predicate, and is still the first landing-type entry for the officer (so the predicate, not the order, moves the landing); - an officer holding `view_all_audit_log` who may read `sys_audit_log` and `sys_user` but not the ledger lands on `nav_users` (People & Org › Users); - the same served tree, with ledger read, lands on `nav_packaged_actions`; - the platform administrator still lands on `nav_system_overview` and is still shown Packaged Actions. ## Verification - `pnpm --filter @objectstack/platform-objects exec vitest run`: 120 of 122 files green; the 2 failing cases are `object-collapsed-sections-echo-decisions.test.ts`, which fails identically on `origin/main` in this worktree (stale local build), so not this change. - `packages/cli`: `setup-landing-audience`, `console-page-nav-entries`, `setup-integrations-order`, `i18n-contributed-nav-coverage`, `translation-contributed-nav-validate-door`: 5 files / 22 tests passed (`platform-objects` rebuilt first; the cli suite reads its `dist/`). - Pre-push hooks passed. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` is not touched. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Part of #33224 — this PR lands the navigation half (the Audit Log entry reaches the auditor). The Setup landing half (Packaged Actions answering
activation ledger HTTP 403) stays open on the card; the seat ruled route A (below), and it follows in its own PR.Clause-②: yes (narrowing) —
GET /meta/app/setupnow servesgroup_diagnosticswith the Audit Log entry (nav_audit_logs) to a member who holdsview_all_audit_logwithoutmanage_platform_settings; before, the whole group was withheld from them. Every shipped permission set is served what it was before:admin_full_accessholds both capabilities and still sees Sessions, Notification Events and Audit Log;organization_adminand the member sets hold neither and still see no Diagnostics group. One custom-set audience narrows: a set grantingmanage_platform_settingswithoutview_all_audit_logis no longer served the Audit Log entry. A gate is all-of, so the entry cannot be gated on either capability.Metadata-protocol: none
BREAKING for a custom permission set that grants
manage_platform_settingswithoutview_all_audit_log. Its holders were served the Setup › Diagnostics › Audit Log entry and no longer are. The Audit Log page itself is unchanged: it still opens by URL and still shows them the organization-attributed ledger rows it showed before. What to do: grantview_all_audit_logto that set if its holders should keep the menu entry, or open the page by URL. A third-party package that contributes an entry intogroup_diagnosticswithout its ownrequiredPermissionsis now shown to every member who can open Setup, where before onlymanage_platform_settingsholders saw it: declarerequiredPermissionson the entry (see below).Maintainer quick read
manage_platform_settingsfor the whole group; each entry carries its own gate. Sessions and Notification Events still requiremanage_platform_settings; Audit Log now requires its own read capability,view_all_audit_log.view_all_audit_logwithout platform-settings power (the auditor of a separation-of-duties setup) never saw the Audit Log entry in Setup and had to type the URL.manage_platform_settingswithoutview_all_audit_log: it no longer sees the Audit Log entry (the page still opens by URL). Rollback is a revert of this PR.packages/platform-objects/src/apps/setup.app.ts(the removed group gate),packages/plugins/plugin-audit/src/audit-plugin.ts(the entry'srequiredPermissions),packages/platform-objects/src/apps/setup-nav.contributions.ts(Sessions and Notification Events take the former group gate).pnpm --filter @objectstack/cli exec vitest run --project unit test/setup-diagnostics-audience.pin.test.ts; expect 3 green cases: aview_all_audit_log-only holder sees only Audit Log under Diagnostics; a caller without it sees Audit Log nowhere in Setup; an admin still sees all three entries.What changes
packages/platform-objects/src/apps/setup.app.ts—group_diagnosticsno longer carriesrequiredPermissions: ['manage_platform_settings']. A group's gate prunes its whole subtree before any child is judged (filterAppForUserWithReasonin@objectstack/rest; the console's sidebar guard does the same), so no entry inside it could reach a member without that power, whatever the entry's own gate said. The slot now gates nothing, asgroup_configurationalready does, and a comment says that a contributor into it gates its own entry.packages/platform-objects/src/apps/setup-nav.contributions.ts— Sessions (nav_sessions) and Notification Events (nav_notifications) carry themanage_platform_settingsgate the group used to, so they reach exactly the members they reached before.packages/plugins/plugin-audit/src/audit-plugin.ts— the Audit Log entry (nav_audit_logs) is gated onview_all_audit_log(LEDGER_AUDIT_CAPABILITY), the ledger's own read capability. Platform administrators hold it by default (ADMIN_FULL_ACCESS_CAPABILITIES).@objectstack/platform-objectsand@objectstack/plugin-audit, patch, with the(narrowing)arm, the BREAKING paragraph above andadr-0087: not-required (no-migration-prescription).Who is served what, by shipped permission set:
admin_full_accessholds both capabilities, so it still sees all three entries;organization_adminand the member sets hold neither, so they still see no Diagnostics group. A member grantedview_all_audit_logalone now sees Diagnostics with Audit Log only. A custom set grantingmanage_platform_settingswithoutview_all_audit_logno longer sees Audit Log (it still sees Sessions and Notification Events, and the page still opens by URL).Tests
packages/cli/test/setup-diagnostics-audience.pin.test.ts(unit tier): composesSETUP_APP,SETUP_NAV_CONTRIBUTIONSandAuditPlugin's real contribution through the realSchemaRegistry, and readsGET /api/v1/meta/apps/setupthrough the realRestServerroute per caller:view_all_audit_logalone: Diagnostics is served with exactlynav_audit_logs;manage_platform_settingsalone: Diagnostics holds Sessions and Notification Events, andnav_audit_logsis served nowhere in Setup;setup.accessalone: no Diagnostics group and nonav_audit_logs(with a control that the app itself is served);ADMIN_FULL_ACCESS_CAPABILITIES): all three entries.It lives in
packages/cli/test/becausecliis the one package that depends on the shell, the plugin, the registry and the per-request filter;@objectstack/plugin-auditresolves to source there through the existing alias.packages/plugins/plugin-audit/src/audit-nav-contribution.test.ts: the entry-shape case now also assertsrequiredPermissionsequals[LEDGER_AUDIT_CAPABILITY], and that the constant isview_all_audit_log.Acceptance notes
The landing half, not done here. For all three officer roles the Setup landing is Packaged Actions, which shows
activation ledger HTTP 403. Measured cause: the console lands on the first entry the member is shown (resolveLandingRoute→firstRouteAcrossinui/packages/app-shell/src/console/AppContent.tsx, overnavEntriesShownToMemberinui/packages/app-shell/src/hooks/useNavMemberGates.ts). The first served Setup group for a member withoutmanage_platform_settingsisgroup_apps, whose one entrynav_packaged_actions(type: 'component') carries no gate (packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts). The console's object-read prune judgestype: 'object'entries only, so a component entry whose page reads/data/sys_metadata_activationis landed on even when that read answers 403. The seat ruled route A: givenav_packaged_actionsan audience (visible: "current_user.can('sys_metadata_activation', 'read')"), reword the pin's reason, and pin where an officer lands instead. It follows in its own PR on #33224.Contributors into
group_diagnostics. The slot no longer gates what is put in it. Every contributor in this tree is gated now (the three entries above), and no contributor exists in the HotCRM checkout. A third-party package that relied on the slot's gate now shows its entry to everysetup.accessholder; the BREAKING paragraph says so.Verification
Code head:
136a7b67;63d6af9dchanges only the changeset text (the(narrowing)arm, BREAKING paragraph and ADR-0087 marker;check-adr-0087-registrationreads it as[BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription)). Build closure:turbo run build --filter=@objectstack/rest... --filter=@objectstack/plugin-audit... --filter=@objectstack/platform-objects...(31 tasks, exit 0). The full dogfood battery owed by the(narrowing)arm runs on the final head and is reported in a comment.New pin and ablations
test/setup-diagnostics-audience.pin.test.ts: 3/3 passed.setup.app.ts,group_diagnosticsgivenrequiredPermissions: ['manage_platform_settings'];platform-objectsresolves todist/in this suite, so it was rebuilt andablation-dist-preflightfound the marker in 4 built files): the auditor case went red (1 failed, 2 passed). Restored (blob equal to HEAD,git diff HEADempty), rebuilt, preflight--absentclean: 3/3 passed. The first try of this ablation was a no-op (its replacement contained its own anchor, whichablation-replacerefused and restored); its green run is void and was not counted.audit-plugin.ts, aliased to source in this suite): the "withoutview_all_audit_log" case went red (1 failed, 2 passed). Restored (blob equal to HEAD,git status --porcelainempty): 3/3 passed.Package suites
At
136a7b67, each part's exit captured separately:pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2: exit 0, Test Files 93 passed (93), Tests 1495 passed (1495).pnpm --filter @objectstack/platform-objects exec vitest run --maxWorkers=2: exit 0, Test Files 122 passed (122), Tests 1957 passed (1957).pnpm --filter @objectstack/cli exec vitest run --project unit test/setup-diagnostics-audience.pin.test.ts: 3 passed (3). Same run:console-page-nav-entries.pin.test.tsandvitest-tiers-partition.test.tspassed;setup-integrations-order.pin.test.tscould not load (@objectstack/cloud-connectionhas no build in this worktree), NOT MEASURED locally.pnpm --filter @objectstack/plugin-audit typecheck: exit 0.pnpm --filter @objectstack/platform-objects typecheck: exit 0.pnpm --filter @objectstack/cli typecheck: NOT MEASURED, reason: the cli build closure is not built here (260 TS2307/TS2882 errors, all unresolved imports of unbuilt workspace packages such as@objectstack/runtime; none in the new file). CI'sTypeScript Type Checkcovers it.Gates
node scripts/pm/dispatch-gates.mjs --commandsat136a7b67: 72 derived. Reconciled with--ran:72 derived famil(ies) accounted for — 67 run, 5 NOT-MEASURED.check:changeset-no-major,check:adr-0087-registration,check:empty-changeset,check:test-source-alias,check:cross-package-test-inputs,check:registry-log-declared,check:tier-file-adoption,check:type-check-coverage,check:nul-bytes,check:doc-authoring,check:issue-citations.check:i18nandcheck:dual-build-cjs-loads(both need the whole workspace built);check-plugin-teardown-shape.mjs --self-test(its fixture commit is outside this shallow clone).check:query-options-erasure,check:type-check-debt.CI runs every one of these.
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/specis not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM