instar 1.3.522 → 1.3.523

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAS3D,OAAO,EAAE,eAAe,EAAiC,MAAM,iCAAiC,CAAC;AAuBjG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AA8G7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAsBtD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,OAAO,CAUT;AAyID,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAm1CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,WAAW,CAAC,EAAE,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,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AE,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACpD,IAAI,CA8eN;AA2lBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAm5ZtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -87,6 +87,7 @@ import { wireRegistrySync } from '../core/wireRegistrySync.js';
87
87
  import { assertSeamlessnessInvariants } from '../core/seamlessnessConfig.js';
88
88
  import { assertStateSyncInvariants } from '../core/stateSyncConfig.js';
89
89
  import { ReplicatedKindRegistry, checkPoolFlagCoherence } from '../core/ReplicatedRecordEnvelope.js';
90
+ import { SnapshotCache, SnapshotRebuildBreaker, StoreSnapshotEngine } from '../core/StoreSnapshot.js';
90
91
  import { FencedLease } from '../core/FencedLease.js';
91
92
  import { GitLeaseStore } from '../core/GitLeaseStore.js';
92
93
  import { LocalLeaseStore } from '../core/LocalLeaseStore.js';
@@ -3293,6 +3294,35 @@ export async function startServer(options) {
3293
3294
  // registry the advert is `{}` (non-participant for every store): the correct
3294
3295
  // single-machine / no-store-yet behavior (a strict no-op).
3295
3296
  const replicatedKindRegistry = new ReplicatedKindRegistry();
3297
+ // Snapshot-then-tail engine (Component 4 / build-order step 3,
3298
+ // multi-machine-replicated-store-foundation §6). The cache (FIXED ceiling,
3299
+ // §8.2 — NOT pool-scaled), the per-peer rebuild breaker (§6.3), and the engine
3300
+ // are constructed here so the substrate is WIRED + dependency-injectable from
3301
+ // the first PR (machinery presence, testable — never a null/no-op). With the
3302
+ // registry EMPTY (no concrete store yet) the engine has no contributing kinds
3303
+ // to load, so a snapshot request finds no entries and the holder declines —
3304
+ // the correct single-machine / no-store-yet behavior (a strict no-op). The
3305
+ // heavy whole-store materialization runs OFF the event loop in
3306
+ // storeSnapshotBuild.worker.js (instar#1069). The first concrete store (WS2.1)
3307
+ // supplies the own-entry loader for its kind(s) onto this same engine.
3308
+ const snapshotCache = new SnapshotCache({
3309
+ maxCachedSnapshots: stateSync.maxCachedSnapshots,
3310
+ maxCacheBytes: stateSync.maxCacheBytes,
3311
+ });
3312
+ const snapshotRebuildBreaker = new SnapshotRebuildBreaker({ now: () => Date.now() });
3313
+ const storeSnapshotEngine = new StoreSnapshotEngine({
3314
+ cache: snapshotCache,
3315
+ breaker: snapshotRebuildBreaker,
3316
+ seams: {
3317
+ // Step-3 substrate: no concrete store kind is registered yet, so there are
3318
+ // no contributing own-streams to load. A consumer PR (WS2.1) replaces this
3319
+ // with a loader that reads the CoherenceJournal own streams for its kind(s).
3320
+ loadOwnEntries: () => ({}),
3321
+ now: () => Date.now(),
3322
+ },
3323
+ maxSnapshotBytes: stateSync.maxCacheBytes,
3324
+ });
3325
+ void storeSnapshotEngine; // consumed by the state-snapshot mesh handler below + the store PRs (WS2.1+)
3296
3326
  const selfStateSyncReceive = () => {
3297
3327
  const out = {};
3298
3328
  const stores = config.multiMachine?.stateSync;
@@ -13047,6 +13077,32 @@ export async function startServer(options) {
13047
13077
  syncPageBytes: wsCfgP?.syncPageBytes,
13048
13078
  });
13049
13079
  },
13080
+ // Single-origin store-snapshot pull (multi-machine-replicated-store-
13081
+ // foundation §6.1/§6.3). The HOLDER serves a single-origin snapshot of
13082
+ // a store it AUTHORED — origin === THIS machine (the authenticated
13083
+ // recipient), so the §6.1 anti-forgery invariant holds end-to-end. The
13084
+ // build runs OFF the event loop in a worker (instar#1069); a flapping
13085
+ // peer is served the cached snapshot (breaker-gated, §6.3). In the
13086
+ // Step-3 substrate the registry is EMPTY, so loadOwnEntries returns no
13087
+ // contributing kinds and serveSnapshot answers 'no-entries' — the
13088
+ // holder declines and the caller falls back to a from-genesis tail
13089
+ // (the legacy behavior). A consumer PR (WS2.1) supplies the own-entry
13090
+ // loader for its kind(s), at which point this same handler serves real
13091
+ // data. `sender` is the recovering peer (for the breaker key); the
13092
+ // origin served is ALWAYS this machine (meshSelfId), never a value the
13093
+ // peer supplies — single-origin is structural, not trusted.
13094
+ 'state-snapshot': async (cmd, sender) => {
13095
+ const c = cmd;
13096
+ const store = c.request?.store;
13097
+ if (typeof store !== 'string' || !store)
13098
+ return { ok: false, reason: 'store required' };
13099
+ // Single-origin: we only ever serve OUR OWN authored records, so the
13100
+ // origin is this machine — never a peer-supplied field.
13101
+ const result = await storeSnapshotEngine.serveSnapshot(sender, meshSelfId, store);
13102
+ if (!result.ok)
13103
+ return { ok: false, reason: result.reason };
13104
+ return { ok: true, snapshot: result.snapshot, source: result.source, truncated: result.truncated };
13105
+ },
13050
13106
  place: ownAction,
13051
13107
  claim: ownAction,
13052
13108
  transfer: ownAction,