Skip to content

Commit 5ff9712

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-7wiz8y
2 parents 89308f3 + a26abbc commit 5ff9712

15 files changed

Lines changed: 400 additions & 36 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@objectstack/service-automation': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
fix(automation)!: a `currency` or `percent` screen field refuses a non-number on resume, as a `number` field does, and the console renders `percent` as a numeric input (#30178)
7+
8+
Clause-②: yes (narrowing) — `POST …/runs/RUN/resume` refuses a string under a `type: 'currency'` or `type: 'percent'` screen field, a bag it accepted before. Nothing is widened.
9+
Metadata-protocol: none
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no stored row changes: ScreenFieldConfigSchema keeps its shape, and the screen-field type stays an open widget hint. What narrows is the resume door's accept set for one value shape on two existing members, so there is nothing at rest for a migration to rewrite; the caller sends a JSON number. -->
12+
13+
**BREAKING** accept-set narrowing at the screen-flow resume door.
14+
15+
- **Before.** A `type: 'percent'` or `type: 'currency'` screen field took any string on resume: `"75"` under a `max` of 60, `"abc"` too. The bound compares numbers, so it never judged a string, and the run consumed its suspension on the value. The console rendered `percent` as a text input and posted a string, so a `percent` field's `min` / `max` held for no console user.
16+
- **Now.** `number`, `currency` and `percent` are one value domain: a present value that is not a finite JSON number is refused with `invalid_type` inside `400 INVALID_SCREEN_INPUT`, the suspension is kept, and a corrected resume still lands. A numeric string is not read as the number it spells. The console renders `percent` as a numeric input carrying `min` / `max`, so it posts a number and the browser stops an over-limit value before any request.
17+
- **Unchanged.** An absent value and a hidden field are not judged; `rating`, `slider`, `progress`, `text` and untyped fields still take a string; a JSON number on `currency` / `percent` is judged against the bound as before.
18+
- **For a caller that skips the console.** The resume bag carries the JSON number (`60`), not a string; the refusal names the field and says it must be a number. No stored metadata changes, so there is nothing for `objectstack migrate meta` to rewrite.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/spec': patch
3+
---
4+
5+
docs(spec)!: the screen-field contract names `number`, `currency` and `percent` as the numeric value domain the resume enforces (#30178)
6+
7+
Clause-②: yes (narrowing) — the resume door refuses a string under a `type: 'currency'` or `type: 'percent'` screen field (`@objectstack/service-automation`); this package's `ScreenFieldSpec` and `ScreenFieldConfigSchema` text now states that rule. No schema shape changes.
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) Only TSDoc and one describe string change: ScreenFieldConfigSchema and ScreenFieldSpec keep every key and type, so nothing an author wrote is refused at parse time and nothing at rest moves. The narrowing they describe is the resume door's, on a submitted value, which no migration can rewrite. -->
11+
12+
**BREAKING** (described here, enforced in `@objectstack/service-automation`): a `currency` or `percent` screen field takes a finite JSON number on resume, as a `number` field does; a numeric string is refused with `invalid_type`, never coerced. `ScreenFieldSpec.type` / `.min` / `.max` and `ScreenFieldConfigSchema.type` / `.min` / `.max` say so, and the `type` describe text names the three kinds.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql): an uninstalled package no longer reads as read-only until a restart
6+
7+
Clause-②: yes (widening) — `@objectstack/objectql`'s exported `SchemaRegistry` gains the public method `onPackageUninstalled(listener)`, which returns its unsubscribe. Nothing is refused that was accepted before.
8+
Metadata-protocol: none
9+
10+
An administrator who uninstalled a package through `DELETE /api/v1/marketplace/install-local/:id` got a 200 "withdrawn from the running kernel", but on the same instance the package id still read as a booted code package until the server restarted. Uninstalling a `<base>.custom` pair that an older runtime had installed as code, as the pair install now prescribes, left `POST /api/v1/packages/<base>/ensure-customization` answering `created: true` with `writable: false`, so nothing could be customized into the new pair. The engine's manifest map, which the ADR-0070 writability check reads first, kept the id after the registry had withdrawn the package.
11+
12+
`SchemaRegistry.uninstallPackage` now announces each completed uninstall to `onPackageUninstalled` listeners, after the package record is gone (never for a refused uninstall), and the engine drops its manifest entry there, so the id is released on whichever door withdrew the package, not per door. A reinstall of the same id registers it again as before. A listener that throws does not turn the completed uninstall into a refusal; it is logged at `error`.

‎content/docs/automation/flows.mdx‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,12 @@ field's declared contract is the only contract behind it — there is no object
800800
schema to catch a bad bag downstream.
801801

