@astrale-os/sdk 0.6.0-beta.37 → 0.6.0-beta.38

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.
@@ -1,7 +1,7 @@
1
1
  import ts from 'typescript';
2
2
  import { propertyChain, resolveImportedSymbol, unwrap, visit, } from '../../adapters/typescript/index.js';
3
3
  import { domainFunctionRequirements, callableReference, callableSelector, declaredDomainDependencies, remoteCallableKey, } from './callable-requirements.js';
4
- import { ambiguity, calls, isForeignDomain, production, violation } from './shared.js';
4
+ import { ambiguity, calls, contextPath, isForeignDomain, production, violation } from './shared.js';
5
5
  export const dependencyRules = [
6
6
  {
7
7
  id: 'FNC-XDOM-DECLARED',
@@ -158,75 +158,3 @@ function selectedCallable(input) {
158
158
  const chain = expression && propertyChain(expression);
159
159
  return chain && chain[0] === parameter.text ? chain.slice(1) : undefined;
160
160
  }
161
- /** Resolve handler context bindings and one immutable local alias without following arbitrary helpers. */
162
- function contextPath(input, run, aliases = 1) {
163
- const expression = unwrap(input);
164
- if (ts.isPropertyAccessExpression(expression)) {
165
- const base = contextPath(expression.expression, run, aliases);
166
- return base && [...base, expression.name.text];
167
- }
168
- if (ts.isElementAccessExpression(expression)) {
169
- const base = contextPath(expression.expression, run, aliases);
170
- return base && [...base, '[computed]'];
171
- }
172
- if (!ts.isIdentifier(expression))
173
- return undefined;
174
- let current = expression.parent;
175
- while (current) {
176
- if (ts.isFunctionLike(current)) {
177
- for (const parameter of current.parameters) {
178
- const path = bindingPath(parameter.name, expression.text);
179
- if (path)
180
- return parameter === current.parameters[0] &&
181
- (current === run || stepCallback(current, run))
182
- ? path
183
- : undefined;
184
- }
185
- }
186
- if (ts.isBlock(current) || ts.isSourceFile(current)) {
187
- for (const statement of current.statements) {
188
- if (ts.isFunctionDeclaration(statement) && statement.name?.text === expression.text)
189
- return undefined;
190
- if (!ts.isVariableStatement(statement))
191
- continue;
192
- for (const declaration of statement.declarationList.declarations) {
193
- const path = bindingPath(declaration.name, expression.text);
194
- if (!path)
195
- continue;
196
- if (aliases === 0 ||
197
- !declaration.initializer ||
198
- declaration.end > expression.pos ||
199
- !(statement.declarationList.flags & ts.NodeFlags.Const))
200
- return undefined;
201
- const base = contextPath(declaration.initializer, run, aliases - 1);
202
- return base && [...base, ...path];
203
- }
204
- }
205
- }
206
- current = current.parent;
207
- }
208
- return undefined;
209
- }
210
- /** A durable Step callback receives the handler's capabilities under the same names. */
211
- function stepCallback(callback, run) {
212
- const call = callback.parent;
213
- if (!ts.isCallExpression(call) || call.arguments[1] !== callback)
214
- return false;
215
- const callee = contextPath(call.expression, run, 0);
216
- return callee?.length === 2 && callee[0] === 'step' && callee[1] === 'run';
217
- }
218
- function bindingPath(name, identifier) {
219
- if (ts.isIdentifier(name))
220
- return name.text === identifier ? [] : undefined;
221
- if (!ts.isObjectBindingPattern(name))
222
- return undefined;
223
- for (const element of name.elements) {
224
- if (element.dotDotDotToken)
225
- continue;
226
- const nested = bindingPath(element.name, identifier);
227
- const property = element.propertyName ?? (ts.isIdentifier(element.name) ? element.name : undefined);
228
- if (nested && property && (ts.isIdentifier(property) || ts.isStringLiteral(property)))
229
- return [property.text, ...nested];
230
- }
231
- return undefined;
232
- }
@@ -36,5 +36,12 @@ export declare function hasForbiddenGlobalCall(file: SourceFile): Array<{
36
36
  node: ts.Node;
37
37
  name: string;
38
38
  }>;
39
+ /** The global a call reaches, as `name(…)` with no import or local binding, or `globalThis.name(…)`. */
40
+ export declare function globalCallName(file: SourceFile, node: ts.CallExpression): string | undefined;
41
+ /**
42
+ * Resolve the path of `input` from the first parameter of `run`, or of a durable Step callback in
43
+ * it, through one immutable local alias, without following arbitrary helpers.
44
+ */
45
+ export declare function contextPath(input: ts.Expression, run: ts.FunctionLikeDeclaration, aliases?: number): readonly string[] | undefined;
39
46
  export declare function isLocallyBoundIdentifier(node: ts.Identifier): boolean;
40
47
  export declare function forbiddenIoImport(specifier: string): boolean;
@@ -215,22 +215,101 @@ export function hasForbiddenGlobalCall(file) {
215
215
  visit(file.source, (node) => {
216
216
  if (!ts.isCallExpression(node))
217
217
  return;
218
- const expression = unwrap(node.expression);
219
- if (ts.isIdentifier(expression)) {
220
- const name = expression.text;
221
- if (forbidden.has(name) &&
222
- !importedSymbol(file, expression) &&
223
- !isLocallyBound(expression, name)) {
224
- result.push({ node, name });
218
+ const name = globalCallName(file, node);
219
+ if (name !== undefined && forbidden.has(name))
220
+ result.push({ node, name });
221
+ });
222
+ return result;
223
+ }
224
+ /** The global a call reaches, as `name(…)` with no import or local binding, or `globalThis.name(…)`. */
225
+ export function globalCallName(file, node) {
226
+ const expression = unwrap(node.expression);
227
+ if (ts.isIdentifier(expression)) {
228
+ const name = expression.text;
229
+ return importedSymbol(file, expression) || isLocallyBound(expression, name) ? undefined : name;
230
+ }
231
+ const chain = propertyChain(expression);
232
+ if (chain?.length !== 2 || chain[0] !== 'globalThis')
233
+ return undefined;
234
+ let root = expression;
235
+ while (ts.isPropertyAccessExpression(root))
236
+ root = unwrap(root.expression);
237
+ return ts.isIdentifier(root) && isLocallyBound(root, root.text) ? undefined : chain[1];
238
+ }
239
+ /**
240
+ * Resolve the path of `input` from the first parameter of `run`, or of a durable Step callback in
241
+ * it, through one immutable local alias, without following arbitrary helpers.
242
+ */
243
+ export function contextPath(input, run, aliases = 1) {
244
+ const expression = unwrap(input);
245
+ if (ts.isPropertyAccessExpression(expression)) {
246
+ const base = contextPath(expression.expression, run, aliases);
247
+ return base && [...base, expression.name.text];
248
+ }
249
+ if (ts.isElementAccessExpression(expression)) {
250
+ const base = contextPath(expression.expression, run, aliases);
251
+ return base && [...base, '[computed]'];
252
+ }
253
+ if (!ts.isIdentifier(expression))
254
+ return undefined;
255
+ let current = expression.parent;
256
+ while (current) {
257
+ if (ts.isFunctionLike(current)) {
258
+ for (const parameter of current.parameters) {
259
+ const path = bindingPath(parameter.name, expression.text);
260
+ if (path)
261
+ return parameter === current.parameters[0] &&
262
+ (current === run || stepCallback(current, run))
263
+ ? path
264
+ : undefined;
225
265
  }
226
- return;
227
266
  }
228
- const chain = propertyChain(expression);
229
- if (chain?.length === 2 && chain[0] === 'globalThis' && forbidden.has(chain[1])) {
230
- result.push({ node, name: chain[1] });
267
+ if (ts.isBlock(current) || ts.isSourceFile(current)) {
268
+ for (const statement of current.statements) {
269
+ if (ts.isFunctionDeclaration(statement) && statement.name?.text === expression.text)
270
+ return undefined;
271
+ if (!ts.isVariableStatement(statement))
272
+ continue;
273
+ for (const declaration of statement.declarationList.declarations) {
274
+ const path = bindingPath(declaration.name, expression.text);
275
+ if (!path)
276
+ continue;
277
+ if (aliases === 0 ||
278
+ !declaration.initializer ||
279
+ declaration.end > expression.pos ||
280
+ !(statement.declarationList.flags & ts.NodeFlags.Const))
281
+ return undefined;
282
+ const base = contextPath(declaration.initializer, run, aliases - 1);
283
+ return base && [...base, ...path];
284
+ }
285
+ }
231
286
  }
232
- });
233
- return result;
287
+ current = current.parent;
288
+ }
289
+ return undefined;
290
+ }
291
+ /** A durable Step callback receives the handler's capabilities under the same names. */
292
+ function stepCallback(callback, run) {
293
+ const call = callback.parent;
294
+ if (!ts.isCallExpression(call) || call.arguments[1] !== callback)
295
+ return false;
296
+ const callee = contextPath(call.expression, run, 0);
297
+ return callee?.length === 2 && callee[0] === 'step' && callee[1] === 'run';
298
+ }
299
+ function bindingPath(name, identifier) {
300
+ if (ts.isIdentifier(name))
301
+ return name.text === identifier ? [] : undefined;
302
+ if (!ts.isObjectBindingPattern(name))
303
+ return undefined;
304
+ for (const element of name.elements) {
305
+ if (element.dotDotDotToken)
306
+ continue;
307
+ const nested = bindingPath(element.name, identifier);
308
+ const property = element.propertyName ?? (ts.isIdentifier(element.name) ? element.name : undefined);
309
+ if (nested && property && (ts.isIdentifier(property) || ts.isStringLiteral(property)))
310
+ return [property.text, ...nested];
311
+ }
312
+ return undefined;
234
313
  }
235
314
  export function isLocallyBoundIdentifier(node) {
236
315
  return isLocallyBound(node, node.text);
@@ -1,8 +1,28 @@
1
1
  import ts from 'typescript';
2
- import { propertyChain, unwrap, visit, visitOwnBody, } from '../../adapters/typescript/index.js';
3
- import { ambiguity, calls, production, staticId, violation } from './shared.js';
2
+ import { expressionType, propertyChain, unwrap, visit, visitOwnBody, } from '../../adapters/typescript/index.js';
3
+ import { ambiguity, calls, contextPath, globalCallName, production, staticId, violation, } from './shared.js';
4
4
  // `query` and `mutate` are the durable Step sugar over `run`; each is one Step too.
5
5
  const STEP_METHODS = new Set(['run', 'query', 'mutate']);
6
+ // Members only a durable Workflow context has: using one proves the Workflow durable.
7
+ const DURABLE_CONTEXT_MEMBERS = new Set(['awaitSignal', 'awaitExecution', 'cancelled', 'sleep']);
8
+ const AUTHORITIES = new Set(['caller', 'self']);
9
+ // Raw Kernel graph reads a Step's `kernel` offers beside `mutate`.
10
+ const KERNEL_READS = new Set(['query', 'get', 'getOrThrow', 'neighbors']);
11
+ // Array methods that run their callback once per element.
12
+ const ITERATING_METHODS = new Set([
13
+ 'every',
14
+ 'filter',
15
+ 'find',
16
+ 'findIndex',
17
+ 'findLast',
18
+ 'findLastIndex',
19
+ 'flatMap',
20
+ 'forEach',
21
+ 'map',
22
+ 'reduce',
23
+ 'reduceRight',
24
+ 'some',
25
+ ]);
6
26
  export const workflowRules = [
7
27
  {
8
28
  id: 'FNC-INT-TYPES',
@@ -110,7 +130,387 @@ export const workflowRules = [
110
130
  return evidence;
111
131
  },
112
132
  },
133
+ {
134
+ id: 'FNC-STEP-READS',
135
+ ruleRevision: '16b3a7c85214d5c0c6cfaede5099c16223da1c3fd98dec9781910634bab89343',
136
+ evaluate(project) {
137
+ const evidence = [];
138
+ for (const step of durableSteps(project, evidence)) {
139
+ const operations = stepOperations(project, step);
140
+ const effects = operations.filter(({ kind }) => kind === 'effect');
141
+ const reads = operations.filter((operation) => operation.kind === 'observation' &&
142
+ effects.some((effect) => precedes(operation, effect, step.callback)));
143
+ if (reads.length === 0)
144
+ continue;
145
+ evidence.push(violation(step.file, step.call, `Durable step ${step.label} reads (${names(reads)}) before it writes (${names(effects)}); a retry after its write would read that write. Read in an earlier step.`));
146
+ }
147
+ return evidence;
148
+ },
149
+ },
150
+ {
151
+ id: 'FNC-EFFECT-STEP',
152
+ ruleRevision: 'edadc22d3dbe2d35a4e8c0c341245808cb2d9f4fb1accf953a05f6162956bea1',
153
+ evaluate(project) {
154
+ const evidence = [];
155
+ for (const step of durableSteps(project, evidence)) {
156
+ const effects = stepOperations(project, step).filter(({ kind }) => kind === 'effect');
157
+ // An effect runs again when it sits in a loop or two of its traces can run in one run.
158
+ const again = (effect) => effect.traces.some((trace) => trace.some((node) => repeated(node, step.callback))) ||
159
+ together(effect.traces, effect.traces, step.callback);
160
+ const involved = effects.filter((effect) => again(effect) ||
161
+ effects.some((other) => other !== effect && together(effect.traces, other.traces, step.callback)));
162
+ if (involved.length === 0)
163
+ continue;
164
+ const listed = involved
165
+ .map((effect) => (again(effect) ? `${effect.name} repeatedly` : effect.name))
166
+ .join(', ');
167
+ evidence.push(violation(step.file, step.call, `Durable step ${step.label} performs several effects (${listed}); if one fails after another committed, the Workflow cannot tell. Give each effect its own step.`));
168
+ }
169
+ return evidence;
170
+ },
171
+ },
172
+ {
173
+ id: 'FNC-STEP-RETRY',
174
+ ruleRevision: 'fefbd4cb783e08b0dfe49788ff036ecff61da9190fd1b64152f92ef3a254a195',
175
+ evaluate(project) {
176
+ const evidence = [];
177
+ for (const step of durableSteps(project, evidence)) {
178
+ for (const operation of stepOperations(project, step)) {
179
+ if (operation.kind !== 'unkeyed')
180
+ continue;
181
+ evidence.push(violation(step.file, operation.node, `Durable step ${step.label} calls ${operation.name}, which runs again when the step is retried; make it idempotent, declare the callee durable, or move it out of the durable Workflow.`));
182
+ }
183
+ }
184
+ return evidence;
185
+ },
186
+ },
113
187
  ];
188
+ /**
189
+ * The `step.run` callbacks of every Workflow its source proves durable: it uses a member only the
190
+ * durable context has, `step.query` or `step.mutate`, or a Step callback that receives
191
+ * capabilities. An inline Workflow never retries a step and is not inspected.
192
+ */
193
+ function durableSteps(project, evidence) {
194
+ const steps = [];
195
+ for (const file of production(project, 'functions')) {
196
+ const helpers = localFunctions(file.source);
197
+ for (const definition of workflowDefinitions(file)) {
198
+ if (definition.origin === 'ambiguous') {
199
+ evidence.push(ambiguity(file, definition.call, 'Workflow definition resolves through a local facade whose ultimate public constructor origin is unknown.'));
200
+ continue;
201
+ }
202
+ const { run } = definition;
203
+ if (!run)
204
+ continue;
205
+ const roots = stepRoots(run);
206
+ const runs = [];
207
+ let durable = usesDurableContext(run);
208
+ visitOwnBody(run, (node) => {
209
+ if (!ts.isCallExpression(node))
210
+ return;
211
+ const method = stepMethod(node, roots);
212
+ if (method === 'query' || method === 'mutate')
213
+ durable = true;
214
+ if (method !== 'run')
215
+ return;
216
+ const callback = node.arguments[1] && stepRunCallback(node.arguments[1], helpers);
217
+ if (!callback)
218
+ return;
219
+ if (callback.parameters.length > 0)
220
+ durable = true;
221
+ const id = staticId(node.arguments[0]);
222
+ runs.push({ file, call: node, label: id ?? 'with a dynamic id', callback });
223
+ });
224
+ if (durable)
225
+ steps.push(...runs);
226
+ }
227
+ }
228
+ return steps;
229
+ }
230
+ /**
231
+ * A `step.run` callback written inline or named by one local function. Any other is not inspected;
232
+ * FNC-NO-NEST reports it as ambiguous.
233
+ */
234
+ function stepRunCallback(argument, helpers) {
235
+ const value = unwrap(argument);
236
+ if (ts.isArrowFunction(value) || ts.isFunctionExpression(value))
237
+ return value;
238
+ if (!ts.isIdentifier(value))
239
+ return undefined;
240
+ const candidates = helpers.get(value.text) ?? [];
241
+ return candidates.length === 1 ? candidates[0] : undefined;
242
+ }
243
+ function usesDurableContext(run) {
244
+ const parameter = run.parameters[0]?.name;
245
+ if (parameter && ts.isObjectBindingPattern(parameter)) {
246
+ return parameter.elements.some((element) => {
247
+ const name = element.propertyName ?? element.name;
248
+ return ts.isIdentifier(name) && DURABLE_CONTEXT_MEMBERS.has(name.text);
249
+ });
250
+ }
251
+ if (!parameter || !ts.isIdentifier(parameter) || !run.body)
252
+ return false;
253
+ let found = false;
254
+ visit(run.body, (node) => {
255
+ if (ts.isPropertyAccessExpression(node) &&
256
+ DURABLE_CONTEXT_MEMBERS.has(node.name.text) &&
257
+ contextPath(node, run)?.length === 1)
258
+ found = true;
259
+ });
260
+ return found;
261
+ }
262
+ /**
263
+ * Operations of one step whose kind is provable, with the traces that run them. An operation of
264
+ * unprovable kind, or in a local helper the step never mentions, is omitted.
265
+ */
266
+ function stepOperations(project, step) {
267
+ const operations = [];
268
+ const body = step.callback.body;
269
+ if (!body)
270
+ return operations;
271
+ visit(body, (node) => {
272
+ if (!ts.isCallExpression(node))
273
+ return;
274
+ const operation = callOperation(project, step, node);
275
+ if (!operation)
276
+ return;
277
+ const traces = runTraces(node, step.callback);
278
+ if (traces.length > 0)
279
+ operations.push({ ...operation, traces });
280
+ });
281
+ return operations;
282
+ }
283
+ function callOperation(project, step, node) {
284
+ if (globalCallName(step.file, node) === 'fetch')
285
+ return { kind: 'unkeyed', node, name: 'fetch' };
286
+ const path = contextPath(node.expression, step.callback);
287
+ return path && capabilityOperation(project, step.file, node, path);
288
+ }
289
+ /**
290
+ * The traces through which the step callback reaches `node`: the node itself, or, inside a local
291
+ * helper bound to a name, each mention of that name followed by the node.
292
+ */
293
+ function runTraces(node, callback, active = new Set()) {
294
+ for (let current = node.parent; current && current !== callback; current = current.parent) {
295
+ const name = ts.isFunctionLike(current) ? helperName(current) : undefined;
296
+ if (!name)
297
+ continue;
298
+ if (active.has(current))
299
+ return [];
300
+ active.add(current);
301
+ const traces = mentions(name, callback)
302
+ .filter(invokes)
303
+ .flatMap((mention) => runTraces(mention, callback, active).map((trace) => [...trace, node]));
304
+ active.delete(current);
305
+ return traces;
306
+ }
307
+ return [[node]];
308
+ }
309
+ function helperName(fn) {
310
+ const name = ts.isFunctionDeclaration(fn)
311
+ ? fn.name
312
+ : (ts.isArrowFunction(fn) || ts.isFunctionExpression(fn)) &&
313
+ ts.isVariableDeclaration(fn.parent) &&
314
+ fn.parent.initializer === fn
315
+ ? fn.parent.name
316
+ : undefined;
317
+ return name && ts.isIdentifier(name) ? name : undefined;
318
+ }
319
+ /**
320
+ * Whether a mention of a helper runs it: the helper is called, or handed to an iterating Array
321
+ * method as its callback. A helper only referenced, returned or stored is not known to run.
322
+ */
323
+ function invokes(mention) {
324
+ const parent = mention.parent;
325
+ if (!ts.isCallExpression(parent))
326
+ return false;
327
+ return parent.expression === mention || iteratingCallback(mention);
328
+ }
329
+ /** Whether `node` is the callback, the first argument, of an iterating Array method call. */
330
+ function iteratingCallback(node) {
331
+ const parent = node.parent;
332
+ return (parent !== undefined &&
333
+ ts.isCallExpression(parent) &&
334
+ parent.arguments[0] === node &&
335
+ ITERATING_METHODS.has(propertyChain(parent.expression)?.at(-1) ?? ''));
336
+ }
337
+ /** The identifiers of `scope` other than `name` itself that refer to its text, not as a member. */
338
+ function mentions(name, scope) {
339
+ const found = [];
340
+ visit(scope, (node) => {
341
+ if (node === name || !ts.isIdentifier(node) || node.text !== name.text)
342
+ return;
343
+ const parent = node.parent;
344
+ if ((ts.isPropertyAccessExpression(parent) || ts.isPropertyAssignment(parent)) &&
345
+ parent.name === node)
346
+ return;
347
+ found.push(node);
348
+ });
349
+ return found;
350
+ }
351
+ function capabilityOperation(project, file, node, path) {
352
+ const name = path.join('.');
353
+ const method = path.at(-1);
354
+ const selected = (parts) => parts.length === 0 || (parts.length === 1 && AUTHORITIES.has(parts[0]));
355
+ if (path.length === 1 && (method === 'query' || method === 'mutate')) {
356
+ return { kind: method === 'query' ? 'observation' : 'effect', node, name };
357
+ }
358
+ if (path[0] === 'graph' && selected(path.slice(1, -1))) {
359
+ if (method === 'query')
360
+ return { kind: 'observation', node, name };
361
+ if (method === 'mutate')
362
+ return { kind: 'effect', node, name };
363
+ return undefined;
364
+ }
365
+ if (path[0] === 'kernel' && selected(path.slice(1, -1))) {
366
+ if (KERNEL_READS.has(method))
367
+ return { kind: 'observation', node, name };
368
+ if (method === 'mutate')
369
+ return { kind: 'effect', node, name };
370
+ if (method !== 'invoke')
371
+ return undefined;
372
+ const target = node.arguments[0] && unwrap(node.arguments[0]);
373
+ if (target &&
374
+ (ts.isStringLiteralLike(target) ||
375
+ ts.isTemplateExpression(target) ||
376
+ stringTyped(project, file, target))) {
377
+ return { kind: 'unkeyed', node, name: `${name} of an untyped Path` };
378
+ }
379
+ return invocation(project, file, node, name);
380
+ }
381
+ if (path[0] === 'dependencies' && path.length === 4 && AUTHORITIES.has(path[2])) {
382
+ return method === 'invoke' ? invocation(project, file, node, name) : undefined;
383
+ }
384
+ return undefined;
385
+ }
386
+ /**
387
+ * A call the types prove durable answers with its Execution and carries the step's key; one they
388
+ * prove ordinary carries none. Without types, or with an unresolved result, the kind is unprovable.
389
+ */
390
+ function invocation(project, file, node, name) {
391
+ const resolved = expressionType(project, file, node);
392
+ if (resolved === undefined)
393
+ return undefined;
394
+ const output = resolved.checker.getAwaitedType(resolved.type) ?? resolved.type;
395
+ const kinds = new Set((output.isUnion() ? output.types : [output]).map(resultKind));
396
+ if (kinds.size !== 1)
397
+ return undefined;
398
+ const [kind] = kinds;
399
+ if (kind === 'durable')
400
+ return { kind: 'effect', node, name };
401
+ if (kind === 'ordinary') {
402
+ return { kind: 'unkeyed', node, name: `${name} of a callable that is not durable` };
403
+ }
404
+ return undefined;
405
+ }
406
+ /** Whether the types prove `expression` a string, which only an untyped Path is. */
407
+ function stringTyped(project, file, expression) {
408
+ const resolved = expressionType(project, file, expression);
409
+ if (resolved === undefined)
410
+ return false;
411
+ const types = resolved.type.isUnion() ? resolved.type.types : [resolved.type];
412
+ return types.every((type) => (type.flags & ts.TypeFlags.StringLike) !== 0);
413
+ }
414
+ function resultKind(type) {
415
+ if (type.flags &
416
+ (ts.TypeFlags.Any |
417
+ ts.TypeFlags.Unknown |
418
+ ts.TypeFlags.Never |
419
+ ts.TypeFlags.TypeParameter |
420
+ ts.TypeFlags.Conditional |
421
+ ts.TypeFlags.IndexedAccess)) {
422
+ return 'unprovable';
423
+ }
424
+ return (type.aliasSymbol ?? type.getSymbol())?.getName() === 'ExecutionRef'
425
+ ? 'durable'
426
+ : 'ordinary';
427
+ }
428
+ /**
429
+ * Whether some run of the step can reach `read` before `effect` completes. Two traces are ordered
430
+ * where they part, in source order: a read that ends first precedes the effect or builds its
431
+ * arguments, unless both sit in the step's own body and take exclusive branches. Inside a helper no
432
+ * branch is exclusive, since each call may take another. A read after the effect sees the same
433
+ * committed write on every attempt.
434
+ */
435
+ function precedes(read, effect, callback) {
436
+ return read.traces.some((first) => effect.traces.some((second) => before(first, second, callback)));
437
+ }
438
+ /** Whether one run of the step can reach two distinct traces, one from each list. */
439
+ function together(traces, others, callback) {
440
+ return traces.some((trace) => others.some((other) => other !== trace && (before(trace, other, callback) || before(other, trace, callback))));
441
+ }
442
+ /** Whether a run can reach the end of `first` before `second` completes, by the order above. */
443
+ function before(first, second, callback) {
444
+ const index = first.findIndex((node, position) => node !== second[position]);
445
+ const left = first[index];
446
+ const right = second[index];
447
+ if (!left || !right)
448
+ return false;
449
+ return left.end < right.end && !exclusive(left, right, callback);
450
+ }
451
+ /**
452
+ * Whether no run of the step reaches `effect` after `read`: both sit directly in the callback, and
453
+ * they take the two branches of one condition outside any loop, or `read` sits in a branch that
454
+ * returns or throws without `effect`.
455
+ */
456
+ function exclusive(read, effect, callback) {
457
+ if (owner(read) !== callback || owner(effect) !== callback)
458
+ return false;
459
+ for (let node = read; node.parent && node !== callback.body; node = node.parent) {
460
+ const parent = node.parent;
461
+ if (ts.isIfStatement(parent) && node !== parent.expression) {
462
+ const other = node === parent.thenStatement ? parent.elseStatement : parent.thenStatement;
463
+ if (other && within(effect, other) && !repeated(parent, callback))
464
+ return true;
465
+ if (exits(node) && !within(effect, node))
466
+ return true;
467
+ }
468
+ if (ts.isConditionalExpression(parent) && node !== parent.condition) {
469
+ const other = node === parent.whenTrue ? parent.whenFalse : parent.whenTrue;
470
+ if (within(effect, other) && !repeated(parent, callback))
471
+ return true;
472
+ }
473
+ }
474
+ return false;
475
+ }
476
+ /**
477
+ * A site the step may run more than once: in a loop, or in or as the callback of an iterating
478
+ * Array method.
479
+ */
480
+ function repeated(node, callback) {
481
+ for (let current = node; current && current !== callback; current = current.parent) {
482
+ if (current !== node && ts.isIterationStatement(current, false))
483
+ return true;
484
+ if (iteratingCallback(current))
485
+ return true;
486
+ }
487
+ return false;
488
+ }
489
+ /** A statement whose every run ends in `return` or `throw`. */
490
+ function exits(statement) {
491
+ if (ts.isReturnStatement(statement) || ts.isThrowStatement(statement))
492
+ return true;
493
+ if (ts.isBlock(statement)) {
494
+ const last = statement.statements.at(-1);
495
+ return last !== undefined && exits(last);
496
+ }
497
+ return (ts.isIfStatement(statement) &&
498
+ statement.elseStatement !== undefined &&
499
+ exits(statement.thenStatement) &&
500
+ exits(statement.elseStatement));
501
+ }
502
+ function owner(node) {
503
+ let current = node.parent;
504
+ while (current && !ts.isFunctionLike(current))
505
+ current = current.parent;
506
+ return current;
507
+ }
508
+ function within(node, container) {
509
+ return node.pos >= container.pos && node.end <= container.end;
510
+ }
511
+ function names(operations) {
512
+ return operations.map(({ name }) => name).join(', ');
513
+ }
114
514
  function workflowDefinitions(file) {
115
515
  return calls(file, 'defineWorkflow').map(({ call: factory, origin }) => {
116
516
  const call = ts.isCallExpression(factory.parent) && factory.parent.expression === factory
@@ -1,7 +1,7 @@
1
1
  /** Generated from the validated Domain knowledge catalog. Regenerate with pnpm sync:linter-policy. */
2
- export const domainPolicyDigest = 'ce31a59799452872e589077b6f4d2d42ecb55123f1ec375bc5aedcbf785c2166';
2
+ export const domainPolicyDigest = '56731cb428490cfb402a16d3c11e64b7bdd6b5563a4da13dbdffa37ee7e6a7c1';
3
3
  export const domainPolicySource = Object.freeze({
4
- rules: "id\tscope\tkind\tseverity\tmessage\tverification\texample\nOWN-SEMANTIC\townership\tarchitecture\terror\tEvery semantic fact, rule, representation, transition, and failure meaning has exactly one owner\tInventory declarations by meaning and report each duplicate authority or ownerless concept\tsemantic-owner.md\nMOD-SUBMODULE\tmodules\tstructure\terror\tEvery semantic source file lives in a dedicated semantic submodule or its registered layer facade\tClassify every layer-root source file and report files outside the registered facade or public index\tsemantic-owner.md\nMOD-REQUIRED\tmodules\tstructure\terror\tEvery required layer and root file declared by the injected layout exists\tCompare admitted project entries with required layout entries and report each missing path\trequired-layout.md\nMOD-GOVERNED\tmodules\tstructure\terror\tEvery source file admitted by the Domain compilation scope belongs to a declared layer or supported root\tClassify admitted source paths after declared workspace and tooling delegation and report each unowned path\tgoverned-source.md\nROOT-FACADE\troots\tstructure\terror\tEvery registered layer facade is exposed through a curated public index\tInspect each layer index and facade and report private-owner behavior or misplaced facade declarations\tpackage-facade.md\nROOT-COMPOSE\troots\tstructure\terror\tPackage roots compose only policy-backed Schema, Runtime, frontend deployment, native Routes, Provider-backed Integrations, and supported package journeys\tInspect declared composition and package roots and report behavior, provider protocol logic, recursive barrels, or unsupported exports\tcomposition-root.md\nROOT-PACKAGE\troots\tevidence\terror\tEvery public Schema package subpath maps one admitted source entrypoint to its deterministic published declaration and JavaScript targets\tCompare source and publish exports and reject missing duplicate non-Schema locally linked generated or Kernel-leaking package artifacts\tmulti-domain-package.md\nDEP-ALLOWLIST\tdependencies\tdependency\terror\tEvery direct cross-layer import and its runtime or type-only kind appears in the dependency allowlist and dependencies between distinct layers are acyclic\tResolve source imports, reject every absent or kind-mismatched edge, and detect cycles after excluding evidence edges\tsemantic-owner.md\nIMP-FACADE\timports\tdependency\terror\tEvery cross-submodule import uses the semantic owner's facade and every foreign Domain import uses its public package facade\tResolve imports and report private deep paths outside the importing submodule\tcross-domain.md\nIMP-SDK-BOUNDARY\timports\tdependency\terror\tDomain source imports Kernel Core and DSL authoring values only through semantic SDK subpaths\tInspect every static and literal dynamic import and report module specifiers rooted at @astrale-os/kernel-core or @astrale-os/kernel-dsl\tsdk-boundary.md\nIMP-LAYER-ALIAS\timports\tdependency\terror\tEvery local import crossing a layer or semantic-submodule boundary uses the registered # layer alias\tResolve relative imports and report each one whose target leaves the importing semantic submodule\tlayer-aliases.md\nIMP-ALIAS-CFG\timports\tdependency\terror\tPackage and TypeScript resolution exactly implement each active layer-facade and semantic-submodule alias\tCompare active and required layers with the injected alias registry and report missing, undeclared, or drifted mappings\talias-configuration.md\nIMP-STATIC\timports\tdependency\terror\tProduction dependency edges use analyzable static ESM declarations or literal import calls\tReject require calls, import-equals declarations, nonliteral import calls, and unresolved static dependency forms\tstatic-imports.md\nTYP-OWNER\ttypes\tarchitecture\terror\tEvery type and reusable expected error is colocated with the semantic concept that defines its meaning\tTrace each declaration to its semantic authority and report catch-all or remotely owned values\texpected-failure.md\nERR-EXPECTED\terrors\tdataflow\terror\tBoundaries map only declared expected failures and propagate unexpected defects\tInspect catches and result mappings and report broad fallback, swallowed defects, or mappings without a declared source failure\texpected-failure.md\nTST-NO-PROD-IMP\ttests\tdependency\terror\tProduction source imports no root or colocated Test artifact\tResolve production imports and report targets under Root Tests, __tests__, or test, spec, bench, and perf source files\ttest-import-boundary.md\nABS-EARNED\tabstractions\tarchitecture\terror\tAn invariant or real boundary earns an abstraction; reuse alone requires two independent consumers and no duplicated semantic behavior\tIdentify the invariant, boundary, or independent consumers for each abstraction and report reuse wrappers that duplicate an owner's semantics\tsemantic-owner.md\nABS-NO-REPO\tabstractions\tarchitecture\terror\tDomain source places no collection-shaped persistence facade between business code and canonical Query or Mutation definitions\tInspect persistence-facing contracts and report abstractions that replace graph identity, traversal, observation, or atomic change semantics\tsemantic-owner.md\nABS-CANON-GRAPH\tabstractions\tdeclaration\terror\tDomain source declares no alternate Query or Mutation language, AST, compiler, planner, or wire representation\tInspect graph-related declarations and report semantics not identical to canonical Kernel Query or Mutation values\tsemantic-owner.md\nTRUST-ADMIT-ONCE\ttrust\tdataflow\terror\tEvery untrusted value is admitted or translated exactly once at its owning boundary\tTrace values from each external boundary and report missing admission or repeated structural validation\texpected-failure.md\nQLT-EXHAUSTIVE\tquality\tbehavior\terror\tEvery closed alternative is handled exhaustively and no required failure becomes placeholder success\tTrace closed unions and failure paths and report permissive defaults, placeholder success, or catch-and-continue behavior\texpected-failure.md\nQLT-CANON-VALUES\tquality\tdataflow\terror\tNo unchecked cast fabricates a canonical Kernel identity, QueryAST, MutationAST, or admitted schema value\tScan casts to canonical values and require an owning constructor or decoder for each\tsemantic-owner.md\nQLT-DEF-IDS\tquality\tdeclaration\terror\tEvery top-level Query and Mutation definition has a stable literal ID unique in its owning namespace\tExtract top-level definition IDs and report missing, dynamic, malformed, or duplicate values\tdefinition-identities.md\nQLT-TYPED-COORD\tquality\tdeclaration\terror\tQueries and Mutations derive graph coordinates from resolved DSL definitions instead of raw string or structural reconstruction\tReject raw PropertyKey calls and structural ClassPath objects; require canonical resolved Classes Properties and keys at graph boundaries\ttyped-coordinates.md\nNODE-INHERITED\tnodes\tdeclaration\terror\tNo Node Class redeclares name, description, createdAt, or updatedAt inherited from Named, Descriptable, and Timestamped\tScan Node Class Properties and report each inherited field redeclaration\tsemantic-owner.md\nDOM-PUBLIC-DEPS\tdomains\tdependency\terror\tEvery directly referenced foreign-Domain graph declaration has one exact Schema dependency\tResolve foreign Schema, Query, and Mutation graph references and report each package without one exact declared Schema dependency\tcross-domain.md\nDOM-CALL-DECLARED\tdomains\tdependency\terror\tCross-Domain calls use exact declared public Schema dependencies and typed invocation; Integrations are optional consumer-owned boundaries\tTrace remote invocations and reject undeclared targets, private imports, forged references, and missing exact Domain Function requirements\tremote-domain-call.md\nDOM-ATOMICITY\tdomains\tbehavior\terror\tA cross-Domain change claims atomicity only when it is one MutationAST on one graph; calls combined with other effects are Workflow steps\tTrace atomicity and effect claims and report multiple commits, service boundaries, or foreign calls combined in a Action\tcross-domain.md\nSCH-SUBMODULE\tschema\tstructure\terror\tEvery Schema source path belongs to the registered facade, one canonical shared declaration kind, or one business-module facade or canonical declaration kind\tClassify admitted Schema source paths including shared and module-owned errors directories and report flat files or source-bearing directories outside the canonical Schema vocabulary\tschema-facade.md\nSCH-ONE-DECL\tschema\tdeclaration\terror\tEvery Schema declaration leaf file exports exactly one locally authored declaration of its directory kind and every declaration-kind index is a curated facade\tInspect runtime exports in Classes, Functions, Policies, States, and Views; resolve canonical SDK constructor origins and report zero, several, re-exported, aggregated, wrong-kind, or index-owned values\tdeclaration-file.md\nSCH-DECL-ONLY\tschema\tdeclaration\terror\tSchema performs no handler execution, Query execution, Mutation submission, Integration call, Workflow step, or Provider call\tResolve Schema imports and call graphs and require zero excluded operations\tpublication-callables.md\nSCH-EXACT-TYPES\tschema\tdeclaration\terror\tSchema authoring values preserve their exact inferred DSL types instead of widening to generic builder contracts\tScan Schema declarations and action returns for explicit generic builder authoring annotations\tschema-facade.md\nSCH-ICON-REQUIRED\tschema\tdeclaration\terror\tEvery Node Class must explicitly declare one admitted SVG icon\tInspect each SDK nodeClass and Node-kind defineClass declaration and report statically proven missing icon values while preserving opaque configurations as indeterminate\tclass-icon.md\nSCH-ICON-NEUTRAL\tschema\tdeclaration\twarning\tEvery neutral Node Class icon should be replaced with a meaningful icon\tInspect each SDK nodeClass and Node-kind defineClass declaration and report explicit classIcon.neutral or exact neutral SVG values\tclass-icon.md\nSCH-POLICY-AUTH\tschema\tdeclaration\terror\tCallable authority and existential Node scope are declared explicitly through Policy and Action implementations add no private authorization rule\tTrace callable admission and existential Node binders; report hidden authority or an ambiguous Node extent\tpolicy.md\nSCH-POLICY-NAME\tschema\tdeclaration\twarning\tEvery Policy is named as the sentence its subject completes, in the Domain's words: each business hop to the object in order, the object last\tRead each Policy name against its match and report a permission prefix such as can or may, a graph mechanics word such as source, target, sub, super, subject, object, or caller, or a business hop of the match the name omits\tpolicy.md\nSCH-STATE-SOURCE\tschema\tdeclaration\terror\tEvery persisted StateMachine vocabulary originates from an exported authority in the same Schema business module rather than a copied literal set\tResolve exact StateMachine and stateProperty origins; report same-owner copied literals and reject cross-module association\tarticle-schema.md\nSCH-STATE-RELATION\tschema\tdeclaration\terror\tEvery StateMachine is one exported static immutable finite relation without parallel vocabulary authorities\tInspect Schema module machines and exported sibling values for split or copied topology\tarticle-status.md\nSCH-STATE-PURE\tschema\tdeclaration\terror\tStateMachine topology contains no behavior, effects, guards, clocks, retry, recovery, or orchestration\tInspect files that declare StateMachine authorities for behavioral exports, boundary imports, and effectful calls\tstate-pure.md\nRUL-SYNC\trules\tbehavior\terror\tEvery Rule is synchronous and returns no Promise, continuation, generator, or asynchronous iterator\tInspect Rule signatures and result types and reject asynchronous forms\tnormalization.md\nRUL-PURE\trules\tbehavior\terror\tRules perform no I/O and depend on no graph executor or Domain execution boundary\tResolve imports and effect origins, permitting pure standard value transformations while reporting conclusive I/O and Domain execution dependencies\tpublish-eligibility.md\nRUL-EXPL-FACTS\trules\tbehavior\terror\tEvery clock value, random value, identity, limit, and environmental observation used by a Rule is an explicit input\tTrace every value source and report reads from ambient state, globals, process state, or hidden singletons\ttime-facts.md\nRUL-CLOSED-DEC\trules\tbehavior\terror\tEvery expected business alternative is represented by a closed decision value rather than thrown control flow\tInspect Rule branches and report expected alternatives represented by exceptions or open optional fields\tpublish-eligibility.md\nQRY-CANON\tqueries\tdataflow\terror\tEvery graph request produced by a Query definition is one canonical QueryAST built through Kernel Query APIs\tTrace request construction and reject every non-canonical graph document\tfiltered-query.md\nQRY-CONTRACT\tqueries\tdataflow\terror\tA Query owns its input, observation, optional business projection, pagination, and expected failures\tInspect each Query definition and report a required concern owned elsewhere or omitted\tquery-transforms.md\nQRY-SINGLE\tqueries\tdataflow\terror\tEvery authored single Query definition declares exactly one build callback and at most one project callback\tInspect definition properties and canonical roots; report opaque helper origins as ambiguity rather than assuming cardinality\tsingle-query.md\nQRY-COMPOSE-TYPED\tqueries\tdataflow\terror\tA composite Query constructs one closed QueryPlan containing only typed single-Query leaves, symbolic output references, and explicit result composition\tInspect plan construction, report unresolved call origins as ambiguity, and reject nested composites, raw sessions, graph clients, result-time callbacks, arbitrary promises, or Domain effects\tdependent-query.md\nQRY-COMPOSE-STABLE\tqueries\tdeclaration\terror\tEvery composite Query leaf has a stable semantic literal ID unique within its definition\tInspect declared Query leaves and reject dynamic, malformed, or duplicate leaf identifiers\tdependent-query.md\nQRY-COLL-FANOUT\tqueries\tdataflow\twarning\tThree or more independent same-kind complete-Class collection leaves use one explicit query.union group\tInfer collection kind from canonical definition types and print the direct named replacement plus logical and physical plan counts\tcollection-union.md\nQRY-PROJECT-PURE\tqueries\tdataflow\terror\tEvery Query project callback is synchronous and performs only pure value transformation\tInspect project callback syntax and call graphs and report asynchronous continuation, I/O, mutation, nondeterminism, hidden query execution, or effects\tprojection.md\nQRY-SNAPSHOT\tqueries\tdataflow\terror\tA composite or paginated Query makes no point-in-time graph snapshot claim beyond one Kernel invocation\tReject shared-snapshot claims across leaves unions or continuations and route stronger consistency to an explicit Kernel facility\tdependent-query.md\nMUT-PLAN-REQ\tmutations\tdependency\terror\tEvery identity operation and foreign Mutation plan declares the exact Kernel Function and foreign Class authority it uses\tInspect SDK MutationAST builders and Kernel Provision or Register calls and match every foreign Class operation and identity syscall invocation to Domain requirements\tprovision-plan.md\nMUT-LOCAL-ALIAS\tmutations\tdeclaration\terror\tEvery literal Mutation createNode alias is a canonical local binding accepted by the Kernel\tInspect statically resolved createNode as values and reject invalid local binding literals before runtime\tatomic-mutation.md\nMUT-CANON\tmutations\tdataflow\terror\tEvery Mutation definition builds one synchronous change through the canonical builder and constructs no alternate or nested graph document\tInspect every definition build callback and reject missing, asynchronous, alternate, or nested Mutation construction\tatomic-mutation.md\nMUT-CONTRACT\tmutations\tdataflow\terror\tA Mutation owns its input, preconditions, operations, optional business projection, and expected failures\tInspect each definition and report required mutation semantics owned elsewhere or omitted\tcreate-aggregate.md\nMUT-PRECONDS\tmutations\tdataflow\terror\tRules decide eligibility and every live graph condition required for safety is encoded as a precondition in the same MutationAST\tMap decisions to preconditions and report duplicated eligibility or safety enforced only by an earlier observation\tconditional-update.md\nMUT-FRAGMENTS\tmutations\tdataflow\terror\tReusable fragments receive the callback-scoped MutationBuilder and contribute only to the same MutationAST\tResolve fragment signatures and calls and reject escaped builders, opaque documents, or nested MutationAST construction\tmutation-fragments.md\nMUT-PURE\tmutations\tdataflow\terror\tMutation definitions perform no session call, external effect, retry, compensation, or second submission\tScan definition call graphs and require zero excluded operations\tedge-change.md\nMUT-MULTI-WFL\tmutations\tdataflow\terror\tA change requiring several MutationAST values is a Workflow and is never exposed as one atomic Mutation\tTrace multi-commit changes and report definitions or names claiming single-mutation atomicity\tdelete-node.md\nMUT-STATE-INITIAL\tmutations\tdataflow\terror\tEvery StateMachine-backed node is created from its machine's initial state\tResolve machine-backed Property initializers and require the canonical machine.initial value rather than a copied state literal\tstate-transition.md\nMUT-STATE-ATOMIC\tmutations\tdataflow\terror\tEvery persisted machine-state change consumes one allowed decision and commits its stale-state precondition and update in the same MutationAST\tInspect machine-backed writes and require transition with the canonical Schema module machine and one allowed decision; reject direct target writes and split precondition updates\tstate-transition.md\nFNC-ONE-IMPL\tfunctions\tbehavior\terror\tEvery registered handler binding resolves to exactly one implementation owned by one semantic Functions submodule\tResolve the handler registry and report non-Action owners or duplicate registrations; SDK typing owns callable exhaustiveness\tsynchronous-result.md\nFNC-ONE-EFFECT\tfunctions\tbehavior\terror\tEvery Action performs at most one effect, as its terminal operation; the Queries and read-only calls it needs precede that effect\tTrace every path and report two effects, an operation after the effect, or hidden orchestration\tmutation-operation.md\nFNC-OP-KINDS\tfunctions\tbehavior\terror\tA semantic asynchronous operation is one Query, Mutation, Integration call, dependency invocation, or canonical Kernel operation; a Query or a call that changes no state is an observation, every other operation is an effect\tClassify every awaited operation including dependency and Kernel calls as an observation or an effect; report undeclared kinds and hidden multiple effects\tintegration-operation.md\nFNC-BOUNDARIES\tfunctions\tbehavior\terror\tHandlers use self-default kernel graph query and mutate capabilities, explicit-authority direct dependencies, and optional declared Integrations; explicit Kernel and graph authority modes are available\tInspect context use, authority selection, dependencies, imports and failure mapping; reject raw unbound graph executors, foreign handler imports, implicit authority changes and swallowed defects\tremote-integration.md\nFNC-BINARY-RESULT\tfunctions\tbehavior\terror\tA binary Action returns detached buffered bytes or streaming bytes with admitted media type status and application headers without collecting or value-framing a provider stream\tExercise buffered and streaming results through their native route; verify exact bytes status headers cancellation and invalid output rejection\tnative-byte-response.md\nFNC-MULTISTEP\tfunctions\tbehavior\terror\tEvery Workflow definition contains at least two effect sites that cannot commit together\tInventory effect sites in the definition and report fewer than two or effects one Mutation could commit; early exit, rejection, and recovery paths may execute fewer\tpublication-workflow.md\nFNC-STEP-EFFECTS\tfunctions\tbehavior\terror\tEvery semantic asynchronous operation maps to one named step: step.run, or the durable step.query and step.mutate shorthands\tTrace operations and report each one outside a named step\tpublication-workflow.md\nFNC-STEP-IDS\tfunctions\tbehavior\terror\tEvery step identifier is a stable non-empty kebab-case literal unique within its Workflow\tExtract step identifiers and reject dynamic, malformed, empty, or duplicate values\tpublication-workflow.md\nFNC-NO-NEST\tfunctions\tbehavior\terror\tNo step.run callback starts another step, whether step.run, step.query or step.mutate, directly or through a reachable helper\tInspect callback call graphs and report every nested step path\tpublication-workflow.md\nFNC-INT-TYPES\tfunctions\tdeclaration\terror\tWorkflow Integration requirements derive from declared Integration definitions and the SDK projects their clients\tReject Workflow-owned operation interfaces and require its definition generic to reference the declared Integration registry\tcross-domain-workflow.md\nFNC-ONE-OP-STEP\tfunctions\tbehavior\terror\tEvery step owns exactly one semantic asynchronous operation, an observation or an effect; an effect step builds its request only from the Workflow input and earlier step results\tTrace each step and report zero or several operations, or an effect whose request depends on an observation made in the same step\tpublication-workflow.md\nFNC-STATE-CODEC\tfunctions\tbehavior\terror\tEvery step result and inter-step value is undefined or portable JSON data\tInspect step values and report actions, clients, symbols, bigint, cycles, or class instances\tpublication-workflow.md\nFNC-RECOVERY\tfunctions\tbehavior\terror\tWhen compensation or unknown-outcome branches exist, they are explicit and rely only on declared operation semantics\tInspect existing recovery branches and report guessed outcomes or compensation without exact evidence\tpublication-workflow.md\nFNC-XDOM-DECLARED\tfunctions\tbehavior\terror\tActions and Workflows invoke direct declared Domain dependencies through explicit-authority dependency invokers or canonical typed kernel.invoke references and import no foreign handler\tResolve handler imports, direct dependency aliases, explicit caller/self authority, selectors, and typed references; reject foreign imports, implicit or chained authority, undeclared aliases and forged references, and report opaque bindings as indeterminate\tcross-domain-workflow.md\nFNC-XDOM-REQ\tfunctions\tbehavior\terror\tEvery selected remote callable has one exact Domain Function requirement including its defining Class and static or instance kind\tCompare each statically selected remote callable with exact Domain Function requirements; report missing requirements and mark opaque selectors or requirement lists indeterminate\tcross-domain-workflow.md\nINT-BOUNDARY\tintegrations\tarchitecture\terror\tEvery Integration represents required behavior across an external, remote-Domain, substitution, process, or trust boundary\tIdentify the boundary for every contract and report behavior that can remain ordinary local Domain code\tpayment-authorization.md\nINT-NEUTRAL\tintegrations\tdeclaration\terror\tEvery Integration owns provider-neutral requests, evidence, correlation, idempotency, trust, and expected failure semantics needed by consumers\tInspect consumers and contracts and report provider fields or missing stable boundary semantics\tid-allocation.md\nINT-PURE\tintegrations\tdependency\terror\tIntegrations remain provider- and execution-boundary-neutral and import no concrete client, credential, configuration, Provider, Action, or Workflow\tResolve runtime and provider imports and report every conclusive concrete or execution-boundary dependency\tdocument-signing.md\nINT-ABILITY-NAME\tintegrations\tstructure\terror\tIntegration submodules are named by required ability and never mirror Schema entities mechanically\tCompare Integration and Schema submodules and report a contract without an independent boundary ability\tobject-storage.md\nRTE-RECIPE\troutes\tdeclaration\terror\tEvery native HTTP Route targets exactly one admitted Action or Workflow recipe\tResolve every route target and report forged missing or several recipes\taction-route.md\nRTE-MAPPING\troutes\tdataflow\terror\tEvery callable input field and instance receiver is mapped exactly once from path query header method or body input\tCompile each route against its resolved callable and reject incomplete ambiguous or unknown mappings\tinstance-route.md\nRTE-CREDENTIAL\troutes\tdataflow\terror\tEvery external credential source is explicit and is never also mapped as callable input\tCompile credential and input mappings and reject duplicate reserved or implicit authority sources\tcredential-route.md\nRTE-ONE-FILE\troutes\tstructure\terror\tEvery Route declaration has one business-intent kebab-case file and Routes composition contains no inline declaration\tInventory route declarations and report generic grouped or inline ownership\tapplication-routes.md\nPRV-INT-IMPL\tproviders\tarchitecture\terror\tEvery Provider implements one or more declared Integrations across a named external or remote-Domain boundary\tIdentify the boundary and implemented contracts and report a Provider without both\tpayment-provider.md\nPRV-BOUNDARY-NAME\tproviders\tstructure\terror\tProvider submodules are named by external system, protocol, or trust boundary rather than Domain entity\tInspect every submodule name and report one justified only by Schema vocabulary\tobject-storage-provider.md\nPRV-ADMIT-RESULT\tproviders\tdataflow\terror\tEvery boundary value is admitted before Integration evidence and recognized boundary failures become stable Integration failures\tTrace input and failure paths and report missing admission, leaked boundary errors, broad mapping, or swallowed defects\twebhook-admission.md\nPRV-NO-DOMAIN\tproviders\tdependency\terror\tProviders perform no local Domain graph operation, business decision, local Action call, or Workflow orchestration\tResolve Provider imports and call graphs and require zero excluded operations\tboundary-composition.md\nPRV-XDOM-TYPED\tproviders\tdependency\terror\tRemote-Domain Providers pass SDK-derived typed callable references to the caller-bound invocation capability without never casts\tInspect Provider execution invoke calls and reject references not constructed through SDK reference, opaque or fabricated references, and never-cast arguments\tremote-domain.md\nPRV-XDOM-REQ\tproviders\tdependency\terror\tEvery statically resolved remote-Domain Provider invocation has one exact Domain Function requirement\tMatch each invocation-bound public callable reference to the same foreign facade and Function selector under Domain requirements; preserve opaque references or composition as indeterminate\tremote-domain.md\nPRV-XDOM-PUBLIC\tproviders\tdependency\terror\tA remote-Domain Provider uses the remote public facade and invokes at most one public callable per Integration operation\tResolve receiver and facade origins for each remote operation and report private access, missing Integration ownership, unrelated calls, or several public invocations\tremote-domain.md\nVIW-PROJECTION\tviews\tdeclaration\terror\tEvery View converts public Domain values or named Query observations into UI props and connects each action to a named bounded Mutation or public callable contract\tInspect View outputs and actions and report behavior without a Schema, Query, UI, Mutation, Rule, or public callable owner\tdetail-view.md\nVIW-SCHEMA-DECL\tviews\tdeclaration\terror\tSchema owns every DSL View declaration and Views declares no Domain schema construct\tScan View declarations and reject Classes, Properties, Policies, Methods, Actions, or DSL Views\tarticle-list.md\nVIW-NO-COMPOSE\tviews\tdeclaration\terror\tThe Domain definition owns frontend deployment composition and Views never calls defineFrontend\tResolve direct imported defineFrontend calls in Views and report SDK constructor calls while ignoring unrelated local functions\tfrontend-composition.md\nVIW-DEPS\tviews\tdependency\terror\tViews import only Schema and its StateMachines, pure Rules, named Queries, bounded named Mutations, UI, shell-react primitives, public callable contracts, and presentation libraries\tInspect resolved imports and report dependencies or raw graph APIs outside the allowlist\tnavigation.md\nVIW-ACTIONS\tviews\tdataflow\terror\tEvery View action executes a named caller-authorized atomic Mutation or invokes a public callable; presentation state is never authorization evidence\tTrace action and authority paths and report inline or raw graph documents, elevated or effectful Mutation use, private Action imports, direct Integration calls, or authority derived from presentation\tform-actions.md\nUI-PRES-DEPS\tui\tdependency\terror\tEvery UI import is a sibling UI module or an external library used only for presentation\tInspect resolved imports and used APIs and report Domain, I/O, persistence, authorization, routing, or provider behavior\tstatus-panel.md\nUI-NO-DOMAIN\tui\tdependency\terror\tUI imports no Domain layer or Domain package facade\tResolve the UI import graph and require zero Domain paths\tresult-list.md\nUI-PURE\tui\tbehavior\terror\tUI performs no I/O, graph access, storage, authorization, business validation, provider call, routing, or Domain result mapping\tInspect components and hooks and report the exact excluded call or branch\tconfirmation-dialog.md\nUI-CALLBACKS\tui\tdataflow\terror\tUI accepts presentation props and forwards intent through callbacks without constructing Domain commands\tInspect props and event handlers and report Domain identities, command construction, or business decisions\tform.md\nUTL-DOM-AGNOSTIC\tutils\tarchitecture\terror\tEvery Utils export is Domain-agnostic and contains no Domain declaration, identity, decision, graph definition, or Workflow step\tInspect signatures and implementations and report the exact Domain concept or business behavior\tresult.md\nUTL-REUSED\tutils\tarchitecture\terror\tEvery Utils extension serves two independent semantic consumers or one package-wide execution boundary\tList direct consumers and report an extension satisfying neither condition\tjson-codec.md\nUTL-PUBLIC-DEPS\tutils\tdependency\terror\tUtils imports only public Kernel, DSL, SDK, standard-library, and sibling Utils modules\tResolve the Utils import graph and reject Domain layers, Providers, or private package paths\tjson-codec.md\nUTL-LIGHTWEIGHT\tutils\tarchitecture\terror\tUtils is private and owns no durable engine, planner, compiler, Repository, service locator, or dependency container\tInspect package exports and declarations and report public exposure or any forbidden framework machinery\tresult.md\nSCR-OPERATOR\tscripts\tbehavior\terror\tEvery root Script implements a supported operator workflow with declared inputs, outcomes, failures, and proof\tInspect each Script contract and report disposable tasks or missing operator semantics\tbackup.md\nSCR-PUBLIC-DEPS\tscripts\tbehavior\terror\tScripts import only dependency-DAG-authorized public facades, standard libraries, and operator libraries and define no Domain behavior\tResolve imports and inspect branches and report private paths, business decisions, graph definitions, or callable behavior\tupgrade.md\nSCR-TEST-DRIVERS\tscripts\tbehavior\terror\tDisposable setup, fixtures, resets, and scenario drivers live under tests/scripts rather than root Scripts\tClassify every Script by supported operator contract and report evidence-only programs at the root\trestore.md\nTST-SYS-OWNER\ttests\tevidence\terror\tRoot Tests owns cross-layer journeys, environments, harnesses, scenarios, seeds, fixtures, and disposable scripts\tInventory evidence support code and report cross-layer artifacts outside Tests or production semantics inside Tests\tinterruption-scenario.md\nTST-COLOCATED\ttests\tevidence\terror\tEvery semantic production submodule owns focused evidence in its local __tests__ directory\tJoin production submodules to focused test directories and report missing owners\tfocused-rule.md\n",
4
+ rules: "id\tscope\tkind\tseverity\tmessage\tverification\texample\nOWN-SEMANTIC\townership\tarchitecture\terror\tEvery semantic fact, rule, representation, transition, and failure meaning has exactly one owner\tInventory declarations by meaning and report each duplicate authority or ownerless concept\tsemantic-owner.md\nMOD-SUBMODULE\tmodules\tstructure\terror\tEvery semantic source file lives in a dedicated semantic submodule or its registered layer facade\tClassify every layer-root source file and report files outside the registered facade or public index\tsemantic-owner.md\nMOD-REQUIRED\tmodules\tstructure\terror\tEvery required layer and root file declared by the injected layout exists\tCompare admitted project entries with required layout entries and report each missing path\trequired-layout.md\nMOD-GOVERNED\tmodules\tstructure\terror\tEvery source file admitted by the Domain compilation scope belongs to a declared layer or supported root\tClassify admitted source paths after declared workspace and tooling delegation and report each unowned path\tgoverned-source.md\nROOT-FACADE\troots\tstructure\terror\tEvery registered layer facade is exposed through a curated public index\tInspect each layer index and facade and report private-owner behavior or misplaced facade declarations\tpackage-facade.md\nROOT-COMPOSE\troots\tstructure\terror\tPackage roots compose only policy-backed Schema, Runtime, frontend deployment, native Routes, Provider-backed Integrations, and supported package journeys\tInspect declared composition and package roots and report behavior, provider protocol logic, recursive barrels, or unsupported exports\tcomposition-root.md\nROOT-PACKAGE\troots\tevidence\terror\tEvery public Schema package subpath maps one admitted source entrypoint to its deterministic published declaration and JavaScript targets\tCompare source and publish exports and reject missing duplicate non-Schema locally linked generated or Kernel-leaking package artifacts\tmulti-domain-package.md\nDEP-ALLOWLIST\tdependencies\tdependency\terror\tEvery direct cross-layer import and its runtime or type-only kind appears in the dependency allowlist and dependencies between distinct layers are acyclic\tResolve source imports, reject every absent or kind-mismatched edge, and detect cycles after excluding evidence edges\tsemantic-owner.md\nIMP-FACADE\timports\tdependency\terror\tEvery cross-submodule import uses the semantic owner's facade and every foreign Domain import uses its public package facade\tResolve imports and report private deep paths outside the importing submodule\tcross-domain.md\nIMP-SDK-BOUNDARY\timports\tdependency\terror\tDomain source imports Kernel Core and DSL authoring values only through semantic SDK subpaths\tInspect every static and literal dynamic import and report module specifiers rooted at @astrale-os/kernel-core or @astrale-os/kernel-dsl\tsdk-boundary.md\nIMP-LAYER-ALIAS\timports\tdependency\terror\tEvery local import crossing a layer or semantic-submodule boundary uses the registered # layer alias\tResolve relative imports and report each one whose target leaves the importing semantic submodule\tlayer-aliases.md\nIMP-ALIAS-CFG\timports\tdependency\terror\tPackage and TypeScript resolution exactly implement each active layer-facade and semantic-submodule alias\tCompare active and required layers with the injected alias registry and report missing, undeclared, or drifted mappings\talias-configuration.md\nIMP-STATIC\timports\tdependency\terror\tProduction dependency edges use analyzable static ESM declarations or literal import calls\tReject require calls, import-equals declarations, nonliteral import calls, and unresolved static dependency forms\tstatic-imports.md\nTYP-OWNER\ttypes\tarchitecture\terror\tEvery type and reusable expected error is colocated with the semantic concept that defines its meaning\tTrace each declaration to its semantic authority and report catch-all or remotely owned values\texpected-failure.md\nERR-EXPECTED\terrors\tdataflow\terror\tBoundaries map only declared expected failures and propagate unexpected defects\tInspect catches and result mappings and report broad fallback, swallowed defects, or mappings without a declared source failure\texpected-failure.md\nTST-NO-PROD-IMP\ttests\tdependency\terror\tProduction source imports no root or colocated Test artifact\tResolve production imports and report targets under Root Tests, __tests__, or test, spec, bench, and perf source files\ttest-import-boundary.md\nABS-EARNED\tabstractions\tarchitecture\terror\tAn invariant or real boundary earns an abstraction; reuse alone requires two independent consumers and no duplicated semantic behavior\tIdentify the invariant, boundary, or independent consumers for each abstraction and report reuse wrappers that duplicate an owner's semantics\tsemantic-owner.md\nABS-NO-REPO\tabstractions\tarchitecture\terror\tDomain source places no collection-shaped persistence facade between business code and canonical Query or Mutation definitions\tInspect persistence-facing contracts and report abstractions that replace graph identity, traversal, observation, or atomic change semantics\tsemantic-owner.md\nABS-CANON-GRAPH\tabstractions\tdeclaration\terror\tDomain source declares no alternate Query or Mutation language, AST, compiler, planner, or wire representation\tInspect graph-related declarations and report semantics not identical to canonical Kernel Query or Mutation values\tsemantic-owner.md\nTRUST-ADMIT-ONCE\ttrust\tdataflow\terror\tEvery untrusted value is admitted or translated exactly once at its owning boundary\tTrace values from each external boundary and report missing admission or repeated structural validation\texpected-failure.md\nQLT-EXHAUSTIVE\tquality\tbehavior\terror\tEvery closed alternative is handled exhaustively and no required failure becomes placeholder success\tTrace closed unions and failure paths and report permissive defaults, placeholder success, or catch-and-continue behavior\texpected-failure.md\nQLT-CANON-VALUES\tquality\tdataflow\terror\tNo unchecked cast fabricates a canonical Kernel identity, QueryAST, MutationAST, or admitted schema value\tScan casts to canonical values and require an owning constructor or decoder for each\tsemantic-owner.md\nQLT-DEF-IDS\tquality\tdeclaration\terror\tEvery top-level Query and Mutation definition has a stable literal ID unique in its owning namespace\tExtract top-level definition IDs and report missing, dynamic, malformed, or duplicate values\tdefinition-identities.md\nQLT-TYPED-COORD\tquality\tdeclaration\terror\tQueries and Mutations derive graph coordinates from resolved DSL definitions instead of raw string or structural reconstruction\tReject raw PropertyKey calls and structural ClassPath objects; require canonical resolved Classes Properties and keys at graph boundaries\ttyped-coordinates.md\nNODE-INHERITED\tnodes\tdeclaration\terror\tNo Node Class redeclares name, description, createdAt, or updatedAt inherited from Named, Descriptable, and Timestamped\tScan Node Class Properties and report each inherited field redeclaration\tsemantic-owner.md\nDOM-PUBLIC-DEPS\tdomains\tdependency\terror\tEvery directly referenced foreign-Domain graph declaration has one exact Schema dependency\tResolve foreign Schema, Query, and Mutation graph references and report each package without one exact declared Schema dependency\tcross-domain.md\nDOM-CALL-DECLARED\tdomains\tdependency\terror\tCross-Domain calls use exact declared public Schema dependencies and typed invocation; Integrations are optional consumer-owned boundaries\tTrace remote invocations and reject undeclared targets, private imports, forged references, and missing exact Domain Function requirements\tremote-domain-call.md\nDOM-ATOMICITY\tdomains\tbehavior\terror\tA cross-Domain change claims atomicity only when it is one MutationAST on one graph; calls combined with other effects are Workflow steps\tTrace atomicity and effect claims and report multiple commits, service boundaries, or foreign calls combined in a Action\tcross-domain.md\nSCH-SUBMODULE\tschema\tstructure\terror\tEvery Schema source path belongs to the registered facade, one canonical shared declaration kind, or one business-module facade or canonical declaration kind\tClassify admitted Schema source paths including shared and module-owned errors directories and report flat files or source-bearing directories outside the canonical Schema vocabulary\tschema-facade.md\nSCH-ONE-DECL\tschema\tdeclaration\terror\tEvery Schema declaration leaf file exports exactly one locally authored declaration of its directory kind and every declaration-kind index is a curated facade\tInspect runtime exports in Classes, Functions, Policies, States, and Views; resolve canonical SDK constructor origins and report zero, several, re-exported, aggregated, wrong-kind, or index-owned values\tdeclaration-file.md\nSCH-DECL-ONLY\tschema\tdeclaration\terror\tSchema performs no handler execution, Query execution, Mutation submission, Integration call, Workflow step, or Provider call\tResolve Schema imports and call graphs and require zero excluded operations\tpublication-callables.md\nSCH-EXACT-TYPES\tschema\tdeclaration\terror\tSchema authoring values preserve their exact inferred DSL types instead of widening to generic builder contracts\tScan Schema declarations and action returns for explicit generic builder authoring annotations\tschema-facade.md\nSCH-ICON-REQUIRED\tschema\tdeclaration\terror\tEvery Node Class must explicitly declare one admitted SVG icon\tInspect each SDK nodeClass and Node-kind defineClass declaration and report statically proven missing icon values while preserving opaque configurations as indeterminate\tclass-icon.md\nSCH-ICON-NEUTRAL\tschema\tdeclaration\twarning\tEvery neutral Node Class icon should be replaced with a meaningful icon\tInspect each SDK nodeClass and Node-kind defineClass declaration and report explicit classIcon.neutral or exact neutral SVG values\tclass-icon.md\nSCH-POLICY-AUTH\tschema\tdeclaration\terror\tCallable authority and existential Node scope are declared explicitly through Policy and Action implementations add no private authorization rule\tTrace callable admission and existential Node binders; report hidden authority or an ambiguous Node extent\tpolicy.md\nSCH-POLICY-NAME\tschema\tdeclaration\twarning\tEvery Policy is named as the sentence its subject completes, in the Domain's words: each business hop to the object in order, the object last\tRead each Policy name against its match and report a permission prefix such as can or may, a graph mechanics word such as source, target, sub, super, subject, object, or caller, or a business hop of the match the name omits\tpolicy.md\nSCH-STATE-SOURCE\tschema\tdeclaration\terror\tEvery persisted StateMachine vocabulary originates from an exported authority in the same Schema business module rather than a copied literal set\tResolve exact StateMachine and stateProperty origins; report same-owner copied literals and reject cross-module association\tarticle-schema.md\nSCH-STATE-RELATION\tschema\tdeclaration\terror\tEvery StateMachine is one exported static immutable finite relation without parallel vocabulary authorities\tInspect Schema module machines and exported sibling values for split or copied topology\tarticle-status.md\nSCH-STATE-PURE\tschema\tdeclaration\terror\tStateMachine topology contains no behavior, effects, guards, clocks, retry, recovery, or orchestration\tInspect files that declare StateMachine authorities for behavioral exports, boundary imports, and effectful calls\tstate-pure.md\nRUL-SYNC\trules\tbehavior\terror\tEvery Rule is synchronous and returns no Promise, continuation, generator, or asynchronous iterator\tInspect Rule signatures and result types and reject asynchronous forms\tnormalization.md\nRUL-PURE\trules\tbehavior\terror\tRules perform no I/O and depend on no graph executor or Domain execution boundary\tResolve imports and effect origins, permitting pure standard value transformations while reporting conclusive I/O and Domain execution dependencies\tpublish-eligibility.md\nRUL-EXPL-FACTS\trules\tbehavior\terror\tEvery clock value, random value, identity, limit, and environmental observation used by a Rule is an explicit input\tTrace every value source and report reads from ambient state, globals, process state, or hidden singletons\ttime-facts.md\nRUL-CLOSED-DEC\trules\tbehavior\terror\tEvery expected business alternative is represented by a closed decision value rather than thrown control flow\tInspect Rule branches and report expected alternatives represented by exceptions or open optional fields\tpublish-eligibility.md\nQRY-CANON\tqueries\tdataflow\terror\tEvery graph request produced by a Query definition is one canonical QueryAST built through Kernel Query APIs\tTrace request construction and reject every non-canonical graph document\tfiltered-query.md\nQRY-CONTRACT\tqueries\tdataflow\terror\tA Query owns its input, observation, optional business projection, pagination, and expected failures\tInspect each Query definition and report a required concern owned elsewhere or omitted\tquery-transforms.md\nQRY-SINGLE\tqueries\tdataflow\terror\tEvery authored single Query definition declares exactly one build callback and at most one project callback\tInspect definition properties and canonical roots; report opaque helper origins as ambiguity rather than assuming cardinality\tsingle-query.md\nQRY-COMPOSE-TYPED\tqueries\tdataflow\terror\tA composite Query constructs one closed QueryPlan containing only typed single-Query leaves, symbolic output references, and explicit result composition\tInspect plan construction, report unresolved call origins as ambiguity, and reject nested composites, raw sessions, graph clients, result-time callbacks, arbitrary promises, or Domain effects\tdependent-query.md\nQRY-COMPOSE-STABLE\tqueries\tdeclaration\terror\tEvery composite Query leaf has a stable semantic literal ID unique within its definition\tInspect declared Query leaves and reject dynamic, malformed, or duplicate leaf identifiers\tdependent-query.md\nQRY-COLL-FANOUT\tqueries\tdataflow\twarning\tThree or more independent same-kind complete-Class collection leaves use one explicit query.union group\tInfer collection kind from canonical definition types and print the direct named replacement plus logical and physical plan counts\tcollection-union.md\nQRY-PROJECT-PURE\tqueries\tdataflow\terror\tEvery Query project callback is synchronous and performs only pure value transformation\tInspect project callback syntax and call graphs and report asynchronous continuation, I/O, mutation, nondeterminism, hidden query execution, or effects\tprojection.md\nQRY-SNAPSHOT\tqueries\tdataflow\terror\tA composite or paginated Query makes no point-in-time graph snapshot claim beyond one Kernel invocation\tReject shared-snapshot claims across leaves unions or continuations and route stronger consistency to an explicit Kernel facility\tdependent-query.md\nMUT-PLAN-REQ\tmutations\tdependency\terror\tEvery identity operation and foreign Mutation plan declares the exact Kernel Function and foreign Class authority it uses\tInspect SDK MutationAST builders and Kernel Provision or Register calls and match every foreign Class operation and identity syscall invocation to Domain requirements\tprovision-plan.md\nMUT-LOCAL-ALIAS\tmutations\tdeclaration\terror\tEvery literal Mutation createNode alias is a canonical local binding accepted by the Kernel\tInspect statically resolved createNode as values and reject invalid local binding literals before runtime\tatomic-mutation.md\nMUT-CANON\tmutations\tdataflow\terror\tEvery Mutation definition builds one synchronous change through the canonical builder and constructs no alternate or nested graph document\tInspect every definition build callback and reject missing, asynchronous, alternate, or nested Mutation construction\tatomic-mutation.md\nMUT-CONTRACT\tmutations\tdataflow\terror\tA Mutation owns its input, preconditions, operations, optional business projection, and expected failures\tInspect each definition and report required mutation semantics owned elsewhere or omitted\tcreate-aggregate.md\nMUT-PRECONDS\tmutations\tdataflow\terror\tRules decide eligibility and every live graph condition required for safety is encoded as a precondition in the same MutationAST\tMap decisions to preconditions and report duplicated eligibility or safety enforced only by an earlier observation\tconditional-update.md\nMUT-FRAGMENTS\tmutations\tdataflow\terror\tReusable fragments receive the callback-scoped MutationBuilder and contribute only to the same MutationAST\tResolve fragment signatures and calls and reject escaped builders, opaque documents, or nested MutationAST construction\tmutation-fragments.md\nMUT-PURE\tmutations\tdataflow\terror\tMutation definitions perform no session call, external effect, retry, compensation, or second submission\tScan definition call graphs and require zero excluded operations\tedge-change.md\nMUT-MULTI-WFL\tmutations\tdataflow\terror\tA change requiring several MutationAST values is a Workflow and is never exposed as one atomic Mutation\tTrace multi-commit changes and report definitions or names claiming single-mutation atomicity\tdelete-node.md\nMUT-STATE-INITIAL\tmutations\tdataflow\terror\tEvery StateMachine-backed node is created from its machine's initial state\tResolve machine-backed Property initializers and require the canonical machine.initial value rather than a copied state literal\tstate-transition.md\nMUT-STATE-ATOMIC\tmutations\tdataflow\terror\tEvery persisted machine-state change consumes one allowed decision and commits its stale-state precondition and update in the same MutationAST\tInspect machine-backed writes and require transition with the canonical Schema module machine and one allowed decision; reject direct target writes and split precondition updates\tstate-transition.md\nFNC-ONE-IMPL\tfunctions\tbehavior\terror\tEvery registered handler binding resolves to exactly one implementation owned by one semantic Functions submodule\tResolve the handler registry and report non-Action owners or duplicate registrations; SDK typing owns callable exhaustiveness\tsynchronous-result.md\nFNC-ONE-EFFECT\tfunctions\tbehavior\terror\tEvery Action performs at most one effect, as its terminal operation; the Queries and read-only calls it needs precede that effect\tTrace every path and report two effects, an operation after the effect, or hidden orchestration\tmutation-operation.md\nFNC-OP-KINDS\tfunctions\tbehavior\terror\tA semantic asynchronous operation is one Query, Mutation, Integration call, dependency invocation, or canonical Kernel operation; a Query or a call that changes no state is an observation, every other operation is an effect\tClassify every awaited operation including dependency and Kernel calls as an observation or an effect; report undeclared kinds and hidden multiple effects\tintegration-operation.md\nFNC-BOUNDARIES\tfunctions\tbehavior\terror\tHandlers use self-default kernel graph query and mutate capabilities, explicit-authority direct dependencies, and optional declared Integrations; explicit Kernel and graph authority modes are available\tInspect context use, authority selection, dependencies, imports and failure mapping; reject raw unbound graph executors, foreign handler imports, implicit authority changes and swallowed defects\tremote-integration.md\nFNC-BINARY-RESULT\tfunctions\tbehavior\terror\tA binary Action returns detached buffered bytes or streaming bytes with admitted media type status and application headers without collecting or value-framing a provider stream\tExercise buffered and streaming results through their native route; verify exact bytes status headers cancellation and invalid output rejection\tnative-byte-response.md\nFNC-MULTISTEP\tfunctions\tbehavior\terror\tEvery Workflow definition contains at least two effect sites that cannot commit together\tInventory effect sites in the definition and report fewer than two or effects one Mutation could commit; early exit, rejection, and recovery paths may execute fewer\tpublication-workflow.md\nFNC-STEP-EFFECTS\tfunctions\tbehavior\terror\tEvery semantic asynchronous operation runs inside a named step: step.run, or the durable step.query and step.mutate shorthands\tTrace operations and report each one outside a named step\tpublication-workflow.md\nFNC-STEP-IDS\tfunctions\tbehavior\terror\tEvery step identifier is a stable non-empty kebab-case literal unique within its Workflow\tExtract step identifiers and reject dynamic, malformed, empty, or duplicate values\tpublication-workflow.md\nFNC-NO-NEST\tfunctions\tbehavior\terror\tNo step.run callback starts another step, whether step.run, step.query or step.mutate, directly or through a reachable helper\tInspect callback call graphs and report every nested step path\tpublication-workflow.md\nFNC-INT-TYPES\tfunctions\tdeclaration\terror\tWorkflow Integration requirements derive from declared Integration definitions and the SDK projects their clients\tReject Workflow-owned operation interfaces and require its definition generic to reference the declared Integration registry\tcross-domain-workflow.md\nFNC-STEP-READS\tfunctions\tbehavior\terror\tA durable step reads nothing before its effect: the effect builds its request and guards only from the Workflow input and earlier step results, so a retried step resends the same request\tIn a durable Workflow, report a step.run callback, inline or a named local function, whose read precedes an effect or builds its arguments unless the two take exclusive branches, where a local helper's operations run where the step calls it, a read is a Query or a raw Kernel read and an effect is a Mutation or a call its types prove durable; a call of unprovable kind is not counted\tpublication-workflow.md\nFNC-EFFECT-STEP\tfunctions\tbehavior\twarning\tEvery step makes at most one effect, so a step that fails leaves no committed effect the Workflow cannot see\tIn a durable Workflow, report a step.run callback, inline or a named local function, where one run can make two effects, counting an effect a local helper runs on each of its calls and an effect in a loop or an iterating Array callback as several, and effects in exclusive branches of the step's body as one run each, where an effect is a Mutation or a call its types prove durable; a call of unprovable kind is not counted\tpublication-workflow.md\nFNC-STEP-RETRY\tfunctions\tbehavior\twarning\tEvery effect a durable step repeats when it is retried survives the repetition: Mutations, durable calls and keyed Integration operations carry the step key, and any other effect is idempotent\tIn a durable Workflow, report a step.run callback, inline or a named local function, that invokes a callable its types prove not durable, invokes an untyped Path, written as a string or typed as one, or calls global fetch\tpublication-workflow.md\nFNC-STATE-CODEC\tfunctions\tbehavior\terror\tEvery step result and inter-step value is undefined or portable JSON data\tInspect step values and report actions, clients, symbols, bigint, cycles, or class instances\tpublication-workflow.md\nFNC-RECOVERY\tfunctions\tbehavior\terror\tWhen compensation or unknown-outcome branches exist, they are explicit and rely only on declared operation semantics\tInspect existing recovery branches and report guessed outcomes or compensation without exact evidence\tpublication-workflow.md\nFNC-XDOM-DECLARED\tfunctions\tbehavior\terror\tActions and Workflows invoke direct declared Domain dependencies through explicit-authority dependency invokers or canonical typed kernel.invoke references and import no foreign handler\tResolve handler imports, direct dependency aliases, explicit caller/self authority, selectors, and typed references; reject foreign imports, implicit or chained authority, undeclared aliases and forged references, and report opaque bindings as indeterminate\tcross-domain-workflow.md\nFNC-XDOM-REQ\tfunctions\tbehavior\terror\tEvery selected remote callable has one exact Domain Function requirement including its defining Class and static or instance kind\tCompare each statically selected remote callable with exact Domain Function requirements; report missing requirements and mark opaque selectors or requirement lists indeterminate\tcross-domain-workflow.md\nINT-BOUNDARY\tintegrations\tarchitecture\terror\tEvery Integration represents required behavior across an external, remote-Domain, substitution, process, or trust boundary\tIdentify the boundary for every contract and report behavior that can remain ordinary local Domain code\tpayment-authorization.md\nINT-NEUTRAL\tintegrations\tdeclaration\terror\tEvery Integration owns provider-neutral requests, evidence, correlation, idempotency, trust, and expected failure semantics needed by consumers\tInspect consumers and contracts and report provider fields or missing stable boundary semantics\tid-allocation.md\nINT-PURE\tintegrations\tdependency\terror\tIntegrations remain provider- and execution-boundary-neutral and import no concrete client, credential, configuration, Provider, Action, or Workflow\tResolve runtime and provider imports and report every conclusive concrete or execution-boundary dependency\tdocument-signing.md\nINT-ABILITY-NAME\tintegrations\tstructure\terror\tIntegration submodules are named by required ability and never mirror Schema entities mechanically\tCompare Integration and Schema submodules and report a contract without an independent boundary ability\tobject-storage.md\nRTE-RECIPE\troutes\tdeclaration\terror\tEvery native HTTP Route targets exactly one admitted Action or Workflow recipe\tResolve every route target and report forged missing or several recipes\taction-route.md\nRTE-MAPPING\troutes\tdataflow\terror\tEvery callable input field and instance receiver is mapped exactly once from path query header method or body input\tCompile each route against its resolved callable and reject incomplete ambiguous or unknown mappings\tinstance-route.md\nRTE-CREDENTIAL\troutes\tdataflow\terror\tEvery external credential source is explicit and is never also mapped as callable input\tCompile credential and input mappings and reject duplicate reserved or implicit authority sources\tcredential-route.md\nRTE-ONE-FILE\troutes\tstructure\terror\tEvery Route declaration has one business-intent kebab-case file and Routes composition contains no inline declaration\tInventory route declarations and report generic grouped or inline ownership\tapplication-routes.md\nPRV-INT-IMPL\tproviders\tarchitecture\terror\tEvery Provider implements one or more declared Integrations across a named external or remote-Domain boundary\tIdentify the boundary and implemented contracts and report a Provider without both\tpayment-provider.md\nPRV-BOUNDARY-NAME\tproviders\tstructure\terror\tProvider submodules are named by external system, protocol, or trust boundary rather than Domain entity\tInspect every submodule name and report one justified only by Schema vocabulary\tobject-storage-provider.md\nPRV-ADMIT-RESULT\tproviders\tdataflow\terror\tEvery boundary value is admitted before Integration evidence and recognized boundary failures become stable Integration failures\tTrace input and failure paths and report missing admission, leaked boundary errors, broad mapping, or swallowed defects\twebhook-admission.md\nPRV-NO-DOMAIN\tproviders\tdependency\terror\tProviders perform no local Domain graph operation, business decision, local Action call, or Workflow orchestration\tResolve Provider imports and call graphs and require zero excluded operations\tboundary-composition.md\nPRV-XDOM-TYPED\tproviders\tdependency\terror\tRemote-Domain Providers pass SDK-derived typed callable references to the caller-bound invocation capability without never casts\tInspect Provider execution invoke calls and reject references not constructed through SDK reference, opaque or fabricated references, and never-cast arguments\tremote-domain.md\nPRV-XDOM-REQ\tproviders\tdependency\terror\tEvery statically resolved remote-Domain Provider invocation has one exact Domain Function requirement\tMatch each invocation-bound public callable reference to the same foreign facade and Function selector under Domain requirements; preserve opaque references or composition as indeterminate\tremote-domain.md\nPRV-XDOM-PUBLIC\tproviders\tdependency\terror\tA remote-Domain Provider uses the remote public facade and invokes at most one public callable per Integration operation\tResolve receiver and facade origins for each remote operation and report private access, missing Integration ownership, unrelated calls, or several public invocations\tremote-domain.md\nVIW-PROJECTION\tviews\tdeclaration\terror\tEvery View converts public Domain values or named Query observations into UI props and connects each action to a named bounded Mutation or public callable contract\tInspect View outputs and actions and report behavior without a Schema, Query, UI, Mutation, Rule, or public callable owner\tdetail-view.md\nVIW-SCHEMA-DECL\tviews\tdeclaration\terror\tSchema owns every DSL View declaration and Views declares no Domain schema construct\tScan View declarations and reject Classes, Properties, Policies, Methods, Actions, or DSL Views\tarticle-list.md\nVIW-NO-COMPOSE\tviews\tdeclaration\terror\tThe Domain definition owns frontend deployment composition and Views never calls defineFrontend\tResolve direct imported defineFrontend calls in Views and report SDK constructor calls while ignoring unrelated local functions\tfrontend-composition.md\nVIW-DEPS\tviews\tdependency\terror\tViews import only Schema and its StateMachines, pure Rules, named Queries, bounded named Mutations, UI, shell-react primitives, public callable contracts, and presentation libraries\tInspect resolved imports and report dependencies or raw graph APIs outside the allowlist\tnavigation.md\nVIW-ACTIONS\tviews\tdataflow\terror\tEvery View action executes a named caller-authorized atomic Mutation or invokes a public callable; presentation state is never authorization evidence\tTrace action and authority paths and report inline or raw graph documents, elevated or effectful Mutation use, private Action imports, direct Integration calls, or authority derived from presentation\tform-actions.md\nUI-PRES-DEPS\tui\tdependency\terror\tEvery UI import is a sibling UI module or an external library used only for presentation\tInspect resolved imports and used APIs and report Domain, I/O, persistence, authorization, routing, or provider behavior\tstatus-panel.md\nUI-NO-DOMAIN\tui\tdependency\terror\tUI imports no Domain layer or Domain package facade\tResolve the UI import graph and require zero Domain paths\tresult-list.md\nUI-PURE\tui\tbehavior\terror\tUI performs no I/O, graph access, storage, authorization, business validation, provider call, routing, or Domain result mapping\tInspect components and hooks and report the exact excluded call or branch\tconfirmation-dialog.md\nUI-CALLBACKS\tui\tdataflow\terror\tUI accepts presentation props and forwards intent through callbacks without constructing Domain commands\tInspect props and event handlers and report Domain identities, command construction, or business decisions\tform.md\nUTL-DOM-AGNOSTIC\tutils\tarchitecture\terror\tEvery Utils export is Domain-agnostic and contains no Domain declaration, identity, decision, graph definition, or Workflow step\tInspect signatures and implementations and report the exact Domain concept or business behavior\tresult.md\nUTL-REUSED\tutils\tarchitecture\terror\tEvery Utils extension serves two independent semantic consumers or one package-wide execution boundary\tList direct consumers and report an extension satisfying neither condition\tjson-codec.md\nUTL-PUBLIC-DEPS\tutils\tdependency\terror\tUtils imports only public Kernel, DSL, SDK, standard-library, and sibling Utils modules\tResolve the Utils import graph and reject Domain layers, Providers, or private package paths\tjson-codec.md\nUTL-LIGHTWEIGHT\tutils\tarchitecture\terror\tUtils is private and owns no durable engine, planner, compiler, Repository, service locator, or dependency container\tInspect package exports and declarations and report public exposure or any forbidden framework machinery\tresult.md\nSCR-OPERATOR\tscripts\tbehavior\terror\tEvery root Script implements a supported operator workflow with declared inputs, outcomes, failures, and proof\tInspect each Script contract and report disposable tasks or missing operator semantics\tbackup.md\nSCR-PUBLIC-DEPS\tscripts\tbehavior\terror\tScripts import only dependency-DAG-authorized public facades, standard libraries, and operator libraries and define no Domain behavior\tResolve imports and inspect branches and report private paths, business decisions, graph definitions, or callable behavior\tupgrade.md\nSCR-TEST-DRIVERS\tscripts\tbehavior\terror\tDisposable setup, fixtures, resets, and scenario drivers live under tests/scripts rather than root Scripts\tClassify every Script by supported operator contract and report evidence-only programs at the root\trestore.md\nTST-SYS-OWNER\ttests\tevidence\terror\tRoot Tests owns cross-layer journeys, environments, harnesses, scenarios, seeds, fixtures, and disposable scripts\tInventory evidence support code and report cross-layer artifacts outside Tests or production semantics inside Tests\tinterruption-scenario.md\nTST-COLOCATED\ttests\tevidence\terror\tEvery semantic production submodule owns focused evidence in its local __tests__ directory\tJoin production submodules to focused test directories and report missing owners\tfocused-rule.md\n",
5
5
  layers: frozenRows([
6
6
  {
7
7
  id: 'schema',
@@ -137,7 +137,9 @@ export const domainRuleRequirements = Object.freeze([
137
137
  row('FNC-STEP-IDS', BEHAVIOR),
138
138
  row('FNC-NO-NEST', BEHAVIOR),
139
139
  row('FNC-INT-TYPES', DECLARATION),
140
- row('FNC-ONE-OP-STEP', BEHAVIOR),
140
+ row('FNC-STEP-READS', BEHAVIOR),
141
+ row('FNC-EFFECT-STEP', BEHAVIOR),
142
+ row('FNC-STEP-RETRY', BEHAVIOR),
141
143
  row('FNC-STATE-CODEC', BEHAVIOR),
142
144
  row('FNC-RECOVERY', BEHAVIOR),
143
145
  row('FNC-XDOM-DECLARED', BEHAVIOR_DEPENDENCY),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/sdk",
3
- "version": "0.6.0-beta.37",
3
+ "version": "0.6.0-beta.38",
4
4
  "description": "Schema-first SDK for defining, composing, and deploying Astrale domains",
5
5
  "keywords": [
6
6
  "astrale",
@@ -257,11 +257,11 @@
257
257
  "registry": "https://registry.npmjs.org/"
258
258
  },
259
259
  "dependencies": {
260
- "@astrale-os/kernel-client": "1.0.0-beta.14",
261
- "@astrale-os/kernel-core": "1.0.0-beta.12",
262
- "@astrale-os/kernel-dsl": "1.0.0-beta.6",
263
- "@astrale-os/kernel-protocol": "1.0.0-beta.12",
264
- "@astrale-os/kernel-server": "1.0.0-beta.12",
260
+ "@astrale-os/kernel-client": "1.0.0-beta.19",
261
+ "@astrale-os/kernel-core": "1.0.0-beta.16",
262
+ "@astrale-os/kernel-dsl": "1.0.0-beta.9",
263
+ "@astrale-os/kernel-protocol": "1.0.0-beta.16",
264
+ "@astrale-os/kernel-server": "1.0.0-beta.16",
265
265
  "@lucide/icons": "1.34.0",
266
266
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
267
267
  "cross-spawn": "7.0.6",