@astrale-os/kernel-dsl 1.0.0-beta.33 → 1.0.0-beta.34
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/dist/v1/addressing/class-key.js +16 -4
- package/dist/v1/addressing/key.d.ts +2 -0
- package/dist/v1/addressing/key.js +2 -0
- package/dist/v1/addressing/property-key.js +14 -2
- package/dist/v1/language/policy/normalization/normalize.js +1 -1
- package/dist/v1/schema/enforcement/install.d.ts +2 -2
- package/dist/v1/schema/enforcement/install.js +8 -2
- package/package.json +1 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { acceptDefinitionRef } from './definition-ref.js';
|
|
2
|
-
import { Key } from './key.js';
|
|
2
|
+
import { Key, KNOWN_KEYS } from './key.js';
|
|
3
|
+
/**
|
|
4
|
+
* Texts `ClassKey.is` found canonical, at most `KNOWN_KEYS` of them: the test depends on the text
|
|
5
|
+
* alone, and stored rows name the same Classes again and again.
|
|
6
|
+
*/
|
|
7
|
+
const knownClassKeys = new Set();
|
|
3
8
|
/** Admit exact canonical Class-key text. */
|
|
4
9
|
export function ClassKey(input) {
|
|
5
10
|
if (!ClassKey.is(input)) {
|
|
@@ -18,13 +23,20 @@ export function ClassKey(input) {
|
|
|
18
23
|
}
|
|
19
24
|
ClassKey.of = of;
|
|
20
25
|
function is(input) {
|
|
21
|
-
if (typeof input !== 'string'
|
|
26
|
+
if (typeof input !== 'string')
|
|
27
|
+
return false;
|
|
28
|
+
if (knownClassKeys.has(input))
|
|
29
|
+
return true;
|
|
30
|
+
if (!Key.is(input))
|
|
22
31
|
return false;
|
|
23
32
|
// Only the coordinate is tested: an origin label may itself be `property` or `method`.
|
|
24
33
|
const coordinate = input.slice(input.indexOf(':') + 1);
|
|
25
|
-
|
|
34
|
+
const canonical = coordinate.startsWith('class.') &&
|
|
26
35
|
!coordinate.includes('.property.') &&
|
|
27
|
-
!coordinate.includes('.method.')
|
|
36
|
+
!coordinate.includes('.method.');
|
|
37
|
+
if (canonical && knownClassKeys.size < KNOWN_KEYS)
|
|
38
|
+
knownClassKeys.add(input);
|
|
39
|
+
return canonical;
|
|
28
40
|
}
|
|
29
41
|
ClassKey.is = is;
|
|
30
42
|
function ref(input) {
|
|
@@ -5,6 +5,8 @@ export type DefinitionKey<Origin extends Key.Origin = Key.Origin, Kind extends D
|
|
|
5
5
|
export type CoreKey<Origin extends Key.Origin = Key.Origin, Name extends string = string> = DefinitionKey<Origin, 'core', Name>;
|
|
6
6
|
export type PropertyKey<Origin extends Key.Origin = Key.Origin, Owner extends string = string, Name extends string = string> = `${Origin}:class.${Owner}.property.${Name}`;
|
|
7
7
|
export type Key = DefinitionKey | PropertyKey | MethodKey;
|
|
8
|
+
/** How many canonical key texts a key family's `is` keeps, so that a test of one is read back. */
|
|
9
|
+
export declare const KNOWN_KEYS = 16384;
|
|
8
10
|
export declare function Key(input: string): Key;
|
|
9
11
|
/** Canonical origin-qualified address operations. */
|
|
10
12
|
export declare namespace Key {
|
|
@@ -4,6 +4,8 @@ const DEFINITION_KEY = /^(?:class|function|policy|view)\.([A-Za-z][A-Za-z0-9_]*)
|
|
|
4
4
|
// The slug is the whole rest of the coordinate, its own `.` included: no member follows a Core key.
|
|
5
5
|
const CORE_KEY = /^core\.((?=.{1,100}$)[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*)$/u;
|
|
6
6
|
const MEMBER_KEY = /^class\.([A-Za-z][A-Za-z0-9_]*)\.(property|method)\.([A-Za-z][A-Za-z0-9_]*)$/u;
|
|
7
|
+
/** How many canonical key texts a key family's `is` keeps, so that a test of one is read back. */
|
|
8
|
+
export const KNOWN_KEYS = 16_384;
|
|
7
9
|
/** The keys of frozen Definition coordinates, derived once each. */
|
|
8
10
|
const derived = new WeakMap();
|
|
9
11
|
export function Key(input) {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { acceptDefinitionRef } from './definition-ref.js';
|
|
2
|
-
import { Key } from './key.js';
|
|
2
|
+
import { Key, KNOWN_KEYS } from './key.js';
|
|
3
3
|
import { MEMBER_NAME_PATTERN, PROPERTY_KEY_PATTERN } from './patterns.js';
|
|
4
|
+
/**
|
|
5
|
+
* Texts `PropertyKey.is` found canonical, at most `KNOWN_KEYS` of them: the test depends on the
|
|
6
|
+
* text alone, and stored rows name the same keys again and again.
|
|
7
|
+
*/
|
|
8
|
+
const knownPropertyKeys = new Set();
|
|
4
9
|
export function PropertyKey(input) {
|
|
5
10
|
if (!PropertyKey.is(input)) {
|
|
6
11
|
throw new TypeError(`Invalid canonical PropertyKey: ${JSON.stringify(input)}.`);
|
|
@@ -18,7 +23,14 @@ export function PropertyKey(input) {
|
|
|
18
23
|
}
|
|
19
24
|
PropertyKey.of = of;
|
|
20
25
|
function is(input) {
|
|
21
|
-
|
|
26
|
+
if (typeof input !== 'string')
|
|
27
|
+
return false;
|
|
28
|
+
if (knownPropertyKeys.has(input))
|
|
29
|
+
return true;
|
|
30
|
+
const canonical = Key.is(input) && PROPERTY_KEY_PATTERN.test(input);
|
|
31
|
+
if (canonical && knownPropertyKeys.size < KNOWN_KEYS)
|
|
32
|
+
knownPropertyKeys.add(input);
|
|
33
|
+
return canonical;
|
|
22
34
|
}
|
|
23
35
|
PropertyKey.is = is;
|
|
24
36
|
function address(input) {
|
|
@@ -154,7 +154,7 @@ function canonicalVariableIds(value) {
|
|
|
154
154
|
if (byDepth !== 0)
|
|
155
155
|
return byDepth;
|
|
156
156
|
// A remaining tie keeps the authored order of the ids: such variables were interchangeable in
|
|
157
|
-
// every admissible Pattern checked (`__tests__/canonical
|
|
157
|
+
// every admissible Pattern checked (`__tests__/canonical-orders-*.test.ts`).
|
|
158
158
|
return left - right;
|
|
159
159
|
});
|
|
160
160
|
return new Map(ordered.map((id, index) => [id, index]));
|
|
@@ -188,8 +188,8 @@ export declare const INSTALL: Readonly<{
|
|
|
188
188
|
readonly refusal: {
|
|
189
189
|
readonly code: 'SCHEMA_ARTIFACT_INVALID';
|
|
190
190
|
};
|
|
191
|
-
readonly statement: 'What a source answers stays within the limits of the protocol.';
|
|
192
|
-
readonly laws: readonly ["SB-LIMITS", "SB-RELEASE-FIRST", "SB-PUBLICATION-VERSION"];
|
|
191
|
+
readonly statement: 'What a source answers stays within the limits of the protocol: an answer over its bound, or a Bundle declared over it, is refused at once, and retrying it does not help.';
|
|
192
|
+
readonly laws: readonly ["SB-LIMITS", "SB-OVER-BOUND-REFUSED", "SB-RELEASE-FIRST", "SB-PUBLICATION-VERSION", "INSTALLATION-OVER-BOUND-SOURCE"];
|
|
193
193
|
};
|
|
194
194
|
readonly SOURCE_RELEASE_DRIFT: {
|
|
195
195
|
readonly phase: 'install';
|
|
@@ -154,8 +154,14 @@ export const INSTALL = deepFreeze({
|
|
|
154
154
|
subjects: ['install.source'],
|
|
155
155
|
does: 'refuse',
|
|
156
156
|
refusal: ARTIFACT,
|
|
157
|
-
statement: 'What a source answers stays within the limits of the protocol.',
|
|
158
|
-
laws: [
|
|
157
|
+
statement: 'What a source answers stays within the limits of the protocol: an answer over its bound, or a Bundle declared over it, is refused at once, and retrying it does not help.',
|
|
158
|
+
laws: [
|
|
159
|
+
'SB-LIMITS',
|
|
160
|
+
'SB-OVER-BOUND-REFUSED',
|
|
161
|
+
'SB-RELEASE-FIRST',
|
|
162
|
+
'SB-PUBLICATION-VERSION',
|
|
163
|
+
'INSTALLATION-OVER-BOUND-SOURCE',
|
|
164
|
+
],
|
|
159
165
|
},
|
|
160
166
|
SOURCE_RELEASE_DRIFT: {
|
|
161
167
|
phase: 'install',
|