@amalgm/shell 0.1.96 → 0.1.98

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.
@@ -289,6 +289,19 @@ export class UserGroundHost {
289
289
  destinationParent: input.destinationParent,
290
290
  cloudHead: input.cloudHead,
291
291
  readContent: (artifact) => this.downloadContent(privateEntityResourceId(identity.userId, sha256Hex), this.cacheDir(identity), artifact, 10, { journey: "add", workspaceId: input.workspace.uuid }),
292
+ adoptMaterialization: (rootUUID) => {
293
+ const settled = this.applyHost?.adoptVerifiedMaterialization(rootUUID) ?? 0;
294
+ this.applyRail?.recordsAvailable();
295
+ if (settled > 0) {
296
+ this.stage({
297
+ primitive: "apply",
298
+ stage: "materialization-baseline",
299
+ status: "completed",
300
+ workspaceId: rootUUID,
301
+ measurements: { settledRecords: settled },
302
+ });
303
+ }
304
+ },
292
305
  onStage: async (stage) => {
293
306
  const now = performance.now();
294
307
  this.stage({
@@ -402,6 +415,10 @@ export class UserGroundHost {
402
415
  destinationParent: dirname(intent.destinationPath),
403
416
  cloudHead: intent.cloudHead,
404
417
  readContent: (artifact) => this.downloadContent(intent.resourceId, this.cacheDir(identity), artifact, 10, { journey: "add", workspaceId: intent.workspaceId }),
418
+ adoptMaterialization: (rootUUID) => {
419
+ this.applyHost?.adoptVerifiedMaterialization(rootUUID);
420
+ this.applyRail?.recordsAvailable();
421
+ },
405
422
  onStage: (stage) => this.options.onWorkspaceAddStage?.({
406
423
  workspaceId: intent.workspaceId,
407
424
  stage,
@@ -806,6 +823,15 @@ export class UserGroundHost {
806
823
  },
807
824
  now: () => this.options.now?.().getTime() ?? Date.now(),
808
825
  });
826
+ const settledMaterialization = host.adoptVerifiedMaterialization();
827
+ if (settledMaterialization > 0) {
828
+ this.stage({
829
+ primitive: "apply",
830
+ stage: "materialization-baseline",
831
+ status: "completed",
832
+ measurements: { settledRecords: settledMaterialization },
833
+ });
834
+ }
809
835
  const rail = new EntityApplyRail({
810
836
  store: host.store,
811
837
  effects: host.effects,
@@ -2088,6 +2114,8 @@ function initializeDatabase(file) {
2088
2114
  ON detection_notebook(device_number, inode);
2089
2115
  CREATE INDEX IF NOT EXISTS record_outbox_pending
2090
2116
  ON record_outbox(status, local_sequence);
2117
+ CREATE INDEX IF NOT EXISTS record_outbox_pending_entity
2118
+ ON record_outbox(status, entity_id, local_sequence);
2091
2119
  `);
2092
2120
  const inboxColumns = new Set(database.prepare("PRAGMA table_info(record_inbox)").all().map(({ name }) => name));
2093
2121
  if (!inboxColumns.has("resolved_at")) {
@@ -4640,6 +4668,7 @@ async function installCloudWorkspace(input) {
4640
4668
  }));
4641
4669
  await onStage?.("materialization-verified");
4642
4670
  persistRows(database, identity, intent.resourceId, intent.workspaceId, rows);
4671
+ input.adoptMaterialization(intent.workspaceId);
4643
4672
  await onStage?.("rows-committed");
4644
4673
  renameSync(intent.stagingPath, intent.destinationPath);
4645
4674
  refreshRevealedRootEvidence(database, intent.workspaceId, intent.destinationPath);