Skip to content

Commit a2c2e31

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/issue-36558-scenario-scorer-gallery-refresh
2 parents 07ee2d5 + 42b4060 commit a2c2e31

47 files changed

Lines changed: 1352 additions & 121 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/plugin-approvals': patch
3+
'@objectstack/plugin-audit': patch
4+
---
5+
6+
fix(approvals,audit): an approval's flow and position labels, and a renamed object's label in approvals and activity summaries, read as the metadata translators serve them
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
In a deployment whose `i18n.sourceLocale` differs from its `i18n.defaultLocale` (an app authored in English that defaults its users to Chinese, say), the approvals door still looked up a request's flow label (`flows.<flow>.label`) and a position's label (`positions.<name>.label`) through `II18nService.t()`, which falls back to the `defaultLocale` row when the reader's locale has no entry. So an `en` or `en-US` reader saw the Chinese flow name on the inbox, the request page and the generic data door's request rows, and the Chinese position name in a timeline note, where the authored text was expected. Both labels now resolve through the spec translators of their types (`translateFlow`, `translatePosition` from `@objectstack/spec/system`) over every locale the i18n service holds. They use the resolve options the metadata route builds: the reader's locale, the declared fallback chain, and the authored language (the declared `sourceLocale`, else `defaultLocale`). A reader in the authored language now reads the label as written, and every other reader reads the same row as before.
12+
13+
A packaged object renamed by a code extension was named in the reader's language by the bundle's translation of its OLD label. This hit the approvals inbox, request page and object-naming refusals, and the object label inside an activity summary, where `GET /meta/object` serves the rename. Both readers now hand `translateObject` the object's served definition and its packaged base (`packagedBase`, read off the engine's registry through `getPackagedObjectBase`, the base `/meta` reads). So the rename stands in every locale, as on `/meta`, and an unrenamed object reads its translation as before.
14+
15+
An approval step's label (`flows.<flow>.approvals.<node_id>.label`) is still read through `t()`: no spec translator reads that key yet.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/fields': patch
3+
---
4+
5+
fix(fields): a tap anywhere on a lookup picker option selects it, including on a record chip in its preview
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A lookup picker's option shows a preview of its other columns under its label. A column that references another record drew a link to that record there (on a record page, its chip), and a tap or a click on it opened that record instead of selecting the option, leaving the edit behind. An email, URL or phone column in the preview did the same with the mail client, the browser or the dialer.
11+
12+
The preview now draws every column the way the "browse all records" picker table already did: a reference keeps its face, the record page's chip included, without the link, and an email, URL, phone or file column shows its text. A tap or a click anywhere on the option selects it, on a phone and on a desktop. Both picker surfaces now take this rule from the one renderer they share.
13+
14+
What does not change: the read cells outside the picker (record page fields, list and grid cells) keep their links. No metadata key, value or default changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@objectstack/plugin-audit': patch
4+
'@objectstack/platform-objects': patch
5+
'@object-ui/app-shell': patch
6+
'@object-ui/i18n': patch
7+
---
8+
9+
feat(studio): the Field History setting offers Default, On and Off, and Default says what it resolves to
10+
11+
Clause-②: yes (widening)
12+
Metadata-protocol: none
13+
14+
The Field History setting on the field form, on each row of the object form's field list, and in the object's capabilities is now a three-way choice instead of a switch. Default leaves the setting unset, so the field (or object) follows the platform, and it names what that means for the row: "Default (On)" for most field types, "Default (Off)" for a media or JSON field unless the field opts in with Track History, and for a credential field always. On and Off write `true` and `false` as before. A setting turned off can now be returned to Default, which removes the key.
15+
16+
`@objectstack/spec/data` exports `resolveFieldHistory(field, object)` and `FIELD_HISTORY_DEFAULT_OFF_TYPES`: whether a changed field's old → new values show on the activity timeline, and the types that are off by default. The activity writer in `@objectstack/plugin-audit` now asks this predicate instead of its own copy of the type list, so the default the form shows and what the writer keeps cannot disagree. Behaviour of the writer is unchanged.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the design-mode menu builds on a case-insensitive file system — its helper module no longer shares the component's name up to letter case
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`layout/` held the menu editor component `DesignModeMenu.tsx` beside its pure tree helpers `designModeMenu.ts`. On a case-insensitive file system (the macOS default) the sidebar's lazy `import('./DesignModeMenu.js')` tried `.ts` first and found the helper module, which has no default export: the `@object-ui/app-shell` build failed with TS1149 ("differs from already included file name … only in casing"), and a Console bundled there turned the whole page white when 「Edit app」 opened design mode. The helpers are now `designModeMenuModel.ts` (its test `designModeMenuModel-36363.test.ts`), so `./DesignModeMenu.js` can only reach the component. No behaviour changes; Linux builds were never affected.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/driver-sql': patch
3+
---
4+
5+
fix(driver-sql): removing a field's default stores NULL on MySQL 8, and never leaves a NOT NULL column refusing writes
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
#36245 made schema sync drop a column DEFAULT the field no longer declares. On MySQL 8 the drop left the column with no default at all, so an insert that omitted the field was refused ("Field … doesn't have a default value") where Postgres and SQLite store NULL. On a nullable column MySQL now sets the default to NULL instead, so an unset insert stores NULL on all three databases.
11+
12+
On a NOT NULL column the drop no longer travels alone, because the database would then refuse every insert that omits the field. When the field does not hold the column NOT NULL (no `storage.notNull` and not `required`, or `storage: { notNull: false }` in words), the drop is reported together with relaxing the column, both `needs_confirm`: `os migrate apply` applies them, and so do the publish of the object and the managed install of its package when the field declares `storage: { notNull: false }`. Afterwards an unset insert stores NULL. Dev auto-reconcile applies neither, as before for a relax. When the field still holds the column NOT NULL (`storage: { notNull: true }` or `required`), the column is left alone and the stale default is reported as `destructive`, which no automatic path applies. No metadata key, value or default changes.

