From 7276e03021dc2496210b2c7f997ea0f1d814eef7 Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Sun, 14 Jun 2026 00:10:31 -0700 Subject: [PATCH] =?UTF-8?q?feat(memory):=20DPLAN-0207=20P3-P5=20=E2=80=94?= =?UTF-8?q?=20unify=20spawn=20templates=20+=20/memo,/prep=20entry=20rule;?= =?UTF-8?q?=20manager.py=20E402=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P3: birthright+builder local/observations templates to unified schema (key_learnings dict->list, session_number->number, pattern/source->note, number+date+tags, schema 3.0.0) P4: edit_gate verified list-aware via changed_entries dispatch — no code change needed P5: /memo + /prep + memo SKILL carry the unified entry rule (stamp number+date, newest-on-top, prepend, no hand-trim) Fix: manager.py E402 (import below logger) leftover from FPLAN-0273 hotfix — was blocking the .py diagnostics edit-gate Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/commands/prep.md | 12 +++++++++++- .codex/skills/memo/SKILL.md | 8 +++++++- .codex/skills/prep/SKILL.md | 4 +++- src/aipass/memory/apps/handlers/learnings/manager.py | 4 +--- .../spawn/templates/birthright/.trinity/local.json | 9 +++++---- .../templates/birthright/.trinity/observations.json | 7 ++++--- .../spawn/templates/builder/.trinity/local.json | 9 +++++---- .../templates/builder/.trinity/observations.json | 7 ++++--- 8 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.claude/commands/prep.md b/.claude/commands/prep.md index 7659df03..c165fbdc 100644 --- a/.claude/commands/prep.md +++ b/.claude/commands/prep.md @@ -14,9 +14,19 @@ Purpose: Button up everything at the end of a session — or before a /compact. Each memory file plays a distinct role. Update based on what actually changed this session. - **`.trinity/passport.json`** — IDENTITY. Who you are: role, capabilities, principles. Only update if identity genuinely evolved this session. -- **`.trinity/local.json`** — YOUR MEMORY. Add/update session entry with a summary of work done. Add key_learnings for anything learned. Update todos[] with current in-flight items. Trim oldest sessions if over 20. +- **`.trinity/local.json`** — YOUR MEMORY. Add/update session entry with a summary of work done. Add key_learnings for anything learned. Update todos[] with current in-flight items. - **`.trinity/observations.json`** — YOUR MEMORY OF THE USER. Collaboration insights, preferences, friction points. Skip if nothing new about the user this session. +### Entry shape — one rule for all four types + +`key_learnings`, `sessions`, `todos` (local.json) and `observations` (observations.json) all share ONE shape: a **list of objects, newest at the top (index 0)**. Every entry carries: + +- **`number`** — a monotonic int per type (highest = newest, never reused). New entry's number = current max for that type **+ 1**. +- **`date`** — ISO date/datetime. +- Plus its text field + extras: key_learnings `{number, date, key, value}` · sessions `{number, date, summary, status, tags}` · todos `{number, date, task, priority, status}` · observations `{number, date, note, tags}`. + +**When adding:** stamp `number` + `date`, then **prepend** (newest on top). **Don't hand-trim** — rollover archives the oldest *by number* to @memory automatically. + ## 2. Active Plans - Check any DPLANs or FPLANs referenced in this session diff --git a/.codex/skills/memo/SKILL.md b/.codex/skills/memo/SKILL.md index d79589bc..95135647 100644 --- a/.codex/skills/memo/SKILL.md +++ b/.codex/skills/memo/SKILL.md @@ -18,9 +18,15 @@ Purpose: Update branch memory files after completing work this session. ### Always -- **.trinity/local.json** — Add new session entry to `sessions` if significant work was done. Add new `key_learnings` for facts you'd need next time. Trim oldest sessions if over 20. +- **.trinity/local.json** — Add new session entry to `sessions` if significant work was done. Add new `key_learnings` for facts you'd need next time. - **.trinity/observations.json** — Add notable collaboration insights: breakthrough moments, pattern corrections, flow states, friction points, preference discoveries. Skip if nothing notable this session. +### Entry shape — one rule for all four types + +`key_learnings`, `sessions`, `todos` (local.json) and `observations` (observations.json) all share ONE shape: a **list of objects, newest at the top (index 0)**. Every entry carries a **`number`** (monotonic int per type — highest = newest, never reused; new = current max + 1) and a **`date`** (ISO), plus its text field + extras: key_learnings `{number, date, key, value}` · sessions `{number, date, summary, status, tags}` · todos `{number, date, task, priority, status}` · observations `{number, date, note, tags}`. + +**When adding:** stamp `number` + `date`, then **prepend** (newest on top). **Don't hand-trim** — rollover archives the oldest *by number* to @memory automatically. + ### If Relevant - **.trinity/passport.json** — Evolve identity when the branch's role, capabilities, or principles have genuinely changed. Don't update just to update — but don't leave placeholders forever either. diff --git a/.codex/skills/prep/SKILL.md b/.codex/skills/prep/SKILL.md index 86d73b93..d18832c4 100644 --- a/.codex/skills/prep/SKILL.md +++ b/.codex/skills/prep/SKILL.md @@ -14,10 +14,12 @@ Purpose: Button up everything at the end of a session — or before a /compact. ## 1. Memories -- **.trinity/local.json** — Add/update session entry with summary of work done. Add new key_learnings for anything learned this session. Trim oldest sessions if over 20. +- **.trinity/local.json** — Add/update session entry with summary of work done. Add new key_learnings for anything learned this session. - **.trinity/observations.json** — Add collaboration insights if anything notable happened. Skip if nothing new. - **.trinity/passport.json** — Only update if role/purpose/principles genuinely changed this session. +**Entry shape — one rule for all four types:** `key_learnings`, `sessions`, `todos` (local.json) and `observations` (observations.json) are all **lists, newest at top (index 0)**. Every entry carries a **`number`** (monotonic int per type — highest = newest, never reused; new = current max + 1) and a **`date`** (ISO), plus its text field + extras: key_learnings `{number, date, key, value}` · sessions `{number, date, summary, status, tags}` · todos `{number, date, task, priority, status}` · observations `{number, date, note, tags}`. Stamp `number` + `date` and **prepend**; **don't hand-trim** — rollover archives the oldest *by number* automatically. + ## 2. Active Plans - Check any DPLANs or FPLANs referenced in this session diff --git a/src/aipass/memory/apps/handlers/learnings/manager.py b/src/aipass/memory/apps/handlers/learnings/manager.py index 62824ae3..d7cfa037 100644 --- a/src/aipass/memory/apps/handlers/learnings/manager.py +++ b/src/aipass/memory/apps/handlers/learnings/manager.py @@ -35,12 +35,10 @@ from datetime import datetime from aipass.prax.apps.modules.logger import get_system_logger from aipass.memory.apps.handlers.json import json_handler +from aipass.memory.apps.handlers.json.memory_files import read_memory_file_data, write_memory_file_simple logger = get_system_logger() -# Handler imports (relative within package) -from aipass.memory.apps.handlers.json.memory_files import read_memory_file_data, write_memory_file_simple - # ChromaDB subprocess for vectorization (resolved relative to handler location) _MEMORY_ROOT = Path(__file__).resolve().parents[3] CHROMA_SUBPROCESS_SCRIPT = _MEMORY_ROOT / "apps" / "handlers" / "storage" / "chroma_subprocess.py" diff --git a/src/aipass/spawn/templates/birthright/.trinity/local.json b/src/aipass/spawn/templates/birthright/.trinity/local.json index 75f4538d..0516179f 100644 --- a/src/aipass/spawn/templates/birthright/.trinity/local.json +++ b/src/aipass/spawn/templates/birthright/.trinity/local.json @@ -3,7 +3,7 @@ "document_type": "session_history", "document_name": "{{BRANCHNAME}}.LOCAL", "version": "2.0.0", - "schema_version": "2.0.0", + "schema_version": "3.0.0", "created": "{{DATE}}", "last_updated": "{{DATE}}", "managed_by": "{{BRANCHNAME}}", @@ -25,13 +25,14 @@ "current_lines": 0 } }, - "key_learnings": {}, + "key_learnings": [], "sessions": [ { - "session_number": 1, + "number": 1, "date": "{{DATE}}", "summary": "Branch initialized - {{BRANCHNAME}} created by aipass init.", - "status": "completed" + "status": "completed", + "tags": [] } ] } diff --git a/src/aipass/spawn/templates/birthright/.trinity/observations.json b/src/aipass/spawn/templates/birthright/.trinity/observations.json index 15d36d99..bfb8d873 100644 --- a/src/aipass/spawn/templates/birthright/.trinity/observations.json +++ b/src/aipass/spawn/templates/birthright/.trinity/observations.json @@ -3,7 +3,7 @@ "document_type": "collaboration_patterns", "document_name": "{{BRANCHNAME}}.OBSERVATIONS", "version": "1.0.0", - "schema_version": "1.0.0", + "schema_version": "3.0.0", "created": "{{DATE}}", "last_updated": "{{DATE}}", "managed_by": "{{BRANCHNAME}}", @@ -28,9 +28,10 @@ }, "observations": [ { + "number": 1, "date": "{{DATE}}", - "pattern": "Branch initialized. Ready to begin capturing collaboration patterns.", - "source": "initialization" + "note": "Branch initialized. Ready to begin capturing collaboration patterns.", + "tags": [] } ] } diff --git a/src/aipass/spawn/templates/builder/.trinity/local.json b/src/aipass/spawn/templates/builder/.trinity/local.json index e7dcb27c..cd360921 100644 --- a/src/aipass/spawn/templates/builder/.trinity/local.json +++ b/src/aipass/spawn/templates/builder/.trinity/local.json @@ -3,7 +3,7 @@ "document_type": "session_history", "document_name": "{{BRANCHNAME}}.LOCAL", "version": "2.0.0", - "schema_version": "2.0.0", + "schema_version": "3.0.0", "created": "{{DATE}}", "last_updated": "{{DATE}}", "managed_by": "{{BRANCHNAME}}", @@ -28,13 +28,14 @@ } }, "todos": [], - "key_learnings": {}, + "key_learnings": [], "sessions": [ { - "session_number": 1, + "number": 1, "date": "{{DATE}}", "summary": "Branch initialized - {{BRANCHNAME}} created by aipass init.", - "status": "completed" + "status": "completed", + "tags": [] } ] } \ No newline at end of file diff --git a/src/aipass/spawn/templates/builder/.trinity/observations.json b/src/aipass/spawn/templates/builder/.trinity/observations.json index 15d36d99..bfb8d873 100644 --- a/src/aipass/spawn/templates/builder/.trinity/observations.json +++ b/src/aipass/spawn/templates/builder/.trinity/observations.json @@ -3,7 +3,7 @@ "document_type": "collaboration_patterns", "document_name": "{{BRANCHNAME}}.OBSERVATIONS", "version": "1.0.0", - "schema_version": "1.0.0", + "schema_version": "3.0.0", "created": "{{DATE}}", "last_updated": "{{DATE}}", "managed_by": "{{BRANCHNAME}}", @@ -28,9 +28,10 @@ }, "observations": [ { + "number": 1, "date": "{{DATE}}", - "pattern": "Branch initialized. Ready to begin capturing collaboration patterns.", - "source": "initialization" + "note": "Branch initialized. Ready to begin capturing collaboration patterns.", + "tags": [] } ] }