@astrale-os/kernel-dsl 0.2.0-beta.34 → 0.2.0-beta.35

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,5 +1,6 @@
1
1
  import type { Key as SemanticKey } from '../../addressing/index.js';
2
2
  import type { Revision } from '../../addressing/index.js';
3
+ import type { ResolvedFunction, ResolvedMethod } from '../../language/callable/resolved.js';
3
4
  import type { DomainSchema } from '../model/schema.js';
4
5
  import { Key } from '../../addressing/index.js';
5
6
  /**
@@ -42,3 +43,11 @@ export interface DependencyMeaningComparison {
42
43
  export declare function compareDependencyMeaning(dependent: DomainSchema, target: DomainSchema): DependencyMeaningComparison;
43
44
  /** Compare one explicit non-empty source member surface and its reachable V1 meaning. */
44
45
  export declare function compareMemberMeaning(source: DomainSchema, target: DomainSchema, roots: readonly [SemanticKey, ...SemanticKey[]]): DependencyMeaningComparison;
46
+ /**
47
+ * Fingerprint the contract a caller compiles against, independently of its Domain revision: the
48
+ * exact key, the owner, dispatch and abstractness of a Method, and the semantic input and output
49
+ * contracts; authorization is excluded (DM-CALLABLE-FINGERPRINT). A static consumer pins this
50
+ * instead of a Domain revision, so a dependency release that leaves the callable contract untouched
51
+ * keeps every bound invocation valid.
52
+ */
53
+ export declare function callableFingerprint(callable: ResolvedFunction | ResolvedMethod): MeaningFingerprint;
@@ -8,7 +8,7 @@ import { revisionOfDomainSchema } from '../canonical/revision.js';
8
8
  import { SchemaError, diagnostic } from '../diagnostic.js';
9
9
  import { knownDomainClosure, lookupForDomainClosure } from '../resolution/closure.js';
10
10
  import { resolve } from '../resolution/domain.js';
11
- import { collectCallableRefs, collectClassPolicyRefs, collectClassRefs, collectCoreRefs, collectEndpointRefs, collectPolicyDefinitionRefs, collectValueDefinitionRefs, } from '../resolution/origins.js';
11
+ import { collectCallableContractRefs, collectCallableRefs, collectClassPolicyRefs, collectClassRefs, collectCoreRefs, collectEndpointRefs, collectPolicyDefinitionRefs, collectValueDefinitionRefs, } from '../resolution/origins.js';
12
12
  import { validateDomainSchemaSemantics } from '../validation/domain.js';
