@mmstack/primitives 20.16.1 → 20.17.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.
@@ -5619,6 +5619,13 @@ function createConvergingApply(opt) {
5619
5619
  // below the captured seq. Side-mapped so the public sibling/checkpoint shapes stay unchanged.
5620
5620
  let ingestSeq = 0;
5621
5621
  const seqs = new Map();
5622
+ // per-origin highest HLC applied: the observation vector (survives reset — knowledge, not state)
5623
+ const applied = new Map();
5624
+ const observeApplied = (origin, hlc) => {
5625
+ const cur = applied.get(origin);
5626
+ if (!cur || compareHlc(hlc, cur) > 0)
5627
+ applied.set(origin, hlc);
5628
+ };
5622
5629
  const setSeq = (key, origin, seq) => {
5623
5630
  let sm = seqs.get(key);
5624
5631
  if (!sm)
@@ -5873,6 +5880,7 @@ function createConvergingApply(opt) {
5873
5880
  ingest: (env, o) => {
5874
5881
  const touched = new Map();
5875
5882
  const seq = ++ingestSeq;
5883
+ observeApplied(env.origin, env.hlc);
5876
5884
  for (const op of env.ops) {
5877
5885
  if (o?.frontier && compareHlc(env.hlc, o.frontier) <= 0)
5878
5886
  continue;
@@ -5960,6 +5968,7 @@ function createConvergingApply(opt) {
5960
5968
  return out;
5961
5969
  },
5962
5970
  captureFrontier: () => ({ seq: ingestSeq }),
5971
+ appliedFrontier: () => Object.fromEntries(applied),
5963
5972
  liveAt: (path) => {
5964
5973
  const reg = registers.get(keyOf$1(path));
5965
5974
  return reg ? liveOf(reg) : [];
@@ -6008,6 +6017,7 @@ function createConvergingApply(opt) {
6008
6017
  const reg = regAt(r.path);
6009
6018
  const key = keyOf$1(r.path);
6010
6019
  for (const s of r.siblings) {
6020
+ observeApplied(s.origin, s.hlc);
6011
6021
  const cur = reg.siblings.get(s.origin);
6012
6022
  if (!cur || compareHlc(s.hlc, cur.hlc) > 0) {
6013
6023
  reg.siblings.set(s.origin, s);
@@ -6015,6 +6025,7 @@ function createConvergingApply(opt) {
6015
6025
  }
6016
6026
  }
6017
6027
  for (const [o, h] of Object.entries(r.water)) {
6028
+ observeApplied(o, h); // a cited write was applied by the room this state came from
6018
6029
  const cur = reg.water.get(o);
6019
6030
  if (!cur || compareHlc(h, cur) > 0)
6020
6031
  reg.water.set(o, h);
@@ -6287,6 +6298,8 @@ function opSync(source, opt) {
6287
6298
  return conv.captureFrontier();
6288
6299
  },
6289
6300
  liveUnder: (path) => conv.liveUnder(path),
6301
+ liveAt: (path) => conv.liveAt(path),
6302
+ appliedFrontier: () => conv.appliedFrontier(),
6290
6303
  commitScope: (frontier, fn) => {
6291
6304
  log.flush(); // earlier pending writes emit against the live frontier, not this one
6292
6305
  scopeFrontier = frontier;