Skip to content
Sign in

memory-consolidate

v0.2.13

Scheduled hygiene for the memory worker: deterministic dedup of near-duplicate memories and an opt-in verify tier that checks notes against their source transcript; every write goes through memory's supersede and correct seams, pinned untouchable. Install, stop, or remove it without touching stored memory.

license: Apache-2.0cleanupdeduplicationmaintenancememoryschedule

Install

bash
iii call compose::add worker=memory-consolidate@0.2.13

Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.

Functions6

memory-consolidate::alias-undo

Function

Undo an entity-handle alias merge: every memory the merge retagged that is live, unpinned, still carries the canonical handle and does not already carry `from` gets it back through memory::update, and the pair is recorded as distinct so no pass merges it again.

Request
  • bankstringrequired

    Bank of the merge.

  • fromstringrequired

    The handle the merge retagged away.

Response
  • bankstringrequired
  • fromstringrequired
  • restoredstring[]required

    Memories given `from` back.

  • skippedstring[]required

    Recorded memories left alone: gone, retired, pinned, no longer carrying `to`, already carrying `from`, or carrying more than eight handles.

  • tostringrequired

    The handle the merge had retagged to.

memory-consolidate::on-config-change

Function

Internal: hot-reload memory-consolidate from the authoritative configuration when it changes.

Request
  • idstring
Response
  • okbooleanrequired

memory-consolidate::on-tick

Function

Internal: schedule heartbeat (observer of cron::on-tick + boot catch-up backstop). Runs a pass only when interval_hours have elapsed since the last one.

Request
  • actual_timestring
  • expressionstring
  • scheduled_timestring
Response
  • ranbooleanrequired

    A pass actually ran (false = not due yet or disabled).

memory-consolidate::rest

Function

Internal: target of the memory-consolidate REST routes, the http::on-request observers with args { method: POST, path: /memory-consolidate/run | /memory-consolidate/status | /memory-consolidate/alias-undo }. Receives the HttpRequest, runs the function the route's path names with the request's JSON body, and returns the HttpResponse { status_code, body }: 200 with the function's result, or 400/404/500 with { error }.

Request
  • bodyunknown

    The request body parsed as JSON; `null` when it is empty or not JSON.

  • pathstringrequired

    The matched route's path: `/memory-consolidate/run`, `/memory-consolidate/status` or `/memory-consolidate/alias-undo`.

Response
  • bodyunknownrequired
  • status_codeinteger· uint16requiredmin 0

memory-consolidate::run

Function

Run one consolidation pass now (all configured banks, or one bank). Deterministic near-duplicate dedup, entity-handle alias merge (a spelling variant retagged through memory::update, a near spelling only once a judge confirms it), plus the optional LLM tiers when enabled (reorder judge; semantic merge/supersede of new memories, each with a reason; promotion of a decision written with a ticket key, rewritten without the key, which moves to its entities; verify of notes against their source transcript, replacing a contradicted one), applied strictly through memory::supersede, memory::update and memory::correct; pinned memories are untouchable. dry_run plans without writing.

Request
  • bankstring

    Consolidate only this bank (must be in the configured allowlist, when one is set).

  • dry_runboolean

    Override the configured dry_run for this call.

