Memory.ScopePolicy (fnord v0.9.29)

View Source

Defines long-term scope rules for memories.

This module decides whether a memory may live in a given long-term scope and whether automatic scope transitions are allowed. The indexer and consolidator both consult these rules so that scope decisions follow the same policy.

Summary

Functions

Returns true when the memory may be moved automatically from one scope to another.

Returns the allowed long-term scopes for the given title.

Returns true when the memory has enough project-specific evidence to be considered for an automatic move from global to project scope.

Returns the number of project-specific signals present across title, content, and topics.

Normalizes a long-term scope value into an atom.

Returns true when the memory is reserved from automatic scope moves.

Returns true when the title identifies a reserved long-term memory.

Returns true when the target title and scope form a valid long-term target.

Returns true when the memory is allowed to live in the target scope.

Returns :ok when the memory is allowed in the target long-term scope.

Functions

allow_automatic_move?(memory, target_scope)

@spec allow_automatic_move?(Memory.t(), Memory.scope()) :: boolean()

Returns true when the memory may be moved automatically from one scope to another.

Automatic scope moves are narrower than general scope validity. A memory may be valid in a scope without being eligible for an unattended move.

allowed_scopes_for_title(title)

@spec allowed_scopes_for_title(String.t()) :: [Memory.scope()]

Returns the allowed long-term scopes for the given title.

Reserved titles may be pinned to a single scope, while ordinary memories may live in either long-term scope.

automatic_move_candidate?(memory)

@spec automatic_move_candidate?(Memory.t()) :: boolean()

Returns true when the memory has enough project-specific evidence to be considered for an automatic move from global to project scope.

count_project_signals(memory)

@spec count_project_signals(Memory.t()) :: non_neg_integer()

Returns the number of project-specific signals present across title, content, and topics.

normalize_scope(scope)

@spec normalize_scope(String.t() | atom()) :: {:ok, Memory.scope()} | :error

Normalizes a long-term scope value into an atom.

reserved_from_automatic_move?(memory)

@spec reserved_from_automatic_move?(Memory.t()) :: boolean()

Returns true when the memory is reserved from automatic scope moves.

reserved_title?(title)

@spec reserved_title?(String.t()) :: boolean()

Returns true when the title identifies a reserved long-term memory.

valid_long_term_target?(title, scope)

@spec valid_long_term_target?(String.t(), String.t() | atom()) :: boolean()

Returns true when the target title and scope form a valid long-term target.

Non-binary titles return false.

valid_target_scope?(memory, target_scope)

@spec valid_target_scope?(Memory.t(), Memory.scope()) :: boolean()

Returns true when the memory is allowed to live in the target scope.

validate_scope(memory, scope)

@spec validate_scope(Memory.t(), String.t() | atom()) ::
  :ok | {:error, :project_scope_not_allowed} | {:error, :invalid_scope}

Returns :ok when the memory is allowed in the target long-term scope.

Returns {:error, :project_scope_not_allowed} when the memory is not allowed in the requested long-term scope and {:error, :invalid_scope} when the scope value cannot be normalized.