@runeditrun/rer 0.2.77 → 0.2.78
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 +32 -0
- package/cli/export.mjs +1 -1
- package/cli/portability-migrations.mjs +35 -14
- package/cli/portability-worker.mjs +2 -2
- package/cli/portability.mjs +2 -2
- package/global/CHANGELOG.md +8 -0
- package/global/README.md +32 -0
- package/modules/deploy-kit/owner-cli.mjs +15 -5
- package/modules/deploy-kit/provider.mjs +9 -4
- package/modules/import-kit/src/d1/README.md +1322 -0
- package/modules/import-kit/src/d1/apply.ts +115 -0
- package/modules/import-kit/src/d1/budget.ts +89 -0
- package/modules/import-kit/src/d1/compressed-plan.ts +63 -0
- package/modules/import-kit/src/d1/creation.ts +95 -0
- package/modules/import-kit/src/d1/custody-fence.ts +27 -0
- package/modules/import-kit/src/d1/custody-state-schema.ts +67 -0
- package/modules/import-kit/src/d1/database.ts +163 -0
- package/modules/import-kit/src/d1/entry-locator.ts +61 -0
- package/modules/import-kit/src/d1/erased-artifacts.ts +38 -0
- package/modules/import-kit/src/d1/erased-custody.ts +36 -0
- package/modules/import-kit/src/d1/erased-plan.ts +47 -0
- package/modules/import-kit/src/d1/erased-reversal.ts +19 -0
- package/modules/import-kit/src/d1/erasure-bounded.ts +22 -0
- package/modules/import-kit/src/d1/erasure-claims.ts +27 -0
- package/modules/import-kit/src/d1/erasure-compiler.ts +67 -0
- package/modules/import-kit/src/d1/erasure-disposition.ts +16 -0
- package/modules/import-kit/src/d1/erasure-fragments.ts +86 -0
- package/modules/import-kit/src/d1/erasure-index.ts +53 -0
- package/modules/import-kit/src/d1/erasure-pages.ts +62 -0
- package/modules/import-kit/src/d1/erasure-progress-schema.ts +8 -0
- package/modules/import-kit/src/d1/erasure-progress.ts +61 -0
- package/modules/import-kit/src/d1/erasure-related.ts +124 -0
- package/modules/import-kit/src/d1/erasure-report.ts +31 -0
- package/modules/import-kit/src/d1/erasure-schema.ts +24 -0
- package/modules/import-kit/src/d1/erasure-selection.ts +77 -0
- package/modules/import-kit/src/d1/erasure-snapshot.ts +15 -0
- package/modules/import-kit/src/d1/erasure-stage.ts +146 -0
- package/modules/import-kit/src/d1/erasure-step.ts +12 -0
- package/modules/import-kit/src/d1/erasure-superseded.ts +98 -0
- package/modules/import-kit/src/d1/erasure-values.ts +83 -0
- package/modules/import-kit/src/d1/erasure-writes.ts +46 -0
- package/modules/import-kit/src/d1/erasure.ts +170 -0
- package/modules/import-kit/src/d1/evolutions/0001-preserved-undo.ts +13 -0
- package/modules/import-kit/src/d1/expected-state.ts +91 -0
- package/modules/import-kit/src/d1/field-redaction.ts +86 -0
- package/modules/import-kit/src/d1/guards.ts +37 -0
- package/modules/import-kit/src/d1/history.ts +71 -0
- package/modules/import-kit/src/d1/index.ts +88 -0
- package/modules/import-kit/src/d1/integrity.ts +127 -0
- package/modules/import-kit/src/d1/inventory-snapshot.ts +84 -0
- package/modules/import-kit/src/d1/jobs.ts +97 -0
- package/modules/import-kit/src/d1/native-set.ts +48 -0
- package/modules/import-kit/src/d1/native-staging-admission.ts +19 -0
- package/modules/import-kit/src/d1/native-staging-context.ts +44 -0
- package/modules/import-kit/src/d1/native-staging-lifecycle.ts +33 -0
- package/modules/import-kit/src/d1/native-staging-offset.ts +74 -0
- package/modules/import-kit/src/d1/native-staging-publication.ts +18 -0
- package/modules/import-kit/src/d1/native-staging-rows.ts +72 -0
- package/modules/import-kit/src/d1/native-staging-schema.ts +28 -0
- package/modules/import-kit/src/d1/native-staging-state.ts +22 -0
- package/modules/import-kit/src/d1/native-staging.ts +64 -0
- package/modules/import-kit/src/d1/original-copies.ts +53 -0
- package/modules/import-kit/src/d1/original-storage.ts +56 -0
- package/modules/import-kit/src/d1/originals.ts +74 -0
- package/modules/import-kit/src/d1/plan-dictionary.ts +80 -0
- package/modules/import-kit/src/d1/plans.ts +121 -0
- package/modules/import-kit/src/d1/preparation-fingerprint.ts +57 -0
- package/modules/import-kit/src/d1/preparation-header.ts +33 -0
- package/modules/import-kit/src/d1/preparation-reader.ts +98 -0
- package/modules/import-kit/src/d1/preparation-schema.ts +16 -0
- package/modules/import-kit/src/d1/preparation-state.ts +56 -0
- package/modules/import-kit/src/d1/preparation-step-combine.ts +80 -0
- package/modules/import-kit/src/d1/preparation-step-control.ts +48 -0
- package/modules/import-kit/src/d1/preparation-step-hash.ts +131 -0
- package/modules/import-kit/src/d1/preparation-step-pages.ts +77 -0
- package/modules/import-kit/src/d1/preparation-steps-schema.ts +11 -0
- package/modules/import-kit/src/d1/preparation-steps.ts +102 -0
- package/modules/import-kit/src/d1/preparations.ts +87 -0
- package/modules/import-kit/src/d1/preserved-preview.ts +89 -0
- package/modules/import-kit/src/d1/preserved-reverse.ts +91 -0
- package/modules/import-kit/src/d1/provenance-set.ts +87 -0
- package/modules/import-kit/src/d1/publication-fence.ts +22 -0
- package/modules/import-kit/src/d1/publication-receipt-schema.ts +15 -0
- package/modules/import-kit/src/d1/published-stream.ts +11 -0
- package/modules/import-kit/src/d1/read-fence.ts +64 -0
- package/modules/import-kit/src/d1/read-results.ts +16 -0
- package/modules/import-kit/src/d1/redacted-custody.ts +76 -0
- package/modules/import-kit/src/d1/redaction-step.ts +125 -0
- package/modules/import-kit/src/d1/referenced-plans.ts +136 -0
- package/modules/import-kit/src/d1/retained-values.ts +35 -0
- package/modules/import-kit/src/d1/retirement-bounded.ts +71 -0
- package/modules/import-kit/src/d1/retirement-door.ts +105 -0
- package/modules/import-kit/src/d1/retirement-schema.ts +39 -0
- package/modules/import-kit/src/d1/retirement-scope.ts +94 -0
- package/modules/import-kit/src/d1/retirement-steps.ts +76 -0
- package/modules/import-kit/src/d1/retirement-tally.ts +74 -0
- package/modules/import-kit/src/d1/retirement.ts +136 -0
- package/modules/import-kit/src/d1/reversal-conversion-record.ts +19 -0
- package/modules/import-kit/src/d1/reversal-conversion-schema.ts +11 -0
- package/modules/import-kit/src/d1/reversal-conversion.ts +40 -0
- package/modules/import-kit/src/d1/reversal-fence-schema.ts +14 -0
- package/modules/import-kit/src/d1/reversal-fence.ts +106 -0
- package/modules/import-kit/src/d1/reversal-journal.ts +24 -0
- package/modules/import-kit/src/d1/reverse.ts +103 -0
- package/modules/import-kit/src/d1/reviewed-source.ts +23 -0
- package/modules/import-kit/src/d1/sets.ts +78 -0
- package/modules/import-kit/src/d1/staged-creation.ts +201 -0
- package/modules/import-kit/src/d1/staging-admission.ts +45 -0
- package/modules/import-kit/src/d1/staging-control.ts +43 -0
- package/modules/import-kit/src/d1/staging-erasure.ts +28 -0
- package/modules/import-kit/src/d1/staging-lifecycle.ts +49 -0
- package/modules/import-kit/src/d1/staging-plan.ts +15 -0
- package/modules/import-kit/src/d1/staging-privacy.ts +22 -0
- package/modules/import-kit/src/d1/staging-publication.ts +79 -0
- package/modules/import-kit/src/d1/staging-schema.ts +37 -0
- package/modules/import-kit/src/d1/staging-statements.ts +8 -0
- package/modules/import-kit/src/d1/staging-transport.ts +70 -0
- package/modules/import-kit/src/d1/stream-boundary.ts +11 -0
- package/modules/import-kit/src/d1/stream-create.ts +55 -0
- package/modules/import-kit/src/d1/stream-identity-admission.ts +37 -0
- package/modules/import-kit/src/d1/stream-input.ts +18 -0
- package/modules/import-kit/src/d1/stream-layout.ts +43 -0
- package/modules/import-kit/src/d1/stream-origin.ts +44 -0
- package/modules/import-kit/src/d1/stream-page-integrity.ts +18 -0
- package/modules/import-kit/src/d1/stream-partition.ts +50 -0
- package/modules/import-kit/src/d1/stream-plan.ts +133 -0
- package/modules/import-kit/src/d1/stream-receipt.ts +45 -0
- package/modules/import-kit/src/d1/stream-revision-schema.ts +35 -0
- package/modules/import-kit/src/d1/stream-snapshot.ts +26 -0
- package/modules/import-kit/src/d1/stream-stage.ts +79 -0
- package/modules/import-kit/src/d1/stream-state.ts +25 -0
- package/modules/import-kit/src/d1/stream-working-set.ts +30 -0
- package/modules/import-kit/src/d1/streams.ts +39 -0
- package/modules/import-kit/src/d1/target-guards.ts +9 -0
- package/modules/import-kit/src/d1/target-identities.ts +17 -0
- package/modules/import-kit/src/d1/transport.ts +10 -0
- package/modules/import-kit/src/d1/types.ts +162 -0
- package/modules/import-kit/src/d1/undo-observations.ts +39 -0
- package/modules/import-kit/src/d1/undo-report.ts +22 -0
- package/modules/import-kit/src/d1/undo-snapshot.ts +87 -0
- package/modules/import-kit/src/d1/undo-state.ts +84 -0
- package/modules/import-kit/src/d1/undo-types.ts +110 -0
- package/modules/import-kit/src/journal/authority.ts +12 -0
- package/modules/import-kit/src/plan/budget.ts +60 -0
- package/modules/import-kit/src/plan/index.ts +123 -0
- package/modules/import-kit/src/plan/size.ts +122 -0
- package/modules/import-kit/src/provenance/canonical-hash.ts +130 -0
- package/modules/import-kit/src/provenance/canonical-stream.ts +85 -0
- package/modules/import-kit/src/provenance/credential-names.ts +131 -0
- package/modules/import-kit/src/provenance/credentials.ts +317 -0
- package/modules/import-kit/src/provenance/identity.ts +51 -0
- package/modules/import-kit/src/provenance/json-snapshot.ts +21 -0
- package/modules/import-kit/src/provenance/resumable-sha256.ts +75 -0
- package/modules/import-kit/src/provenance/validate-json.ts +19 -0
- package/modules/import-kit/src/storage/originals.ts +87 -0
- package/modules/import-kit/src/storage/provenance.ts +64 -0
- package/modules/import-kit/src/storage/schema.ts +42 -0
- package/modules/import-kit/src/types.ts +47 -0
- package/modules/portability/README.md +98 -2
- package/modules/portability/backfills.mjs +42 -15
- package/modules/portability/ledgers.mjs +7 -1
- package/modules/portability/transient-tables.mjs +40 -0
- package/package.json +3 -1
- package/scripts/publish-check/reviewed.py +3 -1
|
@@ -22,10 +22,13 @@ export async function destinationLedger(db) {
|
|
|
22
22
|
if(found.includes('_rer_deploy_migrations'))return (await all(db,"SELECT * FROM _rer_deploy_migrations WHERE state='applied' ORDER BY name")).map(entry);
|
|
23
23
|
if(found.includes('d1_migrations')) {
|
|
24
24
|
const columns=(await all(db,'PRAGMA table_info(d1_migrations)')).map(x=>x.name);
|
|
25
|
+
insist(['id','name','applied_at'].every(name=>columns.includes(name)),'schema_mismatch:migration_history',409);
|
|
25
26
|
const tracked=columns.includes('state') || columns.includes('sha256');
|
|
26
27
|
if(tracked)insist(columns.includes('state') && columns.includes('sha256'),'schema_mismatch:migration_history',409);
|
|
27
28
|
const rows=await all(db,`SELECT name${tracked?',state,sha256':''} FROM d1_migrations ORDER BY id`);
|
|
29
|
+
insist(rows.every(row=>typeof row.name==='string') && new Set(rows.map(row=>row.name)).size===rows.length,'schema_mismatch:migration_history',409);
|
|
28
30
|
if(tracked)insist(rows.every(row=>row.state==='applied'),'schema_mismatch:uncertain_migrations',409);
|
|
31
|
+
if(tracked)insist(rows.every(row=>typeof row.sha256==='string' && /^[a-f0-9]{64}$/.test(row.sha256)),'schema_mismatch:migration_history',409);
|
|
29
32
|
return rows.map(entry);
|
|
30
33
|
}
|
|
31
34
|
if(!found.includes('rer_migrations'))return;
|
|
@@ -34,6 +37,7 @@ export async function destinationLedger(db) {
|
|
|
34
37
|
// cloudflare-migrations.ts:34-44), so rowid order is application order.
|
|
35
38
|
insist(shape(await all(db,'PRAGMA table_info(rer_migrations)'))===platformShape,'schema_mismatch:migration_history',409);
|
|
36
39
|
const rows=await all(db,'SELECT name,sha256 FROM rer_migrations ORDER BY rowid');
|
|
40
|
+
insist(rows.every(row=>typeof row.name==='string' && typeof row.sha256==='string' && /^[a-f0-9]{64}$/.test(row.sha256)) && new Set(rows.map(row=>row.name)).size===rows.length,'schema_mismatch:migration_history',409);
|
|
37
41
|
insist(!rows.some(row=>partial(row.name)),'schema_mismatch:uncertain_migrations',409);
|
|
38
42
|
return rows.map(entry);
|
|
39
43
|
}
|
|
@@ -44,7 +48,7 @@ const entry=row=>({name:row.name,...(typeof row.sha256==='string'?{sha256:row.sh
|
|
|
44
48
|
// confirm that file, but cannot point at another one. Hashless rows use exact
|
|
45
49
|
// names or seed-declared aliases. The caller keeps the destination replay order.
|
|
46
50
|
export function matchMigrationLedger(entries,files,{dataOnly=[]}={}) {
|
|
47
|
-
|
|
51
|
+
const matched=entries.flatMap(m=>{
|
|
48
52
|
const named=files.filter(file=>file.name===m.name || file.aliases?.includes(m.name));
|
|
49
53
|
insist(named.length<=1,'migration_ledger:ambiguous:'+m.name,409);
|
|
50
54
|
if(m.sha256===undefined) {
|
|
@@ -59,6 +63,8 @@ export function matchMigrationLedger(entries,files,{dataOnly=[]}={}) {
|
|
|
59
63
|
insist(!named.length || named[0]===matches[0],'migration_ledger:conflict:'+m.name,409);
|
|
60
64
|
return [matches[0].name];
|
|
61
65
|
});
|
|
66
|
+
insist(new Set(matched).size===matched.length,'migration_ledger:ambiguous',409);
|
|
67
|
+
return matched;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
/** The ledger tables an archive carries (old archives carried rer_migrations before it became bookkeeping). */
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { tokens, identifier, folded } from './generated.mjs';
|
|
2
|
+
import { schemaChange, statementNames, triggerBodies } from './migration-statements.mjs';
|
|
3
|
+
|
|
4
|
+
// A missing historical table is still a real read dependency. Reconstruct only
|
|
5
|
+
// a single, bounded CREATE / INSERTs / DROP wholly after the archive. No schema
|
|
6
|
+
// mutation, FK or trigger effects may escape this temporary lifetime.
|
|
7
|
+
export function transientTables(statements,later,tables,carried) {
|
|
8
|
+
const history=new Map(),dropped=new Set();
|
|
9
|
+
for(const sql of statements) {
|
|
10
|
+
const words=tokens(sql).map(t=>t.quoted?undefined:folded(t.text));
|
|
11
|
+
if(words[0]==='drop' && words[1]==='table')statementNames(sql).forEach(name=>dropped.add(name));
|
|
12
|
+
const ddl=tableDDL(sql);
|
|
13
|
+
if(!ddl)continue;
|
|
14
|
+
if(!history.has(ddl.name))history.set(ddl.name,[]);
|
|
15
|
+
history.get(ddl.name).push({...ddl,sql});
|
|
16
|
+
}
|
|
17
|
+
const missing=[...new Set([...history.keys(),...dropped])].filter(name=>!tables.includes(name)),plans=new Map();
|
|
18
|
+
for(const name of missing) {
|
|
19
|
+
const life=history.get(name);
|
|
20
|
+
if(carried.includes(name) || life?.length!==2 || life[0].verb!=='create' || life[1].verb!=='drop')continue;
|
|
21
|
+
const create=later.find(s=>s.sql===life[0].sql),drop=later.find(s=>s.sql===life[1].sql);
|
|
22
|
+
if(!create || !drop || later.indexOf(create)>=later.indexOf(drop) || schemaChange(create.sql)!=='create table')continue;
|
|
23
|
+
if(tokens(create.sql).some(t=>!t.quoted && folded(t.text)==='references') || triggerBodies(statements,name).length)continue;
|
|
24
|
+
const touches=later.filter(s=>statementNames(s.sql).includes(name));
|
|
25
|
+
if(touches.some(s=>s!==create && s!==drop && (!s.data || later.indexOf(s)<=later.indexOf(create) || later.indexOf(s)>=later.indexOf(drop))))continue;
|
|
26
|
+
const fills=touches.filter(s=>s.data?.target===name);
|
|
27
|
+
if(!fills.length || fills.some(s=>!['insert','replace'].includes(s.data.verb)))continue;
|
|
28
|
+
plans.set(name,{create,drop,fills});
|
|
29
|
+
}
|
|
30
|
+
return {missing,plans};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function tableDDL(sql) {
|
|
34
|
+
const list=tokens(sql),words=list.map(t=>t.quoted?undefined:folded(t.text));
|
|
35
|
+
if(!['create','drop'].includes(words[0]) || words[1]!=='table')return;
|
|
36
|
+
const at=words[2]==='if'?(words[0]==='create'?5:4):2,token=list[at];
|
|
37
|
+
// Qualified names and unusual table syntax keep the previous admission.
|
|
38
|
+
if(!token || !token.quoted && !/^[a-z_][a-z0-9_$]*$/i.test(token.text))return;
|
|
39
|
+
return {name:folded(identifier(token)),verb:words[0]};
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runeditrun/rer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.78",
|
|
4
4
|
"description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"./adapter": "./cli/adapter.mjs",
|
|
12
12
|
"./deploy": "./cli/deploy.mjs",
|
|
13
13
|
"./portability": "./cli/portability.mjs",
|
|
14
|
+
"./portability-migrations": "./cli/portability-migrations.mjs",
|
|
14
15
|
"./errors": "./cli/errors.mjs",
|
|
15
16
|
"./jsonc": "./cli/jsonc.mjs",
|
|
16
17
|
"./parse": "./cli/parse.mjs",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"./modules/portability/legacy-safety": "./modules/portability/legacy-safety.mjs",
|
|
71
72
|
"./modules/portability/migration-history": "./modules/portability/migration-history.mjs",
|
|
72
73
|
"./modules/portability/storage": "./modules/portability/storage.mjs",
|
|
74
|
+
"./modules/import-kit/d1": "./modules/import-kit/src/d1/index.ts",
|
|
73
75
|
"./modules/erasure/fence": "./modules/erasure/fence.mjs",
|
|
74
76
|
"./modules/deploy-kit/migration-ledger": "./modules/deploy-kit/migration-ledger.mjs",
|
|
75
77
|
"./modules/deploy-kit/owner": "./modules/deploy-kit/owner.mjs",
|
|
@@ -26,8 +26,10 @@ def load_reviewed(data):
|
|
|
26
26
|
result = {}
|
|
27
27
|
for entry in document['findings']:
|
|
28
28
|
fields = {'rule', 'path', 'blob', 'reason', 'reviewer', 'date'}
|
|
29
|
-
if not isinstance(entry, dict) or set(entry) not in (fields, fields | {'fixtureValuesSha256'}, fields | {'containedFixtures'})
|
|
29
|
+
if not isinstance(entry, dict) or set(entry) not in (fields, fields | {'fixtureValuesSha256'}, fields | {'containedFixtures'}):
|
|
30
30
|
raise ValueError('invalid reviewed entry')
|
|
31
|
+
if entry['rule'] not in RULES | SECRET_RULES | FORBIDDEN | {'license.holder'}:
|
|
32
|
+
raise ValueError(f"rule {entry['rule']} is non-reviewable; see scripts/publish-check-README.md#reviewed-findings for remediation")
|
|
31
33
|
if not all(isinstance(entry[k], str) and entry[k].strip() for k in fields):
|
|
32
34
|
raise ValueError('invalid reviewed entry')
|
|
33
35
|
if not re.fullmatch(r'[0-9a-f]{40}|[0-9a-f]{64}', entry['blob']):
|