Skip to content
Night Brownie Night Brownie

Memory

SQLite-backed memory: action_log and memory_summary.

All reads and writes use the stdlib sqlite3 module directly — no ORM, no mocks. Tests must use a real temp-file or in-memory database.

Classes:

  • MemoryStore

    Persistent action memory backed by an SQLite database.

MemoryStore

MemoryStore(db_path: Path)

Persistent action memory backed by an SQLite database.

Creates the database file and schema on first use. The connection is kept open for the lifetime of the instance; call close (or use as a context manager) when done.

Parameters:

  • db_path (Path) –

    Filesystem path to the SQLite database file. Intermediate directories are created automatically.

Methods:

  • __enter__

    Return self for use as a context manager.

  • __exit__

    Close the connection on context exit.

  • close

    Close the database connection.

  • get_last_polled

    Return the last-polled timestamp for repo, or None if never polled.

  • get_memory_summary

    Return the stored summary for a (repo, issue_id) pair, or None.

  • log_action

    Append a decision record to action_log.

  • set_last_polled

    Persist the last-polled timestamp for repo.

  • upsert_memory_summary

    Insert or replace the memory summary for a (repo, issue_id) pair.

__enter__

__enter__() -> MemoryStore

Return self for use as a context manager.

__exit__

__exit__(*_: object) -> None

Close the connection on context exit.

close

close() -> None

Close the database connection.

get_last_polled

get_last_polled(repo: str) -> datetime | None

Return the last-polled timestamp for repo, or None if never polled.

Parameters:

  • repo (str) –

    Repository in owner/repo format.

Returns:

  • datetime | None

    The stored datetime.datetime (timezone-aware UTC), or None if no poll has been recorded for this repo.

get_memory_summary

get_memory_summary(repo: str, issue_id: int) -> str | None

Return the stored summary for a (repo, issue_id) pair, or None.

Parameters:

  • repo (str) –

    Repository in owner/repo format.

  • issue_id (int) –

    GitHub issue number.

Returns:

  • str | None

    The LLM-generated summary string, or None if absent.

log_action

log_action(repo: str, issue_id: int, task_type: str, decision: DecisionType, rationale: str | None, actions: list[ActionItem]) -> None

Append a decision record to action_log.

Parameters:

  • repo (str) –

    Repository in owner/repo format.

  • issue_id (int) –

    GitHub issue number.

  • task_type (str) –

    Task type string (e.g. issue.triage).

  • decision (DecisionType) –

    The agent's decision.

  • rationale (str | None) –

    Human-readable explanation, or None.

  • actions (list[ActionItem]) –

    Ordered list of actions the harness will execute.

set_last_polled

set_last_polled(repo: str, timestamp: datetime) -> None

Persist the last-polled timestamp for repo.

Parameters:

  • repo (str) –

    Repository in owner/repo format.

  • timestamp (datetime) –

    The datetime at which the poll completed.

upsert_memory_summary

upsert_memory_summary(repo: str, issue_id: int, summary: str) -> None

Insert or replace the memory summary for a (repo, issue_id) pair.

Parameters:

  • repo (str) –

    Repository in owner/repo format.

  • issue_id (int) –

    GitHub issue number.

  • summary (str) –

    LLM-generated summary of prior actions on this issue.