@mmstack/primitives 21.11.1 → 21.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.
@@ -5395,6 +5395,13 @@ function createConvergingApply(opt) {
5395
5395
  // below the captured seq. Side-mapped so the public sibling/checkpoint shapes stay unchanged.
5396
5396
  let ingestSeq = 0;
5397
5397
  const seqs = new Map();
5398
+ // per-origin highest HLC applied: the observation vector (survives reset — knowledge, not state)
5399
+ const applied = new Map();
5400
+ const observeApplied = (origin, hlc) => {
5401
+ const cur = applied.get(origin);
5402
+ if (!cur || compareHlc(hlc, cur) > 0)
5403
+ applied.set(origin, hlc);
5404
+ };
5398
5405
  const setSeq = (key, origin, seq) => {
5399
5406
  let sm = seqs.get(key);
5400
5407
  if (!sm)
@@ -5649,6 +5656,7 @@ function createConvergingApply(opt) {
5649
5656
  ingest: (env, o) => {
5650
5657
  const touched = new Map();
5651
5658
  const seq = ++ingestSeq;
5659
+ observeApplied(env.origin, env.hlc);
5652
5660
  for (const op of env.ops) {
5653
5661
  if (o?.frontier && compareHlc(env.hlc, o.frontier) <= 0)
5654
5662
  continue;
@@ -5736,6 +5744,7 @@ function createConvergingApply(opt) {
5736
5744
  return out;
5737
5745
  },
5738
5746
  captureFrontier: () => ({ seq: ingestSeq }),
5747
+ appliedFrontier: () => Object.fromEntries(applied),
5739
5748
  liveAt: (path) => {
5740
5749
  const reg = registers.get(keyOf$1(path));
5741
5750
  return reg ? liveOf(reg) : [];
@@ -5784,6 +5793,7 @@ function createConvergingApply(opt) {
5784
5793
  const reg = regAt(r.path);
5785
5794
  const key = keyOf$1(r.path);
5786
5795
  for (const s of r.siblings) {
5796
+ observeApplied(s.origin, s.hlc);
5787
5797
  const cur = reg.siblings.get(s.origin);
5788
5798
  if (!cur || compareHlc(s.hlc, cur.hlc) > 0) {
5789
5799
  reg.siblings.set(s.origin, s);
@@ -5791,6 +5801,7 @@ function createConvergingApply(opt) {
5791
5801
  }
5792
5802
  }
5793
5803
  for (const [o, h] of Object.entries(r.water)) {
5804
+ observeApplied(o, h); // a cited write was applied by the room this state came from
5794
5805
  const cur = reg.water.get(o);
5795
5806
  if (!cur || compareHlc(h, cur) > 0)
5796
5807
  reg.water.set(o, h);
@@ -6063,6 +6074,8 @@ function opSync(source, opt) {
6063
6074
  return conv.captureFrontier();
6064
6075
  },
6065
6076
  liveUnder: (path) => conv.liveUnder(path),
6077
+ liveAt: (path) => conv.liveAt(path),
6078
+ appliedFrontier: () => conv.appliedFrontier(),
6066
6079
  commitScope: (frontier, fn) => {
6067
6080
  log.flush(); // earlier pending writes emit against the live frontier, not this one
6068
6081
  scopeFrontier = frontier;