CYA-WP-0005 T02 done (ralph iter 2): Formalize Profile 0 baseline everywhere

- MemoryVision.md: Large new 'Profile 0 Baseline (Post-0003 / Current Shipped)' section with exact ports, activation logic, retrospection, safety invariants, usage sites, and relationship to 1–3 (plus the prior research section from T01).
- src/cya/memory/__init__.py: Updated module docstring to declare Profile 0 reality + references to MemoryVision + CYA-WP-0005.
- src/cya/orchestrator.py: Updated docstring with Profile 0 memory wiring note.
- SCOPE.md: Named Profile 0 explicitly in delivered slices and core capabilities.
- tests/test_memory.py: Added two new explicit 'Profile 0' tests + comments asserting provenance markers, kinds, activation_context support (T02 acceptance).
- README.md + AGENTS.md: Added Profile 0 mentions + links to the workplan.

All T02 acceptance criteria met. Ralph loop active. Next: T03 (full Profiles 1–3 definitions + matrix).
This commit is contained in:
2026-05-27 20:01:51 +02:00
parent 2bcbe50607
commit 19e80cc9bc
8 changed files with 143 additions and 26 deletions

View File

@@ -133,6 +133,69 @@ See also the full research artifact and CYA-WP-0005 for acceptance criteria and
---
## Profile 0 Baseline (Post-0003 / Current Shipped)
**Status:** Shipped and stable as the production memory implementation (CYA-WP-0002 T02 real JSON + CYA-WP-0003 contextual activation + retrospection extensions). This is the explicit foundation on which Profiles 13 will be built.
**Guiding Principle (Profile 0):** Deliver real, user-controlled, contextually activated, longitudinally improving memory *today* using a high-quality local approximation, while keeping the integration seam (profile, kinds, activation_context, provenance, phase hints) completely stable and ready for eventual replacement by full phase-memory planners, graph store, and lifecycle rules. No hidden state; everything is user-inspectable and user-owned.
### Backing Store & Persistence
- Location: `~/.config/cya/memory/<scope>.json` (one file per scope, default "cwd").
- Format: Simple list of dict records. Fully human-readable and editable by the user.
- Fields per record (typical): `key`, `value`, `ts` (epoch), `scope`, `profile`, `kind`.
- User can `cat`, edit, or delete these files at any time; `cya` will respect the changes on next run.
- When full phase-memory is wired, this backing will be replaced by the durable graph/event store while preserving the exact same high-level port behavior and return shapes.
### Public API (the stable cya ↔ phase-memory seam)
All entry points live in `src/cya/memory/__init__.py`:
- **Constants** (standard kinds used by cya and `cya retrospect`):
- `KIND_PREFERENCE`
- `KIND_RETROSPECTION`
- `KIND_INTERACTION_GOAL`
- **Core functions** (signatures as of 2026-05, all support `profile` for future multi-profile use):
- `remember_preference(key, value, scope="cwd", *, profile=None, ttl=None, kind=KIND_PREFERENCE)`
- `recall_preferences(scope="cwd", task_class=None, *, kinds=None, profile=None, limit=50, activation_context=None) -> dict`
- Returns: `{"items": [...], "provenance": [...], "phase": "fluid", "profile": ..., "note": "..."}`
- `forget(scope="cwd", keys=None, *, profile=None)`
- `export_memory(scope="cwd", *, profile=None, kinds=None) -> dict` (includes `by_kind` counts, `provenance_summary`, `phases` list)
- `remember_retrospection_outcome(...)` — convenience wrapper that chooses the right kind for higher-order memory from reflection sessions.
**Activation logic (0003):** When `activation_context` (populated by the orchestrator from `ContextEnvelope` with `cwd` + git root) is supplied to `recall_preferences`, items whose `scope` or `profile` matches are boosted to the front of the result list. This makes directory/project-bound memory feel proactive without any user having to explicitly recall it.
**Retrospection as first-class input (0003):** `cya retrospect` (guided flow) produces records with special kinds that receive preferential activation in future turns. These are the seed for the self-improving loop described in the 2026-05 research.
**Guaranteed properties of every call:**
- Rich `provenance` array always present (source, count, activation_context, etc.).
- `phase` hint returned (currently always "fluid" for the local store; will become meaningful once phase-memory lifecycle is wired).
- Graceful degradation: on any error the ports log a loud warning to stderr and return safe empty/default values. Never crash the assistance path.
- All memory influence is visible via `--explain-context`.
### Safety & Explainability Invariants (non-negotiable for Profile 0 and all future profiles)
- Memory signals are **only additive** to caution. They may append rationale or force confirmation in the rule-based `RiskClassifier`, but they never downgrade a risk level or bypass mandatory explicit user confirmation for non-SAFE commands.
- Every memory-influenced response can explain exactly which items were activated, why (activation_context match, kind boost, recency, retrospection provenance), and what phase they came from.
- Users can always opt out per-request (`--no-memory` or equivalent) or globally inspect/forget via the ports + future `cya memory` subcommands.
### Usage Sites in the Current System
- `src/cya/orchestrator.py`: Calls `recall_preferences` with activation_context on every assistance request; injects results into the `ContextEnvelope` passed to the LLM; renders memory influence in `--explain-context` panels.
- `src/cya/cli/main.py` (retrospect subcommand): Uses `recall_preferences` + `remember_retrospection_outcome` to close the user-driven continuous optimization loop.
- Risk classifier: Receives memory context and applies only the "increase caution" rules.
### Relationship to Profiles 13 and phase-memory
Profile 0 is deliberately a **complete, usable, production-quality local implementation** of the seam defined in the 0002 T01 contract (refined in 0003). It already delivers the INTENT/SCOPE vision for contextual + longitudinal memory with excellent explainability and zero hidden state.
Future profiles will layer on top:
- Profile 1 adds verbal reflection storage + preferential activation (mostly a small delta on existing retrospection kinds + `cya retrospect`).
- Profile 2 adds episodic capture + synthesis passes (new kinds + calls into phase-memory reflection planners).
- Profile 3 adds procedural rules + meta-policy evolution (new tier + strong proposal/audit UX + safety guardrails).
All of them must continue to satisfy the invariants above and must continue to work against the exact same port signatures (or compatible extensions).
**See:** `history/2026-05-28-CYA-Agentic-Memory-Research-Variations.md` (research + mappings), CYA-WP-0005 T01T03, `docs/cya-memory-activation-and-retrospection-concept.md`, current `src/cya/memory/__init__.py` (the reference implementation), and the 0002 integration contract below (the original seam that Profile 0 realizes).
---
## cya ↔ phase-memory Integration Contract (CYA-WP-0002 T01)
**Date:** 2026-05-26 (ralph iter 1)