Skip to content

Commit 9dbf86c

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-rc3s3i
2 parents 24d01fe + 300f740 commit 9dbf86c

28 files changed

Lines changed: 1810 additions & 109 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): the scenario runner's seed owns a row only by a person the row names, and loads each persona's person row with its user
6+
7+
Clause-②: yes (widening) — `./runner` gains two exports, `personaRecords` (the record binding: each persona's `record` row, `object/id` → persona) and `rowOwner` (the persona a seed row is owned by). `personaHandles` keeps its signature and is now the handle map only: it holds a value from a direct scope rule on a declared user-handle field (`account.owner` = `u_sam`), no longer a row id or option value from any other direct scope rule (`e06`, `public`); on the three control cards its answer is unchanged. `seedApp` sets `owner_id` by the new rule and writes the persona's user id into its record row's `user` field.
8+
Metadata-protocol: none
9+
10+
The seed used to set a row's owner (`owner_id`) from any direct scope value that matched a persona's: an option (`ticket_comment.visibility = public` gave all 237 public comments on `service_desk` to the portal customer, 197 of them on other customers' tickets) or a lookup to a row that is no person (`ticket.group`, `employee.department`), and the last key read won a row two personas matched.
11+
12+
- **Owner rule.** A row is owned by a persona's user only when it IS that persona's `record`, when a declared direct lookup on it (`expect.lookups`) holds that record's id (`ticket.assignee = a02`), or when a declared user-handle field on it holds the persona's handle (the control cards' route, unchanged). The first persona in `run.personas` order the row names owns it. Every other row keeps the inserter, the admin.
13+
- **Person binding.** Each persona's `record` row is loaded with that persona's user id in its `user` field (`PERSON_USER_FIELD`). Without persona accounts (the gallery's screenshot boot) no `user` field and no record-bound owner is set.
14+
- **Build prompt.** The Row ownership section names the person rows, asks for an optional `user`-type field named `user` on each person object, lists the lookups that name a person, states the persona order for a row naming two, and adds a platform-boundary line: the open-source server has no hierarchy resolver, so a person who must see rows another person owns gets them through what the build models.
15+
16+
On `service_desk` the portal customer now owns no comment (was 237), the 5 tickets that name both the support agent and the portal customer go to the support agent, the team lead owns no ticket through `group` (was 78), and `cus_03`, `a02`, `a04` are their personas' rows.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
feat(scenarios): `gallery-refresh`, the gallery refresh in one deterministic step
6+
7+
Clause-②: yes — a new `gallery-refresh` entry point on the published `@objectstack/scenarios` widens its surface; the PR body carries the reading
8+
Metadata-protocol: none
9+
10+
- **`pnpm --filter @objectstack/scenarios gallery-refresh --gallery DIR [--cards DIR] [--model M] [--debut] [--work DIR] [--chromium PATH]`** (`src/export/refresh-cli.ts`): reads npm's latest stable `@objectstack/cli` and the `framework.version` of every app the gallery checkout's `index.json` lists. When every listed app states that release it prints one `skip: …` line and exits 0, having run nothing; it also skips while a remote-tracking `export/<version>` branch awaits review. Otherwise it runs every card the gallery may show (origin `generic`, tier `starter` or `delivery`; `--debut`: the first of them, only into an empty gallery) with `run-scenarios --modes scratch --packages published --create-version <version>`, exports with screenshots into the checkout, commits `apps/` and `index.json` on a new local branch `export/<version>` and prints the branch, the commit and a ready PR body. It never pushes and never opens a PR. Every refusal (not a clean checkout, an index that does not validate, a prerelease `latest`, an existing local branch, no app exported, an app on another framework version, a change outside `apps/` and `index.json`) exits 1 with the reason.
11+
- **`@objectstack/scenarios/export`** also exports the step as a library: `galleryRefresh`, `runnerArgv`, `readGalleryVersions`, `npmLatestVersion`, `refreshPrBody`, `galleryBranch`, `RefreshRefusal`, `FRAMEWORK_PACKAGE`, `STABLE_VERSION` and their types.
12+
- The live driver's header names ruling D2: a local session or a scheduled cloud Claude Code task on the maintainer's subscription login may run the cards; an API-billed model still never may. The driver's refusal of an API key is unchanged.
13+
- The README gains "Refreshing the gallery — `gallery-refresh`" and the scheduled task's runbook: what it runs, what it needs, what it never does, and the task's prompt verbatim.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): the automation skill lists `job`, `queue` and `messaging` only under `--preset minimal`, and the platform skill names the `mcp` and `pinyin-search` host defaults
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`objectstack-automation`'s prerequisite table marks `job`, `queue` and `messaging` with ° and says they are always-on, so they need listing in `requires:` only under `--preset minimal`; the symptoms in their rows are what a minimal boot shows without them. The `timeRelative` example and the Stripe and carrier-callback recipes no longer put `'job'` or `'queue'` in `requires:`. `objectstack-platform`'s `### requires:` lead now says the host defaults are mounted under every preset: `mcp` unless `OS_MCP_SERVER_ENABLED=false`, and `pinyin-search` when the stack's `i18n` names a `zh-*` locale, with `OS_SEARCH_PINYIN_ENABLED` overriding that. The automation evals for inbox notifications and the nightly Stripe sync no longer expect those tokens in `requires:`. The platform behaviour already shipped; this release only teaches it.

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ a PM dispatch sets the assignee (step 1) and posts the `Claim:` naming the dev's
400400
both on the dev's behalf. A dispatched executor inherits both records: it verifies that the
401401
newest `Claim:` names its branch (on a mismatch it stops and reports), posts no second claim —
402402
the dispatch's `Claim:` is its identity and its own record is the report comment — and it ⛔ never
403-
writes the card's assignee (nor the PR's: `pr_create` carries none; the seat sets it at hand-over,
403+
writes the card's assignee (the PR's is the claim's `Account:`, carried by `pr_create`; hand-over is the seat's,
404404
`.claude/agents/os-dev.md` rule 2) and ⛔ never yields a card it was dispatched to. Before writing code, re-read
405405
the comments — the comments decide, not the field: a `Claim:` from another session or branch
406406
(other than the dispatch that sent you) means taken whatever the field says — pick another or

‎docs/qa/scenarios/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ is the seed row that is this person (an employee, an agent, a customer); the loa
175175
one naming no seeded row. It is required on a persona with a `scope`, unless that persona is
176176
named through a handle instead (a direct scope rule on a declared user-handle field,
177177
`owner: u_sam`, as on the three controls), and optional on a global one. The person object's
178-
user field is `user`, fixed by name: no card chooses it. An operation is a `create` (with `values`), an
178+
user field is `user`, fixed by name: no card chooses it. The runner loads that row's `user` with the
179+
persona's user id, and owns (`owner_id`) a seed row by a persona's user only when the row is that
180+
persona's `record`, a declared lookup on it holds the record's id, or a handle field on it holds the
181+
persona's handle; the first persona in `run.personas` order the row names wins. A scope on an
182+
option (`visibility: public`) or on a lookup to a row that is no person (a department, a group)
183+
gives that persona no rows: the build reaches them by its own means (a read policy, a
184+
parent-controlled child). An operation is a `create` (with `values`), an
179185
`update` (with `target` and `values`) or a `delete` (with `target`); a target is a seeded row
180186
id, and every written field is one the seed carries. Every operation names the persona it
181187
acts for (`actingAs`) and declares its `outcome`, so grading reads it with code only:

‎examples/app-todo/test/loop-body-iteration.test.ts‎

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,20 @@
3434
* real flow by deleting `config.body` and re-wiring the flat edges, still dies
3535
* at `update_priority`. Without it a green suite could not distinguish "the
3636
* loop body ran" from "nothing in this harness can fail".
37+
*
38+
* ONE KERNEL PER FILE, CLEAN STATE PER CASE. The boot is ~80% of a case's wall
39+
* (measured locally: ~250 ms of boot against ~25 ms of `execute`), and booting
40+
* it inside every case put a whole kernel under vitest's 5 s per-test default:
41+
* on loaded Test Core shards the first case was cut off at 5011–5033 ms. So the
42+
* kernel boots once in `beforeAll`, under its own measured budget (below), and
43+
* `beforeEach` gives every case the state a fresh boot would: no `todo_task`
44+
* rows (deleted through the driver, so no hook or flow observes the reset) and
45+
* no captured notices. The only registration a case adds — CONTROL's fixture
46+
* flow — is removed in its own `finally`. Each case still passes alone and in
47+
* shuffled order.
3748
*/
3849

39-
import { describe, it, expect, afterEach } from 'vitest';
50+
import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
4051
import { ObjectKernel } from '@objectstack/core';
4152
import { ObjectQLPlugin } from '@objectstack/objectql';
4253
import { SqliteWasmDriver } from '@objectstack/driver-sqlite-wasm';
@@ -55,13 +66,6 @@ interface CapturedEmit {
5566
source?: { object: string; id: string };
5667
}
5768

58-
const openDrivers: Array<{ disconnect?: () => Promise<void> }> = [];
59-
afterEach(async () => {
60-
while (openDrivers.length) {
61-
try { await openDrivers.pop()?.disconnect?.(); } catch { /* noop */ }
62-
}
63-
});
64-
6569
/** `n` whole days before today, as a `Field.date` string (UTC); negative = future. */
6670
function daysAgoIso(n: number): string {
6771
const d = new Date();
@@ -74,11 +78,14 @@ function daysAgoIso(n: number): string {
7478
* A real kernel with the app's real `todo_task` over in-process sqlite-wasm,
7579
* the real automation engine, and a capturing `messaging` service.
7680
*/
77-
async function bootTodoKernel(): Promise<{
81+
interface TodoKernel {
7882
automation: AutomationEngine & Record<string, any>;
7983
data: any;
84+
driver: any;
8085
emits: CapturedEmit[];
81-
}> {
86+
}
87+
88+
async function bootTodoKernel(): Promise<TodoKernel> {
8289
const emits: CapturedEmit[] = [];
8390
const messaging = {
8491
async emit(input: CapturedEmit) {
@@ -107,7 +114,6 @@ async function bootTodoKernel(): Promise<{
107114
const driver: any = new SqliteWasmDriver({ filename: ':memory:' });
108115
await driver.connect();
109116
objectql.registerDriver(driver, true);
110-
openDrivers.push(driver);
111117
objectql.registry.registerObject(Task, 'todo', 'todo');
112118
await objectql.syncSchemas();
113119
// A real `single` install's Default Organization: the system writes below
@@ -116,9 +122,33 @@ async function bootTodoKernel(): Promise<{
116122

117123
automation.registerFlow(OverdueEscalationFlow.name, OverdueEscalationFlow);
118124
automation.registerFlow(TaskReminderFlow.name, TaskReminderFlow);
119-
return { automation, data, emits };
125+
return { automation, data, driver, emits };
120126
}
121127

128+
/**
129+
* The boot budget is measured, not vitest's 10 s hook default. Locally one boot
130+
* (kernel, sqlite-wasm connect, schema sync, Default Organization, flows) took
131+
* 230–330 ms idle and ~650 ms with 8 CPU-bound processes beside the suite on 4
132+
* cores. On Test Core shards the old first case — this boot plus one
133+
* `execute` — was cut off at 5011, 5015 and 5033 ms (jobs 128519296820,
134+
* 128555004931, 128565270519), and one warm case took 4620 ms, so the shard's
135+
* slowdown has reached ~20x the idle reading. 30 s is 6x the 5 s the shards
136+
* already exceeded.
137+
*/
138+
const BOOT_BUDGET_MS = 30_000;
139+
140+
let k: TodoKernel;
141+
beforeAll(async () => { k = await bootTodoKernel(); }, BOOT_BUDGET_MS);
142+
afterAll(async () => { await k?.driver.disconnect?.(); });
143+
144+
/** The state a fresh boot leaves: no task rows, no captured notices. */
145+
beforeEach(async () => {
146+
for (const row of await k.driver.find('todo_task', { where: {} })) {
147+
await k.driver.delete('todo_task', row.id);
148+
}
149+
k.emits.length = 0;
150+
});
151+
122152
const SYSTEM = { context: { isSystem: true } };
123153

124154
/** Seed one task `days` days past due, and return its id. */
@@ -132,7 +162,7 @@ async function seedOverdueTask(data: any, subject: string, days: number, owner =
132162

133163
describe('#19206 — the loop body runs and binds `currentTask`', () => {
134164
it('ESCALATION: the run reaches `notify_owner` and the notice renders the real day count', async () => {
135-
const { automation, data, emits } = await bootTodoKernel();
165+
const { automation, data, emits } = k;
136166
const id = await seedOverdueTask(data, 'Renew the domain', 5);
137167

138168
const result: any = await automation.execute('todo_overdue_escalation');
@@ -158,7 +188,7 @@ describe('#19206 — the loop body runs and binds `currentTask`', () => {
158188
});
159189

160190
it('EVERY item is processed, and each one carries its own values', async () => {
161-
const { automation, data, emits } = await bootTodoKernel();
191+
const { automation, data, emits } = k;
162192
await seedOverdueTask(data, 'Alpha', 4, 'usr_a');
163193
await seedOverdueTask(data, 'Bravo', 9, 'usr_b');
164194
await seedOverdueTask(data, 'Charlie', 12, 'usr_c');
@@ -184,7 +214,7 @@ describe('#19206 — the loop body runs and binds `currentTask`', () => {
184214
});
185215

186216
it('CONTAINMENT: one un-notifiable row does not end the sweep', async () => {
187-
const { automation, data, emits } = await bootTodoKernel();
217+
const { automation, data, emits } = k;
188218
await seedOverdueTask(data, 'Alpha', 4, 'usr_a');
189219
// `notify` refuses an empty resolved recipient set (`notify-node.ts`), so
190220
// this row's iteration fails INSIDE the body's `try_catch`.
@@ -200,7 +230,7 @@ describe('#19206 — the loop body runs and binds `currentTask`', () => {
200230
});
201231

202232
it('REMINDER: the second loop in the file binds its iterator too', async () => {
203-
const { automation, data, emits } = await bootTodoKernel();
233+
const { automation, data, emits } = k;
204234
await data.insert('todo_task', {
205235
subject: 'Pay the invoice', status: 'not_started', priority: 'high',
206236
due_date: daysAgoIso(-1), owner: 'usr_test_owner',
@@ -216,7 +246,7 @@ describe('#19206 — the loop body runs and binds `currentTask`', () => {
216246
});
217247

218248
it('CONTROL: the pre-fix body-less shape still dies at `update_priority`', async () => {
219-
const { automation, data, emits } = await bootTodoKernel();
249+
const { automation, data, emits } = k;
220250
await seedOverdueTask(data, 'Renew the domain', 5);
221251

222252
// The pre-#19206 shape, rebuilt from the real flow so it cannot drift: the
@@ -237,7 +267,12 @@ describe('#19206 — the loop body runs and binds `currentTask`', () => {
237267
];
238268
automation.registerFlow(legacy.name, legacy);
239269

240-
const result: any = await automation.execute(legacy.name);
270+
let result: any;
271+
try {
272+
result = await automation.execute(legacy.name);
273+
} finally {
274+
automation.unregisterFlow(legacy.name);
275+
}
241276
expect(result.success).toBe(false);
242277
// Loud rather than catastrophic: the filter operand reads `currentTask`,
243278
// which the body-less shape never binds, and the operand envelope fails the

0 commit comments

Comments
 (0)