You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Libra already records Intent, Task, Run, evidence, decisions, patch sets, Agent sessions, and code commits. These objects preserve the development process, but an Agent still has to traverse several records and long sessions to explain why code changed, what was attempted, and how an earlier conclusion relates to the current code version.
This issue proposes M2 development-process memory (Episode): structured summaries compiled from Libra's existing development records and linked to their source evidence and code versions.
It should help an Agent answer:
Why was this code introduced or changed?
Which requirement, attempts, and decisions led to the current implementation?
What succeeded or failed in earlier work?
Does an earlier conclusion apply to the current code version?
Design
M2 adds two summary levels:
Task Episode Summary: summarizes the Runs of one Task.
Intent Iteration Summary: summarizes the Task Episodes of one Intent.
Task completion, failure, or cancellation can trigger a Task summary. Intent revision, completion, or cancellation can trigger an Intent summary. Successful, failed, cancelled, partial, and no-code-change attempts are all useful development history.
The compiler keeps observations and Agent inferences as separate fields. Both link back to typed source references (EvidenceRef). Code context records the base/result commit OIDs, branch, and related paths.
flowchart TB
subgraph Facts["Existing Libra development records"]
I[Intent] --> T[Task] --> R[Run]
R --> E[Evidence · Decision · PatchSet]
R --> C[Session · code OID · paths]
end
Facts --> W["MemoryWriter<br/>resolve sources · redact · compile"]
W --> S["Two-level Episode memory<br/>Task Episode Summary<br/>Intent Iteration Summary"]
S --> H["MemoryNote revisions + MemoryEvent<br/>content-addressed history"]
H --> P["SQLite projection<br/>current revision · path index · FTS5/BM25"]
P --> Q["Agent retrieval<br/>task · time · path · code version<br/>Top K summaries · EvidenceRef expansion"]
Loading
Record and storage model
Each Episode is stored as an episodic MemoryNote; changes create a new revision and a MemoryEvent. The standard MemoryNote envelope carries versioning, provenance, policy, and code applicability. An optional EpisodePayloadV1 carries the development summary.
MemoryNote envelope
Part
Fields
Role in M2
Identity
schema_version, note_id, content_digest
Identify the logical note, its schema, and its canonical content
Memory cell
scope, namespace, path, kind, lifecycle
Place the note in a stable Repo-scoped episodic cell
Preserve the relationship to Libra development objects
started_at, ended_at
optional timestamps
Describe the development interval
goal, outcome
text, enum
Record the intended result and observed completion state
observations
list of { claim, evidence_refs }
Store facts derived from Runs, events, tools, tests, and patches
inferences
list of { claim, confidence, evidence_refs }
Store Agent-generated explanations, including root-cause hypotheses
decisions
structured list
Record choices made during the Task or Intent iteration
failed_attempts
structured list
Record attempted approaches and their observed results
unresolved
structured list
Record open questions and remaining work
code
{ base_oid, result_oid, branch_ref, paths }
Bind the Episode to the code versions and files it describes
For a Task Episode, the related-ID lists contain its parent Intent, root Task, and contributing Runs. For an Intent Iteration, they contain the root Intent plus all contributing Tasks and Runs. The outer MemoryNote.links pins every contributing Task Episode by note_id and revision_oid, so the higher-level summary can be traced to the exact Task summaries used during compilation.
The Episode path and search indexes advance with the generic Memory projection under the same scope watermark.
Retrieval applies structured filters for Task, Intent, time, outcome, and path; FTS5 generates lexical matches and bm25() ranks them. Git ancestry and the stored code anchors determine whether a result applies to the current code version. The Agent receives the highest-ranked summaries and can follow EvidenceRef links to the original Run, event, session fragment, patch, or decision.
FTS5 and BM25 are provided by Libra's bundled SQLite, so this design fits the current local storage model.
Motivation
Libra already records
Intent,Task,Run, evidence, decisions, patch sets, Agent sessions, and code commits. These objects preserve the development process, but an Agent still has to traverse several records and long sessions to explain why code changed, what was attempted, and how an earlier conclusion relates to the current code version.This issue proposes M2 development-process memory (
Episode): structured summaries compiled from Libra's existing development records and linked to their source evidence and code versions.It should help an Agent answer:
Design
M2 adds two summary levels:
Task completion, failure, or cancellation can trigger a Task summary. Intent revision, completion, or cancellation can trigger an Intent summary. Successful, failed, cancelled, partial, and no-code-change attempts are all useful development history.
The compiler keeps observations and Agent inferences as separate fields. Both link back to typed source references (
EvidenceRef). Code context records the base/result commit OIDs, branch, and related paths.flowchart TB subgraph Facts["Existing Libra development records"] I[Intent] --> T[Task] --> R[Run] R --> E[Evidence · Decision · PatchSet] R --> C[Session · code OID · paths] end Facts --> W["MemoryWriter<br/>resolve sources · redact · compile"] W --> S["Two-level Episode memory<br/>Task Episode Summary<br/>Intent Iteration Summary"] S --> H["MemoryNote revisions + MemoryEvent<br/>content-addressed history"] H --> P["SQLite projection<br/>current revision · path index · FTS5/BM25"] P --> Q["Agent retrieval<br/>task · time · path · code version<br/>Top K summaries · EvidenceRef expansion"]Record and storage model
Each Episode is stored as an episodic
MemoryNote; changes create a new revision and aMemoryEvent. The standardMemoryNoteenvelope carries versioning, provenance, policy, and code applicability. An optionalEpisodePayloadV1carries the development summary.MemoryNoteenvelopeschema_version,note_id,content_digestscope,namespace,path,kind,lifecyclevisibility,acl_policy_id,confidence,trust,sensitivitybody,rationale,tagsevidence_refs,links,entities,parentsvalid_from,valid_until,effective_from_commit,effective_until_commit,expires_atauthor,created_at,compile_recordepisode: Option<EpisodePayloadV1>EpisodePayloadV1schema_versionroot_kind,root_idtask | intent, object IDrelated_intent_ids,related_task_ids,related_run_idsstarted_at,ended_atgoal,outcomeobservations{ claim, evidence_refs }inferences{ claim, confidence, evidence_refs }decisionsfailed_attemptsunresolvedcode{ base_oid, result_oid, branch_ref, paths }For a Task Episode, the related-ID lists contain its parent Intent, root Task, and contributing Runs. For an Intent Iteration, they contain the root Intent plus all contributing Tasks and Runs. The outer
MemoryNote.linkspins every contributing Task Episode bynote_idandrevision_oid, so the higher-level summary can be traced to the exact Task summaries used during compilation.A Task or Intent maps to a stable Memory cell:
The authoritative history uses Libra's content-addressed objects and a protected Memory ref such as
refs/libra/memory/repo:SQLite stores the current read projection in the existing
.libra/libra.db. The projection can be rebuilt from the note and event history.SQLite organization
erDiagram MEMORY_PROJECTION_STATE ||--o{ MEMORY_HEAD : "tracks scope" MEMORY_NOTE_INDEX ||--|| MEMORY_HEAD : locates MEMORY_NOTE_INDEX ||--o{ MEMORY_REVISION_INDEX : has MEMORY_REVISION_INDEX ||--o{ MEMORY_EPISODE_PATH : indexes MEMORY_REVISION_INDEX ||--o| MEMORY_EPISODE_SEARCH_DOC : projects MEMORY_EPISODE_SEARCH_DOC ||--|| MEMORY_EPISODE_FTS : "" MEMORY_PROJECTION_STATE { string scope_key PK string projected_ref_oid int last_event_seq } MEMORY_HEAD { string note_id FK string scope_key FK string live_revision_oid } MEMORY_NOTE_INDEX { string note_id PK string scope_key string namespace string path } MEMORY_REVISION_INDEX { string revision_oid PK string note_id FK string producer } MEMORY_EPISODE_PATH { string note_id string revision_oid FK string code_path } MEMORY_EPISODE_SEARCH_DOC { int rowid PK string revision_oid FK string root_kind string root_id string outcome string ended_at } MEMORY_EPISODE_FTS { int rowid PK, FK string goal string summary }The SQLite projection is organized as follows:
memory_head(scope_key, namespace, path, note_id),live_revision_oid, lifecycle/review state, trust, sensitivity, code applicability,last_event_seqmemory_note_indexnote_id, cell coordinates, kind, lifecycle, origin, idempotency metadatamemory_revision_indexrevision_oid,note_id, producer, rules/prompt/model/policy versions, input fingerprintsmemory_projection_statescope_key,projected_ref_oid,last_event_seq,schema_version,policy_version,rebuilt_atmemory_episode_path(note_id, revision_oid, code_path)memory_episode_search_docrowid, unique(note_id, revision_oid), root kind/ID, Intent/Task IDs, outcome, start/end time, goal, summary, decisions, failures, unresolved itemsmemory_episode_ftsmemory_episode_search_doc.rowidbm25()rankingThe Episode path and search indexes advance with the generic Memory projection under the same scope watermark.
Retrieval applies structured filters for Task, Intent, time, outcome, and path; FTS5 generates lexical matches and
bm25()ranks them. Git ancestry and the stored code anchors determine whether a result applies to the current code version. The Agent receives the highest-ranked summaries and can followEvidenceReflinks to the original Run, event, session fragment, patch, or decision.FTS5 and BM25 are provided by Libra's bundled SQLite, so this design fits the current local storage model.
References