Skip to content
Merged
17 changes: 17 additions & 0 deletions .changeset/34567-form-layout-inline-edit-bulk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/skills': patch
'@objectstack/lint': patch
---

docs(skills): `objectstack-ui` keeps a long form `simple`, and both skills name the `bulk` an `inlineEdit` save needs; `os lint`, `os validate` and `os build` warn when it is withheld

Clause-②: no
Metadata-protocol: none

`skills/objectstack-ui/SKILL.md` § Form Views no longer caps `simple` at 15 fields or sends objects with many field groups to `tabbed`. `simple` (stacked sections on one scrolling page) is the default at any field count. `tabbed` is for sections read apart, and the row names its cost: a required field missed on another tab is flagged only on its tab, and the tab strip overflows on a phone. A new paragraph says how a long form stays `simple`: `collapse: 'collapsed'` on the object's `fieldGroups` entry or `collapsed: true` on a form section, `columns` as a per-row ceiling (unset, a section draws two), and `modalSize` for the New / Edit dialog (unset, `lg` or `xl` by field count). One eval case asks for a 42-field form and fails an answer with `type: 'tabbed'`.

The parent's form saves an `inlineEdit` child's rows with the parent in one `/api/v1/batch`, and that route asks every object in it for `bulk`. Master-Detail Forms in `objectstack-ui` and § Inline Editing in `objectstack-data` `rules/relationships.md` now say so: a parent or child that declares `enable.apiMethods` must list `'bulk'`, or the save is refused `405 OBJECT_API_METHOD_NOT_ALLOWED`. An undeclared `apiMethods` allows it.

A new authoring rule, `relationship/inline-edit-needs-bulk` (`lintInlineEditBulk`, exported with its id constant `RELATIONSHIP_INLINE_EDIT_NEEDS_BULK`), warns on an `inlineEdit` relationship (`true`, `'grid'` or `'form'`) whose parent or child declares `enable.apiMethods` without `'bulk'`: once per object, at that object's `enable.apiMethods`, with a fix line naming the value to add. It is registered for all three commands, so `os lint`, `os validate` and `os build` (and `objectstack dev`) report it. It is advisory and never fails a build. `references/lint-rules.md` lists it.

The skill files pay for most of this by cutting text stated elsewhere, and the `objectstack-ui/SKILL.md` token ceiling moves by the measured remainder.
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (68)...
→ Running author-time rules (69)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,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 (68)...
→ Running author-time rules (69)...
→ 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 @@ -311,7 +311,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (68)...
→ Running author-time rules (69)...

✗ 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 (68)...
→ Running author-time rules (69)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
68 changes: 67 additions & 1 deletion packages/cli/test/data-model-rules.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { authoringRulesFor, lintDataModel, lintUniqueDeclarations, lintUnscopedDeclaredIndexes, lintLegacyOrganizationComposites } from '@objectstack/lint';
import { authoringRulesFor, lintDataModel, lintInlineEditBulk, lintUniqueDeclarations, lintUnscopedDeclaredIndexes, lintLegacyOrganizationComposites, runAuthoringRules } from '@objectstack/lint';
import { FieldSchema } from '@objectstack/spec/data';
import { lintConfig } from '../src/commands/lint';

Expand Down Expand Up @@ -87,6 +87,72 @@ describe('lintDataModel — relationships', () => {
});
});