Response
  • banksobject[]required
    • aliasesobject[]

      Entity-handle alias pairs: merged (memories retagged through `memory::update`, each spending the per-run supersede cap), judged distinct, waiting for the judge, or ambiguous. A dry run lists what it would merge, `applied: false`.

      • appliedbooleanrequired

        Memories were retagged this pass (never on a dry run).

      • fromstringrequired

        The handle retagged away.

      • idsstring[]

        Memories retagged; on a dry run, the ones that would be.

      • reasonstringrequired

        The rule, the judge's reason, or what the pair waits for.

      • similaritynumber· doublerequired

        pg_trgm similarity of the two handles.

      • skipped_pinnedstring[]

        Memories left alone because they are pinned.

      • tierone ofrequired
        Show 2 nested
        one of (2)
        Variant 1
        valuestringenum spelling
        Variant 2
        valuestringenum near
      • tostringrequired

        The canonical handle: on more live memories, then the older, then the smaller string.

    • bankstringrequired
    • cappedinteger· uintmin 0

      Work left behind by the per-run cap; the next pass picks it up.

    • correctedinteger· uintmin 0

      Notes the verify tier replaced through `memory::correct` (each one also spends the per-run supersede cap; not counted in `superseded`).

    • decisions_promotedinteger· uintmin 0

      Durable lines the promote tier rewrote without their ticket key through `memory::correct`, the key kept as an entity (each also spends the per-run supersede cap; not counted in `superseded`).

    • decisions_refusedinteger· uintmin 0

      Promote-tier rewrites the check refused (more dropped than the ticket keys and the connector words next to them); never written.

    • errorsstring[]

      Real failures (reads, writes). Any error keeps the pass due.

    • groupsobject[]required
      • loser_idsstring[]required
      • loser_textsstring[]required

        Texts of the losers, aligned with `loser_ids` (the judge tier and human review need the words, not just ids).

      • report_onlyboolean

        True = surfaced for review only (token-set match: same words, different order — potentially different meaning). Never written automatically.

      • skipped_pinnedstring[]

        Losers left alone because they are pinned (pinned is untouchable).

      • winner_idstringrequired
      • winner_textstringrequired
    • llm_callsinteger· uintmin 0

      Model call attempts by the judge, alias, semantic, promote and verify tiers, failed ones included.

    • llm_cost_usdnumber· double

      The router's cost in USD, summed over the calls the router priced; absent when none.

    • llm_input_tokensinteger· uintmin 0

      Prompt tokens the router reported, cached ones included.

    • llm_mergedinteger· uintmin 0

      Reorder groups merged after the LLM judge confirmed equivalence.

    • llm_output_tokensinteger· uintmin 0

      Output tokens the router reported.

    • notesstring[]

      Soft skips (an optional tier unavailable, a sibling too old) — telemetry only: they never block the checkpoint, so an absent router cannot re-run the whole pass on every heartbeat.

    • promotedinteger· uintmin 0

      Standing-instruction lines the judge promoted into the bank's `learned` rule.

    • reinforcedinteger· uintrequiredmin 0

      Winner reinforcements applied (one per absorbed duplicate).

    • scannedinteger· uintrequiredmin 0

      Live memories scanned.

    • semanticobject[]

      Applied semantic-tier decisions, each with the judge's reason (the tier never runs on dry runs).

      • keep_idstringrequired

        Merge survivor / supersede replacement.

      • keep_textstringrequired
      • kindstringrequiredenum merge, supersede
      • reasonstringrequired
      • retire_idstringrequired

        Merge duplicate / supersede outdated record.

      • retire_textstringrequired
    • semantic_failedstring[]

      New memories the judge could not decide even alone while another reply of the pass parsed (a poison input); skipped past the cursor.

    • semantic_rejectedinteger· uintmin 0

      Judge actions dropped by validation (unknown alias, pinned target, wrong direction, a lost number, ...).

    • supersededinteger· uintrequiredmin 0

      Supersedes actually applied (0 on dry runs).

    • verifiedinteger· uintmin 0

      Notes the verify tier found supported by their source transcript.

    • verify_rejectedinteger· uintmin 0

      Verify-tier judge replies refused: a correction that failed a guard (quote, numbers, length), or a reply cut short or never parsed.

    • verify_skippedinteger· uintmin 0

      Notes the verify tier passed without a verdict or a write (no span, reinforced, session gone, record changed, ...); a note lists why.

  • checkpointedbooleanrequired

    The pass completed cleanly AND its last-run checkpoint persisted. False = the schedule will retry the pass next check.

  • dry_runbooleanrequired
  • supersededinteger· uintrequiredmin 0

    Total supersedes applied across banks this pass.

memory-consolidate::status

Function

Check the consolidation schedule and last pass: enabled, interval, last run, due, and the reports of the last 30 passes (newest first), each with per-bank results and LLM calls, tokens and cost; only the newest lists its groups, alias pairs and semantic actions.

Request
Empty object
Response
  • dry_runbooleanrequired
  • duebooleanrequired

    A scheduled pass is overdue right now.

  • enabledbooleanrequired
  • interval_hoursinteger· uint64requiredmin 0
  • last_runinteger· uint64requiredmin 0

    Milliseconds since epoch of the last completed pass; 0 = never.

  • reportsunknown[]required

    The last 30 passes, newest first: `{ ms, dry_run, banks }`. Older passes' banks leave out `groups`, `aliases` and `semantic`.

Search the registry

Find workers, kits and executables, or jump to a page.