@astrale-os/sdk 0.5.0-beta.99 → 0.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -2
- package/dist/application/action/action.d.ts +7 -4
- package/dist/application/action/authoring.d.ts +2 -1
- package/dist/application/action/context.d.ts +18 -13
- package/dist/application/action/define.d.ts +5 -1
- package/dist/application/action/define.js +6 -1
- package/dist/application/action/index.d.ts +2 -1
- package/dist/application/dependency/index.d.ts +1 -0
- package/dist/application/dependency/invoker.d.ts +26 -0
- package/dist/application/error/error.d.ts +23 -0
- package/dist/application/error/error.js +87 -0
- package/dist/application/error/index.d.ts +2 -0
- package/dist/application/error/index.js +1 -0
- package/dist/application/index.d.ts +2 -2
- package/dist/application/integration/authentication.d.ts +10 -0
- package/dist/application/integration/authentication.typecheck.js +18 -0
- package/dist/application/integration/client.d.ts +2 -0
- package/dist/application/integration/client.js +19 -2
- package/dist/application/integration/index.d.ts +1 -0
- package/dist/application/integration/operation.d.ts +3 -0
- package/dist/application/mutation/authoring/builder.js +2 -2
- package/dist/application/mutation/authoring/endpoint.d.ts +3 -3
- package/dist/application/mutation/authoring/endpoint.js +9 -0
- package/dist/application/mutation/failure.js +13 -7
- package/dist/application/mutation/index.d.ts +1 -0
- package/dist/application/requirements/{profiles.d.ts → core.d.ts} +5 -3
- package/dist/application/requirements/{profiles.js → core.js} +6 -6
- package/dist/application/requirements/index.d.ts +4 -4
- package/dist/application/requirements/index.js +5 -5
- package/dist/application/requirements/requirement.d.ts +3 -2
- package/dist/application/runtime/authoring.d.ts +1 -0
- package/dist/application/runtime/callables.js +2 -2
- package/dist/application/runtime/declarations.d.ts +43 -0
- package/dist/application/runtime/define.d.ts +2 -1
- package/dist/application/view/index.d.ts +1 -1
- package/dist/application/view/route.d.ts +4 -0
- package/dist/application/view/route.js +5 -1
- package/dist/application/workflow/authoring.d.ts +1 -0
- package/dist/application/workflow/context.d.ts +2 -1
- package/dist/application/workflow/define.d.ts +5 -1
- package/dist/application/workflow/define.js +6 -1
- package/dist/application/workflow/index.d.ts +1 -0
- package/dist/application/workflow/runner/runner.d.ts +3 -2
- package/dist/application/workflow/workflow.d.ts +4 -3
- package/dist/deployment/adapter/adapter.d.ts +12 -7
- package/dist/deployment/adapter/define.d.ts +5 -2
- package/dist/deployment/adapter/define.js +15 -17
- package/dist/deployment/adapter/deploy/context.d.ts +6 -0
- package/dist/deployment/adapter/deploy/result.d.ts +2 -0
- package/dist/deployment/adapter/index.d.ts +2 -3
- package/dist/deployment/adapter/index.js +1 -1
- package/dist/deployment/adapter/prepare/context.d.ts +13 -5
- package/dist/deployment/authoring.d.ts +1 -1
- package/dist/deployment/build/compile.js +21 -19
- package/dist/deployment/build/frontend/compilation.d.ts +2 -1
- package/dist/deployment/build/frontend/compilation.js +1 -0
- package/dist/deployment/build/material.js +5 -5
- package/dist/deployment/deploy.d.ts +10 -4
- package/dist/deployment/deploy.js +5 -5
- package/dist/deployment/deployment.d.ts +8 -5
- package/dist/deployment/deployment.js +10 -1
- package/dist/deployment/index.d.ts +5 -4
- package/dist/deployment/index.js +3 -2
- package/dist/deployment/release/addressing.d.ts +6 -2
- package/dist/deployment/release/addressing.js +9 -4
- package/dist/deployment/release/publication/callables.js +1 -1
- package/dist/deployment/release/publication/index.d.ts +1 -1
- package/dist/deployment/release/publication/index.js +1 -1
- package/dist/deployment/release/publication/routes.js +1 -1
- package/dist/deployment/release/publication/seal.d.ts +0 -1
- package/dist/deployment/release/publication/seal.js +4 -5
- package/dist/deployment/release/publication/views.js +2 -1
- package/dist/deployment/verify/preflight/artifact.js +1 -1
- package/dist/deployment/verify/readiness/deployment.js +7 -3
- package/dist/deployment/verify/readiness/identity.js +1 -1
- package/dist/deployment/verify/readiness/publication.js +2 -2
- package/dist/execution/identity/authentication.js +0 -1
- package/dist/execution/identity/exchange.d.ts +1 -0
- package/dist/execution/identity/exchange.js +1 -1
- package/dist/execution/identity/jwks.js +1 -1
- package/dist/execution/invocation/admission/authentication.d.ts +6 -3
- package/dist/execution/invocation/admission/authentication.js +16 -6
- package/dist/execution/invocation/admission/authority.d.ts +2 -2
- package/dist/execution/invocation/dependency/bind.d.ts +5 -0
- package/dist/execution/invocation/dependency/bind.js +68 -0
- package/dist/execution/invocation/dependency/index.d.ts +1 -0
- package/dist/execution/invocation/dependency/index.js +1 -0
- package/dist/execution/invocation/dispatch/action.js +19 -2
- package/dist/execution/invocation/dispatch/context.d.ts +4 -4
- package/dist/execution/invocation/dispatch/context.js +29 -9
- package/dist/execution/invocation/dispatch/workflow.js +17 -4
- package/dist/execution/invocation/integration/authentication.d.ts +5 -0
- package/dist/execution/invocation/integration/authentication.js +53 -0
- package/dist/execution/invocation/integration/call.d.ts +7 -1
- package/dist/execution/invocation/integration/call.js +8 -3
- package/dist/execution/invocation/integration/clients.d.ts +2 -2
- package/dist/execution/invocation/integration/clients.js +2 -2
- package/dist/execution/invocation/lifecycle/active.js +30 -5
- package/dist/execution/invocation/result/errors.d.ts +1 -0
- package/dist/execution/invocation/result/errors.js +15 -10
- package/dist/execution/service/create.js +3 -1
- package/dist/execution/service/service.d.ts +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/platform/auth/index.d.ts +1 -1
- package/dist/platform/auth/index.js +0 -1
- package/dist/platform/graph/alias.d.ts +6 -0
- package/dist/platform/graph/alias.js +6 -0
- package/dist/platform/graph/document/index.d.ts +2 -1
- package/dist/platform/graph/document/index.js +2 -1
- package/dist/platform/graph/index.d.ts +2 -1
- package/dist/platform/graph/index.js +2 -1
- package/dist/platform/schema/class-authoring.d.ts +37 -0
- package/dist/platform/schema/class-authoring.js +20 -0
- package/dist/platform/schema/class-icon.d.ts +15 -0
- package/dist/platform/schema/class-icon.js +46 -0
- package/dist/platform/schema/error.d.ts +11 -0
- package/dist/platform/schema/error.js +34 -0
- package/dist/platform/schema/errors/index.d.ts +3 -0
- package/dist/platform/schema/errors/index.js +2 -0
- package/dist/platform/schema/icons/index.d.ts +2 -0
- package/dist/platform/schema/icons/index.js +2 -0
- package/dist/platform/schema/index.d.ts +20 -13
- package/dist/platform/schema/index.js +9 -4
- package/dist/platform/schema/kernel.d.ts +22 -0
- package/dist/platform/schema/kernel.js +5 -0
- package/dist/platform/schema/node-id.d.ts +3 -0
- package/dist/platform/schema/node-id.js +6 -0
- package/dist/platform/schema/property.d.ts +12 -0
- package/dist/platform/schema/property.js +3 -0
- package/dist/platform/schema/schema-authoring.d.ts +48 -0
- package/dist/platform/schema/schema-authoring.js +3 -0
- package/dist/platform/schema/state-property.d.ts +11 -0
- package/dist/platform/schema/state-property.js +3 -0
- package/dist/project/admit.d.ts +4 -0
- package/dist/project/admit.js +22 -0
- package/dist/project/define.d.ts +12 -0
- package/dist/project/define.js +106 -0
- package/dist/project/index.d.ts +4 -0
- package/dist/project/index.js +2 -0
- package/dist/project/project.d.ts +24 -0
- package/dist/project/project.js +1 -0
- package/dist/testing/dataset/admission.d.ts +13 -0
- package/dist/testing/dataset/admission.js +107 -0
- package/dist/testing/dataset/builder.d.ts +42 -0
- package/dist/testing/dataset/builder.js +127 -0
- package/dist/testing/dataset/codec.d.ts +6 -0
- package/dist/testing/dataset/codec.js +113 -0
- package/dist/testing/dataset/dataset.d.ts +58 -0
- package/dist/testing/dataset/dataset.js +2 -0
- package/dist/testing/dataset/define.d.ts +33 -0
- package/dist/testing/dataset/define.js +105 -0
- package/dist/testing/dataset/index.d.ts +8 -0
- package/dist/testing/dataset/index.js +4 -0
- package/dist/testing/dataset/references.d.ts +14 -0
- package/dist/testing/dataset/references.js +56 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/load.d.ts +14 -0
- package/dist/testing/load.js +44 -0
- package/dist/testing/reference.d.ts +11 -0
- package/dist/testing/reference.js +19 -0
- package/dist/testing/tests.d.ts +12 -0
- package/dist/testing/tests.js +31 -0
- package/dist/tooling/cli/arguments.d.ts +7 -4
- package/dist/tooling/cli/arguments.js +82 -107
- package/dist/tooling/cli/astrale/authority.d.ts +5 -0
- package/dist/tooling/cli/astrale/authority.js +11 -0
- package/dist/tooling/cli/astrale/executable.d.ts +2 -0
- package/dist/tooling/cli/astrale/executable.js +47 -0
- package/dist/tooling/cli/astrale/failure.d.ts +6 -0
- package/dist/tooling/cli/astrale/failure.js +48 -0
- package/dist/tooling/cli/astrale/instance.d.ts +11 -0
- package/dist/tooling/cli/astrale/instance.js +52 -0
- package/dist/tooling/cli/astrale/process.d.ts +13 -0
- package/dist/tooling/cli/astrale/process.js +94 -0
- package/dist/tooling/cli/astrale/version.d.ts +18 -0
- package/dist/tooling/cli/astrale/version.js +55 -0
- package/dist/tooling/cli/bun.js +1 -1
- package/dist/tooling/cli/credential.d.ts +2 -0
- package/dist/tooling/cli/credential.js +57 -0
- package/dist/tooling/cli/development/candidate.d.ts +25 -0
- package/dist/tooling/cli/development/candidate.js +176 -0
- package/dist/tooling/cli/development/deployment.d.ts +16 -0
- package/dist/tooling/cli/development/deployment.js +39 -0
- package/dist/tooling/cli/development/develop.d.ts +4 -3
- package/dist/tooling/cli/development/develop.js +125 -289
- package/dist/tooling/cli/development/lease.d.ts +18 -0
- package/dist/tooling/cli/development/lease.js +163 -0
- package/dist/tooling/cli/development/lifecycle.js +4 -0
- package/dist/tooling/cli/development/project-imports.d.ts +22 -0
- package/dist/tooling/cli/development/project-imports.js +39 -0
- package/dist/tooling/cli/development/project-lock.d.ts +3 -4
- package/dist/tooling/cli/development/project-lock.js +14 -166
- package/dist/tooling/cli/development/release-evidence.d.ts +4 -0
- package/dist/tooling/cli/development/release-evidence.js +10 -0
- package/dist/tooling/cli/development/report.d.ts +6 -0
- package/dist/tooling/cli/development/report.js +14 -0
- package/dist/tooling/cli/development/source-watch.js +53 -5
- package/dist/tooling/cli/development/sources.d.ts +7 -0
- package/dist/tooling/cli/development/sources.js +48 -0
- package/dist/tooling/cli/development/target-lock.d.ts +16 -0
- package/dist/tooling/cli/development/target-lock.js +68 -0
- package/dist/tooling/cli/development/view.d.ts +28 -0
- package/dist/tooling/cli/development/view.js +151 -0
- package/dist/tooling/cli/environment-release.d.ts +21 -0
- package/dist/tooling/cli/environment-release.js +46 -0
- package/dist/tooling/cli/evidence.d.ts +11 -0
- package/dist/tooling/cli/evidence.js +53 -0
- package/dist/tooling/cli/help.js +78 -34
- package/dist/tooling/cli/index.d.ts +1 -1
- package/dist/tooling/cli/index.js +1 -1
- package/dist/tooling/cli/installation/index.d.ts +2 -0
- package/dist/tooling/cli/installation/index.js +1 -0
- package/dist/tooling/cli/installation/observation.d.ts +10 -0
- package/dist/tooling/cli/installation/observation.js +44 -0
- package/dist/tooling/cli/installation/reconcile.d.ts +32 -0
- package/dist/tooling/cli/installation/reconcile.js +122 -0
- package/dist/tooling/cli/orchestrate.js +84 -44
- package/dist/tooling/cli/project.d.ts +17 -0
- package/dist/tooling/cli/project.js +18 -0
- package/dist/tooling/cli/test.d.ts +12 -0
- package/dist/tooling/cli/test.js +47 -0
- package/dist/tooling/cli/upgrade/index.d.ts +6 -0
- package/dist/tooling/cli/upgrade/index.js +115 -0
- package/dist/tooling/cli/upgrade/manifest.d.ts +18 -0
- package/dist/tooling/cli/upgrade/manifest.js +77 -0
- package/dist/tooling/cli/upgrade/process.d.ts +2 -0
- package/dist/tooling/cli/upgrade/process.js +57 -0
- package/dist/tooling/linter/adapters/typescript/imports.js +2 -0
- package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -0
- package/dist/tooling/linter/adapters/typescript/index.js +1 -0
- package/dist/tooling/linter/adapters/typescript/query-collection-type.js +4 -51
- package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +9 -0
- package/dist/tooling/linter/adapters/typescript/type-analysis.js +55 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +28 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.js +234 -0
- package/dist/tooling/linter/implementations/source/dependencies.d.ts +2 -0
- package/dist/tooling/linter/implementations/source/dependencies.js +219 -0
- package/dist/tooling/linter/implementations/source/global.js +52 -2
- package/dist/tooling/linter/implementations/source/mutations.js +520 -38
- package/dist/tooling/linter/implementations/source/providers.js +19 -164
- package/dist/tooling/linter/implementations/source/schema.js +454 -2
- package/dist/tooling/linter/implementations/source/verifiers.js +2 -0
- package/dist/tooling/linter/implementations/source/workflows.js +8 -35
- package/dist/tooling/linter/policy/generated.js +2 -2
- package/dist/tooling/linter/requirements/registry.js +9 -3
- package/dist/tooling/packaging/declarations/normalize.js +3 -38
- package/dist/tooling/packaging/declarations/paths.d.ts +5 -0
- package/dist/tooling/packaging/declarations/paths.js +38 -0
- package/dist/tooling/packaging/finalize.d.ts +13 -0
- package/dist/tooling/packaging/finalize.js +62 -0
- package/dist/tooling/packaging/index.d.ts +2 -0
- package/dist/tooling/packaging/index.js +1 -0
- package/dist/tooling/packaging/javascript.d.ts +3 -0
- package/dist/tooling/packaging/javascript.js +45 -2
- package/dist/tooling/packaging/packaging.d.ts +2 -5
- package/dist/tooling/packaging/packaging.js +6 -30
- package/package.json +42 -12
- package/CHANGELOG.md +0 -1506
- package/dist/deployment/adapter/development/context.d.ts +0 -18
- package/dist/deployment/adapter/development/index.d.ts +0 -4
- package/dist/deployment/adapter/development/input.d.ts +0 -6
- package/dist/deployment/adapter/development/placement.d.ts +0 -15
- package/dist/deployment/adapter/development/session.d.ts +0 -9
- /package/dist/{deployment/adapter/development → application/dependency}/index.js +0 -0
- /package/dist/{deployment/adapter/development/context.js → application/dependency/invoker.js} +0 -0
- /package/dist/{deployment/adapter/development/input.js → application/integration/authentication.js} +0 -0
- /package/dist/{deployment/adapter/development/placement.js → application/integration/authentication.typecheck.d.ts} +0 -0
- /package/dist/{deployment/adapter/development/session.js → application/runtime/declarations.js} +0 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { propertyChain, resolveImportedSymbol, unwrap, visit, } from '../../adapters/typescript/index.js';
|
|
3
|
+
import { applicationFunctionRequirements, callableReference, callableSelector, declaredDomainDependencies, remoteCallableKey, } from './callable-requirements.js';
|
|
4
|
+
import { ambiguity, calls, isForeignDomain, production, violation } from './shared.js';
|
|
5
|
+
export const dependencyRules = [
|
|
6
|
+
{
|
|
7
|
+
id: 'FNC-XDOM-DECLARED',
|
|
8
|
+
ruleRevision: '269e22202a0fbec5ec4afc3579ca504eed457f44046b99e64a38d08634294909',
|
|
9
|
+
evaluate(project) {
|
|
10
|
+
const evidence = [];
|
|
11
|
+
for (const file of production(project, 'functions')) {
|
|
12
|
+
for (const sourceImport of file.imports) {
|
|
13
|
+
if (isForeignDomain(sourceImport.specifier))
|
|
14
|
+
evidence.push(violation(file, sourceImport.node, `Handler imports foreign Domain ${sourceImport.specifier}; use declared dependencies or an Integration.`));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return [...evidence, ...observeInvocations(project).evidence];
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'FNC-XDOM-REQ',
|
|
22
|
+
ruleRevision: 'a646c9931bb8b5a011a2cf7431f362fcb0e63be49dfc4c1bc0eba77a8aca8fdb',
|
|
23
|
+
evaluate(project) {
|
|
24
|
+
const { targets, evidence } = observeInvocations(project);
|
|
25
|
+
const declared = applicationFunctionRequirements(project);
|
|
26
|
+
const results = evidence.filter(({ kind }) => kind === 'ambiguity');
|
|
27
|
+
for (const target of targets) {
|
|
28
|
+
if (declared.keys.has(remoteCallableKey(target)))
|
|
29
|
+
continue;
|
|
30
|
+
results.push((declared.indeterminate ? ambiguity : violation)(target.file, target.node, `Remote Domain callable ${target.module} ${target.selector.join('.')} lacks one provable exact Application Function requirement.`));
|
|
31
|
+
}
|
|
32
|
+
return results;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
function observeInvocations(project) {
|
|
37
|
+
const dependencies = declaredDomainDependencies(project);
|
|
38
|
+
const targets = [];
|
|
39
|
+
const evidence = [];
|
|
40
|
+
for (const file of production(project, 'functions')) {
|
|
41
|
+
for (const definition of [...calls(file, 'defineAction'), ...calls(file, 'defineWorkflow')]) {
|
|
42
|
+
if (definition.origin === 'ambiguous') {
|
|
43
|
+
evidence.push(ambiguity(file, definition.call, 'Handler definition resolves through a local facade whose ultimate public constructor origin is unknown.'));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const call = ts.isCallExpression(definition.call.parent) &&
|
|
47
|
+
definition.call.parent.expression === definition.call
|
|
48
|
+
? definition.call.parent
|
|
49
|
+
: definition.call;
|
|
50
|
+
const candidate = call.arguments.length === 2
|
|
51
|
+
? call.arguments[1]
|
|
52
|
+
: call.arguments.length === 3
|
|
53
|
+
? call.arguments[2]
|
|
54
|
+
: undefined;
|
|
55
|
+
const run = candidate && unwrap(candidate);
|
|
56
|
+
if (!run || (!ts.isArrowFunction(run) && !ts.isFunctionExpression(run))) {
|
|
57
|
+
evidence.push(ambiguity(file, call, 'Handler run is not a static function.'));
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
visit(run.body, (node) => {
|
|
61
|
+
if (!ts.isCallExpression(node))
|
|
62
|
+
return;
|
|
63
|
+
const path = contextPath(node.expression, run);
|
|
64
|
+
if (!path || path.at(-1) !== 'invoke')
|
|
65
|
+
return;
|
|
66
|
+
if (path.includes('[computed]')) {
|
|
67
|
+
evidence.push(ambiguity(file, node, 'Computed dependency invocation cannot be proven statically.'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let alias;
|
|
71
|
+
let selector;
|
|
72
|
+
if (path[0] === 'dependencies') {
|
|
73
|
+
if (path.length !== 4 || !['caller', 'self', 'union'].includes(path[2])) {
|
|
74
|
+
evidence.push(violation(file, node, 'Dependency invocation requires one direct alias and one explicit caller, self, or union authority.'));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
alias = path[1];
|
|
78
|
+
selector = selectedCallable(node.arguments[0]);
|
|
79
|
+
}
|
|
80
|
+
else if (path[0] === 'kernel' &&
|
|
81
|
+
(path.length === 2 ||
|
|
82
|
+
(path.length === 3 && ['caller', 'self', 'union'].includes(path[1])))) {
|
|
83
|
+
const argument = node.arguments[0];
|
|
84
|
+
if (!argument) {
|
|
85
|
+
evidence.push(violation(file, node, 'Kernel invocation requires one canonical typed reference.'));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const admitted = callableReference(unwrap(argument));
|
|
89
|
+
let reference = admitted.expression;
|
|
90
|
+
if (ts.isCallExpression(reference) && ts.isCallExpression(reference.expression))
|
|
91
|
+
reference = reference.expression;
|
|
92
|
+
if (!admitted.resolved) {
|
|
93
|
+
evidence.push(ambiguity(file, node, 'Kernel invocation reference is opaque.'));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const symbol = ts.isCallExpression(reference)
|
|
97
|
+
? resolveImportedSymbol(file, reference.expression)
|
|
98
|
+
: undefined;
|
|
99
|
+
if (symbol?.kind !== 'resolved' ||
|
|
100
|
+
symbol.module !== '@astrale-os/sdk/client/session' ||
|
|
101
|
+
symbol.name !== 'reference' ||
|
|
102
|
+
!ts.isCallExpression(reference)) {
|
|
103
|
+
evidence.push(violation(file, node, 'Kernel invocation requires one canonical typed reference.'));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const domain = reference.arguments[0] && contextPath(reference.arguments[0], run);
|
|
107
|
+
const callable = reference.arguments[1] && contextPath(reference.arguments[1], run);
|
|
108
|
+
// Local typed Kernel invocations are outside cross-Domain requirement policy.
|
|
109
|
+
if (domain?.length === 1 && domain[0] === 'domain')
|
|
110
|
+
return;
|
|
111
|
+
if (domain?.length === 3 &&
|
|
112
|
+
domain[0] === 'domain' &&
|
|
113
|
+
domain[1] === 'dependencies' &&
|
|
114
|
+
callable &&
|
|
115
|
+
domain.every((part, index) => part === callable[index])) {
|
|
116
|
+
alias = domain[2];
|
|
117
|
+
selector = callable.slice(3);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
return;
|
|
122
|
+
if (!alias || !selector || !callableSelector(selector)) {
|
|
123
|
+
evidence.push(ambiguity(file, node, 'Remote callable selector cannot be proven from one static selector or typed reference.'));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const module = dependencies.aliases.get(alias);
|
|
127
|
+
if (!module) {
|
|
128
|
+
evidence.push((dependencies.indeterminate ? ambiguity : violation)(file, node, `Dependency alias ${alias} is not one declared public Domain dependency.`));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
targets.push({ file, node, module, selector });
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { targets, evidence };
|
|
136
|
+
}
|
|
137
|
+
function selectedCallable(input) {
|
|
138
|
+
if (!input)
|
|
139
|
+
return undefined;
|
|
140
|
+
const admitted = callableReference(unwrap(input));
|
|
141
|
+
const selector = admitted.expression;
|
|
142
|
+
if (!admitted.resolved ||
|
|
143
|
+
(!ts.isArrowFunction(selector) && !ts.isFunctionExpression(selector)) ||
|
|
144
|
+
selector.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword))
|
|
145
|
+
return undefined;
|
|
146
|
+
const parameter = selector.parameters[0]?.name;
|
|
147
|
+
if (!parameter || !ts.isIdentifier(parameter))
|
|
148
|
+
return undefined;
|
|
149
|
+
let expression;
|
|
150
|
+
if (ts.isBlock(selector.body)) {
|
|
151
|
+
if (selector.body.statements.length === 1 && ts.isReturnStatement(selector.body.statements[0]))
|
|
152
|
+
expression = selector.body.statements[0].expression;
|
|
153
|
+
}
|
|
154
|
+
else
|
|
155
|
+
expression = selector.body;
|
|
156
|
+
const chain = expression && propertyChain(expression);
|
|
157
|
+
return chain && chain[0] === parameter.text ? chain.slice(1) : undefined;
|
|
158
|
+
}
|
|
159
|
+
/** Resolve handler context bindings and one immutable local alias without following arbitrary helpers. */
|
|
160
|
+
function contextPath(input, run, aliases = 1) {
|
|
161
|
+
const expression = unwrap(input);
|
|
162
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
163
|
+
const base = contextPath(expression.expression, run, aliases);
|
|
164
|
+
return base && [...base, expression.name.text];
|
|
165
|
+
}
|
|
166
|
+
if (ts.isElementAccessExpression(expression)) {
|
|
167
|
+
const base = contextPath(expression.expression, run, aliases);
|
|
168
|
+
return base && [...base, '[computed]'];
|
|
169
|
+
}
|
|
170
|
+
if (!ts.isIdentifier(expression))
|
|
171
|
+
return undefined;
|
|
172
|
+
let current = expression.parent;
|
|
173
|
+
while (current) {
|
|
174
|
+
if (ts.isFunctionLike(current)) {
|
|
175
|
+
for (const parameter of current.parameters) {
|
|
176
|
+
const path = bindingPath(parameter.name, expression.text);
|
|
177
|
+
if (path)
|
|
178
|
+
return current === run && parameter === run.parameters[0] ? path : undefined;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (ts.isBlock(current) || ts.isSourceFile(current)) {
|
|
182
|
+
for (const statement of current.statements) {
|
|
183
|
+
if (ts.isFunctionDeclaration(statement) && statement.name?.text === expression.text)
|
|
184
|
+
return undefined;
|
|
185
|
+
if (!ts.isVariableStatement(statement))
|
|
186
|
+
continue;
|
|
187
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
188
|
+
const path = bindingPath(declaration.name, expression.text);
|
|
189
|
+
if (!path)
|
|
190
|
+
continue;
|
|
191
|
+
if (aliases === 0 ||
|
|
192
|
+
!declaration.initializer ||
|
|
193
|
+
declaration.end > expression.pos ||
|
|
194
|
+
!(statement.declarationList.flags & ts.NodeFlags.Const))
|
|
195
|
+
return undefined;
|
|
196
|
+
const base = contextPath(declaration.initializer, run, aliases - 1);
|
|
197
|
+
return base && [...base, ...path];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
current = current.parent;
|
|
202
|
+
}
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
function bindingPath(name, identifier) {
|
|
206
|
+
if (ts.isIdentifier(name))
|
|
207
|
+
return name.text === identifier ? [] : undefined;
|
|
208
|
+
if (!ts.isObjectBindingPattern(name))
|
|
209
|
+
return undefined;
|
|
210
|
+
for (const element of name.elements) {
|
|
211
|
+
if (element.dotDotDotToken)
|
|
212
|
+
continue;
|
|
213
|
+
const nested = bindingPath(element.name, identifier);
|
|
214
|
+
const property = element.propertyName ?? (ts.isIdentifier(element.name) ? element.name : undefined);
|
|
215
|
+
if (nested && property && (ts.isIdentifier(property) || ts.isStringLiteral(property)))
|
|
216
|
+
return [property.text, ...nested];
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
@@ -321,7 +321,7 @@ export const globalRules = [
|
|
|
321
321
|
(edge.kind === kind ||
|
|
322
322
|
(kind === 'type-only' &&
|
|
323
323
|
(edge.kind === 'runtime' || edge.kind === 'composition'))))) {
|
|
324
|
-
evidence.push(violation(file, sourceImport.node, `Import ${sourceImport.specifier} creates absent ${file.layer} -> ${target.layer} (${kind}) edge
|
|
324
|
+
evidence.push(violation(file, sourceImport.node, `Import ${sourceImport.specifier} creates absent ${file.layer} -> ${target.layer} (${kind}) edge. ${admittedDependencies(project, file.layer, target.layer)}`));
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -626,7 +626,7 @@ export const globalRules = [
|
|
|
626
626
|
evidence.push(ambiguity(file, property, 'Schema dependency is not one statically aliased Domain facade.'));
|
|
627
627
|
continue;
|
|
628
628
|
}
|
|
629
|
-
const symbol =
|
|
629
|
+
const symbol = dependencySchemaSymbol(file, element);
|
|
630
630
|
if (symbol?.module === '@astrale-os/sdk/schema' && symbol.name === 'KernelSchema') {
|
|
631
631
|
continue;
|
|
632
632
|
}
|
|
@@ -678,6 +678,23 @@ export const globalRules = [
|
|
|
678
678
|
},
|
|
679
679
|
];
|
|
680
680
|
const STABLE_DEFINITION_ID = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
|
|
681
|
+
/**
|
|
682
|
+
* Name the admitted neighborhood of a rejected dependency edge. Rejection alone
|
|
683
|
+
* states that the import is wrong; the allowlist states which decomposition is
|
|
684
|
+
* expected, and the authored condition states why.
|
|
685
|
+
*/
|
|
686
|
+
function admittedDependencies(project, source, target) {
|
|
687
|
+
const admitted = project.policy.dependencies.filter((edge) => edge.source === source);
|
|
688
|
+
const admittedTarget = admitted.filter((edge) => edge.target === target);
|
|
689
|
+
if (admittedTarget.length > 0) {
|
|
690
|
+
const kinds = admittedTarget.map((edge) => `${edge.kind} (${edge.condition})`).join(', ');
|
|
691
|
+
return `Admitted ${source} -> ${target} kinds: ${kinds}.`;
|
|
692
|
+
}
|
|
693
|
+
if (admitted.length === 0)
|
|
694
|
+
return `No ${source} dependency is admitted.`;
|
|
695
|
+
const targets = admitted.map((edge) => `${edge.target} (${edge.kind})`).join(', ');
|
|
696
|
+
return `Admitted ${source} targets: ${targets}.`;
|
|
697
|
+
}
|
|
681
698
|
function rootEvidence(file, evidence) {
|
|
682
699
|
return file ? violation(file, file.source, evidence) : { kind: 'violation', evidence };
|
|
683
700
|
}
|
|
@@ -710,6 +727,39 @@ function isExternalPackage(specifier) {
|
|
|
710
727
|
!specifier.startsWith('@astrale-os/kernel-core') &&
|
|
711
728
|
!specifier.startsWith('@astrale-os/kernel-dsl'));
|
|
712
729
|
}
|
|
730
|
+
function dependencySchemaSymbol(file, expression) {
|
|
731
|
+
const target = unwrap(expression);
|
|
732
|
+
const direct = importedSymbol(file, target);
|
|
733
|
+
if (direct || !ts.isIdentifier(target))
|
|
734
|
+
return direct;
|
|
735
|
+
const declarations = file.source.statements.flatMap((statement) => {
|
|
736
|
+
if (!ts.isVariableStatement(statement) ||
|
|
737
|
+
!(statement.declarationList.flags & ts.NodeFlags.Const)) {
|
|
738
|
+
return [];
|
|
739
|
+
}
|
|
740
|
+
return statement.declarationList.declarations.filter((declaration) => ts.isIdentifier(declaration.name) && declaration.name.text === target.text);
|
|
741
|
+
});
|
|
742
|
+
if (declarations.length !== 1)
|
|
743
|
+
return undefined;
|
|
744
|
+
const initializer = declarations[0].initializer;
|
|
745
|
+
const accepted = initializer && unwrap(initializer);
|
|
746
|
+
if (!accepted ||
|
|
747
|
+
!ts.isCallExpression(accepted) ||
|
|
748
|
+
!ts.isPropertyAccessExpression(unwrap(accepted.expression))) {
|
|
749
|
+
return undefined;
|
|
750
|
+
}
|
|
751
|
+
const callee = unwrap(accepted.expression);
|
|
752
|
+
if (callee.name.text !== 'accept')
|
|
753
|
+
return undefined;
|
|
754
|
+
const owner = resolveImportedSymbol(file, callee.expression);
|
|
755
|
+
if (owner.kind !== 'resolved' ||
|
|
756
|
+
owner.name !== 'schema' ||
|
|
757
|
+
!schemaAuthoringModule(owner.module)) {
|
|
758
|
+
return undefined;
|
|
759
|
+
}
|
|
760
|
+
const admitted = accepted.arguments[0];
|
|
761
|
+
return admitted ? importedSymbol(file, unwrap(admitted)) : undefined;
|
|
762
|
+
}
|
|
713
763
|
function directKernelAuthoringImport(specifier) {
|
|
714
764
|
return (specifier === '@astrale-os/kernel-core' ||
|
|
715
765
|
specifier.startsWith('@astrale-os/kernel-core/') ||
|