@niscorp/moss 0.8.1 → 0.9.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/DOCS.md +87 -26
  3. package/README.md +9 -8
  4. package/dist/{chunk-3DCTQKPQ.cjs → chunk-E6YAYR7G.cjs} +22 -5
  5. package/dist/chunk-E6YAYR7G.cjs.map +1 -0
  6. package/dist/{chunk-TMDKNZYL.cjs → chunk-L2GHVTJW.cjs} +103 -71
  7. package/dist/chunk-L2GHVTJW.cjs.map +1 -0
  8. package/dist/{chunk-I4UOWER3.cjs → chunk-LKTS4PCD.cjs} +5 -5
  9. package/dist/{chunk-I4UOWER3.cjs.map → chunk-LKTS4PCD.cjs.map} +1 -1
  10. package/dist/{chunk-3T422CCN.js → chunk-UUOATPZ7.js} +3 -3
  11. package/dist/{chunk-3T422CCN.js.map → chunk-UUOATPZ7.js.map} +1 -1
  12. package/dist/{chunk-6XC2MD7S.js → chunk-WTWRLOPK.js} +22 -5
  13. package/dist/chunk-WTWRLOPK.js.map +1 -0
  14. package/dist/{chunk-YZILOVCR.js → chunk-Y7PRASR3.js} +49 -18
  15. package/dist/chunk-Y7PRASR3.js.map +1 -0
  16. package/dist/{document-BYAY-Qle.d.ts → document-C3aS9uiW.d.ts} +2 -1
  17. package/dist/{document-DAE71J27.d.cts → document-deAs7Dre.d.cts} +2 -1
  18. package/dist/index.cjs +17 -13
  19. package/dist/index.d.cts +8 -5
  20. package/dist/index.d.ts +8 -5
  21. package/dist/index.js +2 -2
  22. package/dist/integrations.cjs +12 -5
  23. package/dist/integrations.cjs.map +1 -1
  24. package/dist/integrations.js +12 -5
  25. package/dist/integrations.js.map +1 -1
  26. package/dist/node.cjs +7 -7
  27. package/dist/node.d.cts +1 -1
  28. package/dist/node.d.ts +1 -1
  29. package/dist/node.js +3 -3
  30. package/dist/unverified.cjs +2 -2
  31. package/dist/unverified.js +1 -1
  32. package/dist/vite.cjs +8 -8
  33. package/dist/vite.d.cts +1 -1
  34. package/dist/vite.d.ts +1 -1
  35. package/dist/vite.js +3 -3
  36. package/package.json +12 -12
  37. package/dist/chunk-3DCTQKPQ.cjs.map +0 -1
  38. package/dist/chunk-6XC2MD7S.js.map +0 -1
  39. package/dist/chunk-TMDKNZYL.cjs.map +0 -1
  40. package/dist/chunk-YZILOVCR.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk3DCTQKPQ_cjs = require('./chunk-3DCTQKPQ.cjs');
3
+ var chunkE6YAYR7G_cjs = require('./chunk-E6YAYR7G.cjs');
4
4
  var chunkPVZMCEBX_cjs = require('./chunk-PVZMCEBX.cjs');
5
5
  var chunk3RIWTXGI_cjs = require('./chunk-3RIWTXGI.cjs');
6
6
  var zod = require('zod');
@@ -612,8 +612,20 @@ var oneAtATime = (query) => {
612
612
  return next;
613
613
  };
614
614
  };
