Skip to main content

Module compress

Module compress 

Source
Expand description

Deterministic-concatenate compression for Phase 4.D decay jobs.

Given N candidate-tier memories (or N episode summaries), produce ONE summary memory whose:

  • claim is a deterministic concatenation + truncation of the sources’ claims (separator super::DECAY_SUMMARY_CLAIM_SEPARATOR, truncation at super::DECAY_SUMMARY_MAX_CLAIM_BYTES with suffix super::DECAY_SUMMARY_TRUNCATION_SUFFIX).
  • confidence = min(source.confidence) — pessimistic.
  • authority = lowest-trust authority across sources. The trust order is the AuthorityTier::trust_rank ladder; compression CANNOT launder authority upward.
  • source_episodes_json / source_events_json = deduplicated union of the sources’ provenance arrays.
  • domains_json = deduplicated union of the sources’ domain tags.
  • created_at / updated_at = Utc::now().
  • memory_type = "summary" (so downstream readers can distinguish a compressed-from-many memory from a primary candidate).
  • status = "candidate" (the compressed summary is candidate-tier evidence; the standard acceptance ceremony still applies).

The source memories / episodes are NOT deleted; the memory_supersessions / episode_supersessions join tables landed by migration 009_decay_supersessions record the “this summary was produced by compressing X, Y, Z” edge.

§Determinism contract

Same inputs (source rows, source-id order) MUST produce a summary memory whose claim, confidence, authority, and provenance arrays are byte-stable across runs. The only non-deterministic field is the summary memory’s id (ULID) and its created_at / updated_at timestamps. The runner (super::runner) and the compressor are intentionally separate so this determinism stays inspectable from the call site.

Enums§

AuthorityTier
Trust-tier ranking used to fold an authority label across N sources.

Functions§

compress_candidate_memories
Compress N candidate-tier memories into one summary memory and persist the produced summary as a candidate row.
compress_candidate_memories_with_job
Same as compress_candidate_memories but attaches the produced supersession edges to a specific decay job (so the runner can write the audit trail under the job’s id).
compress_episodes
Compress N episode summaries into one summary memory and persist the produced summary as a candidate row.
compress_episodes_with_job
Same as compress_episodes but attaches the produced supersession edges to a specific decay job.