From 17312b8ba628670701e1878c0213fc4f8e5c861d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:56:32 +0000 Subject: [PATCH 01/15] feat(spec,ui): an object declares when a whole record is read-only by hand (object-level uiReadonlyWhen) WIP: spec key, console fold, MCP describe, FLS scrub, lint slot. Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../lint/src/validate-expressions.test.ts | 40 ++++++++ packages/lint/src/validate-expressions.ts | 16 ++++ .../src/__tests__/mcp-server-runtime.test.ts | 23 +++++ packages/mcp/src/mcp-http-tools.ts | 5 +- packages/mcp/src/mcp-server-runtime.ts | 32 ++++++- .../src/object-schema-fls-references.test.ts | 13 +++ .../src/object-schema-fls-references.ts | 19 ++++ .../mcp-object-hand-lock-36806.test.ts | 26 ++++++ packages/runtime/src/domains/mcp.ts | 25 ++++- packages/spec/liveness/object.json | 7 ++ .../spec/src/data/object.metadata-form.ts | 5 + packages/spec/src/data/object.zod.ts | 27 ++++++ .../src/utils/editFormLockedByState.ts | 20 ++-- .../__tests__/handLock-36806.test.ts | 88 +++++++++++++++--- ui/packages/core/src/evaluator/handLock.ts | 91 ++++++++++++++++--- .../plugin-calendar/src/ObjectCalendar.tsx | 4 +- .../plugin-detail/src/DetailSection.tsx | 2 +- .../plugin-detail/src/HeaderHighlight.tsx | 2 +- .../plugin-detail/src/InlineEditSaveBar.tsx | 4 +- .../src/renderers/recordPathStageChange.tsx | 4 +- ui/packages/plugin-form/src/ObjectForm.tsx | 8 +- .../plugin-form/src/deriveMasterDetail.ts | 32 +++++-- ui/packages/plugin-form/src/sectionFields.ts | 8 +- ui/packages/plugin-gantt/src/ObjectGantt.tsx | 4 +- ui/packages/plugin-gantt/src/ganttHandLock.ts | 7 +- ui/packages/plugin-grid/src/ObjectGrid.tsx | 1 + .../src/objectGridCellFacts-35684.test.ts | 1 + .../plugin-grid/src/objectGridCellFacts.ts | 9 +- .../plugin-grid/src/objectGridRowLoad.ts | 12 ++- .../plugin-kanban/src/ObjectKanban.tsx | 2 +- ui/packages/plugin-list/src/ListView.tsx | 9 +- .../plugin-timesheet/src/ObjectTimesheet.tsx | 1 + 32 files changed, 469 insertions(+), 78 deletions(-) diff --git a/packages/lint/src/validate-expressions.test.ts b/packages/lint/src/validate-expressions.test.ts index 9843a5a6ae1..e70389bf5ec 100644 --- a/packages/lint/src/validate-expressions.test.ts +++ b/packages/lint/src/validate-expressions.test.ts @@ -1842,6 +1842,46 @@ describe('validateStackExpressions (ADR-0032 build-time)', () => { }); }); + // [#37402] The object level of the same lock — the whole-record hand lock + // — has no server judge either, so it is checked as the field slot is. + describe('the object-level `uiReadonlyWhen` is checked as the field slot is (#37402)', () => { + const lint = (uiReadonlyWhen: string) => + validateStackExpressions({ + objects: [{ + name: 'hlk_locked_order', + uiReadonlyWhen, + fields: { + status: { type: 'select', options: [{ value: 'draft', label: 'Draft' }, { value: 'confirmed', label: 'Confirmed' }] }, + notes: { type: 'text', uiReadonlyWhen: 'false' }, + }, + }], + }).filter(i => i.where === "object 'hlk_locked_order' uiReadonlyWhen"); + + it('accepts a predicate over the record\'s own columns', () => { + expect(lint("record.status in ['confirmed', 'done']")).toEqual([]); + }); + + it('refuses a bare field reference', () => { + const found = lint("status == 'confirmed'"); + expect(found.map(i => i.severity)).toContain('error'); + expect(found.some(i => /bare reference `status`/.test(i.message))).toBe(true); + }); + + it('refuses a predicate that does not parse', () => { + expect(lint('record.(').some(i => i.severity === 'error')).toBe(true); + }); + + it('refuses a field the object does not declare', () => { + expect(lint("record.stage == 'won'").some(i => i.severity === 'error' && /stage/.test(i.message))).toBe(true); + }); + + it('refuses a root the field level does not bind, naming the console\'s locked outcome', () => { + const found = lint("current_user.id == 'u1'"); + expect(found.map(i => i.severity)).toEqual(['error']); + expect(found[0]!.message).toMatch(/resolves a hand lock it cannot evaluate to LOCKED/); + }); + }); + // `qty` carries `required` + `defaultValue` so it can never be null. That // is not decoration: it mirrors the real `showcase_invoice_line.quantity`, // and without it `record.qty >= 100` is a genuine #4811 finding — `>=` on a diff --git a/packages/lint/src/validate-expressions.ts b/packages/lint/src/validate-expressions.ts index 8ee49d817fb..a14e272cc13 100644 --- a/packages/lint/src/validate-expressions.ts +++ b/packages/lint/src/validate-expressions.ts @@ -4254,6 +4254,22 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression const fieldDefs = new Map(servedSelf ? fieldEntries(servedSelf) : []); for (const [n, def] of fieldList) if (!fieldDefs.has(n)) fieldDefs.set(n, def); for (const [n, def] of injectedColumnDefsFor(obj)) if (!fieldDefs.has(n)) fieldDefs.set(n, def as AnyRec); + // [#37402] The object's own `uiReadonlyWhen` — the whole-record hand lock, + // the object level of the field slot below (the two-tier field-lock model) + // — is judged exactly as that slot is: the `record`-scoped `check` and the + // root verdict over FIELD_RULE_BOUND_ROOTS, with the same consequence + // clause (the console locks every field that inherits it). No server reads + // it, so it carries no write gate. `obj.uiReadonlyWhen` is read literally + // so #5017's source scan checks it against `ObjectSchema`. + { + const where = `object '${objectName}' uiReadonlyWhen`; + const raw: unknown = obj.uiReadonlyWhen; + const verdict = fieldRuleRootVerdict('uiReadonlyWhen', raw); + check(where, raw, objectName, 'record', verdict !== null); + if (verdict) { + issues.push({ where, message: verdict.message, source: verdict.source, severity: 'error' }); + } + } for (const [fname, f] of fieldList) { // [#22032, pass 2] NOT fenced on an object write: the field-rule slots // below — the four slots' root verdict, the `parent` gate, the diff --git a/packages/mcp/src/__tests__/mcp-server-runtime.test.ts b/packages/mcp/src/__tests__/mcp-server-runtime.test.ts index 36a40d0f5e3..433b8870f79 100644 --- a/packages/mcp/src/__tests__/mcp-server-runtime.test.ts +++ b/packages/mcp/src/__tests__/mcp-server-runtime.test.ts @@ -371,3 +371,26 @@ describe('[#36806] describeServedObject reports the hand lock as its own keys', expect('uiReadonly' in field('subject') || 'uiReadonlyWhen' in field('subject')).toBe(false); }); }); + +// [#37402] The object level of the same model: the whole-record hand lock's +// predicate text, on the answer's top level, where the object authors one. +describe('[#37402] describeServedObject reports the object-level uiReadonlyWhen', () => { + const fields = { status: { type: 'text' }, notes: { type: 'text', uiReadonlyWhen: 'false' } }; + it('the predicate text, from an envelope too, beside the fields that override it', () => { + const described = describeServedObject({ + name: 'locked_order', + uiReadonlyWhen: { dialect: 'cel', source: "record.status in ['confirmed', 'done']" }, + fields, + } as never) as { uiReadonlyWhen?: unknown; fields: Array> }; + expect(described.uiReadonlyWhen).toBe("record.status in ['confirmed', 'done']"); + expect(described.fields.find((f) => f.name === 'notes')).toMatchObject({ uiReadonlyWhen: 'false' }); + // Never folded into any field's `readonly`: an agent's write still sets it. + expect(described.fields.find((f) => f.name === 'status')).toMatchObject({ readonly: false }); + expect('uiReadonlyWhen' in described.fields.find((f) => f.name === 'status')!).toBe(false); + }); + + it('CONTROL — an object that authors none, or a blank one, carries no key', () => { + expect('uiReadonlyWhen' in describeServedObject({ name: 'plain', fields } as never)).toBe(false); + expect('uiReadonlyWhen' in describeServedObject({ name: 'blank', uiReadonlyWhen: ' ', fields } as never)).toBe(false); + }); +}); diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index bf81a274c12..353d39c5789 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -4000,7 +4000,10 @@ export function registerObjectTools( + 'does not honour it yet; ' + 'your write may still set it, judged by the validations), system, ' + 'options (send the value) and defaultValue (omit the field to get it; never copy the value); the active ' - + 'validations; the enabled features. readonly is the schema\'s, not your edit permission.', + + 'validations; the enabled features; and the object\'s uiReadonlyWhen where set (while it holds, a person ' + + 'cannot edit any field of the record at the console except a field that lists its own uiReadonly / ' + + 'uiReadonlyWhen, so reach for an action; your write may still set every field, judged by the validations). ' + + 'readonly is the schema\'s, not your edit permission.', inputSchema: strictToolInput( { surface: 'this describe_object call', aliases: { ...OBJECT_NAME_ALIASES, name: 'objectName' } }, { objectName: z.string().describe('The object/table name, e.g. "task"') }, diff --git a/packages/mcp/src/mcp-server-runtime.ts b/packages/mcp/src/mcp-server-runtime.ts index 7be953ed921..b5d1f7ea3a9 100644 --- a/packages/mcp/src/mcp-server-runtime.ts +++ b/packages/mcp/src/mcp-server-runtime.ts @@ -99,6 +99,8 @@ export interface ServedObjectDef { fields?: Record; validations?: unknown[]; enable?: Record; + /** The whole-record hand lock (`ObjectSchema.uiReadonlyWhen`), CEL text or its envelope. */ + uiReadonlyWhen?: unknown; } /** One field of a served object definition: the keys {@link describeServedObject} reads. */ @@ -177,6 +179,9 @@ export function describeServedObject(def: ServedObjectDef, declared: ServedObjec })), validations: describedRules(def.validations), enableFeatures: def.enable ?? {}, + // The whole-record hand lock, off the served object (the object level of + // the two-tier field-lock model): its predicate text, where authored. + ...describedHandLockPredicate(def), }; } @@ -193,15 +198,34 @@ export function describeServedObject(def: ServedObjectDef, declared: ServedObjec * The twin is `describedHandLock` in `packages/runtime/src/domains/mcp.ts`. */ function describedHandLock(f: unknown): { uiReadonly?: true; uiReadonlyWhen?: string } { - const field = (f ?? {}) as { uiReadonly?: unknown; uiReadonlyWhen?: unknown }; - const when = field.uiReadonlyWhen as string | { source?: unknown } | undefined; - const source = typeof when === 'string' ? when : typeof when?.source === 'string' ? when.source : undefined; + const field = (f ?? {}) as { uiReadonly?: unknown }; return { ...(field.uiReadonly === true ? { uiReadonly: true as const } : {}), - ...(source !== undefined && source.trim() !== '' ? { uiReadonlyWhen: source } : {}), + ...describedHandLockPredicate(f), }; } +/** + * A `uiReadonlyWhen` predicate's text as `describe_object` serves it, on a + * field or on the object: `{ uiReadonlyWhen }` where the definition, as the + * caller is served it, authors a non-blank one, and nothing otherwise. On the + * object it is the whole-record hand lock — the default of every field that + * declares no hand lock of its own, which `describe_object` leaves for the + * reader to apply: a field's own key, where listed, wins. Like the field key it + * locks a person at the console only; an agent's write still sets every field, + * judged by the validations. + * + * The twin is `describedHandLockPredicate` in `packages/runtime/src/domains/mcp.ts`. + */ +function describedHandLockPredicate(def: unknown): { uiReadonlyWhen?: string } { + const raw = (def as { uiReadonlyWhen?: unknown } | null | undefined)?.uiReadonlyWhen as + | string + | { source?: unknown } + | undefined; + const source = typeof raw === 'string' ? raw : typeof raw?.source === 'string' ? raw.source : undefined; + return source !== undefined && source.trim() !== '' ? { uiReadonlyWhen: source } : {}; +} + /** * [#34721] An object's or a field's `description` as `list_objects` and * `describe_object` serve it: `{ description }` when the definition, as the diff --git a/packages/metadata-core/src/object-schema-fls-references.test.ts b/packages/metadata-core/src/object-schema-fls-references.test.ts index 95924b30e6a..6ffb26988fe 100644 --- a/packages/metadata-core/src/object-schema-fls-references.test.ts +++ b/packages/metadata-core/src/object-schema-fls-references.test.ts @@ -472,6 +472,19 @@ describe('[ADR-0106 D1] references to a denied field — inside a READABLE field expect(locked.fields.title.readonly).toBe(true); }); + // [#37402] The object level: the whole-record hand lock fails closed the same way. + it('[#37402] serves the object-level `uiReadonlyWhen` as the constant `true` when it reads the denied field', () => { + const served = mask({ name: 'thing', fields: fieldsWith(), uiReadonlyWhen: 'record.secret_score > 0' }); + expect(served.uiReadonlyWhen).toBe('true'); + const envelope = mask({ name: 'thing', fields: fieldsWith(), uiReadonlyWhen: { dialect: 'cel', source: 'record.secret_score > 0' } }); + expect(envelope.uiReadonlyWhen).toEqual({ dialect: 'cel', source: 'true' }); + }); + + it('[#37402] CONTROL: an object-level `uiReadonlyWhen` over readable fields is served as written', () => { + const served = mask({ name: 'thing', fields: fieldsWith(), uiReadonlyWhen: "record.title != ''" }); + expect(served.uiReadonlyWhen).toBe("record.title != ''"); + }); + it('drops a `lookupAutofill` pair whose target is denied, and keeps a source named on the referenced object', () => { // #27945 — `target` is a field of THIS object; `source` names a field of // the lookup's `reference` object, which this projection cannot judge. diff --git a/packages/metadata-core/src/object-schema-fls-references.ts b/packages/metadata-core/src/object-schema-fls-references.ts index 5890918d1e8..fdfa8efdf43 100644 --- a/packages/metadata-core/src/object-schema-fls-references.ts +++ b/packages/metadata-core/src/object-schema-fls-references.ts @@ -731,6 +731,24 @@ const readableField: Scrub = (value, denied, scope) => { // ── Object level ────────────────────────────────────────────────────────────── +/** + * [#37402] The object's whole-record hand lock (`uiReadonlyWhen`, the object + * level of {@link readableField}'s rule): a predicate that mentions a field + * denied to the caller cannot be evaluated by them, and nothing judges the hand + * lock but the console, which fails it CLOSED — so deleting it outright would + * silently OPEN every record for exactly the caller who cannot see why it is + * locked. It is served as the constant predicate `true` instead: every field + * that declares no hand lock of its own stays locked by hand for that caller, + * and a field's own `uiReadonlyWhen` still wins, as it does over the authored + * predicate. Its text, which describes the denied field, is never served. + */ +const objectHandLock: Scrub = (value, denied) => { + if (!mentionsDenied(value, denied, 'include', 'classified')) return value; + return value !== null && typeof value === 'object' && !Array.isArray(value) + ? { dialect: 'cel', source: 'true' } + : 'true'; +}; + /** A row-CRUD override flag: `boolean`, or `{ enabled, visibleWhen, disabledWhen }`. */ const crudFlag: Scrub = (value, denied) => ( value && typeof value === 'object' && !Array.isArray(value) @@ -831,6 +849,7 @@ export const OBJECT_REFERENCE_POSITIONS: Readonly> = { relatedLists: keep, // Expressions. titleFormat: expression, + uiReadonlyWhen: objectHandLock, // Rule entries — dropped whole when they mention a denied field. validations: ruleEntries, indexes: ruleEntries, diff --git a/packages/runtime/src/domains/mcp-object-hand-lock-36806.test.ts b/packages/runtime/src/domains/mcp-object-hand-lock-36806.test.ts index 6e455722475..122b5a4be32 100644 --- a/packages/runtime/src/domains/mcp-object-hand-lock-36806.test.ts +++ b/packages/runtime/src/domains/mcp-object-hand-lock-36806.test.ts @@ -60,6 +60,7 @@ async function bridgeFor(kernel: any, executionContext: Record) } const OBJ = 'mcp_hand_order'; +const LOCKED = 'mcp_hand_locked_order'; const STAFF = { userId: 'usr_staff', positions: [] as string[], permissions: ['mcp_hand_staff'], systemPermissions: [] as string[] }; const prevMcp = process.env.OS_MCP_SERVER_ENABLED; @@ -105,6 +106,17 @@ describe('[#36806] HTTP MCP describe_object reports uiReadonly / uiReadonlyWhen locked: { name: 'locked', type: 'text', label: 'Locked', readonly: true }, }, }, + { + // [#37402] The whole-record hand lock on the object. + name: LOCKED, + label: 'Locked order', + sharingModel: 'public_read_write', + uiReadonlyWhen: "record.status in ['confirmed', 'done']", + fields: { + status: { name: 'status', type: 'text', label: 'Status' }, + notes: { name: 'notes', type: 'text', label: 'Notes', uiReadonlyWhen: 'false' }, + }, + }, ], } as never); await engine.syncSchemas(); @@ -165,4 +177,18 @@ describe('[#36806] HTTP MCP describe_object reports uiReadonly / uiReadonlyWhen expect(field(described, 'locked')).toMatchObject({ readonly: true }); expect('uiReadonly' in field(described, 'locked')).toBe(false); }); + + // [#37402] The object level of the same model, through the real security layer. + it('an object-level `uiReadonlyWhen` is reported on the answer, and no field reads readonly for it', async () => { + const described = await (await bridgeFor(kernelOver(services), STAFF)).describeObject(LOCKED); + expect(described.uiReadonlyWhen).toBe("record.status in ['confirmed', 'done']"); + expect(field(described, 'status')).toMatchObject({ readonly: false }); + expect('uiReadonlyWhen' in field(described, 'status')).toBe(false); + expect(field(described, 'notes')).toMatchObject({ readonly: false, uiReadonlyWhen: 'false' }); + }); + + it('CONTROL — an object that authors no object-level predicate carries no key', async () => { + const described = await (await bridgeFor(kernelOver(services), STAFF)).describeObject(OBJ); + expect('uiReadonlyWhen' in described).toBe(false); + }); }); diff --git a/packages/runtime/src/domains/mcp.ts b/packages/runtime/src/domains/mcp.ts index ec8fe99d149..a43532e834d 100644 --- a/packages/runtime/src/domains/mcp.ts +++ b/packages/runtime/src/domains/mcp.ts @@ -765,6 +765,9 @@ function describeServedObject(def: any, declared: any): Record })), validations: describedRules(def.validations), enableFeatures: def.enable ?? {}, + // The whole-record hand lock, off the served object (the object level + // of the two-tier field-lock model): its predicate text, where authored. + ...describedHandLockPredicate(def), }; } @@ -781,14 +784,30 @@ function describeServedObject(def: any, declared: any): Record * The twin is `describedHandLock` in `packages/mcp/src/mcp-server-runtime.ts`. */ function describedHandLock(f: any): { uiReadonly?: true; uiReadonlyWhen?: string } { - const when = f?.uiReadonlyWhen; - const source = typeof when === 'string' ? when : typeof when?.source === 'string' ? when.source : undefined; return { ...(f?.uiReadonly === true ? { uiReadonly: true as const } : {}), - ...(source !== undefined && source.trim() !== '' ? { uiReadonlyWhen: source } : {}), + ...describedHandLockPredicate(f), }; } +/** + * A `uiReadonlyWhen` predicate's text as `describe_object` serves it, on a + * field or on the object: `{ uiReadonlyWhen }` where the definition, as the + * caller is served it, authors a non-blank one, and nothing otherwise. On the + * object it is the whole-record hand lock — the default of every field that + * declares no hand lock of its own, which `describe_object` leaves for the + * reader to apply: a field's own key, where listed, wins. Like the field key it + * locks a person at the console only; an agent's write still sets every field, + * judged by the validations. + * + * The twin is `describedHandLockPredicate` in `packages/mcp/src/mcp-server-runtime.ts`. + */ +function describedHandLockPredicate(def: any): { uiReadonlyWhen?: string } { + const when = def?.uiReadonlyWhen; + const source = typeof when === 'string' ? when : typeof when?.source === 'string' ? when.source : undefined; + return source !== undefined && source.trim() !== '' ? { uiReadonlyWhen: source } : {}; +} + /** * [#35137] The field names a {@link describeServedObject} answer lists, in its * order: the served-schema half of `fieldVisibilityOf`. The stdio twin is diff --git a/packages/spec/liveness/object.json b/packages/spec/liveness/object.json index 192fd64a526..0ddf4d9cf44 100644 --- a/packages/spec/liveness/object.json +++ b/packages/spec/liveness/object.json @@ -279,6 +279,13 @@ "verifiedAt": "2026-08-28", "note": "DDL — but only through `name`/`fields`/`unique`. `syncDeclaredIndexes` creates every declared index via knex's `table.index()` / `table.unique()`, and the differ's `DeclaredIndexInput` carries `name`/`fields`/`unique`/`nullSafeColumns`. The other two child keys were RETIRED 2026-08-06 (#5248, #4943, ADR-0049): `indexes[].type` selected no access method (and its `.default('btree')` materialized an inert knob into every parse output) and `indexes[].partial` produced a FULL index with the predicate discarded. Both are `retiredKey()` tombstones at `IndexSchema` and are stripped from sources by the protocol-17 conversion `object-index-type-partial-removed`. The container stays `live` because the surviving keys drive real DDL. ⚠ Not to be confused with driver-sql's own `partial: boolean`, which is parsed back out of the database's own CREATE INDEX DDL for drift detection and is unrelated to the declaration surface. 2026-08-28: RE-ANCHORED (commit 93ea19bca) and REPOINTED — the citation was `sql-driver.ts:1181`, in range of this 16289-line file but landing in a docblock about aggregate-function lowering (`count_distinct`), nowhere near an index read. The note already named `syncDeclaredIndexes` in prose and that pointer stayed true the whole time while the evidence line rotted — the same note-survives/evidence-rots split recorded on action.requiredPermissions. Re-closed by hand against c459da6bc." }, + "uiReadonlyWhen": { + "status": "live", + "verifiedAt": "2026-11-28", + "evidenceScope": "in-repo", + "evidence": "ui/packages/core/src/evaluator/handLock.ts#effectiveUiReadonlyWhen (a field's own `uiReadonly` / `uiReadonlyWhen` wins, else the object's predicate) read by #fieldReadOnlyByHand, #fieldHasConditionalHandLock and #fieldLockPredicates, which every hand surface reads with the object definition beside the field: the record page (ui/packages/plugin-detail/src/DetailSection.tsx, HeaderHighlight.tsx, InlineEditSaveBar.tsx, renderers/recordPathStageChange.tsx), the grid cell (ui/packages/plugin-grid/src/objectGridCellFacts.ts#cellReadOnlyKind) and its operand fetch (objectGridRowLoad.ts, ui/packages/plugin-list/src/ListView.tsx), kanban and calendar drops, the Gantt (ui/packages/plugin-gantt/src/ganttHandLock.ts), the timesheet cell, and the edit dialog's form fields (ui/packages/plugin-form/src/sectionFields.ts#fromObjectSchema, ObjectForm.tsx, ui/packages/app-shell/src/utils/editFormLockedByState.ts); packages/runtime/src/domains/mcp.ts#describeServedObject and packages/mcp/src/mcp-server-runtime.ts#describeServedObject (describe_object); packages/lint/src/validate-expressions.ts (objectstack validate)", + "note": "renderer only, by ruling (the two-tier field-lock model, its object level): while TRUE no person edits any field of an existing record at the console surfaces a field's own `uiReadonlyWhen` locks; a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead. The engine never reads it, so REST, import, action and flow writes keep every field, judged by validations. Fail-closed on a fault, as the field key. The console has no person-triggered record duplicate, so no clone surface reads it; the REST clone door is an API write and keeps every value." + }, "validations": { "status": "live", "verifiedAt": "2026-08-28", diff --git a/packages/spec/src/data/object.metadata-form.ts b/packages/spec/src/data/object.metadata-form.ts index b6c53729871..6c26058ebe6 100644 --- a/packages/spec/src/data/object.metadata-form.ts +++ b/packages/spec/src/data/object.metadata-form.ts @@ -532,6 +532,11 @@ export const objectForm = defineMetadataForm({ // `lifecycle.*.onlyWhen` rows — ⛔ not a reconciliation, and not this // row's price of admission. { field: 'validations', widget: 'json', helpText: 'Object-level validation rules — an array of rule objects, e.g. [{ "type": "script", "name": "amount_positive", "condition": "amount > 0", "message": "Amount must be positive" }]. State-machine transition tables are declared here too (ADR-0020)' }, + // The whole-record hand lock (the object level of a field's + // `uiReadonlyWhen`, the two-tier field-lock model), beside the state + // machine it usually follows: the same CEL code row the field form + // gives the field key. + { field: 'uiReadonlyWhen', type: 'code', language: 'expression', colSpan: 2, helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." }, // #19332 (flight G2b of ruling record 5861442317) — the object's // declarative timeline milestones (ADR-0052 §5b.2), beside `validations`: // a milestone fires on a field reaching a value, the same transition a diff --git a/packages/spec/src/data/object.zod.ts b/packages/spec/src/data/object.zod.ts index c92d2d57002..820fac141ac 100644 --- a/packages/spec/src/data/object.zod.ts +++ b/packages/spec/src/data/object.zod.ts @@ -4745,6 +4745,33 @@ const ObjectSchemaBase = strictObject( // enforces the transition table; UIs read the legal next states via the // `/meta/objects/:name/state/:field?from=` introspection endpoint. + /** + * The WHOLE-RECORD hand lock (ruling on the two-tier field-lock model, the + * object level of `Field.uiReadonlyWhen`): while TRUE no person edits any + * field of an existing record at the console — the same surfaces a field's + * own `uiReadonlyWhen` locks — and every other write keeps them. For a + * record that changes only through actions once it reaches a state, e.g. a + * confirmed order: P`record.status in ['confirmed', 'done']`. + * + * It is a DEFAULT for every field: a field that declares its own `uiReadonly` + * or `uiReadonlyWhen` is judged by its own declaration instead, so + * `uiReadonlyWhen: P\`false\`` on a field keeps it editable inside a locked + * record (notes, internal tags). The server lock of a field (`readonly`, + * `readonlyWhen`) is not a hand-lock declaration and still locks on its own. + * A create is not judged, as at the field level. + * + * Same scope and fault direction as the field key: the bound record's OWN + * columns; a predicate the console cannot evaluate fails CLOSED (every field + * that inherits it locks) because no server judges this key (ADR-0137 D2). + * `objectstack validate` checks the predicate. + * + * Read by the console only, through the one hand-lock verdict in + * `@object-ui/core` (`fieldReadOnlyByHand`); `describe_object` (MCP) + * reports it. The engine never reads it: a TRUE predicate refuses no REST, + * import, action or flow write, and drops nothing from one. + */ + uiReadonlyWhen: EvaluatedExpressionInputSchema.optional().describe("Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key."), + /** * Display & UI Hints (Data-Layer) */ diff --git a/ui/packages/app-shell/src/utils/editFormLockedByState.ts b/ui/packages/app-shell/src/utils/editFormLockedByState.ts index b75ae4615fe..e1de5822dff 100644 --- a/ui/packages/app-shell/src/utils/editFormLockedByState.ts +++ b/ui/packages/app-shell/src/utils/editFormLockedByState.ts @@ -21,8 +21,10 @@ * * It answers `true` only when ALL of these hold, and fails open otherwise: * - * - at least one drawn field is locked by its `readonlyWhen`, so the lock is - * the record's state, which is what the header's reason names; + * - at least one drawn field is locked by its `readonlyWhen` or its hand + * lock (its own `uiReadonlyWhen`, or the object's whole-record one it + * inherits), so the lock is the record's state, which is what the header's + * reason names; * - every drawn field resolves read-only, over the object's whole field map, * so a writable field anywhere keeps Edit live; * - the object's field groups place no inline child collection @@ -33,13 +35,13 @@ * the form, so a broken rule never greys Edit. */ -import { isExpressionComputedField, resolveFieldRuleState } from '@object-ui/core'; +import { effectiveUiReadonlyWhen, isExpressionComputedField, resolveFieldRuleState, type ObjectHandLockDef } from '@object-ui/core'; import { filterSystemFields, isAutoGeneratedFieldType } from '@object-ui/plugin-form/core'; import type { FormField } from '@object-ui/types'; import { recordFormSubforms, type ObjectDefinitionForRecordForm } from './recordFormNavigation.js'; /** The slice of a served object definition this reads. */ -export type EditFormLockObject = ObjectDefinitionForRecordForm & { +export type EditFormLockObject = ObjectDefinitionForRecordForm & ObjectHandLockDef & { fields?: Record | Array | null; }; @@ -94,8 +96,14 @@ export function editFormLockedByState( const staticReadonly = isExpressionComputedField(def) || (typeof def.type === 'string' && isAutoGeneratedFieldType(def.type)); const state = resolveFieldRuleState( - // The form folds the hand lock's predicate into the same verdict, so this does too. - { visibleWhen: def.visibleWhen, readonlyWhen: def.readonlyWhen, uiReadonlyWhen: def.uiReadonlyWhen }, + // The form folds the hand lock's predicate into the same verdict, so this + // does too — the EFFECTIVE one, as the form field carries it: a field + // that declares none of its own takes the object's `uiReadonlyWhen`. + { + visibleWhen: def.visibleWhen, + readonlyWhen: def.readonlyWhen, + uiReadonlyWhen: effectiveUiReadonlyWhen(def, objectDef) as typeof def.uiReadonlyWhen, + }, ruleRecord, { readonly: staticReadonly, name }, ruleRecord, diff --git a/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts b/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts index a995b6cfd8f..8dbf5985c65 100644 --- a/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts +++ b/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts @@ -13,6 +13,9 @@ */ import { describe, it, expect } from 'vitest'; import { + effectiveUiReadonlyWhen, + fieldHasConditionalHandLock, + fieldLockPredicates, fieldReadOnlyByHand, fieldStaticallyReadOnlyByHand, resolveFieldRuleState, @@ -30,38 +33,38 @@ describe('fieldReadOnlyByHand (#36806)', () => { it('the full verdict judges uiReadonlyWhen and readonlyWhen over the record', () => { const def = { uiReadonlyWhen: "record.status != 'draft'" }; - expect(fieldReadOnlyByHand(def, { status: 'approved' })).toBe(true); - expect(fieldReadOnlyByHand(def, { status: 'draft' })).toBe(false); + expect(fieldReadOnlyByHand(def, { status: 'approved' }, { object: null })).toBe(true); + expect(fieldReadOnlyByHand(def, { status: 'draft' }, { object: null })).toBe(false); const server = { readonlyWhen: "record.status == 'paid'" }; - expect(fieldReadOnlyByHand(server, { status: 'paid' })).toBe(true); - expect(fieldReadOnlyByHand(server, { status: 'draft' })).toBe(false); - expect(fieldReadOnlyByHand({ uiReadonly: true }, { status: 'draft' })).toBe(true); - expect(fieldReadOnlyByHand({}, { status: 'draft' })).toBe(false); + expect(fieldReadOnlyByHand(server, { status: 'paid' }, { object: null })).toBe(true); + expect(fieldReadOnlyByHand(server, { status: 'draft' }, { object: null })).toBe(false); + expect(fieldReadOnlyByHand({ uiReadonly: true }, { status: 'draft' }, { object: null })).toBe(true); + expect(fieldReadOnlyByHand({}, { status: 'draft' }, { object: null })).toBe(false); }); // REWORK S2: no server judges the hand lock (ADR-0137 D2), so a fault // LOCKS the field — unlike `readonlyWhen`, whose fault the server answers. it('a uiReadonlyWhen that cannot be evaluated LOCKS the field (fail-closed)', () => { - expect(fieldReadOnlyByHand({ uiReadonlyWhen: 'record.(' }, { status: 'x' })).toBe(true); + expect(fieldReadOnlyByHand({ uiReadonlyWhen: 'record.(' }, { status: 'x' }, { object: null })).toBe(true); // The control: a faulted readonlyWhen stays open on the client. - expect(fieldReadOnlyByHand({ readonlyWhen: 'record.(' }, { status: 'x' })).toBe(false); + expect(fieldReadOnlyByHand({ readonlyWhen: 'record.(' }, { status: 'x' }, { object: null })).toBe(false); }); // REWORK S1: a projected row that lacks the operand cannot be judged. it('a row missing the predicate\'s operand is locked, and judged once the operand is read', () => { const def = { uiReadonlyWhen: "record.status != 'draft'" }; - expect(fieldReadOnlyByHand(def, { name: 'projected row' })).toBe(true); - expect(fieldReadOnlyByHand(def, { name: 'full row', status: 'draft' })).toBe(false); + expect(fieldReadOnlyByHand(def, { name: 'projected row' }, { object: null })).toBe(true); + expect(fieldReadOnlyByHand(def, { name: 'full row', status: 'draft' }, { object: null })).toBe(false); }); // REWORK S1: the host scope binds `current_user` on every surface. it('judges a current_user predicate over the host scope it is given', () => { const def = { uiReadonlyWhen: "current_user.id != record.owner" }; const scope = { current_user: { id: 'u1' } }; - expect(fieldReadOnlyByHand(def, { owner: 'u1' }, { scope })).toBe(false); - expect(fieldReadOnlyByHand(def, { owner: 'u2' }, { scope })).toBe(true); + expect(fieldReadOnlyByHand(def, { owner: 'u1' }, { object: null, scope })).toBe(false); + expect(fieldReadOnlyByHand(def, { owner: 'u2' }, { object: null, scope })).toBe(true); // No scope: the root is unbound, the predicate faults, the field locks. - expect(fieldReadOnlyByHand(def, { owner: 'u1' })).toBe(true); + expect(fieldReadOnlyByHand(def, { owner: 'u1' }, { object: null })).toBe(true); }); }); @@ -83,3 +86,62 @@ describe('resolveFieldRuleState folds the hand lock (#36806)', () => { expect(state.faults?.uiReadonlyWhen).toBeTruthy(); }); }); + +/** + * #37402 — the object level of the same model: an object's `uiReadonlyWhen` + * is the hand lock of every field that declares none of its own, and a field's + * own `uiReadonly` / `uiReadonlyWhen` wins over it in both directions. + */ +describe('the object-level hand lock folds into the one verdict (#37402)', () => { + const ORDER = { uiReadonlyWhen: "record.status in ['confirmed', 'done']" }; + const confirmed = { status: 'confirmed', notes: 'x', amount: 1 }; + const draft = { status: 'draft', notes: 'x', amount: 1 }; + + it('locks every field that declares no hand lock of its own while TRUE, and only then', () => { + expect(fieldReadOnlyByHand({}, confirmed, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand(undefined, confirmed, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand({}, draft, { object: ORDER })).toBe(false); + // The control: the same field and record, with no object lock, stay open. + expect(fieldReadOnlyByHand({}, confirmed, { object: null })).toBe(false); + expect(fieldReadOnlyByHand({}, confirmed, { object: {} })).toBe(false); + }); + + it('a field\'s own `uiReadonlyWhen: false` keeps it editable inside a locked record', () => { + expect(fieldReadOnlyByHand({ uiReadonlyWhen: 'false' }, confirmed, { object: ORDER })).toBe(false); + expect(fieldReadOnlyByHand({ uiReadonlyWhen: { dialect: 'cel', source: 'false' } }, confirmed, { object: ORDER })).toBe(false); + }); + + it('a field\'s own hand lock also wins the other way: it locks where the object does not', () => { + const always = { uiReadonlyWhen: "record.status != ''" }; + expect(fieldReadOnlyByHand(always, draft, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand({ uiReadonly: true }, draft, { object: ORDER })).toBe(true); + }); + + it('an explicit `uiReadonly: false` is a declaration of its own too', () => { + expect(fieldReadOnlyByHand({ uiReadonly: false }, confirmed, { object: ORDER })).toBe(false); + }); + + it('the server lock is not a hand-lock declaration: it does not cancel the object default', () => { + const server = { readonlyWhen: "record.status == 'paid'" }; + expect(fieldReadOnlyByHand(server, confirmed, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand(server, { status: 'paid' }, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand(server, draft, { object: ORDER })).toBe(false); + }); + + it('fails CLOSED on an object predicate it cannot evaluate, as at the field level', () => { + expect(fieldReadOnlyByHand({}, draft, { object: { uiReadonlyWhen: 'record.(' } })).toBe(true); + // A row projected without the operand cannot be judged either. + expect(fieldReadOnlyByHand({}, { notes: 'x' }, { object: ORDER })).toBe(true); + }); + + it('the fold every hand-off reads: the effective predicate, the predicate list, the conditional flag', () => { + expect(effectiveUiReadonlyWhen({}, ORDER)).toBe(ORDER.uiReadonlyWhen); + expect(effectiveUiReadonlyWhen({ uiReadonlyWhen: 'false' }, ORDER)).toBe('false'); + expect(effectiveUiReadonlyWhen({ uiReadonly: true }, ORDER)).toBeUndefined(); + expect(effectiveUiReadonlyWhen({}, null)).toBeUndefined(); + expect(fieldLockPredicates({ readonlyWhen: 'record.a' }, ORDER)).toEqual(['record.a', ORDER.uiReadonlyWhen]); + expect(fieldLockPredicates({}, null)).toEqual([]); + expect(fieldHasConditionalHandLock({}, ORDER)).toBe(true); + expect(fieldHasConditionalHandLock({}, null)).toBe(false); + }); +}); diff --git a/ui/packages/core/src/evaluator/handLock.ts b/ui/packages/core/src/evaluator/handLock.ts index 1f123a42513..0fee129f297 100644 --- a/ui/packages/core/src/evaluator/handLock.ts +++ b/ui/packages/core/src/evaluator/handLock.ts @@ -36,6 +36,18 @@ * wizard's target mapping (an import keeps the write) and the Studio/designer * authoring reads (they describe the declaration, not a person's edit). * + * Two levels (the object level of the same ruling): an object's own + * `uiReadonlyWhen` is the hand-lock DEFAULT for every field of its records, and + * a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by + * that declaration instead ({@link effectiveUiReadonlyWhen}). So every verdict + * here takes the object definition beside the field, as a REQUIRED context + * key: a surface that forgot it would silently open a locked record, so the + * compiler asks each caller for it (`null` where a surface has no object). + * A surface that hands a field's lock on to another evaluator (a form field's + * `uiReadonlyWhen`, a predicate whose operands it fetches) reads the folded + * predicate from {@link effectiveUiReadonlyWhen} / {@link fieldLockPredicates}, + * never the object key itself. + * * The predicate halves run through {@link resolveFieldRuleState}, the one * evaluator of field-level CEL, so a predicate here means what it means on * the form. A `readonlyWhen` that cannot be evaluated leaves the field @@ -54,8 +66,23 @@ export interface FieldHandLockDef { uiReadonlyWhen?: unknown; } -/** Optional evaluation context for the predicate halves. */ +/** + * The object-level key this verdict reads (`@objectstack/spec` + * `ObjectSchema.uiReadonlyWhen`): the whole-record hand lock, the default of + * every field that declares no hand lock of its own. + */ +export interface ObjectHandLockDef { + uiReadonlyWhen?: unknown; +} + +/** Evaluation context for the predicate halves. */ export interface FieldHandLockContext { + /** + * The definition of the object the field belongs to, whose `uiReadonlyWhen` + * is the field's default hand lock. REQUIRED on purpose: pass `null` only + * where the surface truly has no object definition. + */ + object: ObjectHandLockDef | null | undefined; /** The stored row an edit starts from, bound as `previous`. */ previous?: Record; /** The host shell's predicate scope (`current_user` and friends). */ @@ -64,38 +91,76 @@ export interface FieldHandLockContext { fieldContext?: string; } +/** True when the field declares a hand lock of its own (either key, either value). */ +function declaresOwnHandLock(def: FieldHandLockDef | null | undefined): boolean { + return def?.uiReadonly !== undefined || def?.uiReadonlyWhen !== undefined; +} + +/** + * The field's EFFECTIVE hand-lock predicate: its own `uiReadonlyWhen` when the + * field declares a hand lock of its own (`uiReadonly` or `uiReadonlyWhen`, any + * value — `uiReadonlyWhen: P\`false\`` keeps a field editable inside a locked + * record), else the object's `uiReadonlyWhen`. `undefined` when neither + * applies. The server lock (`readonly` / `readonlyWhen`) is not a hand-lock + * declaration: it never cancels the object's default, it locks on its own. + */ +export function effectiveUiReadonlyWhen( + def: FieldHandLockDef | null | undefined, + object: ObjectHandLockDef | null | undefined, +): unknown { + if (declaresOwnHandLock(def)) return def?.uiReadonlyWhen ?? undefined; + return object?.uiReadonlyWhen ?? undefined; +} + +/** + * The conditional lock predicates that judge the field — `readonlyWhen` and the + * effective `uiReadonlyWhen` — for a surface that must fetch their operands + * before it judges a row. Absent ones are left out. + */ +export function fieldLockPredicates( + def: FieldHandLockDef | null | undefined, + object: ObjectHandLockDef | null | undefined, +): unknown[] { + return [def?.readonlyWhen ?? undefined, effectiveUiReadonlyWhen(def, object)].filter((p) => p != null); +} + /** * The STATIC half: true when the field is read-only by hand on every record — * `readonly: true` or `uiReadonly: true`. For a surface that decides before it * has a record (which columns a create dialog lists, which fields a payload may - * carry); a surface that has the record reads {@link fieldReadOnlyByHand}. + * carry); a surface that has the record reads {@link fieldReadOnlyByHand}. The + * object level adds nothing here: it is conditional only. */ export function fieldStaticallyReadOnlyByHand(def: FieldHandLockDef | null | undefined): boolean { return def?.readonly === true || def?.uiReadonly === true; } -/** True when the field declares a conditional lock of either tier. */ -export function fieldHasConditionalHandLock(def: FieldHandLockDef | null | undefined): boolean { - return def?.readonlyWhen != null || def?.uiReadonlyWhen != null; +/** True when the field is judged by a conditional lock of either tier, its own or the object's. */ +export function fieldHasConditionalHandLock( + def: FieldHandLockDef | null | undefined, + object: ObjectHandLockDef | null | undefined, +): boolean { + return fieldLockPredicates(def, object).length > 0; } /** - * The FULL verdict over one record: the static half, or `readonlyWhen` / - * `uiReadonlyWhen` TRUE over `record`. With no record the predicates are - * judged over an empty one: `readonlyWhen` then answers open, `uiReadonlyWhen` - * locked (it cannot be judged, and nothing behind it judges the write). + * The FULL verdict over one record: the static half, or `readonlyWhen` / the + * effective `uiReadonlyWhen` TRUE over `record`. With no record the predicates + * are judged over an empty one: `readonlyWhen` then answers open, + * `uiReadonlyWhen` locked (it cannot be judged, and nothing behind it judges + * the write). */ export function fieldReadOnlyByHand( def: FieldHandLockDef | null | undefined, - record?: Record | null, - context: FieldHandLockContext = {}, + record: Record | null | undefined, + context: FieldHandLockContext, ): boolean { if (fieldStaticallyReadOnlyByHand(def)) return true; - if (!fieldHasConditionalHandLock(def)) return false; + if (!fieldHasConditionalHandLock(def, context.object)) return false; return resolveFieldRuleState( { readonlyWhen: (def?.readonlyWhen ?? undefined) as FieldRulePredicate | undefined, - uiReadonlyWhen: (def?.uiReadonlyWhen ?? undefined) as FieldRulePredicate | undefined, + uiReadonlyWhen: effectiveUiReadonlyWhen(def, context.object) as FieldRulePredicate | undefined, }, record ?? {}, {}, diff --git a/ui/packages/plugin-calendar/src/ObjectCalendar.tsx b/ui/packages/plugin-calendar/src/ObjectCalendar.tsx index fa27ed8ac5c..168422bd7fa 100644 --- a/ui/packages/plugin-calendar/src/ObjectCalendar.tsx +++ b/ui/packages/plugin-calendar/src/ObjectCalendar.tsx @@ -1362,8 +1362,8 @@ export const ObjectCalendar: React.FC = ({ // array identity puts the event back where the record has it. const lockDefs = objectSchema?.fields as Record | undefined> | undefined; if ( - fieldReadOnlyByHand(lockDefs?.[startDateField], record, { scope: predicateScope }) || - (writesEnd && fieldReadOnlyByHand(lockDefs?.[endDateField as string], record, { scope: predicateScope })) + fieldReadOnlyByHand(lockDefs?.[startDateField], record, { object: objectSchema, scope: predicateScope }) || + (writesEnd && fieldReadOnlyByHand(lockDefs?.[endDateField as string], record, { object: objectSchema, scope: predicateScope })) ) { setData((prev) => prev.slice()); return; diff --git a/ui/packages/plugin-detail/src/DetailSection.tsx b/ui/packages/plugin-detail/src/DetailSection.tsx index 49915cbef45..1f979305821 100644 --- a/ui/packages/plugin-detail/src/DetailSection.tsx +++ b/ui/packages/plugin-detail/src/DetailSection.tsx @@ -651,7 +651,7 @@ export const DetailSection: React.FC = ({ // The object field's lock goes through the one hand-lock verdict — `readonly`, // `readonlyWhen`, `uiReadonly`, `uiReadonlyWhen` over this record // (`fieldReadOnlyByHand`, `@object-ui/core`) — never `readonly` alone. - const isReadonly = field.readonly === true || fieldReadOnlyByHand(objectDefField, data, { scope: predicateScope }); + const isReadonly = field.readonly === true || fieldReadOnlyByHand(objectDefField, data, { object: objectSchema, scope: predicateScope }); const isSystemField = NON_EDITABLE_SYSTEM_FIELDS.has(field.name); // Types the fields package excludes from in-place editing — the SAME // alias-aware contract the grid consults, not a second list (objectui#4221). diff --git a/ui/packages/plugin-detail/src/HeaderHighlight.tsx b/ui/packages/plugin-detail/src/HeaderHighlight.tsx index b05eb8b19b0..f9b5300b343 100644 --- a/ui/packages/plugin-detail/src/HeaderHighlight.tsx +++ b/ui/packages/plugin-detail/src/HeaderHighlight.tsx @@ -226,7 +226,7 @@ export const HeaderHighlight: React.FC = ({ // The object field's lock is the one hand-lock verdict over this // record (`fieldReadOnlyByHand`), as the details body reads it. const isReadonly = - field.readonly === true || fieldReadOnlyByHand(objectDefField, data, { scope: predicateScope }); + field.readonly === true || fieldReadOnlyByHand(objectDefField, data, { object: objectSchema, scope: predicateScope }); const isSystem = NON_EDITABLE_SYSTEM_FIELDS.has(field.name); // Same shared exclusion the details body and the grid consult, so a // credential chip never opens the plain text editor that would show diff --git a/ui/packages/plugin-detail/src/InlineEditSaveBar.tsx b/ui/packages/plugin-detail/src/InlineEditSaveBar.tsx index e25ecd1a6fd..9e58fa74bbf 100644 --- a/ui/packages/plugin-detail/src/InlineEditSaveBar.tsx +++ b/ui/packages/plugin-detail/src/InlineEditSaveBar.tsx @@ -423,12 +423,12 @@ export const InlineEditSaveBar: React.FC = ({ const fillable = React.useCallback( (name: string, def: Record) => // The one hand-lock verdict over this record (`fieldReadOnlyByHand`). - !fieldReadOnlyByHand(def, data, { scope: predicateScope }) + !fieldReadOnlyByHand(def, data, { object: objectSchema, scope: predicateScope }) && !isComputedDetailField(undefined, def as never) && !NON_EDITABLE_SYSTEM_FIELDS.has(name) && !!objectName && resolveFieldAffordance('recordEdit', perms, objectName, name), - [objectName, perms, data, predicateScope], + [objectName, perms, data, predicateScope, objectSchema], ); /** diff --git a/ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx b/ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx index 18fe77bbc72..d9e8bfbc3a3 100644 --- a/ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx +++ b/ui/packages/plugin-detail/src/renderers/recordPathStageChange.tsx @@ -256,7 +256,7 @@ export function useStageChange( && !inline.editing // The one hand-lock verdict over the stored record (`fieldReadOnlyByHand`): // a status that moves only through actions (`uiReadonly`) offers no stage. - && !fieldReadOnlyByHand(fieldDef, ctx?.data as Record | undefined, { scope: predicateScope }) + && !fieldReadOnlyByHand(fieldDef, ctx?.data as Record | undefined, { object: objectSchema, scope: predicateScope }) && !isComputedDetailField(undefined, fieldDef) && !NON_EDITABLE_SYSTEM_FIELDS.has(statusField) && resolveFieldAffordance('recordEdit', perms, objectName, statusField); @@ -271,7 +271,7 @@ export function useStageChange( // fill-in asks the same one). const fillable = (name: string, def: Record): boolean => name !== statusField - && !fieldReadOnlyByHand(def, record, { scope: predicateScope }) + && !fieldReadOnlyByHand(def, record, { object: objectSchema, scope: predicateScope }) && !isComputedDetailField(undefined, def as FieldDef) && !NON_EDITABLE_SYSTEM_FIELDS.has(name) && !!objectName diff --git a/ui/packages/plugin-form/src/ObjectForm.tsx b/ui/packages/plugin-form/src/ObjectForm.tsx index 620a604403f..269bc8c3c75 100644 --- a/ui/packages/plugin-form/src/ObjectForm.tsx +++ b/ui/packages/plugin-form/src/ObjectForm.tsx @@ -21,7 +21,7 @@ import { pickLocalized, useObjectTranslation, useLocalization, withHomeAmountSou import { useRecordInvalidation } from './recordInvalidation'; import { useReportedDirtyChange } from './formDirtyReport'; import { mapFieldTypeToFormType, buildValidationRules, formatFileSize, fieldHelpText, withFollowedParentObject, withFormObject, PERMISSION_SET_GRANT_COLUMNS } from '@object-ui/fields'; -import { fieldStaticallyReadOnlyByHand, isExpressionComputedField } from '@object-ui/core'; +import { effectiveUiReadonlyWhen, fieldStaticallyReadOnlyByHand, isExpressionComputedField } from '@object-ui/core'; import { useIsMobile, toast, FormSectionNavContext } from '@object-ui/components'; import { resolveSuccessNavigate } from './successBehavior'; import { resolveSubmitRedirect, submitRedirectScope } from './submitRedirect'; @@ -1020,8 +1020,10 @@ const SimpleObjectForm: React.FC<{ schema: LocalizedObjectFormSchema; dataSource // engine (same dialect the server enforces). Undefined when absent. visibleWhen: field.visibleWhen, readonlyWhen: field.readonlyWhen, - // The hand lock's predicate, folded with `readonlyWhen` by the form renderer. - uiReadonlyWhen: field.uiReadonlyWhen, + // The hand lock's predicate, folded with `readonlyWhen` by the form + // renderer: the EFFECTIVE one, so a field that declares none of its + // own carries the object's whole-record `uiReadonlyWhen`. + uiReadonlyWhen: effectiveUiReadonlyWhen(field, objectSchema), requiredWhen: field.requiredWhen, // Field-group membership (Field.group → object.fieldGroups[].key). // Carried through so the form can auto-derive sections from the diff --git a/ui/packages/plugin-form/src/deriveMasterDetail.ts b/ui/packages/plugin-form/src/deriveMasterDetail.ts index cd554b0b87d..2f5ed4b8675 100644 --- a/ui/packages/plugin-form/src/deriveMasterDetail.ts +++ b/ui/packages/plugin-form/src/deriveMasterDetail.ts @@ -22,7 +22,7 @@ import { deriveInlineRowFormFields, } from '@objectstack/spec/data'; import { summaryDeclaresCurrency, type BooleanValueLabel, type GridColumn } from '@object-ui/fields'; -import { isExpressionComputedField } from '@object-ui/core'; +import { effectiveUiReadonlyWhen, isExpressionComputedField } from '@object-ui/core'; /** * Minimal shape of a MASTER-DETAIL CHILD object's schema, as returned by @@ -267,7 +267,7 @@ export function deriveColumns( maxColumns: opts.maxColumns ?? DEFAULT_MAX_INLINE_GRID_COLUMNS, }); return derived.map(({ name, defaultHidden }) => { - const col = deriveColumn(name, fields[name], opts.booleanLabel); + const col = deriveColumn(name, fields[name], opts.booleanLabel, childSchema); return defaultHidden ? { ...col, defaultHidden } : col; }); } @@ -277,7 +277,12 @@ export function deriveColumns( * `d` (the field map holds `null` / `undefined` / `0` / `''` / `false` under * that name) still builds a plain text column headed by the field name. */ -function deriveColumn(name: string, d: any, booleanLabel: BooleanValueLabel): GridColumn { +function deriveColumn( + name: string, + d: any, + booleanLabel: BooleanValueLabel, + childSchema: ChildObjectSchemaLike | undefined, +): GridColumn { const col: GridColumn = { name, label: d?.label || name, @@ -311,7 +316,10 @@ function deriveColumn(name: string, d: any, booleanLabel: BooleanValueLabel): Gr // The child FIELD's hand-lock predicate (`uiReadonlyWhen`), carried onto its // column in memory: the cell folds it into the same per-row read-only verdict // (`resolveFieldRuleState`). Not an `inlineColumns` key an author writes. - if (d?.uiReadonlyWhen) (col as { uiReadonlyWhen?: unknown }).uiReadonlyWhen = d.uiReadonlyWhen; + // The EFFECTIVE predicate (objectstack#37402): a child field that declares + // no hand lock of its own carries the child object's whole-record one. + const handLockWhen = effectiveUiReadonlyWhen(d, childSchema); + if (handLockWhen) (col as { uiReadonlyWhen?: unknown }).uiReadonlyWhen = handLockWhen; if (d?.requiredWhen) col.requiredWhen = d.requiredWhen; // A field carrying an arithmetic `expression` (e.g. amount = quantity * // unit_price) becomes a live read-only computed column. The expression may @@ -417,7 +425,7 @@ export function hydrateColumns( if (col.type === 'currency') reportCurrencyColumnScale(col, childSchema?.name, false); // explicit type — respect the author's choice, save the child field's // hand lock, which no authored column may open (objectstack#36806) - return withHandLock(col, (fields as any)[col.name]); + return withHandLock(col, (fields as any)[col.name], childSchema); } const d = (fields as any)[col.name]; if (!d) return col; // unknown field — leave as-is (grid falls back to text) @@ -438,7 +446,7 @@ export function hydrateColumns( } if (type === 'file') applyFileColumnProps(next, d); if (next.readonlyWhen == null && d?.readonlyWhen) next.readonlyWhen = d.readonlyWhen; - Object.assign(next, withHandLock(next, d)); + Object.assign(next, withHandLock(next, d, childSchema)); if (next.requiredWhen == null && d?.requiredWhen) { next.requiredWhen = d.requiredWhen; } @@ -459,11 +467,19 @@ export function hydrateColumns( * cell verdict. Derived columns never list a `uiReadonly` child field * (`deriveInlineGridColumns` skips it); an AUTHORED column may name one, typed * or not, and the lock must hold there too — no server strip stands behind it. + * A child field that declares no hand lock of its own carries the child + * object's `uiReadonlyWhen` instead (the object level of the same model). */ -function withHandLock(col: GridColumn, d: Record | undefined): GridColumn { +function withHandLock( + col: GridColumn, + d: Record | undefined, + childSchema: ChildObjectSchemaLike | undefined, +): GridColumn { if (!d) return col; const lockStatic = d.uiReadonly === true; - const lockWhen = d.uiReadonlyWhen; + // The EFFECTIVE predicate (objectstack#37402): the field's own, else the + // child object's whole-record `uiReadonlyWhen`. + const lockWhen = effectiveUiReadonlyWhen(d, childSchema); if (!lockStatic && lockWhen == null) return col; const next = { ...col } as GridColumn & { uiReadonly?: boolean; uiReadonlyWhen?: unknown }; if (lockStatic) next.uiReadonly = true; diff --git a/ui/packages/plugin-form/src/sectionFields.ts b/ui/packages/plugin-form/src/sectionFields.ts index bea5dff9e07..4c3e3dbca0a 100644 --- a/ui/packages/plugin-form/src/sectionFields.ts +++ b/ui/packages/plugin-form/src/sectionFields.ts @@ -41,7 +41,7 @@ */ import type { FormField } from '@object-ui/types'; -import { evalFieldPredicate, fieldStaticallyReadOnlyByHand, isBlankPredicateText, isExpressionComputedField, type FieldRulePredicate } from '@object-ui/core'; +import { effectiveUiReadonlyWhen, evalFieldPredicate, fieldStaticallyReadOnlyByHand, isBlankPredicateText, isExpressionComputedField, type FieldRulePredicate } from '@object-ui/core'; import { mapFieldTypeToFormType, buildValidationRules, fieldHelpText, withFollowedParentObject, withFormObject } from '@object-ui/fields'; import { withHomeAmountSource } from '@object-ui/i18n'; import { isCreateFormMode, isRequiredInForm } from './schemaDefaults'; @@ -371,8 +371,10 @@ export function fromObjectSchema(fieldName: string, ctx: SectionFieldsContext): visibleWhen: field.visibleWhen, readonlyWhen: field.readonlyWhen, // The hand lock's predicate (`Field.uiReadonlyWhen`): the form renderer - // folds it into the same read-only verdict as `readonlyWhen`. - uiReadonlyWhen: field.uiReadonlyWhen, + // folds it into the same read-only verdict as `readonlyWhen`. The + // EFFECTIVE one: a field that declares no hand lock of its own carries the + // object's whole-record `uiReadonlyWhen` (`effectiveUiReadonlyWhen`). + uiReadonlyWhen: effectiveUiReadonlyWhen(field, ctx.objectSchema), requiredWhen: field.requiredWhen, // A stored field carrying an `expression` is computed by the engine on // every write, so a typed value never stands (objectstack#31759): it draws diff --git a/ui/packages/plugin-gantt/src/ObjectGantt.tsx b/ui/packages/plugin-gantt/src/ObjectGantt.tsx index b83fa9ae809..2bbac5b4e66 100644 --- a/ui/packages/plugin-gantt/src/ObjectGantt.tsx +++ b/ui/packages/plugin-gantt/src/ObjectGantt.tsx @@ -2150,7 +2150,7 @@ export const ObjectGantt: React.FC = ({ // editor, auto-schedule, the conflict reschedule, undo and redo — so the // field hand lock is judged here, over the stored record: a locked field // the write changes refuses it, one it only echoes is left out of it. - const verdict = ganttPatchByHand(patch, stored, objectSchema?.fields as GanttLockDefs, predicateScope); + const verdict = ganttPatchByHand(patch, stored, objectSchema?.fields as GanttLockDefs, objectSchema, predicateScope); if (verdict.kind === 'refused') { refuseLockedWrite(); return; @@ -2213,7 +2213,7 @@ export const ObjectGantt: React.FC = ({ // A link is an edit by hand of the TARGET's dependencies field: its // hand lock over that record refuses it (`ganttPatchByHand`). const target = data.find((r) => String(r.id ?? r._id) === String(targetId)) ?? {}; - if (ganttPatchByHand({ [depField]: nextValue }, target, objectSchema?.fields as GanttLockDefs, predicateScope).kind === 'refused') { + if (ganttPatchByHand({ [depField]: nextValue }, target, objectSchema?.fields as GanttLockDefs, objectSchema, predicateScope).kind === 'refused') { refuseLockedWrite(); return; } diff --git a/ui/packages/plugin-gantt/src/ganttHandLock.ts b/ui/packages/plugin-gantt/src/ganttHandLock.ts index 1ab2681b352..f4746217eb8 100644 --- a/ui/packages/plugin-gantt/src/ganttHandLock.ts +++ b/ui/packages/plugin-gantt/src/ganttHandLock.ts @@ -25,7 +25,7 @@ * judged on the write itself, so every commit path — undo and redo too — * meets it. */ -import { fieldReadOnlyByHand, fieldStaticallyReadOnlyByHand, type FieldHandLockDef } from '@object-ui/core'; +import { fieldReadOnlyByHand, fieldStaticallyReadOnlyByHand, type FieldHandLockDef, type ObjectHandLockDef } from '@object-ui/core'; import type { GanttInteractions } from './GanttView'; /** The field definitions the verdict reads, keyed by field name. */ @@ -86,17 +86,20 @@ function sameStoredValue(next: unknown, stored: unknown): boolean { * record whose value the patch CHANGES refuses the whole patch (the chart puts * the bar back); one the patch leaves unchanged is dropped from it, so an * in-place edit of the title does not send the locked dates it echoes back. + * `object` is the object definition the fields belong to: its `uiReadonlyWhen` + * is the hand lock of every field that declares none of its own. */ export function ganttPatchByHand( patch: Record, stored: Record, defs: GanttLockDefs, + object: ObjectHandLockDef | null | undefined, scope: Record | undefined, ): GanttPatchVerdict { const out: Record = {}; for (const [field, value] of Object.entries(patch)) { const def = defs?.[field]; - if (!fieldReadOnlyByHand(def, stored, { scope, fieldContext: `field '${field}'` })) { + if (!fieldReadOnlyByHand(def, stored, { object, scope, fieldContext: `field '${field}'` })) { out[field] = value; continue; } diff --git a/ui/packages/plugin-grid/src/ObjectGrid.tsx b/ui/packages/plugin-grid/src/ObjectGrid.tsx index 3fc7c45091c..b41293098db 100644 --- a/ui/packages/plugin-grid/src/ObjectGrid.tsx +++ b/ui/packages/plugin-grid/src/ObjectGrid.tsx @@ -1562,6 +1562,7 @@ export const ObjectGrid: React.FC = ({ const kind = cellReadOnlyKind({ fieldDef, row, + object: objectSchema, scope: cellLockScope, fieldWritable: !objectName || resolveFieldAffordance('listInlineEdit', perms, objectName, columnKey), gridEditable, diff --git a/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts b/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts index 1cfe7422e2d..cdf61ae1688 100644 --- a/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts +++ b/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts @@ -20,6 +20,7 @@ import { RICH_TEXT_FIELD_TYPES, hasInCellPanelEditWidget } from '@object-ui/fiel const OPEN: CellReadOnlyInputs = { fieldDef: { type: 'text' }, + object: null, fieldWritable: true, gridEditable: true, objectEditable: true, diff --git a/ui/packages/plugin-grid/src/objectGridCellFacts.ts b/ui/packages/plugin-grid/src/objectGridCellFacts.ts index c2ea864d1ec..333d05f6ab5 100644 --- a/ui/packages/plugin-grid/src/objectGridCellFacts.ts +++ b/ui/packages/plugin-grid/src/objectGridCellFacts.ts @@ -13,7 +13,7 @@ * acts on a cell, never while it draws. */ import { buildValidationRules, RICH_TEXT_FIELD_TYPES } from '@object-ui/fields'; -import { fieldReadOnlyByHand, type FieldHandLockDef } from '@object-ui/core'; +import { fieldReadOnlyByHand, type FieldHandLockDef, type ObjectHandLockDef } from '@object-ui/core'; import { fieldInlineReadOnlyKind } from './inline-edit-options'; /** Why a cell opens no editor, in the order a cell names them. */ @@ -53,6 +53,11 @@ export interface CellReadOnlyInputs { * half is read. */ row?: Record | null; + /** + * The object definition the row belongs to: its `uiReadonlyWhen` is the hand + * lock of every field that declares none of its own. `null` while unknown. + */ + object: ObjectHandLockDef | null | undefined; /** The host's predicate scope (`current_user` and friends), as the edit dialog binds it. */ scope?: Record; /** May this reader write the field (`resolveFieldAffordance('listInlineEdit', …)`)? */ @@ -78,7 +83,7 @@ export function cellReadOnlyKind(inputs: CellReadOnlyInputs): CellReadOnlyKind | const fieldKind = fieldInlineReadOnlyKind(inputs.fieldDef); if (fieldKind) return fieldKind; // The conditional half of the one hand-lock verdict, over this row. - if (inputs.row != null && fieldReadOnlyByHand(inputs.fieldDef, inputs.row, { scope: inputs.scope })) return 'readonly'; + if (inputs.row != null && fieldReadOnlyByHand(inputs.fieldDef, inputs.row, { object: inputs.object, scope: inputs.scope })) return 'readonly'; if (!inputs.fieldWritable) return 'noFieldPermission'; if (!inputs.canUpdate) return 'noPermission'; if (!inputs.objectEditable) return 'objectReadOnly'; diff --git a/ui/packages/plugin-grid/src/objectGridRowLoad.ts b/ui/packages/plugin-grid/src/objectGridRowLoad.ts index 210b2ed107d..da45ec76f54 100644 --- a/ui/packages/plugin-grid/src/objectGridRowLoad.ts +++ b/ui/packages/plugin-grid/src/objectGridRowLoad.ts @@ -12,7 +12,7 @@ import React, { useEffect } from 'react'; import type { ObjectGridSchema, DataSource, DependsOnInput, ViewData } from '@object-ui/types'; import { useDataInvalidation, type OwnWrites } from '@object-ui/react'; import { recordCurrencyReadField } from '@object-ui/i18n'; -import { resolveDependsOnFields, shownQuantityUnitReads, declaredNameField, buildExpandFields, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, isProjectableField, convertSortToQueryParams, normalizeSortEntries, readWithheldFieldNames, refersToWithheldField, type QuerySortEntry } from '@object-ui/core'; +import { resolveDependsOnFields, shownQuantityUnitReads, declaredNameField, buildExpandFields, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, isProjectableField, convertSortToQueryParams, normalizeSortEntries, readWithheldFieldNames, refersToWithheldField, fieldLockPredicates, type FieldHandLockDef, type QuerySortEntry } from '@object-ui/core'; import type { usePermissions } from '@object-ui/permissions'; import { findParamsSignature } from './objectGridQuery'; import { normalizeColumns } from './objectGridColumns'; @@ -450,13 +450,15 @@ export function useObjectGridRowLoad({ // fetched rows without it and CEL faulted `No such key` — open for // `readonlyWhen` (the server drops the write), locked for the hand // lock (nothing behind it judges one). Read them, so each row is - // judged as it is. The same two gates as the harvests above. + // judged as it is. The same two gates as the harvests above. The + // hand lock is the EFFECTIVE one (`fieldLockPredicates`): a field + // that declares none of its own inherits the object's + // `uiReadonlyWhen`, whose operands every such column needs too. const lockOperandFields = declared ? collectPredicateFieldRefs( shownColumns - .map((entry) => (declared as Record)[columnIdentity(entry) ?? '']) - .flatMap((def) => [def?.readonlyWhen, def?.uiReadonlyWhen]) - .filter((pred) => pred != null), + .map((entry) => (declared as Record)[columnIdentity(entry) ?? '']) + .flatMap((def) => fieldLockPredicates(def, resolvedSchema)), ) .filter((f) => isProjectableField(f, declared as Record)) .filter((f) => passesProjectionGate(f)) diff --git a/ui/packages/plugin-kanban/src/ObjectKanban.tsx b/ui/packages/plugin-kanban/src/ObjectKanban.tsx index 67a358ddacb..f578721dd7d 100644 --- a/ui/packages/plugin-kanban/src/ObjectKanban.tsx +++ b/ui/packages/plugin-kanban/src/ObjectKanban.tsx @@ -2342,7 +2342,7 @@ export const ObjectKanban: React.FC = ({ // hand lock `uiReadonlyWhen`): no write, and the card goes back — a fresh // array identity re-buckets the board from the unchanged rows. const laneDef = (objectDef?.fields as Record | undefined> | undefined)?.[groupBy]; - if (fieldReadOnlyByHand(laneDef, record, { fieldContext: `field '${groupBy}'`, scope: predicateScope })) { + if (fieldReadOnlyByHand(laneDef, record, { object: objectDef, fieldContext: `field '${groupBy}'`, scope: predicateScope })) { setFetchedData((prev) => prev.map((r) => r)); return { kind: 'refused', message: tt('grid.readOnlyReason.readonly', 'This field is read-only.') }; } diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index 700c97a247f..0f7f38217d9 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -64,7 +64,7 @@ import { useDensityMode, resolveInlineAriaProps } from '@object-ui/react'; import type { DataTableSchema, DependsOnInput, ListViewSchema, ObjectMapConfig } from '@object-ui/types'; import { AUDIT_FIELD_NAMES, detectStatusField, isSystemManagedField } from '@object-ui/types'; import { usePullToRefresh } from '@object-ui/mobile'; -import { type ListViewVisualization, resolveConditionalFormatting, buildExpandFields, buildExportFileName, resolveAffordance, isObjectExportOffered, type SchemaLike, partitionRowsByPredicate, normalizeListViewSchema, isListViewVisualization, rowHeightToDensityMode, mergeFilterNodes, toFilterNodeSafely, FilterOperatorError, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, PLATFORM_RECORD_COLUMNS, EXPANDABLE_FIELD_TYPES, UNMATERIALIZED_FIELD_TYPES, readObjectSortability, isPlatformSortableField, leadWithNameField, filterPlatformSortableSort, applyNonGridRowCeiling, type NonGridCeilingResult, resolveNameField, declaredNameField, resolveDependsOnFields, GANTT_CONFIG_SPELLING, kanbanDeclaredLanes, csvBlob, readWithheldFieldNames, refersToWithheldField, withHeaderSortPick, shownQuantityUnitReads } from '@object-ui/core'; +import { type ListViewVisualization, resolveConditionalFormatting, buildExpandFields, buildExportFileName, resolveAffordance, isObjectExportOffered, type SchemaLike, partitionRowsByPredicate, normalizeListViewSchema, isListViewVisualization, rowHeightToDensityMode, mergeFilterNodes, toFilterNodeSafely, FilterOperatorError, columnIdentity, collectPredicateFieldRefs, collectGroupingFieldRefs, listViewPredicates, PLATFORM_RECORD_COLUMNS, EXPANDABLE_FIELD_TYPES, UNMATERIALIZED_FIELD_TYPES, readObjectSortability, isPlatformSortableField, leadWithNameField, filterPlatformSortableSort, applyNonGridRowCeiling, type NonGridCeilingResult, resolveNameField, declaredNameField, resolveDependsOnFields, GANTT_CONFIG_SPELLING, kanbanDeclaredLanes, csvBlob, readWithheldFieldNames, refersToWithheldField, withHeaderSortPick, shownQuantityUnitReads, fieldLockPredicates, type FieldHandLockDef } from '@object-ui/core'; import { useObjectLabel, useSafeFieldLabel, createSafeTranslation, useDisplayLocale, pickLocalized, recordCurrencyField, recordCurrencyReadField } from '@object-ui/i18n'; // Two resolvers, two vocabularies — the repo spells the distinction into the // NAMES (objectui#4167). `resolveInlineI18nLabel` is the spec's own @@ -4576,7 +4576,9 @@ export const ListView = React.forwardRef(({ // viewer is never served the predicate either: the definition's FLS // scrub (`@objectstack/metadata-core`) deletes it and serves the // field `uiReadonly: true` in its place, so it stays locked by hand. - const lockDefs = objectDef?.fields as Record | undefined; + // The hand lock is the EFFECTIVE one (`fieldLockPredicates`): a field + // that declares none of its own inherits the object's `uiReadonlyWhen`. + const lockDefs = objectDef?.fields as Record | undefined; const editedInPlace = [ ...cols, kanbanLaneFieldOf(schema, objectDef), @@ -4585,8 +4587,7 @@ export const ListView = React.forwardRef(({ ].filter((name): name is string => typeof name === 'string' && name.length > 0); for (const f of collectPredicateFieldRefs( editedInPlace - .flatMap((name) => [lockDefs?.[name]?.readonlyWhen, lockDefs?.[name]?.uiReadonlyWhen]) - .filter((pred) => pred != null), + .flatMap((name) => fieldLockPredicates(lockDefs?.[name], objectDef)), )) addSpeculative(f); // [objectui#13036] A shown `referenceVia` pointer column's TYPE diff --git a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx index 2964a327229..c9996379fbf 100644 --- a/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx +++ b/ui/packages/plugin-timesheet/src/ObjectTimesheet.tsx @@ -329,6 +329,7 @@ function TimesheetGridView({ schema, objectName, binding, dataSource, className, ); const valueLockedByHand = (record: Record): boolean => fieldReadOnlyByHand(lockDefs?.[binding.valueField], record, { + object: objectSchema, scope: predicateScope, fieldContext: `field '${binding.valueField}'`, }); From a824f8ca6bb93fad3e325f06bc3a6f9ca5fd9149 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:04:22 +0000 Subject: [PATCH 02/15] =?UTF-8?q?feat(spec,ui):=20object-level=20uiReadonl?= =?UTF-8?q?yWhen=20=E2=80=94=20changesets,=20dogfood=20pin,=20regenerated?= =?UTF-8?q?=20references?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../37402-object-ui-readonly-when-lint.md | 10 ++ .../37402-object-ui-readonly-when-mcp.md | 10 ++ ...2-object-ui-readonly-when-metadata-core.md | 10 ++ ...object-ui-readonly-when-plugin-calendar.md | 10 ++ ...2-object-ui-readonly-when-plugin-detail.md | 10 ++ ...402-object-ui-readonly-when-plugin-form.md | 10 ++ ...02-object-ui-readonly-when-plugin-gantt.md | 10 ++ ...402-object-ui-readonly-when-plugin-grid.md | 10 ++ ...2-object-ui-readonly-when-plugin-kanban.md | 10 ++ ...402-object-ui-readonly-when-plugin-list.md | 10 ++ ...bject-ui-readonly-when-plugin-timesheet.md | 10 ++ .../37402-object-ui-readonly-when-runtime.md | 10 ++ .../37402-object-ui-readonly-when-spec.md | 15 ++ .../37402-object-ui-readonly-when-ui-core.md | 11 ++ content/docs/references/api/metadata.mdx | 1 + content/docs/references/data/object.mdx | 1 + content/docs/references/system/migration.mdx | 2 + ...i-readonly-hand-lock-36806.dogfood.test.ts | 129 ++++++++++++++++-- packages/spec/authorable-surface/data.json | 1 + packages/spec/liveness/state-counts/object.md | 2 +- packages/spec/src/data/object.zod.ts | 2 +- 21 files changed, 269 insertions(+), 15 deletions(-) create mode 100644 .changeset/37402-object-ui-readonly-when-lint.md create mode 100644 .changeset/37402-object-ui-readonly-when-mcp.md create mode 100644 .changeset/37402-object-ui-readonly-when-metadata-core.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-calendar.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-detail.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-form.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-gantt.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-grid.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-kanban.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-list.md create mode 100644 .changeset/37402-object-ui-readonly-when-plugin-timesheet.md create mode 100644 .changeset/37402-object-ui-readonly-when-runtime.md create mode 100644 .changeset/37402-object-ui-readonly-when-spec.md create mode 100644 .changeset/37402-object-ui-readonly-when-ui-core.md diff --git a/.changeset/37402-object-ui-readonly-when-lint.md b/.changeset/37402-object-ui-readonly-when-lint.md new file mode 100644 index 00000000000..ce2c75b4b61 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-lint.md @@ -0,0 +1,10 @@ +--- +'@objectstack/lint': patch +--- + +feat(lint): `os validate` checks an object's `uiReadonlyWhen` as it checks a field's + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +The whole-record hand lock has no server judge, so this pass is the only place an author hears about a broken one: it must parse, read the record's own columns as `record.FIELD` (never a bare field), name only declared fields, and read only the roots the field-rule slots bind — the same record-scoped check and root verdict a field's `uiReadonlyWhen` gets, reported at `object 'NAME' uiReadonlyWhen`. diff --git a/.changeset/37402-object-ui-readonly-when-mcp.md b/.changeset/37402-object-ui-readonly-when-mcp.md new file mode 100644 index 00000000000..04de0dce87b --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-mcp.md @@ -0,0 +1,10 @@ +--- +'@objectstack/mcp': patch +--- + +feat(mcp): `describe_object` reports an object's whole-record hand lock (`uiReadonlyWhen`), and its description says how to read it + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +The stdio transport and the `objectstack://objects/{name}` resource answer the object's `uiReadonlyWhen` predicate text at the top level where authored, the twin of the HTTP transport. The tool description names it: while it holds, a person cannot edit any field at the console except one that lists its own `uiReadonly` / `uiReadonlyWhen`; an agent's write may still set every field, judged by the validations. diff --git a/.changeset/37402-object-ui-readonly-when-metadata-core.md b/.changeset/37402-object-ui-readonly-when-metadata-core.md new file mode 100644 index 00000000000..002735289eb --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-metadata-core.md @@ -0,0 +1,10 @@ +--- +'@objectstack/metadata-core': patch +--- + +feat(metadata-core): the field-level-security scrub keeps an object's whole-record hand lock closed for a caller who cannot evaluate it + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +`uiReadonlyWhen` on the object is classified in the object-schema FLS reference table. Where its predicate reads a field denied to the caller, it is served as the constant predicate `true` instead of being deleted: the console fails the hand lock closed and no server judges it, so deleting the predicate would silently open every record for exactly that caller. A field's own `uiReadonlyWhen` still wins over it. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-calendar.md b/.changeset/37402-object-ui-readonly-when-plugin-calendar.md new file mode 100644 index 00000000000..3c74916dbc6 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-calendar.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-calendar': patch +--- + +feat(plugin-calendar): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: an event drag judges the start and end fields against the object's whole-record lock at the drop, through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-detail.md b/.changeset/37402-object-ui-readonly-when-plugin-detail.md new file mode 100644 index 00000000000..fbaa01bc861 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-detail.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-detail': patch +--- + +feat(plugin-detail): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: the record page's inline edit, the highlight-strip chip, the save bar's fill-in and the stage path judge a field against its object's whole-record lock, through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-form.md b/.changeset/37402-object-ui-readonly-when-plugin-form.md new file mode 100644 index 00000000000..408ec7bc7fd --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-form.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-form': patch +--- + +feat(plugin-form): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: the create and edit dialogs' form fields and the line-item grid's columns carry the EFFECTIVE hand-lock predicate (a field's own, else the object's; a child field's own, else the child object's), through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-gantt.md b/.changeset/37402-object-ui-readonly-when-plugin-gantt.md new file mode 100644 index 00000000000..307275f3e8e --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-gantt.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-gantt': patch +--- + +feat(plugin-gantt): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: every Gantt write judges its fields against the object's whole-record lock (`ganttPatchByHand` takes the object definition), through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-grid.md b/.changeset/37402-object-ui-readonly-when-plugin-grid.md new file mode 100644 index 00000000000..f4831116efb --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-grid.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-grid': patch +--- + +feat(plugin-grid): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: a grid cell judges its field against the object's whole-record lock, and the grid's own row load fetches that predicate's operands (`cellReadOnlyKind` takes a required `object`), through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-kanban.md b/.changeset/37402-object-ui-readonly-when-plugin-kanban.md new file mode 100644 index 00000000000..d01b2f63ac4 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-kanban.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-kanban': patch +--- + +feat(plugin-kanban): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: a card drag judges the lane field against the object's whole-record lock at the drop, through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-list.md b/.changeset/37402-object-ui-readonly-when-plugin-list.md new file mode 100644 index 00000000000..7b1f1696f00 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-list.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-list': patch +--- + +feat(plugin-list): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: the list view's `$select` fetches the operands of the object's whole-record lock for every field it edits in place, through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-timesheet.md b/.changeset/37402-object-ui-readonly-when-plugin-timesheet.md new file mode 100644 index 00000000000..641c981c71c --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-plugin-timesheet.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-timesheet': patch +--- + +feat(plugin-timesheet): the object's whole-record hand lock (`uiReadonlyWhen`) holds here + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: a timesheet cell edit judges the value field against the object's whole-record lock, through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-runtime.md b/.changeset/37402-object-ui-readonly-when-runtime.md new file mode 100644 index 00000000000..34e84485407 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-runtime.md @@ -0,0 +1,10 @@ +--- +'@objectstack/runtime': patch +--- + +feat(runtime): MCP `describe_object` reports an object's whole-record hand lock (`uiReadonlyWhen`) + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +The HTTP transport's `describe_object` answer carries the object's `uiReadonlyWhen` predicate text at its top level where the object authors one, so an agent acting for a person knows the record cannot be edited by hand and reaches for an action. Never folded into any field's `readonly`: an agent's write still sets every field, judged by the validations. diff --git a/.changeset/37402-object-ui-readonly-when-spec.md b/.changeset/37402-object-ui-readonly-when-spec.md new file mode 100644 index 00000000000..84c4b9e1b5a --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-spec.md @@ -0,0 +1,15 @@ +--- +'@objectstack/spec': minor +--- + +feat(spec): an object declares when a whole record is read-only by hand (`uiReadonlyWhen` on the object) + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +A confirmed order, a posted invoice or a closed ticket is locked as a whole, and writing a `uiReadonlyWhen` on every field was both tedious and easy to get wrong by missing one. The object now carries the hand lock's object level: + +- **`ObjectSchema.uiReadonlyWhen`** (CEL over the record's own columns, the same scope as a field's `readonlyWhen`), e.g. `uiReadonlyWhen: P\`record.status in ['confirmed', 'done']\``. While TRUE no person edits any field of an existing record on the console surfaces a field's own `uiReadonlyWhen` locks. A create is not judged. +- **A field's own declaration wins.** A field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead of the object default, in both directions: `uiReadonlyWhen: P\`false\`` keeps a field (notes, internal tags) editable inside a locked record, and a field's own predicate can lock it where the object does not. A field's server lock (`readonly`, `readonlyWhen`) is not a hand-lock declaration and keeps locking on its own. +- **Every write keeps every field.** The engine never reads the key: REST, import, declarative and script actions and flows write a locked record, judged by the object's validations, and nothing is dropped from the write (`X-ObjectStack-Dropped-Fields` stays absent). +- A predicate the console cannot evaluate locks every field that inherits it, as at the field level; `os validate` checks it. Liveness row `object.uiReadonlyWhen` (live), the Studio object form's Advanced section offers it as a CEL row, and the reference docs, authorable-surface record and state counts are regenerated. diff --git a/.changeset/37402-object-ui-readonly-when-ui-core.md b/.changeset/37402-object-ui-readonly-when-ui-core.md new file mode 100644 index 00000000000..1ff4d5147db --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-ui-core.md @@ -0,0 +1,11 @@ +--- +'@object-ui/core': minor +--- + +feat(core): the one hand-lock verdict folds an object's whole-record `uiReadonlyWhen`, and asks every caller for the object + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +- `fieldReadOnlyByHand(def, record, context)` now takes the object definition in a REQUIRED `context.object` (pass `null` only where a surface has none), and so does `fieldHasConditionalHandLock(def, object)`: a caller that forgot the object would silently open a locked record. The record and context arguments are required too (pass `null` for no record). Migration: add `{ object: objectDef }` to the context of every call. These helpers have not been published yet (they first ship in this prerelease line, after `19.0.0-next.0`), so no released caller breaks. +- New `effectiveUiReadonlyWhen(def, object)` — the field's own `uiReadonlyWhen` when it declares a hand lock of its own (`uiReadonly` or `uiReadonlyWhen`, any value), else the object's — and `fieldLockPredicates(def, object)`, the predicates whose operands a surface fetches before it judges a row. New type `ObjectHandLockDef`. diff --git a/content/docs/references/api/metadata.mdx b/content/docs/references/api/metadata.mdx index 5a6df280ec4..ff919311dd9 100644 --- a/content/docs/references/api/metadata.mdx +++ b/content/docs/references/api/metadata.mdx @@ -962,6 +962,7 @@ Metadata query with filtering, sorting, and pagination | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index 63bced317b6..3cdbb673d71 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -171,6 +171,7 @@ const result = ApiMethod.parse(data); | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/system/migration.mdx b/content/docs/references/system/migration.mdx index eb4e86d1ad8..77c8cfa3e2a 100644 --- a/content/docs/references/system/migration.mdx +++ b/content/docs/references/system/migration.mdx @@ -356,6 +356,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | @@ -665,6 +666,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts b/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts index d674ff6e48d..143e720f58a 100644 --- a/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts +++ b/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts @@ -17,10 +17,17 @@ // submits, since a hand-locked field is never in its payload) lands on the // field's `defaultValue`, and an API create outside `initialStates` is // refused by the machine, not by the lock. +// +// [#37402] The object level of the same model: an object whose +// `uiReadonlyWhen` locks a whole confirmed record by hand, with one field +// (`notes`) that overrides it with its own `uiReadonlyWhen: P\`false\``. The +// engine reads neither key, so on a confirmed record a PATCH, an import update +// and a declarative action still write, judged by the machine, and nothing is +// dropped; the served definition carries the predicate the console folds. import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { bootStack, type VerifyStack } from '@objectstack/verify'; -import { defineStack } from '@objectstack/spec'; +import { defineStack, P } from '@objectstack/spec'; import { ObjectSchema, Field } from '@objectstack/spec/data'; const OBJ = 'hlk_order'; @@ -57,6 +64,38 @@ const order = ObjectSchema.create({ ], } as never); +const LOCKED = 'hlo_order'; +const LOCKED_MESSAGE = 'An order moves draft, then confirmed, then done.'; + +const lockedOrder = ObjectSchema.create({ + name: LOCKED, + label: 'Locked order', + pluralLabel: 'Locked orders', + uiReadonlyWhen: P`record.status in ['confirmed', 'done']`, + fields: { + name: Field.text({ label: 'Name', required: true }), + status: { + ...Field.select(['draft', 'confirmed', 'done'], { label: 'Status' }), + defaultValue: 'draft', + }, + amount: Field.number({ label: 'Amount' }), + notes: { ...Field.text({ label: 'Notes' }), uiReadonlyWhen: P`false` }, + }, + validations: [ + { + type: 'state_machine', + name: 'hlo_order_flow', + message: LOCKED_MESSAGE, + field: 'status', + initialStates: ['draft'], + transitions: { draft: ['confirmed'], confirmed: ['done'], done: [] }, + }, + ], + actions: [ + { name: 'hlo_finish', label: 'Finish', objectName: LOCKED, operation: 'update', patch: { status: 'done', amount: 99 } }, + ], +} as never); + const stackConfig = defineStack({ manifest: { id: 'com.dogfood.ui-readonly-hand-lock', @@ -66,12 +105,23 @@ const stackConfig = defineStack({ name: 'Hand Lock Fixture', description: 'One object whose status is locked by hand at the console and judged by a state machine on every write.', }, - objects: [order], + objects: [order, lockedOrder], } as never); +// One booted stack for both describes below (the field level and the object level). +let stack: VerifyStack; +let admin = ''; + +beforeAll(async () => { + stack = await bootStack(stackConfig as never); + admin = await stack.signIn(); +}, 240_000); + +afterAll(async () => { + await stack?.stop?.(); +}); + describe('[#36806] a uiReadonly field keeps every write path, judged by the validations', () => { - let stack: VerifyStack; - let admin = ''; const create = async (name: string): Promise => { const res = await stack.apiAs(admin, 'POST', `/data/${OBJ}`, { name }); @@ -91,15 +141,6 @@ describe('[#36806] a uiReadonly field keeps every write path, judged by the vali return id; }; - beforeAll(async () => { - stack = await bootStack(stackConfig as never); - admin = await stack.signIn(); - }, 240_000); - - afterAll(async () => { - await stack?.stop?.(); - }); - it('a create that leaves the hand-locked field out lands on its defaultValue', async () => { const id = await create('hlk default'); expect(await statusOf(id)).toBe('draft'); @@ -170,3 +211,65 @@ describe('[#36806] a uiReadonly field keeps every write path, judged by the vali expect({ status: res.status, code }, JSON.stringify(body)).toEqual({ status: 400, code: 'VALIDATION_FAILED' }); }); }); + +describe('[#37402] an object-level uiReadonlyWhen keeps every write path on a locked record', () => { + const create = async (name: string): Promise => { + const res = await stack.apiAs(admin, 'POST', `/data/${LOCKED}`, { name, amount: 1, notes: 'n' }); + expect(res.status, await res.clone().text()).toBe(201); + return idOf(await res.json()); + }; + const read = async (id: string) => + recordOf(await (await stack.apiAs(admin, 'GET', `/data/${LOCKED}/${id}`)).json()); + /** A fresh order moved to `confirmed` — the state the object's hand lock holds. */ + const confirmed = async (name: string): Promise => { + const id = await create(name); + const res = await stack.apiAs(admin, 'PATCH', `/data/${LOCKED}/${id}`, { status: 'confirmed' }); + expect(res.status, await res.clone().text()).toBe(200); + expect((await read(id)).status).toBe('confirmed'); + return id; + }; + + it('the served definition carries the object predicate and the field override the console folds', async () => { + const res = await stack.apiAs(admin, 'GET', `/meta/object/${LOCKED}`); + expect(res.status).toBe(200); + const item: any = ((await res.json()) as { item?: unknown }).item; + const source = (p: unknown) => (typeof p === 'string' ? p : (p as { source?: string } | undefined)?.source); + expect(source(item?.uiReadonlyWhen)).toBe("record.status in ['confirmed', 'done']"); + expect(source(item?.fields?.notes?.uiReadonlyWhen)).toBe('false'); + }); + + it('a PATCH to a confirmed record writes every field and drops none', async () => { + const id = await confirmed('hlo patch'); + const res = await stack.apiAs(admin, 'PATCH', `/data/${LOCKED}/${id}`, { amount: 7, notes: 'changed', name: 'hlo patched' }); + const body: any = await res.json(); + expect(res.status, JSON.stringify(body)).toBe(200); + expect(res.headers.get('X-ObjectStack-Dropped-Fields')).toBeNull(); + expect(body?.droppedFields, JSON.stringify(body?.droppedFields)).toBeUndefined(); + expect(await read(id)).toMatchObject({ amount: 7, notes: 'changed', name: 'hlo patched', status: 'confirmed' }); + }); + + it('an import update on a confirmed record writes, and the machine still judges the lifecycle field', async () => { + const id = await confirmed('hlo import'); + const refused = await confirmed('hlo import refused'); + const res = await stack.apiAs(admin, 'POST', `/data/${LOCKED}/import`, { + format: 'json', + writeMode: 'update', + matchFields: ['id'], + rows: [{ id, amount: 42 }, { id: refused, status: 'draft' }], + }); + const report: any = await res.json(); + expect(res.status, JSON.stringify(report)).toBe(200); + expect(report.results?.[0]?.ok, JSON.stringify(report.results)).toBe(true); + expect(report.results?.[1]?.ok, JSON.stringify(report.results)).toBe(false); + expect(JSON.stringify(report.results?.[1])).toContain(LOCKED_MESSAGE); + expect((await read(id)).amount).toBe(42); + expect((await read(refused)).status).toBe('confirmed'); + }); + + it('a declarative action on a confirmed record writes the fields it patches', async () => { + const id = await confirmed('hlo action'); + const res = await stack.apiAs(admin, 'POST', `/actions/${LOCKED}/hlo_finish`, { recordId: id }); + expect(res.status, await res.clone().text()).toBe(200); + expect(await read(id)).toMatchObject({ status: 'done', amount: 99 }); + }); +}); diff --git a/packages/spec/authorable-surface/data.json b/packages/spec/authorable-surface/data.json index 2006cbdea15..07c0cb93ecb 100644 --- a/packages/spec/authorable-surface/data.json +++ b/packages/spec/authorable-surface/data.json @@ -722,6 +722,7 @@ "data/Object:systemFields", "data/Object:tenancy", "data/Object:titleFormat", + "data/Object:uiReadonlyWhen", "data/Object:userActions", "data/Object:validations", "data/ObjectAccessConfig:default", diff --git a/packages/spec/liveness/state-counts/object.md b/packages/spec/liveness/state-counts/object.md index bd9976320f9..a51975c0ba9 100644 --- a/packages/spec/liveness/state-counts/object.md +++ b/packages/spec/liveness/state-counts/object.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `object` | 94 | 0 | 0 | 1 | 1 | 96 | +| `object` | 95 | 0 | 0 | 1 | 1 | 97 | diff --git a/packages/spec/src/data/object.zod.ts b/packages/spec/src/data/object.zod.ts index 820fac141ac..4f221b0b8b9 100644 --- a/packages/spec/src/data/object.zod.ts +++ b/packages/spec/src/data/object.zod.ts @@ -4770,7 +4770,7 @@ const ObjectSchemaBase = strictObject( * reports it. The engine never reads it: a TRUE predicate refuses no REST, * import, action or flow write, and drops nothing from one. */ - uiReadonlyWhen: EvaluatedExpressionInputSchema.optional().describe("Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key."), + uiReadonlyWhen: EvaluatedExpressionInputSchema.optional().describe("Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key."), /** * Display & UI Hints (Data-Layer) From 36f03269a9a367d9863b70f7aa5699e5e8663f52 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:09:23 +0000 Subject: [PATCH 03/15] feat(platform-objects): translate the object form's uiReadonlyWhen row Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../37402-object-ui-readonly-when-platform-objects.md | 10 ++++++++++ .../apps/translations/ar.metadata-forms.generated.ts | 4 ++++ .../apps/translations/de.metadata-forms.generated.ts | 4 ++++ .../apps/translations/en.metadata-forms.generated.ts | 4 ++++ .../translations/es-ES.metadata-forms.generated.ts | 4 ++++ .../apps/translations/fr.metadata-forms.generated.ts | 4 ++++ .../translations/ja-JP.metadata-forms.generated.ts | 4 ++++ .../apps/translations/ko.metadata-forms.generated.ts | 4 ++++ .../object-lifecycle-panel-echo-decisions.test.ts | 4 +++- .../translations/pt-BR.metadata-forms.generated.ts | 4 ++++ .../apps/translations/ru.metadata-forms.generated.ts | 4 ++++ .../translations/zh-CN.metadata-forms.generated.ts | 4 ++++ .../translations/zh-Hant.metadata-forms.generated.ts | 4 ++++ 13 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .changeset/37402-object-ui-readonly-when-platform-objects.md diff --git a/.changeset/37402-object-ui-readonly-when-platform-objects.md b/.changeset/37402-object-ui-readonly-when-platform-objects.md new file mode 100644 index 00000000000..8a997b4dd82 --- /dev/null +++ b/.changeset/37402-object-ui-readonly-when-platform-objects.md @@ -0,0 +1,10 @@ +--- +'@objectstack/platform-objects': patch +--- + +feat(platform-objects): the Studio object form's whole-record hand-lock row is translated in every metadata-forms locale pack + +Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) +Metadata-protocol: added + +The object form's Advanced section offers `uiReadonlyWhen` (the object level of the field hand lock); its label and help text are authored in all eleven metadata-forms locale packs, the generator re-run after the leaf values so no fill hash is left. diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index ccbc22fcc41..50ba0c37013 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const arMetadataForms: NonNullable = { label: "قواعد التحقق", helpText: "قواعد التحقق على مستوى الكائن — مصفوفة من كائنات القواعد، مثل [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. وتُعلَن هنا أيضًا جداول انتقالات آلة الحالة (ADR-0020)" }, + uiReadonlyWhen: { + label: "السجل كله للقراءة فقط في الواجهة عندما", + helpText: "شرط CEL على السجل (مثل record.status in ['confirmed', 'done']) — ما دام TRUE لا يستطيع أحد تعديل أي حقل من سجل موجود في وحدة التحكم (مربع حوار التعديل، صفحة السجل، الجداول، كانبان، السحب في التقويم ومخطط جانت، جدول الدوام)؛ ولا يُقيَّم مربع حوار إنشاء سجل جديد. الحقل الذي يعلن قفله اليدوي الخاص (uiReadonly أو uiReadonlyWhen) يُحكم عليه بإعلانه، لذا فإن uiReadonlyWhen: false على حقل يبقيه قابلاً للتعديل. تستمر الإجراءات والاستيراد وواجهة API والتدفقات في كتابة كل حقل، وتحكم عليها قواعد التحقق للكائن. يقرأ أعمدة السجل نفسه. المساعد داخل التطبيق الذي يعمل نيابة عن شخص لا يلتزم بهذا بعد." + }, activityMilestones: { label: "معالم النشاط", helpText: "إدخالات في الخط الزمني يُطلقها وصول حقل إلى قيمة (ADR-0052 §5b.2): عندما ينقل تحديثٌ الحقلَ المراقَب إلى القيمة، يكتب مكوّن التدقيق الإضافي ملخّص المَعلم في الخط الزمني لنشاط السجل بدلًا من إدخال تغيير الحقل. يفوز أول مَعلم يطابق." diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index 873ac240c5f..58b8a2b5de7 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const deMetadataForms: NonNullable = { label: "Validierungen", helpText: "Validierungsregeln auf Objektebene – ein Array von Regelobjekten, z. B. [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. Übergangstabellen von Zustandsautomaten werden ebenfalls hier deklariert (ADR-0020)" }, + uiReadonlyWhen: { + label: "Ganzer Datensatz in der Oberfläche schreibgeschützt wenn", + helpText: "CEL-Prädikat über den Datensatz (z. B. record.status in ['confirmed', 'done']) – solange es TRUE ist, kann niemand in der Konsole ein Feld eines bestehenden Datensatzes bearbeiten (Bearbeitungsdialog, Datensatzseite, Tabellen, Kanban, Kalender- und Gantt-Ziehen, Zeiterfassung); der Erstellungsdialog eines neuen Datensatzes wird nicht geprüft. Ein Feld, das eine eigene manuelle Sperre (uiReadonly oder uiReadonlyWhen) festlegt, wird stattdessen danach beurteilt, sodass uiReadonlyWhen: false an einem Feld es bearbeitbar hält. Aktionen, Importe, die API und Flows schreiben weiterhin jedes Feld, beurteilt durch die Validierungen des Objekts. Liest die eigenen Spalten des Datensatzes. Der In-App-Assistent, der für eine Person handelt, beachtet dies noch nicht." + }, activityMilestones: { label: "Aktivitätsmeilensteine", helpText: "Zeitleisteneinträge, die ausgelöst werden, wenn ein Feld einen Wert erreicht (ADR-0052 §5b.2): Wenn eine Aktualisierung das beobachtete Feld auf den Wert setzt, schreibt das Audit-Plugin die Zusammenfassung des Meilensteins statt des Feldänderungseintrags in die Aktivitätszeitleiste des Datensatzes. Der erste passende Meilenstein gewinnt." diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index 33ef019670b..ceac3ff2712 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const enMetadataForms: NonNullable = { label: "Validations", helpText: "Object-level validation rules — an array of rule objects, e.g. [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. State-machine transition tables are declared here too (ADR-0020)" }, + uiReadonlyWhen: { + label: "Ui Readonly When", + helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." + }, activityMilestones: { label: "Activity Milestones", helpText: "Timeline entries fired by a field reaching a value (ADR-0052 §5b.2): when an update moves the watched field into the value, the audit plugin writes the milestone's summary to the record's activity timeline instead of the field-change entry. The first milestone that matches wins." diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index 4313e9643bc..44c1ddb02fe 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const esESMetadataForms: NonNullable = label: "Validaciones", helpText: "Reglas de validación a nivel de objeto — un array de objetos de regla, p. ej. [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. Las tablas de transición de máquinas de estado también se declaran aquí (ADR-0020)" }, + uiReadonlyWhen: { + label: "Condición de solo lectura en la interfaz para todo el registro", + helpText: "Predicado CEL sobre el registro (p. ej. record.status in ['confirmed', 'done']): mientras sea TRUE, nadie puede editar ningún campo de un registro existente en la consola (el diálogo de edición, la página del registro, las cuadrículas, el kanban, el arrastre del calendario y del Gantt, la hoja de horas); el diálogo de creación de un registro nuevo no se evalúa. Un campo que declara su propio bloqueo manual (uiReadonly o uiReadonlyWhen) se juzga por él, así que uiReadonlyWhen: false en un campo lo mantiene editable. Las acciones, las importaciones, la API y los flujos siguen escribiendo todos los campos, juzgados por las validaciones del objeto. Lee las columnas propias del registro. El asistente integrado que actúa por una persona aún no lo respeta." + }, activityMilestones: { label: "Hitos de actividad", helpText: "Entradas de la cronología que se disparan cuando un campo alcanza un valor (ADR-0052 §5b.2): cuando una actualización cambia el campo vigilado a ese valor, el plugin de auditoría escribe el resumen del hito en la cronología de actividad del registro en lugar de la entrada de cambio de campo. Gana el primer hito que coincide." diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index 83ec352622b..d84a3ffc7ff 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const frMetadataForms: NonNullable = { label: "Validations", helpText: "Règles de validation au niveau de l’objet — un tableau d’objets de règle, par ex. [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. Les tables de transition des machines à états sont également déclarées ici (ADR-0020)" }, + uiReadonlyWhen: { + label: "Enregistrement entier en lecture seule dans l'interface si", + helpText: "Prédicat CEL sur l'enregistrement (par ex. record.status in ['confirmed', 'done']) — tant qu'il est TRUE, personne ne peut modifier un champ d'un enregistrement existant dans la console (boîte de dialogue de modification, page de l'enregistrement, grilles, kanban, glisser-déposer du calendrier et du Gantt, feuille de temps) ; la boîte de dialogue de création d'un nouvel enregistrement n'est pas évaluée. Un champ qui déclare son propre verrou manuel (uiReadonly ou uiReadonlyWhen) est jugé par celui-ci, donc uiReadonlyWhen: false sur un champ le garde modifiable. Les actions, les imports, l'API et les flux écrivent toujours chaque champ, jugés par les validations de l'objet. Lit les colonnes propres de l'enregistrement. L'assistant intégré agissant pour une personne ne le respecte pas encore." + }, activityMilestones: { label: "Jalons d’activité", helpText: "Entrées de chronologie déclenchées lorsqu’un champ atteint une valeur (ADR-0052 §5b.2) : lorsqu’une mise à jour fait passer le champ surveillé à cette valeur, le plugin d’audit écrit le résumé du jalon dans la chronologie d’activité de l’enregistrement au lieu de l’entrée de modification de champ. Le premier jalon qui correspond l’emporte." diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index 708be7fbf21..d09b4f9e684 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const jaJPMetadataForms: NonNullable = label: "検証ルール", helpText: "オブジェクトレベルの検証ルール — ルールオブジェクトの配列。例: [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]。ステートマシンの遷移テーブルもここで宣言します(ADR-0020)" }, + uiReadonlyWhen: { + label: "レコード全体を画面上で読み取り専用にする条件", + helpText: "レコードに対する CEL 述語(例: record.status in ['confirmed', 'done'])。TRUE の間、コンソールのどこでも既存レコードのどのフィールドも人が編集できません(編集ダイアログ、レコードページ、グリッド、カンバン、カレンダーとガントのドラッグ、タイムシート)。新規レコードの作成ダイアログは判定されません。独自の手動ロック(uiReadonly または uiReadonlyWhen)を宣言したフィールドはその宣言で判定されるため、フィールドに uiReadonlyWhen: false を設定すると編集可能なままになります。アクション、インポート、API、フローは引き続きすべてのフィールドに書き込み、オブジェクトの検証ルールで判定されます。レコード自身の列を読み取ります。ユーザーの代わりに操作するアプリ内アシスタントはまだこの設定に従いません。" + }, activityMilestones: { label: "アクティビティのマイルストーン", helpText: "フィールドが特定の値に達したときに書き込まれるタイムラインのエントリ(ADR-0052 §5b.2)。更新で監視対象のフィールドがその値に変わると、監査プラグインはフィールド変更のエントリの代わりに、マイルストーンの概要をレコードのアクティビティタイムラインに書き込みます。最初に一致したマイルストーンが使われます。" diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index 730b6ee3f33..7e6d51f3698 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const koMetadataForms: NonNullable = { label: "유효성 검사", helpText: "객체 수준 유효성 검사 규칙으로, 규칙 객체의 배열입니다. 예: [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. 상태 머신 전이 표도 여기에 선언합니다(ADR-0020)" }, + uiReadonlyWhen: { + label: "레코드 전체를 화면에서 읽기 전용으로 하는 조건", + helpText: "레코드에 대한 CEL 조건식(예: record.status in ['confirmed', 'done']) — TRUE인 동안 콘솔 어디에서도 기존 레코드의 어떤 필드도 사람이 편집할 수 없습니다(편집 대화상자, 레코드 페이지, 그리드, 칸반, 캘린더와 간트 드래그, 타임시트). 새 레코드의 생성 대화상자는 판정하지 않습니다. 자체 수동 잠금(uiReadonly 또는 uiReadonlyWhen)을 선언한 필드는 그 선언으로 판정되므로, 필드에 uiReadonlyWhen: false를 두면 편집 가능한 상태로 유지됩니다. 작업, 가져오기, API, 플로는 여전히 모든 필드에 쓰며 객체의 검증 규칙이 판정합니다. 레코드 자체의 열을 읽습니다. 사용자를 대신해 작업하는 앱 내 어시스턴트는 아직 이 설정을 따르지 않습니다." + }, activityMilestones: { label: "활동 마일스톤", helpText: "필드가 특정 값에 도달하면 발생하는 타임라인 항목입니다(ADR-0052 §5b.2). 업데이트로 감시 대상 필드가 그 값으로 바뀌면, 감사 플러그인이 필드 변경 항목 대신 마일스톤의 요약을 레코드 활동 타임라인에 기록합니다. 처음 일치하는 마일스톤이 우선합니다." diff --git a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts index 51145085029..94e1c7613a2 100644 --- a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts @@ -1350,7 +1350,9 @@ describe('#19403 round 10 — the verdicts, on the live bundles', () => { // all three locales. // 845 since #37304: the `knowledge_source` type's own label (ADR-0161 // K4), authored in every locale. - expect(translated.length, `${locale} positive control`).toBe(845); + // 846 since #37402: the object form's `uiReadonlyWhen` row (the + // whole-record hand lock), authored in every locale. + expect(translated.length, `${locale} positive control`).toBe(846); } // ⭐ DARK — the blindness, executable. On a synthetic two-locale catalog the // all-three predicate returns 0 while the per-locale one returns 1, so the diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 9267e8c6e7a..61ef466078c 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const ptBRMetadataForms: NonNullable = label: "Validações", helpText: "Regras de validação no nível do objeto — um array de objetos de regra, por exemplo [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. As tabelas de transição de máquinas de estado também são declaradas aqui (ADR-0020)" }, + uiReadonlyWhen: { + label: "Registro inteiro somente leitura na interface quando", + helpText: "Predicado CEL sobre o registro (por exemplo, record.status in ['confirmed', 'done']) — enquanto for TRUE, ninguém pode editar nenhum campo de um registro existente no console (o diálogo de edição, a página do registro, grades, kanban, arrastar no calendário e no Gantt, a planilha de horas); o diálogo de criação de um novo registro não é avaliado. Um campo que declara seu próprio bloqueio manual (uiReadonly ou uiReadonlyWhen) é julgado por ele, então uiReadonlyWhen: false em um campo o mantém editável. Ações, importações, a API e fluxos continuam gravando todos os campos, julgados pelas validações do objeto. Lê as colunas do próprio registro. O assistente no aplicativo que age por uma pessoa ainda não respeita isso." + }, activityMilestones: { label: "Marcos de atividade", helpText: "Entradas da linha do tempo disparadas quando um campo atinge um valor (ADR-0052 §5b.2): quando uma atualização leva o campo observado para o valor, o plugin de auditoria grava o resumo do marco na linha do tempo de atividades do registro em vez da entrada de alteração de campo. O primeiro marco correspondente vence." diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index 4c2ba1d6c74..f4fb166e67e 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const ruMetadataForms: NonNullable = { label: "Проверки", helpText: "Правила проверки уровня объекта — массив объектов правил, например [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]. Здесь же объявляются таблицы переходов конечного автомата (ADR-0020)" }, + uiReadonlyWhen: { + label: "Вся запись только для чтения в интерфейсе, когда", + helpText: "Предикат CEL над записью (например, record.status in ['confirmed', 'done']) — пока он TRUE, никто не может изменить ни одно поле существующей записи в консоли (диалог редактирования, страница записи, таблицы, канбан, перетаскивание в календаре и диаграмме Ганта, табель); диалог создания новой записи не проверяется. Поле, объявившее собственную ручную блокировку (uiReadonly или uiReadonlyWhen), оценивается по ней, поэтому uiReadonlyWhen: false у поля оставляет его редактируемым. Действия, импорт, API и потоки по-прежнему записывают каждое поле, и их оценивают проверки объекта. Читает собственные столбцы записи. Встроенный помощник, действующий от имени человека, пока это не учитывает." + }, activityMilestones: { label: "Вехи активности", helpText: "Записи ленты, создаваемые, когда поле достигает значения (ADR-0052 §5b.2): когда обновление переводит отслеживаемое поле в это значение, плагин аудита записывает в ленту активности записи сводку вехи вместо записи об изменении поля. Побеждает первая подходящая веха." diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index f4a06890fdd..322e5b1b69a 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const zhCNMetadataForms: NonNullable = label: "校验规则", helpText: "对象级校验规则——由规则对象组成的数组,例如 [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]。状态机转移表也在此声明(ADR-0020)" }, + uiReadonlyWhen: { + label: "记录界面只读条件", + helpText: "基于记录的 CEL 谓词(例如 record.status in ['confirmed', 'done'])——为 TRUE 时,用户无法在控制台中编辑已有记录的任何字段(编辑对话框、记录页、表格、看板、日历和甘特图拖动、工时表);新建记录的创建对话框不做判断。自行声明了手动锁定(uiReadonly 或 uiReadonlyWhen)的字段按其自身声明裁决,因此字段上的 uiReadonlyWhen: false 可让它保持可编辑。动作、导入、API 和流程仍可写入每个字段,并由对象的校验规则裁决。读取记录自身的列。代表用户操作的应用内助手暂不遵循此设置。" + }, activityMilestones: { label: "活动里程碑", helpText: "由字段到达某个值触发的时间线条目(ADR-0052 §5b.2):当一次更新把被监视的字段变为该值时,审计插件会把该里程碑的摘要写入记录的活动时间线,代替字段变更条目。第一个匹配的里程碑生效。" diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index 837d956894a..4fa40149e3a 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -425,6 +425,10 @@ export const zhHantMetadataForms: NonNullable label: "驗證規則", helpText: "物件級驗證規則——由規則物件組成的陣列,例如 [{ \"type\": \"script\", \"name\": \"amount_positive\", \"condition\": \"amount > 0\", \"message\": \"Amount must be positive\" }]。狀態機轉移表也在此宣告(ADR-0020)" }, + uiReadonlyWhen: { + label: "記錄介面唯讀條件", + helpText: "基於記錄的 CEL 述詞(例如 record.status in ['confirmed', 'done'])——為 TRUE 時,使用者無法在主控台中編輯既有記錄的任何欄位(編輯對話框、記錄頁、表格、看板、行事曆與甘特圖拖曳、工時表);新記錄的建立對話框不做判斷。自行宣告了手動鎖定(uiReadonly 或 uiReadonlyWhen)的欄位依其自身宣告裁決,因此欄位上的 uiReadonlyWhen: false 可讓它保持可編輯。動作、匯入、API 與流程仍可寫入每個欄位,並由物件的驗證規則裁決。讀取記錄自身的欄。代表使用者操作的應用程式內助理暫不遵循此設定。" + }, activityMilestones: { label: "活動里程碑", helpText: "由欄位到達某個值觸發的時間軸條目(ADR-0052 §5b.2):當一次更新把被監視的欄位變為該值時,稽核外掛會把該里程碑的摘要寫入記錄的活動時間軸,代替欄位變更條目。第一個比對的里程碑生效。" From 0228594f36a02feded2e77b6f09c8bf64afda855 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:11:18 +0000 Subject: [PATCH 04/15] docs(spec): regenerate references for the object-level uiReadonlyWhen describe Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- content/docs/references/api/metadata.mdx | 2 +- content/docs/references/data/object.mdx | 2 +- content/docs/references/system/migration.mdx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/content/docs/references/api/metadata.mdx b/content/docs/references/api/metadata.mdx index ff919311dd9..ccb23ecc761 100644 --- a/content/docs/references/api/metadata.mdx +++ b/content/docs/references/api/metadata.mdx @@ -962,7 +962,7 @@ Metadata query with filtering, sorting, and pagination | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index 3cdbb673d71..b9b4c5697b7 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -171,7 +171,7 @@ const result = ApiMethod.parse(data); | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/system/migration.mdx b/content/docs/references/system/migration.mdx index 77c8cfa3e2a..39f79e4f53a 100644 --- a/content/docs/references/system/migration.mdx +++ b/content/docs/references/system/migration.mdx @@ -356,7 +356,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | @@ -666,7 +666,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so `uiReadonlyWhen: P`false`` on a field keeps it editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | From f5aec614d84d15310152b869661041c9ee4b9a89 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:16:53 +0000 Subject: [PATCH 05/15] test(lint): the object read surface now reads uiReadonlyWhen Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- packages/lint/src/validate-expressions.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/lint/src/validate-expressions.test.ts b/packages/lint/src/validate-expressions.test.ts index e70389bf5ec..4065e724633 100644 --- a/packages/lint/src/validate-expressions.test.ts +++ b/packages/lint/src/validate-expressions.test.ts @@ -4288,7 +4288,8 @@ const READ_SURFACES: Array<{ receiver: string; expected: string[]; declaredBy: s // `listViews` joined with #24798: an object's own list views carry bulk // defs whose `confirmText` is judged. // `fieldGroups` joined with #26646: each group's section predicate. - expected: ['actions', 'attachedOnRead', 'fieldGroups', 'fields', 'listViews', 'name', 'validations'], + // `uiReadonlyWhen` joined with #37402: the whole-record hand lock's predicate. + expected: ['actions', 'attachedOnRead', 'fieldGroups', 'fields', 'listViews', 'name', 'uiReadonlyWhen', 'validations'], declaredBy: 'ObjectSchema', keys: () => Object.keys(ObjectSchema.shape), }, From 6ce7aa650f8f804f473a61c7529c4b6e04470a4b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:18:33 +0000 Subject: [PATCH 06/15] test(ui): pin the object-level hand lock on the dialog fields, line items, edit lock, grid and kanban Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../src/utils/editFormLockedByState.test.ts | 26 +++++++++++ .../__tests__/dialogHandLock-36806.test.ts | 46 +++++++++++++++++++ .../lockOperandProjection-36806.test.tsx | 26 +++++++++++ ...objectGridCellFacts.handLock-36806.test.ts | 21 +++++++++ .../src/ObjectKanban.handLock-36806.test.tsx | 30 ++++++++++-- 5 files changed, 145 insertions(+), 4 deletions(-) diff --git a/ui/packages/app-shell/src/utils/editFormLockedByState.test.ts b/ui/packages/app-shell/src/utils/editFormLockedByState.test.ts index 94ebdb9571d..844fa387267 100644 --- a/ui/packages/app-shell/src/utils/editFormLockedByState.test.ts +++ b/ui/packages/app-shell/src/utils/editFormLockedByState.test.ts @@ -92,3 +92,29 @@ describe('editFormLockedByState (objectstack#32756)', () => { expect(editFormLockedByState(locked, null)).toBe(false); }); }); + +/** + * #37402 — the object-level hand lock is the record's state too: an object + * whose `uiReadonlyWhen` holds greys Edit when it locks every drawn field, and + * a field that overrides it (`uiReadonlyWhen: 'false'`) keeps Edit live. + */ +describe('editFormLockedByState reads the object-level uiReadonlyWhen (#37402)', () => { + const CONFIRMED = { id: 'o1', status: 'confirmed', amount: 1, notes: 'n' }; + const order = (notes: Record) => ({ + name: 'order', + uiReadonlyWhen: "record.status in ['confirmed', 'done']", + fields: { status: { type: 'text' }, amount: { type: 'number' }, notes: { type: 'text', ...notes } }, + }); + + it('is true when the object lock holds and no field overrides it', () => { + expect(editFormLockedByState(order({}), CONFIRMED)).toBe(true); + }); + + it('is false when a field keeps itself editable with its own uiReadonlyWhen', () => { + expect(editFormLockedByState(order({ uiReadonlyWhen: 'false' }), CONFIRMED)).toBe(false); + }); + + it('is false while the object predicate does not hold', () => { + expect(editFormLockedByState(order({}), { ...CONFIRMED, status: 'draft' })).toBe(false); + }); +}); diff --git a/ui/packages/plugin-form/src/__tests__/dialogHandLock-36806.test.ts b/ui/packages/plugin-form/src/__tests__/dialogHandLock-36806.test.ts index f5f929394d2..c67c5639bc9 100644 --- a/ui/packages/plugin-form/src/__tests__/dialogHandLock-36806.test.ts +++ b/ui/packages/plugin-form/src/__tests__/dialogHandLock-36806.test.ts @@ -16,6 +16,8 @@ import { describe, it, expect } from 'vitest'; import { filterCreateModeFields, filterSystemFields } from '../autoLayout'; import { sanitizeFormData } from '../sanitize'; +import { fromObjectSchema, type SectionFieldsContext } from '../sectionFields'; +import { deriveColumns, hydrateColumns } from '../deriveMasterDetail'; import type { FormField } from '@object-ui/types'; const objectSchema = { @@ -42,3 +44,47 @@ describe('dialog hand lock (#36806)', () => { expect(out).toEqual({ title: 'A', note: 'n' }); }); }); + +/** + * #37402 — the object level: the edit dialog's form fields and the line-item + * grid's columns carry the EFFECTIVE hand-lock predicate, so the form renderer + * and the line-item cell (which judge only what a field carries) fold the + * object's whole-record `uiReadonlyWhen` without reading the object. + */ +describe('the dialog and line-item fields carry the object-level hand lock (#37402)', () => { + const LOCK = "record.status in ['confirmed', 'done']"; + const order = { + name: 'order', + uiReadonlyWhen: LOCK, + fields: { + status: { type: 'select' }, + amount: { type: 'number' }, + notes: { type: 'text', uiReadonlyWhen: 'false' }, + parent: { type: 'master_detail', reference: 'head' }, + }, + }; + const ctx = (objectSchema: unknown) => ({ + objectSchema, + objectName: 'order', + mode: 'edit', + fieldLabel: (_o: string, _f: string, fallback: string) => fallback, + }) as unknown as SectionFieldsContext; + + it('a field that declares no hand lock carries the object predicate; one that does keeps its own', () => { + expect((fromObjectSchema('amount', ctx(order)) as any)?.uiReadonlyWhen).toBe(LOCK); + expect((fromObjectSchema('status', ctx(order)) as any)?.uiReadonlyWhen).toBe(LOCK); + expect((fromObjectSchema('notes', ctx(order)) as any)?.uiReadonlyWhen).toBe('false'); + // The control: the same field of an object without the lock carries none. + const { uiReadonlyWhen: _drop, ...plain } = order; + expect((fromObjectSchema('amount', ctx(plain)) as any)?.uiReadonlyWhen).toBeUndefined(); + }); + + it('a line-item column carries the CHILD object\'s predicate, derived or authored', () => { + const derived = deriveColumns(order, { booleanLabel: (v: boolean) => String(v), relationshipField: 'parent' } as never); + const byName = (cols: any[], n: string) => cols.find((c) => c.name === n); + expect(byName(derived, 'amount')?.uiReadonlyWhen).toBe(LOCK); + expect(byName(derived, 'notes')?.uiReadonlyWhen).toBe('false'); + const authored = hydrateColumns([{ name: 'amount', type: 'number' } as never], order, { booleanLabel: (v: boolean) => String(v) } as never); + expect((authored[0] as any).uiReadonlyWhen).toBe(LOCK); + }); +}); diff --git a/ui/packages/plugin-grid/src/__tests__/lockOperandProjection-36806.test.tsx b/ui/packages/plugin-grid/src/__tests__/lockOperandProjection-36806.test.tsx index 3cc65d2c22b..bb700672af0 100644 --- a/ui/packages/plugin-grid/src/__tests__/lockOperandProjection-36806.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/lockOperandProjection-36806.test.tsx @@ -138,3 +138,29 @@ describe('ObjectGrid — a shown column\'s lock operands are projected (objectst expect(lastSelect(ds)).toEqual(['id', 'status']); }); }); + +describe('ObjectGrid — the object-level hand lock\'s operands are projected (objectstack#37402)', () => { + it('asks for the operand of the object\'s uiReadonlyWhen for a column that inherits it', async () => { + const ds = makeDataSource(); + ds.getObjectSchema.mockImplementation(async () => ({ + name: OBJECT, + uiReadonlyWhen: "record.stage == 'closed'", + fields: OBJECT_FIELDS, + })); + renderGrid(ds, ['status']); + await vi.waitFor(() => expect(ds.find).toHaveBeenCalled()); + expect(lastSelect(ds)).toEqual(['id', 'stage', 'status']); + }); + + it('control: a column whose field declares its own hand lock does not inherit the object operand', async () => { + const ds = makeDataSource(); + ds.getObjectSchema.mockImplementation(async () => ({ + name: OBJECT, + uiReadonlyWhen: "record.stage == 'closed'", + fields: OBJECT_FIELDS, + })); + renderGrid(ds, ['subject']); + await vi.waitFor(() => expect(ds.find).toHaveBeenCalled()); + expect(lastSelect(ds)).toEqual(['id', 'status', 'subject']); + }); +}); diff --git a/ui/packages/plugin-grid/src/objectGridCellFacts.handLock-36806.test.ts b/ui/packages/plugin-grid/src/objectGridCellFacts.handLock-36806.test.ts index 925e9c36700..ca1d793a84e 100644 --- a/ui/packages/plugin-grid/src/objectGridCellFacts.handLock-36806.test.ts +++ b/ui/packages/plugin-grid/src/objectGridCellFacts.handLock-36806.test.ts @@ -19,6 +19,7 @@ import { fieldInlineReadOnlyKind, isFieldInlineEditable } from './inline-edit-op const OPEN: CellReadOnlyInputs = { fieldDef: { type: 'text' }, + object: null, fieldWritable: true, gridEditable: true, objectEditable: true, @@ -66,3 +67,23 @@ describe('grid hand lock (#36806)', () => { expect(cellReadOnlyKind({ ...OPEN, row: { status: 'approved' } })).toBeNull(); }); }); + +/** + * #37402 — the object level: a cell over a field that declares no hand lock is + * judged by the object's whole-record `uiReadonlyWhen` over its row, and a + * field's own `uiReadonlyWhen` wins over it. + */ +describe('grid cells read the object-level hand lock (#37402)', () => { + const object = { uiReadonlyWhen: "record.status in ['confirmed', 'done']" }; + it('locks a plain column on a locked row, and only there', () => { + expect(cellReadOnlyKind({ ...OPEN, object, row: { status: 'confirmed' } })).toBe('readonly'); + expect(cellReadOnlyKind({ ...OPEN, object, row: { status: 'draft' } })).toBeNull(); + // The control: the same row with no object lock edits. + expect(cellReadOnlyKind({ ...OPEN, row: { status: 'confirmed' } })).toBeNull(); + }); + + it('a column whose field keeps itself editable edits on a locked row', () => { + const fieldDef = { type: 'text', uiReadonlyWhen: 'false' }; + expect(cellReadOnlyKind({ ...OPEN, object, fieldDef, row: { status: 'confirmed' } })).toBeNull(); + }); +}); diff --git a/ui/packages/plugin-kanban/src/ObjectKanban.handLock-36806.test.tsx b/ui/packages/plugin-kanban/src/ObjectKanban.handLock-36806.test.tsx index d677ce6ff4a..f826dddeb99 100644 --- a/ui/packages/plugin-kanban/src/ObjectKanban.handLock-36806.test.tsx +++ b/ui/packages/plugin-kanban/src/ObjectKanban.handLock-36806.test.tsx @@ -71,16 +71,16 @@ const schema = { ], } satisfies ObjectKanbanSchema; -function makeDataSource(lock: Record) { +function makeDataSource(lock: Record, objectLock: Record = {}) { return { - getObjectSchema: vi.fn(async () => ({ name: OBJECT, fields: { title: { type: 'text', label: 'Title' }, status: statusField(lock) } })), + getObjectSchema: vi.fn(async () => ({ name: OBJECT, ...objectLock, fields: { title: { type: 'text', label: 'Title' }, status: statusField(lock) } })), find: vi.fn(async () => ({ value: [{ id: 't1', title: CARD, status: 'backlog' }] })), update: vi.fn(async () => ({ id: 't1', status: 'in_progress' })), } as unknown as DataSource & { update: ReturnType }; } -async function mountBoard(lock: Record) { - const ds = makeDataSource(lock); +async function mountBoard(lock: Record, objectLock: Record = {}) { + const ds = makeDataSource(lock, objectLock); render(); expect(await screen.findByText(CARD)).toBeTruthy(); await act(async () => { @@ -139,6 +139,28 @@ describe('ObjectKanban: the lane field\'s lock closes the drag (objectstack#3680 }); }); +/** + * objectstack#37402 — the object level: the object's whole-record + * `uiReadonlyWhen` TRUE over the dragged record locks a lane field that + * declares no hand lock of its own, and a lane field's own declaration wins. + */ +describe('ObjectKanban: the object-level hand lock closes the drop (objectstack#37402)', () => { + const OBJECT_LOCK = { uiReadonlyWhen: "record.status == 'backlog'" }; + + it('TRUE over the dragged record: the drop writes nothing', async () => { + const ds = await mountBoard({}, OBJECT_LOCK); + expect(cardNode().getAttribute('aria-disabled')).toBe('false'); + await dropOnInProgress(); + expect(ds.update).not.toHaveBeenCalled(); + }); + + it('CONTROL — a lane field that keeps itself editable writes the move inside a locked record', async () => { + const ds = await mountBoard({ uiReadonlyWhen: 'false' }, OBJECT_LOCK); + await dropOnInProgress(); + await waitFor(() => expect(ds.update).toHaveBeenCalledWith(OBJECT, 't1', { status: 'in_progress' })); + }); +}); + /** * objectstack#37448 — the swimlane board. A drop between columns writes the * lane field and nothing else: a drop into another swimlane's row moves the From fe9fc9cfbb4b909e63e40dd6df2e142e012fabda Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:32:08 +0000 Subject: [PATCH 07/15] fix(plugin-form): type the folded predicate and the child schema's lock key Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- ui/packages/plugin-form/src/ObjectForm.tsx | 4 ++-- .../src/__tests__/parameterTypesNameable-7324.test.ts | 8 ++++++-- ui/packages/plugin-form/src/deriveMasterDetail.ts | 2 ++ .../plugin-grid/src/objectGridCellFacts-35684.test.ts | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/packages/plugin-form/src/ObjectForm.tsx b/ui/packages/plugin-form/src/ObjectForm.tsx index 269bc8c3c75..5a4c38101a8 100644 --- a/ui/packages/plugin-form/src/ObjectForm.tsx +++ b/ui/packages/plugin-form/src/ObjectForm.tsx @@ -21,7 +21,7 @@ import { pickLocalized, useObjectTranslation, useLocalization, withHomeAmountSou import { useRecordInvalidation } from './recordInvalidation'; import { useReportedDirtyChange } from './formDirtyReport'; import { mapFieldTypeToFormType, buildValidationRules, formatFileSize, fieldHelpText, withFollowedParentObject, withFormObject, PERMISSION_SET_GRANT_COLUMNS } from '@object-ui/fields'; -import { effectiveUiReadonlyWhen, fieldStaticallyReadOnlyByHand, isExpressionComputedField } from '@object-ui/core'; +import { effectiveUiReadonlyWhen, fieldStaticallyReadOnlyByHand, isExpressionComputedField, type FieldRulePredicate } from '@object-ui/core'; import { useIsMobile, toast, FormSectionNavContext } from '@object-ui/components'; import { resolveSuccessNavigate } from './successBehavior'; import { resolveSubmitRedirect, submitRedirectScope } from './submitRedirect'; @@ -1023,7 +1023,7 @@ const SimpleObjectForm: React.FC<{ schema: LocalizedObjectFormSchema; dataSource // The hand lock's predicate, folded with `readonlyWhen` by the form // renderer: the EFFECTIVE one, so a field that declares none of its // own carries the object's whole-record `uiReadonlyWhen`. - uiReadonlyWhen: effectiveUiReadonlyWhen(field, objectSchema), + uiReadonlyWhen: effectiveUiReadonlyWhen(field, objectSchema) as FieldRulePredicate | undefined, requiredWhen: field.requiredWhen, // Field-group membership (Field.group → object.fieldGroups[].key). // Carried through so the form can auto-derive sections from the diff --git a/ui/packages/plugin-form/src/__tests__/parameterTypesNameable-7324.test.ts b/ui/packages/plugin-form/src/__tests__/parameterTypesNameable-7324.test.ts index 510ea1c4f97..777119d5a25 100644 --- a/ui/packages/plugin-form/src/__tests__/parameterTypesNameable-7324.test.ts +++ b/ui/packages/plugin-form/src/__tests__/parameterTypesNameable-7324.test.ts @@ -80,8 +80,12 @@ type DefaultsFieldValue = NonNullable, + /** + * The child schema carries the object's `name`; the defaults one does not. + * objectstack#37402 added `uiReadonlyWhen`: the child object's whole-record + * hand lock, which the line-item columns fold. + */ + childKeys: true satisfies Equals, defaultsKeys: true satisfies Equals, /** The child one deliberately does not constrain a field value. */ childFieldValueIsAny: true satisfies IsAny, diff --git a/ui/packages/plugin-form/src/deriveMasterDetail.ts b/ui/packages/plugin-form/src/deriveMasterDetail.ts index 2f5ed4b8675..72aca4055a4 100644 --- a/ui/packages/plugin-form/src/deriveMasterDetail.ts +++ b/ui/packages/plugin-form/src/deriveMasterDetail.ts @@ -47,6 +47,8 @@ import { effectiveUiReadonlyWhen, isExpressionComputedField } from '@object-ui/c export interface ChildObjectSchemaLike { name?: string; fields?: Record; + /** The child object's whole-record hand lock (`ObjectSchema.uiReadonlyWhen`), folded onto its columns. */ + uiReadonlyWhen?: unknown; } /** Map an ObjectQL field type to a LineItems grid column type. */ diff --git a/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts b/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts index cdf61ae1688..09d4e1468e4 100644 --- a/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts +++ b/ui/packages/plugin-grid/src/objectGridCellFacts-35684.test.ts @@ -51,6 +51,7 @@ describe('cellReadOnlyKind — the reason a cell names (objectstack#35684)', () it("puts the field's reason first, then the grid's, then the record's", () => { const all: CellReadOnlyInputs = { fieldDef: { type: 'formula' }, + object: null, fieldWritable: false, gridEditable: false, objectEditable: false, From 0c03dd7117f79dca683f244e9944216951a904f8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:39:13 +0000 Subject: [PATCH 08/15] test(dogfood): the locked-order fixture takes the package namespace prefix Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../test/ui-readonly-hand-lock-36806.dogfood.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts b/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts index 143e720f58a..c0201a556b5 100644 --- a/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts +++ b/packages/qa/dogfood/test/ui-readonly-hand-lock-36806.dogfood.test.ts @@ -64,7 +64,7 @@ const order = ObjectSchema.create({ ], } as never); -const LOCKED = 'hlo_order'; +const LOCKED = 'hlk_locked_order'; const LOCKED_MESSAGE = 'An order moves draft, then confirmed, then done.'; const lockedOrder = ObjectSchema.create({ @@ -84,7 +84,7 @@ const lockedOrder = ObjectSchema.create({ validations: [ { type: 'state_machine', - name: 'hlo_order_flow', + name: 'hlk_locked_order_flow', message: LOCKED_MESSAGE, field: 'status', initialStates: ['draft'], @@ -92,7 +92,7 @@ const lockedOrder = ObjectSchema.create({ }, ], actions: [ - { name: 'hlo_finish', label: 'Finish', objectName: LOCKED, operation: 'update', patch: { status: 'done', amount: 99 } }, + { name: 'hlk_locked_finish', label: 'Finish', objectName: LOCKED, operation: 'update', patch: { status: 'done', amount: 99 } }, ], } as never); @@ -268,7 +268,7 @@ describe('[#37402] an object-level uiReadonlyWhen keeps every write path on a lo it('a declarative action on a confirmed record writes the fields it patches', async () => { const id = await confirmed('hlo action'); - const res = await stack.apiAs(admin, 'POST', `/actions/${LOCKED}/hlo_finish`, { recordId: id }); + const res = await stack.apiAs(admin, 'POST', `/actions/${LOCKED}/hlk_locked_finish`, { recordId: id }); expect(res.status, await res.clone().text()).toBe(200); expect(await read(id)).toMatchObject({ status: 'done', amount: 99 }); }); From 107988740ed21acd268ca97814000c1581969a19 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:43:46 +0000 Subject: [PATCH 09/15] test(platform-objects): the object form's advanced section gains the uiReadonlyWhen leaves Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../object-collapsed-sections-echo-decisions.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts index 54a8a7cf6bf..234b7bd2f8e 100644 --- a/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-collapsed-sections-echo-decisions.test.ts @@ -967,10 +967,13 @@ describe('#19403 round 8 — the population, DERIVED from the form and a shape', // action arrangement per scope) and its `list` / `record` rows — a label // and a help text each, three rows and six leaves, all translated leaves // authored by that card. `advanced` reads 106 → 112. - expect(PANEL_LEAVES.length).toBe(125); + // 127 since #37402 gave `advanced` the object's whole-record hand lock + // (`uiReadonlyWhen`) — a label and a help text, two leaves, all translated + // leaves authored in every locale by that card. `advanced` reads 112 → 114. + expect(PANEL_LEAVES.length).toBe(127); expect(PANEL_LEAVES.every((l) => l.prop === 'label' || l.prop === 'helpText')).toBe(true); expect(PANEL_LEAVES.filter((l) => l.section === 'capabilities').length).toBe(13); - expect(PANEL_LEAVES.filter((l) => l.section === 'advanced').length).toBe(112); + expect(PANEL_LEAVES.filter((l) => l.section === 'advanced').length).toBe(114); }); it('⭐ DARK, OUTWARD — the open sections are excluded, and `fields.placeholder` is the one that proves it', () => { From dbb395cd85cff7c64c6bf0cc902de513938b62db Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:53:34 +0000 Subject: [PATCH 10/15] test(metadata-protocol): /meta/types serves the object's uiReadonlyWhen (52 -> 53) Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../src/protocol.meta-types-degenerate-derivation.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts b/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts index 85d4480f984..0c643849454 100644 --- a/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts +++ b/packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts @@ -411,9 +411,11 @@ describe('#17501 — /meta/types serves a real schema for `action`, and moves no // lock (no person edits the field at the console; writes keep it). // [#37141] `skill` 17 → 18: `context`, the context pack a skill works // from (ADR-0160 D8), which gives its MCP prompt a record argument. + // [#37402] `object` 52 → 53: `uiReadonlyWhen`, the whole-record hand lock + // (no person edits a field of the record at the console; writes keep it). const CARD_PROPERTY_COUNTS: Record = { agent: 24, app: 24, dashboard: 21, dataset: 17, field: 89, flow: 24, - hook: 24, object: 52, page: 28, position: 14, report: 24, skill: 18, tool: 14, + hook: 24, object: 53, page: 28, position: 14, report: 24, skill: 18, tool: 14, }; it.each(Object.entries(CARD_PROPERTY_COUNTS))( From 20624cb53a783ebe57ccb7db1c272eff45ef90c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 06:31:54 +0000 Subject: [PATCH 11/15] =?UTF-8?q?feat(ui,spec):=20uiReadonly:=20false=20is?= =?UTF-8?q?=20not=20a=20field's=20own=20hand=20lock=20=E2=80=94=20it=20fol?= =?UTF-8?q?lows=20the=20object=20lock=20(ruling=20Q1=20=3D=20B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../37402-object-ui-readonly-when-mcp.md | 2 +- .../37402-object-ui-readonly-when-spec.md | 2 +- .../37402-object-ui-readonly-when-ui-core.md | 2 +- .../src/__tests__/mcp-server-runtime.test.ts | 6 ++++- packages/mcp/src/mcp-http-tools.ts | 4 ++-- packages/mcp/src/mcp-server-runtime.ts | 4 +++- packages/runtime/src/domains/mcp.ts | 4 +++- packages/spec/liveness/object.json | 4 ++-- .../spec/src/data/object.metadata-form.ts | 2 +- packages/spec/src/data/object.zod.ts | 11 +++++---- .../__tests__/handLock-36806.test.ts | 15 +++++++++--- ui/packages/core/src/evaluator/handLock.ts | 24 +++++++++++++------ 12 files changed, 54 insertions(+), 26 deletions(-) diff --git a/.changeset/37402-object-ui-readonly-when-mcp.md b/.changeset/37402-object-ui-readonly-when-mcp.md index 04de0dce87b..73e1ecdc3eb 100644 --- a/.changeset/37402-object-ui-readonly-when-mcp.md +++ b/.changeset/37402-object-ui-readonly-when-mcp.md @@ -7,4 +7,4 @@ feat(mcp): `describe_object` reports an object's whole-record hand lock (`uiRead Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) Metadata-protocol: added -The stdio transport and the `objectstack://objects/{name}` resource answer the object's `uiReadonlyWhen` predicate text at the top level where authored, the twin of the HTTP transport. The tool description names it: while it holds, a person cannot edit any field at the console except one that lists its own `uiReadonly` / `uiReadonlyWhen`; an agent's write may still set every field, judged by the validations. +The stdio transport and the `objectstack://objects/{name}` resource answer the object's `uiReadonlyWhen` predicate text at the top level where authored, the twin of the HTTP transport. The tool description names it: while it holds, a person cannot edit any field at the console except one that lists its own `uiReadonlyWhen` (one listing `uiReadonly: true` is locked anyway); an agent's write may still set every field, judged by the validations. diff --git a/.changeset/37402-object-ui-readonly-when-spec.md b/.changeset/37402-object-ui-readonly-when-spec.md index 84c4b9e1b5a..93c54801520 100644 --- a/.changeset/37402-object-ui-readonly-when-spec.md +++ b/.changeset/37402-object-ui-readonly-when-spec.md @@ -10,6 +10,6 @@ Metadata-protocol: added A confirmed order, a posted invoice or a closed ticket is locked as a whole, and writing a `uiReadonlyWhen` on every field was both tedious and easy to get wrong by missing one. The object now carries the hand lock's object level: - **`ObjectSchema.uiReadonlyWhen`** (CEL over the record's own columns, the same scope as a field's `readonlyWhen`), e.g. `uiReadonlyWhen: P\`record.status in ['confirmed', 'done']\``. While TRUE no person edits any field of an existing record on the console surfaces a field's own `uiReadonlyWhen` locks. A create is not judged. -- **A field's own declaration wins.** A field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead of the object default, in both directions: `uiReadonlyWhen: P\`false\`` keeps a field (notes, internal tags) editable inside a locked record, and a field's own predicate can lock it where the object does not. A field's server lock (`readonly`, `readonlyWhen`) is not a hand-lock declaration and keeps locking on its own. +- **A field's own declaration wins.** A field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead of the object default, in both directions: `uiReadonlyWhen: P\`false\`` keeps a field (notes, internal tags) editable inside a locked record, and a field's own predicate can lock it where the object does not. `uiReadonly: false` is NOT a declaration of its own — it is that key's default, and a Studio switch turned on and off stores it — so such a field follows the object lock; the one opt-out spelling is `uiReadonlyWhen: P\`false\``. A field's server lock (`readonly`, `readonlyWhen`) is not a hand-lock declaration and keeps locking on its own. - **Every write keeps every field.** The engine never reads the key: REST, import, declarative and script actions and flows write a locked record, judged by the object's validations, and nothing is dropped from the write (`X-ObjectStack-Dropped-Fields` stays absent). - A predicate the console cannot evaluate locks every field that inherits it, as at the field level; `os validate` checks it. Liveness row `object.uiReadonlyWhen` (live), the Studio object form's Advanced section offers it as a CEL row, and the reference docs, authorable-surface record and state counts are regenerated. diff --git a/.changeset/37402-object-ui-readonly-when-ui-core.md b/.changeset/37402-object-ui-readonly-when-ui-core.md index 1ff4d5147db..b943baa20de 100644 --- a/.changeset/37402-object-ui-readonly-when-ui-core.md +++ b/.changeset/37402-object-ui-readonly-when-ui-core.md @@ -8,4 +8,4 @@ Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiRead Metadata-protocol: added - `fieldReadOnlyByHand(def, record, context)` now takes the object definition in a REQUIRED `context.object` (pass `null` only where a surface has none), and so does `fieldHasConditionalHandLock(def, object)`: a caller that forgot the object would silently open a locked record. The record and context arguments are required too (pass `null` for no record). Migration: add `{ object: objectDef }` to the context of every call. These helpers have not been published yet (they first ship in this prerelease line, after `19.0.0-next.0`), so no released caller breaks. -- New `effectiveUiReadonlyWhen(def, object)` — the field's own `uiReadonlyWhen` when it declares a hand lock of its own (`uiReadonly` or `uiReadonlyWhen`, any value), else the object's — and `fieldLockPredicates(def, object)`, the predicates whose operands a surface fetches before it judges a row. New type `ObjectHandLockDef`. +- New `effectiveUiReadonlyWhen(def, object)` — the field's own `uiReadonlyWhen` when it declares a hand lock of its own (`uiReadonly: true` or a `uiReadonlyWhen`; `uiReadonly: false` reads as absent and follows the object lock), else the object's — and `fieldLockPredicates(def, object)`, the predicates whose operands a surface fetches before it judges a row. New type `ObjectHandLockDef`. diff --git a/packages/mcp/src/__tests__/mcp-server-runtime.test.ts b/packages/mcp/src/__tests__/mcp-server-runtime.test.ts index 433b8870f79..03659e48bc9 100644 --- a/packages/mcp/src/__tests__/mcp-server-runtime.test.ts +++ b/packages/mcp/src/__tests__/mcp-server-runtime.test.ts @@ -375,7 +375,7 @@ describe('[#36806] describeServedObject reports the hand lock as its own keys', // [#37402] The object level of the same model: the whole-record hand lock's // predicate text, on the answer's top level, where the object authors one. describe('[#37402] describeServedObject reports the object-level uiReadonlyWhen', () => { - const fields = { status: { type: 'text' }, notes: { type: 'text', uiReadonlyWhen: 'false' } }; + const fields = { status: { type: 'text' }, notes: { type: 'text', uiReadonlyWhen: 'false' }, tag: { type: 'text', uiReadonly: false } }; it('the predicate text, from an envelope too, beside the fields that override it', () => { const described = describeServedObject({ name: 'locked_order', @@ -387,6 +387,10 @@ describe('[#37402] describeServedObject reports the object-level uiReadonlyWhen' // Never folded into any field's `readonly`: an agent's write still sets it. expect(described.fields.find((f) => f.name === 'status')).toMatchObject({ readonly: false }); expect('uiReadonlyWhen' in described.fields.find((f) => f.name === 'status')!).toBe(false); + // A stored `uiReadonly: false` is not an opt-out (it follows the object + // lock), so it is never listed as a key a reader could take for one. + const tag = described.fields.find((f) => f.name === 'tag')!; + expect('uiReadonly' in tag || 'uiReadonlyWhen' in tag).toBe(false); }); it('CONTROL — an object that authors none, or a blank one, carries no key', () => { diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 353d39c5789..05c4683e80f 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -4001,8 +4001,8 @@ export function registerObjectTools( + 'your write may still set it, judged by the validations), system, ' + 'options (send the value) and defaultValue (omit the field to get it; never copy the value); the active ' + 'validations; the enabled features; and the object\'s uiReadonlyWhen where set (while it holds, a person ' - + 'cannot edit any field of the record at the console except a field that lists its own uiReadonly / ' - + 'uiReadonlyWhen, so reach for an action; your write may still set every field, judged by the validations). ' + + 'cannot edit any field of the record at the console except a field that lists its own uiReadonlyWhen ' + + '(a field listing uiReadonly: true is locked anyway), so reach for an action; your write may still set every field, judged by the validations). ' + 'readonly is the schema\'s, not your edit permission.', inputSchema: strictToolInput( { surface: 'this describe_object call', aliases: { ...OBJECT_NAME_ALIASES, name: 'objectName' } }, diff --git a/packages/mcp/src/mcp-server-runtime.ts b/packages/mcp/src/mcp-server-runtime.ts index b5d1f7ea3a9..026e4a2a8d1 100644 --- a/packages/mcp/src/mcp-server-runtime.ts +++ b/packages/mcp/src/mcp-server-runtime.ts @@ -211,7 +211,9 @@ function describedHandLock(f: unknown): { uiReadonly?: true; uiReadonlyWhen?: st * caller is served it, authors a non-blank one, and nothing otherwise. On the * object it is the whole-record hand lock — the default of every field that * declares no hand lock of its own, which `describe_object` leaves for the - * reader to apply: a field's own key, where listed, wins. Like the field key it + * reader to apply: a field's own `uiReadonlyWhen`, or `uiReadonly: true`, where + * listed, wins (`uiReadonly` is listed only when true, so a stored `false` — + * which follows the object lock — is never mistaken for an opt-out). Like the field key it * locks a person at the console only; an agent's write still sets every field, * judged by the validations. * diff --git a/packages/runtime/src/domains/mcp.ts b/packages/runtime/src/domains/mcp.ts index a43532e834d..02af1e8cd26 100644 --- a/packages/runtime/src/domains/mcp.ts +++ b/packages/runtime/src/domains/mcp.ts @@ -796,7 +796,9 @@ function describedHandLock(f: any): { uiReadonly?: true; uiReadonlyWhen?: string * caller is served it, authors a non-blank one, and nothing otherwise. On the * object it is the whole-record hand lock — the default of every field that * declares no hand lock of its own, which `describe_object` leaves for the - * reader to apply: a field's own key, where listed, wins. Like the field key it + * reader to apply: a field's own `uiReadonlyWhen`, or `uiReadonly: true`, where + * listed, wins (`uiReadonly` is listed only when true, so a stored `false` — + * which follows the object lock — is never mistaken for an opt-out). Like the field key it * locks a person at the console only; an agent's write still sets every field, * judged by the validations. * diff --git a/packages/spec/liveness/object.json b/packages/spec/liveness/object.json index 0ddf4d9cf44..efe379ab252 100644 --- a/packages/spec/liveness/object.json +++ b/packages/spec/liveness/object.json @@ -283,8 +283,8 @@ "status": "live", "verifiedAt": "2026-11-28", "evidenceScope": "in-repo", - "evidence": "ui/packages/core/src/evaluator/handLock.ts#effectiveUiReadonlyWhen (a field's own `uiReadonly` / `uiReadonlyWhen` wins, else the object's predicate) read by #fieldReadOnlyByHand, #fieldHasConditionalHandLock and #fieldLockPredicates, which every hand surface reads with the object definition beside the field: the record page (ui/packages/plugin-detail/src/DetailSection.tsx, HeaderHighlight.tsx, InlineEditSaveBar.tsx, renderers/recordPathStageChange.tsx), the grid cell (ui/packages/plugin-grid/src/objectGridCellFacts.ts#cellReadOnlyKind) and its operand fetch (objectGridRowLoad.ts, ui/packages/plugin-list/src/ListView.tsx), kanban and calendar drops, the Gantt (ui/packages/plugin-gantt/src/ganttHandLock.ts), the timesheet cell, and the edit dialog's form fields (ui/packages/plugin-form/src/sectionFields.ts#fromObjectSchema, ObjectForm.tsx, ui/packages/app-shell/src/utils/editFormLockedByState.ts); packages/runtime/src/domains/mcp.ts#describeServedObject and packages/mcp/src/mcp-server-runtime.ts#describeServedObject (describe_object); packages/lint/src/validate-expressions.ts (objectstack validate)", - "note": "renderer only, by ruling (the two-tier field-lock model, its object level): while TRUE no person edits any field of an existing record at the console surfaces a field's own `uiReadonlyWhen` locks; a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead. The engine never reads it, so REST, import, action and flow writes keep every field, judged by validations. Fail-closed on a fault, as the field key. The console has no person-triggered record duplicate, so no clone surface reads it; the REST clone door is an API write and keeps every value." + "evidence": "ui/packages/core/src/evaluator/handLock.ts#effectiveUiReadonlyWhen (a field's own `uiReadonly: true` / `uiReadonlyWhen` wins, else the object's predicate; `uiReadonly: false` reads as absent) read by #fieldReadOnlyByHand, #fieldHasConditionalHandLock and #fieldLockPredicates, which every hand surface reads with the object definition beside the field: the record page (ui/packages/plugin-detail/src/DetailSection.tsx, HeaderHighlight.tsx, InlineEditSaveBar.tsx, renderers/recordPathStageChange.tsx), the grid cell (ui/packages/plugin-grid/src/objectGridCellFacts.ts#cellReadOnlyKind) and its operand fetch (objectGridRowLoad.ts, ui/packages/plugin-list/src/ListView.tsx), kanban and calendar drops, the Gantt (ui/packages/plugin-gantt/src/ganttHandLock.ts), the timesheet cell, and the edit dialog's form fields (ui/packages/plugin-form/src/sectionFields.ts#fromObjectSchema, ObjectForm.tsx, ui/packages/app-shell/src/utils/editFormLockedByState.ts); packages/runtime/src/domains/mcp.ts#describeServedObject and packages/mcp/src/mcp-server-runtime.ts#describeServedObject (describe_object); packages/lint/src/validate-expressions.ts (objectstack validate)", + "note": "renderer only, by ruling (the two-tier field-lock model, its object level): while TRUE no person edits any field of an existing record at the console surfaces a field's own `uiReadonlyWhen` locks; a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead (`uiReadonly: false` is not a declaration: the field follows the object lock; the opt-out spelling is a field `uiReadonlyWhen` of P`false`). The engine never reads it, so REST, import, action and flow writes keep every field, judged by validations. Fail-closed on a fault, as the field key. The console has no person-triggered record duplicate, so no clone surface reads it; the REST clone door is an API write and keeps every value." }, "validations": { "status": "live", diff --git a/packages/spec/src/data/object.metadata-form.ts b/packages/spec/src/data/object.metadata-form.ts index 6c26058ebe6..950350f6892 100644 --- a/packages/spec/src/data/object.metadata-form.ts +++ b/packages/spec/src/data/object.metadata-form.ts @@ -536,7 +536,7 @@ export const objectForm = defineMetadataForm({ // `uiReadonlyWhen`, the two-tier field-lock model), beside the state // machine it usually follows: the same CEL code row the field form // gives the field key. - { field: 'uiReadonlyWhen', type: 'code', language: 'expression', colSpan: 2, helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." }, + { field: 'uiReadonlyWhen', type: 'code', language: 'expression', colSpan: 2, helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly turned on, or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable; uiReadonly turned off does not, and the field follows this lock. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." }, // #19332 (flight G2b of ruling record 5861442317) — the object's // declarative timeline milestones (ADR-0052 §5b.2), beside `validations`: // a milestone fires on a field reaching a value, the same transition a diff --git a/packages/spec/src/data/object.zod.ts b/packages/spec/src/data/object.zod.ts index 4f221b0b8b9..72027fe7c1a 100644 --- a/packages/spec/src/data/object.zod.ts +++ b/packages/spec/src/data/object.zod.ts @@ -4753,10 +4753,11 @@ const ObjectSchemaBase = strictObject( * record that changes only through actions once it reaches a state, e.g. a * confirmed order: P`record.status in ['confirmed', 'done']`. * - * It is a DEFAULT for every field: a field that declares its own `uiReadonly` - * or `uiReadonlyWhen` is judged by its own declaration instead, so - * `uiReadonlyWhen: P\`false\`` on a field keeps it editable inside a locked - * record (notes, internal tags). The server lock of a field (`readonly`, + * It is a DEFAULT for every field: a field that declares a hand lock of its + * own — `uiReadonly: true` or a `uiReadonlyWhen` — is judged by that instead, + * so `uiReadonlyWhen: P\`false\`` on a field keeps it editable inside a + * locked record (notes, internal tags). `uiReadonly: false` is NOT such a + * declaration: it is that key's default, and the field follows the object lock. The server lock of a field (`readonly`, * `readonlyWhen`) is not a hand-lock declaration and still locks on its own. * A create is not judged, as at the field level. * @@ -4770,7 +4771,7 @@ const ObjectSchemaBase = strictObject( * reports it. The engine never reads it: a TRUE predicate refuses no REST, * import, action or flow write, and drops nothing from one. */ - uiReadonlyWhen: EvaluatedExpressionInputSchema.optional().describe("Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key."), + uiReadonlyWhen: EvaluatedExpressionInputSchema.optional().describe("Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record; `uiReadonly: false` is not such a declaration and the field follows the object lock. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key."), /** * Display & UI Hints (Data-Layer) diff --git a/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts b/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts index 8dbf5985c65..c76f68c47e5 100644 --- a/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts +++ b/ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts @@ -90,7 +90,8 @@ describe('resolveFieldRuleState folds the hand lock (#36806)', () => { /** * #37402 — the object level of the same model: an object's `uiReadonlyWhen` * is the hand lock of every field that declares none of its own, and a field's - * own `uiReadonly` / `uiReadonlyWhen` wins over it in both directions. + * own `uiReadonly: true` / `uiReadonlyWhen` wins over it in both directions + * (`uiReadonly: false` is not a declaration of its own). */ describe('the object-level hand lock folds into the one verdict (#37402)', () => { const ORDER = { uiReadonlyWhen: "record.status in ['confirmed', 'done']" }; @@ -117,8 +118,16 @@ describe('the object-level hand lock folds into the one verdict (#37402)', () => expect(fieldReadOnlyByHand({ uiReadonly: true }, draft, { object: ORDER })).toBe(true); }); - it('an explicit `uiReadonly: false` is a declaration of its own too', () => { - expect(fieldReadOnlyByHand({ uiReadonly: false }, confirmed, { object: ORDER })).toBe(false); + // Maintainer ruling on this card (Q1 = B): `uiReadonly: false` is the key's + // default — a Studio switch turned on and off stores it — so it is NOT the + // field's own declaration and the field follows the object lock. + it('an explicit `uiReadonly: false` is NOT a declaration of its own: the field follows the object lock', () => { + expect(fieldReadOnlyByHand({ uiReadonly: false }, confirmed, { object: ORDER })).toBe(true); + expect(fieldReadOnlyByHand({ uiReadonly: false }, draft, { object: ORDER })).toBe(false); + expect(effectiveUiReadonlyWhen({ uiReadonly: false }, ORDER)).toBe(ORDER.uiReadonlyWhen); + // CONTROL: the one opt-out spelling still opens the field inside the locked record. + expect(fieldReadOnlyByHand({ uiReadonly: false, uiReadonlyWhen: 'false' }, confirmed, { object: ORDER })).toBe(false); + expect(fieldReadOnlyByHand({ uiReadonlyWhen: 'false' }, confirmed, { object: ORDER })).toBe(false); }); it('the server lock is not a hand-lock declaration: it does not cancel the object default', () => { diff --git a/ui/packages/core/src/evaluator/handLock.ts b/ui/packages/core/src/evaluator/handLock.ts index 0fee129f297..2121a14a6e6 100644 --- a/ui/packages/core/src/evaluator/handLock.ts +++ b/ui/packages/core/src/evaluator/handLock.ts @@ -38,8 +38,11 @@ * * Two levels (the object level of the same ruling): an object's own * `uiReadonlyWhen` is the hand-lock DEFAULT for every field of its records, and - * a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by - * that declaration instead ({@link effectiveUiReadonlyWhen}). So every verdict + * a field that declares a hand lock of its own — `uiReadonly: true` or a + * `uiReadonlyWhen` — is judged by that declaration instead + * ({@link effectiveUiReadonlyWhen}). `uiReadonly: false` is NOT one: it reads as + * absent and the field follows the object lock (the only opt-out spelling is + * `uiReadonlyWhen: P\`false\``). So every verdict * here takes the object definition beside the field, as a REQUIRED context * key: a surface that forgot it would silently open a locked record, so the * compiler asks each caller for it (`null` where a surface has no object). @@ -91,16 +94,23 @@ export interface FieldHandLockContext { fieldContext?: string; } -/** True when the field declares a hand lock of its own (either key, either value). */ +/** + * True when the field declares a hand lock of its own: `uiReadonly: true` or a + * `uiReadonlyWhen`. ⛔ `uiReadonly: false` is not one (maintainer ruling on the + * object-level card): `false` is the key's default, and a Studio switch turned + * on and off again stores it, so counting it would silently open that field on + * every locked record. + */ function declaresOwnHandLock(def: FieldHandLockDef | null | undefined): boolean { - return def?.uiReadonly !== undefined || def?.uiReadonlyWhen !== undefined; + return def?.uiReadonly === true || def?.uiReadonlyWhen != null; } /** * The field's EFFECTIVE hand-lock predicate: its own `uiReadonlyWhen` when the - * field declares a hand lock of its own (`uiReadonly` or `uiReadonlyWhen`, any - * value — `uiReadonlyWhen: P\`false\`` keeps a field editable inside a locked - * record), else the object's `uiReadonlyWhen`. `undefined` when neither + * field declares a hand lock of its own (`uiReadonly: true`, or a + * `uiReadonlyWhen` — `uiReadonlyWhen: P\`false\`` keeps a field editable inside + * a locked record), else the object's `uiReadonlyWhen`; `uiReadonly: false` + * reads as absent. `undefined` when neither * applies. The server lock (`readonly` / `readonlyWhen`) is not a hand-lock * declaration: it never cancels the object's default, it locks on its own. */ From 696c37e9089a35d06fc3be07c5893eb26987d05a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 06:40:45 +0000 Subject: [PATCH 12/15] docs(spec,platform-objects): the object-level hand-lock help and references name the two counting spellings Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- content/docs/references/api/metadata.mdx | 2 +- content/docs/references/data/object.mdx | 2 +- content/docs/references/system/migration.mdx | 4 ++-- .../src/apps/translations/ar.metadata-forms.generated.ts | 2 +- .../src/apps/translations/de.metadata-forms.generated.ts | 2 +- .../src/apps/translations/en.metadata-forms.generated.ts | 2 +- .../src/apps/translations/es-ES.metadata-forms.generated.ts | 2 +- .../src/apps/translations/fr.metadata-forms.generated.ts | 2 +- .../src/apps/translations/ja-JP.metadata-forms.generated.ts | 2 +- .../src/apps/translations/ko.metadata-forms.generated.ts | 2 +- .../src/apps/translations/pt-BR.metadata-forms.generated.ts | 2 +- .../src/apps/translations/ru.metadata-forms.generated.ts | 2 +- .../src/apps/translations/zh-CN.metadata-forms.generated.ts | 2 +- .../src/apps/translations/zh-Hant.metadata-forms.generated.ts | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/content/docs/references/api/metadata.mdx b/content/docs/references/api/metadata.mdx index ccb23ecc761..99d813b39b7 100644 --- a/content/docs/references/api/metadata.mdx +++ b/content/docs/references/api/metadata.mdx @@ -962,7 +962,7 @@ Metadata query with filtering, sorting, and pagination | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record; `uiReadonly: false` is not such a declaration and the field follows the object lock. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/data/object.mdx b/content/docs/references/data/object.mdx index b9b4c5697b7..f96288e2907 100644 --- a/content/docs/references/data/object.mdx +++ b/content/docs/references/data/object.mdx @@ -171,7 +171,7 @@ const result = ApiMethod.parse(data); | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record; `uiReadonly: false` is not such a declaration and the field follows the object lock. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/content/docs/references/system/migration.mdx b/content/docs/references/system/migration.mdx index 39f79e4f53a..659131258dc 100644 --- a/content/docs/references/system/migration.mdx +++ b/content/docs/references/system/migration.mdx @@ -356,7 +356,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record; `uiReadonly: false` is not such a declaration and the field follows the object lock. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | @@ -666,7 +666,7 @@ Create a new object | **schemaReadDelegate** | `string` | optional | Kernel service that decides whether a caller who may not read this object is still served its definition on the metadata API, projected by that caller's field-level security. For objects whose rows reach callers only through a service's own door (e.g. sys_approval_request → approvals); it opens no row. Fails closed. | | **validations** | `any[]` | optional | Object-level validation rules | | **activityMilestones** | `{ field: string; value: string; summary: string; type?: string }[]` | optional | Declarative semantic activity milestones — emit a templated timeline row when a field transitions into a value, no hook code (ADR-0052 §5b.2). | -| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares its own `uiReadonly` or `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | +| **uiReadonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — every field of an existing record is read-only BY HAND while TRUE: the console surfaces a field's own `uiReadonlyWhen` locks (the edit dialog, record-page inline edit and the stage path, the highlight-strip chip, grid inline edit and multi-row save, kanban column drag, calendar drag, the Gantt, the timesheet cell, the line-item grid) do not let a person edit the record, while REST, import, action and flow writes keep every field, judged by the object's validations. e.g. P`record.status in ['confirmed', 'done']` on an order moved by Confirm / Cancel actions. A default for every field: a field that declares `uiReadonly: true` or its own `uiReadonlyWhen` is judged by that instead, so a field whose own `uiReadonlyWhen` is P`false` stays editable inside a locked record; `uiReadonly: false` is not such a declaration and the field follows the object lock. A create is not judged. A predicate the console cannot evaluate locks every field that inherits it. Same scope as a field's `readonlyWhen`: the record's OWN columns. The engine never reads this key. | | **nameField** | `string` | optional | [ADR-0079] Canonical primary title field — the stored field used as the record display name (e.g. "name", "title"). | | **displayNameField** | `string` | optional | [DEPRECATED → nameField] Field to use as the record display name (e.g., "name", "title"). Accepted as an alias for nameField. | | **titleFormat** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object }` | optional | [DEPRECATED → nameField (ADR-0079)] Render-only title template; the server cannot return or query it, and an explicit nameField now takes precedence. An object definition that declares it is refused at the metadata save gate and by os validate; a stored object that carries it still parses and reads. Migrate a single-field title to nameField; a composite title that import, sort or search must match to a stored computed field (a non-formula field with an expression, computed and stored on every write) designated as nameField — a text formula designated as nameField stays legal for a title shown for display only. Placeholders may be written `{{field}}` or `{field}` — the title renderers treat the two as equivalent, normalizing `{{field}}` to `{field}` before substituting; neither spelling is judged at parse time. | diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index 50ba0c37013..dd8aa7d518f 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const arMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "السجل كله للقراءة فقط في الواجهة عندما", - helpText: "شرط CEL على السجل (مثل record.status in ['confirmed', 'done']) — ما دام TRUE لا يستطيع أحد تعديل أي حقل من سجل موجود في وحدة التحكم (مربع حوار التعديل، صفحة السجل، الجداول، كانبان، السحب في التقويم ومخطط جانت، جدول الدوام)؛ ولا يُقيَّم مربع حوار إنشاء سجل جديد. الحقل الذي يعلن قفله اليدوي الخاص (uiReadonly أو uiReadonlyWhen) يُحكم عليه بإعلانه، لذا فإن uiReadonlyWhen: false على حقل يبقيه قابلاً للتعديل. تستمر الإجراءات والاستيراد وواجهة API والتدفقات في كتابة كل حقل، وتحكم عليها قواعد التحقق للكائن. يقرأ أعمدة السجل نفسه. المساعد داخل التطبيق الذي يعمل نيابة عن شخص لا يلتزم بهذا بعد." + helpText: "شرط CEL على السجل (مثل record.status in ['confirmed', 'done']) — ما دام TRUE لا يستطيع أحد تعديل أي حقل من سجل موجود في وحدة التحكم (مربع حوار التعديل، صفحة السجل، الجداول، كانبان، السحب في التقويم ومخطط جانت، جدول الدوام)؛ ولا يُقيَّم مربع حوار إنشاء سجل جديد. الحقل الذي يعلن قفله اليدوي الخاص (تفعيل uiReadonly، أو uiReadonlyWhen) يُحكم عليه بإعلانه، لذا فإن uiReadonlyWhen: false على حقل يبقيه قابلاً للتعديل؛ أما إيقاف uiReadonly فلا يُحتسب، ويتبع الحقل هذا القفل. تستمر الإجراءات والاستيراد وواجهة API والتدفقات في كتابة كل حقل، وتحكم عليها قواعد التحقق للكائن. يقرأ أعمدة السجل نفسه. المساعد داخل التطبيق الذي يعمل نيابة عن شخص لا يلتزم بهذا بعد." }, activityMilestones: { label: "معالم النشاط", diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index 58b8a2b5de7..aa11260db47 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const deMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "Ganzer Datensatz in der Oberfläche schreibgeschützt wenn", - helpText: "CEL-Prädikat über den Datensatz (z. B. record.status in ['confirmed', 'done']) – solange es TRUE ist, kann niemand in der Konsole ein Feld eines bestehenden Datensatzes bearbeiten (Bearbeitungsdialog, Datensatzseite, Tabellen, Kanban, Kalender- und Gantt-Ziehen, Zeiterfassung); der Erstellungsdialog eines neuen Datensatzes wird nicht geprüft. Ein Feld, das eine eigene manuelle Sperre (uiReadonly oder uiReadonlyWhen) festlegt, wird stattdessen danach beurteilt, sodass uiReadonlyWhen: false an einem Feld es bearbeitbar hält. Aktionen, Importe, die API und Flows schreiben weiterhin jedes Feld, beurteilt durch die Validierungen des Objekts. Liest die eigenen Spalten des Datensatzes. Der In-App-Assistent, der für eine Person handelt, beachtet dies noch nicht." + helpText: "CEL-Prädikat über den Datensatz (z. B. record.status in ['confirmed', 'done']) – solange es TRUE ist, kann niemand in der Konsole ein Feld eines bestehenden Datensatzes bearbeiten (Bearbeitungsdialog, Datensatzseite, Tabellen, Kanban, Kalender- und Gantt-Ziehen, Zeiterfassung); der Erstellungsdialog eines neuen Datensatzes wird nicht geprüft. Ein Feld, das eine eigene manuelle Sperre (uiReadonly eingeschaltet oder uiReadonlyWhen) festlegt, wird stattdessen danach beurteilt, sodass uiReadonlyWhen: false an einem Feld es bearbeitbar hält; ein ausgeschaltetes uiReadonly zählt nicht, und das Feld folgt dieser Sperre. Aktionen, Importe, die API und Flows schreiben weiterhin jedes Feld, beurteilt durch die Validierungen des Objekts. Liest die eigenen Spalten des Datensatzes. Der In-App-Assistent, der für eine Person handelt, beachtet dies noch nicht." }, activityMilestones: { label: "Aktivitätsmeilensteine", diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index ceac3ff2712..168daaac046 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const enMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "Ui Readonly When", - helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." + helpText: "CEL predicate over the record (e.g. record.status in ['confirmed', 'done']) — while it is TRUE, people cannot edit any field of an existing record anywhere in the console (the edit dialog, the record page, grids, kanban, calendar and Gantt drag, the timesheet); a new record's create dialog is not judged. A field that sets its own hand lock (uiReadonly turned on, or uiReadonlyWhen) is judged by that instead, so uiReadonlyWhen: false on a field keeps it editable; uiReadonly turned off does not, and the field follows this lock. Actions, imports, the API and flows still write every field, judged by the object's validations. Reads the record's own columns. The in-app assistant acting for a person does not honour it yet." }, activityMilestones: { label: "Activity Milestones", diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index 44c1ddb02fe..c96ff96d03a 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const esESMetadataForms: NonNullable = }, uiReadonlyWhen: { label: "Condición de solo lectura en la interfaz para todo el registro", - helpText: "Predicado CEL sobre el registro (p. ej. record.status in ['confirmed', 'done']): mientras sea TRUE, nadie puede editar ningún campo de un registro existente en la consola (el diálogo de edición, la página del registro, las cuadrículas, el kanban, el arrastre del calendario y del Gantt, la hoja de horas); el diálogo de creación de un registro nuevo no se evalúa. Un campo que declara su propio bloqueo manual (uiReadonly o uiReadonlyWhen) se juzga por él, así que uiReadonlyWhen: false en un campo lo mantiene editable. Las acciones, las importaciones, la API y los flujos siguen escribiendo todos los campos, juzgados por las validaciones del objeto. Lee las columnas propias del registro. El asistente integrado que actúa por una persona aún no lo respeta." + helpText: "Predicado CEL sobre el registro (p. ej. record.status in ['confirmed', 'done']): mientras sea TRUE, nadie puede editar ningún campo de un registro existente en la consola (el diálogo de edición, la página del registro, las cuadrículas, el kanban, el arrastre del calendario y del Gantt, la hoja de horas); el diálogo de creación de un registro nuevo no se evalúa. Un campo que declara su propio bloqueo manual (uiReadonly activado, o uiReadonlyWhen) se juzga por él, así que uiReadonlyWhen: false en un campo lo mantiene editable; uiReadonly desactivado no cuenta y el campo sigue este bloqueo. Las acciones, las importaciones, la API y los flujos siguen escribiendo todos los campos, juzgados por las validaciones del objeto. Lee las columnas propias del registro. El asistente integrado que actúa por una persona aún no lo respeta." }, activityMilestones: { label: "Hitos de actividad", diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index d84a3ffc7ff..1c742b57ac6 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const frMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "Enregistrement entier en lecture seule dans l'interface si", - helpText: "Prédicat CEL sur l'enregistrement (par ex. record.status in ['confirmed', 'done']) — tant qu'il est TRUE, personne ne peut modifier un champ d'un enregistrement existant dans la console (boîte de dialogue de modification, page de l'enregistrement, grilles, kanban, glisser-déposer du calendrier et du Gantt, feuille de temps) ; la boîte de dialogue de création d'un nouvel enregistrement n'est pas évaluée. Un champ qui déclare son propre verrou manuel (uiReadonly ou uiReadonlyWhen) est jugé par celui-ci, donc uiReadonlyWhen: false sur un champ le garde modifiable. Les actions, les imports, l'API et les flux écrivent toujours chaque champ, jugés par les validations de l'objet. Lit les colonnes propres de l'enregistrement. L'assistant intégré agissant pour une personne ne le respecte pas encore." + helpText: "Prédicat CEL sur l'enregistrement (par ex. record.status in ['confirmed', 'done']) — tant qu'il est TRUE, personne ne peut modifier un champ d'un enregistrement existant dans la console (boîte de dialogue de modification, page de l'enregistrement, grilles, kanban, glisser-déposer du calendrier et du Gantt, feuille de temps) ; la boîte de dialogue de création d'un nouvel enregistrement n'est pas évaluée. Un champ qui déclare son propre verrou manuel (uiReadonly activé, ou uiReadonlyWhen) est jugé par celui-ci, donc uiReadonlyWhen: false sur un champ le garde modifiable ; uiReadonly désactivé ne compte pas, et le champ suit ce verrou. Les actions, les imports, l'API et les flux écrivent toujours chaque champ, jugés par les validations de l'objet. Lit les colonnes propres de l'enregistrement. L'assistant intégré agissant pour une personne ne le respecte pas encore." }, activityMilestones: { label: "Jalons d’activité", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index d09b4f9e684..61b6526e377 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const jaJPMetadataForms: NonNullable = }, uiReadonlyWhen: { label: "レコード全体を画面上で読み取り専用にする条件", - helpText: "レコードに対する CEL 述語(例: record.status in ['confirmed', 'done'])。TRUE の間、コンソールのどこでも既存レコードのどのフィールドも人が編集できません(編集ダイアログ、レコードページ、グリッド、カンバン、カレンダーとガントのドラッグ、タイムシート)。新規レコードの作成ダイアログは判定されません。独自の手動ロック(uiReadonly または uiReadonlyWhen)を宣言したフィールドはその宣言で判定されるため、フィールドに uiReadonlyWhen: false を設定すると編集可能なままになります。アクション、インポート、API、フローは引き続きすべてのフィールドに書き込み、オブジェクトの検証ルールで判定されます。レコード自身の列を読み取ります。ユーザーの代わりに操作するアプリ内アシスタントはまだこの設定に従いません。" + helpText: "レコードに対する CEL 述語(例: record.status in ['confirmed', 'done'])。TRUE の間、コンソールのどこでも既存レコードのどのフィールドも人が編集できません(編集ダイアログ、レコードページ、グリッド、カンバン、カレンダーとガントのドラッグ、タイムシート)。新規レコードの作成ダイアログは判定されません。独自の手動ロック(uiReadonly をオン、または uiReadonlyWhen)を宣言したフィールドはその宣言で判定されるため、フィールドに uiReadonlyWhen: false を設定すると編集可能なままになります。uiReadonly をオフにしてもそうはならず、フィールドはこのロックに従います。アクション、インポート、API、フローは引き続きすべてのフィールドに書き込み、オブジェクトの検証ルールで判定されます。レコード自身の列を読み取ります。ユーザーの代わりに操作するアプリ内アシスタントはまだこの設定に従いません。" }, activityMilestones: { label: "アクティビティのマイルストーン", diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index 7e6d51f3698..46aa0df79eb 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const koMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "레코드 전체를 화면에서 읽기 전용으로 하는 조건", - helpText: "레코드에 대한 CEL 조건식(예: record.status in ['confirmed', 'done']) — TRUE인 동안 콘솔 어디에서도 기존 레코드의 어떤 필드도 사람이 편집할 수 없습니다(편집 대화상자, 레코드 페이지, 그리드, 칸반, 캘린더와 간트 드래그, 타임시트). 새 레코드의 생성 대화상자는 판정하지 않습니다. 자체 수동 잠금(uiReadonly 또는 uiReadonlyWhen)을 선언한 필드는 그 선언으로 판정되므로, 필드에 uiReadonlyWhen: false를 두면 편집 가능한 상태로 유지됩니다. 작업, 가져오기, API, 플로는 여전히 모든 필드에 쓰며 객체의 검증 규칙이 판정합니다. 레코드 자체의 열을 읽습니다. 사용자를 대신해 작업하는 앱 내 어시스턴트는 아직 이 설정을 따르지 않습니다." + helpText: "레코드에 대한 CEL 조건식(예: record.status in ['confirmed', 'done']) — TRUE인 동안 콘솔 어디에서도 기존 레코드의 어떤 필드도 사람이 편집할 수 없습니다(편집 대화상자, 레코드 페이지, 그리드, 칸반, 캘린더와 간트 드래그, 타임시트). 새 레코드의 생성 대화상자는 판정하지 않습니다. 자체 수동 잠금(uiReadonly 켜기 또는 uiReadonlyWhen)을 선언한 필드는 그 선언으로 판정되므로, 필드에 uiReadonlyWhen: false를 두면 편집 가능한 상태로 유지됩니다. uiReadonly를 끈 것은 해당하지 않으며 필드는 이 잠금을 따릅니다. 작업, 가져오기, API, 플로는 여전히 모든 필드에 쓰며 객체의 검증 규칙이 판정합니다. 레코드 자체의 열을 읽습니다. 사용자를 대신해 작업하는 앱 내 어시스턴트는 아직 이 설정을 따르지 않습니다." }, activityMilestones: { label: "활동 마일스톤", diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 61ef466078c..bd061699486 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const ptBRMetadataForms: NonNullable = }, uiReadonlyWhen: { label: "Registro inteiro somente leitura na interface quando", - helpText: "Predicado CEL sobre o registro (por exemplo, record.status in ['confirmed', 'done']) — enquanto for TRUE, ninguém pode editar nenhum campo de um registro existente no console (o diálogo de edição, a página do registro, grades, kanban, arrastar no calendário e no Gantt, a planilha de horas); o diálogo de criação de um novo registro não é avaliado. Um campo que declara seu próprio bloqueio manual (uiReadonly ou uiReadonlyWhen) é julgado por ele, então uiReadonlyWhen: false em um campo o mantém editável. Ações, importações, a API e fluxos continuam gravando todos os campos, julgados pelas validações do objeto. Lê as colunas do próprio registro. O assistente no aplicativo que age por uma pessoa ainda não respeita isso." + helpText: "Predicado CEL sobre o registro (por exemplo, record.status in ['confirmed', 'done']) — enquanto for TRUE, ninguém pode editar nenhum campo de um registro existente no console (o diálogo de edição, a página do registro, grades, kanban, arrastar no calendário e no Gantt, a planilha de horas); o diálogo de criação de um novo registro não é avaliado. Um campo que declara seu próprio bloqueio manual (uiReadonly ativado, ou uiReadonlyWhen) é julgado por ele, então uiReadonlyWhen: false em um campo o mantém editável; uiReadonly desativado não conta, e o campo segue este bloqueio. Ações, importações, a API e fluxos continuam gravando todos os campos, julgados pelas validações do objeto. Lê as colunas do próprio registro. O assistente no aplicativo que age por uma pessoa ainda não respeita isso." }, activityMilestones: { label: "Marcos de atividade", diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index f4fb166e67e..6ee5f424eea 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const ruMetadataForms: NonNullable = { }, uiReadonlyWhen: { label: "Вся запись только для чтения в интерфейсе, когда", - helpText: "Предикат CEL над записью (например, record.status in ['confirmed', 'done']) — пока он TRUE, никто не может изменить ни одно поле существующей записи в консоли (диалог редактирования, страница записи, таблицы, канбан, перетаскивание в календаре и диаграмме Ганта, табель); диалог создания новой записи не проверяется. Поле, объявившее собственную ручную блокировку (uiReadonly или uiReadonlyWhen), оценивается по ней, поэтому uiReadonlyWhen: false у поля оставляет его редактируемым. Действия, импорт, API и потоки по-прежнему записывают каждое поле, и их оценивают проверки объекта. Читает собственные столбцы записи. Встроенный помощник, действующий от имени человека, пока это не учитывает." + helpText: "Предикат CEL над записью (например, record.status in ['confirmed', 'done']) — пока он TRUE, никто не может изменить ни одно поле существующей записи в консоли (диалог редактирования, страница записи, таблицы, канбан, перетаскивание в календаре и диаграмме Ганта, табель); диалог создания новой записи не проверяется. Поле, объявившее собственную ручную блокировку (включённый uiReadonly или uiReadonlyWhen), оценивается по ней, поэтому uiReadonlyWhen: false у поля оставляет его редактируемым; выключенный uiReadonly не считается, и поле следует этой блокировке. Действия, импорт, API и потоки по-прежнему записывают каждое поле, и их оценивают проверки объекта. Читает собственные столбцы записи. Встроенный помощник, действующий от имени человека, пока это не учитывает." }, activityMilestones: { label: "Вехи активности", diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index 322e5b1b69a..7d15b6c7cdf 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const zhCNMetadataForms: NonNullable = }, uiReadonlyWhen: { label: "记录界面只读条件", - helpText: "基于记录的 CEL 谓词(例如 record.status in ['confirmed', 'done'])——为 TRUE 时,用户无法在控制台中编辑已有记录的任何字段(编辑对话框、记录页、表格、看板、日历和甘特图拖动、工时表);新建记录的创建对话框不做判断。自行声明了手动锁定(uiReadonly 或 uiReadonlyWhen)的字段按其自身声明裁决,因此字段上的 uiReadonlyWhen: false 可让它保持可编辑。动作、导入、API 和流程仍可写入每个字段,并由对象的校验规则裁决。读取记录自身的列。代表用户操作的应用内助手暂不遵循此设置。" + helpText: "基于记录的 CEL 谓词(例如 record.status in ['confirmed', 'done'])——为 TRUE 时,用户无法在控制台中编辑已有记录的任何字段(编辑对话框、记录页、表格、看板、日历和甘特图拖动、工时表);新建记录的创建对话框不做判断。自行声明了手动锁定(开启 uiReadonly,或 uiReadonlyWhen)的字段按其自身声明裁决,因此字段上的 uiReadonlyWhen: false 可让它保持可编辑;关闭 uiReadonly 不算,字段仍随此锁定。动作、导入、API 和流程仍可写入每个字段,并由对象的校验规则裁决。读取记录自身的列。代表用户操作的应用内助手暂不遵循此设置。" }, activityMilestones: { label: "活动里程碑", diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index 4fa40149e3a..fafac2bbfa6 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -427,7 +427,7 @@ export const zhHantMetadataForms: NonNullable }, uiReadonlyWhen: { label: "記錄介面唯讀條件", - helpText: "基於記錄的 CEL 述詞(例如 record.status in ['confirmed', 'done'])——為 TRUE 時,使用者無法在主控台中編輯既有記錄的任何欄位(編輯對話框、記錄頁、表格、看板、行事曆與甘特圖拖曳、工時表);新記錄的建立對話框不做判斷。自行宣告了手動鎖定(uiReadonly 或 uiReadonlyWhen)的欄位依其自身宣告裁決,因此欄位上的 uiReadonlyWhen: false 可讓它保持可編輯。動作、匯入、API 與流程仍可寫入每個欄位,並由物件的驗證規則裁決。讀取記錄自身的欄。代表使用者操作的應用程式內助理暫不遵循此設定。" + helpText: "基於記錄的 CEL 述詞(例如 record.status in ['confirmed', 'done'])——為 TRUE 時,使用者無法在主控台中編輯既有記錄的任何欄位(編輯對話框、記錄頁、表格、看板、行事曆與甘特圖拖曳、工時表);新記錄的建立對話框不做判斷。自行宣告了手動鎖定(開啟 uiReadonly,或 uiReadonlyWhen)的欄位依其自身宣告裁決,因此欄位上的 uiReadonlyWhen: false 可讓它保持可編輯;關閉 uiReadonly 不算,欄位仍隨此鎖定。動作、匯入、API 與流程仍可寫入每個欄位,並由物件的驗證規則裁決。讀取記錄自身的欄。代表使用者操作的應用程式內助理暫不遵循此設定。" }, activityMilestones: { label: "活動里程碑", From 36e883f107c47c6a9c01302aa892848de5280c0c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 08:58:38 +0000 Subject: [PATCH 13/15] fix(plugin-form): the wizard's final-submit gate does not judge the hand lock on a create (L2 S1) Also: the @object-ui/core changeset names the prerelease the helpers first shipped in, and describe_object says a field's own uiReadonlyWhen may itself lock it. Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../37402-object-ui-readonly-when-mcp.md | 2 +- ...402-object-ui-readonly-when-plugin-form.md | 2 +- .../37402-object-ui-readonly-when-ui-core.md | 2 +- packages/mcp/src/mcp-http-tools.ts | 5 +- ui/packages/plugin-form/src/WizardForm.tsx | 10 ++- .../src/wizardPredicateScope.test.tsx | 85 +++++++++++++++++++ 6 files changed, 100 insertions(+), 6 deletions(-) diff --git a/.changeset/37402-object-ui-readonly-when-mcp.md b/.changeset/37402-object-ui-readonly-when-mcp.md index 73e1ecdc3eb..ab8bc5066f2 100644 --- a/.changeset/37402-object-ui-readonly-when-mcp.md +++ b/.changeset/37402-object-ui-readonly-when-mcp.md @@ -7,4 +7,4 @@ feat(mcp): `describe_object` reports an object's whole-record hand lock (`uiRead Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) Metadata-protocol: added -The stdio transport and the `objectstack://objects/{name}` resource answer the object's `uiReadonlyWhen` predicate text at the top level where authored, the twin of the HTTP transport. The tool description names it: while it holds, a person cannot edit any field at the console except one that lists its own `uiReadonlyWhen` (one listing `uiReadonly: true` is locked anyway); an agent's write may still set every field, judged by the validations. +The stdio transport and the `objectstack://objects/{name}` resource answer the object's `uiReadonlyWhen` predicate text at the top level where authored, the twin of the HTTP transport. The tool description names it: while it holds, a person cannot edit any field at the console — a field that lists its own `uiReadonlyWhen` is judged by that predicate instead, which may itself lock it, and one listing `uiReadonly: true` is always locked; an agent's write may still set every field, judged by the validations. diff --git a/.changeset/37402-object-ui-readonly-when-plugin-form.md b/.changeset/37402-object-ui-readonly-when-plugin-form.md index 408ec7bc7fd..a496c87428f 100644 --- a/.changeset/37402-object-ui-readonly-when-plugin-form.md +++ b/.changeset/37402-object-ui-readonly-when-plugin-form.md @@ -7,4 +7,4 @@ feat(plugin-form): the object's whole-record hand lock (`uiReadonlyWhen`) holds Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) Metadata-protocol: added -An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: the create and edit dialogs' form fields and the line-item grid's columns carry the EFFECTIVE hand-lock predicate (a field's own, else the object's; a child field's own, else the child object's), through the one verdict of `@object-ui/core`. Writes outside the console are unchanged. +An object's `uiReadonlyWhen` is the hand lock of every field that declares none of its own: the create and edit dialogs' form fields and the line-item grid's columns carry the EFFECTIVE hand-lock predicate (a field's own, else the object's; a child field's own, else the child object's), through the one verdict of `@object-ui/core`. The wizard's final-submit required re-check does not judge the hand lock on a CREATE wizard (as the form renderer does not), so an object lock TRUE over a new record's values cannot skip that check. Writes outside the console are unchanged. diff --git a/.changeset/37402-object-ui-readonly-when-ui-core.md b/.changeset/37402-object-ui-readonly-when-ui-core.md index b943baa20de..f9b708d9495 100644 --- a/.changeset/37402-object-ui-readonly-when-ui-core.md +++ b/.changeset/37402-object-ui-readonly-when-ui-core.md @@ -7,5 +7,5 @@ feat(core): the one hand-lock verdict folds an object's whole-record `uiReadonly Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.uiReadonlyWhen`) Metadata-protocol: added -- `fieldReadOnlyByHand(def, record, context)` now takes the object definition in a REQUIRED `context.object` (pass `null` only where a surface has none), and so does `fieldHasConditionalHandLock(def, object)`: a caller that forgot the object would silently open a locked record. The record and context arguments are required too (pass `null` for no record). Migration: add `{ object: objectDef }` to the context of every call. These helpers have not been published yet (they first ship in this prerelease line, after `19.0.0-next.0`), so no released caller breaks. +- `fieldReadOnlyByHand(def, record, context)` now takes the object definition in a REQUIRED `context.object` (pass `null` only where a surface has none), and so does `fieldHasConditionalHandLock(def, object)`: a caller that forgot the object would silently open a locked record. The record and context arguments are required too (pass `null` for no record). Migration: add `{ object: objectDef }` to the context of every call. These helpers first shipped in the `19.0.0-next.0` prerelease (the field-level hand lock) and are in no stable release; a caller written against that prerelease's `fieldReadOnlyByHand(def, record?, context?)` must now pass `{ object }` (or `{ object: null }`) as shown above. - New `effectiveUiReadonlyWhen(def, object)` — the field's own `uiReadonlyWhen` when it declares a hand lock of its own (`uiReadonly: true` or a `uiReadonlyWhen`; `uiReadonly: false` reads as absent and follows the object lock), else the object's — and `fieldLockPredicates(def, object)`, the predicates whose operands a surface fetches before it judges a row. New type `ObjectHandLockDef`. diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 05c4683e80f..a7743d23c69 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -4001,8 +4001,9 @@ export function registerObjectTools( + 'your write may still set it, judged by the validations), system, ' + 'options (send the value) and defaultValue (omit the field to get it; never copy the value); the active ' + 'validations; the enabled features; and the object\'s uiReadonlyWhen where set (while it holds, a person ' - + 'cannot edit any field of the record at the console except a field that lists its own uiReadonlyWhen ' - + '(a field listing uiReadonly: true is locked anyway), so reach for an action; your write may still set every field, judged by the validations). ' + + 'cannot edit any field of the record at the console; a field that lists its own uiReadonlyWhen is judged ' + + 'by that predicate instead, which may itself lock it, and one listing uiReadonly: true is always locked; ' + + 'so reach for an action; your write may still set every field, judged by the validations). ' + 'readonly is the schema\'s, not your edit permission.', inputSchema: strictToolInput( { surface: 'this describe_object call', aliases: { ...OBJECT_NAME_ALIASES, name: 'objectName' } }, diff --git a/ui/packages/plugin-form/src/WizardForm.tsx b/ui/packages/plugin-form/src/WizardForm.tsx index 42d08c50c99..fc04e033528 100644 --- a/ui/packages/plugin-form/src/WizardForm.tsx +++ b/ui/packages/plugin-form/src/WizardForm.tsx @@ -902,7 +902,15 @@ export const WizardForm: React.FC = ({ { visibleWhen, readonlyWhen: (field as any).readonlyWhen, - uiReadonlyWhen: (field as any).uiReadonlyWhen, + // The hand lock is judged on an existing record only ("a create + // is not judged", `@objectstack/spec` `Field.uiReadonlyWhen` and + // `ObjectSchema.uiReadonlyWhen`): dropped on a CREATE wizard + // here, at the evaluating site, as the form renderer drops it + // (`form.tsx`). The carried predicate may be the object's + // whole-record lock (`fromObjectSchema` folds it in every mode), + // and judged here it would make every inheriting field read-only + // and skip this whole-form required re-check (objectstack#37402). + uiReadonlyWhen: isCreateWizard ? undefined : (field as any).uiReadonlyWhen, requiredWhen: (field as any).requiredWhen, }, ruleRecord, diff --git a/ui/packages/plugin-form/src/wizardPredicateScope.test.tsx b/ui/packages/plugin-form/src/wizardPredicateScope.test.tsx index f7d1ec1283d..772f45c5d8a 100644 --- a/ui/packages/plugin-form/src/wizardPredicateScope.test.tsx +++ b/ui/packages/plugin-form/src/wizardPredicateScope.test.tsx @@ -223,3 +223,88 @@ describe('#6110 controls — stated plainly: these pass on a revert', () => { await expectBlocked(ds); }); }); + +// ─── objectstack#37402 (L2 S1) — "a create is not judged" holds in this gate ── + +/** + * The object's whole-record hand lock (`ObjectSchema.uiReadonlyWhen`) rides on + * every form field `fromObjectSchema` builds. The form renderer drops it on a + * create; this gate must too, or a lock TRUE (or faulting) over a CREATE + * wizard's values makes every inheriting field read-only and the whole-form + * required re-check is skipped. On an EDIT wizard the lock still holds: a + * locked field is not demanded. + */ +describe('#37402 — the submit-time gate does not judge the object hand lock on a CREATE wizard', () => { + /** True over the wizard's own values (step 1 fills `subject` with 'S1'). */ + const LOCK_TRUE_ON_CREATE = "record.subject == 'S1'"; + const CONFIRMED_LOCK = "record.status == 'confirmed'"; + + function lockedSchema(uiReadonlyWhen: string) { + return { + name: 'order', + uiReadonlyWhen, + fields: { + subject: { type: 'text', label: 'Subject' }, + status: { type: 'text', label: 'Status' }, + owner: { type: 'text', label: 'Owner', required: true }, + // Keeps itself editable inside a locked record, so an edit can be made. + notes: { type: 'text', label: 'Notes', uiReadonlyWhen: 'false' }, + }, + }; + } + + function mount(mode: 'create' | 'edit', uiReadonlyWhen: string, stored?: Record) { + const dataSource: any = { + getObjectSchema: vi.fn().mockResolvedValue(lockedSchema(uiReadonlyWhen)), + findOne: vi.fn().mockResolvedValue(stored ? { id: 'o1', ...stored } : null), + create: vi.fn().mockResolvedValue({ id: 'o1' }), + update: vi.fn(async (_o: string, _id: string, d: any) => ({ id: 'o1', ...stored, ...d })), + }; + render( + + + , + ); + return dataSource; + } + + it('a CREATE wizard over a locked object still demands the empty required field', async () => { + const ds = mount('create', LOCK_TRUE_ON_CREATE); + await waitFor(() => expect(document.body.querySelector('[data-field="subject"]')).toBeTruthy()); + fill('subject', 'S1'); + fireEvent.click(stepIndicator(2)); + await waitFor(() => expect(document.body.querySelector('[data-field="notes"]')).toBeTruthy()); + fill('notes', 'n'); + fireEvent.click(screen.getByRole('button', { name: /Create/i })); + await expectBlocked(ds); + }); + + it('CONTROL — an EDIT wizard on a confirmed record still treats the inheriting field as locked: it is not demanded', async () => { + const ds = mount('edit', CONFIRMED_LOCK, { subject: 'Order', status: 'confirmed', owner: null, notes: '' }); + // `subject` inherits the lock on this confirmed record, so it draws its read + // face, not an input: wait for the stored record to load instead. + await waitFor(() => expect(ds.findOne).toHaveBeenCalled()); + await waitFor(() => expect(document.body.querySelector('[data-field="subject"]')).toBeTruthy()); + await waitFor(() => expect(document.body.textContent ?? '').toContain('Order')); + fireEvent.click(stepIndicator(2)); + await waitFor(() => expect(document.body.querySelector('[data-field="notes"]')).toBeTruthy()); + fill('notes', 'followed up'); + fireEvent.click(screen.getByRole('button', { name: /Update/i })); + await waitFor(() => expect(ds.update).toHaveBeenCalledTimes(1)); + }); +}); From fe52e09c7884d94d9f59d32b601629d4da210cd5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 10:04:16 +0000 Subject: [PATCH 14/15] fix(mcp): shorten describe_object's object-lock clause to fit the tools/list byte ceiling Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- packages/mcp/src/mcp-http-tools.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index a7743d23c69..059a487596e 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -4000,10 +4000,9 @@ export function registerObjectTools( + 'does not honour it yet; ' + 'your write may still set it, judged by the validations), system, ' + 'options (send the value) and defaultValue (omit the field to get it; never copy the value); the active ' - + 'validations; the enabled features; and the object\'s uiReadonlyWhen where set (while it holds, a person ' - + 'cannot edit any field of the record at the console; a field that lists its own uiReadonlyWhen is judged ' - + 'by that predicate instead, which may itself lock it, and one listing uiReadonly: true is always locked; ' - + 'so reach for an action; your write may still set every field, judged by the validations). ' + + 'validations; the enabled features; the object\'s uiReadonlyWhen where set (while true no person edits ' + + 'the record at the console, but a field listing its own uiReadonly / uiReadonlyWhen is judged by that, ' + + 'which may lock it too; use an action; your write may still set every field). ' + 'readonly is the schema\'s, not your edit permission.', inputSchema: strictToolInput( { surface: 'this describe_object call', aliases: { ...OBJECT_NAME_ALIASES, name: 'objectName' } }, From b012f9b6094cfc372f46c5a64cbecc127b733524 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 11:36:05 +0000 Subject: [PATCH 15/15] test(dogfood): the expression conformance ledger classifies ObjectSchema.uiReadonlyWhen Claude-Session: https://claude.ai/code/session_017xRBcRd37NZMCYvVAmVk4b Co-authored-by: Claude --- .../qa/dogfood/test/expression-conformance.ledger.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/qa/dogfood/test/expression-conformance.ledger.ts b/packages/qa/dogfood/test/expression-conformance.ledger.ts index 94812cdf400..20a124500c1 100644 --- a/packages/qa/dogfood/test/expression-conformance.ledger.ts +++ b/packages/qa/dogfood/test/expression-conformance.ledger.ts @@ -237,12 +237,17 @@ export const EXPRESSION_SURFACE: ExprSurface[] = [ // server rule-validator; a fault LOCKS the field (`fail-closed`), where // that row is `fail-soft-log`; and no server reads it at all. The server // lock is `readonlyWhen`, classified by `cel-field-rule`. + // #37402 — the object level of the same lock (`ObjectSchema.uiReadonlyWhen`) + // is a second cover, not a row of its own: it runs through the same verdict + // (`effectiveUiReadonlyWhen` folds it in as the default of every field that + // declares no hand lock of its own), with the same record binding, the same + // fail-closed answer and the same authoring check. id: 'cel-field-ui-readonly-when', - summary: "a field's console hand lock (Field.uiReadonlyWhen) — UI only, fails closed", + summary: "the console hand lock (Field.uiReadonlyWhen, and the object's whole-record ObjectSchema.uiReadonlyWhen) — UI only, fails closed", dialect: 'cel', mode: 'interpret', state: 'enforced', failPolicy: 'fail-closed', enforcement: - 'console (ui/) resolveFieldRuleState → evalFieldPredicate (core/evaluator/fieldRules.ts) → @objectstack/formula celEngine (interpret) — called directly by the edit dialog and the grid cell, and through the one verdict fieldReadOnlyByHand (core/evaluator/handLock.ts) everywhere else — evaluated per existing record with the row bound as `record` (plus `previous` and the host predicate scope), by the hosts that let a person edit a stored record: the edit dialog (which also refuses submit while the predicate faults), the record page (inline edit, highlight chip, save bar, stage path), grid cells and the line-item grid\'s stored rows, kanban drag, calendar drag, the Gantt\'s writes and the timesheet cell. A create is not judged. A predicate that faults answers LOCKED (UI_READONLY_WHEN_FAULTED = true), because nothing behind it judges the write. UI only: no server evaluates it, and an API or automation write is not refused by it; the server lock is `readonlyWhen`. Judged at authoring by lint\'s field-rule pass (`validate-expressions.ts`) as `readonlyWhen` is', - covers: ['data/field.zod.ts:FieldSchema.uiReadonlyWhen'], + 'console (ui/) resolveFieldRuleState → evalFieldPredicate (core/evaluator/fieldRules.ts) → @objectstack/formula celEngine (interpret) — called directly by the edit dialog and the grid cell, and through the one verdict fieldReadOnlyByHand (core/evaluator/handLock.ts) everywhere else — evaluated per existing record with the row bound as `record` (plus `previous` and the host predicate scope), by the hosts that let a person edit a stored record: the edit dialog (which also refuses submit while the predicate faults), the record page (inline edit, highlight chip, save bar, stage path), grid cells and the line-item grid\'s stored rows, kanban drag, calendar drag, the Gantt\'s writes and the timesheet cell. A create is not judged. A predicate that faults answers LOCKED (UI_READONLY_WHEN_FAULTED = true), because nothing behind it judges the write. UI only: no server evaluates it, and an API or automation write is not refused by it; the server lock is `readonlyWhen`. Judged at authoring by lint\'s field-rule pass (`validate-expressions.ts`) as `readonlyWhen` is. The object\'s `uiReadonlyWhen` is the default predicate of every field that declares no hand lock of its own (`uiReadonly: true` or a `uiReadonlyWhen`): folded in by effectiveUiReadonlyWhen (core/evaluator/handLock.ts) and judged by the same verdict on the same hosts, faulting LOCKED likewise; lint checks the object slot at `object \'NAME\' uiReadonlyWhen` the same way', + covers: ['data/field.zod.ts:FieldSchema.uiReadonlyWhen', 'data/object.zod.ts:ObjectSchemaBase.uiReadonlyWhen'], proof: 'ui/packages/core/src/evaluator/__tests__/handLock-36806.test.ts', }, {