@runeditrun/rer 0.2.69 → 0.2.71
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/cli/README.md +2 -0
- package/cli/deploy-claim-session.mjs +25 -0
- package/cli/deploy-command.mjs +8 -3
- package/cli/deploy-observation.mjs +7 -2
- package/cli/deploy-owner.mjs +5 -4
- package/cli/deploy-product.mjs +30 -0
- package/cli/deploy.mjs +3 -1
- package/cli/portability-worker.mjs +7 -4
- package/global/CHANGELOG.md +17 -0
- package/modules/deploy-kit/README.md +2 -0
- package/modules/deploy-kit/owner.mjs +1 -1
- package/modules/operator-auth/README.md +31 -10
- package/modules/operator-auth/SCHEDULED-POLICY.md +137 -0
- package/modules/operator-auth/accounts/admin.mjs +2 -10
- package/modules/operator-auth/accounts/schema/last-signin.sql +11 -0
- package/modules/operator-auth/accounts/schema/operator-auth.sql +25 -1
- package/modules/operator-auth/accounts/schema/scheduled-policy-hardening.sql +8 -0
- package/modules/operator-auth/accounts/schema/scheduled-policy.sql +18 -0
- package/modules/operator-auth/accounts/status.mjs +18 -0
- package/modules/operator-auth/accounts/store.mjs +3 -0
- package/modules/operator-auth/branding.mjs +5 -2
- package/modules/operator-auth/conformance/README.md +7 -3
- package/modules/operator-auth/conformance/index.d.mts +2 -2
- package/modules/operator-auth/conformance/index.mjs +6 -4
- package/modules/operator-auth/conformance/presentation.mjs +8 -3
- package/modules/operator-auth/dev-gate.mjs +5 -3
- package/modules/operator-auth/index.d.mts +6 -2
- package/modules/operator-auth/page.mjs +5 -3
- package/modules/operator-auth/routes.mjs +6 -1
- package/modules/operator-auth/scheduled/definition.mjs +38 -0
- package/modules/operator-auth/scheduled/expiry.mjs +17 -0
- package/modules/operator-auth/scheduled/fence.mjs +28 -0
- package/modules/operator-auth/scheduled/history.mjs +30 -0
- package/modules/operator-auth/scheduled/index.d.mts +21 -0
- package/modules/operator-auth/scheduled/index.mjs +83 -0
- package/modules/operator-auth/scheduled/runner.mjs +68 -0
- package/modules/operator-auth/service.mjs +2 -0
- package/modules/portability/README.md +57 -4
- package/modules/portability/backfills.mjs +94 -0
- package/modules/portability/bridge.mjs +18 -12
- package/modules/portability/export.mjs +5 -1
- package/modules/portability/import.mjs +11 -7
- package/modules/portability/index.d.mts +1 -1
- package/modules/portability/migration-statements.mjs +105 -11
- package/modules/portability/policy-data.mjs +10 -0
- package/modules/portability/sql-text.mjs +95 -0
- package/onboarding/adapter.mjs +5 -2
- package/onboarding/process-diagnostics.mjs +7 -2
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { tokens, identifier, folded } from './generated.mjs';
|
|
2
|
+
|
|
3
|
+
// Migration SQL split where SQLite itself ends statements: sqlite3_complete's
|
|
4
|
+
// state machine (https://github.com/sqlite/sqlite/blob/master/src/complete.c,
|
|
5
|
+
// public domain). A trigger ends only at `; END ;`, so CASE ... END (also
|
|
6
|
+
// `END||x`), quoted or commented semicolons and BEGIN ... END bodies never end
|
|
7
|
+
// one. Runners hand over chunks from their own splitter, which can glue a
|
|
8
|
+
// trigger to the statements after it; each chunk is split again here before
|
|
9
|
+
// it is classified. Statements are returned without their final semicolon. A
|
|
10
|
+
// trailing trigger with no `; END` is returned as it stands: the classifier
|
|
11
|
+
// cannot bound it (migration-statements.mjs) and judges it as unbounded.
|
|
12
|
+
const transitions=[
|
|
13
|
+
[1,0,2,3,4,2,2,2],// 0 invalid
|
|
14
|
+
[1,1,2,3,4,2,2,2],// 1 start
|
|
15
|
+
[1,2,2,2,2,2,2,2],// 2 normal
|
|
16
|
+
[1,3,3,2,4,2,2,2],// 3 explain
|
|
17
|
+
[1,4,2,2,2,4,5,2],// 4 create
|
|
18
|
+
[6,5,5,5,5,5,5,5],// 5 trigger
|
|
19
|
+
[6,6,5,5,5,5,5,7],// 6 semicolon in a trigger
|
|
20
|
+
[1,7,5,5,5,5,5,5],// 7 end in a trigger
|
|
21
|
+
];// columns: semicolon, space, other, EXPLAIN, CREATE, TEMP/TEMPORARY, TRIGGER, END
|
|
22
|
+
const kinds={explain:3,create:4,temp:5,temporary:5,trigger:6,end:7};
|
|
23
|
+
export function splitStatements(sql) {
|
|
24
|
+
const result=[];let state=0,start=0,code=false;
|
|
25
|
+
for(const t of tokens(sql)) {
|
|
26
|
+
const pieces=t.quoted?[{text:t.text,at:t.start}]:[...t.text.matchAll(/[A-Za-z0-9_$\u0080-]+|[^A-Za-z0-9_$\u0080-]/g)].map(m=>({text:m[0],at:t.start+m.index}));
|
|
27
|
+
for(const {text,at} of pieces) {
|
|
28
|
+
const kind=t.quoted?2:text===';'?0:kinds[folded(text)]??2;
|
|
29
|
+
if(kind)code=true;
|
|
30
|
+
state=transitions[state][kind];
|
|
31
|
+
if(state!==1)continue;
|
|
32
|
+
if(code)result.push(sql.slice(start,at).trim());
|
|
33
|
+
start=at+1;code=false;state=0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if(code)result.push(sql.slice(start).trim());
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// SQLite's keywords (sqlite3_keyword_name), with the pseudo-tables a trigger
|
|
41
|
+
// or upsert names (NEW, OLD, excluded) and the boolean literals.
|
|
42
|
+
const keywords=new Set(`abort action add after all alter always analyze and as asc attach autoincrement before begin between by cascade case cast check collate column commit conflict constraint create cross current current_date current_time current_timestamp database default deferrable deferred delete desc detach distinct do drop each else end escape except exclude exclusive exists explain fail filter first following for foreign from full generated glob group groups having if ignore immediate in index indexed initially inner insert instead intersect into is isnull join key last left like limit match materialized natural no not nothing notnull null nulls of offset on or order others outer over partition plan pragma preceding primary query raise range recursive references regexp reindex release rename replace restrict returning right rollback row rows savepoint select set table temp temporary then ties to transaction trigger unbounded union unique update using vacuum values view virtual when where window with without new old excluded true false`.split(' '));
|
|
43
|
+
const pseudo=new Set(['new','old','excluded']);
|
|
44
|
+
// Words that can follow a keyword naming a table without being one: UPDATE OR,
|
|
45
|
+
// AFTER UPDATE ON/OF, DO UPDATE SET, TABLE IF [NOT] EXISTS.
|
|
46
|
+
const grammar=new Set(['or','on','of','set','if']);
|
|
47
|
+
|
|
48
|
+
// Every name in a token list (tokens()) that can be a table: identifiers in
|
|
49
|
+
// table position (after FROM, JOIN, INTO, UPDATE [OR ...], TABLE [IF [NOT]
|
|
50
|
+
// EXISTS], REFERENCES, and the ON of a CREATE INDEX or TRIGGER header), the
|
|
51
|
+
// qualifiers of a qualified name (`t` of t.column), and other bare
|
|
52
|
+
// identifiers. SQL keywords outside table position, function names (a name
|
|
53
|
+
// followed by `(`, also a table-valued one after FROM or JOIN), the column
|
|
54
|
+
// of a qualified reference, string and blob literals, numbers and comments
|
|
55
|
+
// never count. Names are folded.
|
|
56
|
+
export function tableNames(list) {
|
|
57
|
+
const lex=lexemes(list),result=[],header=headerOn(lex);
|
|
58
|
+
for(let i=0;i<lex.length;i++) {
|
|
59
|
+
if(!named(lex[i]))continue;
|
|
60
|
+
let j=i;
|
|
61
|
+
while(lex[j+1]?.text==='.' && named(lex[j+2]))j+=2;
|
|
62
|
+
const parts=lex.slice(i,j+1).filter((_,k)=>k%2===0),call=lex[j+1]?.text==='(',at=position(lex,i,header);
|
|
63
|
+
if(at && !(lex[i].kind==='word' && grammar.has(lex[i].value))){if(at==='target' || !call)result.push(parts.at(-1).value);}
|
|
64
|
+
else if(parts.length>1)result.push(...parts.slice(0,-1).filter(p=>!pseudo.has(p.value)).map(p=>p.value));
|
|
65
|
+
else if(!call && !(lex[i].kind==='word' && keywords.has(lex[i].value)) && !(folded(lex[i].text)==='x' && lex[i+1]?.kind==='string'))result.push(lex[i].value);
|
|
66
|
+
i=j;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
function lexemes(list) {
|
|
71
|
+
return list.flatMap(t=>t.quoted?[{kind:t.text[0]==="'"?'string':'name',text:t.text,value:folded(identifier(t))}]:
|
|
72
|
+
[...t.text.matchAll(/(\d[\w$]*(?:\.\d*)?(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)|([A-Za-z_\u0080-][\w$\u0080-]*)|\S/g)]
|
|
73
|
+
.map(m=>m[1]!==undefined?{kind:'number',text:m[0]}:m[2]!==undefined?{kind:'word',text:m[0],value:folded(m[0])}:{kind:'symbol',text:m[0]}));
|
|
74
|
+
}
|
|
75
|
+
const named=a=>a?.kind==='name' || a?.kind==='word';
|
|
76
|
+
const is=(a,value)=>a?.kind==='word' && a.value===value;
|
|
77
|
+
// Whether the name starting at lex[i] is in table position: 'source' (FROM,
|
|
78
|
+
// JOIN: a name called there is a table-valued function), 'target' otherwise.
|
|
79
|
+
function position(lex,i,header) {
|
|
80
|
+
if(is(lex[i-1],'from') || is(lex[i-1],'join'))return 'source';
|
|
81
|
+
if(['into','references','update'].some(w=>is(lex[i-1],w)) || i-1===header)return 'target';
|
|
82
|
+
if(is(lex[i-2],'or') && ['update','insert'].some(w=>is(lex[i-3],w)))return 'target';
|
|
83
|
+
let k=i-1;
|
|
84
|
+
if(is(lex[k],'exists')){k--;if(is(lex[k],'not'))k--;if(!is(lex[k],'if'))return;k--;}
|
|
85
|
+
if(is(lex[k],'table'))return 'target';
|
|
86
|
+
}
|
|
87
|
+
// The index of the ON naming the table of a CREATE [UNIQUE] INDEX or CREATE
|
|
88
|
+
// [TEMP] TRIGGER statement: its first ON outside parentheses.
|
|
89
|
+
function headerOn(lex) {
|
|
90
|
+
const head=lex.slice(0,4).filter(a=>!['unique','temp','temporary'].some(w=>is(a,w)));
|
|
91
|
+
if(!is(head[0],'create') || !(is(head[1],'index') || is(head[1],'trigger')))return -1;
|
|
92
|
+
let depth=0;
|
|
93
|
+
for(let i=0;i<lex.length;i++){if(lex[i].text==='(')depth++;else if(lex[i].text===')')depth--;else if(!depth && is(lex[i],'on'))return i;else if(!depth && is(lex[i],'begin'))return -1;}
|
|
94
|
+
return -1;
|
|
95
|
+
}
|
package/onboarding/adapter.mjs
CHANGED
|
@@ -238,8 +238,11 @@ async function start(context, hooks) {
|
|
|
238
238
|
// its /health would pass. Claim and sign in only against the process this
|
|
239
239
|
// setup started.
|
|
240
240
|
let ownership;
|
|
241
|
-
try { ownership=await listenerOwnership(child.pid,expectedPort,context.runtimePort?'127.0.0.1':new URL(url).hostname,inspectionContext({port:expectedPort,verb:context.verb??'setup'})); }
|
|
242
|
-
catch(error){
|
|
241
|
+
try { ownership=await listenerOwnership(child.pid,expectedPort,context.runtimePort?'127.0.0.1':new URL(url).hostname,inspectionContext({port:expectedPort,verb:context.verb??'setup',signal})); }
|
|
242
|
+
catch(error){
|
|
243
|
+
if (signal?.aborted) throw error;
|
|
244
|
+
throw installationFailure('command_failed',{step:'start',diagnostic:error});
|
|
245
|
+
}
|
|
243
246
|
if (ownership.status !== 'owned') {
|
|
244
247
|
const message = (store.redact??(value=>value))(ownership.status==='other'
|
|
245
248
|
? `Another process answered on port ${expectedPort}; the application did not bind it. Listener PID ${ownership.pid}. Nothing was sent. Stop that process or choose another port, then run setup again.`
|
|
@@ -25,8 +25,10 @@ const run=async(command,args,context=inspectionContext(),{maxBuffer=1024*1024,no
|
|
|
25
25
|
const remaining=Math.floor(context.deadline-performance.now());
|
|
26
26
|
if(remaining<=0)break;
|
|
27
27
|
const timeout=attempt===0?Math.min(3000,remaining):remaining;
|
|
28
|
-
try{return (await exec(command,args,{timeout,maxBuffer})).stdout;}
|
|
28
|
+
try{return (await exec(command,args,{timeout,maxBuffer,signal:context.signal})).stdout;}
|
|
29
29
|
catch(error){
|
|
30
|
+
// A cancelled caller stops inspecting: the abort is never an ownership verdict.
|
|
31
|
+
if(context.signal?.aborted)throw context.signal.reason;
|
|
30
32
|
// A selected state file positively observed before a timeout still has a
|
|
31
33
|
// holder. Partial output can never establish the absence of a holder.
|
|
32
34
|
if(typeof error.stdout==='string'&&positiveResult?.(error.stdout))return error.stdout;
|
|
@@ -166,6 +168,9 @@ export async function listenerPorts(pid,context=inspectionContext()){
|
|
|
166
168
|
export async function listenerOwnership(pid,port,host,context=inspectionContext()){
|
|
167
169
|
context.port=port;
|
|
168
170
|
do {
|
|
171
|
+
// A cancelled launch has stopped its app, so its listener never appears:
|
|
172
|
+
// end now rather than polling ps and lsof until the inspection budget.
|
|
173
|
+
context.signal?.throwIfAborted();
|
|
169
174
|
const owned=await descendants(pid,context);
|
|
170
175
|
const ownRows=await listeners([...owned],context);
|
|
171
176
|
const own=ownRows.find(row=>owned.has(row.pid)&&row.sockets.some(socket=>serves(socket,port,host)===true));
|
|
@@ -180,7 +185,7 @@ export async function listenerOwnership(pid,port,host,context=inspectionContext(
|
|
|
180
185
|
if(row)return {status:owned.has(row.pid)?'owned':'other',pid:row.pid};
|
|
181
186
|
const remaining=context.deadline-performance.now();
|
|
182
187
|
if(remaining<=0)return {status:'none'};
|
|
183
|
-
await delay(Math.min(100,remaining));
|
|
188
|
+
await delay(Math.min(100,remaining),undefined,{signal:context.signal});
|
|
184
189
|
}while(performance.now()<context.deadline);
|
|
185
190
|
return {status:'none'};
|
|
186
191
|
}
|