// The parent's form saves parent + inline children in ONE cross-object
// `/api/v1/batch`, which gates every op as `bulk` on the op's own object. A
// declared `enable.apiMethods` without `bulk` on either side is warned about,
// naming the object to edit and the value to add; an undeclared list is open.
// A registry rule (`lintInlineEditBulk`), so all three commands report it.
describe('lintInlineEditBulk — relationship/inline-edit-needs-bulk', () => {
const RULE = 'relationship/inline-edit-needs-bulk';
const OPEN = ['get', 'list', 'create', 'update', 'delete'];
const budget = (enable?: unknown) => ({ name: 'project_budget', ...(enable ? { enable } : {}), fields: { title: { type: 'text' } } });
const line = (inlineEdit: unknown, enable?: unknown) => ({
name: 'project_budget_line',
...(enable ? { enable } : {}),
fields: {
project_budget: { type: 'master_detail', reference: 'project_budget', required: true, deleteBehavior: 'cascade', ...(inlineEdit === undefined ? {} : { inlineEdit }) },
amount: { type: 'currency' },
},
});
const hits = (objects: any[]) => lintInlineEditBulk(objects).filter((i) => i.rule === RULE);

it.each([true, 'grid', 'form'])('warns on the parent when inlineEdit is %s and its apiMethods omit bulk', (inlineEdit) => {
const [issue, ...rest] = hits([budget({ apiMethods: OPEN }), line(inlineEdit)]);
expect(rest).toEqual([]);
expect(issue?.severity).toBe('warning');
expect(issue?.path).toBe('objects[0].enable.apiMethods');
expect(issue?.where).toBe('object "project_budget"');
expect(issue?.fix).toBe("add 'bulk' to project_budget.enable.apiMethods");
expect(issue?.message).toContain('OBJECT_API_METHOD_NOT_ALLOWED');
});

it('warns on the child when the child declares apiMethods without bulk', () => {
const [issue, ...rest] = hits([budget(), line('grid', { apiMethods: OPEN })]);
expect(rest).toEqual([]);
expect(issue?.path).toBe('objects[1].enable.apiMethods');
expect(issue?.fix).toBe("add 'bulk' to project_budget_line.enable.apiMethods");
});

it('treats an empty apiMethods (deny-all) as withholding bulk', () => {
expect(hits([budget({ apiMethods: [] }), line(true)])).toHaveLength(1);
});

it('reports a parent once however many inline children it has', () => {
const second = { ...line('grid'), name: 'project_budget_item' };
expect(hits([budget({ apiMethods: OPEN }), line('grid'), second])).toHaveLength(1);
});

it('is silent when apiMethods include bulk, are undeclared, or nothing is inline-edited', () => {
expect(hits([budget({ apiMethods: [...OPEN, 'bulk'] }), line('grid', { apiMethods: [...OPEN, 'bulk'] })])).toEqual([]);
expect(hits([budget(), line('grid')])).toEqual([]);
expect(hits([budget({ apiMethods: OPEN }), line(undefined)])).toEqual([]);
expect(hits([budget({ apiMethods: OPEN }), line(false)])).toEqual([]);
});

it('reaches os lint, os validate and os build through the registry, as a warning, once', () => {
const objects = [budget({ apiMethods: OPEN }), line('grid')];
for (const command of ['lint', 'validate', 'build'] as const) {
expect(authoringRulesFor(command).map((r) => r.name), command).toContain('lintInlineEditBulk');
const found = runAuthoringRules(command, { normalized: { objects }, parsed: { objects } }).filter((f) => f.rule === RULE);
expect(found.map((f) => [f.severity, f.path, f.hint]), command).toEqual([
['warning', 'objects[0].enable.apiMethods', "add 'bulk' to project_budget.enable.apiMethods"],
]);
}
// Not a second copy in `os lint`'s best-practice sweep.
expect(lintDataModel(objects).filter((i) => i.rule === RULE)).toEqual([]);
});
});

