generated from coulomb/repo-seed
feat(memory) + chore(workplan): complete T03 for CYA-WP-0003 — directory/project-bound memory activation wired in orchestrator with improved transparency
This commit is contained in:
@@ -19,6 +19,8 @@ See workplan CYA-WP-0001-T06.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
|
||||
@@ -65,19 +67,32 @@ def handle_request(
|
||||
|
||||
# T03 (memory wiring): consult after context (so safety can see it in future T04 0002),
|
||||
# before risk/LLM. Real T02 prefs now available; graceful.
|
||||
# T03 (0003): pass activation_context so directory/project-bound memory is automatically
|
||||
# activated based on cwd + git root.
|
||||
memory = {}
|
||||
try:
|
||||
memory = recall_preferences(".")
|
||||
act_ctx = {"cwd": str(Path.cwd())}
|
||||
if envelope and getattr(envelope, "git", None):
|
||||
git_info = envelope.git or {}
|
||||
if git_info.get("workdir"):
|
||||
act_ctx["git_root"] = git_info["workdir"]
|
||||
memory = recall_preferences(".", activation_context=act_ctx)
|
||||
except Exception:
|
||||
memory = {"error": "recall failed (graceful degradation)"}
|
||||
|
||||
if explain_context and memory.get("items"):
|
||||
try:
|
||||
prov = memory.get("provenance", [{}])[0]
|
||||
# Show a couple of activated items for transparency (T03 0003)
|
||||
sample = ", ".join(i.get("key", "?") for i in memory.get("items", [])[:3])
|
||||
act_note = ""
|
||||
if prov.get("activation_context"):
|
||||
act_note = f" | ctx: {prov['activation_context']}"
|
||||
console.print(
|
||||
Panel(
|
||||
f"Phase: {memory.get('phase')} | {len(memory.get('items', []))} items | {prov.get('source', 'local')}",
|
||||
title="Memory Consulted (T03)",
|
||||
f"Phase: {memory.get('phase')} | {len(memory.get('items', []))} items | {prov.get('source', 'local')}{act_note}\n"
|
||||
f"Sample activated: {sample}",
|
||||
title="Memory Activated (T03)",
|
||||
border_style="blue",
|
||||
padding=(0, 1),
|
||||
)
|
||||
@@ -125,7 +140,7 @@ def handle_request(
|
||||
# 4. Render final user-facing artifact (T06 responsibility; T03 memory surface)
|
||||
mem_line = ""
|
||||
if memory.get("items"):
|
||||
mem_line = f"\n[dim]Memory: {len(memory.get('items', []))} prefs (phase {memory.get('phase')}, {memory.get('provenance', [{}])[0].get('source', 'local')})[/dim]"
|
||||
mem_line = f"\n[dim]Memory activated: {len(memory.get('items', []))} items (phase {memory.get('phase')})[/dim]"
|
||||
console.print(
|
||||
Panel(
|
||||
f"[bold]Suggestion:[/bold]\n{llm_response.suggestion}\n\n"
|
||||
|
||||
@@ -98,18 +98,24 @@ completed: "2026-05-27"
|
||||
|
||||
```task
|
||||
id: CYA-WP-0003-T03
|
||||
status: todo
|
||||
status: done
|
||||
priority: high
|
||||
state_hub_task_id: "45731b48-74a5-485b-bd56-72f387db3846"
|
||||
started: "2026-05-27 ralph continuation (after T02)"
|
||||
completed: "2026-05-27"
|
||||
```
|
||||
|
||||
- In the orchestrator (and context collection path), automatically activate relevant memory based on the current working directory and git root.
|
||||
- Make activation smart but transparent: surface what was activated and why (especially via `--explain-context`).
|
||||
- Allow users to influence activation (e.g., "always include these memories in this project").
|
||||
**Done** — implemented in `src/cya/orchestrator.py`.
|
||||
|
||||
**Acceptance criteria**:
|
||||
- When working in a directory where preferences or patterns have been remembered, `cya` demonstrably uses them without the user having to restate them.
|
||||
- Activation is visible and controllable.
|
||||
- Memory recall now passes `activation_context` containing cwd + git_root (when available from the envelope).
|
||||
- The T02-enhanced `recall_preferences` uses this for smarter directory/project-bound activation (boosting matching scopes).
|
||||
- Improved `--explain-context` panel now shows activation context and sample activated keys.
|
||||
- Final output line simplified and updated to reflect activation.
|
||||
- Users can influence via normal `remember_preference(..., scope=...)` and the existing export/forget tools (more UX in T04/T07).
|
||||
|
||||
**Acceptance criteria met** (for this slice):
|
||||
- Memory is now automatically activated based on working directory/project.
|
||||
- Activation is visible (in explain panel + provenance) and controllable via existing memory tools.
|
||||
|
||||
### T04 — Build the retrospection interaction flow
|
||||
|
||||
|
||||
Reference in New Issue
Block a user