@astrale-os/kernel-dsl 0.2.0-beta.32 → 0.2.0-beta.33

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.
@@ -58,15 +58,11 @@ export type FunctionInput = ConcreteCallableInput & {
58
58
  readonly static?: never;
59
59
  readonly abstract?: never;
60
60
  };
61
- export type MethodInput = (ConcreteCallableInput & {
61
+ export type MethodInput = ConcreteCallableInput & {
62
62
  readonly static?: boolean;
63
- readonly abstract?: false;
64
- }) | (CallableInputBase & {
65
- readonly static?: boolean;
66
- readonly abstract: true;
67
- readonly auth: FunctionAuth;
68
- readonly policy?: never;
69
- });
63
+ /** Require every concrete descendant to declare this contract locally. */
64
+ readonly abstract?: boolean;
65
+ };
70
66
  export type CallableInput = FunctionInput | MethodInput;
71
67
  export interface CallableProjection<out Input = unknown, out Output = unknown, out Auth extends FunctionAuth = FunctionAuth, out Static extends boolean = boolean, out Abstract extends boolean = boolean> {
72
68
  readonly [CALLABLE_PROJECTION_VALUE]: true;
@@ -25,9 +25,6 @@ export class V1CallableCompiler {
25
25
  }
26
26
  const isStatic = method ? (config.static ?? false) : undefined;
27
27
  const isAbstract = method ? (config.abstract ?? false) : undefined;
28
- if (isAbstract === true && config.policy !== undefined) {
29
- fail('BUILDER_ABSTRACT_POLICY', `${placement.pointer}/policy`, 'An abstract Method cannot declare a Policy check.');
30
- }
31
28
  const input = this.values.schema(config.input, 'callable-input', `${placement.pointer}/input`);
32
29
  const output = this.compileOutput(config.output, `${placement.pointer}/output`);
33
30
  const policy = config.policy === undefined
@@ -1,5 +1,6 @@
1
1
  import { compareDefinitionRefs, compareUnicode, definitionRefIndex, } from '../../../addressing/ordering.js';
2
2
  import { DEPENDENCY_ALIAS_PATTERN } from '../../../addressing/patterns.js';
3
+ import { isMethodExecutable } from '../../../language/callable/executable.js';
3
4
  import { policyObjectKey, policyObjectOrigin } from '../../../language/index.js';
4
5
  import { graphNodePathSchema } from '../../../language/value/syntax/node-path/schema.js';
5
6
  import { revisionOfDomainSchema } from '../../../schema/canonical/revision.js';
@@ -260,7 +261,7 @@ function hasPolicyObject(schema, ref) {
260
261
  case 'method': {
261
262
  const owner = schema.classes[ref.owner.name];
262
263
  const method = owner?.kind === 'node' ? owner.methods[ref.name] : undefined;
263
- return method !== undefined && !method.abstract;
264
+ return method !== undefined && isMethodExecutable(owner, method);
264
265
  }
265
266
  case 'class':
266
267
  return Object.hasOwn(schema.classes, ref.name);
@@ -4,7 +4,7 @@ import type * as language from '../../language/index.js';
4
4
  import type { StateTopology } from '../../language/state/index.js';
5
5
  import type { DomainOfSchema, DomainSchema } from '../../schema/model/schema.js';
6
6
  import type { CallableProjection, Function, Method } from '../callable/authoring.js';
7
- import type { AuthoredPropertyProjection, AuthoredMethodProjection, Class, ClassIdentityProjection, ClassIdentityProjectionOf, ClassOwnerProjection, ClassOwnerProjectionOf, ClassReferenceProjection, ClassReferenceProjectionOf, DirectedEdgeClass, NodeClass, ProjectionOfClass, UndirectedEdgeClass } from '../class/authoring.js';
7
+ import type { AuthoredPropertyProjection, Class, ClassIdentityProjection, ClassIdentityProjectionOf, ClassOwnerProjection, ClassOwnerProjectionOf, ClassReferenceProjection, ClassReferenceProjectionOf, DirectedEdgeClass, NodeClass, ProjectionOfClass, UndirectedEdgeClass } from '../class/authoring.js';
8
8
  import type { DomainSchemaInput } from './input.js';
9
9
  export interface PropertyProjection<Value = unknown, Required extends boolean = boolean, Name extends string = string, Key extends language.PropertyKey = language.PropertyKey, State extends StateTopology | undefined = StateTopology | undefined> {
10
10
  readonly value: Value;
@@ -13,11 +13,13 @@ export interface PropertyProjection<Value = unknown, Required extends boolean =
13
13
  readonly key: Key;
14
14
  readonly state?: State;
15
15
  }
16
- export interface MethodProjection<Input = unknown, Output = unknown, Static extends boolean = boolean, Abstract extends boolean = boolean, Auth extends language.FunctionAuth = language.FunctionAuth, Name extends string = string, Key extends language.MethodKey = language.MethodKey> {
16
+ type MethodExecutableOf<OwnerAbstract extends boolean, MethodAbstract extends boolean> = MethodAbstract extends false ? true : OwnerAbstract extends false ? true : false;
17
+ export interface MethodProjection<Input = unknown, Output = unknown, Static extends boolean = boolean, Abstract extends boolean = boolean, Auth extends language.FunctionAuth = language.FunctionAuth, Name extends string = string, Key extends language.MethodKey = language.MethodKey, Executable extends boolean = boolean> {
17
18
  readonly input: Input;
18
19
  readonly output: Output;
19
20
  readonly static: Static;
20
21
  readonly abstract: Abstract;
22
+ readonly executable: Executable;
21
23
  readonly auth: Auth;
22
24
  readonly name: Name;
23
25
  readonly key: Key;
@@ -255,7 +257,7 @@ type CallableAbstractOf<Value extends Method> = CallableConfig<Value> extends {
255
257
  readonly abstract: infer Abstract extends boolean;
256
258
  } ? Abstract : false;
257
259
  type CallableAuthOf<Value extends Method | Function> = CallableConfig<Value>['auth'];
258
- type MethodProjectionOfEntry<Origin extends string, OwnerName extends string, Entry> = Entry extends language.ResolvedMethod ? MethodProjectionOfResolved<Entry> : Entry extends AuthoredMethodEntry<unknown, infer Name, infer Value> ? MethodProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableStaticOf<Value>, CallableAbstractOf<Value>, CallableAuthOf<Value>, Name, language.MethodKey<Origin, OwnerName, Name>> : never;
260
+ type MethodProjectionOfEntry<Origin extends string, OwnerName extends string, Entry> = Entry extends language.ResolvedMethod ? MethodProjectionOfResolved<Entry> : Entry extends AuthoredMethodEntry<infer Owner, infer Name, infer Value> ? MethodProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableStaticOf<Value>, CallableAbstractOf<Value>, CallableAuthOf<Value>, Name, language.MethodKey<Origin, OwnerName, Name>, MethodExecutableOf<AbstractOf<ClassInputOf<Owner>>, CallableAbstractOf<Value>>> : never;
259
261
  type MethodProjectionOfEntries<Origin extends string, OwnerName extends string, Entries> = Entries extends unknown ? MethodProjectionOfEntry<Origin, OwnerName, Entries> : never;
260
262
  type MethodCollectionOperation = 'byKey' | 'get';
261
263
  type PropertyProjectionOfResolved<Value> = Value extends language.ResolvedProperty<infer PropertyValue, infer Required, infer State> & {
@@ -264,7 +266,7 @@ type PropertyProjectionOfResolved<Value> = Value extends language.ResolvedProper
264
266
  } ? PropertyProjection<PropertyValue, Required, Name, Key, State> : never;
265
267
  type MethodProjectionOfResolved<Value> = Value extends language.ResolvedMethod<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer _Policy, infer Key> & {
266
268
  readonly name: infer Name extends string;
267
- } ? MethodProjection<Input, Output, Static, Abstract, Auth, Name, Key> : never;
269
+ } ? MethodProjection<Input, Output, Static, Abstract, Auth, Name, Key, Value['executable']> : never;
268
270
  type PropertiesOfCollection<Value> = Value extends {
269
271
  readonly byKey: infer ByKey extends Readonly<Record<language.PropertyKey, language.ResolvedProperty<unknown, boolean>>>;
270
272
  } ? PropertyProjectionOfResolved<ByKey[keyof ByKey]> : never;
@@ -299,20 +301,14 @@ type EffectivePropertyProjectionOfEntry<Origin extends string, CurrentName exten
299
301
  type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Root, Entry> : never : never;
300
302
  type OwnInstanceMethodProjectionsOf<Origin extends string, Name extends string, Value> = MethodProjectionOfEntries<Origin, Name, OwnMethodEntries<Value, false>>;
301
303
  type OwnStaticMethodProjectionsOf<Origin extends string, Name extends string, Value> = MethodProjectionOfEntries<Origin, Name, OwnMethodEntries<Value, true>>;
302
- type EffectiveMethodEntriesOfClass<Value, Static extends boolean> = ClassInputOf<Value> extends {
303
- readonly effectiveInstanceMethods: infer InstanceMethods;
304
- readonly effectiveStaticMethods: infer StaticMethods;
305
- } ? Static extends true ? StaticMethods : InstanceMethods : never;
306
- type EffectiveMethodProjectionOfEntry<Origin extends string, CurrentName extends string, Root extends DomainSchemaInput, Entry> = Entry extends language.ResolvedMethod ? MethodProjectionOfResolved<Entry> : Entry extends AuthoredMethodProjection<infer Value, infer MethodName, infer Owner> ? OwnerNameOf<Root, CurrentName, Owner> extends infer OwnerName extends string ? MethodProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableStaticOf<Value>, CallableAbstractOf<Value>, CallableAuthOf<Value>, MethodName, language.MethodKey<Origin, OwnerName, MethodName>> : never : never;
307
- type EffectiveMethodProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput, Static extends boolean> = EffectiveMethodEntriesOfClass<Value, Static> extends infer Entry ? Entry extends unknown ? EffectiveMethodProjectionOfEntry<Origin, Name, Root, Entry> : never : never;
308
304
  type ShallowClassProjectionOfAuthoring<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = Value extends NodeClass<infer _Config> ? ClassProjection<'node', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.NodeClassDefinition>, language.ClassRef<Name> & {
309
305
  readonly origin: Origin;
310
- }, language.DefinitionKey<Origin, 'class', Name>, readonly language.AnyResolvedClass[], EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, EffectiveMethodProjectionsOf<Origin, Name, Value, Root, false>, EffectiveMethodProjectionsOf<Origin, Name, Value, Root, true>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
306
+ }, language.DefinitionKey<Origin, 'class', Name>, readonly language.AnyResolvedClass[], EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
311
307
  readonly origin: Origin;
312
308
  }, language.DefinitionKey<Origin, 'class', Name>, readonly language.AnyResolvedClass[], EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, never, never, OwnPropertyProjectionsOf<Origin, Name, Value>, never, never> : never;
313
309
  type ClassProjectionOfAuthoring<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput, Seen = Value> = Value extends NodeClass ? ClassProjection<'node', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.NodeClassDefinition>, language.ClassRef<Name> & {
314
310
  readonly origin: Origin;
315
- }, language.DefinitionKey<Origin, 'class', Name>, ParentClassProjectionTuple<Origin, ParentInputsOfConfig<ProjectionOfClass<Extract<Value, Class>>>, Root, Seen>, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, EffectiveMethodProjectionsOf<Origin, Name, Value, Root, false>, EffectiveMethodProjectionsOf<Origin, Name, Value, Root, true>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
311
+ }, language.DefinitionKey<Origin, 'class', Name>, ParentClassProjectionTuple<Origin, ParentInputsOfConfig<ProjectionOfClass<Extract<Value, Class>>>, Root, Seen>, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
316
312
  readonly origin: Origin;
