@runeditrun/rer 0.2.93 → 0.2.94
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/agent-door.mjs +20 -10
- package/cli/agent-history-database.mjs +82 -0
- package/cli/agent-history-isolation.mjs +68 -0
- package/cli/agent-history.mjs +58 -0
- package/cli/agent-journey-fixtures.mjs +3 -3
- package/cli/agent-network.mjs +12 -6
- package/cli/business/choices.mjs +3 -3
- package/cli/business/command.mjs +19 -0
- package/cli/business/setup-command.mjs +14 -1
- package/cli/export.mjs +1 -1
- package/cli/hosted-hosts.mjs +21 -0
- package/cli/hosted-output.mjs +91 -8
- package/cli/lifecycle.mjs +5 -0
- package/cli/local.mjs +1 -1
- package/cli/port.mjs +1 -2
- package/cli/portability-evidence.d.mts +5 -0
- package/cli/portability-evidence.mjs +85 -0
- package/cli/portability-migrations.mjs +12 -4
- package/edition-authoring/module-edges.mjs +14 -1
- package/foundation/runtime/contract-anchor.mjs +87 -0
- package/foundation/runtime/contract-docs.mjs +20 -4
- package/global/CHANGELOG.md +36 -0
- package/install.sh +4 -1
- package/modules/agent-door/conformance/injection.mjs +5 -3
- package/modules/agent-door/conformance/journey.mjs +1 -1
- package/modules/deploy-kit/README.md +1 -1
- package/modules/deploy-kit/prepare.mjs +5 -2
- package/modules/portability/README.md +42 -10
- package/modules/portability/catalogue.mjs +11 -1
- package/modules/portability/checkout-history.mjs +14 -0
- package/modules/portability/index.d.mts +1 -1
- package/modules/portability/library-history.mjs +2 -7
- package/modules/portability/restore-safety.mjs +6 -3
- package/modules/portability/worker-history.d.mts +9 -0
- package/modules/portability/worker-history.mjs +29 -0
- package/onboarding/adapter.mjs +25 -13
- package/package.json +9 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArchivePolicy, MigrationReplay } from './index.mjs';
|
|
2
|
+
export interface MigrationEvidence {
|
|
3
|
+
version:1;
|
|
4
|
+
files:{name:string;sha256:string;statements:string[]}[];
|
|
5
|
+
objects:{name:string;sql:string;type:string;tbl_name:string}[];
|
|
6
|
+
prefixes:{objects:number[];shadows:string[];seeds:{name:string;columns:string[];hashes:string[]}[]}[];
|
|
7
|
+
}
|
|
8
|
+
/** Return a replay bound to the destination's hashed ledger and complete schema. */
|
|
9
|
+
export function workerMigrations(db:D1Database,policy:ArchivePolicy,evidence:MigrationEvidence):Promise<MigrationReplay>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { policy, inventorySchemaIdentity } from './catalogue.mjs';
|
|
2
|
+
import { canonicalJson } from './hash.mjs';
|
|
3
|
+
import { checkoutHistory } from './checkout-history.mjs';
|
|
4
|
+
import { insist, PortabilityError } from './storage.mjs';
|
|
5
|
+
|
|
6
|
+
// This adapter supplies replay evidence, never archive validation. The same
|
|
7
|
+
// collector, ledger matching, schema bridge and restore guards serve both doors.
|
|
8
|
+
export async function workerMigrations(db,input,evidence) {
|
|
9
|
+
try {
|
|
10
|
+
insist(evidence?.version===1 && evidence.prefixes.length===evidence.files.length+1,'schema_mismatch:legacy_evidence',409);
|
|
11
|
+
const config=policy(input),files=evidence.files;
|
|
12
|
+
return await checkoutHistory(db,input,files,names=>{
|
|
13
|
+
const prefix=selected=>{
|
|
14
|
+
insist(selected.length<=names.length && canonicalJson(selected)===canonicalJson(files.slice(0,selected.length).map(f=>f.name)),'schema_mismatch:legacy_evidence',409);
|
|
15
|
+
const found=evidence.prefixes[selected.length];
|
|
16
|
+
insist(found,'schema_mismatch:legacy_evidence',409);return found;
|
|
17
|
+
};
|
|
18
|
+
const final=prefix(names);
|
|
19
|
+
return {names,statements:name=>files.find(f=>f.name===name)?.statements,sha256:name=>files.find(f=>f.name===name)?.sha256,
|
|
20
|
+
schemaAfter(selected,options){
|
|
21
|
+
const snapshot=prefix(selected);
|
|
22
|
+
return inventorySchemaIdentity({objects:snapshot.objects.map(i=>evidence.objects[i]),kinds:snapshot.shadows.map(name=>({name,type:'shadow'}))},config,options);
|
|
23
|
+
},
|
|
24
|
+
async rowImages(requests){return new Map(requests.filter(r=>final.seeds.some(s=>s.name===r.name && !s.hashes.length)).map(r=>[r.name,[]]));},
|
|
25
|
+
async rowHashes(requests,limit){return new Map(requests.flatMap(r=>{const found=final.seeds.find(s=>s.name===r.name && s.hashes.length<=limit && canonicalJson(s.columns)===canonicalJson(r.columns));return found?[[r.name,found.hashes]]:[];}));},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}catch(error){if(error instanceof PortabilityError)throw error;throw new PortabilityError('schema_mismatch:legacy_evidence',409);}
|
|
29
|
+
}
|
package/onboarding/adapter.mjs
CHANGED
|
@@ -10,8 +10,8 @@ import { credentialValues } from './redaction.mjs';
|
|
|
10
10
|
import { dependencyEnvironment } from './dependency-environment.mjs';
|
|
11
11
|
import { labels } from './adapter-labels.mjs';
|
|
12
12
|
import { chooseOrigin, prepareSettings, readSettings } from './adapter-settings.mjs';
|
|
13
|
-
import {listenerPorts,listenerOwnership,inspectionContext} from './process-diagnostics.mjs';
|
|
14
|
-
import { appFetch
|
|
13
|
+
import {listenerPorts,listenerOwnership,processName,inspectionContext} from './process-diagnostics.mjs';
|
|
14
|
+
import { appFetch } from './app-fetch.mjs';
|
|
15
15
|
import { owner, signIn } from './adapter-auth.mjs';
|
|
16
16
|
import { installerDevKey } from './dev-identity.mjs';
|
|
17
17
|
import { assertArchiveFree } from './archive-output.mjs';
|
|
@@ -220,7 +220,10 @@ async function start(context, hooks) {
|
|
|
220
220
|
// credential prefix as private even when it happens to be an ordinary port.
|
|
221
221
|
const mismatch=port=>({fatal:detectedMismatch=`the application listened on port ${port} but the CLI expected ${expectedPort} for the runtime listener`});
|
|
222
222
|
const announced=message=>{if(message?.type==='rer-listening')announcement=message;};
|
|
223
|
-
|
|
223
|
+
child.on('message',announced);
|
|
224
|
+
// Only explicit application bindings are candidates for a port mismatch. A
|
|
225
|
+
// descendant's open socket alone says nothing about its protocol or purpose.
|
|
226
|
+
const declaredPorts=new Set([spawnOptions.env?.RER_RUNTIME_PORT,...args.flatMap((arg,index)=>arg==='--port'?[args[index+1]]:arg.startsWith('--port=')?[arg.slice(7)]:[])].filter(value=>/^\d+$/.test(String(value))).map(Number).filter(port=>port>0&&port<=65535));
|
|
224
227
|
context.app = child;
|
|
225
228
|
await onApp(child);
|
|
226
229
|
const url = new URL(health, context.origin).href;
|
|
@@ -243,16 +246,25 @@ async function start(context, hooks) {
|
|
|
243
246
|
context.setRuntimePort(port);context.runtimePort=port;expectedPort=port;
|
|
244
247
|
}
|
|
245
248
|
}
|
|
246
|
-
|
|
249
|
+
let result;
|
|
250
|
+
try { result=await (ready??hooks.health??defaultHealth)(url,probeSignal,context); }
|
|
251
|
+
catch(error){if(probeSignal.aborted)throw error;result={ready:false,message:'Health probe failed'};}
|
|
247
252
|
if(result===true||result?.ready===true)return result;
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
// Diagnose an explicit misbinding through socket custody, never HTTP. In
|
|
254
|
+
// particular, workerd's auxiliary RPC sockets must not receive /health while
|
|
255
|
+
// Vite is still starting. A runtime announcement can identify its application
|
|
256
|
+
// socket even when workerd itself serves it (the production target).
|
|
257
|
+
const candidates=[...declaredPorts].filter(port=>port!==expectedPort);
|
|
258
|
+
if(candidates.length){
|
|
259
|
+
const inspection=inspectionContext({signal:probeSignal,budgetMs:3000});
|
|
260
|
+
const ports=await listenerPorts(child.pid,inspection);
|
|
261
|
+
if(!ports.includes(expectedPort))for(const port of candidates.filter(port=>ports.includes(port))){
|
|
262
|
+
const ownership=await listenerOwnership(child.pid,port,'127.0.0.1',inspection);
|
|
263
|
+
if(ownership.status!=='owned')continue;
|
|
264
|
+
const name=await processName(ownership.pid,inspection);
|
|
265
|
+
if(/^workerd(?:[.-]|$)/i.test(name)&&!(announcement?.port===port&&announcement.requestedPort===port))continue;
|
|
266
|
+
return mismatch(port);
|
|
267
|
+
}
|
|
256
268
|
}
|
|
257
269
|
return result;
|
|
258
270
|
}, { signal, timeoutMs: Math.min(timeoutMs??60000,60000), ...(softAfterMs ? { softAfterMs } : {}), ...(intervalMs ? { intervalMs } : {}) });
|
|
@@ -268,7 +280,7 @@ async function start(context, hooks) {
|
|
|
268
280
|
store.report(message);const prior=approvedFailure(error);error=commandFailure(`${prior?.message??readinessLabel}\n${message}`,prior??{});
|
|
269
281
|
}
|
|
270
282
|
throw installationFailure('command_failed', { step: 'start', diagnostic: error });
|
|
271
|
-
} finally {
|
|
283
|
+
} finally { child.removeListener('message',announced); }
|
|
272
284
|
// Another app can take the loopback port between the port check and the bind;
|
|
273
285
|
// its /health would pass. Claim and sign in only against the process this
|
|
274
286
|
// setup started.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runeditrun/rer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.94",
|
|
4
4
|
"description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"./deploy": "./cli/deploy.mjs",
|
|
13
13
|
"./portability": "./cli/portability.mjs",
|
|
14
14
|
"./portability-migrations": "./cli/portability-migrations.mjs",
|
|
15
|
+
"./portability-evidence": {
|
|
16
|
+
"types": "./cli/portability-evidence.d.mts",
|
|
17
|
+
"default": "./cli/portability-evidence.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./modules/portability/worker-history": {
|
|
20
|
+
"types": "./modules/portability/worker-history.d.mts",
|
|
21
|
+
"default": "./modules/portability/worker-history.mjs"
|
|
22
|
+
},
|
|
15
23
|
"./errors": "./cli/errors.mjs",
|
|
16
24
|
"./jsonc": "./cli/jsonc.mjs",
|
|
17
25
|
"./parse": "./cli/parse.mjs",
|