Skip to main content

Module decay

Module decay 

Source
Expand description

Phase 4.D decay job substrate.

Decay jobs are operator-fired scheduled tasks that compress or summarize OLD memory rows (and operator-driven re-promotion reviews of expired principle waivers). They do NOT touch the immutable, hash-chained event log: the Phase 4.D guardrail is that raw events and the hash chain remain unchanged. Compression operates one level up, on the semantic memory surface and on candidate principles whose policy waiver has expired.

Provenance is preserved: every summary memory landed by a decay job retains pointers back to its source memory ids and (transitively) the source event ids those memories already carry, via the same source_episodes_json / source_events_json fields existing memory candidates use. A summary is therefore a re-shaping of already-attested content rather than a new claim with weaker lineage.

This module owns the types (state machine, kind discriminator, summary method enum) and the conversion shims used by the persistence layer in cortex-store::repo::decay_jobs. It does NOT own:

  • The actual compression / summarization implementation (Phase 4.D D3-B).
  • The CLI surface that operators use to fire jobs (Phase 4.D D3-C).
  • Any retrieval-side rewiring (Phase 4.D2).

Downstream agents land on the types defined here. The wire forms produced by DecayJobKind::kind_wire, SummaryMethod::method_wire, and DecayJobState::state_wire are part of the persistence contract — they match the CHECK constraints in migrations/008_decay_jobs.sql.

Modules§

compress
Deterministic-concatenate compression for Phase 4.D decay jobs.
runner
Phase 4.D decay job runner.
summary
Phase 4.D LLM-summary execution path.

Structs§

DecayJob
Durable shape of a scheduled decay job.

Enums§

DecayError
Errors raised by the Phase 4.D decay path.
DecayJobConversionError
Error raised when a DecayJobRecord cannot be reassembled into a typed DecayJob. Surfaces on the persistence boundary when the store contains a row whose wire shape no longer matches the typed substrate (e.g. mid-deploy schema drift).
DecayJobKind
Kinds of decay operations the substrate currently supports.
DecayJobState
Lifecycle state of a decay job. The terminal states (Completed, Failed, Cancelled) are observable but no longer subject to scheduling.
SummaryMethod
How a compression decay job produces its summary text.

Constants§

DECAY_COMPRESS_INPUT_INVALID_INVARIANT
Stable invariant surfaced when the runner refuses to compress an empty source set or a heterogeneous (mixed memory + episode) source set.
DECAY_COMPRESS_SOURCE_MISSING_INVARIANT
Stable invariant surfaced when the runner cannot find one of the source rows named by a decay job.
DECAY_LLM_SUMMARY_ATTESTATION_PURPOSE
Purpose discriminator baked into the LLM-summary operator attestation envelope so a captured envelope cannot be replayed against the migration-attestation surface (or vice versa).
DECAY_LLM_SUMMARY_ATTESTATION_REJECTED_INVARIANT
Stable invariant surfaced by DecayError::LlmSummaryAttestationRejected.
DECAY_LLM_SUMMARY_ATTESTATION_SCHEMA_VERSION
Schema version of the operator attestation envelope accepted by the LLM-summary surface. Today it mirrors the migration-attestation envelope’s schema_version == 1; the LLM-summary purpose discriminator keeps the two domains structurally disjoint.
DECAY_LLM_SUMMARY_BACKEND_CALL_FAILED_INVARIANT
Stable invariant surfaced by DecayError::LlmSummaryBackendCallFailed. Operator scripts that grep for this token can distinguish a backend-side refusal from an attestation-shape refusal.
DECAY_LLM_SUMMARY_REQUIRES_OPERATOR_ATTESTATION_INVARIANT
Stable invariant surfaced by DecayError::LlmSummaryRequiresOperatorAttestation.
DECAY_SUMMARY_CLAIM_SEPARATOR
Separator inserted between source claims during deterministic concatenation. Stable across runs.
DECAY_SUMMARY_MAX_CLAIM_BYTES
Maximum byte length of a deterministic-concatenated summary claim before the compressor truncates with the standard ellipsis suffix. Picked to stay comfortably below SQLite’s text column / FTS5 tokeniser practical limits while remaining useful as a summary surface. Stable across runs.
DECAY_SUMMARY_TRUNCATION_SUFFIX
Suffix appended when the concatenated claim is truncated to DECAY_SUMMARY_MAX_CLAIM_BYTES.
SUMMARY_METHOD_NONE_WIRE
Sentinel wire token used in the summary_method column when the job kind does not carry a summary method (currently only ExpiredPrincipleReview).

Type Aliases§

DecayResult
Result alias for the decay module.