@mmstack/primitives 22.11.1 → 22.12.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.
@@ -5435,6 +5435,13 @@ function createConvergingApply(opt) {
5435
5435
  // below the captured seq. Side-mapped so the public sibling/checkpoint shapes stay unchanged.
5436
5436
  let ingestSeq = 0;
5437
5437
  const seqs = new Map();
5438
+ // per-origin highest HLC applied: the observation vector (survives reset — knowledge, not state)
5439
+ const applied = new Map();
5440
+ const observeApplied = (origin, hlc) => {
5441
+ const cur = applied.get(origin);
5442
+ if (!cur || compareHlc(hlc, cur) > 0)
5443
+ applied.set(origin, hlc);
5444
+ };
5438
5445
  const setSeq = (key, origin, seq) => {
5439
5446
  let sm = seqs.get(key);
5440
5447
  if (!sm)
@@ -5689,6 +5696,7 @@ function createConvergingApply(opt) {
5689
5696
  ingest: (env, o) => {
5690
5697
  const touched = new Map();
5691
5698
  const seq = ++ingestSeq;
5699
+ observeApplied(env.origin, env.hlc);
5692
5700
  for (const op of env.ops) {
5693
5701
  if (o?.frontier && compareHlc(env.hlc, o.frontier) <= 0)
5694
5702
  continue;
@@ -5776,6 +5784,7 @@ function createConvergingApply(opt) {
5776
5784
  return out;
5777
5785
  },
5778
5786
  captureFrontier: () => ({ seq: ingestSeq }),
5787
+ appliedFrontier: () => Object.fromEntries(applied),
5779
5788
  liveAt: (path) => {
5780
5789
  const reg = registers.get(keyOf$1(path));
5781
5790
  return reg ? liveOf(reg) : [];
@@ -5824,6 +5833,7 @@ function createConvergingApply(opt) {
5824
5833
  const reg = regAt(r.path);
5825
5834
  const key = keyOf$1(r.path);
5826
5835
  for (const s of r.siblings) {
5836
+ observeApplied(s.origin, s.hlc);
5827
5837
  const cur = reg.siblings.get(s.origin);
5828
5838
  if (!cur || compareHlc(s.hlc, cur.hlc) > 0) {
5829
5839
  reg.siblings.set(s.origin, s);
@@ -5831,6 +5841,7 @@ function createConvergingApply(opt) {
5831
5841
  }
5832
5842
  }
5833
5843
  for (const [o, h] of Object.entries(r.water)) {
5844
+ observeApplied(o, h); // a cited write was applied by the room this state came from
5834
5845
  const cur = reg.water.get(o);
5835
5846
  if (!cur || compareHlc(h, cur) > 0)
5836
5847
  reg.water.set(o, h);
@@ -6104,6 +6115,8 @@ function opSync(source, opt) {
6104
6115
  return conv.captureFrontier();
6105
6116
  },
6106
6117
  liveUnder: (path) => conv.liveUnder(path),
6118
+ liveAt: (path) => conv.liveAt(path),
6119
+ appliedFrontier: () => conv.appliedFrontier(),
6107
6120
  commitScope: (frontier, fn) => {
6108
6121
  log.flush(); // earlier pending writes emit against the live frontier, not this one
6109
6122
  scopeFrontier = frontier;