13
13
  const VALUE_SCHEMA_ANNOTATIONS = new Set([
14
14
  '$comment',
@@ -59,6 +59,23 @@ export function compareMemberMeaning(source, target, roots) {
59
59
  const meanings = collectReachableMeanings(coordinates, source.origin, context);
60
60
  return compareSourceMeanings(source, target, meanings);
61
61
  }
62
+ /**
63
+ * Fingerprint the contract a caller compiles against, independently of its Domain revision: the
64
+ * exact key, the owner, dispatch and abstractness of a Method, and the semantic input and output
65
+ * contracts; authorization is excluded (DM-CALLABLE-FINGERPRINT). A static consumer pins this
66
+ * instead of a Domain revision, so a dependency release that leaves the callable contract untouched
67
+ * keeps every bound invocation valid.
68
+ */
69
+ export function callableFingerprint(callable) {
70
+ return fingerprintMeaning('owner' in callable
71
+ ? {
72
+ kind: 'method',
73
+ key: callable.key,
74
+ owner: callable.owner.key,
75
+ ...semanticMethod(callable),
76
+ }
77
+ : { kind: 'function', key: callable.key, ...semanticFunction(callable) });
78
+ }
62
79
  function contextOf(root) {
63
80
  const schemas = new Map([
64
81
  [root.origin, root],
@@ -230,7 +247,7 @@ function collectReachableMeanings(roots, selectedOrigin, context) {
230
247
  }
231
248
  for (const method of analysis.methods.values()) {
232
249
  retainMeaning(meanings, selectedOrigin, methodCoordinate(method.owner, method.name), methodMeaning(method));
233
- collectCallableRefs(method.declaration, push);
250
+ collectCallableContractRefs(method.declaration, push);
234
251
  }
235
252
  collectClassPolicyRefs(declaration, push);
236
253
  }
@@ -287,7 +304,7 @@ function collectCoordinateSemanticRefs(context, coordinate, add) {
287
304
  }
288
305
  const method = [...analysis.methods.values()].find((candidate) => MethodKey.of(candidate.owner, candidate.name) === coordinate.key);
289
306
  if (method !== undefined)
290
- collectCallableRefs(method.declaration, add);
307
+ collectCallableContractRefs(method.declaration, add);
291
308
  }
292
309
  function collectMemberSemanticRefs(owner, ref, add) {
293
310
  switch (ref.kind) {
@@ -485,19 +502,16 @@ function methodMeaning(method) {
485
502
  };
486
503
  }
487
504
  function semanticFunction(declaration) {
488
- const { description: _description, ...rest } = declaration;
489
505
  return {
490
- ...rest,
491
506
  input: semanticValueSchema(declaration.input),
492
507
  output: semanticOutput(declaration.output),
493
508
  };
494
509
  }
495
510
  function semanticMethod(declaration) {
496
- const { description: _description, ...rest } = declaration;
497
511
  return {
498
- ...rest,
499
- input: semanticValueSchema(declaration.input),
500
- output: semanticOutput(declaration.output),
512
+ static: declaration.static,
513
+ abstract: declaration.abstract,
514
+ ...semanticFunction(declaration),
501
515
  };
502
516
  }
503
517
  function semanticOutput(output) {
@@ -11,7 +11,7 @@ export type { SchemaDiagnosticCode as DiagnosticCode } from './diagnostic.js';
11
11
  export { acceptDomainSchema as accept } from './admission/accept.js';
12
12
  export { decodeDomainSchema as decode, encodeDomainSchema as encode, serializeDomainSchema as serialize, } from './codec/schema.js';
13
13
  export { revisionOfDomainSchema as revision } from './canonical/revision.js';
14
- export { compareDependencyMeaning, compareMemberMeaning } from './compatibility/meaning.js';
14
+ export { callableFingerprint, compareDependencyMeaning, compareMemberMeaning, } from './compatibility/meaning.js';
15
15
  export type { DependencyMeaningChange, DependencyMeaningChangeKind, DependencyMeaningComparison, DependencyMeaningLevel, MeaningFingerprint, } from './compatibility/meaning.js';
16
16
  export { header } from './codec/header.js';
17
17
  export { DOMAIN_FORMAT as FORMAT, DOMAIN_VERSION as VERSION } from './model/format.js';
@@ -4,7 +4,7 @@ export const resolve = resolveDomainSchema;
4
4
  export { acceptDomainSchema as accept } from './admission/accept.js';
5
5
  export { decodeDomainSchema as decode, encodeDomainSchema as encode, serializeDomainSchema as serialize, } from './codec/schema.js';
6
6
  export { revisionOfDomainSchema as revision } from './canonical/revision.js';
7
- export { compareDependencyMeaning, compareMemberMeaning } from './compatibility/meaning.js';
7
+ export { callableFingerprint, compareDependencyMeaning, compareMemberMeaning, } from './compatibility/meaning.js';
8
8
  export { header } from './codec/header.js';
9
9
  export { DOMAIN_FORMAT as FORMAT, DOMAIN_VERSION as VERSION } from './model/format.js';
10
10
  export { compile, load } from '../compiled/index.js';
@@ -21,5 +21,7 @@ export declare function collectEndpointRefs(declaration: Extract<ClassDefinition
21
21
  readonly kind: 'edge';
22
22
  }>, add: ReferenceCollector): void;
23
23
  export declare function collectCallableRefs(declaration: FunctionDefinition | MethodDefinition, add: ReferenceCollector): void;
24
+ /** References inside the contract a caller compiles against: the input and output value schemas. */
25
+ export declare function collectCallableContractRefs(declaration: Pick<FunctionDefinition | MethodDefinition, 'input' | 'output'>, add: ReferenceCollector): void;
24
26
  export declare function collectPolicyDefinitionRefs(declaration: PolicyDefinition, add: ReferenceCollector): void;
25
27
  export declare function collectValueDefinitionRefs(schema: JsonSchema, add: ReferenceCollector): void;
@@ -66,13 +66,17 @@ export function collectEndpointRefs(declaration, add) {
66
66
  endpoints[1].accepts.forEach((ref) => add(ref, 'endpoint'));
67
67
  }
68
68
  export function collectCallableRefs(declaration, add) {
69
+ collectCallableContractRefs(declaration, add);
70
+ if (declaration.policy !== undefined)
71
+ collectPolicyCheckRefs(declaration.policy, add);
72
+ }
73
+ /** References inside the contract a caller compiles against: the input and output value schemas. */
74
+ export function collectCallableContractRefs(declaration, add) {
69
75
  collectValueDefinitionRefs(declaration.input, add);
70
76
  if (declaration.output.mode === 'value')
71
77
  collectValueDefinitionRefs(declaration.output.schema, add);
72
78
  if (declaration.output.mode === 'stream')
73
79
  collectValueDefinitionRefs(declaration.output.item, add);
74
- if (declaration.policy !== undefined)
75
- collectPolicyCheckRefs(declaration.policy, add);
76
80
  }
77
81
  export function collectPolicyDefinitionRefs(declaration, add) {
78
82
  collectPolicyExpressionRefs(declaration.expression, add);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-dsl",
3
- "version": "0.2.0-beta.34",
3
+ "version": "0.2.0-beta.35",
4
4
  "description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {