Enable implicit phase-memory activation on every warden command.
Load coordination memory by default via ensure_memory_context on app bootstrap and route/access flows; invalidate cache after episode writes. WARDEN_MEMORY=0 remains the opt-out. Document that warden memory activate is optional only.
This commit is contained in:
parent
04929e7981
commit
120de64bcb
6 changed files with 129 additions and 13 deletions
|
|
@ -54,6 +54,19 @@ console = Console()
|
|||
err = Console(stderr=True)
|
||||
|
||||
|
||||
@app.callback()
|
||||
def _bootstrap_memory(ctx: typer.Context) -> None:
|
||||
"""Implicitly load phase-memory for every warden command (opt-out: WARDEN_MEMORY=0)."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
return
|
||||
try:
|
||||
from warden import memory as warden_memory
|
||||
|
||||
warden_memory.ensure_memory_context(implicit=True)
|
||||
except Exception: # noqa: BLE001 — memory must never block warden commands
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -783,6 +796,12 @@ def route_find(
|
|||
limit: Annotated[int, typer.Option("--limit", help="Max matches")] = 5,
|
||||
) -> None:
|
||||
"""Rank routing scenarios by keyword overlap with the query."""
|
||||
try:
|
||||
from warden import memory as warden_memory
|
||||
|
||||
warden_memory.ensure_memory_context(need=query, implicit=True)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
catalog = _load_catalog()
|
||||
matches = catalog.find(query, include_draft=all_entries, limit=limit)
|
||||
|
||||
|
|
@ -1026,6 +1045,12 @@ def access(
|
|||
"""
|
||||
from warden.access import expand_handoff, policy_gate_status
|
||||
|
||||
try:
|
||||
from warden import memory as warden_memory
|
||||
|
||||
warden_memory.ensure_memory_context(need=need, implicit=True)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
catalog = _load_catalog()
|
||||
matches = catalog.find(need, include_draft=all_entries, limit=1)
|
||||
if not matches:
|
||||
|
|
@ -1408,14 +1433,14 @@ def memory_activate(
|
|||
] = None,
|
||||
output_json: Annotated[bool, typer.Option("--json", help="Output JSON")] = False,
|
||||
) -> None:
|
||||
"""Activate bounded coordination memory for worker, operator, or agent sessions."""
|
||||
"""Inspect or refresh coordination memory (optional — memory loads by default)."""
|
||||
from warden import memory as warden_memory
|
||||
|
||||
if not warden_memory.memory_available():
|
||||
err.print(f"[red]{warden_memory._PHASE_MEMORY_ERROR}[/red]")
|
||||
raise typer.Exit(2)
|
||||
try:
|
||||
payload = warden_memory.activate(need=need, agent=agent)
|
||||
payload = warden_memory.activate(need=need, agent=agent, implicit=False)
|
||||
except RuntimeError as e:
|
||||
err.print(f"[red]{e}[/red]")
|
||||
raise typer.Exit(2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue