feat: async significance pass with auto-pin on score 3
This commit is contained in:
@@ -38,6 +38,35 @@ def _apply_memory_written(conn: Connection, e: Event) -> None:
|
||||
)
|
||||
|
||||
|
||||
@on("memory_significance_set")
|
||||
def _apply_memory_significance_set(conn: Connection, e: Event) -> None:
|
||||
"""Update an existing memory's significance score (T22).
|
||||
|
||||
Emitted by the async significance worker after it scores the turn.
|
||||
"""
|
||||
p = e.payload
|
||||
conn.execute(
|
||||
"UPDATE memories SET significance = ? WHERE id = ?",
|
||||
(int(p["significance"]), int(p["memory_id"])),
|
||||
)
|
||||
|
||||
|
||||
@on("memory_pin_changed")
|
||||
def _apply_memory_pin_changed(conn: Connection, e: Event) -> None:
|
||||
"""Toggle a memory's pin state (T22, §8.5).
|
||||
|
||||
Used both for auto-pinning a pivotal turn and for evicting the oldest
|
||||
auto-pin when the per-owner soft cap is exceeded. Manual pins use the
|
||||
same handler; the ``auto_pinned`` flag distinguishes them so the
|
||||
eviction query can leave manual pins alone.
|
||||
"""
|
||||
p = e.payload
|
||||
conn.execute(
|
||||
"UPDATE memories SET pinned = ?, auto_pinned = ? WHERE id = ?",
|
||||
(int(p["pinned"]), int(p["auto_pinned"]), int(p["memory_id"])),
|
||||
)
|
||||
|
||||
|
||||
def get_memory(conn: Connection, memory_id: int) -> dict | None:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM memories WHERE id = ?", (memory_id,)
|
||||
|
||||
Reference in New Issue
Block a user