On this page

RiftMemorySystem๏ƒ

Receive this surface through rift.space.memory_system; use that owning object's public entry point.

Implementation source

class RiftMemorySystem(*, rift_id: str, space_type: str, step_counter: int = 0, epoch_counter: int = 0)[source]๏ƒ

Internal

Locked source of truth for RiftSpace memory sequencing and shared context.

Purpose:

Centralize the counters and shared metadata used to build immutable RiftMemory records so command/view/workstation emission can reuse one coherent memory context.

Contract:

  • Owns step_counter and epoch_counter.

  • Owns shared memory metadata including rift_id, space_type, and optional CommandOps context fields.

  • Produces immutable RiftMemory snapshots.

  • Cleanup is idempotent and clears all owned mutable state.

Registration:

MELDER KERNEL - guarded. Owned by one RiftSpace; reached through the room.

Subsystem Context:

The room's memory sequencing hub, paired with the room-local RiftEventSystem (outbound publication). Commands, views, and the workstation all emit through this one object.

System Context:

Centralizing the counters is what makes room memory COHERENT rather than merely present. step_counter and epoch_counter live in exactly one place, so records emitted from a command, a view, and the workstation share one ordering - if each emitter kept its own counter, the room's history could not be linearized and "what happened before what" would be unanswerable. Producing IMMUTABLE RiftMemory snapshots is the second half: a record that could change after emission would make the history a live view of the present rather than an account of the past. This is the system codegen rooms emit FULL-SOURCE records through, which is why the shared metadata carries rift_id, space_type, and the optional CommandOps context fields - a record has to identify where and under what posture it happened to be worth keeping.

AGENT_ACCESS: internal

AGENT_PURPOSE:

access: internal. The room's memory-sequencing hub: it owns the step/epoch counters and shared metadata and mints immutable RiftMemory records that command/view/workstation emission share. Read it to understand room memory; you receive the RiftMemory records, not this system.

cleanup() → None[source]๏ƒ

Idempotently clear memory-system state.

Returns:

None.

property rift_id: str๏ƒ

Return the owning Rift id.

property space_type: str๏ƒ

Return the owning space type.

property step_counter: int๏ƒ

Return the current step counter.

property epoch_counter: int๏ƒ

Return the current epoch counter.

property memory_enabled: bool๏ƒ

Return whether memory emission is currently enabled.

increment_step() → int[source]๏ƒ

Increment and return the step counter.

reset_step() → None[source]๏ƒ

Reset the step counter to zero.

Returns:

None.

increment_epoch(*, reset_step: bool = True) → int[source]๏ƒ

Increment the epoch counter and optionally reset step.

reset_epoch() → None[source]๏ƒ

Reset the epoch counter to zero.

Returns:

None.

update_context(*, task_name: str | None = None, activity_name: str | None = None, mission_name: str | None = None, agent_name: str | None = None, agent_id: str | None = None, metadata: Dict[str, object] | None = None) → None[source]๏ƒ

Update shared CommandOps-facing memory context.

Returns:

None.

clear_context() → None[source]๏ƒ

Clear optional CommandOps-facing context and shared metadata.

Returns:

None.

describe_state() → Dict[str, object][source]๏ƒ

Return a detached snapshot of current memory-system state.

create_memory(*, frame_name: str, action_name: str, metadata: Dict[str, object] | None = None, increment_step: bool = True) → RiftMemory[source]๏ƒ

Create one immutable Rift memory snapshot.

Parameters:
  • frame_name -- Required frame name.

  • action_name -- Required action name.

  • metadata -- Optional action-specific metadata.

  • increment_step -- When True, increments step before capturing the snapshot.

Returns:

New immutable memory record.

Return type:

RiftMemory

register_memory_callback(callback: Callable[[RiftMemory], None]) → str[source]๏ƒ

Register one callback for emitted memory records.

Parameters:

callback -- Callback invoked once per emitted memory record.

Returns:

Stable subscription id for later unregistration.

Return type:

str

Raises:

TypeError -- If callback is not callable.

unregister_memory_callback(subscription_id: str) → None[source]๏ƒ

Remove one memory callback subscription by id.

Parameters:

subscription_id -- Subscription id returned by register_memory_callback(...).

Returns:

None.

Raises:

ValueError -- If subscription_id is empty.

emit_memory(memory: RiftMemory) → None[source]๏ƒ

Emit one memory record to every registered callback.

Parameters:

memory -- Memory record to emit.

Returns:

None.

create_and_emit_memory(*, frame_name: str, action_name: str, metadata: Dict[str, object] | None = None, increment_step: bool = True) → RiftMemory[source]๏ƒ

Create one memory record and emit it immediately.

Parameters:
  • frame_name -- Required frame name.

  • action_name -- Required action name.

  • metadata -- Optional action-specific metadata.

  • increment_step -- When True, increments step before capturing the snapshot.

Returns:

Emitted immutable memory record.

Return type:

RiftMemory

Topic reference ยท Full contents