‎packages/drivers/driver-sql/src/schema-drift.ts‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,12 @@ export function diffManagedTable(args: {
13441344
// explicit physical constraint — NOT against `required`, which is the
13451345
// write-time contract and implies nothing about the column) ──────────
13461346
const expectNullable = field.storage?.notNull !== true;
1347+
// [#36596] Whether a `relax_not_null` is proposed for this column: the
1348+
// literal-DEFAULT arm below drops a NOT NULL column's stale default only
1349+
// alongside it, never alone.
1350+
let relaxProposed = false;
13471351
if (expectNullable && !col.nullable && field.storage?.notNull === false && fieldName !== ceremonyOwnedNullability) {
1352+
relaxProposed = true;
13481353
// [#32590] The author DECLARED the column nullable — `storage: { notNull:
13491354
// false }`, written out, not merely absent. The column constraint is the
13501355
// declaration's to own (ADR-0113 D2), and this is the "deliberately
@@ -1385,6 +1390,7 @@ export function diffManagedTable(args: {
13851390
`package applies it ("os package install"); or relax it deliberately via "os migrate apply".`,
13861391
});
13871392
} else if (expectNullable && !col.nullable && field.required !== true && fieldName !== ceremonyOwnedNullability) {
1393+
relaxProposed = true;
13881394
// Column STRICTER than its declaration — and the field is not even
13891395
// write-gated, so an omitting write reaches the DB and dies as a raw
13901396
// driver error instead of a clean validation 400. That surprise is
@@ -1491,7 +1497,7 @@ export function diffManagedTable(args: {
14911497
const physical = physicalDefaultLiteral(col.defaultValue);
14921498
const multiValue = isMultiValueField({ type: String(field.type ?? ''), multiple: field.multiple === true });
14931499
if (physical.kind === 'literal' && !multiValue) {
1494-
if (dv === undefined || dv === null) {
1500+
if ((dv === undefined || dv === null) && col.nullable) {
14951501
out.push({
14961502
kind: 'default_mismatch',
14971503
remoteName: table,
@@ -1508,6 +1514,43 @@ export function diffManagedTable(args: {
15081514
`database stores nothing. Dropping the default is non-destructive and rewrites no stored row. ` +
15091515
SAFE_COLUMN_REMEDY,
15101516
});
1517+
} else if (dv === undefined || dv === null) {
1518+
// [#36596] A NOT NULL column. Dropping its only DEFAULT alone would
1519+
// turn every insert that omits the field from "stores the old value"
1520+
// into "refused by the database" — so the drop never travels alone.
1521+
// Where the declaration does not hold the column NOT NULL (the relax
1522+
// above is proposed: `storage.notNull: false` in words, or no storage
1523+
// declaration on a field that is not `required`), the drop travels
1524+
// WITH that relax at the relax's own category, `needs_confirm`, and
1525+
// is applied by the same deliberate acts (publish / package install
1526+
// for the declared-`false` case, #33724; `os migrate apply`), after
1527+
// which an omitting insert stores NULL. Anywhere else (`storage:
1528+
// { notNull: true }`, a `required` field, the ceremony-owned tenant
1529+
// column) the column is left alone: the entry is `destructive`, so no
1530+
// automatic path applies it, and it is reported (warned at boot, listed
1531+
// by "os migrate plan") rather than silently ignored.
1532+
const pairs = relaxProposed;
1533+
out.push({
1534+
kind: 'default_mismatch',
1535+
remoteName: table,
1536+
table,
1537+
column: fieldName,
1538+
expected: '(no column default)',
1539+
actual: `DEFAULT ${quoteDefaultForMessage(physical.text)}`,
1540+
severity: 'warning',
1541+
category: pairs ? 'needs_confirm' : 'destructive',
1542+
op: { type: 'drop_column_default', table, column: fieldName },
1543+
message: pairs
1544+
? `${table}.${fieldName}: the NOT NULL column carries DEFAULT ${quoteDefaultForMessage(physical.text)}, but the ` +
1545+
`field declares no default and does not hold the column NOT NULL. Dropping the default goes with ` +
1546+
`relaxing the column (reported alongside), so an insert that omits the field stores NULL, as on a new ` +
1547+
`database; neither statement rewrites a stored row. Apply both together: publish the object, install ` +
1548+
`the package that declares it, or run "os migrate apply".`
1549+
: `${table}.${fieldName}: the NOT NULL column carries DEFAULT ${quoteDefaultForMessage(physical.text)}, but the ` +
1550+
`field declares no default. Left as it is: the column stays NOT NULL, so dropping its default would ` +
1551+
`make the database refuse every insert that omits the field. Declare the default again, or relax the ` +
1552+
`column (\`storage: { notNull: false }\`) and the default is dropped with it.`,
1553+
});
15111554
} else if ((typeof dv === 'string' || typeof dv === 'number' || typeof dv === 'boolean') && !isRuntimeDefaultValue(dv)) {
15121555
if (physicalLiteralMatches(physical.text, dv, field.type) === false) {
15131556
out.push({

‎packages/drivers/driver-sql/src/sql-driver-36245-stale-literal-default.test.ts‎

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
* neither reported nor changed; a changed literal stores the new value; a row
2929
* stored before is not rewritten; and with no auto-reconcile the two entries
3030
* are reported `safe` and applied by the explicit apply door.
31+
*
32+
* [#36596] §3, one cell per dialect: the same removal on a NOT NULL column.
33+
* #36245 first shipped a MySQL `DROP DEFAULT`, which on MySQL 8 leaves even a
34+
* NULLABLE column with no default at all, so §2's unset insert was refused
35+
* ("Field 'digest' doesn't have a default value", ER 1364) — MariaDB 10.11,
36+
* where it was measured, stores NULL. §2 now holds on MySQL 8 as it stands. On
37+
* a NOT NULL column the drop never travels alone, since an omitting insert
38+
* would then be refused: where the declaration does not hold the column NOT
39+
* NULL it is paired with the `relax_not_null` (`needs_confirm`, both applied by
40+
* the explicit apply door, and by the publish when the field says `storage:
41+
* { notNull: false }` in words), after which an unset insert stores NULL;
42+
* where it does, the column is left alone and the entry reported `destructive`.
3143
*/
3244

3345
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -198,6 +210,128 @@ function measure(cell: DialectCell): void {
198210
expect(await second.detectManagedDrift([SECOND])).toEqual([]);
199211
});
200212
});
213+
214+
describe(`#36596 §3 — a stale literal DEFAULT on a NOT NULL column (${cell.label})`, () => {
215+
const NN = 'os36596_pref';
216+
const open: SqlDriver[] = [];
217+
let dir: string | undefined;
218+
219+
const config = (): Record<string, any> => {
220+
if (cell.id !== 'sqlite') return cell.config();
221+
dir ??= mkdtempSync(join(tmpdir(), 'os36596-'));
222+
return { ...cell.config(), connection: { filename: join(dir, 'db.sqlite') } };
223+
};
224+
225+
const boot = async (obj: any, opts: Record<string, any> = {}): Promise<SqlDriver> => {
226+
const driver = new SqlDriver({ ...config(), ...opts } as any);
227+
(driver as any).logger = quietLogger();
228+
open.push(driver);
229+
await driver.initObjects([obj]);
230+
return driver;
231+
};
232+
233+
const insertUnset = async (driver: SqlDriver, id: string) => {
234+
await driver.create(NN, { id, title: id }, { bypassTenantAudit: true } as any);
235+
return (driver as any).knex(NN).where('id', id).first();
236+
};
237+
238+
/** The first release: `code` is NOT NULL, with a literal default. */
239+
const FIRST_NN = {
240+
name: NN,
241+
fields: {
242+
title: { type: 'string' },
243+
code: { type: 'string', defaultValue: 'none', storage: { notNull: true } },
244+
},
245+
} as any;
246+
const second = (code: Record<string, any>) => ({ name: NN, fields: { title: { type: 'string' }, code: { type: 'string', ...code } } }) as any;
247+
248+
/** Create the first release's table, then boot the second declaration over it. */
249+
const upgrade = async (next: any, opts: Record<string, any> = {}): Promise<SqlDriver> => {
250+
const first = await boot(FIRST_NN);
251+
await (first as any).knex.schema.dropTableIfExists(NN);
252+
await first.initObjects([FIRST_NN]);
253+
await first.disconnect();
254+
open.splice(open.indexOf(first), 1);
255+
return boot(next, opts);
256+
};
257+
258+
const nullable = async (driver: SqlDriver): Promise<boolean> =>
259+
(await (driver as any).knex(NN).columnInfo())?.code?.nullable === true;
260+
261+
afterEach(async () => {
262+
const last = open[open.length - 1];
263+
if (last) await (last as any).knex.schema.dropTableIfExists(NN);
264+
for (const d of open.splice(0)) await d.disconnect();
265+
if (dir) rmSync(dir, { recursive: true, force: true });
266+
dir = undefined;
267+
});
268+
269+
it('no default, no storage declaration, not required: the drop is paired with the relax and an unset insert then stores NULL', async () => {
270+
const next = second({});
271+
const driver = await upgrade(next, { autoMigrate: 'safe', schemaMode: 'managed' });
272+
273+
const drift = await driver.detectManagedDrift([next]);
274+
expect(drift.map((d) => [d.column, d.op.type, d.category]).sort()).toEqual([
275+
['code', 'drop_column_default', 'needs_confirm'],
276+
['code', 'relax_not_null', 'needs_confirm'],
277+
]);
278+
// Dev auto-reconcile applies neither (ADR-0113 D5): the column is left as
279+
// it was, so an unset insert still stores the old default, never refused.
280+
expect(await nullable(driver)).toBe(false);
281+
expect((await insertUnset(driver, 'unrepaired')).code).toBe('none');
282+
283+
const { applied, skipped } = await driver.applyMigrationEntries(drift, { allowDestructive: false });
284+
expect(skipped).toEqual([]);
285+
expect(applied).toHaveLength(2);
286+
expect(await nullable(driver)).toBe(true);
287+
expect((await insertUnset(driver, 'repaired')).code).toBeNull();
288+
expect(await driver.detectManagedDrift([next])).toEqual([]);
289+
// The row stored before keeps what it holds.
290+
expect((await (driver as any).knex(NN).where('id', 'unrepaired').first()).code).toBe('none');
291+
});
292+
293+
it('`storage: { notNull: false }` declared: the publish applies the relax and the drop together', async () => {
294+
const next = second({ storage: { notNull: false } });
295+
const driver = await upgrade(next);
296+
expect((await insertUnset(driver, 'unrepaired')).code).toBe('none');
297+
298+
const { applied, skipped } = await driver.applyPublishedColumnChanges(next);
299+
expect(skipped).toEqual([]);
300+
expect(applied.map((d) => d.op.type).sort()).toEqual(['drop_column_default', 'relax_not_null']);
301+
expect((await insertUnset(driver, 'repaired')).code).toBeNull();
302+
expect(await driver.detectManagedDrift([next])).toEqual([]);
303+
});
304+
305+
it('a declaration that still holds the column NOT NULL: the column is left alone and the entry reported `destructive`', async () => {
306+
const next = second({ storage: { notNull: true } });
307+
const driver = await upgrade(next, { autoMigrate: 'safe', schemaMode: 'managed' });
308+
309+
const drift = await driver.detectManagedDrift([next]);
310+
expect(drift.map((d) => [d.column, d.op.type, d.category])).toEqual([['code', 'drop_column_default', 'destructive']]);
311+
expect(drift[0].message).toMatch(/Left as it is/);
312+
313+
// Neither the boot, the publish nor the non-destructive apply door touches it.
314+
expect((await driver.applyPublishedColumnChanges(next)).applied).toEqual([]);
315+
const { applied } = await driver.applyMigrationEntries(drift, { allowDestructive: false });
316+
expect(applied).toEqual([]);
317+
expect(await nullable(driver)).toBe(false);
318+
expect((await insertUnset(driver, 'kept')).code).toBe('none');
319+
});
320+
321+
it('a `required` field over the NOT NULL column (no storage declaration): left alone and reported `destructive`', async () => {
322+
const next = second({ required: true });
323+
const driver = await upgrade(next);
324+
325+
const drift = await driver.detectManagedDrift([next]);
326+
// The relax stays silent for a legacy `required` field (ADR-0113); the
327+
// stale default is reported, never applied by a non-destructive door.
328+
expect(drift.map((d) => [d.column, d.op.type, d.category])).toEqual([['code', 'drop_column_default', 'destructive']]);
329+
expect((await driver.applyMigrationEntries(drift, { allowDestructive: false })).applied).toEqual([]);
330+
expect(await nullable(driver)).toBe(false);
331+
await driver.create(NN, { id: 'r', title: 'r', code: 'given' }, { bypassTenantAudit: true } as any);
332+
expect((await (driver as any).knex(NN).where('id', 'r').first()).code).toBe('given');
333+
});
334+
});
201335
}
202336

203337
for (const cell of DIALECT_CELLS) {

0 commit comments

Comments
 (0)