@happyvertical/smrt-scanner 0.70.0 → 0.70.2

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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { r as ManifestAdapter, t as OxcScanner } from "./chunks/scanner-DIX2ZSU8.js";
2
+ import { r as ManifestAdapter, t as OxcScanner } from "./chunks/scanner-tseYDUFG.js";
3
3
  import { readFileSync, writeFileSync } from "node:fs";
4
4
  import { dirname, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export { classifyNumericFieldName, lintNumericPrecision, type NumericPrecisionFi
26
26
  export { extractSmrtImports, parseAgentSurfaceFile, parseFile, parseRecipeFile, parseSource, } from './oxc-parser.js';
27
27
  export { deriveHelpFieldRefs, extractRecipes, type RawRecipe, type RawRecipeModelRef, resolveRecipes, sourceMayDeclareRecipe, } from './recipes.js';
28
28
  export { OxcScanner } from './scanner.js';
29
+ export { lintSetterHiddenReads, type SetterHiddenReadFinding, sourceMayContainSetterHiddenRead, } from './setter-hidden-read-lint.js';
29
30
  export * from './types.js';
30
31
  export { parseUiSelectorsFile } from './ui-selectors.js';
31
32
  export { type VerifyManifestCompletenessOptions, type VerifyManifestCompletenessResult, type VerifyManifestStatus, verifyManifestCompleteness, } from './verify-completeness.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,KAAK,2BAA2B,EAChC,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL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BAAuB,EACvB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,qCAAqC,EACrC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,cAAc,EACd,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,gCAAgC,GACjC,MAAM,8BAA8B,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { C as isPrunedAgentSurfacePath, E as sourceMayDeclareAgentSurface, S as isAgentSurfaceSourcePath, T as scanSvelteAgentSurface, _ as normalizeGlobSeparators, a as extractSmrtImports, b as emptyAgentSurface, c as parseRecipeFile, d as extractRecipes, f as resolveRecipes, g as discoverSourceFiles, h as resolveEnumValues, i as defaultCollectionName, l as parseSource, m as InheritanceResolver, n as parseUiSelectorsFile, o as parseAgentSurfaceFile, p as sourceMayDeclareRecipe, r as ManifestAdapter, s as parseFile, t as OxcScanner, u as deriveHelpFieldRefs, v as relativeGlobToCwd, w as mergeAgentSurfaces, x as extractAgentSurface, y as checkAgentSurfaceToolNames } from "./chunks/scanner-DIX2ZSU8.js";
1
+ import { C as isPrunedAgentSurfacePath, D as getLineColumn, E as sourceMayDeclareAgentSurface, S as isAgentSurfaceSourcePath, T as scanSvelteAgentSurface, _ as normalizeGlobSeparators, a as extractSmrtImports, b as emptyAgentSurface, c as parseRecipeFile, d as extractRecipes, f as resolveRecipes, g as discoverSourceFiles, h as resolveEnumValues, i as defaultCollectionName, l as parseSource, m as InheritanceResolver, n as parseUiSelectorsFile, o as parseAgentSurfaceFile, p as sourceMayDeclareRecipe, r as ManifestAdapter, s as parseFile, t as OxcScanner, u as deriveHelpFieldRefs, v as relativeGlobToCwd, w as mergeAgentSurfaces, x as extractAgentSurface, y as checkAgentSurfaceToolNames } from "./chunks/scanner-tseYDUFG.js";
2
2
  import "./types.js";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { basename, resolve } from "node:path";
5
+ import { parseSync } from "oxc-parser";
5
6
  //#region src/numeric-precision-lint.ts
6
7
  var MONEY_HEAD_WORDS = /* @__PURE__ */ new Set([
7
8
  "amount",
@@ -138,6 +139,199 @@ function lintNumericPrecision(classes, sourceText) {
138
139
  return findings;
139
140
  }
140
141
  //#endregion
142
+ //#region src/setter-hidden-read-lint.ts
143
+ var SKIP_KEYS = /* @__PURE__ */ new Set([
144
+ "loc",
145
+ "start",
146
+ "end",
147
+ "range",
148
+ "parent"
149
+ ]);
150
+ var TS_WRAPPERS = /* @__PURE__ */ new Set([
151
+ "TSNonNullExpression",
152
+ "TSAsExpression",
153
+ "TSSatisfiesExpression",
154
+ "TSTypeAssertion",
155
+ "ParenthesizedExpression"
156
+ ]);
157
+ function sourceMayContainSetterHiddenRead(source) {
158
+ return /\bset\s*[\w$#['"`]/.test(source) && /\bthis\b/.test(source) && /\b(?:sensitive|readPermission)\b/.test(source);
159
+ }
160
+ function unwrap(node) {
161
+ let current = node;
162
+ while (current && TS_WRAPPERS.has(current.type)) current = current.expression;
163
+ return current;
164
+ }
165
+ function keyName(key, computed) {
166
+ if (!key) return void 0;
167
+ if (!computed && key.type === "Identifier") return key.name;
168
+ if (key.type === "Literal" && typeof key.value === "string") return key.value;
169
+ }
170
+ function thisMemberName(node) {
171
+ const target = unwrap(node);
172
+ if (target?.type !== "MemberExpression") return void 0;
173
+ if (unwrap(target.object)?.type !== "ThisExpression") return void 0;
174
+ return keyName(target.property, target.computed);
175
+ }
176
+ function objectProperty(object, name) {
177
+ for (const prop of object.properties ?? []) {
178
+ if (prop.type !== "Property") continue;
179
+ if (keyName(prop.key, prop.computed) === name) return prop;
180
+ }
181
+ }
182
+ function hiddenBy(member) {
183
+ for (const decorator of member.decorators ?? []) {
184
+ const call = decorator.expression;
185
+ if (call?.type !== "CallExpression") continue;
186
+ if (call.callee?.type !== "Identifier" || call.callee.name !== "field") continue;
187
+ const config = call.arguments?.[0];
188
+ if (config?.type !== "ObjectExpression") continue;
189
+ const sensitive = objectProperty(config, "sensitive");
190
+ if (sensitive?.value?.type === "Literal" && sensitive.value.value === true) return "sensitive";
191
+ const permission = objectProperty(config, "readPermission");
192
+ if (permission?.value?.type === "Literal" && typeof permission.value.value === "string" && permission.value.value !== "") return "readPermission";
193
+ }
194
+ }
195
+ function collectReads(body, hidden) {
196
+ const reads = [];
197
+ const visitTarget = (node) => {
198
+ const target = unwrap(node);
199
+ if (!target) return;
200
+ switch (target.type) {
201
+ case "MemberExpression":
202
+ if (thisMemberName(target) === void 0) {
203
+ visit(target.object);
204
+ if (target.computed) visit(target.property);
205
+ }
206
+ return;
207
+ case "ArrayPattern":
208
+ for (const element of target.elements ?? []) visitTarget(element);
209
+ return;
210
+ case "ObjectPattern":
211
+ for (const prop of target.properties ?? []) if (prop.type === "RestElement") visitTarget(prop.argument);
212
+ else {
213
+ if (prop.computed) visit(prop.key);
214
+ visitTarget(prop.value);
215
+ }
216
+ return;
217
+ case "RestElement":
218
+ visitTarget(target.argument);
219
+ return;
220
+ case "AssignmentPattern":
221
+ visitTarget(target.left);
222
+ visit(target.right);
223
+ return;
224
+ default: return;
225
+ }
226
+ };
227
+ const visitThisPattern = (pattern) => {
228
+ for (const prop of pattern?.properties ?? []) {
229
+ if (prop.type !== "Property") continue;
230
+ const name = keyName(prop.key, prop.computed);
231
+ if (name !== void 0 && hidden.has(name)) reads.push({
232
+ field: name,
233
+ start: prop.start
234
+ });
235
+ }
236
+ };
237
+ const visit = (node) => {
238
+ if (!node || typeof node !== "object") return;
239
+ if (Array.isArray(node)) {
240
+ for (const item of node) visit(item);
241
+ return;
242
+ }
243
+ if (typeof node.type !== "string") return;
244
+ switch (node.type) {
245
+ case "FunctionExpression":
246
+ case "FunctionDeclaration":
247
+ case "ClassExpression":
248
+ case "ClassDeclaration": return;
249
+ case "AssignmentExpression":
250
+ if (node.operator === "=") {
251
+ visitTarget(node.left);
252
+ if (unwrap(node.right)?.type === "ThisExpression" && unwrap(node.left)?.type === "ObjectPattern") visitThisPattern(unwrap(node.left));
253
+ visit(node.right);
254
+ return;
255
+ }
256
+ break;
257
+ case "ForOfStatement":
258
+ case "ForInStatement":
259
+ if (node.left?.type === "VariableDeclaration") visit(node.left);
260
+ else visitTarget(node.left);
261
+ visit(node.right);
262
+ visit(node.body);
263
+ return;
264
+ case "VariableDeclarator":
265
+ if (unwrap(node.init)?.type === "ThisExpression" && node.id?.type === "ObjectPattern") visitThisPattern(node.id);
266
+ break;
267
+ case "MemberExpression": {
268
+ const name = thisMemberName(node);
269
+ if (name !== void 0 && hidden.has(name)) {
270
+ reads.push({
271
+ field: name,
272
+ start: node.start
273
+ });
274
+ return;
275
+ }
276
+ break;
277
+ }
278
+ }
279
+ for (const [key, value] of Object.entries(node)) if (!SKIP_KEYS.has(key)) visit(value);
280
+ };
281
+ visit(body);
282
+ return reads;
283
+ }
284
+ function lintSetterHiddenReads(sourceText, filePath = "model.ts") {
285
+ const parsed = parseSync(filePath, sourceText, {
286
+ lang: filePath.endsWith(".tsx") ? "tsx" : "ts",
287
+ preserveParens: false
288
+ });
289
+ const findings = [];
290
+ const visitClass = (cls) => {
291
+ const hidden = /* @__PURE__ */ new Map();
292
+ for (const member of cls.body?.body ?? []) {
293
+ if (member.type !== "PropertyDefinition" || member.static) continue;
294
+ const name = keyName(member.key, member.computed);
295
+ const reason = name === void 0 ? void 0 : hiddenBy(member);
296
+ if (name !== void 0 && reason) hidden.set(name, reason);
297
+ }
298
+ if (hidden.size === 0) return;
299
+ for (const member of cls.body.body) {
300
+ if (member.type !== "MethodDefinition" || member.kind !== "set" || member.static) continue;
301
+ const setterName = keyName(member.key, member.computed) ?? "<computed>";
302
+ const seen = /* @__PURE__ */ new Set();
303
+ for (const read of collectReads(member.value?.body, new Set(hidden.keys()))) {
304
+ if (seen.has(read.field)) continue;
305
+ seen.add(read.field);
306
+ const reason = hidden.get(read.field);
307
+ const className = cls.id?.name ?? "<anonymous>";
308
+ findings.push({
309
+ className,
310
+ setterName,
311
+ fieldName: read.field,
312
+ hiddenBy: reason,
313
+ filePath,
314
+ line: getLineColumn(sourceText, read.start)?.line ?? 0,
315
+ message: `${className}.${setterName} (setter) reads ${read.field}, a ${reason === "sensitive" ? "sensitive" : "readPermission"} field some callers cannot read. A caller with update permission can confirm the hidden value by whether the write is accepted or refused; the engine does not proxy hidden-field reads in accessors.`,
316
+ remedy: `Do not read ${read.field} in the setter: assign it unconditionally, or move the branch into a method that is not reachable through a caller-writable key.`
317
+ });
318
+ }
319
+ }
320
+ };
321
+ const walk = (node) => {
322
+ if (!node || typeof node !== "object") return;
323
+ if (Array.isArray(node)) {
324
+ for (const item of node) walk(item);
325
+ return;
326
+ }
327
+ if (typeof node.type !== "string") return;
328
+ if (node.type === "ClassDeclaration" || node.type === "ClassExpression") visitClass(node);
329
+ for (const [key, value] of Object.entries(node)) if (!SKIP_KEYS.has(key)) walk(value);
330
+ };
331
+ walk(parsed.program);
332
+ return findings;
333
+ }
334
+ //#endregion
141
335
  //#region src/verify-completeness.ts
142
336
  var DEFAULT_INCLUDE = ["src/**/*.ts"];
143
337
  var DEFAULT_EXCLUDE = [
@@ -281,6 +475,6 @@ async function verifyManifestCompleteness(options) {
281
475
  };
282
476
  }
283
477
  //#endregion
284
- export { InheritanceResolver, ManifestAdapter, OxcScanner, checkAgentSurfaceToolNames, classifyNumericFieldName, defaultCollectionName, deriveHelpFieldRefs, discoverSourceFiles, emptyAgentSurface, extractAgentSurface, extractRecipes, extractSmrtImports, isAgentSurfaceSourcePath, isPrunedAgentSurfacePath, lintNumericPrecision, mergeAgentSurfaces, normalizeGlobSeparators, parseAgentSurfaceFile, parseFile, parseRecipeFile, parseSource, parseUiSelectorsFile, relativeGlobToCwd, resolveEnumValues, resolveRecipes, scanSvelteAgentSurface, sourceMayContainNumericPrecisionIssue, sourceMayDeclareAgentSurface, sourceMayDeclareRecipe, splitIdentifierWords, verifyManifestCompleteness };
478
+ export { InheritanceResolver, ManifestAdapter, OxcScanner, checkAgentSurfaceToolNames, classifyNumericFieldName, defaultCollectionName, deriveHelpFieldRefs, discoverSourceFiles, emptyAgentSurface, extractAgentSurface, extractRecipes, extractSmrtImports, isAgentSurfaceSourcePath, isPrunedAgentSurfacePath, lintNumericPrecision, lintSetterHiddenReads, mergeAgentSurfaces, normalizeGlobSeparators, parseAgentSurfaceFile, parseFile, parseRecipeFile, parseSource, parseUiSelectorsFile, relativeGlobToCwd, resolveEnumValues, resolveRecipes, scanSvelteAgentSurface, sourceMayContainNumericPrecisionIssue, sourceMayContainSetterHiddenRead, sourceMayDeclareAgentSurface, sourceMayDeclareRecipe, splitIdentifierWords, verifyManifestCompleteness };
285
479
 
286
480
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/numeric-precision-lint.ts","../src/verify-completeness.ts"],"sourcesContent":["/**\n * Numeric-precision lint for money and rate fields (#2361).\n *\n * SMRT infers a `number` field's column type from the *initializer literal*:\n * `= 0` compiles to INTEGER and `= 0.0` compiles to DECIMAL\n * (`manifest-adapter.ts`, inference steps 3 and 3.5). The rule is silent, and\n * SQLite's type affinity happily stores a REAL in an INTEGER column — so a\n * mistyped field passes every SQLite suite and then behaves differently in\n * production on PostgreSQL.\n *\n * Two vocabularies, opposite answers:\n *\n * - **Money is exact**, so it is stored as *integer minor units* — cents,\n * satoshis. `$19.99` is `1999`. A money field declared `= 0.0` becomes a\n * float column, which reintroduces binary-fraction error into amounts that\n * must balance, and invites callers to write major units.\n * - **Rates are inherently fractional** — `taxRate`, `confidence`, a percentage\n * — so they must be DECIMAL. INTEGER would truncate every meaningful value\n * (a confidence in `[0, 1]` collapses to 0 or 1) and PostgreSQL rejects the\n * write outright with `22P02`.\n *\n * Matching is head-noun based rather than substring based, which is what keeps\n * it usable as a repo-wide gate: `amountCents` and `totalTokensUsed` name a\n * unit or a count as their head and are left alone, while `totalAmount`,\n * `amountPaid` and a bare `total` are money. JSDoc prose is deliberately NOT\n * matched — the head-noun signal is precise, and scanning prose for the same\n * vocabulary would make the gate fire on documentation wording.\n */\n\nimport type { RawClassDefinition, RawFieldDefinition } from './types.js';\n\n/**\n * Head nouns that denote an exact monetary quantity, stored as integer minor\n * units.\n *\n * `tax` is money (a tax *amount*); `taxRate` is not, and the rate vocabulary\n * below wins whenever both appear, so the two never collide.\n */\nconst MONEY_HEAD_WORDS = new Set([\n 'amount',\n 'balance',\n 'cost',\n 'discount',\n 'due',\n 'fee',\n 'paid',\n 'price',\n 'subtotal',\n 'tax',\n 'total',\n]);\n\n/**\n * Head nouns that denote an inherently fractional quantity, stored as DECIMAL.\n *\n * A name carrying any of these is a rate even when it also carries a money word\n * (`taxRate`, `feePercentage`), because the rate is what the value *is*.\n */\nconst RATE_WORDS = new Set([\n 'confidence',\n 'credibility',\n 'probability',\n 'rate',\n 'ratio',\n]);\n\n/**\n * Deliberately NOT rate words: `weight`, `score`, `factor`, `percent`.\n *\n * Each is commonly a whole number — an ad-rotation `weight` of 1, a score out\n * of 100, a percent as 0–100 — so treating them as necessarily fractional\n * produces false positives on correct code. `AdVariation.weight = 1` is the\n * worked example. They are left unclassified rather than guessed at.\n */\n\n/**\n * Words that may trail a head noun without displacing it.\n *\n * `amountPaid` is still an amount; `amountCents` is not — its head noun already\n * names the exact unit — which is why this is an allowlist rather than a\n * blocklist of unit words.\n */\nconst TRAILING_QUALIFIERS = new Set([\n 'applied',\n 'billed',\n 'charged',\n 'collected',\n 'earned',\n 'gross',\n 'net',\n 'outstanding',\n 'owed',\n 'refunded',\n 'remaining',\n]);\n\n/** Base classes whose fields become table columns even without `@smrt()`. */\nconst PERSISTED_BASE_CLASSES = new Set([\n 'SmrtObject',\n 'SmrtJunction',\n 'SmrtJunctionBase',\n 'SmrtHierarchical',\n 'SmrtPolymorphicAssociation',\n]);\n\n/** Which rule a field falls under, if any. */\nexport type NumericPrecisionKind = 'money' | 'rate';\n\n/** One field whose declared precision contradicts its name. */\nexport interface NumericPrecisionFinding {\n /** `money` wants INTEGER minor units; `rate` wants DECIMAL. */\n kind: NumericPrecisionKind;\n /** Declaring class, e.g. `Invoice`. */\n className: string;\n /** Field name, e.g. `totalAmount`. */\n fieldName: string;\n /** File the class was scanned from. */\n filePath: string;\n /**\n * 1-based line of the field declaration, or `0` when it could not be\n * resolved. The OXC AST nodes this scanner consumes do not carry `loc`, so\n * the line is recovered from the source text when a caller passes it to\n * {@link lintNumericPrecision}.\n */\n line: number;\n /** The initializer that triggered the finding. */\n initializer: string;\n /** Human-readable explanation naming the rule. */\n message: string;\n /** The accepted fixes. */\n remedy: string;\n}\n\n/**\n * Split an identifier into lowercase words on camelCase, PascalCase, digits,\n * and underscores. `totalAmountCents` → `['total', 'amount', 'cents']`.\n */\nexport function splitIdentifierWords(name: string): string[] {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .split(/[\\s_$]+/)\n .filter(Boolean)\n .map((word) => word.toLowerCase());\n}\n\n/**\n * Classify an identifier as money, a rate, or neither.\n *\n * The head noun is the last word, or the last word before a trailing qualifier\n * such as `Paid`. A rate word anywhere in the name wins outright: `taxRate` is\n * a rate even though `tax` is money, and that precedence is what stops the two\n * vocabularies from fighting over the same field.\n */\nexport function classifyNumericFieldName(\n name: string,\n): NumericPrecisionKind | undefined {\n const words = splitIdentifierWords(name);\n if (words.some((word) => RATE_WORDS.has(word))) return 'rate';\n for (let index = words.length - 1; index >= 0; index -= 1) {\n const word = words[index];\n if (MONEY_HEAD_WORDS.has(word)) return 'money';\n if (!TRAILING_QUALIFIERS.has(word)) return undefined;\n }\n return undefined;\n}\n\n/**\n * Text a file must contain before it can declare a field this lint reports.\n *\n * `@smrt` is matched without requiring parentheses because the parser accepts\n * the bare identifier form too, and the decorator name is never resolved\n * through an import alias — so the literal text is always present.\n */\nconst PERSISTED_CLASS_MARKER = /@smrt\\b|extends\\s+Smrt/;\n\n/** Any numeric initializer. Deliberately does not require a terminator. */\nconst NUMERIC_INITIALIZER = /=\\s*-?\\d/;\n\nconst ALL_WORDS = [...MONEY_HEAD_WORDS, ...RATE_WORDS];\n\n/**\n * A relevant word starting an identifier — any case, since `Price` and `price`\n * are both legal there. Case-insensitivity also matches prose in comments,\n * which costs a parse and nothing else.\n */\nconst WORD_AT_START = new RegExp(\n `(?<![A-Za-z])(?:${ALL_WORDS.join('|')})`,\n 'i',\n);\n\n/**\n * A relevant word after a camel hump (`unitPrice`, `USDPrice`), where it is\n * necessarily capitalized and necessarily preceded by an identifier character.\n * This arm cannot be case-insensitive: `generate` would then match on `rate`.\n *\n * Together the two arms cover exactly the boundaries {@link splitIdentifierWords}\n * cuts on, which is what makes the filter conservative rather than plausible.\n */\nconst WORD_AFTER_HUMP = new RegExp(\n `(?<=[A-Za-z0-9])(?:${ALL_WORDS.map(\n (word) => word[0].toUpperCase() + word.slice(1),\n ).join('|')})`,\n);\n\n/**\n * Cheap pre-filter so callers can skip parsing files that cannot produce a\n * finding.\n *\n * Conservative by construction: every condition here is textually implied by a\n * finding. A reported field lives in a class carrying `@smrt` or\n * `extends Smrt…`, is initialized to a number, and has a money or rate word at\n * one of the boundaries the head-noun splitter cuts on. It may still return\n * `true` for a file the AST pass then clears — that is the intended direction.\n *\n * @param source - Full file contents.\n * @returns `false` only when the file provably cannot produce a finding.\n */\nexport function sourceMayContainNumericPrecisionIssue(source: string): boolean {\n return (\n PERSISTED_CLASS_MARKER.test(source) &&\n NUMERIC_INITIALIZER.test(source) &&\n (WORD_AT_START.test(source) || WORD_AFTER_HUMP.test(source))\n );\n}\n\n/**\n * Blank out string-literal contents so option *keys* can be matched without\n * prose inside a value masquerading as one.\n *\n * `@field({ description: 'Discount type: percent or flat' })` otherwise reads\n * as an explicit `type:` and silently suppresses a real finding — and\n * `description` is a shipped option (#2046), so this is reachable, not\n * hypothetical. Quote characters are preserved to keep offsets stable.\n */\nfunction blankStringLiterals(text: string): string {\n return text.replace(/(['\"`])(?:\\\\.|(?!\\1)[\\s\\S])*\\1/g, (match) =>\n match[0].repeat(match.length),\n );\n}\n\n/** Does any decorator on this field state the column type explicitly? */\nfunction hasExplicitTypeDecorator(field: RawFieldDefinition): boolean {\n for (const decorator of field.decorators) {\n // Relationship decorators own the column type outright.\n if (\n decorator.name === 'foreignKey' ||\n decorator.name === 'crossPackageRef' ||\n decorator.name === 'oneToMany' ||\n decorator.name === 'manyToMany' ||\n decorator.name === 'tenantId'\n ) {\n return true;\n }\n if (decorator.name !== 'field') continue;\n const args = blankStringLiterals(decorator.arguments.join(' '));\n // An explicit declaration of intent is exactly what this lint asks for,\n // whichever type was chosen.\n if (/\\btype\\s*:/.test(args)) return true;\n // A transient field is never persisted, so no column type is inferred.\n if (/\\btransient\\s*:\\s*true\\b/.test(args)) return true;\n }\n return false;\n}\n\n/** Fields stored in the STI `_meta_data` JSON blob get no typed column. */\nfunction isMetaField(field: RawFieldDefinition): boolean {\n if (field.decorators.some((decorator) => decorator.name === 'meta')) {\n return true;\n }\n return /^Meta\\s*</.test(field.typeAnnotation ?? '');\n}\n\n/** Is this a plain `number` column whose type came from the literal? */\nfunction usesLiteralInference(field: RawFieldDefinition): boolean {\n if (field.numericValue === null) return false;\n const annotation = (field.typeAnnotation ?? '').replace(/\\s/g, '');\n if (annotation === '') return true; // `price = 0` — inference step 3.5\n return annotation === 'number' || annotation === 'number|null';\n}\n\n/** Are this class's fields materialized as table columns? */\nfunction isPersistedClass(cls: RawClassDefinition): boolean {\n if (cls.hasSmartDecorator) return true;\n return PERSISTED_BASE_CLASSES.has(cls.extendsClause ?? '');\n}\n\n/**\n * Recover a field's 1-based declaration line from source text.\n *\n * The scanner's raw field records carry `line: 0` because the OXC AST nodes\n * have no `loc`, and a finding that cannot point at a line is much harder to\n * act on — so callers that already hold the file contents get a real line.\n */\nfunction resolveDeclarationLine(\n sourceText: string | undefined,\n fieldName: string,\n fallback: number,\n): number {\n if (fallback > 0 || !sourceText) return fallback;\n // `$` is a legal identifier character and a regex anchor, so the name has to\n // be escaped rather than interpolated raw.\n const escapedName = fieldName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const declaration = new RegExp(\n `^\\\\s*(?:(?:public|private|protected|readonly|declare|override)\\\\s+)*${escapedName}\\\\s*[?!]?\\\\s*(?::[^=;]+)?=\\\\s*-?\\\\d`,\n );\n const lines = sourceText.split('\\n');\n for (let index = 0; index < lines.length; index += 1) {\n if (declaration.test(lines[index])) return index + 1;\n }\n return 0;\n}\n\nfunction describeMoneyFinding(\n cls: RawClassDefinition,\n field: RawFieldDefinition,\n): Pick<NumericPrecisionFinding, 'message' | 'remedy'> {\n const whole = Math.trunc(field.numericValue ?? 0);\n return {\n message:\n `${cls.className}.${field.name} is a money field with a decimal ` +\n `initializer (= ${field.initializer ?? field.numericValue}), so SMRT ` +\n 'compiles it to a floating-point column. Money is exact and is stored ' +\n 'as integer minor units (cents, satoshis) — $19.99 is 1999 — so a float ' +\n 'column reintroduces binary-fraction error into amounts that must ' +\n 'balance.',\n remedy:\n `Write an integer initializer (\\`${field.name} = ${whole}\\`) and treat ` +\n 'the value as minor units, or state the intent explicitly with ' +\n \"`@field({ type: 'decimal' })` when the value really is fractional.\",\n };\n}\n\nfunction describeRateFinding(\n cls: RawClassDefinition,\n field: RawFieldDefinition,\n): Pick<NumericPrecisionFinding, 'message' | 'remedy'> {\n return {\n message:\n `${cls.className}.${field.name} is a rate with an integer initializer ` +\n `(= ${field.numericValue}), so SMRT compiles it to an INTEGER column. A ` +\n 'rate is inherently fractional, so every meaningful value truncates; ' +\n 'PostgreSQL rejects the save with 22P02 while SQLite silently accepts it.',\n remedy:\n `Write a decimal initializer (\\`${field.name} = ${field.numericValue}.0\\`) ` +\n 'to get a DECIMAL column, or state the intent explicitly with ' +\n \"`@field({ type: 'integer' })` when the value really is a whole count.\",\n };\n}\n\n/**\n * Report every persisted `number` field whose declared precision contradicts\n * its name — money declared decimal, or a rate declared integer.\n *\n * @param classes - Raw class definitions from `parseFile` / `OxcScanner`.\n * @param sourceText - Optional contents of the scanned file, used only to\n * recover declaration line numbers the AST does not carry.\n * @returns One finding per offending field, in declaration order.\n */\nexport function lintNumericPrecision(\n classes: RawClassDefinition[],\n sourceText?: string,\n): NumericPrecisionFinding[] {\n const findings: NumericPrecisionFinding[] = [];\n for (const cls of classes) {\n if (!isPersistedClass(cls)) continue;\n for (const field of cls.fields) {\n if (field.isStatic) continue;\n if (!usesLiteralInference(field)) continue;\n const kind = classifyNumericFieldName(field.name);\n if (!kind) continue;\n // Money wants an integer literal; a rate wants a decimal one. A field\n // already on the right side of its rule is fine.\n if (kind === 'money' && !field.hasDecimalPoint) continue;\n if (kind === 'rate' && field.hasDecimalPoint) continue;\n if (isMetaField(field)) continue;\n if (hasExplicitTypeDecorator(field)) continue;\n findings.push({\n kind,\n className: cls.className,\n fieldName: field.name,\n filePath: cls.filePath,\n line: resolveDeclarationLine(sourceText, field.name, field.line),\n initializer: field.initializer ?? String(field.numericValue),\n ...(kind === 'money'\n ? describeMoneyFinding(cls, field)\n : describeRateFinding(cls, field)),\n });\n }\n }\n return findings;\n}\n","/**\n * Manifest completeness verification.\n *\n * Re-scans a package's `src/` with the same OXC scanner the build uses and\n * asserts that every `@smrt()`-decorated object (and its collection) is present\n * in the package's published `dist/manifest.json`. This is a publish-time guard:\n * downstream schema migration is manifest-driven, so a stale manifest that omits\n * an object means consumers can never create its table via `smrt db:migrate`.\n *\n * Root cause it guards against (issue #1483): `@happyvertical/smrt-jobs@0.27.41`\n * shipped a `dist/manifest.json` generated before `SmrtWorker` existed. The\n * source, exports, and `__smrt-register__` path were all correct, but the\n * published manifest had only 4 of 6 objects, so `_smrt_workers` was never\n * created and `TaskRunner.start()` threw on every consumer that upgraded.\n *\n * The check compares object-key SETS only. The downstream manifest-enrichment\n * passes (schema/validation/agent generation) mutate object entries but never\n * add or remove object keys, so the scanner + adapter object set is the source\n * of truth for \"which objects the published manifest must contain\". The\n * comparison is `expected ⊆ dist`: enrichment passes that add keys to `dist`\n * (e.g. STI children) never trigger a false failure.\n *\n * Parse errors are handled before the set comparison: a syntactically broken\n * source file drops its objects from `expected` AND `dist` symmetrically, which\n * a naive `expected ⊆ dist` would wave through as `ok`. The scan's\n * `severity:'error'` entries therefore short-circuit to a distinct `scan-error`\n * status so a broken source can never masquerade as a complete manifest.\n *\n * @see https://github.com/happyvertical/smrt/issues/1483\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, resolve } from 'node:path';\nimport { ManifestAdapter } from './manifest-adapter.js';\nimport { OxcScanner } from './scanner.js';\n\n/**\n * Source globs for the completeness scan. The build (`vite.config.base.ts`)\n * passes `include: ['src/**\\/*.ts']` and excludes `*.test.ts` / `*.spec.ts` (the\n * plugin also drops `*.svelte`); we reproduce that so the expected object set\n * matches what the build would publish. We additionally exclude\n * `**\\/__tests__\\/**` so any `@smrt()` fixtures in non-test helper modules under\n * `src/__tests__/` (e.g. `src/__tests__/helpers/*.ts`) are never required in the\n * published manifest. These extra exclusions can only shrink `expected` relative\n * to the build, so they can never cause a false failure — the check is\n * `expected ⊆ dist`.\n */\nconst DEFAULT_INCLUDE = ['src/**/*.ts'];\nconst DEFAULT_EXCLUDE = [\n '**/*.test.ts',\n '**/*.spec.ts',\n '**/__tests__/**',\n '**/*.svelte',\n '**/node_modules/**',\n '**/dist/**',\n '**/*.d.ts',\n];\n\n/**\n * Framework-infrastructure packages whose published manifest is NOT produced by\n * the OXC scanner path (e.g. `@happyvertical/smrt-core` ships a curated static\n * manifest). Mirrors `skipSmrtPlugin` in `vite.config.base.ts`. Keyed by package\n * directory basename.\n */\nconst DEFAULT_SKIP_PACKAGES = [\n 'core',\n 'types',\n 'config',\n 'scanner',\n 'vitest',\n 'smrt-playground',\n];\n\nexport type VerifyManifestStatus =\n | 'ok'\n | 'incomplete'\n | 'missing-manifest'\n | 'scan-error'\n | 'skipped';\n\nexport interface VerifyManifestCompletenessOptions {\n /** Absolute or relative path to the package directory to verify. */\n packageDir: string;\n /** Source include globs (default mirrors the build). */\n include?: string[];\n /** Source exclude globs (default mirrors the build). */\n exclude?: string[];\n /** Package directory basenames to skip (default: framework infrastructure). */\n skipPackages?: string[];\n /**\n * Release mode (issue #2853): when the package publishes no `./manifest`\n * export, scan its source anyway and report `missing-manifest` if it declares\n * `@smrt()` objects, instead of skipping. Without this, a package can leave\n * the guard by omitting the export, and consumers never discover its objects.\n */\n requireManifestExport?: boolean;\n}\n\nexport interface VerifyManifestCompletenessResult {\n status: VerifyManifestStatus;\n packageName?: string;\n manifestPath?: string;\n /** Qualified object keys present in source but missing from the manifest. */\n missing: string[];\n /** Number of objects the source is expected to contribute. */\n expectedCount: number;\n /** Number of objects present in the published manifest. */\n distCount: number;\n /** Human-readable explanation for `skipped` / `missing-manifest`. */\n reason?: string;\n}\n\ninterface MinimalPackageJson {\n name?: string;\n version?: string;\n exports?: Record<string, unknown>;\n}\n\n/**\n * Resolve the `./manifest` (or `./manifest.json`) export target to an absolute\n * path. Returns `null` when the package does not publish a manifest.\n */\nfunction resolveManifestPath(\n packageDir: string,\n pkgJson: MinimalPackageJson,\n): string | null {\n const exportsMap = pkgJson.exports ?? {};\n const entry = exportsMap['./manifest'] ?? exportsMap['./manifest.json'];\n\n let relativeTarget: string | undefined;\n if (typeof entry === 'string') {\n relativeTarget = entry;\n } else if (entry && typeof entry === 'object') {\n const conditional = entry as Record<string, unknown>;\n const candidate =\n conditional.default ?? conditional.import ?? conditional.types;\n if (typeof candidate === 'string') {\n relativeTarget = candidate;\n }\n }\n\n if (!relativeTarget) {\n return null;\n }\n\n return resolve(packageDir, relativeTarget);\n}\n\n/**\n * Verify that `dist/manifest.json` contains every `@smrt()` object declared in\n * the package source. See module docs for the rationale and guarantees.\n */\nexport async function verifyManifestCompleteness(\n options: VerifyManifestCompletenessOptions,\n): Promise<VerifyManifestCompletenessResult> {\n const packageDir = resolve(options.packageDir);\n const include = options.include ?? DEFAULT_INCLUDE;\n const exclude = options.exclude ?? DEFAULT_EXCLUDE;\n const skipPackages = options.skipPackages ?? DEFAULT_SKIP_PACKAGES;\n\n const packageJsonPath = resolve(packageDir, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return {\n status: 'skipped',\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: `no package.json at ${packageDir}`,\n };\n }\n\n const pkgJson: MinimalPackageJson = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8'),\n );\n const packageName = pkgJson.name;\n\n if (skipPackages.includes(basename(packageDir))) {\n return {\n status: 'skipped',\n packageName,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason:\n 'framework infrastructure package (does not use scanner manifest)',\n };\n }\n\n const manifestPath = resolveManifestPath(packageDir, pkgJson);\n if (!manifestPath && !options.requireManifestExport) {\n return {\n status: 'skipped',\n packageName,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: 'package does not publish a ./manifest export',\n };\n }\n\n // Derive the object set the source SHOULD produce, using the same scanner and\n // adapter the build uses (vite-plugin scanWithOxc).\n const scanner = new OxcScanner({ cwd: packageDir, include, exclude });\n const { results, resolved } = await scanner.scanAndResolve();\n\n // A source file with a syntax error parses to `errors:[...], body:[]`, so any\n // @smrt() class in it is dropped from BOTH the re-scanned `expected` set and\n // (having never built) the published `dist`. Because the completeness check is\n // `expected ⊆ dist`, the object vanishes symmetrically and the guard would\n // return `ok` — silently defeating the #1483 guarantee for the exact case\n // (broken source) that most needs catching. Surface scan errors as a distinct\n // non-`ok` status instead of computing `expected` from a partial scan.\n const scanErrors = results.errors.filter((e) => e.severity === 'error');\n if (scanErrors.length > 0) {\n const detail = scanErrors\n .map((e) => {\n const where = e.line ? `${e.filePath}:${e.line}` : e.filePath;\n return `${where} — ${e.message}`;\n })\n .join('; ');\n return {\n status: 'scan-error',\n packageName,\n manifestPath: manifestPath ?? undefined,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: `source scan reported ${scanErrors.length} parse error(s): ${detail}`,\n };\n }\n\n const adapter = new ManifestAdapter();\n const expected = adapter.toManifest(resolved, {\n packageName,\n packageVersion: pkgJson.version,\n typeAliases: results.typeAliases,\n });\n const expectedKeys = Object.keys(expected.objects);\n\n // Nothing to verify if the package declares no SMRT objects (e.g. a package\n // that publishes ./manifest but only ships base classes).\n if (expectedKeys.length === 0) {\n return {\n status: 'skipped',\n packageName,\n manifestPath: manifestPath ?? undefined,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: manifestPath\n ? 'no @smrt() objects found in source'\n : 'package does not publish a ./manifest export and declares no @smrt() objects',\n };\n }\n\n if (!manifestPath) {\n return {\n status: 'missing-manifest',\n packageName,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `source declares ${expectedKeys.length} @smrt() object(s) but package.json publishes no ./manifest export`,\n };\n }\n\n if (!existsSync(manifestPath)) {\n return {\n status: 'missing-manifest',\n packageName,\n manifestPath,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `published manifest not found at ${manifestPath}`,\n };\n }\n\n let distObjects: Record<string, unknown> = {};\n try {\n const distManifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n distObjects =\n distManifest && typeof distManifest.objects === 'object'\n ? distManifest.objects\n : {};\n } catch (error) {\n return {\n status: 'missing-manifest',\n packageName,\n manifestPath,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `published manifest is not valid JSON: ${(error as Error).message}`,\n };\n }\n\n const distKeys = new Set(Object.keys(distObjects));\n const missing = expectedKeys.filter((key) => !distKeys.has(key));\n\n return {\n status: missing.length > 0 ? 'incomplete' : 'ok',\n packageName,\n manifestPath,\n missing,\n expectedCount: expectedKeys.length,\n distCount: distKeys.size,\n };\n}\n"],"mappings":";;;;;AAsCA,IAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAQD,IAAM,6BAAa,IAAI,IAAI;CACzB;CACA;CACA;CACA;CACA;AACF,CAAC;AAkBD,IAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,IAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;AACF,CAAC;AAkCM,SAAS,qBAAqB,MAAwB;CAC3D,OAAO,KACJ,QAAQ,sBAAsB,OAAO,CAAA,CACrC,QAAQ,yBAAyB,OAAO,CAAA,CACxC,MAAM,SAAS,CAAA,CACf,OAAO,OAAO,CAAA,CACd,KAAK,SAAS,KAAK,YAAY,CAAC;AACrC;AAUO,SAAS,yBACd,MACkC;CAClC,MAAM,QAAQ,qBAAqB,IAAI;CACvC,IAAI,MAAM,MAAM,SAAS,WAAW,IAAI,IAAI,CAAC,GAAG,OAAO;CACvD,KAAA,IAAS,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;E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AQ;EACR;EACA,cAAc,gBAAgB,KAAA;EAC9B,SAAS,CAAC;EACV,eAAe;EACf,WAAW;EACX,QAAQ,eACJ,uCACA;CACN;CAGF,IAAI,CAAC,cACH,OAAO;EACL,QAAQ;EACR;EACA,SAAS;EACT,eAAe,aAAa;EAC5B,WAAW;EACX,QAAQ,mBAAmB,aAAa,OAAM;CAChD;CAGF,IAAI,CAAC,WAAW,YAAY,GAC1B,OAAO;EACL,QAAQ;EACR;EACA;EACA,SAAS;EACT,eAAe,aAAa;EAC5B,WAAW;EACX,QAAQ,mCAAmC;CAC7C;CAGF,IAAI,cAAuC,CAAC;CAC5C,IAAI;EACF,MAAM,eAAe,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;EACnE,cACE,gBAAgB,OAAO,aAAa,YAAY,WAC5C,aAAa,UACb,CAAC;CACT,SAAS,OAAO;EACd,OAAO;GACL,QAAQ;GACR;GACA;GACA,SAAS;GACT,eAAe,aAAa;GAC5B,WAAW;GACX,QAAQ,yCAA0C,MAAgB;EACpE;CACF;CAEA,MAAM,WAAW,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;CACjD,MAAM,UAAU,aAAa,QAAQ,QAAQ,CAAC,SAAS,IAAI,GAAG,CAAC;CAE/D,OAAO;EACL,QAAQ,QAAQ,SAAS,IAAI,eAAe;EAC5C;EACA;EACA;EACA,eAAe,aAAa;EAC5B,WAAW,SAAS;CACtB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/numeric-precision-lint.ts","../src/setter-hidden-read-lint.ts","../src/verify-completeness.ts"],"sourcesContent":["/**\n * Numeric-precision lint for money and rate fields (#2361).\n *\n * SMRT infers a `number` field's column type from the *initializer literal*:\n * `= 0` compiles to INTEGER and `= 0.0` compiles to DECIMAL\n * (`manifest-adapter.ts`, inference steps 3 and 3.5). The rule is silent, and\n * SQLite's type affinity happily stores a REAL in an INTEGER column — so a\n * mistyped field passes every SQLite suite and then behaves differently in\n * production on PostgreSQL.\n *\n * Two vocabularies, opposite answers:\n *\n * - **Money is exact**, so it is stored as *integer minor units* — cents,\n * satoshis. `$19.99` is `1999`. A money field declared `= 0.0` becomes a\n * float column, which reintroduces binary-fraction error into amounts that\n * must balance, and invites callers to write major units.\n * - **Rates are inherently fractional** — `taxRate`, `confidence`, a percentage\n * — so they must be DECIMAL. INTEGER would truncate every meaningful value\n * (a confidence in `[0, 1]` collapses to 0 or 1) and PostgreSQL rejects the\n * write outright with `22P02`.\n *\n * Matching is head-noun based rather than substring based, which is what keeps\n * it usable as a repo-wide gate: `amountCents` and `totalTokensUsed` name a\n * unit or a count as their head and are left alone, while `totalAmount`,\n * `amountPaid` and a bare `total` are money. JSDoc prose is deliberately NOT\n * matched — the head-noun signal is precise, and scanning prose for the same\n * vocabulary would make the gate fire on documentation wording.\n */\n\nimport type { RawClassDefinition, RawFieldDefinition } from './types.js';\n\n/**\n * Head nouns that denote an exact monetary quantity, stored as integer minor\n * units.\n *\n * `tax` is money (a tax *amount*); `taxRate` is not, and the rate vocabulary\n * below wins whenever both appear, so the two never collide.\n */\nconst MONEY_HEAD_WORDS = new Set([\n 'amount',\n 'balance',\n 'cost',\n 'discount',\n 'due',\n 'fee',\n 'paid',\n 'price',\n 'subtotal',\n 'tax',\n 'total',\n]);\n\n/**\n * Head nouns that denote an inherently fractional quantity, stored as DECIMAL.\n *\n * A name carrying any of these is a rate even when it also carries a money word\n * (`taxRate`, `feePercentage`), because the rate is what the value *is*.\n */\nconst RATE_WORDS = new Set([\n 'confidence',\n 'credibility',\n 'probability',\n 'rate',\n 'ratio',\n]);\n\n/**\n * Deliberately NOT rate words: `weight`, `score`, `factor`, `percent`.\n *\n * Each is commonly a whole number — an ad-rotation `weight` of 1, a score out\n * of 100, a percent as 0–100 — so treating them as necessarily fractional\n * produces false positives on correct code. `AdVariation.weight = 1` is the\n * worked example. They are left unclassified rather than guessed at.\n */\n\n/**\n * Words that may trail a head noun without displacing it.\n *\n * `amountPaid` is still an amount; `amountCents` is not — its head noun already\n * names the exact unit — which is why this is an allowlist rather than a\n * blocklist of unit words.\n */\nconst TRAILING_QUALIFIERS = new Set([\n 'applied',\n 'billed',\n 'charged',\n 'collected',\n 'earned',\n 'gross',\n 'net',\n 'outstanding',\n 'owed',\n 'refunded',\n 'remaining',\n]);\n\n/** Base classes whose fields become table columns even without `@smrt()`. */\nconst PERSISTED_BASE_CLASSES = new Set([\n 'SmrtObject',\n 'SmrtJunction',\n 'SmrtJunctionBase',\n 'SmrtHierarchical',\n 'SmrtPolymorphicAssociation',\n]);\n\n/** Which rule a field falls under, if any. */\nexport type NumericPrecisionKind = 'money' | 'rate';\n\n/** One field whose declared precision contradicts its name. */\nexport interface NumericPrecisionFinding {\n /** `money` wants INTEGER minor units; `rate` wants DECIMAL. */\n kind: NumericPrecisionKind;\n /** Declaring class, e.g. `Invoice`. */\n className: string;\n /** Field name, e.g. `totalAmount`. */\n fieldName: string;\n /** File the class was scanned from. */\n filePath: string;\n /**\n * 1-based line of the field declaration, or `0` when it could not be\n * resolved. The OXC AST nodes this scanner consumes do not carry `loc`, so\n * the line is recovered from the source text when a caller passes it to\n * {@link lintNumericPrecision}.\n */\n line: number;\n /** The initializer that triggered the finding. */\n initializer: string;\n /** Human-readable explanation naming the rule. */\n message: string;\n /** The accepted fixes. */\n remedy: string;\n}\n\n/**\n * Split an identifier into lowercase words on camelCase, PascalCase, digits,\n * and underscores. `totalAmountCents` → `['total', 'amount', 'cents']`.\n */\nexport function splitIdentifierWords(name: string): string[] {\n return name\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .split(/[\\s_$]+/)\n .filter(Boolean)\n .map((word) => word.toLowerCase());\n}\n\n/**\n * Classify an identifier as money, a rate, or neither.\n *\n * The head noun is the last word, or the last word before a trailing qualifier\n * such as `Paid`. A rate word anywhere in the name wins outright: `taxRate` is\n * a rate even though `tax` is money, and that precedence is what stops the two\n * vocabularies from fighting over the same field.\n */\nexport function classifyNumericFieldName(\n name: string,\n): NumericPrecisionKind | undefined {\n const words = splitIdentifierWords(name);\n if (words.some((word) => RATE_WORDS.has(word))) return 'rate';\n for (let index = words.length - 1; index >= 0; index -= 1) {\n const word = words[index];\n if (MONEY_HEAD_WORDS.has(word)) return 'money';\n if (!TRAILING_QUALIFIERS.has(word)) return undefined;\n }\n return undefined;\n}\n\n/**\n * Text a file must contain before it can declare a field this lint reports.\n *\n * `@smrt` is matched without requiring parentheses because the parser accepts\n * the bare identifier form too, and the decorator name is never resolved\n * through an import alias — so the literal text is always present.\n */\nconst PERSISTED_CLASS_MARKER = /@smrt\\b|extends\\s+Smrt/;\n\n/** Any numeric initializer. Deliberately does not require a terminator. */\nconst NUMERIC_INITIALIZER = /=\\s*-?\\d/;\n\nconst ALL_WORDS = [...MONEY_HEAD_WORDS, ...RATE_WORDS];\n\n/**\n * A relevant word starting an identifier — any case, since `Price` and `price`\n * are both legal there. Case-insensitivity also matches prose in comments,\n * which costs a parse and nothing else.\n */\nconst WORD_AT_START = new RegExp(\n `(?<![A-Za-z])(?:${ALL_WORDS.join('|')})`,\n 'i',\n);\n\n/**\n * A relevant word after a camel hump (`unitPrice`, `USDPrice`), where it is\n * necessarily capitalized and necessarily preceded by an identifier character.\n * This arm cannot be case-insensitive: `generate` would then match on `rate`.\n *\n * Together the two arms cover exactly the boundaries {@link splitIdentifierWords}\n * cuts on, which is what makes the filter conservative rather than plausible.\n */\nconst WORD_AFTER_HUMP = new RegExp(\n `(?<=[A-Za-z0-9])(?:${ALL_WORDS.map(\n (word) => word[0].toUpperCase() + word.slice(1),\n ).join('|')})`,\n);\n\n/**\n * Cheap pre-filter so callers can skip parsing files that cannot produce a\n * finding.\n *\n * Conservative by construction: every condition here is textually implied by a\n * finding. A reported field lives in a class carrying `@smrt` or\n * `extends Smrt…`, is initialized to a number, and has a money or rate word at\n * one of the boundaries the head-noun splitter cuts on. It may still return\n * `true` for a file the AST pass then clears — that is the intended direction.\n *\n * @param source - Full file contents.\n * @returns `false` only when the file provably cannot produce a finding.\n */\nexport function sourceMayContainNumericPrecisionIssue(source: string): boolean {\n return (\n PERSISTED_CLASS_MARKER.test(source) &&\n NUMERIC_INITIALIZER.test(source) &&\n (WORD_AT_START.test(source) || WORD_AFTER_HUMP.test(source))\n );\n}\n\n/**\n * Blank out string-literal contents so option *keys* can be matched without\n * prose inside a value masquerading as one.\n *\n * `@field({ description: 'Discount type: percent or flat' })` otherwise reads\n * as an explicit `type:` and silently suppresses a real finding — and\n * `description` is a shipped option (#2046), so this is reachable, not\n * hypothetical. Quote characters are preserved to keep offsets stable.\n */\nfunction blankStringLiterals(text: string): string {\n return text.replace(/(['\"`])(?:\\\\.|(?!\\1)[\\s\\S])*\\1/g, (match) =>\n match[0].repeat(match.length),\n );\n}\n\n/** Does any decorator on this field state the column type explicitly? */\nfunction hasExplicitTypeDecorator(field: RawFieldDefinition): boolean {\n for (const decorator of field.decorators) {\n // Relationship decorators own the column type outright.\n if (\n decorator.name === 'foreignKey' ||\n decorator.name === 'crossPackageRef' ||\n decorator.name === 'oneToMany' ||\n decorator.name === 'manyToMany' ||\n decorator.name === 'tenantId'\n ) {\n return true;\n }\n if (decorator.name !== 'field') continue;\n const args = blankStringLiterals(decorator.arguments.join(' '));\n // An explicit declaration of intent is exactly what this lint asks for,\n // whichever type was chosen.\n if (/\\btype\\s*:/.test(args)) return true;\n // A transient field is never persisted, so no column type is inferred.\n if (/\\btransient\\s*:\\s*true\\b/.test(args)) return true;\n }\n return false;\n}\n\n/** Fields stored in the STI `_meta_data` JSON blob get no typed column. */\nfunction isMetaField(field: RawFieldDefinition): boolean {\n if (field.decorators.some((decorator) => decorator.name === 'meta')) {\n return true;\n }\n return /^Meta\\s*</.test(field.typeAnnotation ?? '');\n}\n\n/** Is this a plain `number` column whose type came from the literal? */\nfunction usesLiteralInference(field: RawFieldDefinition): boolean {\n if (field.numericValue === null) return false;\n const annotation = (field.typeAnnotation ?? '').replace(/\\s/g, '');\n if (annotation === '') return true; // `price = 0` — inference step 3.5\n return annotation === 'number' || annotation === 'number|null';\n}\n\n/** Are this class's fields materialized as table columns? */\nfunction isPersistedClass(cls: RawClassDefinition): boolean {\n if (cls.hasSmartDecorator) return true;\n return PERSISTED_BASE_CLASSES.has(cls.extendsClause ?? '');\n}\n\n/**\n * Recover a field's 1-based declaration line from source text.\n *\n * The scanner's raw field records carry `line: 0` because the OXC AST nodes\n * have no `loc`, and a finding that cannot point at a line is much harder to\n * act on — so callers that already hold the file contents get a real line.\n */\nfunction resolveDeclarationLine(\n sourceText: string | undefined,\n fieldName: string,\n fallback: number,\n): number {\n if (fallback > 0 || !sourceText) return fallback;\n // `$` is a legal identifier character and a regex anchor, so the name has to\n // be escaped rather than interpolated raw.\n const escapedName = fieldName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const declaration = new RegExp(\n `^\\\\s*(?:(?:public|private|protected|readonly|declare|override)\\\\s+)*${escapedName}\\\\s*[?!]?\\\\s*(?::[^=;]+)?=\\\\s*-?\\\\d`,\n );\n const lines = sourceText.split('\\n');\n for (let index = 0; index < lines.length; index += 1) {\n if (declaration.test(lines[index])) return index + 1;\n }\n return 0;\n}\n\nfunction describeMoneyFinding(\n cls: RawClassDefinition,\n field: RawFieldDefinition,\n): Pick<NumericPrecisionFinding, 'message' | 'remedy'> {\n const whole = Math.trunc(field.numericValue ?? 0);\n return {\n message:\n `${cls.className}.${field.name} is a money field with a decimal ` +\n `initializer (= ${field.initializer ?? field.numericValue}), so SMRT ` +\n 'compiles it to a floating-point column. Money is exact and is stored ' +\n 'as integer minor units (cents, satoshis) — $19.99 is 1999 — so a float ' +\n 'column reintroduces binary-fraction error into amounts that must ' +\n 'balance.',\n remedy:\n `Write an integer initializer (\\`${field.name} = ${whole}\\`) and treat ` +\n 'the value as minor units, or state the intent explicitly with ' +\n \"`@field({ type: 'decimal' })` when the value really is fractional.\",\n };\n}\n\nfunction describeRateFinding(\n cls: RawClassDefinition,\n field: RawFieldDefinition,\n): Pick<NumericPrecisionFinding, 'message' | 'remedy'> {\n return {\n message:\n `${cls.className}.${field.name} is a rate with an integer initializer ` +\n `(= ${field.numericValue}), so SMRT compiles it to an INTEGER column. A ` +\n 'rate is inherently fractional, so every meaningful value truncates; ' +\n 'PostgreSQL rejects the save with 22P02 while SQLite silently accepts it.',\n remedy:\n `Write a decimal initializer (\\`${field.name} = ${field.numericValue}.0\\`) ` +\n 'to get a DECIMAL column, or state the intent explicitly with ' +\n \"`@field({ type: 'integer' })` when the value really is a whole count.\",\n };\n}\n\n/**\n * Report every persisted `number` field whose declared precision contradicts\n * its name — money declared decimal, or a rate declared integer.\n *\n * @param classes - Raw class definitions from `parseFile` / `OxcScanner`.\n * @param sourceText - Optional contents of the scanned file, used only to\n * recover declaration line numbers the AST does not carry.\n * @returns One finding per offending field, in declaration order.\n */\nexport function lintNumericPrecision(\n classes: RawClassDefinition[],\n sourceText?: string,\n): NumericPrecisionFinding[] {\n const findings: NumericPrecisionFinding[] = [];\n for (const cls of classes) {\n if (!isPersistedClass(cls)) continue;\n for (const field of cls.fields) {\n if (field.isStatic) continue;\n if (!usesLiteralInference(field)) continue;\n const kind = classifyNumericFieldName(field.name);\n if (!kind) continue;\n // Money wants an integer literal; a rate wants a decimal one. A field\n // already on the right side of its rule is fine.\n if (kind === 'money' && !field.hasDecimalPoint) continue;\n if (kind === 'rate' && field.hasDecimalPoint) continue;\n if (isMetaField(field)) continue;\n if (hasExplicitTypeDecorator(field)) continue;\n findings.push({\n kind,\n className: cls.className,\n fieldName: field.name,\n filePath: cls.filePath,\n line: resolveDeclarationLine(sourceText, field.name, field.line),\n initializer: field.initializer ?? String(field.numericValue),\n ...(kind === 'money'\n ? describeMoneyFinding(cls, field)\n : describeRateFinding(cls, field)),\n });\n }\n }\n return findings;\n}\n","/**\n * Setter-reads-hidden-field lint (#5603).\n *\n * The write rule (#5195, `FieldNotWritableError`) refuses a changed protected\n * field, and a protected field the caller cannot read is refused whatever its\n * value, so a caller never learns the stored value from an accepted-versus-\n * refused answer. A setter is application code, though: if it READS such a\n * field before deciding what to assign,\n *\n * set label(value: string) {\n * if (this.secretHash !== value) this.secretHash = value;\n * }\n *\n * a caller with update permission confirms the hidden value by the 200 versus\n * 400 the branch produces. The engine does not proxy hidden-field reads inside\n * accessors (documented known limit), so the rule is on the model author:\n * **a setter must not read a field some callers cannot read.** This lint finds\n * the violation in source.\n *\n * \"Hidden\" here is what the scanner can see on a field declaration:\n * `@field({ sensitive: true })` or `@field({ readPermission: '...' })`, the two\n * options that withhold a field from `toPublicJSON()`.\n *\n * What counts as a read: `this.f`, `this['f']`, `this?.f`, a compound or\n * logical assignment (`this.f += 1`, `this.f ??= v`), `this.f++`, and\n * destructuring `this` (`const { f } = this`). A plain assignment to the field\n * (`this.f = v`, including as a destructuring target) is not a read; the\n * assignment trap already refuses it.\n *\n * Deliberately syntactic: aliases (`const self = this`), dynamic keys\n * (`this[name]`), calls into helpers that read the field, config options the\n * scanner cannot resolve to a literal, and fields inherited from a parent\n * declared in another file are not followed. A missed finding is a documented\n * limit; a false finding would make the gate noisy.\n */\n\nimport { parseSync } from 'oxc-parser';\nimport { getLineColumn } from './source-location.js';\n\n/** One setter that reads a field some callers cannot read. */\nexport interface SetterHiddenReadFinding {\n /** Declaring class, e.g. `Account`. */\n className: string;\n /** Setter name. */\n setterName: string;\n /** The hidden field the setter reads. */\n fieldName: string;\n /** Why the field is hidden: `sensitive` or `readPermission`. */\n hiddenBy: 'sensitive' | 'readPermission';\n /** File passed to the lint. */\n filePath: string;\n /** 1-based line of the read, or `0` when it could not be resolved. */\n line: number;\n /** Human-readable explanation naming the rule. */\n message: string;\n /** The accepted fixes. */\n remedy: string;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: ESTree nodes are walked structurally\ntype Node = any;\n\nconst SKIP_KEYS = new Set(['loc', 'start', 'end', 'range', 'parent']);\nconst TS_WRAPPERS = new Set([\n 'TSNonNullExpression',\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSTypeAssertion',\n 'ParenthesizedExpression',\n]);\n\n/** Cheap pre-filter: a file without all three words cannot produce a finding. */\nexport function sourceMayContainSetterHiddenRead(source: string): boolean {\n return (\n /\\bset\\s*[\\w$#['\"`]/.test(source) &&\n /\\bthis\\b/.test(source) &&\n /\\b(?:sensitive|readPermission)\\b/.test(source)\n );\n}\n\nfunction unwrap(node: Node): Node {\n let current = node;\n while (current && TS_WRAPPERS.has(current.type)) current = current.expression;\n return current;\n}\n\nfunction keyName(key: Node, computed: boolean): string | undefined {\n if (!key) return undefined;\n if (!computed && key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n return undefined;\n}\n\n/** `this.f` / `this['f']` -> `f`; anything else -> undefined. */\nfunction thisMemberName(node: Node): string | undefined {\n const target = unwrap(node);\n if (target?.type !== 'MemberExpression') return undefined;\n if (unwrap(target.object)?.type !== 'ThisExpression') return undefined;\n return keyName(target.property, target.computed);\n}\n\nfunction objectProperty(object: Node, name: string): Node | undefined {\n for (const prop of object.properties ?? []) {\n if (prop.type !== 'Property') continue;\n if (keyName(prop.key, prop.computed) === name) return prop;\n }\n return undefined;\n}\n\n/** Why a field declaration is hidden from some callers, if it is. */\nfunction hiddenBy(member: Node): 'sensitive' | 'readPermission' | undefined {\n for (const decorator of member.decorators ?? []) {\n const call = decorator.expression;\n if (call?.type !== 'CallExpression') continue;\n if (call.callee?.type !== 'Identifier' || call.callee.name !== 'field') {\n continue;\n }\n const config = call.arguments?.[0];\n if (config?.type !== 'ObjectExpression') continue;\n const sensitive = objectProperty(config, 'sensitive');\n if (\n sensitive?.value?.type === 'Literal' &&\n sensitive.value.value === true\n ) {\n return 'sensitive';\n }\n const permission = objectProperty(config, 'readPermission');\n if (\n permission?.value?.type === 'Literal' &&\n typeof permission.value.value === 'string' &&\n permission.value.value !== ''\n ) {\n return 'readPermission';\n }\n }\n return undefined;\n}\n\ninterface Read {\n field: string;\n start: number;\n}\n\n/**\n * Collect reads of `this.<hidden>` in a setter body. Nested non-arrow\n * functions and classes rebind `this`, so they are not entered.\n */\nfunction collectReads(body: Node, hidden: ReadonlySet<string>): Read[] {\n const reads: Read[] = [];\n\n const visitTarget = (node: Node): void => {\n const target = unwrap(node);\n if (!target) return;\n switch (target.type) {\n case 'MemberExpression': {\n // `this.f = v` is a write; `this.f.x = v` and `a[this.f] = v` read.\n if (thisMemberName(target) === undefined) {\n visit(target.object);\n if (target.computed) visit(target.property);\n }\n return;\n }\n case 'ArrayPattern':\n for (const element of target.elements ?? []) visitTarget(element);\n return;\n case 'ObjectPattern':\n for (const prop of target.properties ?? []) {\n if (prop.type === 'RestElement') visitTarget(prop.argument);\n else {\n if (prop.computed) visit(prop.key);\n visitTarget(prop.value);\n }\n }\n return;\n case 'RestElement':\n visitTarget(target.argument);\n return;\n case 'AssignmentPattern':\n visitTarget(target.left);\n visit(target.right);\n return;\n default:\n return;\n }\n };\n\n /** Keys read out of `this` by an object pattern (`const { f } = this`). */\n const visitThisPattern = (pattern: Node): void => {\n for (const prop of pattern?.properties ?? []) {\n if (prop.type !== 'Property') continue;\n const name = keyName(prop.key, prop.computed);\n if (name !== undefined && hidden.has(name)) {\n reads.push({ field: name, start: prop.start });\n }\n }\n };\n\n const visit = (node: Node): void => {\n if (!node || typeof node !== 'object') return;\n if (Array.isArray(node)) {\n for (const item of node) visit(item);\n return;\n }\n if (typeof node.type !== 'string') return;\n switch (node.type) {\n case 'FunctionExpression':\n case 'FunctionDeclaration':\n case 'ClassExpression':\n case 'ClassDeclaration':\n return;\n case 'AssignmentExpression':\n if (node.operator === '=') {\n visitTarget(node.left);\n if (\n unwrap(node.right)?.type === 'ThisExpression' &&\n unwrap(node.left)?.type === 'ObjectPattern'\n ) {\n visitThisPattern(unwrap(node.left));\n }\n visit(node.right);\n return;\n }\n break;\n case 'ForOfStatement':\n case 'ForInStatement':\n // `for (this.f of xs)` assigns the field; the iterable and body read.\n if (node.left?.type === 'VariableDeclaration') visit(node.left);\n else visitTarget(node.left);\n visit(node.right);\n visit(node.body);\n return;\n case 'VariableDeclarator':\n if (\n unwrap(node.init)?.type === 'ThisExpression' &&\n node.id?.type === 'ObjectPattern'\n ) {\n visitThisPattern(node.id);\n }\n break;\n case 'MemberExpression': {\n const name = thisMemberName(node);\n if (name !== undefined && hidden.has(name)) {\n reads.push({ field: name, start: node.start });\n return;\n }\n break;\n }\n }\n for (const [key, value] of Object.entries(node)) {\n if (!SKIP_KEYS.has(key)) visit(value);\n }\n };\n\n visit(body);\n return reads;\n}\n\n/**\n * Report every setter on a class whose body reads one of that class's hidden\n * fields (`@field({ sensitive: true })` or `@field({ readPermission })`).\n *\n * @param sourceText - Contents of one TypeScript file.\n * @param filePath - Path used in findings and to pick the parser language.\n * @returns One finding per (setter, field) pair, in source order.\n */\nexport function lintSetterHiddenReads(\n sourceText: string,\n filePath = 'model.ts',\n): SetterHiddenReadFinding[] {\n const parsed = parseSync(filePath, sourceText, {\n lang: filePath.endsWith('.tsx') ? 'tsx' : 'ts',\n preserveParens: false,\n });\n const findings: SetterHiddenReadFinding[] = [];\n\n const visitClass = (cls: Node): void => {\n const hidden = new Map<string, 'sensitive' | 'readPermission'>();\n for (const member of cls.body?.body ?? []) {\n if (member.type !== 'PropertyDefinition' || member.static) continue;\n const name = keyName(member.key, member.computed);\n const reason = name === undefined ? undefined : hiddenBy(member);\n if (name !== undefined && reason) hidden.set(name, reason);\n }\n if (hidden.size === 0) return;\n for (const member of cls.body.body) {\n if (\n member.type !== 'MethodDefinition' ||\n member.kind !== 'set' ||\n member.static\n ) {\n continue;\n }\n const setterName = keyName(member.key, member.computed) ?? '<computed>';\n const seen = new Set<string>();\n for (const read of collectReads(\n member.value?.body,\n new Set(hidden.keys()),\n )) {\n if (seen.has(read.field)) continue;\n seen.add(read.field);\n const reason = hidden.get(read.field) as 'sensitive' | 'readPermission';\n const className = cls.id?.name ?? '<anonymous>';\n findings.push({\n className,\n setterName,\n fieldName: read.field,\n hiddenBy: reason,\n filePath,\n line: getLineColumn(sourceText, read.start)?.line ?? 0,\n message:\n `${className}.${setterName} (setter) reads ${read.field}, a ` +\n `${reason === 'sensitive' ? 'sensitive' : 'readPermission'} ` +\n 'field some callers cannot read. A caller with update permission ' +\n 'can confirm the hidden value by whether the write is accepted or ' +\n 'refused; the engine does not proxy hidden-field reads in accessors.',\n remedy:\n `Do not read ${read.field} in the setter: assign it ` +\n 'unconditionally, or move the branch into a method that is not ' +\n 'reachable through a caller-writable key.',\n });\n }\n }\n };\n\n const walk = (node: Node): void => {\n if (!node || typeof node !== 'object') return;\n if (Array.isArray(node)) {\n for (const item of node) walk(item);\n return;\n }\n if (typeof node.type !== 'string') return;\n if (node.type === 'ClassDeclaration' || node.type === 'ClassExpression') {\n visitClass(node);\n }\n for (const [key, value] of Object.entries(node)) {\n if (!SKIP_KEYS.has(key)) walk(value);\n }\n };\n walk(parsed.program);\n return findings;\n}\n","/**\n * Manifest completeness verification.\n *\n * Re-scans a package's `src/` with the same OXC scanner the build uses and\n * asserts that every `@smrt()`-decorated object (and its collection) is present\n * in the package's published `dist/manifest.json`. This is a publish-time guard:\n * downstream schema migration is manifest-driven, so a stale manifest that omits\n * an object means consumers can never create its table via `smrt db:migrate`.\n *\n * Root cause it guards against (issue #1483): `@happyvertical/smrt-jobs@0.27.41`\n * shipped a `dist/manifest.json` generated before `SmrtWorker` existed. The\n * source, exports, and `__smrt-register__` path were all correct, but the\n * published manifest had only 4 of 6 objects, so `_smrt_workers` was never\n * created and `TaskRunner.start()` threw on every consumer that upgraded.\n *\n * The check compares object-key SETS only. The downstream manifest-enrichment\n * passes (schema/validation/agent generation) mutate object entries but never\n * add or remove object keys, so the scanner + adapter object set is the source\n * of truth for \"which objects the published manifest must contain\". The\n * comparison is `expected ⊆ dist`: enrichment passes that add keys to `dist`\n * (e.g. STI children) never trigger a false failure.\n *\n * Parse errors are handled before the set comparison: a syntactically broken\n * source file drops its objects from `expected` AND `dist` symmetrically, which\n * a naive `expected ⊆ dist` would wave through as `ok`. The scan's\n * `severity:'error'` entries therefore short-circuit to a distinct `scan-error`\n * status so a broken source can never masquerade as a complete manifest.\n *\n * @see https://github.com/happyvertical/smrt/issues/1483\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, resolve } from 'node:path';\nimport { ManifestAdapter } from './manifest-adapter.js';\nimport { OxcScanner } from './scanner.js';\n\n/**\n * Source globs for the completeness scan. The build (`vite.config.base.ts`)\n * passes `include: ['src/**\\/*.ts']` and excludes `*.test.ts` / `*.spec.ts` (the\n * plugin also drops `*.svelte`); we reproduce that so the expected object set\n * matches what the build would publish. We additionally exclude\n * `**\\/__tests__\\/**` so any `@smrt()` fixtures in non-test helper modules under\n * `src/__tests__/` (e.g. `src/__tests__/helpers/*.ts`) are never required in the\n * published manifest. These extra exclusions can only shrink `expected` relative\n * to the build, so they can never cause a false failure — the check is\n * `expected ⊆ dist`.\n */\nconst DEFAULT_INCLUDE = ['src/**/*.ts'];\nconst DEFAULT_EXCLUDE = [\n '**/*.test.ts',\n '**/*.spec.ts',\n '**/__tests__/**',\n '**/*.svelte',\n '**/node_modules/**',\n '**/dist/**',\n '**/*.d.ts',\n];\n\n/**\n * Framework-infrastructure packages whose published manifest is NOT produced by\n * the OXC scanner path (e.g. `@happyvertical/smrt-core` ships a curated static\n * manifest). Mirrors `skipSmrtPlugin` in `vite.config.base.ts`. Keyed by package\n * directory basename.\n */\nconst DEFAULT_SKIP_PACKAGES = [\n 'core',\n 'types',\n 'config',\n 'scanner',\n 'vitest',\n 'smrt-playground',\n];\n\nexport type VerifyManifestStatus =\n | 'ok'\n | 'incomplete'\n | 'missing-manifest'\n | 'scan-error'\n | 'skipped';\n\nexport interface VerifyManifestCompletenessOptions {\n /** Absolute or relative path to the package directory to verify. */\n packageDir: string;\n /** Source include globs (default mirrors the build). */\n include?: string[];\n /** Source exclude globs (default mirrors the build). */\n exclude?: string[];\n /** Package directory basenames to skip (default: framework infrastructure). */\n skipPackages?: string[];\n /**\n * Release mode (issue #2853): when the package publishes no `./manifest`\n * export, scan its source anyway and report `missing-manifest` if it declares\n * `@smrt()` objects, instead of skipping. Without this, a package can leave\n * the guard by omitting the export, and consumers never discover its objects.\n */\n requireManifestExport?: boolean;\n}\n\nexport interface VerifyManifestCompletenessResult {\n status: VerifyManifestStatus;\n packageName?: string;\n manifestPath?: string;\n /** Qualified object keys present in source but missing from the manifest. */\n missing: string[];\n /** Number of objects the source is expected to contribute. */\n expectedCount: number;\n /** Number of objects present in the published manifest. */\n distCount: number;\n /** Human-readable explanation for `skipped` / `missing-manifest`. */\n reason?: string;\n}\n\ninterface MinimalPackageJson {\n name?: string;\n version?: string;\n exports?: Record<string, unknown>;\n}\n\n/**\n * Resolve the `./manifest` (or `./manifest.json`) export target to an absolute\n * path. Returns `null` when the package does not publish a manifest.\n */\nfunction resolveManifestPath(\n packageDir: string,\n pkgJson: MinimalPackageJson,\n): string | null {\n const exportsMap = pkgJson.exports ?? {};\n const entry = exportsMap['./manifest'] ?? exportsMap['./manifest.json'];\n\n let relativeTarget: string | undefined;\n if (typeof entry === 'string') {\n relativeTarget = entry;\n } else if (entry && typeof entry === 'object') {\n const conditional = entry as Record<string, unknown>;\n const candidate =\n conditional.default ?? conditional.import ?? conditional.types;\n if (typeof candidate === 'string') {\n relativeTarget = candidate;\n }\n }\n\n if (!relativeTarget) {\n return null;\n }\n\n return resolve(packageDir, relativeTarget);\n}\n\n/**\n * Verify that `dist/manifest.json` contains every `@smrt()` object declared in\n * the package source. See module docs for the rationale and guarantees.\n */\nexport async function verifyManifestCompleteness(\n options: VerifyManifestCompletenessOptions,\n): Promise<VerifyManifestCompletenessResult> {\n const packageDir = resolve(options.packageDir);\n const include = options.include ?? DEFAULT_INCLUDE;\n const exclude = options.exclude ?? DEFAULT_EXCLUDE;\n const skipPackages = options.skipPackages ?? DEFAULT_SKIP_PACKAGES;\n\n const packageJsonPath = resolve(packageDir, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return {\n status: 'skipped',\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: `no package.json at ${packageDir}`,\n };\n }\n\n const pkgJson: MinimalPackageJson = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8'),\n );\n const packageName = pkgJson.name;\n\n if (skipPackages.includes(basename(packageDir))) {\n return {\n status: 'skipped',\n packageName,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason:\n 'framework infrastructure package (does not use scanner manifest)',\n };\n }\n\n const manifestPath = resolveManifestPath(packageDir, pkgJson);\n if (!manifestPath && !options.requireManifestExport) {\n return {\n status: 'skipped',\n packageName,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: 'package does not publish a ./manifest export',\n };\n }\n\n // Derive the object set the source SHOULD produce, using the same scanner and\n // adapter the build uses (vite-plugin scanWithOxc).\n const scanner = new OxcScanner({ cwd: packageDir, include, exclude });\n const { results, resolved } = await scanner.scanAndResolve();\n\n // A source file with a syntax error parses to `errors:[...], body:[]`, so any\n // @smrt() class in it is dropped from BOTH the re-scanned `expected` set and\n // (having never built) the published `dist`. Because the completeness check is\n // `expected ⊆ dist`, the object vanishes symmetrically and the guard would\n // return `ok` — silently defeating the #1483 guarantee for the exact case\n // (broken source) that most needs catching. Surface scan errors as a distinct\n // non-`ok` status instead of computing `expected` from a partial scan.\n const scanErrors = results.errors.filter((e) => e.severity === 'error');\n if (scanErrors.length > 0) {\n const detail = scanErrors\n .map((e) => {\n const where = e.line ? `${e.filePath}:${e.line}` : e.filePath;\n return `${where} — ${e.message}`;\n })\n .join('; ');\n return {\n status: 'scan-error',\n packageName,\n manifestPath: manifestPath ?? undefined,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: `source scan reported ${scanErrors.length} parse error(s): ${detail}`,\n };\n }\n\n const adapter = new ManifestAdapter();\n const expected = adapter.toManifest(resolved, {\n packageName,\n packageVersion: pkgJson.version,\n typeAliases: results.typeAliases,\n });\n const expectedKeys = Object.keys(expected.objects);\n\n // Nothing to verify if the package declares no SMRT objects (e.g. a package\n // that publishes ./manifest but only ships base classes).\n if (expectedKeys.length === 0) {\n return {\n status: 'skipped',\n packageName,\n manifestPath: manifestPath ?? undefined,\n missing: [],\n expectedCount: 0,\n distCount: 0,\n reason: manifestPath\n ? 'no @smrt() objects found in source'\n : 'package does not publish a ./manifest export and declares no @smrt() objects',\n };\n }\n\n if (!manifestPath) {\n return {\n status: 'missing-manifest',\n packageName,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `source declares ${expectedKeys.length} @smrt() object(s) but package.json publishes no ./manifest export`,\n };\n }\n\n if (!existsSync(manifestPath)) {\n return {\n status: 'missing-manifest',\n packageName,\n manifestPath,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `published manifest not found at ${manifestPath}`,\n };\n }\n\n let distObjects: Record<string, unknown> = {};\n try {\n const distManifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n distObjects =\n distManifest && typeof distManifest.objects === 'object'\n ? distManifest.objects\n : {};\n } catch (error) {\n return {\n status: 'missing-manifest',\n packageName,\n manifestPath,\n missing: expectedKeys,\n expectedCount: expectedKeys.length,\n distCount: 0,\n reason: `published manifest is not valid JSON: ${(error as Error).message}`,\n };\n }\n\n const distKeys = new Set(Object.keys(distObjects));\n const missing = expectedKeys.filter((key) => !distKeys.has(key));\n\n return {\n status: missing.length > 0 ? 'incomplete' : 'ok',\n packageName,\n manifestPath,\n missing,\n expectedCount: expectedKeys.length,\n distCount: distKeys.size,\n };\n}\n"],"mappings":";;;;;;AAsCA,IAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAQD,IAAM,6BAAa,IAAI,IAAI;CACzB;CACA;CACA;CACA;CACA;AACF,CAAC;AAkBD,IAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,IAAM,yCAAyB,IAAI,IA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Aa,YAAY,WAC5C,aAAa,UACb,CAAC;CACT,SAAS,OAAO;EACd,OAAO;GACL,QAAQ;GACR;GACA;GACA,SAAS;GACT,eAAe,aAAa;GAC5B,WAAW;GACX,QAAQ,yCAA0C,MAAgB;EACpE;CACF;CAEA,MAAM,WAAW,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC;CACjD,MAAM,UAAU,aAAa,QAAQ,QAAQ,CAAC,SAAS,IAAI,GAAG,CAAC;CAE/D,OAAO;EACL,QAAQ,QAAQ,SAAS,IAAI,eAAe;EAC5C;EACA;EACA;EACA,eAAe,aAAa;EAC5B,WAAW,SAAS;CACtB;AACF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Setter-reads-hidden-field lint (#5603).
3
+ *
4
+ * The write rule (#5195, `FieldNotWritableError`) refuses a changed protected
5
+ * field, and a protected field the caller cannot read is refused whatever its
6
+ * value, so a caller never learns the stored value from an accepted-versus-
7
+ * refused answer. A setter is application code, though: if it READS such a
8
+ * field before deciding what to assign,
9
+ *
10
+ * set label(value: string) {
11
+ * if (this.secretHash !== value) this.secretHash = value;
12
+ * }
13
+ *
14
+ * a caller with update permission confirms the hidden value by the 200 versus
15
+ * 400 the branch produces. The engine does not proxy hidden-field reads inside
16
+ * accessors (documented known limit), so the rule is on the model author:
17
+ * **a setter must not read a field some callers cannot read.** This lint finds
18
+ * the violation in source.
19
+ *
20
+ * "Hidden" here is what the scanner can see on a field declaration:
21
+ * `@field({ sensitive: true })` or `@field({ readPermission: '...' })`, the two
22
+ * options that withhold a field from `toPublicJSON()`.
23
+ *
24
+ * What counts as a read: `this.f`, `this['f']`, `this?.f`, a compound or
25
+ * logical assignment (`this.f += 1`, `this.f ??= v`), `this.f++`, and
26
+ * destructuring `this` (`const { f } = this`). A plain assignment to the field
27
+ * (`this.f = v`, including as a destructuring target) is not a read; the
28
+ * assignment trap already refuses it.
29
+ *
30
+ * Deliberately syntactic: aliases (`const self = this`), dynamic keys
31
+ * (`this[name]`), calls into helpers that read the field, config options the
32
+ * scanner cannot resolve to a literal, and fields inherited from a parent
33
+ * declared in another file are not followed. A missed finding is a documented
34
+ * limit; a false finding would make the gate noisy.
35
+ */
36
+ /** One setter that reads a field some callers cannot read. */
37
+ export interface SetterHiddenReadFinding {
38
+ /** Declaring class, e.g. `Account`. */
39
+ className: string;
40
+ /** Setter name. */
41
+ setterName: string;
42
+ /** The hidden field the setter reads. */
43
+ fieldName: string;
44
+ /** Why the field is hidden: `sensitive` or `readPermission`. */
45
+ hiddenBy: 'sensitive' | 'readPermission';
46
+ /** File passed to the lint. */
47
+ filePath: string;
48
+ /** 1-based line of the read, or `0` when it could not be resolved. */
49
+ line: number;
50
+ /** Human-readable explanation naming the rule. */
51
+ message: string;
52
+ /** The accepted fixes. */
53
+ remedy: string;
54
+ }
55
+ /** Cheap pre-filter: a file without all three words cannot produce a finding. */
56
+ export declare function sourceMayContainSetterHiddenRead(source: string): boolean;
57
+ /**
58
+ * Report every setter on a class whose body reads one of that class's hidden
59
+ * fields (`@field({ sensitive: true })` or `@field({ readPermission })`).
60
+ *
61
+ * @param sourceText - Contents of one TypeScript file.
62
+ * @param filePath - Path used in findings and to pick the parser language.
63
+ * @returns One finding per (setter, field) pair, in source order.
64
+ */
65
+ export declare function lintSetterHiddenReads(sourceText: string, filePath?: string): SetterHiddenReadFinding[];
66
+ //# sourceMappingURL=setter-hidden-read-lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setter-hidden-read-lint.d.ts","sourceRoot":"","sources":["../src/setter-hidden-read-lint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAAC;IACzC,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAcD,iFAAiF;AACjF,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMxE;AAmLD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,SAAa,GACpB,uBAAuB,EAAE,CAwE3B"}
@@ -5,10 +5,10 @@ description: "High-performance TypeScript scanner using OXC for SMRT manifest ge
5
5
  status: "stable"
6
6
  generated:
7
7
  by: "smrt/scripts/generate-knowledge-okf.ts"
8
- at: "2026-11-05T15:48:19Z"
8
+ at: "2026-11-24T19:09:34Z"
9
9
  audience: "internal"
10
10
  evidence_level: "manifest-described"
11
- source_revision: "sha256:675a955a76fe3a3ec24852b45ccd9c6686496a2350110155075b9c1bf35007f3"
11
+ source_revision: "sha256:38ceabe104c46a62d3b86e90ffd242ec3e90bc1b25c141e414eaf1dc903c8e22"
12
12
  sources:
13
13
  - id: "manifest"
14
14
  resource: "https://github.com/happyvertical/smrt/blob/main/packages/scanner/package.json"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-scanner",
3
- "version": "0.70.0",
3
+ "version": "0.70.2",
4
4
  "description": "High-performance TypeScript scanner using OXC for SMRT manifest generation",
5
5
  "author": "HappyVertical",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@happyvertical/smrt-types": "0.70.0",
37
+ "@happyvertical/smrt-types": "0.70.2",
38
38
  "minimatch": "10.2.6",
39
39
  "oxc-parser": "^0.150.0",
40
40
  "oxc-resolver": "^11.24.2",