suppa-mcp-2 1.35.0 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -600,11 +600,12 @@ string and is typed by shape — right there, W620 anywhere else.
600
600
  Those, plus
601
601
  `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
602
602
  `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
603
- W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
603
+ W610, W611, W612, W613, W615, W616, W617, W618, W619, W620, W621, W622, W623, W625 — and like errors they exit 1, because a
604
604
  rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
605
605
  they print as `[rule violation, demoted]` and the summary ends `NOT a clean
606
- run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
607
- the checker could not see.
606
+ run`. Advisory warnings — W601-W606, W608, W614, W624 — never block; they report what
607
+ the checker could not see. W624 is the one to read rather than skim: it names a
608
+ check that could NOT run, which is not the same as a check that passed.
608
609
 
609
610
  Tabular parts (owned child sub-tables like checklist items or order lines)
610
611
  and the remove-and-re-add-a-field semantics — a re-added field restores its
package/dist/server.js CHANGED
@@ -162,6 +162,26 @@ const BlocksJson = z
162
162
  const EntityName = z
163
163
  .string()
164
164
  .describe("Exact entity name, e.g. 'Tasks' — discover via suppa_list_entities.");
165
+ /**
166
+ * A field label: a plain string, or the LOCALIZATION OBJECT the builder doc
167
+ * prescribes (`title | object | Localization object`, builder.txt:56).
168
+ *
169
+ * It was typed `string` here while buildFieldDef had accepted either for two
170
+ * releases, so the documented shape was rejected by input validation before it
171
+ * could reach the platform at all — `{ en, uk }` came back as "Expected string,
172
+ * received object" and never left this process.
173
+ */
174
+ const FieldTitle = z
175
+ .union([z.string(), z.record(z.string())])
176
+ // OPTIONAL, not nullable: a two-branch union plus a null branch is an `anyOf`
177
+ // the listing's compaction cannot collapse into a type list (the object
178
+ // branch carries additionalProperties, which a type list cannot say), and
179
+ // toolsListEconomy refuses a nullable spelled as anyOf. Omitting the
180
+ // parameter and passing null mean the same thing downstream — buildFieldDef
181
+ // tests for both — so the null branch bought nothing and cost the collapse.
182
+ .optional()
183
+ .describe('Label users see: "Budget", or {"en": "Budget", "uk": "Бюджет"}. Omitted: no title, and ' +
184
+ "none is invented from the name.");
165
185
  // Entity Options (captures/api-entity-builder-builder.txt:74-90) — the platform's
166
186
  // 15 per-entity features, plus customFields (newer than that capture, verified live). The TIP at :91-92 is quoted in full: enabling one is a
167
187
  // schema change (it creates the backing side table), not a preference toggle.
