@ai-matrx/records 0.98.11 → 0.98.12

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.
@@ -13775,6 +13775,13 @@ function tableRenderSchema(facts) {
13775
13775
  function refuse4(code, message, hint) {
13776
13776
  return { ok: false, error: { code, message, hint, ours: true } };
13777
13777
  }
13778
+ function displacedSource(envelope) {
13779
+ if (envelope.src) return { src: envelope.src };
13780
+ const by = envelope.actor === "agent" ? "an agent" : envelope.actor === "system" ? "the system" : envelope.actor ? "a person" : null;
13781
+ if (by === null) return {};
13782
+ const day = typeof envelope.at === "string" && envelope.at.length >= 10 ? ` on ${envelope.at.slice(0, 10)}` : "";
13783
+ return { src: { name: `Entered by ${by}${day}` } };
13784
+ }
13778
13785
  function alternatePatch(document, field_key, alternate_index, rank) {
13779
13786
  const block = document._values ?? {};
13780
13787
  const envelope = block[field_key];
@@ -13790,7 +13797,7 @@ function alternatePatch(document, field_key, alternate_index, rank) {
13790
13797
  const taken = new Set(kept.map((a) => a.rank));
13791
13798
  let rank2 = 1;
13792
13799
  while (taken.has(rank2)) rank2 += 1;
13793
- next.push({ value: current, ...envelope.src ? { src: envelope.src } : {}, rank: rank2 });
13800
+ next.push({ value: current, ...displacedSource(envelope), rank: rank2 });
13794
13801
  }
13795
13802
  const { ver: _ver, actor: _actor, at: _at, on_behalf_of: _on, absent: _absent, alternates: _alts, src: _src, ...rest } = envelope;
13796
13803
  const changed = { ...rest, ...chosen.src ? { src: chosen.src } : {} };