Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
36edb6a
fix(objectql,metadata-protocol,console): a view column on a field a d…
claude Nov 17, 2026
bf6cbc8
test(objectql,metadata-protocol,console): pin the withheld-field mark…
claude Nov 17, 2026
f4ea4f9
fix(objectql): register getWithheldExtensionFields as a read in the r…
claude Nov 17, 2026
b76b858
chore(i18n): regenerate zh-Hant from zh-Hans for list.withheldFieldsL…
claude Nov 17, 2026
d639b90
docs(changeset): the Clause-② line counts one locale key (#34901)
claude Nov 17, 2026
c45d97c
test(spec): the connector redactor's read-decoration pin carries _wit…
claude Nov 17, 2026
da04396
Merge origin/main into claude/issue-34901-disabled-package-view-column
os-support-ai Nov 17, 2026
9733be7
fix(metadata-protocol): a served view's lint judges a withheld field …
claude Nov 17, 2026
2a4d8e5
chore(changeset): name the served view diagnostics fold
claude Nov 17, 2026
323b0cc
feat(spec): an optional security-service member names the withheld fi…
claude Nov 18, 2026
343c61d
feat(plugin-security): judge a disabled package's withheld fields aga…
claude Nov 18, 2026
5ed144f
fix(metadata-core): the object-schema projection drops withheld entri…
claude Nov 18, 2026
865ff17
test(rest, runtime): a disabled package's withheld field is served pe…
claude Nov 18, 2026
01192b4
Merge origin/main into claude/issue-34901-disabled-package-view-column
claude Nov 18, 2026
7407301
test: the withheld-field doubles route through the engine contract he…
claude Nov 18, 2026
24d71a8
docs(permissions): the system-context census names the withheld-field…
claude Nov 18, 2026
610ee49
test(plugin-security): the delegator census counts the withheld-field…
claude Nov 18, 2026
69afbe1
Merge origin/main into claude/issue-34901-disabled-package-view-column
claude Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .changeset/34901-disabled-package-view-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@objectstack/objectql': patch
'@objectstack/metadata-protocol': patch
'@objectstack/spec': patch
'@objectstack/metadata-core': patch
'@objectstack/plugin-security': patch
'@object-ui/core': patch
'@object-ui/plugin-list': patch
'@object-ui/plugin-grid': patch
'@object-ui/i18n': patch
---

fix(objectql, metadata-protocol, console): a list view column on a field a disabled package adds no longer fails the whole list

Clause-②: yes (widening: the view save door accepts withheld names; one spec read-decoration member; one locale key; one optional security-service member, add-only)
Metadata-protocol: none

A package can add fields to another package's object. While that package is disabled, the platform leaves those fields out of the served object, and the data door refuses every request that names one (`400 INVALID_FIELD`, or `400 INVALID_SORT` for a sort). The owner's views still named the field, so a view with such a column, sort, filter, grouping level or searchable field failed for everyone. Saving the view (a rename, a pin, a Studio edit) was refused too (`422`, `list-view-field-unknown` / `sort-field-unknown`).

- **The served object read names what is withheld.** `GET /api/v1/meta/object/:name` and the object list read carry `_withheldFields: { [field]: { packageId } }` when a disabled package withholds a field from the object. It is a read decoration (`METADATA_READ_DECORATIONS`), so the save door strips it, and the execution face and the layered editor read do not carry it. The registry gains `getWithheldExtensionFields(name)`.
- **A caller who may not read a withheld field is not told it exists.** The object-schema projection (ADR-0106) keeps a `_withheldFields` entry only for a caller the security service admits. `ISecurityService` gains an optional member, `getMetadataReadableWithheldFields(object, context)`, which answers the withheld names the caller may read; `@objectstack/plugin-security` implements it from each field's stored definition: the permission set's field entry, the field's own `requiredPermissions`, the fallback set for a caller with no set, and the on-behalf-of delegator. A security service without the member, an `undefined` answer or a throw drops every entry. Each dropped entry moves the caller's ETag, so two callers who are told different things never share a `304`. A caller exempt from the projection (a platform admin, a system context) is served every entry, as before.
- **The view save door judges a view against the stored object.** A `view` write is judged against the object with every disabled package's extension folded in (the new fold option `includeDisabledExtensions`). A withheld field is a real stored field, so the view saves and keeps its column and sort. A misspelled field is still refused. Other writes are still judged against the served object, so a page or flow that names a withheld field is still refused while the package is off. A served view's `_diagnostics` is judged against the same stored object, so it no longer warns `list-view-field-unknown` or `form-field-unknown` on a withheld name the save door accepts; a misspelled field still warns.
- **The console leaves withheld names out.** The list view and the grid leave a withheld field out of `$select`, `$filter`, `$orderby`, `$searchFields` and `groupBy`, and do not draw its column. A line above the rows names it (`list.withheldFieldsLeftOut`). Nothing is written to the view or to the user's list preferences, and a sort the user saves keeps the withheld entry. Once the package is enabled, the column, the sort and the grouping come back without any write.
3 changes: 2 additions & 1 deletion content/docs/permissions/system-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bugs — it is the protection or the side effect that silently does not happen.
| 1b | **App-authored automation's system context is REFUSED governed writes to the identity-assignment objects** — a flow run's, an app-authored hook's (`runAs: 'system'`, a system context it inherits, its `sudo()`) and an action body's; checked ahead of the middleware's short-circuit, beside the append-only refusal (`assertAppAutomationAppendOnlyWriteAllowed`) | plugin-security | Get: nothing — an insert, update, delete, transfer, restore or purge of `sys_user_position`, `sys_user_permission_set`, `sys_invitation` or `sys_member` from a context carrying `isSystem` and either a `flowRunId` (a `runAs: 'system'` flow's data nodes) or the app-automation elevation mark (`@objectstack/core`; set only by a hook's `runAs: 'system'` derivation, by the action body's execution-context builder and `ObjectRepository.execute`, and on the api of a hook bound through the hook binder, whose inherited system context and `sudo()` it marks), at any depth of their writes, is refused `PERMISSION_DENIED` before the short-circuit skips the ADR-0090 D12 gate and the identity write guard. Lose: nothing a platform writer held — a system context with neither (the seeders, better-auth and its reconciliation, invitation placement, platform code's `sudo()`, which never sets the mark, and a hook registered in code) passes on to the short-circuit unchanged, reads are not judged, and a `runAs: 'user'` flow or hook carries no `isSystem`, so the D12 gate judges it as the user it acts for | `elevationSource`, `appAuthoredHookApi` |
| 2 | **`owner_id` is not auto-stamped on INSERT** (the step 3.5 anchor guard is inside the block row 1 skips) — except an action body's insert | plugin-security | Lose: the row lands `owner_id = NULL`, so the default `owner_only_writes` policy hides it **from its own creator**. Get: nothing — this is a gap, not a capability. Except an action body's: an insert from a context carrying `isSystem` and the `'action'` app-automation elevation mark, with no `flowRunId`, has every EMPTY `owner_id` stamped with the envelope's own `userId` ahead of the short-circuit, by the same stamp step 3.5 applies (nothing for the guest; an owner the body sets is kept; an `owner_id` supplied empty beside a supplied queue parks the row). Like a direct create, such an insert is the invoker's own record, so assignment rules (ADR-0142 D5), which route only a row whose owner and queue are both still empty, route neither; a body has no spelling today that asks a rule to route its row. The mark is set on every handler an action door dispatches (a host code action handler included) and by `ObjectRepository.execute`. A flow run, a hook's `runAs: 'system'`, the seeders and every other system context still land the owner they write, or none, and an unowned, queue-less one is still routed | the step 3.5 guard block and the short-circuit that skips it are both inside `registerAuthzMiddleware`; the action-body exception is `isActionBodyElevation` |
| 3 | Row-level read filter resolves to "no filter" | plugin-security | Get: unscoped reads. Lose: row-level scoping entirely | `getReadFilter` |
| 4 | Field-level security returns **all** fields | plugin-security | Get: every column readable (`getReadableFields`) and writable (`getWritableFields`). Lose: field masking | `resolveProjectionFieldMask` |
| 4 | Field-level security returns **all** fields | plugin-security | Get: every column readable (`getReadableFields`) and writable (`getWritableFields`), and every field a disabled package withholds named to it (`getMetadataReadableWithheldFields`, so the served object's `_withheldFields` keeps every entry). Lose: field masking | `resolveProjectionFieldMask`, `computeMetadataReadableWithheldFields` |
| 5 | Export permission granted unconditionally | plugin-security | Get: `canExport` is `true` | `canExport` |
| 6 | Object-level read admission granted unconditionally | plugin-security | Get: `canReadObject` is `true`. This is the OBJECT-level half of a read — "may this caller read this object at all" — which the doors that bypass this middleware ask before they compile a statement of their own; `getReadFilter` is its row-level half, and the two are not interchangeable | `canReadObject` |
| 6b | WRITE admission granted unconditionally | plugin-security | Get: `canWriteObject` is `true`. The WRITE twin of the object-level read admission above, asked by the write PREVIEW (`ObjectQL.validate()`), which runs no middleware for its target object and so has no gate of its own. It exists because a validation rule that reads one hop through a reference field is evaluated against a related row fetched under system authority, and that elevation is bounded to the arms the question RUNS — named, ⛔ never a category of the write decision, and ⛔ not a promise the write would succeed. The arms: the ADR-0103 engine-owned affordance gate and the ADR-0090 D12 delegated-admin gate (both ahead of every resolution), the fail-closed postures (#3545's unresolvable posture, the D10 dangling delegator and, on a walled posture, the D10 delegator who is not a member of the organization the request runs in), the ADR-0066 D3 capability arm, the CRUD grant, the ADR-0090 D10 delegator arm that a bare CRUD-grant check misses, the field-level-security write gate over the caller's payload when one is supplied, and the ADR-0123 D2 no-active-organization wall | `canWriteObject` |
Expand Down Expand Up @@ -617,6 +617,7 @@ and CI refuses one that differs from what the tree produces.
| `packages/plugins/plugin-security/src/security-plugin-object-admission.ts#canWriteObject` | 1 | 6b |
| `packages/plugins/plugin-security/src/security-plugin-read-filter.ts#getReadFilter` | 1 | 3 |
| `packages/plugins/plugin-security/src/security-plugin-security-service.ts#registerSecurityService` | 3 | 7 |
| `packages/plugins/plugin-security/src/security-plugin-withheld-field-readers.ts#computeMetadataReadableWithheldFields` | 1 | 4 |
| `packages/plugins/plugin-security/src/security-plugin-write-tenant-wall.ts#writeWallVerdict` | 1 | 6c |
| `packages/plugins/plugin-security/src/stored-permission-set-package-stamp.ts#holderLeftToEngine` | 1 | 23h |
| `packages/plugins/plugin-security/src/stored-permission-set-package-stamp.ts#onUpdate` | 1 | 23h |
Expand Down
90 changes: 89 additions & 1 deletion packages/metadata-core/src/object-schema-fls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* per-exit contract suites consume rather than re-derive.
*/

import { describe, it, expect } from 'vitest';
import { describe, it, expect, vi } from 'vitest';
import {
ObjectSchemaMaskEvaluationError,
actionObjectOverrideTargets,
Expand Down Expand Up @@ -721,3 +721,91 @@ describe('[decision 6840464379] an object whose owner declares a schemaReadDeleg
expect(await bare.declaredDelegate('sys_request')).toBeUndefined();
});
});

describe('[ADR-0106 D1/D3, #34901] a disabled package\'s withheld fields, judged per caller', () => {
/** A served object read whose package-disabled extension withholds two fields. */
const SERVED = {
name: 'deal',
label: 'Deal',
fields: { id: { type: 'text' }, amount: { type: 'number' } },
_withheldFields: { crm_project: { packageId: 'com.acme.projects' }, crm_margin: { packageId: 'com.acme.projects' } },
};
const caller = { userId: 'u1', systemPermissions: [] as string[] };
/** A service that reads every live field and admits `admitted` of the withheld ones. */
const service = (admitted: string[] | undefined | (() => never)) => ({
getMetadataReadableFields: async () => ['id', 'amount'],
getMetadataReadableWithheldFields: async () => (typeof admitted === 'function' ? admitted() : admitted),
});
const servedTo = async (security: Record<string, unknown> | undefined, context: unknown = caller, telemetry?: Record<string, unknown>) => {
const posture = await resolveObjectSchemaMaskPosture({ objectName: 'deal', context, security: security as any, enabled: true, telemetry: telemetry as any });
return applyObjectSchemaMask(SERVED, posture);
};

it('drops every entry the member does not admit, and the decoration with the last one', async () => {
const some = await servedTo(service(['crm_margin']));
expect((some.document as any)._withheldFields).toEqual({ crm_margin: { packageId: 'com.acme.projects' } });
expect(some.document).not.toBe(SERVED);
expect(SERVED._withheldFields, 'the cached document is never mutated').toHaveProperty('crm_project');
const none = await servedTo(service([]));
expect('_withheldFields' in (none.document as object)).toBe(false);
// Nothing else moves: every live field, no denied field, not emptied.
expect(Object.keys((none.document as any).fields)).toEqual(['id', 'amount']);
expect({ denied: none.denied, emptied: none.emptied, hidden: none.hidden }).toEqual({ denied: [], emptied: false, hidden: false });
});

it('an admitted caller is served the decoration whole, by reference, with no fingerprint', async () => {
const all = await servedTo(service(['crm_project', 'crm_margin']));
expect(all.document).toBe(SERVED);
expect(all.fingerprint).toBe('');
});

it('fails closed: a service without the member, an undefined answer and a throw each drop every entry', async () => {
const warn = vi.fn();
const cases = {
'member absent': { getMetadataReadableFields: async () => ['id', 'amount'] },
'undefined answer': service(undefined),
throws: service(() => { throw new Error('security service unhealthy (test)'); }),
};
for (const [label, security] of Object.entries(cases)) {
const masked = await servedTo(security, caller, { warn });
expect('_withheldFields' in (masked.document as object), label).toBe(false);
expect(Object.keys((masked.document as any).fields), label).toEqual(['id', 'amount']);
}
// A throw is no D6 fault — nothing the caller needs depends on it — and is said once, at warn.
expect(warn.mock.calls.filter(([, meta]) => meta?.decision === 'drop-withheld-fields')).toHaveLength(1);
});

it('a passthrough posture keeps the decoration: a D4-exempt caller, no security service, the D8 switch', async () => {
const admin = { userId: 'u_admin', systemPermissions: [OBJECT_SCHEMA_MASK_EXEMPT_CAPABILITIES[0]] };
expect((await servedTo(service([]), admin)).document).toBe(SERVED);
expect((await servedTo(undefined)).document).toBe(SERVED);
const disabled = await resolveObjectSchemaMaskPosture({ objectName: 'deal', context: caller, security: service([]) as any, enabled: false });
expect(applyObjectSchemaMask(SERVED, disabled).document).toBe(SERVED);
});

it('a project posture built without the answer drops every entry', () => {
const masked = applyObjectSchemaMask(SERVED, { kind: 'project', readable: new Set(['id', 'amount']) });
expect('_withheldFields' in (masked.document as object)).toBe(false);
});

it('[D3] the ETag fingerprint differs between callers who see different withheld sets, and is equal for the same set', async () => {
const a = await servedTo(service([]));
const b = await servedTo(service(['crm_margin']));
const c = await servedTo(service([]));
expect(a.fingerprint).not.toBe('');
expect(a.fingerprint).not.toBe(b.fingerprint);
expect(a.fingerprint).toBe(c.fingerprint);
// Qualified: a dropped withheld entry never hashes equal to a removed field of the same name.
expect(a.fingerprint).not.toBe(objectFieldVisibilityFingerprint(['crm_margin', 'crm_project']));
expect(foldVisibilityFingerprintIntoEtag('shared', a.fingerprint)).not.toBe(foldVisibilityFingerprintIntoEtag('shared', b.fingerprint));
});

it('the member is asked once per posture, with the caller\'s context', async () => {
const ask = vi.fn(async () => ['crm_margin']);
await resolveObjectSchemaMaskPosture({
objectName: 'deal', context: caller, enabled: true,
security: { getMetadataReadableFields: async () => ['id', 'amount'], getMetadataReadableWithheldFields: ask } as any,
});
expect(ask.mock.calls).toEqual([['deal', caller]]);
});
});
Loading
Loading