@@ -1134,7 +1154,7 @@ export function buildServer() {
1134
1154
  field_type: z
1135
1155
  .string()
1136
1156
  .describe("A real Suppa 2.0 type (see suppa_list_field_types). NO date/richtext/email type exists — use 'timestamp' (+sub_type='date') or 'multi-language'. 'one-to-many' is refused — use suppa_create_tabular_part for owned children, 'many-to-many' for shared lookups."),
1137
- title: z.string().nullable().default(null),
1157
+ title: FieldTitle,
1138
1158
  required: z.boolean().default(false),
1139
1159
  default_value: z
1140
1160
  .string()
@@ -1429,9 +1449,9 @@ export function buildServer() {
1429
1449
  " Needs context_field + context_value (the set for that context is created if it has\n" +
1430
1450
  " none) or set_ids — a custom field belonging to neither is refused. The entity needs\n" +
1431
1451
  " options.customFields on (suppa_update_entity_options).\n" +
1432
- " Types, sub_type and options are suppa_add_field's. There is no 'required': this build\n" +
1433
- " cannot create a notNull custom field. To make one mandatory in a context, set required\n" +
1434
- " on its CustomFieldSetFields row — an ordinary record.\n" +
1452
+ " Types, sub_type and options are suppa_add_field's. required=true marks it mandatory in\n" +
1453
+ " THIS context (its CustomFieldSetFields row), binding when the values row is written;\n" +
1454
+ " column-level notNull is a different thing this build cannot create.\n" +
1435
1455
  " Enum values come after: suppa_add_enum_values(entity_name='<Entity>CustomFields',\n" +
1436
1456
  " field_name='<field>') — both, or it cannot read the group off the field.",
1437
1457
  inputSchema: {
@@ -1441,7 +1461,7 @@ export function buildServer() {
1441
1461
  .describe("camelCase, letters/numbers/underscores, 1-50 — and the English MEANING of the title, " +
1442
1462
  "never the title in Latin letters (opysPrychyny is refused; reasonDescription is the name)."),
1443
1463
  field_type: z.string().describe("As suppa_add_field (see suppa_list_field_types)."),
1444
- title: z.string().nullable().default(null).describe("Label users see."),
1464
+ title: FieldTitle,
1445
1465
  context_field: z
1446
1466
  .string()
1447
1467
  .nullable()
@@ -1457,6 +1477,11 @@ export function buildServer() {
1457
1477
  .nullable()
1458
1478
  .default(null)
1459
1479
  .describe("Existing CustomFieldSets ids, instead of a context."),
1480
+ required: z
1481
+ .boolean()
1482
+ .default(false)
1483
+ .describe("Mandatory in THIS context — set on the field's CustomFieldSetFields row. An insert " +
1484
+ "naming it null is refused; one with no customFields key still passes."),
1460
1485
  relation_entity: z.string().nullable().default(null),
1461
1486
  options_json: z.string().nullable().default(null),
1462
1487
  sub_type: z.string().nullable().default(null),
@@ -1469,6 +1494,7 @@ export function buildServer() {
1469
1494
  contextField: a.context_field,
1470
1495
  contextValue: a.context_value,
1471
1496
  setIds: a.set_ids,
1497
+ required: a.required,
1472
1498
  relationEntity: a.relation_entity,
1473
1499
  options: a.options_json,
1474
1500
  subType: a.sub_type,
@@ -42,9 +42,9 @@
42
42
  * field mandatory is `required` on the CustomFieldSetFields link row, which
43
43
  * the platform enforces when the values row is created.
44
44
  */
45
- import { makeRequest, searchEntity } from "../httpClient.js";
45
+ import { makeRequest, searchEntity, updateEntity } from "../httpClient.js";
46
46
  import { customFieldsHint } from "../customFieldHints.js";
47
- import { jsonResponse, confirmRequired } from "../utils.js";
47
+ import { jsonResponse, confirmRequired, makeFilter } from "../utils.js";
48
48
  import { buildFieldDef, CUSTOM_FIELDS_EXTENSION_SUFFIX, CUSTOM_FIELDS_KEY, CUSTOM_FIELDS_OPTION, } from "./entity.js";
49
49
  /**
50
50
  * Re-exported from ./entity.ts, where the option lives beside the rest of the
@@ -235,22 +235,23 @@ export async function addCustomField(entityName, fieldName, fieldType, title, op
235
235
  "ways to name the same thing and the builder reads only one of them. Nothing was sent.",
236
236
  });
237
237
  }
238
- // notNull is refused rather than forwarded: BOTH forms fail on this build, and
239
- // the second one fails AFTER the set has already been created, leaving a set
240
- // behind for a field that does not exist.
241
- if (fieldOpts.required) {
242
- return jsonResponse({
243
- error: "Refused: required=true cannot be applied to a custom field on this platform build. " +
244
- "Without default_value the builder answers HTTP 400 \"`defaultValue` is required when " +
245
- 'creating a field with `notNull: true`"; WITH one it answers HTTP 400 "Field ' +
246
- `\"${fieldName}\" is not available for this record's context." — even for a context that ` +
247
- "holds no values yet (verified 2026-09-04). Nothing was sent.",
248
- how_to_make_it_mandatory: "Create the field without required, then mark it required IN THE SET, which is where " +
249
- "per-context obligation actually lives: suppa_search_records('CustomFieldSetFields', " +
250
- "filters on set + field) to find the link row, then suppa_update_record on it with " +
251
- '{"required": true}. The platform enforces that when the record\'s values row is created.',
252
- });
253
- }
238
+ // `required` is NOT notNull. Column-level notNull is refused by this build
239
+ // (without a default the builder answers "`defaultValue` is required when
240
+ // creating a field with `notNull: true`"; with one it answers "Field x is not
241
+ // available for this record's context", even for a context holding no values).
242
+ // Per-CONTEXT obligation is a different mechanism and it works: it lives on
243
+ // the CustomFieldSetFields link row, resolve reports it, and the platform
244
+ // enforces it when the values row is created — an insert naming the field as
245
+ // null is refused with "is required for this record's context" (verified on
246
+ // dev 2026-09-15, traceId 70caccc643d55bdf3f021331510c1c89).
247
+ //
248
+ // This used to be a refusal telling the caller to go and set that row by
249
+ // hand — and the refusal was unreachable, because the tool exposed no
250
+ // `required` parameter at all and `options_json` rejects notNull as an
251
+ // unknown option. So a caller who asked for a mandatory field got an optional
252
+ // one and no warning. Do the two steps instead of describing them.
253
+ const wantRequired = Boolean(fieldOpts.required);
254
+ delete fieldOpts.required; // never forwarded to the builder as notNull
254
255
  // An enum custom field is bound through relationTarget, exactly like a normal
255
256
  // one; the tenant convention (every enum field already on the tenant) is the
256
257
  // qualified '<ExtensionEntity>.<field>' name, and the variants are ordinary
@@ -290,6 +291,8 @@ export async function addCustomField(entityName, fieldName, fieldType, title, op
290
291
  return errorResponse(e, { sent: { customFields: envelope } });
291
292
  }
292
293
  const out = { result };
294
+ if (wantRequired)
295
+ out.required = await _markRequiredInSets(entityName, fieldName, result);
293
296
  if (usage)
294
297
  Object.assign(out, quotaNote(usage, 1));
295
298
  if (built.notApplicable && built.notApplicable.length > 0) {
@@ -336,6 +339,82 @@ export async function addCustomField(entityName, fieldName, fieldType, title, op
336
339
  `{"${fieldName}": <value>}}')`;
337
340
  return jsonResponse(out);
338
341
  }
342
+ /**
343
+ * Turn on per-context obligation for a custom field that was just created.
344
+ *
345
+ * `required` is a property of the LINK between a field and a set
346
+ * (`CustomFieldSetFields`), not of the column — one field can be mandatory in
347
+ * one context and optional in another, which is the whole point of sets. The
348
+ * builder has no way to set it, so this is a second call by design.
349
+ *
350
+ * NEVER turns a successful creation into a failure: the field exists either
351
+ * way, and the caller has to be told exactly which half happened rather than
352
+ * being handed an error for a column that is sitting on the tenant.
353
+ */
354
+ async function _markRequiredInSets(entityName, fieldName, result) {
355
+ const manual = `suppa_search_records("CustomFieldSetFields", filters on field.name="${fieldName}") to find ` +
356
+ 'the link row, then suppa_update_record on it with {"required": true}.';
357
+ const created = result?.[CUSTOM_FIELDS_KEY];
358
+ const fieldId = Array.isArray(created)
359
+ ? created.find((f) => f?.name === fieldName)?.id
360
+ : undefined;
361
+ if (typeof fieldId !== "number") {
362
+ return {
363
+ applied: false,
364
+ field_is_optional: true,
365
+ reason: "the builder's answer carried no id for this field, so its set link could not be found",
366
+ do_this: manual,
367
+ };
368
+ }
369
+ let links;
370
+ try {
371
+ links = await searchEntity("CustomFieldSetFields", [makeFilter("field.id", fieldId)], { id: true, set: { id: true } }, 50);
372
+ }
373
+ catch (e) {
374
+ return {
375
+ applied: false,
376
+ field_is_optional: true,
377
+ reason: `the field was created, but its set links could not be read: ${e instanceof Error ? e.message : String(e)}`,
378
+ do_this: manual,
379
+ };
380
+ }
381
+ const ids = links
382
+ .map((l) => l?.id)
383
+ .filter((id) => typeof id === "number");
384
+ if (ids.length === 0) {
385
+ return {
386
+ applied: false,
387
+ field_is_optional: true,
388
+ reason: "the field was created but is linked to no set, so there is no context to be required in",
389
+ do_this: manual,
390
+ };
391
+ }
392
+ const done = [];
393
+ const failed = {};
394
+ for (const id of ids) {
395
+ try {
396
+ await updateEntity("CustomFieldSetFields", id, { required: true });
397
+ done.push(id);
398
+ }
399
+ catch (e) {
400
+ failed[String(id)] = e instanceof Error ? e.message : String(e);
401
+ }
402
+ }
403
+ return {
404
+ applied: done.length > 0 && Object.keys(failed).length === 0,
405
+ link_rows_marked: done,
406
+ ...(Object.keys(failed).length > 0 ? { link_rows_that_failed: failed, do_this: manual } : {}),
407
+ // Obligation binds when the values row is created, not on every insert —
408
+ // an insert that never mentions customFields at all still passes (verified
409
+ // on dev 2026-09-15: record 120 went in with no customFields key).
410
+ means: `'${fieldName}' is now mandatory in this context: an insert or update that names it as ` +
411
+ `null is refused with "is required for this record's context". An insert that carries no ` +
412
+ `customFields key at all still passes — the obligation binds when the values row is written.`,
413
+ undo: `suppa_update_record("CustomFieldSetFields", <link row id>, '{"required": false}') — the ` +
414
+ `rows are listed above. suppa_resolve_custom_fields("${entityName}", …) shows each field's ` +
415
+ `current required flag.`,
416
+ };
417
+ }
339
418
  // ---------------------------------------------------------------------------
340
419
  // Remove / restore
341
420
  // ---------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -131,7 +131,9 @@ Confirm all 5 before writing anything:
131
131
 
132
132
  On an entity you do **not** own, the columns still come from your file — only the switch is out of reach: extension mode ignores entity options, so enable the feature once with `suppa_update_entity_options(entity_name, '{"customFields": true}')` (`POST /core/builder/<Entity>/update-options`). That is what W618 means when it fires on `options`.
133
133
 
134
- The gate enforces all of it — E124 (nested class registered, decorated or extending a base class), E125 (property name), E126 (primary / reverse relation), E127 (`nullable: false` without a default), E128 (half a context), E129 (SDK below 1.38.0), E130 (one class shared by two owners), W621 (column with no set), W622 (`contextField` not on the owner), W623 (the option written beside the decorator), W625 (a number as `contextValue` on an enum context field — that is an Enums row id copied off one tenant, not the stored value). Start from `templates/custom-fields.template.ts`.
134
+ **An extension whose only member is `@CustomFields` is complete** — it declares the columns of the generated table and nothing else, and the gate treats that as declaring plenty. W617 ("adds nothing") fires only on a class that declares neither columns nor `@CustomFields`; on a stub, `@CustomFields` is E117 like any other field, because the columns it names land on a tenant you do not own.
135
+
136
+ The gate enforces all of it — E124 (nested class registered, decorated or extending a base class), E125 (property name), E126 (primary / reverse relation), E127 (`nullable: false` without a default), E128 (half a context), E129 (SDK below 1.38.0), E130 (one class shared by two owners), W621 (column with no set), W622 (`contextField` not on the owner — owner mode only; in extension mode the owner's fields are declared elsewhere, so you get the advisory W624 instead of a block), W623 (the option written beside the decorator), W625 (a number as `contextValue` on an enum context field — that is an Enums row id copied off one tenant, not the stored value). Start from `templates/custom-fields.template.ts`.
135
137
 
136
138
  Two limits from the API reference: the extension table is capped at `CUSTOM_FIELDS_LIMIT` active custom fields (**default 200** — the cap guards the API, not migrations, so a long port can push a table past it and the API then stops serving it; the MCP tools that add fields report where the table stands), and a set declared for a context value applies to that value's **descendants** when the context field points at a hierarchical entity, so one entry covers a subtree.
137
139
 
@@ -238,9 +238,9 @@ The migrations page links to a separate [custom fields API reference](https://do
238
238
  | E129 | `@suppa/sdk` pinned below 1.38.0 in `package.json` |
239
239
  | E130 | one class named by `@CustomFields` on two owners |
240
240
  | W621 | a column with no `customFieldSets` — no record shows it |
241
- | W622 | `contextField` names no field on the owner |
241
+ | W622 | `contextField` names no field on the owner — **owner mode only**, where the file declares the whole entity. Inherited `SystemBaseEntity` columns (`id`, `createdAt`, `updatedAt`, `deletedAt`, `createdBy`, `removedBy`) count as fields on the owner and never trip it |
242
242
  | W623 | `options: { customFields: true }` written beside the decorator that implies it |
243
- | W624 | advisory: the nested class is declared in another file, or the SDK range cannot be read, so a check was skipped |
243
+ | W624 | advisory: the nested class is declared in another file, the SDK range cannot be read, or the class is an **extension** — there the owner's own fields are declared elsewhere, so `contextField` cannot be checked against them and W622 would be guesswork. Reported once per class, and never blocks |
244
244
  | W625 | a number as `contextValue` on an `@Enum` context field — an id, where the stored value belongs |
245
245
 
246
246
  ## Which route to take
@@ -769,6 +769,30 @@ function analyzeEntities(ts, sf, model, opts = {}) {
769
769
  });
770
770
  }
771
771
 
772
+ /**
773
+ * Every member the class DECLARES — which is NOT the same as `info.properties`.
774
+ *
775
+ * `info.properties` holds what became a COLUMN, and `@CustomFields` is
776
+ * deliberately kept out of it so no field rule treats it as one (see the
777
+ * CustomFields branch in collectEntities). Four rules then ask "does this class
778
+ * declare anything at all?" — W617 twice, E117 and W616 — and reading
779
+ * `properties.size` for that turned a class whose only member is `@CustomFields`
780
+ * into a class that declares nothing. That shipped: an extension holding one
781
+ * @CustomFields class, the exact form SKILL.md rule 22 prescribes for an entity
782
+ * you do not own, was told it "adds nothing" and the gate blocked it. The owner
783
+ * variant of the same class was told to rename itself to a stub, which would
784
+ * then have tripped E117.
785
+ *
786
+ * ANY future member kept off `properties` for the same reason must be added
787
+ * here, or those four rules go blind to it again. This is the one place that
788
+ * knows the difference between "declares no columns" and "declares nothing".
789
+ */
790
+ function declaredMembers(info) {
791
+ const names = [...info.properties.keys()];
792
+ if (info.customFieldsProp) names.push(info.customFieldsProp.propName);
793
+ return names;
794
+ }
795
+
772
796
  // ── rules: custom fields declared in code (@suppa/sdk 1.38.0) ──
773
797
  /**
774
798
  * `@CustomFields(() => Cls)` on an owner entity, with Cls a PLAIN class of
@@ -950,12 +974,22 @@ export function sdkFloorProblem(rootDir, floorText = "1.38.0") {
950
974
 
951
975
  /** Every property of the nested class is one custom field. */
952
976
  function checkCustomFieldColumns(ts, info, cls, findings) {
953
- const ownerFields = new Set();
977
+ // Seeded with the inherited columns: every entity extends SystemBaseEntity,
978
+ // so id/createdAt/updatedAt/deletedAt/createdBy/removedBy are fields ON THE
979
+ // OWNER that are never written in the file. Keying a context on one of them
980
+ // is legal, and comparing against declared properties alone called it a
981
+ // field the owner does not declare.
982
+ const ownerFields = new Set(SYSTEM_COLUMNS);
954
983
  for (const [propName, prop] of info.properties) {
955
984
  ownerFields.add(propName);
956
985
  const colName = stringValue(ts, prop.nameNode);
957
986
  if (colName) ownerFields.add(colName);
958
987
  }
988
+ // In extension mode the owner's field list is not in this file, so
989
+ // contextField cannot be checked against it. Collected here and reported ONCE
990
+ // per class: one advisory per column per set would drown the real findings.
991
+ const extensionMode = isExtensionFileName(info.sf.fileName);
992
+ const unverifiedContexts = new Set();
959
993
 
960
994
  for (const member of cls.members ?? []) {
961
995
  if (!member.name) continue;
@@ -1052,14 +1086,33 @@ function checkCustomFieldColumns(ts, info, cls, findings) {
1052
1086
  }
1053
1087
  // "contextField — Name of the field ON THE OWNER whose value decides the
1054
1088
  // context. It must exist on the owner."
1055
- if (cfName && ownerFields.size > 0 && !ownerFields.has(cfName)) {
1056
- findings.push(finding(ts, info.sf, cfNode, "W622",
1057
- `'${propName}' keys its context on '${cfName}', which '${info.className}' does not declare — ` +
1058
- `contextField must name a field ON THE OWNER. The migration resolves the context inside the ` +
1059
- `write transaction, so an unresolvable one fails the whole start, not just this field.`));
1089
+ //
1090
+ // Only decidable when this file describes the whole owner. An EXTENSION
1091
+ // declares its own columns on a table another application owns, so the
1092
+ // owner's other fields are not here to be found and their absence proves
1093
+ // nothing — blocking on it would fail the very shape rule 22 prescribes
1094
+ // for an entity you do not own. Report it as a check that could not run.
1095
+ if (cfName && !ownerFields.has(cfName)) {
1096
+ if (extensionMode) {
1097
+ unverifiedContexts.add(cfName);
1098
+ } else {
1099
+ findings.push(finding(ts, info.sf, cfNode, "W622",
1100
+ `'${propName}' keys its context on '${cfName}', which '${info.className}' does not declare — ` +
1101
+ `contextField must name a field ON THE OWNER. The migration resolves the context inside the ` +
1102
+ `write transaction, so an unresolvable one fails the whole start, not just this field.`));
1103
+ }
1060
1104
  }
1061
1105
  }
1062
1106
  }
1107
+
1108
+ if (unverifiedContexts.size > 0) {
1109
+ findings.push(finding(ts, info.sf, info.customFieldsProp.node, "W624",
1110
+ `'${info.className}' is an EXTENSION, so the owner's own fields are declared by whoever owns ` +
1111
+ `'${info.entityName}', not in this file — contextField ${[...unverifiedContexts].map((n) => `'${n}'`).join(", ")} ` +
1112
+ `could NOT be checked against them. Confirm each one exists on '${info.entityName}' ` +
1113
+ `(suppa_describe_entity("${info.entityName}")): the migration resolves the context inside the write ` +
1114
+ `transaction, so an unresolvable one fails the whole start, not just this field. Advisory — it does not block.`));
1115
+ }
1063
1116
  }
1064
1117
 
1065
1118
  // ── rules: tabular parts ──
@@ -2018,7 +2071,11 @@ function checkExtension(ts, info, findings) {
2018
2071
  : "")));
2019
2072
  }
2020
2073
 
2021
- if (info.properties.size === 0) {
2074
+ // declaredMembers, NOT properties.size: an extension whose only member is
2075
+ // @CustomFields contributes the columns of the nested class, and rule 22
2076
+ // prescribes exactly that shape for an entity you do not own — "the custom
2077
+ // field COLUMNS still come from your file, only the switch is an owner action".
2078
+ if (declaredMembers(info).length === 0) {
2022
2079
  findings.push(finding(ts, sf, anchor, "W617",
2023
2080
  `extension '${info.className}' declares no columns, so it adds nothing to ${target} — ` +
2024
2081
  `an extension exists to contribute fields. If you only need the entity as a RELATION TARGET, that is a ` +
@@ -2541,7 +2598,11 @@ function checkStubFiles(ts, model, findings) {
2541
2598
  const stubFile = isStubFileName(infos[0].sf.fileName);
2542
2599
  for (const info of infos) {
2543
2600
  const anchor = info.node.name ?? info.node;
2544
- const fields = info.properties.size;
2601
+ // declaredMembers, NOT properties.size — see its doc comment. A class
2602
+ // whose only member is @CustomFields declares plenty; counting columns
2603
+ // made it look empty to all three rules below at once.
2604
+ const members = declaredMembers(info);
2605
+ const fields = members.length;
2545
2606
 
2546
2607
  // The whole point of a stub is the EMPTY body: it names a table another
2547
2608
  // application owns, and any field it declares is a column the migration
@@ -2549,10 +2610,19 @@ function checkStubFiles(ts, model, findings) {
2549
2610
  // that KEPT its fields is the failure this catches — it used to pass.
2550
2611
  if (stubFile && fields > 0) {
2551
2612
  findings.push(finding(ts, info.sf, anchor, "E117",
2552
- `stub '${info.className}' declares ${fields} field(s) (${[...info.properties.keys()].slice(0, 4).join(", ")}` +
2613
+ `stub '${info.className}' declares ${fields} field(s) (${members.slice(0, 4).join(", ")}` +
2553
2614
  `${fields > 4 ? ", …" : ""}) — a stub stands in for a table this application does NOT own, and every ` +
2554
2615
  `field it declares is a column the migration will create or alter on that real table. The body must ` +
2555
- `be EMPTY. If this entity IS yours to describe, it is not a stub: move it to ` +
2616
+ `be EMPTY.` +
2617
+ // @CustomFields declares columns just as surely as @Column does, only
2618
+ // on the generated {Owner}CustomFields table — and it is the member a
2619
+ // stub is most likely to be given by mistake, because the columns sit
2620
+ // in a class one level down and do not look like the stub's own body.
2621
+ (info.customFieldsProp
2622
+ ? ` @CustomFields counts: the nested class it names becomes the columns of ` +
2623
+ `'${info.entityName}CustomFields', a table on that same tenant.`
2624
+ : "") +
2625
+ ` If this entity IS yours to describe, it is not a stub: move it to ` +
2556
2626
  `${kebabOf(info.className)}.entity.ts and describe it there. If you mean to ADD columns to an entity ` +
2557
2627
  `another application owns, that is an extension, not a stub — declare only your own columns in ` +
2558
2628
  `${kebabOf(info.entityName)}.extension.entity.ts (see SKILL.md rule 20)`));