@fabrika/check 0.9.0-dev.18 → 0.9.0-dev.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/check",
3
- "version": "0.9.0-dev.18",
3
+ "version": "0.9.0-dev.19",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,11 +47,11 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@babel/parser": "8.0.7",
50
- "@fabrika/app": "0.9.0-dev.18",
51
- "@fabrika/auth-core": "0.9.0-dev.18",
52
- "@fabrika/db": "0.9.0-dev.18",
53
- "@fabrika/operations-contract": "0.9.0-dev.18",
54
- "@fabrika/platform-node": "0.9.0-dev.18",
50
+ "@fabrika/app": "0.9.0-dev.19",
51
+ "@fabrika/auth-core": "0.9.0-dev.19",
52
+ "@fabrika/db": "0.9.0-dev.19",
53
+ "@fabrika/operations-contract": "0.9.0-dev.19",
54
+ "@fabrika/platform-node": "0.9.0-dev.19",
55
55
  "zod": "^3.25.76"
56
56
  }
57
57
  }
package/src/check.ts CHANGED
@@ -27,11 +27,11 @@ import { readTablesValue } from './reader/tables'
27
27
  import { type ModuleReference, moduleReferences } from './references'
28
28
  import { type ImportMappings, readImportMappings } from './resolution'
29
29
  import { checkCloudflareContract } from './rules/cloudflare'
30
+ import { checkContractCompiles } from './rules/compile'
30
31
  import { checkContractRead } from './rules/contract'
31
32
  import { checkCrontab, contractJobs } from './rules/crontab'
32
33
  import { checkFrameworkWrite, trustedBindings } from './rules/framework'
33
34
  import { checkClientIdentity } from './rules/identity'
34
- import { checkGeneratedTests } from './rules/isolation'
35
35
  import { checkJsonStrings } from './rules/json'
36
36
  import { checkLiteralGraph } from './rules/literal'
37
37
  import { checkMigrationHistory, type MigrationBase } from './rules/migration-history'
@@ -52,7 +52,7 @@ import { checkAmbientModule, checkPackageReplacement } from './rules/packages'
52
52
  import { checkBackupPlan, checkMigrationClassification } from './rules/platform-migrations'
53
53
  import { checkKeyLiteralNode, checkRuntimeNode, crossAppFetchMessage, rawSqlBindings } from './rules/runtime'
54
54
  import { checkStructureNode, checkStructureReferences, checkToolPackages, structurePlace } from './rules/structure'
55
- import { checkGeneratedTest, checkMockModule, checkTestNode, checkTestSuiteConfig } from './rules/tests'
55
+ import { checkMockModule, checkTestNode, checkTestSuiteConfig } from './rules/tests'
56
56
  import { checkComments, checkTypeNode } from './rules/types'
57
57
  import { moduleSlice, sliceFinding } from './slice'
58
58
  import { BUNFIG_FILE, checkTrustedResolution } from './trust'