317
313
  }, language.DefinitionKey<Origin, 'class', Name>, ParentClassProjectionTuple<Origin, ParentInputsOfConfig<ProjectionOfClass<Extract<Value, Class>>>, Root, Seen>, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, never, never, OwnPropertyProjectionsOf<Origin, Name, Value>, never, never> : never;
318
314
  type FunctionProjectionOfAuthoring<Origin extends string, Name extends string, Value> = Value extends Function ? FunctionProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableAuthOf<Value>, language.FunctionRef<Name> & {
@@ -335,8 +331,9 @@ type ProjectionPropertyByName<Entries extends PropertyProjection> = Readonly<{
335
331
  }>>;
336
332
  }>;
337
333
  type PropertyCollectionOfProjection<Entries extends PropertyProjection> = language.ResolvedPropertyCollection<ProjectionPropertyByKey<Entries>, ProjectionPropertyByName<Entries>>;
338
- type ResolvedMethodOfProjection<Value> = Value extends MethodProjection<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer Name, infer Key> ? language.ResolvedMethod<Input, Output, Static, Abstract, Auth, language.PolicyCheckExpression, Key> & {
334
+ type ResolvedMethodOfProjection<Value> = Value extends MethodProjection<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer Name, infer Key, infer Executable> ? language.ResolvedMethod<Input, Output, Static, Abstract, Auth, language.PolicyCheckExpression, Key> & {
339
335
  readonly name: Name;
336
+ readonly executable: Executable;
340
337
  } : never;
341
338
  type ProjectionMethodByKey<Entries extends MethodProjection> = Readonly<{
342
339
  [Key in Entries['key']]: ResolvedMethodOfProjection<Extract<Entries, {
@@ -249,7 +249,7 @@ function compiledCallable(input, values, method, path) {
249
249
  }
250
250
  description(value.description, 'Callable description', `${path}/description`);
251
251
  if (value.policy !== undefined) {
252
- if (value.auth !== 'authorized' || (method && value.abstract === true)) {
252
+ if (value.auth !== 'authorized') {
253
253
  invalid('Callable Policy placement', undefined, `${path}/policy`);
254
254
  }
255
255
  policyCheck(value.policy, 0, `${path}/policy`);
@@ -2,6 +2,7 @@ import { json } from '@astrale-os/kernel-dsl/value';
2
2
  import { Key, PropertyKey as PropertyKeyValue } from '../../addressing/index.js';
3
3
  import { compareUnicode } from '../../addressing/ordering.js';
4
4
  import { composeMethods } from '../../language/callable/composition.js';
5
+ import { isMethodExecutable } from '../../language/callable/executable.js';
5
6
  import { policyObjectOrigin, policyVariableClass } from '../../language/index.js';
6
7
  import { branchesOf, branchProduct, capBranches, isConnected, targetMode, termKey, } from '../../language/policy/analysis/branches.js';
7
8
  import { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, } from '../../language/policy/analysis/budgets.js';
@@ -160,7 +161,7 @@ function validateClassFacets(context) {
160
161
  }
161
162
  if (located.value.kind === 'node') {
162
163
  for (const [index, method] of located.value.methods.entries()) {
163
- if (method.abstract === true && method.policy !== undefined) {
164
+ if (!isMethodExecutable(located.value, method) && method.policy !== undefined) {
164
165
  fail(`${located.pointer}/methods/${index}/policy`, 'An abstract Method cannot have a Policy.');
165
166
  }
166
167
  }
@@ -363,7 +364,7 @@ function validatePolicyTerm(context, term, path, scope) {
363
364
  function validatePolicyMethod(context, ref, path) {
364
365
  const owner = context.classes.get(Key.of(ref.owner))?.value;
365
366
  const method = owner?.kind === 'node' ? owner.methods.find((method) => method.name === ref.name) : undefined;
366
- if (method === undefined || method.abstract)
367
+ if (method === undefined || !isMethodExecutable(owner, method))
367
368
  fail(path, 'Policy Method ref must name an exact concrete Method declaration.');
368
369
  }
369
370
  function validatePolicyCycles(entry, local, entryIndex) {
@@ -1,4 +1,5 @@
1
1
  import { Key, MethodKey as MethodKeyValue, PropertyKey as PropertyKeyValue, } from '../../addressing/index.js';
2
+ import { isMethodExecutable } from '../../language/callable/executable.js';
2
3
  import { acceptPropertyValues } from '../../language/class/property-values.js';
3
4
  import { appendPointer } from '../../language/value/syntax/pointer.js';
4
5
  import { createMethodCollection, createPropertyCollection } from '../namespace/member-collection.js';
@@ -8,7 +9,6 @@ export function createClasses(definitions, validation) {
8
9
  .map((value) => [Key.of(value.ref), value]));
9
10
  const resolved = new Map();
10
11
  const visiting = new Set();
11
- const frontiers = new Map();
12
12
  const resolve = (ref) => {
13
13
  const key = Key.of(ref);
14
14
  const cached = resolved.get(key);
@@ -26,18 +26,14 @@ export function createClasses(definitions, validation) {
26
26
  }
27
27
  const shell = {};
28
28
  const effectiveProperties = new Map();
29
- const frontier = new Map();
30
29
  let inheritedData;
31
30
  for (const parent of parents) {
32
31
  for (const property of parent.properties) {
33
32
  effectiveProperties.set(property.key, property);
34
33
  }
35
- for (const [name, method] of frontiers.get(parent.key))
36
- frontier.set(name, method);
37
34
  if (parent.kind === 'node' && inheritedData === undefined)
38
35
  inheritedData = parent.data;
39
36
  }
40
- const effectiveMethods = new Map(frontier);
41
37
  const ownProperties = [];
42
38
  for (const [name, propertyDefinition] of Object.entries(definition.properties)) {
43
39
  const propertyKey = PropertyKeyValue.of(ref, name);
@@ -73,20 +69,16 @@ export function createClasses(definitions, validation) {
73
69
  policy: methodDefinition.policy,
74
70
  static: methodDefinition.static,
75
71
  abstract: methodDefinition.abstract,
72
+ executable: isMethodExecutable(definition, methodDefinition),
76
73
  ...(inputFields === undefined ? {} : { inputFields }),
77
74
  definition: methodDefinition,
78
75
  validateInput: (input) => validation.callableInput(methodKey, input),
79
76
  validateInputField: (field, input) => validation.callableInputField(methodKey, field, input),
80
77
  validateOutput: (output) => validation.callableOutput(methodKey, output),
81
78
  });
82
- if (method.abstract)
83
- frontier.set(name, method);
84
- effectiveMethods.set(name, method);
85
79
  (methodDefinition.static ? ownStaticMethods : ownInstanceMethods).push(method);
86
80
  }
87
81
  }
88
- const instanceMethods = [...effectiveMethods.values()].filter(({ definition }) => !definition.static);
89
- const staticMethods = [...effectiveMethods.values()].filter(({ definition }) => definition.static);
90
82
  Object.assign(shell, {
91
83
  ref: definition.ref,
92
84
  key,
@@ -97,8 +89,8 @@ export function createClasses(definitions, validation) {
97
89
  policies: definition.policies,
98
90
  data: definition.kind === 'node' ? (ownData ?? inheritedData) : undefined,
99
91
  properties: createPropertyCollection(effectiveProperties.values()),
100
- methods: createMethodCollection(instanceMethods),
101
- static: Object.freeze({ methods: createMethodCollection(staticMethods) }),
92
+ methods: createMethodCollection(ownInstanceMethods),
93
+ static: Object.freeze({ methods: createMethodCollection(ownStaticMethods) }),
102
94
  self: Object.freeze({
103
95
  data: definition.kind === 'node' ? ownData : undefined,
104
96
  properties: createPropertyCollection(ownProperties),
@@ -121,7 +113,6 @@ export function createClasses(definitions, validation) {
121
113
  },
122
114
  });
123
115
  const value = Object.freeze(shell);
124
- frontiers.set(key, frontier);
125
116
  resolved.set(key, value);
126
117
  visiting.delete(key);
127
118
  return value;
@@ -4,7 +4,7 @@ export { stateMachine } from './language/state/index.js';
4
4
  export type { EventOf, StateMachine, StateOf } from './language/state/index.js';
5
5
  export { PropertyValues } from './language/index.js';
6
6
  export * as metadata from './language/definition/metadata.js';
7
- export type { AnyResolvedClass, BoundMethodOf, BoundMethodShortcutsOf, CallableResultOf, CallableInputOf, CallableOutputOf, ClassSatisfactionKeysOf, ClassDefinition, CoreDefinition, CoreEdge, FunctionAuth, FunctionDefinition, MethodDefinition, MethodOwnerKeyOf, PolicyCheckExpression, PolicyDefinition, PropertyInputOf, PropertyAccessOf, PropertyOutputOf, PropertyShortcutsOf, PropertyValuesOf, ResolvedClass, ResolvedCoreDefinition, ResolvedData, ResolvedFunction, ResolvedMethod, ResolvedMethodCollection, ResolvedPolicy, ResolvedProperty, ResolvedView, MethodAccessOf, SelfMethodsOf, SelfPropertiesOf, SelfStaticMethodsOf, StaticMethodsOf, ViewDefinition, } from './language/index.js';
7
+ export type { AnyResolvedClass, BoundMethodOf, BoundMethodShortcutsOf, CallableResultOf, CallableInputOf, CallableOutputOf, ClassSatisfactionKeysOf, ClassDefinition, CoreDefinition, CoreEdge, FunctionAuth, FunctionDefinition, MethodDefinition, MethodOwnerKeyOf, PolicyCheckExpression, PolicyDefinition, PropertyInputOf, PropertyAccessOf, PropertyOutputOf, PropertyShortcutsOf, PropertyValuesOf, ResolvedClass, ResolvedCoreDefinition, ResolvedData, ResolvedFunction, ExecutableMethod, ResolvedMethod, ResolvedMethodCollection, ResolvedPolicy, ResolvedProperty, ResolvedView, MethodAccessOf, SelfMethodsOf, SelfPropertiesOf, SelfStaticMethodsOf, StaticMethodsOf, ViewDefinition, } from './language/index.js';
8
8
  export { acceptDefinitionRef, callableAddress, ClassKey, equalDefinitionRefs, isDefinitionRef, Key, MethodKey, PropertyKey, } from './addressing/index.js';
9
9
  export type { ClassRef, CoreRef, DefinitionBase, DefinitionKey, DefinitionRef, FunctionRef, MethodAddress, PolicyRef, Revision, ViewRef, } from './addressing/index.js';
10
10
  export type { Definition } from './language/index.js';
@@ -32,9 +32,9 @@ export function composeMethods(parents, own, abstract, sameSignature, report) {
32
32
  const missing = new Set();
33
33
  for (const required of requirements.values()) {
34
34
  const local = own.get(required.name);
35
- if ((local === undefined || local.declaration.abstract) && !missing.has(required.name)) {
35
+ if (local === undefined && !missing.has(required.name)) {
36
36
  missing.add(required.name);
37
- report(`Concrete Class requires a local concrete implementation of ${required.key}.`);
37
+ report(`Concrete Class requires a local Method declaration of ${required.key}.`);
38
38
  }
39
39
  }
40
40
  }
@@ -0,0 +1,6 @@
1
+ /** A local Method is executable unless both its contract and its owner are abstract. */
2
+ export declare function isMethodExecutable(owner: {
3
+ readonly abstract: boolean;
4
+ }, method: {
5
+ readonly abstract: boolean;
6
+ }): boolean;
@@ -0,0 +1,4 @@
1
+ /** A local Method is executable unless both its contract and its owner are abstract. */
2
+ export function isMethodExecutable(owner, method) {
3
+ return !method.abstract || !owner.abstract;
4
+ }
@@ -21,12 +21,14 @@ export interface ResolvedMethod<out Input = unknown, out Output = unknown, out S
21
21
  readonly input: MethodDefinition['input'];
22
22
  readonly output: MethodDefinition['output'];
23
23
  readonly auth: Auth;
24
- readonly policy?: Abstract extends true ? never : Auth extends 'authorized' ? Policy : never;
24
+ readonly policy?: Auth extends 'authorized' ? Policy : never;
25
25
  readonly static: Static;
26
26
  readonly abstract: Abstract;
27
+ /** Whether this exact local declaration requires an implementation. */
28
+ readonly executable: Abstract extends false ? true : boolean;
27
29
  /** Present only when the callable input is a safely enumerable closed object. */
28
30
  readonly inputFields?: readonly string[];
29
- readonly definition: CallableDefinitionOf<MethodDefinition, Auth, Abstract extends true ? never : Policy> & {
31
+ readonly definition: CallableDefinitionOf<MethodDefinition, Auth, Policy> & {
30
32
  readonly static: Static;
31
33
  readonly abstract: Abstract;
32
34
  };
@@ -65,4 +67,8 @@ export type MethodOwnerKeyOf<Method> = Method extends {
65
67
  type MethodOwnerKeyOfKey<ExactKey extends MethodKey> = ExactKey extends `${infer Origin}:class.${infer Owner}.method.${string}` ? DefinitionKey<Extract<Origin, Key.Origin>, 'class', Owner> : never;
66
68
  export type CallableInputOf<Callable> = Callable extends ResolvedMethod<infer Input, unknown, boolean> ? Input : Callable extends ResolvedFunction<infer Input, unknown> ? Input : never;
67
69
  export type CallableOutputOf<Callable> = Callable extends ResolvedMethod<unknown, infer Output, boolean> ? Output : Callable extends ResolvedFunction<unknown, infer Output> ? Output : never;
70
+ /** An exact local Method whose Schema requires an implementation. */
71
+ export type ExecutableMethod<Input = unknown, Output = unknown, Static extends boolean = boolean> = ResolvedMethod<Input, Output, Static> & {
72
+ readonly executable: true;
73
+ };
68
74
  export {};
@@ -40,7 +40,9 @@ export type CallableResultOf<Callable, Binary = unknown> = CallableOutputOf<Call
40
40
  } ? AsyncIterable<Item> : Output extends {
41
41
  readonly mode: 'binary';
42
42
  } ? Binary : never : never;
43
- type ExecutableMethod<Method> = Method extends ResolvedMethod<unknown, unknown, false, infer Inheritance> ? Inheritance extends 'abstract' ? never : Method : never;
43
+ type ExecutableMethod<Method> = Method extends ResolvedMethod<unknown, unknown, false> & {
44
+ readonly executable: true;
45
+ } ? Method : never;
44
46
  export type BoundMethodOf<Method, Binary = unknown> = ExecutableMethod<Method> extends infer Callable ? [Callable] extends [never] ? never : (input: CallableInputOf<Callable>) => Promise<CallableResultOf<Callable, Binary>> : never;
45
47
  /** Collision-safe direct bound Methods. Client supplies graph/wrapper reserved names. */
46
48
  export type BoundMethodShortcutsOf<Class, Binary = unknown, Reserved extends MemberName = never> = Readonly<{
@@ -1,3 +1,4 @@
1
+ export { isMethodExecutable } from './callable/executable.js';
1
2
  export type { ClassRef, CoreRef, DefinitionBase, DefinitionKey, DefinitionRef, FunctionRef, MethodKey, PolicyRef, PropertyKey, ViewRef, } from '../addressing/index.js';
2
3
  export type { Value as PropertyValue } from '@astrale-os/kernel-dsl/value';
3
4
  export type { JsonSchema as ValueSchema, JsonSchemaObject as ValueSchemaObject, } from './value/model/schema.js';
@@ -1,3 +1,4 @@
1
+ export { isMethodExecutable } from './callable/executable.js';
1
2
  export { stateMachine } from './state/index.js';
2
3
  export { PropertyValues } from './class/property-values.js';
3
4
  export { policyVariableClass, policyVariableSelector, policyObjectKey, policyObjectOrigin, } from './policy/model/policy.js';
@@ -1,5 +1,6 @@
1
1
  import { Key } from '../../addressing/key.js';
2
2
  import { definitionRefIndex } from '../../addressing/ordering.js';
3
+ import { isMethodExecutable } from '../../language/callable/executable.js';
3
4
  import { admitStateTopology } from '../../language/state/topology.js';
4
5
  import { classifyOrdering } from '../../language/value/ordering.js';
5
6
  import { diagnostic } from '../diagnostic.js';
@@ -71,7 +72,7 @@ function validateFacet(environment, declaration, pointer, diagnostics) {
71
72
  return;
72
73
  for (const [name, method] of Object.entries(declaration.methods)) {
73
74
  const methodPointer = `${pointer}/methods/${escapePointer(name)}`;
74
- if (method.abstract === true && method.policy !== undefined) {
75
+ if (!isMethodExecutable(declaration, method) && method.policy !== undefined) {
75
76
  diagnostics.push(diagnostic('DV_METHOD_ABSTRACT', `${methodPointer}/policy`, 'Abstract Methods cannot have a Policy.'));
76
77
  }
77
78
  }
@@ -190,14 +190,6 @@ const methodDeclarationSchema = strictObject({
190
190
  static: boolean(),
191
191
  abstract: boolean(),
192
192
  }).superRefine((method, context) => {
193
- if (method.abstract === true && method.policy !== undefined) {
194
- context.addIssue({
195
- code: 'custom',
196
- path: ['policy'],
197
- message: 'An abstract method cannot declare a policy.',
198
- params: { structureCode: 'STRUCTURE_ABSTRACT_POLICY' },
199
- });
200
- }
201
193
  if (method.auth !== 'authorized' && method.policy !== undefined) {
202
194
  context.addIssue({
203
195
  code: 'custom',
@@ -1,4 +1,5 @@
1
1
  import { definitionRefIndex } from '../../../addressing/ordering.js';
2
+ import { isMethodExecutable } from '../../../language/callable/executable.js';
2
3
  import { policyObjectKey, policyObjectOrigin } from '../../../language/index.js';
3
4
  const KERNEL_ORIGIN = 'kernel.astrale.ai';
4
5
  const PROJECTION_CLASS = nodeClassRef('Class');
@@ -26,7 +27,7 @@ export function referenceContracts(validation, ref, pointer) {
26
27
  case 'method': {
27
28
  const declaringClass = owner.classes[ref.owner.name];
28
29
  const method = declaringClass?.kind === 'node' ? declaringClass.methods[ref.name] : undefined;
29
- return method === undefined || method.abstract
30
+ return method === undefined || !isMethodExecutable(declaringClass, method)
30
31
  ? invalidPolicyObjectRef(validation, ref, pointer)
31
32
  : [{ kind: 'exact', ref: PROJECTION_FUNCTION }];
32
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "0.2.0-beta.32",
3
+ "version": "0.2.0-beta.33",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {