Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
64c370e
wip(lint): seeds and actions publish checks
claude Nov 27, 2026
748e7bc
wip(lint): door pins and lazy-deps action leg
claude Nov 27, 2026
4364bf6
wip(lint): rule ids module-local, roster pins
claude Nov 27, 2026
ee0969c
fix(cli): infer api.write from a lone updateMany or deleteMany
claude Nov 27, 2026
cd83ed8
docs: rule count and rule-family rows for the seeds and actions checks
claude Nov 27, 2026
4ba19b7
chore: changeset and upgrade-guide entry for the seeds and actions ch…
claude Nov 27, 2026
c670495
Merge remote-tracking branch 'origin/main' into claude/issue-35143-se…
claude Nov 27, 2026
72b7cec
test(lint): drop the gate-input name key the runtime gate does not take
claude Nov 27, 2026
0a916bb
chore(lint): declare the sandbox runner as an input of the lint test …
claude Nov 27, 2026
04d056b
test(dogfood): the package that binds an action to a showcase object …
claude Nov 27, 2026
9dbc28b
docs(lint): an action saved into a package is judged against its clos…
claude Nov 27, 2026
e5a226a
fix(lint): leave the seed binding to the save door; no verdict on an …
claude Nov 27, 2026
a683a7d
test: fixtures that bind another package's object or an unserved one,…
claude Nov 27, 2026
c6bb575
fix(lint): advise a flow node's unknown object on the CLI; admit the …
claude Nov 27, 2026
295210a
fix(cli): infer api.write through a bound handle, ?. before the leaf …
claude Nov 27, 2026
6361589
chore: the changeset names the two exported rule ids
claude Nov 27, 2026
1f2599c
chore(changeset): declare Clause-② yes (narrowing) — @objectstack/lin…
claude Nov 27, 2026
ce21bee
Merge remote-tracking branch 'origin/main' into claude/issue-35143-se…
claude Nov 27, 2026
d2a3806
docs: author-time rule count is 85 after merging main
claude Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .changeset/35143-seeds-actions-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@objectstack/lint': minor
'@objectstack/spec': patch
'@objectstack/cli': patch
---

fix(lint)!: three publish-time checks for seeds, flow nodes and actions that save and do not work

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #37814

<!-- adr-0087: registered publish-refuses-seeds-and-actions-that-save-and-do-not-work -->

**BREAKING** for the publish of a seed, a flow, an action or an object that carries one of the errors below: it was accepted before and is refused now, with the fix named in the finding. The schema is unchanged and stored metadata is not rewritten or refused at boot; the refusal comes at the next publish, and from `os validate` / `lint` / `compile` / `build`.

- `seed-record-unknown-field`: a seed record key, or a seed `columns` key, that the engine's insert door would refuse: a key that names no field of the dataset's object, no system column the platform injects on it (`owner_id`, the tenant and audit columns, unless the object opts out), and none of the columns every table carries (`id`, `created_at`, `updated_at`). The seed load writes each record through that insert, so such a record is dropped while the rest load. An object with no field map is not judged, as the engine's door does not judge it. `defineSeed` already refused such a key when it ran; a plain `data: [{ object, records }]` entry and a `seed` saved at the runtime publish door are now judged too. A field an object extension adds counts. Runs on the runtime `seed` door.
- `object-reference-unknown` (and the warning `object-reference-unregistered-platform` for a platform-prefixed name no known package registers), at three more bindings: a seed dataset's `object`, a flow `get_record` / `create_record` / `update_record` / `delete_record` / object-form `screen` node's `config.objectName`, and a standalone action's `objectName`. A seed over a missing object loads nothing, and an action bound to one is carried by no page. A flow node is split as `flow-trigger-unknown-object` is: on `os validate` / `lint` / `build` an unprefixed name the stack does not define is a warning, because a package the stack declares in `dependencies` may define it and a build cannot see that package; at the runtime publish door it is an error, judged against the written package's closure, or against every object the deployment serves for a write that names no package, where a step bound to a missing object fails the run every time it executes. An object the stack extends resolves at these three. At the runtime publish door the seed binding stays with the save door's own refusal of a seed over an unknown object (#34864), which accepts a draft of the object in the same package; the rule now also runs on the runtime `action` door, so an `action` write is therefore also judged for its params' `reference` / `objectOverride` objects, as `os validate` already judged them, and an action saved into a package (`?package=`) is judged against that package's closure, as a flow saved there already was: an object another package owns resolves only when the manifest declares that package in `dependencies`.
- `action-body-write-capability-undeclared`: an L2 action body that calls a `ctx.api` write (`insert`, `update`, `delete`, `updateMany`, `deleteMany`, `upsert`) without `api.write` in its `body.capabilities`. The sandbox refuses the call with `403 INSUFFICIENT_PRIVILEGES` every time the action reaches it. Runs on the runtime `action` and `object` doors.