802802
That sentence carries no "if the value is a number" qualifier, because the
803-
shape is checked first: on a `type: 'number'` field a submitted value that is
804-
not a JSON number is **refused** on resume with `invalid_type`. `"25"` — the
805-
same quantity as a *string* — is **not coerced** into `25` and does not reach
806-
the bound; it is rejected as the wrong shape. The bound then compares numbers
807-
only, which is all a bound can do.
803+
shape is checked first: on a numeric field — `type: 'number'`, `'currency'` or
804+
`'percent'` — a submitted value that is not a JSON number is **refused** on
805+
resume with `invalid_type`. `"25"` — the same quantity as a *string* — is **not
806+
coerced** into `25` and does not reach the bound; it is rejected as the wrong
807+
shape. The bound then compares numbers only, which is all a bound can do. The
808+
console renders all three kinds as a numeric input, which posts a number.
808809

809810
**What these keys refuse:**
810811

@@ -835,7 +836,8 @@ only, which is all a bound can do.
835836
- **A bound on a non-numeric field.** A screen field's `type` has no closed
836837
vocabulary, so this schema cannot judge which types a bound is meaningful on.
837838
A bound on a `text` field constrains nothing and is not an error — the shape
838-
check above reads `type: 'number'` alone, never the presence of a bound.
839+
check above reads the three numeric kinds alone (not `rating`, `slider` or
840+
`progress`), never the presence of a bound.
839841
- **An absent value.** A bound constrains a value that is present — an optional
840842
bounded field left empty is conformant. Presence is `required`'s question.
841843
- **A bound on a field the user was never shown.** Like `required`, a bound on a
@@ -1353,8 +1355,9 @@ POST /api/v1/automation/{flow}/runs/{runId}/resume
13531355
```
13541356

13551357
These conditions are refused, all reported at once and all with
1356-
`code: 'INVALID_SCREEN_INPUT'` (the value shapes of `type: 'number'` and
1357-
`type: 'file'`, and the `min` / `max` bounds, are described with those fields
1358+
`code: 'INVALID_SCREEN_INPUT'` (the value shapes of the numeric kinds
1359+
`number` / `currency` / `percent` and of `type: 'file'`, and the `min` / `max`
1360+
bounds, are described with those fields
13581361
above):
13591362

13601363
- a **`required` field the caller was actually asked for** is missing (an empty

‎content/docs/references/automation/builtin-node-config.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ A value: a CEL value envelope `{ dialect: 'cel', source }` evaluated by the expr
289289
| :--- | :--- | :--- | :--- |
290290
| **name** | `string` | ✅ | Field name (the flow variable the value binds to) — a name without a leading `$` (the `$` names are the flow engine's own), read as `{{ name }}` |
291291
| **label** | `string` | optional | Display label |
292-
| **type** | `string` | optional | Input type — an open widget hint (text, number, select, …); `file` renders the platform upload widget and the screen resumes with the uploaded file's id, which a later node writes into a `file` field; `record_link` shows the `reference` record whose id `defaultValue` evaluates to, by its display name, as a link to its record page, and takes no input |
292+
| **type** | `string` | optional | Input type — an open widget hint (text, number, select, …); `number`, `currency` and `percent` take a finite number on resume (a numeric string is refused); `file` renders the platform upload widget and the screen resumes with the uploaded file's id, which a later node writes into a `file` field; `record_link` shows the `reference` record whose id `defaultValue` evaluates to, by its display name, as a link to its record page, and takes no input |
293293
| **required** | `boolean` | optional | Whether a value is required to submit |
294294
| **options** | `{ value: any; label: string }[]` | optional | Choices for a select-style field; option values must stay distinct when read as text |
295295
| **defaultValue** | `any` | optional | Prefilled value: a CEL value envelope `{ dialect: 'cel', source }` evaluated when the screen is served (the client receives the value, never the envelope), or a literal written as it is — a `{…}` template token is refused |
@@ -311,7 +311,7 @@ A value: a CEL value envelope `{ dialect: 'cel', source }` evaluated by the expr
311311
| :--- | :--- | :--- | :--- |
312312
| **name** | `string` | ✅ | Field name (the flow variable the value binds to) — a name without a leading `$` (the `$` names are the flow engine's own), read as `{{ name }}` |
313313
| **label** | `string` | optional | Display label |
314-
| **type** | `string` | optional | Input type — an open widget hint (text, number, select, …); `file` renders the platform upload widget and the screen resumes with the uploaded file's id, which a later node writes into a `file` field; `record_link` shows the `reference` record whose id `defaultValue` evaluates to, by its display name, as a link to its record page, and takes no input |
314+
| **type** | `string` | optional | Input type — an open widget hint (text, number, select, …); `number`, `currency` and `percent` take a finite number on resume (a numeric string is refused); `file` renders the platform upload widget and the screen resumes with the uploaded file's id, which a later node writes into a `file` field; `record_link` shows the `reference` record whose id `defaultValue` evaluates to, by its display name, as a link to its record page, and takes no input |
315315
| **required** | `boolean` | optional | Whether a value is required to submit |
316316
| **options** | `{ value: any; label: string }[]` | optional | Choices for a select-style field; option values must stay distinct when read as text |
317317
| **defaultValue** | `any` | optional | Prefilled value: a CEL value envelope `{ dialect: 'cel', source }` evaluated when the screen is served (the client receives the value, never the envelope), or a literal written as it is — a `{…}` template token is refused |
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* #30215 — an uninstalled package stops reading as a booted code package on
5+
* the running instance.
6+
*
7+
* `registerApp` puts a package's manifest in the engine's `manifests` map, and
8+
* ADR-0070's `isWritablePackage` reads that map FIRST: an id in it is a code
9+
* package, read-only. Every uninstall door (the protocol's `deletePackage`,
10+
* `DELETE /packages/:id`, the install-local DELETE) withdraws the package
11+
* through `SchemaRegistry.uninstallPackage`, and nothing took the id out of
12+
* the engine's map. So an administrator who uninstalled a package got a 200,
13+
* then `ensure-customization` on the same instance answered `writable: false`
14+
* for it until the server restarted.
15+
*
16+
* Pinned here, against a real engine and its own registry:
17+
* - the registry's uninstall drops the engine's manifest entry, so the
18+
* predicate answers writable again;
19+
* - an uninstall the registry REFUSES (ADR-0029: another package extends an
20+
* object this one owns) removes nothing, the manifest entry included;
21+
* - a reinstall of the same id puts the entry back (read-only again);
22+
* - the registry's announcement: once per withdrawn package, never for an id
23+
* it does not hold, never after unsubscribe, and a throwing listener does
24+
* not turn a completed uninstall into a refused one.
25+
*/
26+
27+
import { describe, it, expect, vi, afterEach } from 'vitest';
28+
import { isWritablePackage } from '@objectstack/metadata-protocol';
29+
import { ObjectQL } from './engine.js';
30+
import { SchemaRegistry } from './registry.js';
31+
32+
const PKG = 'com.example.tasksapp';
33+
34+
function manifestsOf(engine: ObjectQL): Map<string, unknown> {
35+
return (engine as unknown as { manifests: Map<string, unknown> }).manifests;
36+
}
37+
38+
function bootWithPackage(): ObjectQL {
39+
const engine = new ObjectQL();
40+
engine.registerApp({
41+
id: PKG,
42+
namespace: 'tasks_app',
43+
objects: [{ name: 'tasks_app_task', fields: { name: { type: 'text' } } }],
44+
} as any);
45+
return engine;
46+
}
47+
48+
describe('ObjectQL — an uninstall forgets the package\'s manifest (#30215)', () => {
49+
it('reads a registered code package as read-only, and writable once the registry uninstalls it', () => {
50+
const engine = bootWithPackage();
51+
expect(manifestsOf(engine).has(PKG)).toBe(true);
52+
expect(isWritablePackage(engine, PKG)).toBe(false);
53+
54+
expect(engine.registry.uninstallPackage(PKG)).toBe(true);
55+
56+
expect(engine.registry.getPackage(PKG)).toBeUndefined();
57+
expect(manifestsOf(engine).has(PKG)).toBe(false);
58+
expect(isWritablePackage(engine, PKG)).toBe(true);
59+
});
60+
61+
it('keeps the manifest entry when the registry refuses the uninstall (an extended object)', () => {
62+
const engine = bootWithPackage();
63+
engine.registry.registerObject(
64+
{ name: 'tasks_app_task', fields: {} } as any, 'com.example.addon', undefined, 'extend',
65+
);
66+
67+
expect(() => engine.registry.uninstallPackage(PKG)).toThrow();
68+
69+
expect(engine.registry.getPackage(PKG)).toBeDefined();
70+
expect(manifestsOf(engine).has(PKG)).toBe(true);
71+
expect(isWritablePackage(engine, PKG)).toBe(false);
72+
});
73+
74+
it('puts the entry back on a reinstall of the same id', () => {
75+
const engine = bootWithPackage();
76+
engine.registry.uninstallPackage(PKG);
77+
expect(isWritablePackage(engine, PKG)).toBe(true);
78+
79+
engine.registerApp({
80+
id: PKG,
81+
namespace: 'tasks_app',
82+
objects: [{ name: 'tasks_app_task', fields: { name: { type: 'text' } } }],
83+
} as any);
84+
85+
expect(manifestsOf(engine).has(PKG)).toBe(true);
86+
expect(isWritablePackage(engine, PKG)).toBe(false);
87+
});
88+
89+
it('leaves every other package\'s manifest entry in place', () => {
90+
const engine = bootWithPackage();
91+
engine.registerApp({ id: 'com.example.notesapp', namespace: 'notes_app' } as any);
92+
93+
engine.registry.uninstallPackage(PKG);
94+
95+
expect(manifestsOf(engine).has('com.example.notesapp')).toBe(true);
96+
expect(isWritablePackage(engine, 'com.example.notesapp')).toBe(false);
97+
});
98+
});
99+
100+
describe('SchemaRegistry.onPackageUninstalled (#30215)', () => {
101+
afterEach(() => { vi.restoreAllMocks(); });
102+
103+
function registryWith(id: string): SchemaRegistry {
104+
const registry = new SchemaRegistry();
105+
registry.installPackage({ id, name: id, version: '1.0.0', type: 'app' } as any, 'code');
106+
return registry;
107+
}
108+
109+
it('announces a withdrawn package once, after its record is gone', () => {
110+
const registry = registryWith(PKG);
111+
const seen: Array<{ id: string; recordGone: boolean }> = [];
112+
registry.onPackageUninstalled((id) => {
113+
seen.push({ id, recordGone: registry.getPackage(id) === undefined });
114+
});
115+
116+
vi.spyOn(console, 'warn').mockImplementation(() => {});
117+
registry.uninstallPackage(PKG);
118+
registry.uninstallPackage(PKG); // nothing left to withdraw
119+
120+
expect(seen).toEqual([{ id: PKG, recordGone: true }]);
121+
});
122+
123+
it('announces nothing for an id the registry does not hold, or after unsubscribe', () => {
124+
const registry = registryWith(PKG);
125+
const listener = vi.fn();
126+
vi.spyOn(console, 'warn').mockImplementation(() => {});
127+
const unsubscribe = registry.onPackageUninstalled(listener);
128+
129+
registry.uninstallPackage('com.example.never-installed');
130+
expect(listener).not.toHaveBeenCalled();
131+
132+
unsubscribe();
133+
registry.uninstallPackage(PKG);
134+
expect(listener).not.toHaveBeenCalled();
135+
});
136+
137+
it('a throwing listener neither refuses the uninstall nor starves the next listener, and is logged at error', () => {
138+
const registry = registryWith(PKG);
139+
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
140+
const next = vi.fn();
141+
registry.onPackageUninstalled(() => { throw new Error('boom'); });
142+
registry.onPackageUninstalled(next);
143+
144+
expect(registry.uninstallPackage(PKG)).toBe(true);
145+
146+
expect(registry.getPackage(PKG)).toBeUndefined();
147+
expect(next).toHaveBeenCalledWith(PKG);
148+
expect(error).toHaveBeenCalledTimes(1);
149+
expect(String(error.mock.calls[0][0])).toContain(`package "${PKG}" was uninstalled`);
150+
expect(String(error.mock.calls[0][0])).toContain('boom');
151+
});
152+
});

‎packages/objectql/src/engine.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,12 @@ export class ObjectQL implements IObjectQLEngine {
740740
constructor(hostContext: Record<string, any> = {}) {
741741
// Use provided logger or create a new one
742742
this.logger = hostContext.logger || createLogger({ level: 'info', format: 'pretty' });
743+
// [#30215] `registerApp` writes `manifests`; an uninstall withdraws the
744+
// package through the registry's own verb, on every door, so the entry goes
745+
// with the registry's record. Left behind, ADR-0070's `isWritablePackage`
746+
// (which reads this map first) kept an uninstalled package read-only until
747+
// a restart.
748+
this._registry.onPackageUninstalled((packageId) => { this.manifests.delete(packageId); });
743749
// Pick up production hardening switches from env so deployers can
744750
// enforce strict-body without code changes:
745751
// OBJECTQL_STRICT_HOOKS=1 → unresolved hooks throw at bind time

‎packages/objectql/src/registry-module-mock.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ export function createRegistryModuleMock(
183183
// a refused registration is put back. The double runs the body as given:
184184
// it records nothing, so it has nothing to put back.
185185
restoringOnRefusal: vi.fn((register: () => unknown) => register()),
186+
// [#30215] Every engine subscribes in its constructor, so its manifest map
187+
// forgets a package the registry uninstalls. The double never uninstalls,
188+
// so it never announces: it records the subscription and answers the
189+
// unsubscribe the real member answers.
190+
onPackageUninstalled: vi.fn(() => () => {}),
186191
reset: vi.fn(),
187192
metadata: { get: vi.fn(() => new Map()) },
188193
...instanceOverrides,

0 commit comments

Comments
 (0)