@cotal-ai/core 0.11.6 → 0.13.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/dist/acls.d.ts +31 -7
- package/dist/acls.d.ts.map +1 -1
- package/dist/acls.js +105 -17
- package/dist/acls.js.map +1 -1
- package/dist/agent-file.js +1 -1
- package/dist/agent-file.js.map +1 -1
- package/dist/auth-provider.d.ts +90 -10
- package/dist/auth-provider.d.ts.map +1 -1
- package/dist/auth-provider.js.map +1 -1
- package/dist/backup-config.d.ts +55 -0
- package/dist/backup-config.d.ts.map +1 -0
- package/dist/backup-config.js +243 -0
- package/dist/backup-config.js.map +1 -0
- package/dist/backup.d.ts +86 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +497 -0
- package/dist/backup.js.map +1 -0
- package/dist/broker-floor.d.ts +34 -0
- package/dist/broker-floor.d.ts.map +1 -0
- package/dist/broker-floor.js +39 -0
- package/dist/broker-floor.js.map +1 -0
- package/dist/canonical.d.ts +24 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +159 -0
- package/dist/canonical.js.map +1 -0
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +8 -1
- package/dist/channels.js.map +1 -1
- package/dist/connector.d.ts +4 -0
- package/dist/connector.d.ts.map +1 -1
- package/dist/endpoint-action.d.ts +424 -0
- package/dist/endpoint-action.d.ts.map +1 -0
- package/dist/endpoint-action.js +910 -0
- package/dist/endpoint-action.js.map +1 -0
- package/dist/endpoint-binding.d.ts +344 -0
- package/dist/endpoint-binding.d.ts.map +1 -0
- package/dist/endpoint-binding.js +753 -0
- package/dist/endpoint-binding.js.map +1 -0
- package/dist/endpoint-checkpoint.d.ts +292 -0
- package/dist/endpoint-checkpoint.d.ts.map +1 -0
- package/dist/endpoint-checkpoint.js +818 -0
- package/dist/endpoint-checkpoint.js.map +1 -0
- package/dist/endpoint-cluster.d.ts +95 -0
- package/dist/endpoint-cluster.d.ts.map +1 -0
- package/dist/endpoint-cluster.js +194 -0
- package/dist/endpoint-cluster.js.map +1 -0
- package/dist/endpoint-contract-store.d.ts +90 -0
- package/dist/endpoint-contract-store.d.ts.map +1 -0
- package/dist/endpoint-contract-store.js +348 -0
- package/dist/endpoint-contract-store.js.map +1 -0
- package/dist/endpoint-envelope.d.ts +165 -0
- package/dist/endpoint-envelope.d.ts.map +1 -0
- package/dist/endpoint-envelope.js +346 -0
- package/dist/endpoint-envelope.js.map +1 -0
- package/dist/endpoint-grants.d.ts +123 -0
- package/dist/endpoint-grants.d.ts.map +1 -0
- package/dist/endpoint-grants.js +215 -0
- package/dist/endpoint-grants.js.map +1 -0
- package/dist/endpoint-guard.d.ts +222 -0
- package/dist/endpoint-guard.d.ts.map +1 -0
- package/dist/endpoint-guard.js +468 -0
- package/dist/endpoint-guard.js.map +1 -0
- package/dist/endpoint-handle.d.ts +176 -0
- package/dist/endpoint-handle.d.ts.map +1 -0
- package/dist/endpoint-handle.js +608 -0
- package/dist/endpoint-handle.js.map +1 -0
- package/dist/endpoint-journal.d.ts +225 -0
- package/dist/endpoint-journal.d.ts.map +1 -0
- package/dist/endpoint-journal.js +431 -0
- package/dist/endpoint-journal.js.map +1 -0
- package/dist/endpoint-receipt.d.ts +225 -0
- package/dist/endpoint-receipt.d.ts.map +1 -0
- package/dist/endpoint-receipt.js +417 -0
- package/dist/endpoint-receipt.js.map +1 -0
- package/dist/endpoint-records.d.ts +243 -0
- package/dist/endpoint-records.d.ts.map +1 -0
- package/dist/endpoint-records.js +591 -0
- package/dist/endpoint-records.js.map +1 -0
- package/dist/endpoint-serve.d.ts +176 -0
- package/dist/endpoint-serve.d.ts.map +1 -0
- package/dist/endpoint-serve.js +446 -0
- package/dist/endpoint-serve.js.map +1 -0
- package/dist/endpoint-service.d.ts +518 -0
- package/dist/endpoint-service.d.ts.map +1 -0
- package/dist/endpoint-service.js +973 -0
- package/dist/endpoint-service.js.map +1 -0
- package/dist/endpoint-session.d.ts +398 -0
- package/dist/endpoint-session.d.ts.map +1 -0
- package/dist/endpoint-session.js +834 -0
- package/dist/endpoint-session.js.map +1 -0
- package/dist/endpoint-signing.d.ts +105 -0
- package/dist/endpoint-signing.d.ts.map +1 -0
- package/dist/endpoint-signing.js +190 -0
- package/dist/endpoint-signing.js.map +1 -0
- package/dist/endpoint-subjects.d.ts +222 -0
- package/dist/endpoint-subjects.d.ts.map +1 -0
- package/dist/endpoint-subjects.js +381 -0
- package/dist/endpoint-subjects.js.map +1 -0
- package/dist/endpoint-supervisor.d.ts +19 -0
- package/dist/endpoint-supervisor.d.ts.map +1 -0
- package/dist/endpoint-supervisor.js +12 -0
- package/dist/endpoint-supervisor.js.map +1 -0
- package/dist/endpoint-traits.d.ts +225 -0
- package/dist/endpoint-traits.d.ts.map +1 -0
- package/dist/endpoint-traits.js +469 -0
- package/dist/endpoint-traits.js.map +1 -0
- package/dist/endpoint-verbs.d.ts +277 -0
- package/dist/endpoint-verbs.d.ts.map +1 -0
- package/dist/endpoint-verbs.js +576 -0
- package/dist/endpoint-verbs.js.map +1 -0
- package/dist/endpoint-virtual.d.ts +308 -0
- package/dist/endpoint-virtual.d.ts.map +1 -0
- package/dist/endpoint-virtual.js +440 -0
- package/dist/endpoint-virtual.js.map +1 -0
- package/dist/endpoint-work.d.ts +304 -0
- package/dist/endpoint-work.d.ts.map +1 -0
- package/dist/endpoint-work.js +728 -0
- package/dist/endpoint-work.js.map +1 -0
- package/dist/endpoint.d.ts +66 -22
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +289 -89
- package/dist/endpoint.js.map +1 -1
- package/dist/evict.d.ts +95 -32
- package/dist/evict.d.ts.map +1 -1
- package/dist/evict.js +193 -3
- package/dist/evict.js.map +1 -1
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/lease.d.ts +4 -0
- package/dist/lease.d.ts.map +1 -1
- package/dist/lease.js.map +1 -1
- package/dist/members.d.ts +4 -4
- package/dist/members.d.ts.map +1 -1
- package/dist/members.js +12 -12
- package/dist/members.js.map +1 -1
- package/dist/provision.d.ts +78 -20
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +214 -37
- package/dist/provision.js.map +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/safe-pattern.d.ts +33 -0
- package/dist/safe-pattern.d.ts.map +1 -0
- package/dist/safe-pattern.js +486 -0
- package/dist/safe-pattern.js.map +1 -0
- package/dist/schema-profile.d.ts +93 -0
- package/dist/schema-profile.d.ts.map +1 -0
- package/dist/schema-profile.js +284 -0
- package/dist/schema-profile.js.map +1 -0
- package/dist/secret-store.d.ts +46 -0
- package/dist/secret-store.d.ts.map +1 -0
- package/dist/secret-store.js +2 -0
- package/dist/secret-store.js.map +1 -0
- package/dist/space-auth.d.ts +9 -0
- package/dist/space-auth.d.ts.map +1 -0
- package/dist/space-auth.js +126 -0
- package/dist/space-auth.js.map +1 -0
- package/dist/streams.d.ts +14 -10
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +47 -76
- package/dist/streams.js.map +1 -1
- package/dist/subjects.d.ts +100 -40
- package/dist/subjects.d.ts.map +1 -1
- package/dist/subjects.js +136 -60
- package/dist/subjects.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -2
package/dist/runtime.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ export interface AgentHandle {
|
|
|
37
37
|
stop(opts?: {
|
|
38
38
|
graceful?: boolean;
|
|
39
39
|
}): void;
|
|
40
|
+
/** Resolve only after the runtime has authoritatively proved the process/window/workspace is gone.
|
|
41
|
+
* Optional during the preservation rollout; a manager maintenance cut must fail closed when absent. */
|
|
42
|
+
waitForExit?(): Promise<void>;
|
|
40
43
|
interrupt(): void;
|
|
41
44
|
/** Open a live attach. Throws on backends that can't stream (e.g. tmux/cmux, which
|
|
42
45
|
* you attach to nat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*
|
|
4
|
+
* A length cap is not a complexity bound (`^(a+)+$` is 8 characters and exponential), and a
|
|
5
|
+
* denylist of known-bad shapes is not one either (`^(a|aa)+$` has no nested quantifier and is
|
|
6
|
+
* exponential all the same). This module instead ADMITS a demonstrably-safe subset and refuses
|
|
7
|
+
* everything it cannot prove, at registration time (`contract-invalid` at the caller):
|
|
8
|
+
*
|
|
9
|
+
* - parse refusals: backreferences, lookarounds, and anything outside the subset grammar;
|
|
10
|
+
* - a variable repetition (`*`, `+`, `{m,}`, `{m,n}` with n>m>0, `{m}` with m>1 over variable
|
|
11
|
+
* content) REFUSES a body that is itself variable (nested repetition, `(a+)+`), nullable
|
|
12
|
+
* (`(a?)*`), or ambiguous (an alternation anywhere inside with overlapping or multiply
|
|
13
|
+
* nullable branches, `(a|aa)+`) — the three per-input-character ambiguity sources;
|
|
14
|
+
* - in a sequence, two variable repetitions with intersecting character sets refuse unless a
|
|
15
|
+
* HARD separator (non-nullable AND disjoint from the run) fences them (`a*a*`, `a*b?a*`,
|
|
16
|
+
* `\d*0{3}0*` — the polynomial overlap class); edge repeat-sets propagate through grouping
|
|
17
|
+
* AND through mandatory items the run can absorb (`a*(aa*)` refuses — grouping never
|
|
18
|
+
* changes the proof);
|
|
19
|
+
* - the AGGREGATE ambiguity across the whole pattern is budgeted: fixed ambiguous choices
|
|
20
|
+
* multiply through a sequence (`(a|aa)(a|aa)…` is 2^k paths with no quantifier), so a
|
|
21
|
+
* pattern whose path bound exceeds the budget refuses;
|
|
22
|
+
* - `?` (0-or-1) is repetition-exempt where it cannot multiply per input character: `(…)?`
|
|
23
|
+
* over quantified content stays admitted (one alternative in total).
|
|
24
|
+
*
|
|
25
|
+
* Character sets are computed conservatively (unknown escapes like `\p{…}` widen to ALL, so
|
|
26
|
+
* uncertainty always refuses more, never less). Every admitted pattern backtracks at most a
|
|
27
|
+
* constant number of alternatives per input position; every refused pattern names its reason.
|
|
28
|
+
*/
|
|
29
|
+
/** Assert `pattern` is inside the profile's safe subset. Throws a plain `Error` naming the
|
|
30
|
+
* refusal reason (callers wrap it in their boundary's error type). `maxChars` is the §13.7
|
|
31
|
+
* length bound, checked first. */
|
|
32
|
+
export declare function assertSafePattern(pattern: string, maxChars: number): void;
|
|
33
|
+
//# sourceMappingURL=safe-pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-pattern.d.ts","sourceRoot":"","sources":["../src/safe-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAyZH;;mCAEmC;AACnC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAazE"}
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The safe regex subset behind SPEC §13.7/§13.8 "bounded pattern complexity" / "bounded regex".
|
|
3
|
+
*
|
|
4
|
+
* A length cap is not a complexity bound (`^(a+)+$` is 8 characters and exponential), and a
|
|
5
|
+
* denylist of known-bad shapes is not one either (`^(a|aa)+$` has no nested quantifier and is
|
|
6
|
+
* exponential all the same). This module instead ADMITS a demonstrably-safe subset and refuses
|
|
7
|
+
* everything it cannot prove, at registration time (`contract-invalid` at the caller):
|
|
8
|
+
*
|
|
9
|
+
* - parse refusals: backreferences, lookarounds, and anything outside the subset grammar;
|
|
10
|
+
* - a variable repetition (`*`, `+`, `{m,}`, `{m,n}` with n>m>0, `{m}` with m>1 over variable
|
|
11
|
+
* content) REFUSES a body that is itself variable (nested repetition, `(a+)+`), nullable
|
|
12
|
+
* (`(a?)*`), or ambiguous (an alternation anywhere inside with overlapping or multiply
|
|
13
|
+
* nullable branches, `(a|aa)+`) — the three per-input-character ambiguity sources;
|
|
14
|
+
* - in a sequence, two variable repetitions with intersecting character sets refuse unless a
|
|
15
|
+
* HARD separator (non-nullable AND disjoint from the run) fences them (`a*a*`, `a*b?a*`,
|
|
16
|
+
* `\d*0{3}0*` — the polynomial overlap class); edge repeat-sets propagate through grouping
|
|
17
|
+
* AND through mandatory items the run can absorb (`a*(aa*)` refuses — grouping never
|
|
18
|
+
* changes the proof);
|
|
19
|
+
* - the AGGREGATE ambiguity across the whole pattern is budgeted: fixed ambiguous choices
|
|
20
|
+
* multiply through a sequence (`(a|aa)(a|aa)…` is 2^k paths with no quantifier), so a
|
|
21
|
+
* pattern whose path bound exceeds the budget refuses;
|
|
22
|
+
* - `?` (0-or-1) is repetition-exempt where it cannot multiply per input character: `(…)?`
|
|
23
|
+
* over quantified content stays admitted (one alternative in total).
|
|
24
|
+
*
|
|
25
|
+
* Character sets are computed conservatively (unknown escapes like `\p{…}` widen to ALL, so
|
|
26
|
+
* uncertainty always refuses more, never less). Every admitted pattern backtracks at most a
|
|
27
|
+
* constant number of alternatives per input position; every refused pattern names its reason.
|
|
28
|
+
*/
|
|
29
|
+
const FULL = { neg: true, ranges: [] };
|
|
30
|
+
const EMPTY = { neg: false, ranges: [] };
|
|
31
|
+
const set = (...ranges) => ({ neg: false, ranges });
|
|
32
|
+
const single = (c) => set([c, c]);
|
|
33
|
+
function rangesOverlap(a, b) {
|
|
34
|
+
for (const [al, ah] of a)
|
|
35
|
+
for (const [bl, bh] of b)
|
|
36
|
+
if (al <= bh && bl <= ah)
|
|
37
|
+
return true;
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function rangesCover(outer, [lo, hi]) {
|
|
41
|
+
// Conservative single-range cover test (enough for the complement cases below).
|
|
42
|
+
return outer.some(([ol, oh]) => ol <= lo && hi <= oh);
|
|
43
|
+
}
|
|
44
|
+
/** Conservative non-empty-intersection test: uncertainty answers `true` (refuse-more). */
|
|
45
|
+
function intersects(a, b) {
|
|
46
|
+
if (!a.neg && !b.neg)
|
|
47
|
+
return rangesOverlap(a.ranges, b.ranges);
|
|
48
|
+
if (a.neg && b.neg)
|
|
49
|
+
return true; // two complements always share almost everything
|
|
50
|
+
const pos = a.neg ? b : a;
|
|
51
|
+
const neg = a.neg ? a : b;
|
|
52
|
+
// pos ∩ complement(neg.ranges) is empty only if neg's ranges cover every pos range.
|
|
53
|
+
return !pos.ranges.every((r) => rangesCover(neg.ranges, r));
|
|
54
|
+
}
|
|
55
|
+
function union(a, b) {
|
|
56
|
+
if (!a.neg && a.ranges.length === 0)
|
|
57
|
+
return b; // EMPTY is the identity — never widen past it
|
|
58
|
+
if (!b.neg && b.ranges.length === 0)
|
|
59
|
+
return a;
|
|
60
|
+
if (a.neg || b.neg)
|
|
61
|
+
return FULL; // two non-trivial sets, one a complement: widen to ALL (sound)
|
|
62
|
+
return { neg: false, ranges: [...a.ranges, ...b.ranges] };
|
|
63
|
+
}
|
|
64
|
+
class PatternRefused extends Error {
|
|
65
|
+
}
|
|
66
|
+
const refuse = (reason) => { throw new PatternRefused(reason); };
|
|
67
|
+
class Parser {
|
|
68
|
+
src;
|
|
69
|
+
i = 0;
|
|
70
|
+
constructor(src) {
|
|
71
|
+
this.src = src;
|
|
72
|
+
}
|
|
73
|
+
peek() { return this.src[this.i]; }
|
|
74
|
+
next() { return this.src[this.i++]; }
|
|
75
|
+
eof() { return this.i >= this.src.length; }
|
|
76
|
+
parse() {
|
|
77
|
+
const node = this.alternation();
|
|
78
|
+
if (!this.eof())
|
|
79
|
+
refuse(`unexpected "${this.peek()}" at ${this.i}`);
|
|
80
|
+
return node;
|
|
81
|
+
}
|
|
82
|
+
alternation() {
|
|
83
|
+
const branches = [this.sequence()];
|
|
84
|
+
while (this.peek() === "|") {
|
|
85
|
+
this.next();
|
|
86
|
+
branches.push(this.sequence());
|
|
87
|
+
}
|
|
88
|
+
return branches.length === 1 ? branches[0] : { kind: "alt", branches };
|
|
89
|
+
}
|
|
90
|
+
sequence() {
|
|
91
|
+
const items = [];
|
|
92
|
+
while (!this.eof() && this.peek() !== "|" && this.peek() !== ")")
|
|
93
|
+
items.push(this.quantified());
|
|
94
|
+
return { kind: "seq", items };
|
|
95
|
+
}
|
|
96
|
+
quantified() {
|
|
97
|
+
let node = this.atom();
|
|
98
|
+
for (;;) {
|
|
99
|
+
const c = this.peek();
|
|
100
|
+
let min, max;
|
|
101
|
+
if (c === "*") {
|
|
102
|
+
min = 0;
|
|
103
|
+
max = Infinity;
|
|
104
|
+
}
|
|
105
|
+
else if (c === "+") {
|
|
106
|
+
min = 1;
|
|
107
|
+
max = Infinity;
|
|
108
|
+
}
|
|
109
|
+
else if (c === "?") {
|
|
110
|
+
min = 0;
|
|
111
|
+
max = 1;
|
|
112
|
+
}
|
|
113
|
+
else if (c === "{") {
|
|
114
|
+
const m = /^\{(\d+)(?:,(\d*))?\}/.exec(this.src.slice(this.i));
|
|
115
|
+
if (!m)
|
|
116
|
+
break; // a literal '{'
|
|
117
|
+
min = parseInt(m[1], 10);
|
|
118
|
+
max = m[2] === undefined ? min : m[2] === "" ? Infinity : parseInt(m[2], 10);
|
|
119
|
+
if (max < min)
|
|
120
|
+
refuse(`quantifier {${min},${max}} is inverted`);
|
|
121
|
+
this.i += m[0].length - 1; // -1: the shared next() below consumes one char
|
|
122
|
+
}
|
|
123
|
+
else
|
|
124
|
+
break;
|
|
125
|
+
this.next();
|
|
126
|
+
if (this.peek() === "?")
|
|
127
|
+
this.next(); // lazy marker — same admitted language
|
|
128
|
+
node = { kind: "quant", body: node, min, max };
|
|
129
|
+
}
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
atom() {
|
|
133
|
+
const c = this.next();
|
|
134
|
+
if (c === "(") {
|
|
135
|
+
if (this.peek() === "?") {
|
|
136
|
+
const ahead = this.src.slice(this.i, this.i + 3);
|
|
137
|
+
if (/^\?(:|<[a-zA-Z_])/.test(ahead)) {
|
|
138
|
+
// non-capturing or named group: plain grouping
|
|
139
|
+
this.next(); // '?'
|
|
140
|
+
if (this.peek() === "<") {
|
|
141
|
+
while (this.next() !== ">") {
|
|
142
|
+
if (this.eof())
|
|
143
|
+
refuse("unterminated group name");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else
|
|
147
|
+
this.next(); // ':'
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
refuse("lookarounds and special groups are outside the profile's safe subset");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const body = this.alternation();
|
|
154
|
+
if (this.next() !== ")")
|
|
155
|
+
refuse("unterminated group");
|
|
156
|
+
return body;
|
|
157
|
+
}
|
|
158
|
+
if (c === "[")
|
|
159
|
+
return { kind: "atom", set: this.charClass() };
|
|
160
|
+
if (c === ".")
|
|
161
|
+
return { kind: "atom", set: FULL };
|
|
162
|
+
if (c === "^")
|
|
163
|
+
return { kind: "anchor", at: "start" };
|
|
164
|
+
if (c === "$")
|
|
165
|
+
return { kind: "anchor", at: "end" };
|
|
166
|
+
if (c === "\\")
|
|
167
|
+
return { kind: "atom", set: this.escape(false) };
|
|
168
|
+
if (c === ")" || c === undefined)
|
|
169
|
+
refuse("unbalanced group");
|
|
170
|
+
return { kind: "atom", set: single(this.codePoint()) };
|
|
171
|
+
}
|
|
172
|
+
/** One literal code POINT (never a lone code unit): `/u` semantics treat an astral pair as
|
|
173
|
+
* one atom, so the analyzer must too, or `😀*` models as high-surrogate + repeated
|
|
174
|
+
* low-surrogate and adjacency/overlap analysis silently under-approximates. */
|
|
175
|
+
codePoint() {
|
|
176
|
+
const cp = this.src.codePointAt(this.i - 1);
|
|
177
|
+
if (cp > 0xffff)
|
|
178
|
+
this.i++; // consumed the low half too
|
|
179
|
+
return cp;
|
|
180
|
+
}
|
|
181
|
+
charClass() {
|
|
182
|
+
let neg = false;
|
|
183
|
+
if (this.peek() === "^") {
|
|
184
|
+
this.next();
|
|
185
|
+
neg = true;
|
|
186
|
+
}
|
|
187
|
+
const ranges = [];
|
|
188
|
+
let approx = false; // any widened member: the set is an over-approximation
|
|
189
|
+
while (this.peek() !== "]") {
|
|
190
|
+
if (this.eof())
|
|
191
|
+
refuse("unterminated character class");
|
|
192
|
+
let lo;
|
|
193
|
+
const c = this.next();
|
|
194
|
+
if (c === "\\") {
|
|
195
|
+
if (this.peek() === "b") {
|
|
196
|
+
this.next();
|
|
197
|
+
lo = 0x08;
|
|
198
|
+
} // in a class, \b is backspace
|
|
199
|
+
else {
|
|
200
|
+
const s = this.escape(true);
|
|
201
|
+
if (s.neg || s.ranges.length !== 1 || s.ranges[0][0] !== s.ranges[0][1]) {
|
|
202
|
+
approx = true; // \d, \D, \p{…} inside a class: fold in conservatively
|
|
203
|
+
for (const r of s.neg ? [[0, 0x10ffff]] : s.ranges)
|
|
204
|
+
ranges.push(r);
|
|
205
|
+
}
|
|
206
|
+
else
|
|
207
|
+
lo = s.ranges[0][0];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else
|
|
211
|
+
lo = this.codePoint();
|
|
212
|
+
if (lo !== undefined) {
|
|
213
|
+
if (this.peek() === "-" && this.src[this.i + 1] !== "]" && this.src[this.i + 1] !== undefined) {
|
|
214
|
+
this.next();
|
|
215
|
+
const hiC = this.next();
|
|
216
|
+
const hi = hiC === "\\" ? (() => { const s = this.escape(true); if (s.neg || s.ranges.length !== 1) {
|
|
217
|
+
approx = true;
|
|
218
|
+
return 0x10ffff;
|
|
219
|
+
} return s.ranges[0][0]; })() : this.codePoint();
|
|
220
|
+
ranges.push([lo, hi]);
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
ranges.push([lo, lo]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
this.next(); // ']'
|
|
227
|
+
// An over-approximated set NEGATED becomes an UNDER-approximation ([^\D] would model as
|
|
228
|
+
// complement(ALL) = EMPTY while the engine sees \d) — widening must survive negation, so
|
|
229
|
+
// an approximate negated class is FULL, never its complement.
|
|
230
|
+
if (neg && approx)
|
|
231
|
+
return FULL;
|
|
232
|
+
return { neg, ranges };
|
|
233
|
+
}
|
|
234
|
+
escape(inClass) {
|
|
235
|
+
const c = this.next();
|
|
236
|
+
if (c === undefined)
|
|
237
|
+
refuse("dangling escape");
|
|
238
|
+
if (!inClass && c >= "1" && c <= "9")
|
|
239
|
+
refuse(`backreference \\${c} is outside the profile's safe subset`);
|
|
240
|
+
if (c === "k")
|
|
241
|
+
refuse("named backreferences are outside the profile's safe subset");
|
|
242
|
+
if (c === "b" || c === "B")
|
|
243
|
+
return EMPTY; // word boundary: zero-width (as an atom: anchor-like)
|
|
244
|
+
switch (c) {
|
|
245
|
+
case "d": return set([0x30, 0x39]);
|
|
246
|
+
case "D": return { neg: true, ranges: [[0x30, 0x39]] };
|
|
247
|
+
case "w": return set([0x30, 0x39], [0x41, 0x5a], [0x5f, 0x5f], [0x61, 0x7a]);
|
|
248
|
+
case "W": return { neg: true, ranges: [[0x30, 0x39], [0x41, 0x5a], [0x5f, 0x5f], [0x61, 0x7a]] };
|
|
249
|
+
case "s": return set([0x09, 0x0d], [0x20, 0x20], [0xa0, 0xa0], [0x2028, 0x2029]);
|
|
250
|
+
case "S": return { neg: true, ranges: [[0x09, 0x0d], [0x20, 0x20], [0xa0, 0xa0], [0x2028, 0x2029]] };
|
|
251
|
+
case "n": return single(0x0a);
|
|
252
|
+
case "r": return single(0x0d);
|
|
253
|
+
case "t": return single(0x09);
|
|
254
|
+
case "f": return single(0x0c);
|
|
255
|
+
case "v": return single(0x0b);
|
|
256
|
+
case "0": return single(0);
|
|
257
|
+
case "x": {
|
|
258
|
+
const m = /^[0-9a-fA-F]{2}/.exec(this.src.slice(this.i));
|
|
259
|
+
if (!m)
|
|
260
|
+
refuse("malformed \\x escape");
|
|
261
|
+
this.i += 2;
|
|
262
|
+
return single(parseInt(m[0], 16));
|
|
263
|
+
}
|
|
264
|
+
case "u": {
|
|
265
|
+
const braced = /^\{([0-9a-fA-F]{1,6})\}/.exec(this.src.slice(this.i));
|
|
266
|
+
if (braced) {
|
|
267
|
+
this.i += braced[0].length;
|
|
268
|
+
const cp = parseInt(braced[1], 16);
|
|
269
|
+
if (cp >= 0xd800 && cp <= 0xdfff)
|
|
270
|
+
refuse("surrogate code point escapes are outside the safe subset");
|
|
271
|
+
return single(cp);
|
|
272
|
+
}
|
|
273
|
+
const m = /^[0-9a-fA-F]{4}/.exec(this.src.slice(this.i));
|
|
274
|
+
if (!m)
|
|
275
|
+
refuse("malformed \\u escape");
|
|
276
|
+
this.i += 4;
|
|
277
|
+
const cp = parseInt(m[0], 16);
|
|
278
|
+
// Under /u a surrogate escape pairs with its sibling into one code point; modeling the
|
|
279
|
+
// halves separately under-approximates repetition — refuse, write the character or \u{…}.
|
|
280
|
+
if (cp >= 0xd800 && cp <= 0xdfff)
|
|
281
|
+
refuse("surrogate escapes are outside the safe subset (write the character or \\u{…})");
|
|
282
|
+
return single(cp);
|
|
283
|
+
}
|
|
284
|
+
case "p":
|
|
285
|
+
case "P": {
|
|
286
|
+
const m = /^\{[^}]*\}/.exec(this.src.slice(this.i));
|
|
287
|
+
if (!m)
|
|
288
|
+
refuse("malformed \\p escape");
|
|
289
|
+
this.i += m[0].length;
|
|
290
|
+
return FULL; // unknown property set: widen — uncertainty refuses more, never less
|
|
291
|
+
}
|
|
292
|
+
default:
|
|
293
|
+
// An escaped ALPHANUMERIC we do not model has (or may gain) engine meaning (\cA is
|
|
294
|
+
// control-A, not literal c+A — modeling it as such under-approximated repetition):
|
|
295
|
+
// refuse instead of fallback-admitting. Escaped punctuation is exactly that literal.
|
|
296
|
+
if (/[A-Za-z0-9]/.test(c))
|
|
297
|
+
refuse(`escape \\${c} is outside the profile's safe subset`);
|
|
298
|
+
return single(c.codePointAt(0));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/** The aggregate-ambiguity ceiling: an admitted pattern explores at most this many alternative
|
|
303
|
+
* paths per match attempt from fixed (unquantified) ambiguous choices — small enough to be
|
|
304
|
+
* noise at the 10 ms validation budget, generous enough for real idioms (a chain of six
|
|
305
|
+
* two-way ambiguous alternations). Beyond it the fixed-alternation class turns exponential in
|
|
306
|
+
* the author's pattern length (`(a|aa)`×25 is 153 chars and 2^25 paths). */
|
|
307
|
+
const CHOICE_BUDGET = 64;
|
|
308
|
+
const CHOICE_SAT = 1 << 20; // saturation ceiling for the bookkeeping, far above the budget
|
|
309
|
+
const mulSat = (a, b) => Math.min(a * b, CHOICE_SAT);
|
|
310
|
+
function powSat(base, exp) {
|
|
311
|
+
let out = 1;
|
|
312
|
+
for (let i = 0; i < exp && out < CHOICE_SAT; i++)
|
|
313
|
+
out = mulSat(out, base);
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
/** Front-to-back accumulation of an edge repeat-set across a sequence. A repetition surfaces at
|
|
317
|
+
* the edge through any NULLABLE prefix — and ALSO through a mandatory item that the repeated
|
|
318
|
+
* run can ABSORB (its set intersects a repetition edge-set deeper in the scan): the mandatory
|
|
319
|
+
* `a` in `(aa*)` does not fence the inner `a*` off from a neighboring `a*`, it is satisfiable
|
|
320
|
+
* anywhere inside the same run (the grouped form of the run-slosh class — grouping must not
|
|
321
|
+
* change the proof). Only a mandatory item DISJOINT from everything deeper stops the scan.
|
|
322
|
+
* `pick` selects the edge. */
|
|
323
|
+
function edgeRepeat(facts, pick) {
|
|
324
|
+
// Suffix unions of the picked edge sets: what a mandatory item at position i would need to
|
|
325
|
+
// be absorbable by (any repetition surfacing deeper in scan order).
|
|
326
|
+
const deeper = new Array(facts.length + 1);
|
|
327
|
+
deeper[facts.length] = EMPTY;
|
|
328
|
+
for (let i = facts.length - 1; i >= 0; i--)
|
|
329
|
+
deeper[i] = union(pick(facts[i]), deeper[i + 1]);
|
|
330
|
+
let acc = EMPTY;
|
|
331
|
+
for (let i = 0; i < facts.length; i++) {
|
|
332
|
+
acc = union(acc, pick(facts[i]));
|
|
333
|
+
if (!facts[i].nullable && !intersects(facts[i].set, deeper[i + 1]))
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
return acc;
|
|
337
|
+
}
|
|
338
|
+
/** Every alternation branch reachable at the top level MUST begin with a `^` start anchor.
|
|
339
|
+
* Ajv matches `pattern` with unanchored `RegExp.test()`, which retries at EVERY input position;
|
|
340
|
+
* a branch not pinned to the start therefore turns even a single repetition-plus-obligation
|
|
341
|
+
* (`[0b]*$`, `[a-z]+@`) into an O(n²) scan across n start positions. A `^` collapses the search
|
|
342
|
+
* to one position, under which the overlap analysis below is sound. (End-anchoring is not
|
|
343
|
+
* required: a trailing repetition with no obligation after it is linear.) */
|
|
344
|
+
function assertStartAnchored(node) {
|
|
345
|
+
switch (node.kind) {
|
|
346
|
+
case "anchor":
|
|
347
|
+
if (node.at !== "start")
|
|
348
|
+
refuse("a top-level branch must begin with a '^' start anchor (Ajv tests patterns unanchored)");
|
|
349
|
+
return;
|
|
350
|
+
case "seq":
|
|
351
|
+
if (node.items.length === 0)
|
|
352
|
+
refuse("an empty top-level branch is not start-anchored");
|
|
353
|
+
assertStartAnchored(node.items[0]);
|
|
354
|
+
return;
|
|
355
|
+
case "alt":
|
|
356
|
+
for (const b of node.branches)
|
|
357
|
+
assertStartAnchored(b);
|
|
358
|
+
return;
|
|
359
|
+
default:
|
|
360
|
+
refuse("a top-level branch must begin with a '^' start anchor (Ajv tests patterns unanchored)");
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function analyze(node) {
|
|
364
|
+
switch (node.kind) {
|
|
365
|
+
case "anchor":
|
|
366
|
+
return { set: EMPTY, nullable: true, variable: false, ambiguousAlt: false, choices: 1, leadRep: EMPTY, trailRep: EMPTY };
|
|
367
|
+
case "atom":
|
|
368
|
+
return { set: node.set, nullable: node.set.ranges.length === 0 && !node.set.neg, variable: false, ambiguousAlt: false, choices: 1, leadRep: EMPTY, trailRep: EMPTY };
|
|
369
|
+
case "seq": {
|
|
370
|
+
const facts = node.items.map(analyze);
|
|
371
|
+
// The polynomial overlap class (`a*a*`, `a*b?a*`, `(a*|b)a*`, `\d*0000 0*`): a node whose
|
|
372
|
+
// TRAILING repeat-set `T` intersects a later node's LEADING repeat-set is refused. The
|
|
373
|
+
// window is only closed by a HARD SEPARATOR — a non-nullable item whose set is DISJOINT
|
|
374
|
+
// from `T`. A non-nullable item whose set INTERSECTS `T` does NOT separate: the run of
|
|
375
|
+
// `T`-characters sloshes through it (the fixed `0000` between `\d*` and `0*` is satisfiable
|
|
376
|
+
// anywhere in a zero-run, so the two still split the run ambiguously).
|
|
377
|
+
for (let i = 0; i < facts.length; i++) {
|
|
378
|
+
const T = facts[i].trailRep;
|
|
379
|
+
if (T.ranges.length === 0 && !T.neg)
|
|
380
|
+
continue;
|
|
381
|
+
for (let j = i + 1; j < facts.length; j++) {
|
|
382
|
+
if (intersects(T, facts[j].leadRep))
|
|
383
|
+
refuse("two overlapping variable repetitions in sequence (polynomial backtracking class)");
|
|
384
|
+
if (!facts[j].nullable && !intersects(facts[j].set, T))
|
|
385
|
+
break; // a disjoint obligation separates the run
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
set: facts.reduce((s, f) => union(s, f.set), EMPTY),
|
|
390
|
+
nullable: facts.every((f) => f.nullable),
|
|
391
|
+
variable: facts.some((f) => f.variable),
|
|
392
|
+
ambiguousAlt: facts.some((f) => f.ambiguousAlt),
|
|
393
|
+
// A sequence MULTIPLIES its items' path counts — the fixed-alternation class
|
|
394
|
+
// (`(a|aa)(a|aa)…`) turns exponential exactly here, with no quantifier anywhere.
|
|
395
|
+
choices: facts.reduce((n, f) => mulSat(n, f.choices), 1),
|
|
396
|
+
leadRep: edgeRepeat(facts, (f) => f.leadRep),
|
|
397
|
+
trailRep: edgeRepeat([...facts].reverse(), (f) => f.trailRep),
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
case "alt": {
|
|
401
|
+
const facts = node.branches.map(analyze);
|
|
402
|
+
let ambiguous = facts.some((f) => f.ambiguousAlt);
|
|
403
|
+
if (facts.filter((f) => f.nullable).length > 1)
|
|
404
|
+
ambiguous = true; // two empty-matching branches
|
|
405
|
+
for (let i = 0; i < facts.length && !ambiguous; i++) {
|
|
406
|
+
for (let j = i + 1; j < facts.length; j++) {
|
|
407
|
+
if (intersects(facts[i].set, facts[j].set)) {
|
|
408
|
+
ambiguous = true;
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// ANY branch may be the matched one, so its edge repeat-sets are all exposed at this
|
|
414
|
+
// alternation's edges.
|
|
415
|
+
return {
|
|
416
|
+
set: facts.reduce((s, f) => union(s, f.set), EMPTY),
|
|
417
|
+
nullable: facts.some((f) => f.nullable),
|
|
418
|
+
variable: facts.some((f) => f.variable),
|
|
419
|
+
ambiguousAlt: ambiguous,
|
|
420
|
+
// Overlapping branches can EACH match the same span (paths add); disjoint branches are
|
|
421
|
+
// mutually exclusive on any given input (only the surviving branch's paths count).
|
|
422
|
+
choices: ambiguous
|
|
423
|
+
? facts.reduce((n, f) => Math.min(n + f.choices, CHOICE_SAT), 0)
|
|
424
|
+
: facts.reduce((n, f) => Math.max(n, f.choices), 1),
|
|
425
|
+
leadRep: facts.reduce((s, f) => union(s, f.leadRep), EMPTY),
|
|
426
|
+
trailRep: facts.reduce((s, f) => union(s, f.trailRep), EMPTY),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
case "quant": {
|
|
430
|
+
const body = analyze(node.body);
|
|
431
|
+
const repeats = node.max > 1 || node.max === Infinity; // a `?` (0-or-1) cannot multiply per input char
|
|
432
|
+
if (repeats) {
|
|
433
|
+
if (body.variable)
|
|
434
|
+
refuse("repeats a group that itself contains a quantifier (exponential backtracking class)");
|
|
435
|
+
if (body.nullable)
|
|
436
|
+
refuse("repeats a nullable body (unbounded ambiguity on empty matches)");
|
|
437
|
+
if (body.ambiguousAlt)
|
|
438
|
+
refuse("repeats an ambiguous alternation (branches overlap; exponential backtracking class)");
|
|
439
|
+
}
|
|
440
|
+
// Every NONDETERMINISTIC repetition (`max > min`: `*`, `+`, `{n,}`, `?`, and any `{m,n}`
|
|
441
|
+
// with n>m) drives the polynomial overlap, because it can match a VARIABLE number of the
|
|
442
|
+
// same characters, so an adjacent one over an intersecting set is a `C(input,k)` split
|
|
443
|
+
// ambiguity — and an author-chosen finite bound like `{0,100000}` is not a "constant
|
|
444
|
+
// factor" at a 10ms budget. Only a FIXED `{n}` (max===min) is deterministic and exempt.
|
|
445
|
+
// A nondeterministic repetition exposes its BODY's set at both edges (its own repeated
|
|
446
|
+
// content), plus any repeat-set the body already carried.
|
|
447
|
+
const nondet = node.max > node.min;
|
|
448
|
+
return {
|
|
449
|
+
set: body.set,
|
|
450
|
+
nullable: body.nullable || node.min === 0,
|
|
451
|
+
variable: body.variable || nondet || repeats,
|
|
452
|
+
ambiguousAlt: body.ambiguousAlt,
|
|
453
|
+
// Fixed {n}: the body's paths multiply per iteration (a repeat over an ambiguous body
|
|
454
|
+
// is refused above, so this stays 1 there; `?` adds the skip alternative). Variable
|
|
455
|
+
// repetitions contribute their split ambiguity through the edge-set analysis instead.
|
|
456
|
+
choices: node.max === node.min
|
|
457
|
+
? powSat(body.choices, node.min)
|
|
458
|
+
: node.min === 0 && node.max === 1
|
|
459
|
+
? Math.min(body.choices + 1, CHOICE_SAT)
|
|
460
|
+
: body.choices,
|
|
461
|
+
leadRep: nondet ? union(body.set, body.leadRep) : body.leadRep,
|
|
462
|
+
trailRep: nondet ? union(body.set, body.trailRep) : body.trailRep,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/** Assert `pattern` is inside the profile's safe subset. Throws a plain `Error` naming the
|
|
468
|
+
* refusal reason (callers wrap it in their boundary's error type). `maxChars` is the §13.7
|
|
469
|
+
* length bound, checked first. */
|
|
470
|
+
export function assertSafePattern(pattern, maxChars) {
|
|
471
|
+
if (pattern.length > maxChars)
|
|
472
|
+
throw new Error(`pattern of ${pattern.length} characters exceeds the profile complexity bound (${maxChars})`);
|
|
473
|
+
try {
|
|
474
|
+
const ast = new Parser(pattern).parse();
|
|
475
|
+
assertStartAnchored(ast); // sound only under single-start matching (Ajv tests unanchored)
|
|
476
|
+
const facts = analyze(ast);
|
|
477
|
+
if (facts.choices > CHOICE_BUDGET)
|
|
478
|
+
refuse(`aggregate alternation ambiguity of ${facts.choices >= CHOICE_SAT ? "at least " : ""}${facts.choices} paths exceeds the ${CHOICE_BUDGET}-path budget (the fixed-alternation exponential class)`);
|
|
479
|
+
}
|
|
480
|
+
catch (e) {
|
|
481
|
+
if (e instanceof PatternRefused)
|
|
482
|
+
throw new Error(`pattern ${JSON.stringify(pattern)} is outside the profile's safe subset: ${e.message}`);
|
|
483
|
+
throw new Error(`pattern ${JSON.stringify(pattern)} did not parse under the profile's safe subset: ${e.message}`);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
//# sourceMappingURL=safe-pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe-pattern.js","sourceRoot":"","sources":["../src/safe-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAUH,MAAM,IAAI,GAAY,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAChD,MAAM,KAAK,GAAY,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAClD,MAAM,GAAG,GAAG,CAAC,GAAG,MAA+B,EAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACtF,MAAM,MAAM,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEnD,SAAS,aAAa,CAAC,CAA0B,EAAE,CAA0B;IAC3E,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QAAE,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;gBAAE,OAAO,IAAI,CAAC;IAC1F,OAAO,KAAK,CAAC;AACf,CAAC;AA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