`os build` now infers `api.write` for every handler write shape the new check reads: a lone `updateMany` or `deleteMany`, `?.` before the leaf, an `.object(…)` argument holding a call, and a handle bound to `.object(…)` (`const repo = ctx.api.object('x'); repo.update(…)`). Before, such a handler was lowered with no grant and refused at every call.

## FROM → TO

- `data: [{ object: 'task', records: [{ name: 'a', stauts: 'open' }] }]` → `status: 'open'`, or declare `stauts` on `task`, or drop the key.
- `{ type: 'create_record', config: { objectName: 'invoce', … } }` → `objectName: 'invoice'` (the object's full, namespaced name).
- `body: { language: 'js', source: "await ctx.api.object('task').update(…)", capabilities: [] }` → `capabilities: ['api.write']`.

`@objectstack/lint` exports two rule id constants, `SEED_RECORD_UNKNOWN_FIELD` and `ACTION_BODY_WRITE_CAPABILITY_UNDECLARED`, so `os explain` carries an entry for each; the rules themselves are not exported. `@objectstack/spec` adds only the upgrade-guide entry `publish-refuses-seeds-and-actions-that-save-and-do-not-work`.
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (83)...
→ Running author-time rules (85)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
8 changes: 5 additions & 3 deletions content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ orthogonal to both, and no cell here can carry it; it is written out in
| Filter placeholder resolvability (#3574) | ✓ | ✓ | ✓ | — |
| Ordering comparands naming a date-range preset — `last_30_days` in a `>=` position (#8793) | ✓ | ✓ | ✓ | ✓ᵈᵛᵒᵖᶠʳ |
| Empty filter combinators — `$and: []`, `$or: []`, `$not: {}` (#5330) | ✓ | ✓ | ✓ | ✓ᶠʳ |
| Object & action name references (#3583) | ✓ | ✓ | ✓ | ✓ᶠᵈᵗ |
| Reference integrity — flow node writes, template paths, read-only writes (#3583); at the publish door each write type runs only the members that declare it, and the flow members run on `flow` alone (#9313) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵈᵗʳᵖ |
| Object & action name references (#3583) — and the object a seed dataset, a flow `get_record` / `create_record` / `update_record` / `delete_record` / object-form `screen` node or a standalone action is bound to (`object-reference-unknown`, #35143); a flow node's miss is a warning on the CLI, where a declared dependency may define the object, and an error at the publish door; at the publish door a seed over an unknown object is the save door's own refusal (#34864) | ✓ | ✓ | ✓ | ✓ᶠᵈᵗᵃᶜ |
| Reference integrity — flow node writes, template paths, read-only writes (#3583); at the publish door each write type runs only the members that declare it, and the flow members run on `flow` alone (#9313) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵈᵗʳᵖᵃᶜ |
| List-view field members — a list view's `sort` (a `sortable: false` field, a `formula`, an unknown name: `sort-field-unsortable`), its `searchableFields` (`searchable-field-unknown`) and its field references, columns, filter keys, grouping and the board bindings (`list-view-field-unknown`); the row merges three members, so its codes follow no one rule's order, and the `page` door runs the sort member only (#9313, #15495, #30095) | ✓ | ✓ | ✓ | ✓ᶠᵛᵒᵖ |
| Page-component field bindings (#3583) | ✓ | ✓ | ✓ | ✓ᶠ |
| React page block field bindings — §10 (#4340) | ✓ | ✓ | ✓ | ✓ᶠ |
Expand All @@ -520,6 +520,8 @@ orthogonal to both, and no cell here can carry it; it is written out in
| Page variable declarations — each name once and never blank, a `defaultValue` of its declared type, a `source` naming a component the page holds (#28663, #28725) | ✓ | ✓ | ✓ | ✓ᵖ |
| JSX / React page source parses (ADR-0080/0081) | ✓ | ✓ | ✓ | — |
| Script action bodies compile in the runtime's wrapper — an L2 action's `body.source` that does not compile as the body of `(async (input, ctx) => { … })`, most often `const input = …` redeclaring a parameter; an object write runs it over its inline `actions[]`, so an object write cannot republish a refused body (`action-body-does-not-compile`, #34884) | ✓ | ✓ | ✓ | ✓ᵃᶜᵒ |
| Script action bodies hold the grant they call — an L2 action body that calls a `ctx.api` write (`insert`, `update`, `delete`, `updateMany`, `deleteMany`, `upsert`) without `api.write` in its `body.capabilities`, which the sandbox refuses at every call (`action-body-write-capability-undeclared`, #35143) | ✓ | ✓ | ✓ | ✓ᵃᶜᵒ |
| Seed record keys — a seed record key, or a seed `columns` key, that names no field of the dataset's object, no system column injected on it and none of `id` / `created_at` / `updated_at`; the engine's insert door refuses such a record and the seed load loads the rest (`seed-record-unknown-field`, #35143) | ✓ | ✓ | ✓ | ✓ˢ |
| Hook and job bodies compile in the runtime's wrapper — an L2 hook or job `body.source` that does not compile as the body of `(async (ctx) => { … })`, most often `const ctx = …` redeclaring the parameter or one name declared twice; no door publishes a job, so the publish column is the `hook` write alone (`hook-body-does-not-compile`, `job-body-does-not-compile`, #34987) | ✓ | ✓ | ✓ | ✓ʰ |
| Approval-node approvers (ADR-0090 D3) | ✓ | ✓ | ✓ | ✓ᶠ |
| Security posture (ADR-0090 — e.g. every custom object declares `sharingModel`) | ✓ | ✓ | ✓ | ✓ˢᵖᵉᵇᵒ |
Expand Down Expand Up @@ -867,7 +869,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
→ Running author-time rules (83)...
→ Running author-time rules (85)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (83)...
→ Running author-time rules (85)...

✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
Expand Down
2 changes: 1 addition & 1 deletion content/docs/ui/react-pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ objectstack validate
────────────────────────────────────────
→ Loading configuration...
→ Validating against ObjectStack Protocol...
→ Running author-time rules (83)...
→ Running author-time rules (85)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
51 changes: 50 additions & 1 deletion packages/cli/src/utils/extract-hook-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ const CAPABILITY_PATTERNS: Array<{ rx: RegExp; cap: 'api.read' | 'api.write' | '
// checks a grant only at a call. One token is the exception, see the door
// patterns at the end of this list.
{ rx: /\.object\s*\([^)]+\)\s*\.\s*(?:find|findOne|count|aggregate|get|list)\b/, cap: 'api.read' },
{ rx: /\.object\s*\([^)]+\)\s*\.\s*(?:insert|update|upsert|delete|patch|remove|create)\b/, cap: 'api.write' },
// [#35143] `updateMany` / `deleteMany` spelled out: `update\b` does not match
// inside either name, and both are sandbox `api.write` leaves.
{ rx: /\.object\s*\([^)]+\)\s*\.\s*(?:insert|updateMany|update|upsert|deleteMany|delete|patch|remove|create)\b/, cap: 'api.write' },
{ rx: /ctx\.crypto\.randomUUID\b/, cap: 'crypto.uuid' },
// NO `ctx.crypto.hash` pattern: the `crypto.hash` token was removed in spec 17
// (#4391) because the sandbox never installed the function. Inferring a
Expand Down Expand Up @@ -553,6 +555,51 @@ const CAPABILITY_PATTERNS: Array<{ rx: RegExp; cap: 'api.read' | 'api.write' | '
{ rx: /ctx\.activity\.append\b/, cap: 'activity.append' },
];

/** The write leaves the `api.write` pattern above names, as one alternation. */
const OBJECT_WRITE_LEAVES = 'insert|updateMany|update|upsert|deleteMany|delete|patch|remove|create';

/** The index of the `)` closing the `(` at `open`, or -1. Counts nesting; strings are not special. */
function closingParen(source: string, open: number): number {
let depth = 0;
for (let i = open; i < source.length; i++) {
const ch = source[i];
if (ch === '(') depth++;
else if (ch === ')' && --depth === 0) return i;
}
return -1;
}

/**
* [#35143] Whether the body writes through `.object(...)` in a shape the
* `api.write` pattern's single regex cannot read — the shapes the publish
* check `action-body-write-capability-undeclared` reads, so a handler `os build`
* lowers is never refused by the next step of the same build:
*
* - an argument holding a call or other parentheses: `ctx.api.object(name()).update(…)`;
* - `?.` before the leaf: `ctx.api.object('x')?.update(…)`;
* - a bound handle: `const repo = ctx.api.object('x'); … repo.update(…)`.
*
* Receiver-loose like the patterns above, for their reason: an over-inferred
* grant is one the sandbox never checks, an under-inferred one is a 403 at
* every call.
*/
function callsObjectWriteThroughHandle(source: string): boolean {
const chainedWrite = new RegExp(String.raw`^\s*\??\.\s*(?:${OBJECT_WRITE_LEAVES})\b`);
const handles: string[] = [];
for (const m of source.matchAll(/\??\.\s*object\s*\(/g)) {
const open = (m.index ?? 0) + m[0].length - 1;
const close = closingParen(source, open);
if (close < 0) continue;
const after = source.slice(close + 1);
if (chainedWrite.test(after)) return true;
const bound = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:await\s+)?[\w$.? \t]*$/.exec(source.slice(0, m.index ?? 0));
if (bound && /^\s*(?:;|\n|$)/.test(after)) handles.push(bound[1]);
}
return handles.some((name) =>
new RegExp(String.raw`(?<![\w$.])${name.replace(/\$/g, '\\$')}\s*\??\.\s*(?:${OBJECT_WRITE_LEAVES})\s*\(`).test(source),
);
}

export interface ExtractedBody {
/** Pure function-body source (without the surrounding `(ctx) => {...}`). */
source: string;
Expand Down Expand Up @@ -657,6 +704,8 @@ export function extractLoweredBody(
for (const { rx, cap } of CAPABILITY_PATTERNS) {
if (rx.test(source)) inferred.add(cap);
}
// [#35143] The `.object(...)` write shapes one regex cannot read; see the helper.
if (callsObjectWriteThroughHandle(source)) inferred.add('api.write');
// [#22837] The ctx-anchored patterns above spell `ctx.`; a rebound body
// reaches the same members through the handler's own names.
for (const cap of reboundCapabilities(source, rebind)) inferred.add(cap);
Expand Down
47 changes: 47 additions & 0 deletions packages/cli/test/extract-hook-body.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,53 @@ describe('extractHookBody', () => {
expect(extractHookBody(fn, 'hook c').capabilities).toContain('api.write');
});

// [#35143] `updateMany` and `deleteMany` are two of the sandbox's six
// `api.write` leaves. The write pattern's `\b` after `update` / `delete` did
// not match inside either name, so a handler whose only write was one of them
// was lowered with no grant and refused at every call.
it.each(['updateMany', 'deleteMany'])('infers api.write from a lone %s', (method) => {
const fn =
method === 'updateMany'
? async (ctx: any) => {
await ctx.api.object('foo').updateMany({ status: 'x' }, { done: true });
}
: async (ctx: any) => {
await ctx.api.object('foo').deleteMany({ status: 'x' });
};
expect(extractHookBody(fn, 'hook c2').capabilities).toEqual(['api.write']);
});

// [#35143] The shapes the publish check `action-body-write-capability-undeclared`
// reads (`bodyApiWriteCalls`) beyond a direct chain. Each lowered without a
// grant before, so `os build` lowered a handler and then refused it.
it.each([
['a bound handle', async (ctx: any) => {
const repo = ctx.api.object('foo');
await repo.update('id', { done: true });
}],
['a bound handle through an alias of ctx.api', async (ctx: any) => {
const api = ctx.api;
const repo = api.object('foo');
await repo.deleteMany({ done: true });
}],
['`?.` before the leaf', async (ctx: any) => {
await ctx.api.object('foo')?.insert({ name: 'x' });
}],
['an object argument holding a call', async (ctx: any) => {
await ctx.api.object(String('foo')).upsert({ name: 'x' }, { on: ['name'] });
}],
])('infers api.write through %s', (_shape, fn) => {
expect(extractHookBody(fn, 'hook shapes').capabilities).toContain('api.write');
});

it('infers no api.write from a bound handle that only reads (control)', () => {
const fn = async (ctx: any) => {
const repo = ctx.api.object('foo');
return repo.find({});
};
expect(extractHookBody(fn, 'hook read handle').capabilities).not.toContain('api.write');
});

it('infers log', () => {
const fn = (ctx: any) => {
ctx.log.info('hi');
Expand Down
Loading
Loading