describe('lintDataModel — roll-ups', () => {
it('suggests a roll-up when a parent owns master_detail children with numeric fields', () => {
const issues = lintDataModel([
Expand Down
26 changes: 26 additions & 0 deletions packages/lint/src/authoring-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ import {
lintUnscopedDeclaredIndexes,
lintLegacyOrganizationComposites,
lintSummaryRollups,
lintInlineEditBulk,
} from './data-model-rules.js';

import type { IObjectQLEngine } from '@objectstack/spec/contracts';
Expand Down Expand Up @@ -2479,6 +2480,31 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
hint: f.fix ?? '',
})),
},
// An inline-edited relationship whose parent or child declares
// `enable.apiMethods` without `bulk` (`relationship/inline-edit-needs-bulk`).
// The parent's form saves the rows in one cross-object `/api/v1/batch`, which
// asks every object in it for `bulk`, so the form fills and then 405s on save.
// Registered rather than left in `lintDataModel`: it forecasts a refusal at run
// time, not a style nudge, so all three commands report it. Advisory: a
// warning that refuses nothing and never fails `os build`.
{
name: 'lintInlineEditBulk',
tier: 'advisory',
input: 'parsed',
commands: ALL,
source: 'packages/lint/src/data-model-rules.ts',
surfaces: CLI_ONLY,
surfaceReason: RUNTIME_OBJECT_ADVISORY_VOLUME,
run: (stack) =>
lintInlineEditBulk(Array.isArray(stack.objects) ? (stack.objects as unknown[]) : []).map((f) => ({
severity: f.severity === 'suggestion' ? ('info' as const) : f.severity,
rule: f.rule,
where: f.where,
path: f.path,
message: f.message,
hint: f.fix ?? '',
})),
},
// ADR-0090 D7 — the security-domain publish linter. Every `error` rule mirrors
// a runtime enforcement point (fail-closed OWD default, canonical enum, anchor
// binding gate, vocabulary freeze), moving the failure from a runtime deny to
Expand Down
59 changes: 59 additions & 0 deletions packages/lint/src/data-model-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import {
BOOLEAN_VALUE_TYPES,
NUMERIC_VALUE_TYPES,
isAggregateCompatibleWithFieldType,
isApiOperationAllowed,
masterDetailRequiredOmitted,
referenceCarrierOf,
resolveEffectiveApiMethods,
type AggregationFunction,
} from '@objectstack/spec/data';

Expand Down Expand Up @@ -266,6 +268,63 @@ export const RELATIONSHIP_MASTER_DETAIL_REQUIRED = 'relationship/master-detail-r
/** The rule id R3 reports under (`master_detail` without `deleteBehavior`). */
export const RELATIONSHIP_DELETE_BEHAVIOR = 'relationship/delete-behavior';

/** The rule id {@link lintInlineEditBulk} reports under. */
export const RELATIONSHIP_INLINE_EDIT_NEEDS_BULK = 'relationship/inline-edit-needs-bulk';

/**
* An inline-edited relationship whose parent or child withholds `bulk`.
*
* The parent's form saves an `inlineEdit` child's rows together with the parent
* in ONE cross-object `/api/v1/batch` (ADR-0035), and that route gates EVERY op
* as `bulk` plus its own write on the op's own object
* (`packages/rest/src/batch-routes.ts`). So a parent or child whose DECLARED
* `enable.apiMethods` omits `bulk` gets a form that renders and fills, then is
* refused 405 `OBJECT_API_METHOD_NOT_ALLOWED` on save. An undeclared
* `apiMethods` is unrestricted, so the spec's own resolver decides, never a
* copy of its table.
*
* A registry rule (`AUTHORING_RULES`), not a `lintDataModel` member: it
* forecasts a refusal at run time rather than nudging a style, so `os lint`,
* `os validate` and `os build` all report it. Advisory: a warning that refuses
* nothing. One finding per object, however many inline children name it.
*/
export function lintInlineEditBulk(objects: any[]): LocatedLintIssue[] {
const issues: LocatedLintIssue[] = [];
if (!Array.isArray(objects)) return issues;
const indexByName = new Map<string, number>();
objects.forEach((o, j) => {
if (typeof o?.name === 'string' && !indexByName.has(o.name)) indexByName.set(o.name, j);
});
const reported = new Set<string>();
for (const child of objects) {
if (!child?.name) continue;
for (const { name: fieldName, def } of fieldEntries(child.fields)) {
if (!RELATIONSHIP_TYPES.has(def?.type)) continue;
if (def.inlineEdit !== true && def.inlineEdit !== 'grid' && def.inlineEdit !== 'form') continue;
const parent = refOf(def);
if (!parent) continue;
for (const target of [parent, child.name]) {
const j = indexByName.get(target);
if (j === undefined || reported.has(target)) continue;
if (isApiOperationAllowed(resolveEffectiveApiMethods(objects[j]?.enable), 'bulk')) continue;
reported.add(target);
issues.push({
severity: 'warning',
rule: RELATIONSHIP_INLINE_EDIT_NEEDS_BULK,
where: objectWhere(objects[j]),
message:
`inlineEdit on "${child.name}.${fieldName}" saves ${parent} and its ${child.name} rows in one ` +
`/api/v1/batch, which needs 'bulk' on every object in it; "${target}" declares ` +
`enable.apiMethods without 'bulk', so that save is refused 405 OBJECT_API_METHOD_NOT_ALLOWED`,
path: `objects[${j}].enable.apiMethods`,
fix: `add 'bulk' to ${target}.enable.apiMethods`,
});
}
}
}
return issues;
}

/**
* The rule id R13 reports under: a roll-up whose child field the function
* cannot aggregate into the summary column — a `min`/`max` whose answer is not
Expand Down
2 changes: 2 additions & 0 deletions packages/lint/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ export {
lintUnscopedDeclaredIndexes,
lintLegacyOrganizationComposites,
lintSummaryRollups,
lintInlineEditBulk,
lintDataModel,
UNIQUE_DOUBLE_DECLARATION,
UNIQUE_UNSCOPED_DECLARED_INDEX,
Expand All @@ -1214,6 +1215,7 @@ export {
RELATIONSHIP_DELETE_BEHAVIOR,
ROLLUP_NON_NUMERIC_AGGREGAND,
FIELD_EMBEDDED_SUB_FIELDS,
RELATIONSHIP_INLINE_EDIT_NEEDS_BULK,
} from './data-model-rules.js';
export type { LintIssue, LocatedLintIssue, Severity } from './data-model-rules.js';

Expand Down
32 changes: 29 additions & 3 deletions scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,25 @@ export const CEILINGS = new Map([
// bytes (15233 priced, 3809 tokens, headroom 5) -> 15349 (15329 priced) -> 3833 tokens,
// the 5 absorbed, ceiling +19, pinned AT the measurement, zero headroom.
// ceil(($(wc -c < skills/objectstack-ui/SKILL.md) - 20) / 4) == ceil(15329 / 4)
['skills/objectstack-ui/SKILL.md', 3833],
// 3833 -> 3888: Form Views stops steering a long form to `tabbed` — `simple` is the
// default at any field count, `tabbed` names its cost, and one paragraph says how a long
// form stays `simple` (collapsed groups, `columns`, `modalSize`). PAID DOWN FIRST by two
// restatements cut from this file, each keeping a home: the derived-FK / roll-up paragraph
// under Master-Detail Forms (-223 bytes; the line-item paragraph's "every behaviour is
// derived from the DATA MODEL" and objectstack-data `rules/relationships.md` § Roll-up
// Summaries) and the "row-by-row" sentence under Field Conditional Rules (-97; the
// objectstack-data SKILL.md § Conditional Field Rules the line above links). Remainder
// raised under the standing ruling 「A:先削重复,余额按实测提高」 (record 6513306068):
// 15349 bytes (15329 priced) -> 15569 (15549 priced) -> 3888 tokens, pinned AT the
// measurement, zero headroom.
// ceil(($(wc -c < skills/objectstack-ui/SKILL.md) - 20) / 4) == ceil(15549 / 4)
// 3888 -> 3921: Master-Detail Forms item 1 names the save's precondition — a parent or
// child declaring `enable.apiMethods` must list `'bulk'`, or the one `/api/v1/batch` is
// refused 405. Nothing else in this file restates it or was left to cut after the row
// above; same standing ruling (record 6513306068). 15569 bytes (15549 priced) -> 15704
// (15684 priced) -> 3921 tokens, pinned AT the measurement, zero headroom.
// ceil(($(wc -c < skills/objectstack-ui/SKILL.md) - 20) / 4) == ceil(15684 / 4)
['skills/objectstack-ui/SKILL.md', 3921],
// 8333 -> 6193: RE-LOCK at the landed count after the #19715 split (decision
// batch #213 item 1, maintainer 「1 2 4 同意」): the worked R1, the report
// template and the v17-canonical shapes block moved VERBATIM into
Expand Down Expand Up @@ -1029,7 +1047,12 @@ export const CEILINGS = new Map([
// ceil(16925 / 4) = 4232; the ceiling moves +105, pinned AT the measurement.
// Raise path the 2026-10-27 ruling 「A:先削重复,余额按实测提高」 (ruling record
// 6513306068), quoted verbatim and untranslated in the PR body.
['skills/objectstack-data/rules/relationships.md', 4232],
// 4232 -> 4229: Inline Editing names the save's `bulk` precondition (+129 bytes), paid by
// restatement cut from the same file: the `subforms` sentence (the objectstack-ui pointer
// now carries it), the related-list example's "write side" comment (the paragraph above
// says it) and "(no UI config)" (the sentence says "purely from how you model"). 16925 ->
// 16916 bytes -> ceil(16916 / 4) = 4229; the row follows the measurement down.
['skills/objectstack-data/rules/relationships.md', 4229],
// NEW FILE (#14296 item 1 = A, condition (b)): the entry's Security & Access
// Control block moved here whole. Pinned at its landed count — no headroom,
// because a split that arrives with budget is a raise wearing a new path.
Expand Down Expand Up @@ -1511,7 +1534,10 @@ export const CEILINGS = new Map([
// review's module pointer paid by the custom-Page aside (the ui skill's
// rule); the row follows the measurement down, zero headroom.
['skills/objectstack-data/references/examples-objects.md', 1728],
['skills/objectstack-data/references/lint-rules.md', 970],
// 970 -> 934: one row for `relationship/inline-edit-needs-bulk`, and the closing "target a
// lint-clean model" paragraph cut — it restated the table's rows one by one. 3829 -> 3735
// bytes -> ceil(3735 / 4) = 934; the row follows the measurement down, zero headroom.
['skills/objectstack-data/references/lint-rules.md', 934],
// 1299 -> 1566 (#26297): the `columns` dataset key and `applyOn: 'create'`
// — a column a job or an admin owns after the first load is written on
// create and left alone on every `upsert` replay; which modes it touches,
Expand Down
5 changes: 1 addition & 4 deletions skills/objectstack-data/references/lint-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Data-model rules (in addition to naming/label/i18n):
| `relationship/master-detail-required` | warning; error under `controlled_by_parent` | a `master_detail` that isn't `required` (under `controlled_by_parent`, the only one may be `required: false`: the optional master) — or, under `controlled_by_parent`, is `readonly`/`system` |
| `relationship/delete-behavior` | suggestion | `master_detail` without an explicit `deleteBehavior` |
| `relationship/line-items-inline-edit` | suggestion | a `*_line`/`*_item` master_detail child without `inlineEdit` |
| `relationship/inline-edit-needs-bulk` | warning | `inlineEdit` while the parent's or child's `enable.apiMethods` omits `'bulk'` |
| `relationship/line-item-should-be-master-detail` | suggestion | a line-item-shaped child using `lookup` instead of `master_detail` |
| `relationship/association-inline-edit` | warning | an association (comment/audit/activity) marked `inlineEdit` (clutters the parent form — use a detail-page related list) |
| `rollup/missing-summary` | suggestion | a parent of numeric master_detail children with no roll-up `summary` |
Expand Down Expand Up @@ -46,7 +47,3 @@ These same rules are the **rubric for AI-generated metadata** — a generation i
corpus (invoice+lines, project+tasks, blog+comments, expense+lines,
account+contacts) offline; each case must clear the pass bar (`--eval-min`,
default 75). Deterministic, no API key.

When generating object metadata, target a lint-clean model: master_detail (with
`required` + `deleteBehavior` + `inlineEdit` for line items), roll-up summaries
on parents, `select` options, and a name/title field per object.
Loading
Loading