@@ -119,9 +119,9 @@ interface ContractDependent {
119
119
  * A module under `tools/` runs on a developer's machine, never in the application: it is held to how its source is
120
120
  * written (`type-assertion`, `any-type`, `capability-widening`, `suppression-comment`), `key-literal`, a `declare
121
121
  * module` of a trusted package and the rules of its tests. Every other module rule guards code that runs in the
122
- * application. `generated-test-import` reaches it through `checkStructureReferences`, as every module.
122
+ * application.
123
123
  */
124
- const checkToolModule = async (module: ParsedModule, text: string, files: ReadonlyMap<string, string>, findings: Finding[]): Promise<void> => {
124
+ const checkToolModule = (module: ParsedModule, findings: Finding[]): void => {
125
125
  const report = reporter(module.file, findings)
126
126
  const isTest = isTestFile(module.file)
127
127
  walk(module.program, (node, ancestors) => {
@@ -129,21 +129,19 @@ const checkToolModule = async (module: ParsedModule, text: string, files: Readon
129
129
  checkTypeNode(node, report)
130
130
  checkAmbientModule(node, report)
131
131
  if (isTest) checkTestNode(node, ancestors, report)
132
- checkMockModule(node, module.file, files, report)
132
+ checkMockModule(node, report)
133
133
  })
134
134
  checkComments(module.comments, report)
135
- await checkGeneratedTest(text, module.comments, report)
136
135
  }
137
136
 
138
- const checkSourceModule = async (
137
+ const checkSourceModule = (
139
138
  module: ParsedModule,
140
139
  references: readonly ModuleReference[],
141
- text: string,
142
140
  mappings: ImportMappings,
143
141
  files: ReadonlyMap<string, string>,
144
142
  findings: Finding[],
145
143
  dependent: ContractDependent,
146
- ): Promise<void> => {
144
+ ): void => {
147
145
  const exists = (path: string): boolean => files.has(path)
148
146
  const report = reporter(module.file, findings)
149
147
  const isGeneratedEntry = module.file === GENERATED_ENTRY_FILE
@@ -180,12 +178,11 @@ const checkSourceModule = async (
180
178
  checkTypeNode(node, report)
181
179
  checkAmbientModule(node, report)
182
180
  if (isTest) checkTestNode(node, ancestors, report)
183
- checkMockModule(node, module.file, files, report)
181
+ checkMockModule(node, report)
184
182
  checkStructureNode(place, node, report)
185
183
  })
186
184
  checkComments(module.comments, report)
187
185
  checkModuleReferences(module.file, references, mappings, exists, report, isGeneratedEntry, isTest)
188
- await checkGeneratedTest(text, module.comments, report)
189
186
  }
190
187
 
191
188
  /** `module` as its shell slice (itself when it holds no colocated handler), and the `.handle(…)` forms it refused. */
@@ -316,8 +313,8 @@ export const checkApplication = async (input: CheckInput): Promise<Finding[]> =>
316
313
  modules.set(path, parsed.module)
317
314
  const referencesOfModule = moduleReferences(parsed.module.program)
318
315
  references.set(path, referencesOfModule)
319
- if (isToolModule(path)) await checkToolModule(parsed.module, text, tree.files, findings)
320
- else await checkSourceModule(parsed.module, referencesOfModule, text, mappings, tree.files, findings, dependent)
316
+ if (isToolModule(path)) checkToolModule(parsed.module, findings)
317
+ else checkSourceModule(parsed.module, referencesOfModule, mappings, tree.files, findings, dependent)
321
318
  }
322
319
  const structure = { files: tree.files, mappings, referencesOf: (path: string) => references.get(path) ?? [] }
323
320
  for (const path of modules.keys()) {
@@ -341,7 +338,7 @@ export const checkApplication = async (input: CheckInput): Promise<Finding[]> =>
341
338
  const contractRead = contract !== undefined && literal.length === 0 ? checkContractRead(graph) : []
342
339
  findings.push(...contractRead)
343
340
  for (const module of contract === undefined ? [] : contractModules(graph, contract)) findings.push(...checkClientIdentity(module, graph))
344
- findings.push(...(await checkGeneratedTests(tree.files, literal.length === 0 && trust.length === 0 && contractRead.length === 0)))
341
+ findings.push(...checkContractCompiles(tree.files, literal.length === 0 && trust.length === 0 && contractRead.length === 0))
345
342
  findings.push(...checkMigrationNames(checkedPaths))
346
343
  if (input.migrationBase !== undefined) findings.push(...checkMigrationHistory(tree.files, input.migrationBase))
347
344
  findings.push(...checkToolPackages(checkedPaths))
package/src/finding.ts CHANGED
@@ -37,12 +37,9 @@ export const REFUSAL_RULE_IDS = [
37
37
  'package-replacement',
38
38
  'skipped-test',
39
39
  'test-without-assertion',
40
- 'generated-test-hash',
41
40
  'mock-module',
42
- 'endpoint-fixture',
43
41
  'spa-server-import',
44
42
  'layer-import',
45
- 'generated-test-import',
46
43
  'shared-import',
47
44
  'tool-import',
48
45
  'cloudflare-scan',
package/src/index.ts CHANGED
@@ -5,14 +5,3 @@ export { CONFIG_FILE, CONTRACT_FILE, GENERATED_ENTRY_FILE, MIGRATIONS_DIR, TABLE
5
5
  export { readMigrationBase } from './migration-base'
6
6
  export { type PackedSet, type PackedTarball, readPackedSet } from './packed'
7
7
  export type { MigrationBase } from './rules/migration-history'
8
- export { GENERATED_TEST_HEADER, generatedTestHeader } from './rules/tests'
9
- export {
10
- ENDPOINT_ACCESS_TEST,
11
- ENDPOINT_FIXTURES_FILE,
12
- type GeneratedTest,
13
- generatedTests,
14
- missingEndpointFixtures,
15
- POLICY_TESTS_DIR,
16
- policyTestPath,
17
- scaffoldInputs,
18
- } from './scaffold'
package/src/layout.ts CHANGED
@@ -11,13 +11,6 @@ export const GENERATED_ENTRY_FILE = 'fabrika/entry.generated.ts'
11
11
  /** Where a Cloudflare deploy stages the SPA mounts' built files (`@fabrika/provider-cloudflare`): build output, never source. */
12
12
  export const STAGED_ASSETS_DIR = 'fabrika/assets/'
13
13
  export const MIGRATIONS_DIR = 'db/migrations/'
14
- /** Where `fabrika db test-scaffold` writes the policy isolation tests, `<table>.policy-isolation.test.ts`. */
15
- export const POLICY_TESTS_DIR = 'src/db/__tests__/'
16
- export const POLICY_TEST_SUFFIX = '.policy-isolation.test.ts'
17
- /** The generated endpoint access tests; they import `src/app.ts`, whose default export they boot. */
18
- export const ENDPOINT_ACCESS_TEST = 'src/__tests__/endpoint-access.test.ts'
19
- /** The inputs the author gives the endpoint access tests where the scaffold cannot sample one; read, never run. */
20
- export const ENDPOINT_FIXTURES_FILE = 'src/__tests__/endpoint-access.fixtures.ts'
21
14
  export const ZEROPS_FILES = ['zerops.yaml', 'zerops.yml'] as const
22
15
 
23
16
  /** The application architecture (docs/reference/application-architecture.md): where each layer's code lives. */
@@ -31,7 +24,7 @@ export const SCHEMAS_DIR = 'src/schemas/'
31
24
  * its own directory.
32
25
  */
33
26
  export const SHARED_DIR = 'src/shared/'
34
- /** `src/db/`: the tables, the generated schema and their generated tests; never a slice. */
27
+ /** `src/db/`: the tables and the generated schema; never a slice. */
35
28
  export const DATABASE_DIR = 'src/db/'
36
29
  /** A slice is a directory `src/<slice>/` that holds these modules, each optional. */
37
30
  export const SLICE_ENDPOINTS_FILE = 'endpoints.ts'
@@ -0,0 +1,32 @@
1
+ import { ContractError } from '@fabrika/app/contract'
2
+ import { ContractSourceError, readContractSource, readTablesDefinition } from '../contract'
3
+ import type { Finding } from '../finding'
4
+ import { CONTRACT_FILE } from '../layout'
5
+
6
+ /**
7
+ * What the reader refuses of `src/db/tables.ts`, and a contract that does not compile against its policies: Control
8
+ * reads the commit with the same calls and refuses the deploy. `readable` is false while the literal, trust or
9
+ * contract rules report the sources, so a refusal is not reported twice.
10
+ */
11
+ export const checkContractCompiles = (files: ReadonlyMap<string, string>, readable: boolean): Finding[] => {
12
+ if (!readable) return []
13
+ try {
14
+ const tables = readTablesDefinition(files)
15
+ if (files.has(CONTRACT_FILE) && tables !== null) readContractSource(files, tables)
16
+ return []
17
+ } catch (error) {
18
+ if (error instanceof ContractSourceError) return [...error.findings]
19
+ if (error instanceof ContractError) {
20
+ return error.problems.map((problem): Finding => ({
21
+ file: CONTRACT_FILE,
22
+ line: 1,
23
+ column: 1,
24
+ severity: 'refusal',
25
+ rule: 'contract',
26
+ message: problem,
27
+ allowed: 'a contract that compiles against src/db/tables.ts',
28
+ }))
29
+ }
30
+ throw error
31
+ }
32
+ }
@@ -20,10 +20,9 @@ import {
20
20
  import type { ModuleReference } from '../references'
21
21
  import { type ImportMappings, mappedTargets } from '../resolution'
22
22
  import { isTestKit } from './modules'
23
- import { isGeneratedTestPath } from './tests'
24
23
 
25
- /** The rules of the application architecture (docs/reference/application-architecture.md): four refusals and the hints. */
26
- export const STRUCTURE_RULE_IDS = ['spa-server-import', 'layer-import', 'generated-test-import', 'shared-import', ...STRUCTURE_HINT_RULE_IDS] as const
24
+ /** The rules of the application architecture (docs/reference/application-architecture.md): three refusals and the hints. */
25
+ export const STRUCTURE_RULE_IDS = ['spa-server-import', 'layer-import', 'shared-import', ...STRUCTURE_HINT_RULE_IDS] as const
27
26
 
28
27
  type SlicePart = 'endpoints' | 'logic' | 'queries'
29
28
 
@@ -242,14 +241,6 @@ export const checkToolPackages = (paths: readonly string[]): Finding[] =>
242
241
  export const checkStructureReferences = (graph: StructureGraph, place: StructurePlace, report: Report): void => {
243
242
  for (const reference of graph.referencesOf(place.file)) {
244
243
  const targets = referenceTargets(graph, place.file, reference.specifier)
245
- if (targets.files.some((path) => isGeneratedTestPath(path, graph.files))) {
246
- report(
247
- reference.node,
248
- 'generated-test-import',
249
- `'${reference.specifier}' is a generated test, which no module imports`,
250
- 'a helper module of your own; fabrika db test-scaffold rewrites the generated tests',
251
- )
252
- }
253
244
  if (reference.typeOnly) continue
254
245
  const tool = isToolModule(place.file) ? undefined : targets.files.find(isToolModule)
255
246
  if (tool !== undefined) {
@@ -1,6 +1,5 @@
1
- import { type AstNode, child, children, type Comment, identifierName, memberPath, memberSuffix, staticString, walk } from '../ast'
1
+ import { type AstNode, child, children, identifierName, memberPath, memberSuffix, staticString, walk } from '../ast'
2
2
  import type { Finding, Report } from '../finding'
3
- import { ENDPOINT_ACCESS_TEST, isRelativeSpecifier, joinRelative, POLICY_TEST_SUFFIX, POLICY_TESTS_DIR, resolveRelative } from '../layout'
4
3
  import { declaringScope } from '../scope'
5
4
  import { isKey, parseToml } from '../toml'
6
5
  import { BUNFIG_FILE } from '../trust'
@@ -107,50 +106,12 @@ export const checkTestNode = (node: AstNode, ancestors: readonly AstNode[], repo
107
106
  }
108
107
  }
109
108
 
110
- /** The first line of a test written by `fabrika db test-scaffold`, followed by the SHA-256 of everything after that line. */
111
- export const GENERATED_TEST_HEADER = '// @generated by fabrika db test-scaffold sha256:'
112
- const GENERATED_TEST_MARKER = '// @generated by fabrika db test-scaffold'
113
-
114
- const sha256 = async (text: string): Promise<string> => {
115
- const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
116
- return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('')
117
- }
118
-
119
- /** The header `fabrika db test-scaffold` puts on a generated test with this body. */
120
- export const generatedTestHeader = async (body: string): Promise<string> => `${GENERATED_TEST_HEADER}${await sha256(body)}`
121
-
122
- export const checkGeneratedTest = async (text: string, comments: readonly Comment[], report: Report): Promise<void> => {
123
- if (!text.startsWith(GENERATED_TEST_MARKER)) {
124
- const misplaced = comments.find((comment) => comment.text.includes(GENERATED_TEST_MARKER.slice('// '.length)))
125
- if (misplaced !== undefined) {
126
- report(
127
- misplaced.position,
128
- 'generated-test-hash',
129
- 'the generated-test header is not the first line of the file',
130
- 'the file as fabrika db test-scaffold wrote it',
131
- )
132
- }
133
- return
134
- }
135
- const newline = text.indexOf('\n')
136
- const header = newline === -1 ? text : text.slice(0, newline)
137
- const body = newline === -1 ? '' : text.slice(newline + 1)
138
- if (header === (await generatedTestHeader(body))) return
139
- report(
140
- { line: 1, column: 1 },
141
- 'generated-test-hash',
142
- 'this generated test differs from what fabrika db test-scaffold wrote',
143
- 'the file as generated; rerun fabrika db test-scaffold after a table change',
144
- )
145
- }
146
-
147
109
  /** `[test]` keys that pick other test files, skip some, or let a failing test pass on a later attempt. */
148
110
  const SUITE_NARROWING_TEST_KEYS = ['root', 'pathIgnorePatterns', 'retry'] as const
149
111
 
150
112
  /**
151
- * The `bunfig.toml` of an application must not narrow its own suite. The platform's run of the generated tests ignores
152
- * the file (`fabrika db test-isolation`); this keeps the application's own run whole too. A file outside the TOML
153
- * subset is reported by the trust rules.
113
+ * The `bunfig.toml` of an application must not narrow its own suite, which the platform build runs. A file outside the
114
+ * TOML subset is reported by the trust rules.
154
115
  */
155
116
  export const checkTestSuiteConfig = (text: string): Finding[] => {
156
117
  const document = parseToml(text)
@@ -174,35 +135,23 @@ export const checkTestSuiteConfig = (text: string): Finding[] => {
174
135
  return findings
175
136
  }
176
137
 
177
- /** Whether `path` is a file the scaffold generates: a policy isolation test, the endpoint access test, or one with the header. */
178
- export const isGeneratedTestPath = (path: string, files: ReadonlyMap<string, string>): boolean =>
179
- path === ENDPOINT_ACCESS_TEST || (path.startsWith(POLICY_TESTS_DIR) && path.endsWith(POLICY_TEST_SUFFIX))
180
- || (files.get(path)?.startsWith(GENERATED_TEST_MARKER) ?? false)
181
-
182
138
  /**
183
- * `mock.module(…)` of the test runner, a framework package or a generated test would let application code replace what
184
- * the generated tests run on; a computed specifier could name any of them. Refused anywhere in the application.
139
+ * `mock.module(…)` of the test runner or a framework package would let application code replace what the test kit runs
140
+ * on; a computed specifier could name either. Refused anywhere in the application.
185
141
  */
186
- export const checkMockModule = (node: AstNode, file: string, files: ReadonlyMap<string, string>, report: Report): void => {
142
+ export const checkMockModule = (node: AstNode, report: Report): void => {
187
143
  if (node.type !== 'CallExpression') return
188
144
  const callee = child(node, 'callee')
189
145
  if (callee === undefined || callee.type !== 'MemberExpression') return
190
146
  const suffix = memberPath(callee) ?? memberSuffix(callee)
191
147
  if (suffix.length < 2 || suffix[suffix.length - 1] !== 'module' || suffix[suffix.length - 2] !== 'mock') return
192
- const allowed = 'mock.module of an application module that no generated test is, with a literal specifier'
148
+ const allowed = 'mock.module of an application module, with a literal specifier'
193
149
  const specifier = staticString(children(node, 'arguments')[0] ?? undefined)
194
150
  if (specifier === undefined) {
195
151
  report(node, 'mock-module', 'mock.module with a computed specifier could replace the test runner or the framework', allowed)
196
152
  return
197
153
  }
198
154
  if (specifier === 'bun:test' || specifier.startsWith('@fabrika/')) {
199
- report(node, 'mock-module', `mock.module('${specifier}') replaces what the generated tests run on`, allowed)
200
- return
201
- }
202
- if (!isRelativeSpecifier(specifier)) return
203
- const resolved = resolveRelative((path) => files.has(path), file, specifier)
204
- const targets = resolved.kind === 'file' ? [resolved.path] : resolved.kind === 'missing' ? [joinRelative(file, specifier) ?? ''] : resolved.paths
205
- if (targets.some((target) => isGeneratedTestPath(target, files))) {
206
- report(node, 'mock-module', `mock.module('${specifier}') replaces a generated test`, allowed)
155
+ report(node, 'mock-module', `mock.module('${specifier}') replaces what the test kit runs on`, allowed)
207
156
  }
208
157
  }
@@ -1,6 +1,6 @@
1
1
  import type { AstNode, Position } from './ast';
2
2
  /** Rules whose finding fails the check: the framework's forms and platform integrity. */
3
- export declare const REFUSAL_RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "generated-test-hash", "mock-module", "endpoint-fixture", "spa-server-import", "layer-import", "generated-test-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger"];
3
+ export declare const REFUSAL_RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "mock-module", "spa-server-import", "layer-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger"];
4
4
  /** Rules that report a step out of the application architecture. */
5
5
  export declare const STRUCTURE_HINT_RULE_IDS: readonly ["logic-data-access", "cross-slice-queries", "handler-location", "data-access-location"];
6
6
  /**
@@ -9,7 +9,7 @@ export declare const STRUCTURE_HINT_RULE_IDS: readonly ["logic-data-access", "cr
9
9
  * Cloudflare mutation that waits for an outside call inside the object's transaction.
10
10
  */
11
11
  export declare const HINT_RULE_IDS: readonly ["logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external", "cloudflare-held-call"];
12
- export declare const RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "generated-test-hash", "mock-module", "endpoint-fixture", "spa-server-import", "layer-import", "generated-test-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger", "logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external", "cloudflare-held-call"];
12
+ export declare const RULE_IDS: readonly ["parse-error", "literal", "contract", "forbidden-import", "test-only-import", "unchecked-import", "forbidden-global", "raw-sql", "type-assertion", "any-type", "suppression-comment", "capability-widening", "prototype-assignment", "framework-write", "env-read", "public-env", "cross-app-fetch", "url-endpoint", "on-conflict-index", "access-view-key", "key-literal", "client-identity", "sensitive-log", "unsafe-html", "dynamic-code", "migration-name", "migration-refused", "backup-schema", "migration-edited", "file-column-migration", "crontab", "package-replacement", "skipped-test", "test-without-assertion", "mock-module", "spa-server-import", "layer-import", "shared-import", "tool-import", "cloudflare-scan", "cloudflare-job-segment", "cloudflare-current-timestamp", "cloudflare-framework-name", "cloudflare-view-trigger", "logic-data-access", "cross-slice-queries", "handler-location", "data-access-location", "sql-undeclared", "member-admits-external", "cloudflare-held-call"];
13
13
  export type RefusalRuleId = (typeof REFUSAL_RULE_IDS)[number];
14
14
  export type HintRuleId = (typeof HINT_RULE_IDS)[number];
15
15
  export type RuleId = (typeof RULE_IDS)[number];
@@ -5,5 +5,3 @@ export { CONFIG_FILE, CONTRACT_FILE, GENERATED_ENTRY_FILE, MIGRATIONS_DIR, TABLE
5
5
  export { readMigrationBase } from './migration-base';
6
6
  export { type PackedSet, type PackedTarball, readPackedSet } from './packed';
7
7
  export type { MigrationBase } from './rules/migration-history';
8
- export { GENERATED_TEST_HEADER, generatedTestHeader } from './rules/tests';
9
- export { ENDPOINT_ACCESS_TEST, ENDPOINT_FIXTURES_FILE, type GeneratedTest, generatedTests, missingEndpointFixtures, POLICY_TESTS_DIR, policyTestPath, scaffoldInputs, } from './scaffold';
@@ -11,13 +11,6 @@ export declare const GENERATED_ENTRY_FILE = "fabrika/entry.generated.ts";
11
11
  /** Where a Cloudflare deploy stages the SPA mounts' built files (`@fabrika/provider-cloudflare`): build output, never source. */
12
12
  export declare const STAGED_ASSETS_DIR = "fabrika/assets/";
13
13
  export declare const MIGRATIONS_DIR = "db/migrations/";
14
- /** Where `fabrika db test-scaffold` writes the policy isolation tests, `<table>.policy-isolation.test.ts`. */
15
- export declare const POLICY_TESTS_DIR = "src/db/__tests__/";
16
- export declare const POLICY_TEST_SUFFIX = ".policy-isolation.test.ts";
17
- /** The generated endpoint access tests; they import `src/app.ts`, whose default export they boot. */
18
- export declare const ENDPOINT_ACCESS_TEST = "src/__tests__/endpoint-access.test.ts";
19
- /** The inputs the author gives the endpoint access tests where the scaffold cannot sample one; read, never run. */
20
- export declare const ENDPOINT_FIXTURES_FILE = "src/__tests__/endpoint-access.fixtures.ts";
21
14
  export declare const ZEROPS_FILES: readonly ["zerops.yaml", "zerops.yml"];
22
15
  /** The application architecture (docs/reference/application-architecture.md): where each layer's code lives. */
23
16
  export declare const VOCABULARY_FILE = "src/vocabulary.ts";
@@ -30,7 +23,7 @@ export declare const SCHEMAS_DIR = "src/schemas/";
30
23
  * its own directory.
31
24
  */
32
25
  export declare const SHARED_DIR = "src/shared/";
33
- /** `src/db/`: the tables, the generated schema and their generated tests; never a slice. */
26
+ /** `src/db/`: the tables and the generated schema; never a slice. */
34
27
  export declare const DATABASE_DIR = "src/db/";
35
28
  /** A slice is a directory `src/<slice>/` that holds these modules, each optional. */
36
29
  export declare const SLICE_ENDPOINTS_FILE = "endpoints.ts";
@@ -0,0 +1,7 @@
1
+ import type { Finding } from '../finding';
2
+ /**
3
+ * What the reader refuses of `src/db/tables.ts`, and a contract that does not compile against its policies: Control
4
+ * reads the commit with the same calls and refuses the deploy. `readable` is false while the literal, trust or
5
+ * contract rules report the sources, so a refusal is not reported twice.
6
+ */
7
+ export declare const checkContractCompiles: (files: ReadonlyMap<string, string>, readable: boolean) => Finding[];
@@ -2,8 +2,8 @@ import { type AstNode } from '../ast';
2
2
  import { type Finding, type Report } from '../finding';
3
3
  import type { ModuleReference } from '../references';
4
4
  import { type ImportMappings } from '../resolution';
5
- /** The rules of the application architecture (docs/reference/application-architecture.md): four refusals and the hints. */
6
- export declare const STRUCTURE_RULE_IDS: readonly ["spa-server-import", "layer-import", "generated-test-import", "shared-import", "logic-data-access", "cross-slice-queries", "handler-location", "data-access-location"];
5
+ /** The rules of the application architecture (docs/reference/application-architecture.md): three refusals and the hints. */
6
+ export declare const STRUCTURE_RULE_IDS: readonly ["spa-server-import", "layer-import", "shared-import", "logic-data-access", "cross-slice-queries", "handler-location", "data-access-location"];
7
7
  type SlicePart = 'endpoints' | 'logic' | 'queries';
8
8
  /** Where a module sits in the architecture, which decides what it may import and call. */
9
9
  export interface StructurePlace {
@@ -1,22 +1,14 @@
1
- import { type AstNode, type Comment } from '../ast';
1
+ import { type AstNode } from '../ast';
2
2
  import type { Finding, Report } from '../finding';
3
3
  /** For test files: every test runs, and every test asserts. */
4
4
  export declare const checkTestNode: (node: AstNode, ancestors: readonly AstNode[], report: Report) => void;
5
- /** The first line of a test written by `fabrika db test-scaffold`, followed by the SHA-256 of everything after that line. */
6
- export declare const GENERATED_TEST_HEADER = "// @generated by fabrika db test-scaffold sha256:";
7
- /** The header `fabrika db test-scaffold` puts on a generated test with this body. */
8
- export declare const generatedTestHeader: (body: string) => Promise<string>;
9
- export declare const checkGeneratedTest: (text: string, comments: readonly Comment[], report: Report) => Promise<void>;
10
5
  /**
11
- * The `bunfig.toml` of an application must not narrow its own suite. The platform's run of the generated tests ignores
12
- * the file (`fabrika db test-isolation`); this keeps the application's own run whole too. A file outside the TOML
13
- * subset is reported by the trust rules.
6
+ * The `bunfig.toml` of an application must not narrow its own suite, which the platform build runs. A file outside the
7
+ * TOML subset is reported by the trust rules.
14
8
  */
15
9
  export declare const checkTestSuiteConfig: (text: string) => Finding[];
16
- /** Whether `path` is a file the scaffold generates: a policy isolation test, the endpoint access test, or one with the header. */
17
- export declare const isGeneratedTestPath: (path: string, files: ReadonlyMap<string, string>) => boolean;
18
10
  /**
19
- * `mock.module(…)` of the test runner, a framework package or a generated test would let application code replace what
20
- * the generated tests run on; a computed specifier could name any of them. Refused anywhere in the application.
11
+ * `mock.module(…)` of the test runner or a framework package would let application code replace what the test kit runs
12
+ * on; a computed specifier could name either. Refused anywhere in the application.
21
13
  */
22
- export declare const checkMockModule: (node: AstNode, file: string, files: ReadonlyMap<string, string>, report: Report) => void;
14
+ export declare const checkMockModule: (node: AstNode, report: Report) => void;