615
+ var ownersOf = (runtime, app) => ({
616
+ pool: runtime.pool,
617
+ cache: runtime.cache,
618
+ storesSessions: runtime.session === "sessions",
619
+ featureTables: featureTablesOf(app),
620
+ tables: runtime.tables
621
+ });
622
+ var tableStatus = async (runtime, app) => postgres.status(runtime.pool, tableSequencesOf(ownersOf(runtime, app)), { complete: true });
623
+ var removalsRefused = (found) => [
624
+ ...found.removed.map((what) => `this run removes ${what}`),
625
+ ...found.retyped.map((what) => `this run changes the type of ${what}`)
626
+ ].map((sentence) => `${sentence} \u2014 nothing removed or retyped is applied unless it is allowed (\`allowRemoval\`; \`nisc migrate --allow-removal\`)`);
615
627
  var migrateTables = async (runtime, app, options = {}) => {
616
- const entries = chunk3DCTQKPQ_cjs.entriesOf(app);
628
+ const entries = chunkE6YAYR7G_cjs.entriesOf(app);
617
629
  const cache = runtime.cache ?? vex.createPostgresCache({ pool: runtime.pool });
618
630
  const before = await vex.createPostgresAdapter({ pool: runtime.pool }).introspect();
619
631
  const misfitsBefore = misfitsOf(entries, before);
@@ -622,10 +634,10 @@ var migrateTables = async (runtime, app, options = {}) => {
622
634
  if (misfitsBefore.has(entry.fingerprint) && await isSeededAs(cache, entry).catch(() => false)) excused.add(entry.fingerprint);
623
635
  }
624
636
  let found = { removed: [], retyped: [], alreadyBroken: [] };
625
- const owners = { pool: runtime.pool, cache: runtime.cache, storesSessions: runtime.session === "sessions", featureTables: featureTablesOf(app), tables: runtime.tables };
626
- const report = await postgres.migrate(runtime.pool, tableSequencesOf(owners), {
637
+ const report = await postgres.migrate(runtime.pool, tableSequencesOf(ownersOf(runtime, app)), {
638
+ complete: true,
627
639
  ...options.dryRun === true ? { dryRun: true } : {},
628
- guard: async (tx) => {
640
+ guard: async (tx, run) => {
629
641
  const after = await vex.createPostgresAdapter({ pool: { query: oneAtATime((text, values) => tx.query(text, values)) } }).introspect();
630
642
  const refused = [];
631
643
  const alreadyBroken = [];
@@ -633,11 +645,12 @@ var migrateTables = async (runtime, app, options = {}) => {
633
645
  if (excused.has(fingerprint)) alreadyBroken.push(`${fingerprint}: ${why}`);
634
646
  else refused.push(`${fingerprint}: ${why}`);
635
647
  }
636
- found = { ...changesBetween(before, after), alreadyBroken };
637
- return refused;
648
+ const changes = run.applied.length === 0 ? { removed: [], retyped: [] } : changesBetween(before, after);
649
+ found = { ...changes, alreadyBroken };
650
+ return options.allowRemoval === true ? refused : [...refused, ...removalsRefused(changes)];
638
651
  }
639
652
  });
640
- return { ...report, ...found, ...report.applied.length === 0 ? { removed: [], retyped: [] } : {} };
653
+ return { ...report, ...found };
641
654
  };
642
655
  var featureTablesOf = (app) => {
643
656
  const features = /* @__PURE__ */ new Set();
@@ -997,7 +1010,15 @@ var createIntentAnswers = (deps) => {
997
1010
  // src/data/data.ts
998
1011
  var callerOfRoles = (roles) => ({ memoKey: memoKey(roles, void 0), roles });
999
1012
  var prepareEngine = async (config) => {
1000
- await postgres.migrate(config.pool, tableSequencesOf(config), { mode: config.migrations ?? "apply" });
1013
+ await postgres.migrate(config.pool, tableSequencesOf(config), { mode: config.migrations ?? "verify", complete: true }).catch((error) => {
1014
+ if (!(error instanceof strata.StrataError) || error.code !== "PENDING") throw error;
1015
+ throw new strata.StrataError(
1016
+ "PENDING",
1017
+ `The database is ${error.details.length} migration${error.details.length === 1 ? "" : "s"} behind this code, and the server only checks its tables at boot. Rehearse them with \`npx nisc migrate --check\`, then apply them with \`npx nisc migrate\`. A database that starts empty every time (PGlite in memory) is migrated at boot instead: its runtime sets \`migrations: 'apply'\`.`,
1018
+ error.details,
1019
+ { cause: error }
1020
+ );
1021
+ });
1001
1022
  const grammars = await createGrammarUpgrader({ grammars: config.grammars });
1002
1023
  const layer = await createDataLayer(config);
1003
1024
  return {
@@ -1251,15 +1272,15 @@ var isKept = (layout) => layout !== void 0 && layout !== null && typeof layout !
1251
1272
  var shellWithStoredLayouts = (shell) => {
1252
1273
  const layouts = {};
1253
1274
  const frame = shell.layout;
1254
- if (isKept(frame)) layouts[chunk3DCTQKPQ_cjs.FRAME_LAYOUT_REF] = frame;
1275
+ if (isKept(frame)) layouts[chunkE6YAYR7G_cjs.FRAME_LAYOUT_REF] = frame;
1255
1276
  const canvases = shell.canvases.map((canvas) => {
1256
1277
  const layout = canvas.actionLayout;
1257
1278
  if (!isKept(layout)) return canvas;
1258
- const ref = chunk3DCTQKPQ_cjs.canvasLayoutRef(canvas.id);
1279
+ const ref = chunkE6YAYR7G_cjs.canvasLayoutRef(canvas.id);
1259
1280
  layouts[ref] = layout;
1260
1281
  return { ...canvas, actionLayout: ref };
1261
1282
  });
1262
- return { canvases, ...isKept(frame) ? { frame: chunk3DCTQKPQ_cjs.FRAME_LAYOUT_REF } : typeof frame === "string" ? { frame } : {}, layouts };
1283
+ return { canvases, ...isKept(frame) ? { frame: chunkE6YAYR7G_cjs.FRAME_LAYOUT_REF } : typeof frame === "string" ? { frame } : {}, layouts };
1263
1284
  };
1264
1285
  var slottedIn = /* @__PURE__ */ new WeakMap();
1265
1286
  var canvasesSlottedIn = (layout) => {
@@ -1310,7 +1331,7 @@ var createComponentNames = (read2) => {
1310
1331
  var SavedLayoutSchema = zod.z.strictObject({ ref: zod.z.string(), layout: nova.LayoutNodeSchema, use: zod.z.boolean().optional() });
1311
1332
  var upgradedLayoutBody = (upgrader, body, stamp) => reflect.isRecord(body) && body["layout"] !== void 0 ? { ...body, layout: upgrader.upgrade(body["layout"], { kind: "nisc.nova/layout", stamp }).document } : body;
1312
1333
  var actionAtRef = (actions, layouts) => (ref) => {
1313
- const id = chunk3DCTQKPQ_cjs.actionOfLayoutRef(ref);
1334
+ const id = chunkE6YAYR7G_cjs.actionOfLayoutRef(ref);
1314
1335
  const action = id !== void 0 && Object.hasOwn(actions, id) ? actions[id] : void 0;
1315
1336
  const layout = Object.hasOwn(layouts, ref) ? layouts[ref] : void 0;
1316
1337
  return action === void 0 || layout === void 0 ? void 0 : { ...action, layout };
@@ -1335,9 +1356,9 @@ var readLayout = (body, heldTo) => {
1335
1356
  const { ref, layout } = parsed.data;
1336
1357
  const target = targetAt(ref, heldTo);
1337
1358
  if (target === void 0) return { refusal: nothingKeptUnder(ref) };
1338
- const misfits = chunk3DCTQKPQ_cjs.layoutMisfits(layout, target.kit);
1359
+ const misfits = chunkE6YAYR7G_cjs.layoutMisfits(layout, target.kit);
1339
1360
  if (misfits.length > 0) return { refusal: misfits.join("; ") };
1340
- const named = chunk3DCTQKPQ_cjs.layoutNameRefusal(layout);
1361
+ const named = chunkE6YAYR7G_cjs.layoutNameRefusal(layout);
1341
1362
  if (named !== void 0) return { refusal: `it ${named}` };
1342
1363
  const { action } = target;
1343
1364
  if (action === void 0) return { layout: parsed.data };
@@ -1371,7 +1392,7 @@ var layoutsInUse = (inForce2, drawnFor) => {
1371
1392
  }
1372
1393
  return layouts;
1373
1394
  };
1374
- var generatedId = () => `${chunk3DCTQKPQ_cjs.GENERATED_ID_PREFIX}${crypto$1.randomUUID()}`;
1395
+ var generatedId = () => `${chunkE6YAYR7G_cjs.GENERATED_ID_PREFIX}${crypto$1.randomUUID()}`;
1375
1396
  var VEX_ROUTE = /^\/api\/(?:[A-Za-z0-9_-]+\/)?vex$/;
1376
1397
  var endpointRefusals = async (endpoints, heldTo) => {
1377
1398
  const refusals = [];
@@ -1408,8 +1429,8 @@ var parsedUnder = (schema, body, id, more = {}) => {
1408
1429
  return { refusal: first === void 0 ? "no reason given" : `${first.path.join(".") || "(the body)"}: ${first.message}` };
1409
1430
  };
1410
1431
  var layoutRefusals = (layout, kit) => {
1411
- const named = chunk3DCTQKPQ_cjs.layoutNameRefusal(layout);
1412
- return [...layout === void 0 || typeof layout === "string" ? [] : chunk3DCTQKPQ_cjs.layoutMisfits(layout, kit), ...named === void 0 ? [] : [`it ${named}`]];
1432
+ const named = chunkE6YAYR7G_cjs.layoutNameRefusal(layout);
1433
+ return [...layout === void 0 || typeof layout === "string" ? [] : chunkE6YAYR7G_cjs.layoutMisfits(layout, kit), ...named === void 0 ? [] : [`it ${named}`]];
1413
1434
  };
1414
1435
  var passedOrRefused = (body, refusals) => refusals.length > 0 ? { refusal: refusals.join("; ") } : { body };
1415
1436
  var readAction = async (body, id, heldTo) => {
@@ -1811,7 +1832,7 @@ var createGeneration = (pointer, ctx) => {
1811
1832
  var NO_DEFAULTS = { actions: {}, fragments: {}, reads: /* @__PURE__ */ new Map() };
1812
1833
  var drawableIn = (fragments, kit, say) => Object.fromEntries(
1813
1834
  Object.entries(fragments).filter(([id, fragment]) => {
1814
- const misfits = chunk3DCTQKPQ_cjs.layoutMisfits(fragment.layout, kit);
1835
+ const misfits = chunkE6YAYR7G_cjs.layoutMisfits(fragment.layout, kit);
1815
1836
  if (misfits.length > 0) say(`[moss] the fragment "${id}" published for everybody is left out of a shell that cannot draw it: ${misfits.join("; ")}`);
1816
1837
  return misfits.length === 0;
1817
1838
  })
@@ -1849,7 +1870,7 @@ var checkedDefaults = async (versions, heldTo, whose) => {
1849
1870
  catalog: () => [...Object.values(heldTo.built).map((action) => ({ id: action.id, input: action.input ?? {} })), ...catalogOfGenerated(versions)]
1850
1871
  };
1851
1872
  const passed = await generatedInForce(versions, checks, whose);
1852
- return { passed, reads, verified: chunk3DCTQKPQ_cjs.verifyManifest(heldTo.candidate({ ...heldTo.built, ...passed.actions }, passed.fragments)) };
1873
+ return { passed, reads, verified: chunkE6YAYR7G_cjs.verifyManifest(heldTo.candidate({ ...heldTo.built, ...passed.actions }, passed.fragments)) };
1853
1874
  };
1854
1875
  var narrowedBy = (filter, ids, installed) => {
1855
1876
  const answered = new Set(filter(ids, installed));
@@ -1862,9 +1883,9 @@ var catalogFor = (app, roles, installed, installedOnly) => {
1862
1883
  };
1863
1884
  var resolveVariantsForRoles = (app, roles) => {
1864
1885
  const variants = app.layouts ?? {};
1865
- return chunk3DCTQKPQ_cjs.variantLayouts(variants, charter.resolvePrincipal(app.charter, Object.keys(variants), roles, "layouts"));
1886
+ return chunkE6YAYR7G_cjs.variantLayouts(variants, charter.resolvePrincipal(app.charter, Object.keys(variants), roles, "layouts"));
1866
1887
  };
1867
- var definitionsFor = (actions, ids, variants) => Object.freeze(Object.fromEntries(chunk3DCTQKPQ_cjs.withVariants(actions, ids, variants)));
1888
+ var definitionsFor = (actions, ids, variants) => Object.freeze(Object.fromEntries(chunkE6YAYR7G_cjs.withVariants(actions, ids, variants)));
1868
1889
  var actionsWithStoredLayouts = (definitions) => {
1869
1890
  const actions = {};
1870
1891
  const layouts = {};
@@ -1874,7 +1895,7 @@ var actionsWithStoredLayouts = (definitions) => {
1874
1895
  actions[id] = definition;
1875
1896
  continue;
1876
1897
  }
1877
- const ref = chunk3DCTQKPQ_cjs.actionLayoutRef(id);
1898
+ const ref = chunkE6YAYR7G_cjs.actionLayoutRef(id);
1878
1899
  layouts[ref] = layout;
1879
1900
  actions[id] = { ...definition, layout: { ref } };
1880
1901
  }
@@ -1970,17 +1991,17 @@ var tell = (listener, ...told) => {
1970
1991
  };
1971
1992
  var createRunningManifest = (config) => {
1972
1993
  const { shipped } = config;
1973
- const entries = createEntriesInForce(chunk3DCTQKPQ_cjs.entriesOf(shipped));
1994
+ const entries = createEntriesInForce(chunkE6YAYR7G_cjs.entriesOf(shipped));
1974
1995
  let defaults = NO_DEFAULTS;
1975
1996
  const usage = createUsage(config.touchEveryMs ?? TOUCH_EVERY_MS);
1976
1997
  let functionIds;
1977
- const candidate = (actions, held = entries.list(), fragments = defaults.fragments) => chunk3DCTQKPQ_cjs.withFragments({ ...chunk3DCTQKPQ_cjs.candidateOf(shipped, { actions, entries: held }, config.grants), ...functionIds === void 0 ? {} : { functionIds } }, fragments);
1998
+ const candidate = (actions, held = entries.list(), fragments = defaults.fragments) => chunkE6YAYR7G_cjs.withFragments({ ...chunkE6YAYR7G_cjs.candidateOf(shipped, { actions, entries: held }, config.grants), ...functionIds === void 0 ? {} : { functionIds } }, fragments);
1978
1999
  const own = shipped.actions;
1979
2000
  const loaders = /* @__PURE__ */ new Map();
1980
2001
  const owners = createSetOwners();
1981
2002
  let sets = /* @__PURE__ */ new Map();
1982
2003
  let inForce2 = mergedActions(own, sets);
1983
- let report = chunk3DCTQKPQ_cjs.verifiedAtBoot(candidate(inForce2));
2004
+ let report = chunkE6YAYR7G_cjs.verifiedAtBoot(candidate(inForce2));
1984
2005
  const components = createComponentNames((shell) => shellComponents({ actions: inForce2, layouts: shipped.layouts }, shell));
1985
2006
  const componentsOf2 = (shells) => {
1986
2007
  const kit = /* @__PURE__ */ new Map();
@@ -2015,14 +2036,14 @@ var createRunningManifest = (config) => {
2015
2036
  const { reads: readSources } = config;
2016
2037
  const functionsWritten = (written) => {
2017
2038
  if (functionIds !== void 0) return;
2018
- const ids = chunk3DCTQKPQ_cjs.functionsIn(written).map((definition) => definition.id);
2019
- const charter = chunk3DCTQKPQ_cjs.charterOverFunctions(shipped.charter, { actions: Object.keys(inForce2), data: config.grants, layouts: Object.keys(shipped.layouts ?? {}) }, ids);
2039
+ const ids = chunkE6YAYR7G_cjs.functionsIn(written).map((definition) => definition.id);
2040
+ const charter = chunkE6YAYR7G_cjs.charterOverFunctions(shipped.charter, { actions: Object.keys(inForce2), data: config.grants, layouts: Object.keys(shipped.layouts ?? {}) }, ids);
2020
2041
  if (charter.errors.length > 0) throw new Error(`Charter is incoherent over the app\u2019s functions \u2014 refusing to serve:
2021
2042
  ${charter.errors.join("\n ")}`);
2022
2043
  functionIds = new Set(ids);
2023
2044
  const built = mergedActions(own, sets);
2024
- const verified = chunk3DCTQKPQ_cjs.verifyManifest(candidate(built, entries.list(), {}));
2025
- const refusal = chunk3DCTQKPQ_cjs.refusalOf(verified, "boot");
2045
+ const verified = chunkE6YAYR7G_cjs.verifyManifest(candidate(built, entries.list(), {}));
2046
+ const refusal = chunkE6YAYR7G_cjs.refusalOf(verified, "boot");
2026
2047
  if (refusal !== void 0) {
2027
2048
  functionIds = void 0;
2028
2049
  throw new Error(refusal);
@@ -2033,7 +2054,7 @@ var createRunningManifest = (config) => {
2033
2054
  dropMemos();
2034
2055
  memo.drop();
2035
2056
  for (const warning2 of charter.warnings) console.warn(`[moss] charter: ${warning2}`);
2036
- const warning = chunk3DCTQKPQ_cjs.functionsWarning(written);
2057
+ const warning = chunkE6YAYR7G_cjs.functionsWarning(written);
2037
2058
  if (warning !== void 0) console.warn(warning);
2038
2059
  };
2039
2060
  const grantedFunctionsOf = (roles) => (names) => charter.resolvePrincipal(shipped.charter, names, roles, "functions");
@@ -2087,7 +2108,7 @@ var createRunningManifest = (config) => {
2087
2108
  const over = sets;
2088
2109
  const { passed, reads, verified } = await checkedDefaults(versions, defaultsHeldTo(), "published for everybody");
2089
2110
  if (sets !== over) return applyPublished(versions);
2090
- const refusal = chunk3DCTQKPQ_cjs.refusalOf(verified, "boot");
2111
+ const refusal = chunkE6YAYR7G_cjs.refusalOf(verified, "boot");
2091
2112
  if (refusal !== void 0) memo.sayOnce(`[moss] what is published for everybody is left out, and the build\u2019s copies stand: ${refusal}`);
2092
2113
  const next = refusal === void 0 ? { actions: passed.actions, fragments: passed.fragments, reads } : { ...NO_DEFAULTS, reads };
2093
2114
  if (!hasDefaults(next) && !hasDefaults(defaults)) return;
@@ -2111,10 +2132,10 @@ var createRunningManifest = (config) => {
2111
2132
  const applySets = (arrived, announce) => {
2112
2133
  const next = new Map([...sets, ...arrived]);
2113
2134
  const actions = mergedActions(own, next, defaults.actions);
2114
- const verified = chunk3DCTQKPQ_cjs.verifyManifest(candidate(actions));
2115
- const refusal = chunk3DCTQKPQ_cjs.refusalOf(verified, "refresh");
2135
+ const verified = chunkE6YAYR7G_cjs.verifyManifest(candidate(actions));
2136
+ const refusal = chunkE6YAYR7G_cjs.refusalOf(verified, "refresh");
2116
2137
  if (refusal !== void 0) throw new Error(refusal);
2117
- for (const set of arrived.values()) chunk3DCTQKPQ_cjs.freezeDeep(set);
2138
+ for (const set of arrived.values()) chunkE6YAYR7G_cjs.freezeDeep(set);
2118
2139
  sets = next;
2119
2140
  inForce2 = actions;
2120
2141
  report = verified;
@@ -2130,13 +2151,13 @@ var createRunningManifest = (config) => {
2130
2151
  };
2131
2152
  const takeEntries = async (source, handed) => {
2132
2153
  owners.assertAppOwned(source);
2133
- const misfits = chunk3DCTQKPQ_cjs.entryMisfits(handed);
2154
+ const misfits = chunkE6YAYR7G_cjs.entryMisfits(handed);
2134
2155
  if (misfits.length > 0) throw new Error(["Refresh refused \u2014 entries that do not parse:", ...misfits.map((misfit) => ` ${misfit}`)].join("\n"));
2135
2156
  const compiled = await compileEntries(handed);
2136
- const verified = chunk3DCTQKPQ_cjs.verifyManifest(candidate(inForce2, entries.withSet(source, handed)));
2137
- const refusal = chunk3DCTQKPQ_cjs.refusalOf(verified, "refresh");
2157
+ const verified = chunkE6YAYR7G_cjs.verifyManifest(candidate(inForce2, entries.withSet(source, handed)));
2158
+ const refusal = chunkE6YAYR7G_cjs.refusalOf(verified, "refresh");
2138
2159
  if (refusal !== void 0) throw new Error(refusal);
2139
- chunk3DCTQKPQ_cjs.freezeDeep(handed);
2160
+ chunkE6YAYR7G_cjs.freezeDeep(handed);
2140
2161
  entries.takeSet(source, handed, compiled);
2141
2162
  report = verified;
2142
2163
  for (const listener of [...listeners]) tell(listener);
@@ -2146,7 +2167,7 @@ var createRunningManifest = (config) => {
2146
2167
  return {
2147
2168
  actions: () => inForce2,
2148
2169
  entries: entries.list,
2149
- verify: (actions) => chunk3DCTQKPQ_cjs.verifyManifest(candidate(actions)),
2170
+ verify: (actions) => chunkE6YAYR7G_cjs.verifyManifest(candidate(actions)),
2150
2171
  report: () => report,
2151
2172
  replace: (source, actions) => applySets(/* @__PURE__ */ new Map([[owners.assertAppOwned(source), actions]]), true),
2152
2173
  // In turn: a set is compiled before it is taken, and of two handed over
@@ -2207,7 +2228,7 @@ var createRunningManifest = (config) => {
2207
2228
  const drawable = theirOwn.heldTo.layouts;
2208
2229
  const theirs2 = layoutsInUse(versions, { whose, heldTo: drawable });
2209
2230
  const variants = roleMemo.variantsFor(roles);
2210
- const underVariants = { ...drawable, actionAt: (ref) => variants.has(chunk3DCTQKPQ_cjs.actionOfLayoutRef(ref) ?? "") ? void 0 : drawable.actionAt(ref) };
2231
+ const underVariants = { ...drawable, actionAt: (ref) => variants.has(chunkE6YAYR7G_cjs.actionOfLayoutRef(ref) ?? "") ? void 0 : drawable.actionAt(ref) };
2211
2232
  const everybodys = layoutsInUse(everybodysVersions, { whose: "published for everybody", heldTo: underVariants, say: memo.sayOnce });
2212
2233
  const laidOverShell = { ...drawableIn(defaults.fragments, kitOf2(shell), memo.sayOnce), ...theirOwn.fragments };
2213
2234
  const fragments = Object.keys(laidOverShell).length === 0 ? shell.fragments : { ...shell.fragments, ...laidOverShell };
@@ -2239,7 +2260,7 @@ var createRunningManifest = (config) => {
2239
2260
  verify: async (versions, inForce3) => {
2240
2261
  const kept = inForce3.filter((held) => !versions.some((version) => version.kind === held.kind && version.id === held.id));
2241
2262
  const asked = versions.map((version) => ({ ...version, save: "", createdAt: "" }));
2242
- const refusal = chunk3DCTQKPQ_cjs.refusalOf((await checkedDefaults([...kept, ...asked], defaultsHeldTo(), void 0)).verified, "publish");
2263
+ const refusal = chunkE6YAYR7G_cjs.refusalOf((await checkedDefaults([...kept, ...asked], defaultsHeldTo(), void 0)).verified, "publish");
2243
2264
  if (refusal !== void 0) throw new Error(refusal);
2244
2265
  }
2245
2266
  },
@@ -2630,7 +2651,7 @@ var refusalOf2 = (error) => {
2630
2651
  var spanOf = (emit) => {
2631
2652
  if (emit === void 0) return void 0;
2632
2653
  const clock = chunkPVZMCEBX_cjs.spanClock();
2633
- return (name, status, hasPrincipal) => emit({ name, startUnixNano: clock.startUnixNano, endUnixNano: clock.endUnixNano(), status, attributes: { hasPrincipal } });
2654
+ return (name, status2, hasPrincipal) => emit({ name, startUnixNano: clock.startUnixNano, endUnixNano: clock.endUnixNano(), status: status2, attributes: { hasPrincipal } });
2634
2655
  };
2635
2656
  var openingOf = (config, { seed, path }) => {
2636
2657
  const route = path === void 0 ? void 0 : config.page?.(path);
@@ -2737,13 +2758,13 @@ var seamsFor = (feature, owned, { app, runtime, server, operator, registered, id
2737
2758
  grantedActionIds: (roles, installed) => running.catalogFor(roles, installed).ids,
2738
2759
  actions: running.actions,
2739
2760
  replaceActions: owned.replace,
2740
- refusalOf: (actions) => chunk3DCTQKPQ_cjs.refusalOf(running.verify(actions), "refresh"),
2761
+ refusalOf: (actions) => chunkE6YAYR7G_cjs.refusalOf(running.verify(actions), "refresh"),
2741
2762
  setActionsLoader: owned.setLoader,
2742
2763
  addCatalogFilter: running.addCatalogFilter,
2743
2764
  charter: app.charter,
2744
2765
  components: app.shell?.components ?? {},
2745
- layoutMisfits: (layout) => chunk3DCTQKPQ_cjs.layoutMisfits(layout, kitOf(app)),
2746
- endlessChains: chunk3DCTQKPQ_cjs.endlessChains,
2766
+ layoutMisfits: (layout) => chunkE6YAYR7G_cjs.layoutMisfits(layout, kitOf(app)),
2767
+ endlessChains: chunkE6YAYR7G_cjs.endlessChains,
2747
2768
  ownEntries: (entries) => data.ownEntries(feature.name, entries),
2748
2769
  grammars: data.grammars,
2749
2770
  upgradeStore: (store) => data.upgradeStore(feature.name, store),
@@ -2810,9 +2831,9 @@ var read = (live) => {
2810
2831
  console.error("[moss/shells] the shell frame failed to render for a snapshot \u2014 serving an empty arrangement:", error);
2811
2832
  }
2812
2833
  const trees = {};
2813
- for (const canvasId of chunk3DCTQKPQ_cjs.canvasesOf(live)) {
2834
+ for (const canvasId of chunkE6YAYR7G_cjs.canvasesOf(live)) {
2814
2835
  try {
2815
- trees[canvasId] = chunk3DCTQKPQ_cjs.treeOf(live, canvasId);
2836
+ trees[canvasId] = chunkE6YAYR7G_cjs.treeOf(live, canvasId);
2816
2837
  } catch (error) {
2817
2838
  console.error(`[moss/shells] canvas "${canvasId}" failed to render for a snapshot \u2014 leaving it out:`, error);
2818
2839
  }
@@ -2829,7 +2850,7 @@ var needOf = (live, principal, kept) => {
2829
2850
  for (const instance of canvas.stack) {
2830
2851
  const definition = live.shell.getRuntime(instance.id)?.definition;
2831
2852
  if (definition === void 0) continue;
2832
- const need = shellNeedOf(chunk3DCTQKPQ_cjs.withLayoutInPlace(definition, live.shell.layoutStore), entries);
2853
+ const need = shellNeedOf(chunkE6YAYR7G_cjs.withLayoutInPlace(definition, live.shell.layoutStore), entries);
2833
2854
  for (const reason of need.why) why.push(`${definition.id}: ${reason}`);
2834
2855
  for (const read2 of need.drawnWith) drawnWith.push(read2);
2835
2856
  }
@@ -2852,7 +2873,7 @@ var sweep = (host, idleMs) => {
2852
2873
  }
2853
2874
  if (live.connections.size > 0 || live.idleSince === null) continue;
2854
2875
  if (now - live.idleSince < idleMs) continue;
2855
- chunk3DCTQKPQ_cjs.endShell(host, live);
2876
+ chunkE6YAYR7G_cjs.endShell(host, live);
2856
2877
  live.shell.dispose();
2857
2878
  durable.delete(principal);
2858
2879
  }
@@ -2874,7 +2895,7 @@ var rosterOf = (durable) => {
2874
2895
  var sameDocument = (one, other) => one === other || JSON.stringify(one) === JSON.stringify(other);
2875
2896
  var takeLayouts = (live, made) => {
2876
2897
  const taken = live.layouts;
2877
- const answered = chunk3DCTQKPQ_cjs.layoutsOf(made);
2898
+ const answered = chunkE6YAYR7G_cjs.layoutsOf(made);
2878
2899
  for (const [ref, layout] of Object.entries(answered.layoutStore)) {
2879
2900
  if (!sameDocument(taken.layoutStore[ref], layout)) live.shell.setLayout(ref, layout);
2880
2901
  }
@@ -2904,15 +2925,15 @@ var takeComposition = (live, made) => {
2904
2925
  live.entries = made.entries;
2905
2926
  takeLayouts(live, made);
2906
2927
  takeCanvases(live, made);
2907
- chunk3DCTQKPQ_cjs.holdGranted(live.functions, made.grantedFunctions);
2928
+ chunkE6YAYR7G_cjs.holdGranted(live.functions, made.grantedFunctions);
2908
2929
  };
2909
2930
  var adoptDraft = async (host, live, next) => {
2910
2931
  for (; ; ) {
2911
2932
  const cell = host.living.get(live);
2912
- if (cell === void 0 || cell.live !== live) throw new Error(chunk3DCTQKPQ_cjs.SHELL_GONE);
2933
+ if (cell === void 0 || cell.live !== live) throw new Error(chunkE6YAYR7G_cjs.SHELL_GONE);
2913
2934
  const changes = host.changes;
2914
- const made = await host.config.composition(cell.principal, chunk3DCTQKPQ_cjs.draftedIn(next));
2915
- if (live.ended || cell.live !== live) throw new Error(chunk3DCTQKPQ_cjs.SHELL_GONE);
2935
+ const made = await host.config.composition(cell.principal, chunkE6YAYR7G_cjs.draftedIn(next));
2936
+ if (live.ended || cell.live !== live) throw new Error(chunkE6YAYR7G_cjs.SHELL_GONE);
2916
2937
  if (changes < cell.changes) continue;
2917
2938
  cell.changes = changes;
2918
2939
  live.draft = next;
@@ -2926,7 +2947,7 @@ var adopt = (host, cell) => {
2926
2947
  if (asked.ended) return;
2927
2948
  const drafted = asked.draft;
2928
2949
  const changes = host.changes;
2929
- const made = await host.config.composition(cell.principal, chunk3DCTQKPQ_cjs.draftedIn(drafted));
2950
+ const made = await host.config.composition(cell.principal, chunkE6YAYR7G_cjs.draftedIn(drafted));
2930
2951
  if (asked.ended || changes <= cell.changes) return;
2931
2952
  if (asked.draft !== drafted) {
2932
2953
  adopt(host, cell);
@@ -2957,7 +2978,7 @@ var build = (host, asked, wanted = () => true) => {
2957
2978
  reject(new Error(`moss: the shell of ${asked.principal ?? "nobody"} was not built within ${limit}ms.`));
2958
2979
  }, limit);
2959
2980
  timer.unref?.();
2960
- chunk3DCTQKPQ_cjs.buildShell(host, { ...asked, wanted: () => inTime && wanted() }).then((live) => resolve2(live === void 0 ? void 0 : { live, changes }), reject).finally(() => clearTimeout(timer));
2981
+ chunkE6YAYR7G_cjs.buildShell(host, { ...asked, wanted: () => inTime && wanted() }).then((live) => resolve2(live === void 0 ? void 0 : { live, changes }), reject).finally(() => clearTimeout(timer));
2961
2982
  });
2962
2983
  };
2963
2984
  var builtOrThrow = (built) => {
@@ -2997,21 +3018,26 @@ var replaceShell = async (host, cell) => {
2997
3018
  if (built === void 0) return;
2998
3019
  const old = cell.live;
2999
3020
  if (!stands()) {
3000
- chunk3DCTQKPQ_cjs.endShell(host, built.live);
3021
+ chunkE6YAYR7G_cjs.endShell(host, built.live);
3001
3022
  built.live.shell.dispose();
3002
3023
  return;
3003
3024
  }
3004
3025
  const carried = [...old.connections].map((connection) => ({ connection, wants: old.deltaReady.has(connection) }));
3005
- chunk3DCTQKPQ_cjs.endShell(host, old);
3026
+ chunkE6YAYR7G_cjs.endShell(host, old);
3006
3027
  old.connections.clear();
3007
3028
  old.shell.dispose();
3008
3029
  cell.live = built.live;
3009
3030
  cell.changes = built.changes;
3010
3031
  registerLiving(host, cell);
3011
- for (const { connection, wants } of carried) chunk3DCTQKPQ_cjs.attach(built.live, connection, host.delta && wants);
3032
+ for (const { connection, wants } of carried) chunkE6YAYR7G_cjs.attach(built.live, connection, host.delta && wants);
3012
3033
  };
3013
3034
  var resetCell = (host, cell) => {
3014
- const turn = (cell.resetting ?? Promise.resolve()).then(() => replaceShell(host, cell));
3035
+ if (cell.hasWaitingReset === true) return;
3036
+ cell.hasWaitingReset = true;
3037
+ const turn = (cell.resetting ?? Promise.resolve()).then(() => {
3038
+ cell.hasWaitingReset = false;
3039
+ return replaceShell(host, cell);
3040
+ });
3015
3041
  cell.resetting = turn.catch((error) => console.error("[moss/shells] a reset failed to rebuild", error));
3016
3042
  };
3017
3043
  var shellsOf = (host, principal) => {
@@ -3046,7 +3072,7 @@ var snapshotOf = (host) => async (token, principal, options) => {
3046
3072
  const settled = await settle(live, waitMs);
3047
3073
  return { ...read(live), seed, settled, ...needOf(live, principal, kept) };
3048
3074
  } finally {
3049
- chunk3DCTQKPQ_cjs.endShell(host, live);
3075
+ chunkE6YAYR7G_cjs.endShell(host, live);
3050
3076
  live.shell.dispose();
3051
3077
  }
3052
3078
  };
@@ -3078,9 +3104,9 @@ var createShellHost = (config) => {
3078
3104
  const handedOut = {
3079
3105
  session: async (token, principal, options) => {
3080
3106
  if (principal === null || !host.kept) {
3081
- return chunk3DCTQKPQ_cjs.sessionOn(host, await open2(host, { token, principal, ...options !== void 0 ? { opening: options } : {} }, false), true, reset);
3107
+ return chunkE6YAYR7G_cjs.sessionOn(host, await open2(host, { token, principal, ...options !== void 0 ? { opening: options } : {} }, false), true, reset);
3082
3108
  }
3083
- return chunk3DCTQKPQ_cjs.sessionOn(host, await keptCell(host, token, principal), false, reset);
3109
+ return chunkE6YAYR7G_cjs.sessionOn(host, await keptCell(host, token, principal), false, reset);
3084
3110
  },
3085
3111
  snapshot: snapshotOf(host),
3086
3112
  deliver: deliverTo(host),
@@ -3121,7 +3147,8 @@ var hostConfig = (deps, shell, kept) => {
3121
3147
  ...app.phrases !== void 0 ? { phrases: app.phrases } : {},
3122
3148
  ...app.functions !== void 0 ? { functions: app.functions } : {},
3123
3149
  ...app.onSession !== void 0 ? { onSession: app.onSession } : {},
3124
- ...app.runs !== void 0 ? { runs: app.runs } : {}
3150
+ ...app.runs !== void 0 ? { runs: app.runs } : {},
3151
+ ...app.reconcilers !== void 0 ? { reconcilers: app.reconcilers } : {}
3125
3152
  },
3126
3153
  ...app.phraseKeys !== void 0 ? { phraseKeys: app.phraseKeys } : {},
3127
3154
  kept,
@@ -3286,14 +3313,18 @@ var operatorPrefix = (runtime) => {
3286
3313
  guardOperator(operator, { key: runtime.operatorKey ?? "", gate: runtime.operatorGate });
3287
3314
  return operator;
3288
3315
  };
3289
- var buildSignals = ({ fabric, identity, reset, adopt: adopt2, deliver }) => {
3316
+ var buildSignals = ({ fabric, identity, reset, adopt: adopt2, adoptAll: adoptAll2, deliver }) => {
3290
3317
  const origin = crypto$1.randomBytes(8).toString("hex");
3291
3318
  const applyInvalidateIdentity = (principal) => {
3292
3319
  const held = identity.invalidate(principal);
3293
3320
  reset(principal);
3294
3321
  return held;
3295
3322
  };
3296
- const applyInvalidateTag = (tag) => identity.invalidateTag(tag).length;
3323
+ const applyInvalidateTag = (tag) => {
3324
+ const forgotten = identity.invalidateTag(tag).length;
3325
+ adoptAll2();
3326
+ return forgotten;
3327
+ };
3297
3328
  const applyNudge = (principal, channel) => {
3298
3329
  deliver(principal, channel);
3299
3330
  };
@@ -3376,7 +3407,7 @@ var wireFabric = (fabric, origin, apply) => {
3376
3407
 
3377
3408
  // src/server/server.ts
3378
3409
  var createServerWith = async (app, runtime, dataOf) => {
3379
- chunk3DCTQKPQ_cjs.receiveManifest(app);
3410
+ chunkE6YAYR7G_cjs.receiveManifest(app);
3380
3411
  const session = sessionVerifierOf(runtime);
3381
3412
  const revokeSessions = sessionRevokerOf(runtime);
3382
3413
  const data = await dataOf(app, runtime);
@@ -3435,7 +3466,7 @@ var assemble = async ({ app, runtime, session, revokeSessions, data }, stops) =>
3435
3466
  mountRoutes(server, { app, session, credentials: registered.credentials, identity, running, data });
3436
3467
  const hosts = buildShellHosts({ app, runtime, identity, running, data, savedAs: saved.of, wire: createInternalWire(server), wrapWire: composeWireWraps(registered), revokeSessions });
3437
3468
  stops.push(hosts.stop);
3438
- const signals = buildSignals({ fabric: runtime.fabric, identity, reset: hosts.reset, adopt: hosts.adoptFor, deliver: hosts.deliver });
3469
+ const signals = buildSignals({ fabric: runtime.fabric, identity, reset: hosts.reset, adopt: hosts.adoptFor, adoptAll: hosts.adopt, deliver: hosts.deliver });
3439
3470
  running.onChange(() => {
3440
3471
  identity.invalidateAll();
3441
3472
  hosts.adopt();
@@ -3562,5 +3593,6 @@ exports.mintSession = mintSession;
3562
3593
  exports.renderDocument = renderDocument;
3563
3594
  exports.revokeAllFor = revokeAllFor;
3564
3595
  exports.sessionCookies = sessionCookies;
3565
- //# sourceMappingURL=chunk-TMDKNZYL.cjs.map
3566
- //# sourceMappingURL=chunk-TMDKNZYL.cjs.map
3596
+ exports.tableStatus = tableStatus;
3597
+ //# sourceMappingURL=chunk-L2GHVTJW.cjs.map
3598
+ //# sourceMappingURL=chunk-L2GHVTJW.cjs.map