You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maka.apache.org by "1625567290 (via GitHub)" <gi...@apache.org> on 2026/09/01 07:54:39 UTC
Re: [D] Proposal: expose bounded memory_search and memory_get over the existing memory_item store [maka]
GitHub user 1625567290 edited a discussion: Proposal: expose bounded memory_search and memory_get over the existing memory_item store
> **Revision note:** This proposal has been narrowed after review. It now covers only the smallest model-facing read path over the existing Host-owned `memory_item` store. Stateful Plugin Platform work, source-range recall, working projections, observation/reflection, indexes, background consolidation, and new governance UI are not prerequisites for this slice.
## Summary
A user should not need to repeat a durable preference, project fact, or prior decision in every conversation.
Maka already extracts atomic items and stores them with keys, Scope, temporal state, lifecycle, and `RuntimeEvent` provenance. The missing product link is smaller: the Agent cannot search or read those accepted items.
The proposed first slice is therefore two bounded, Host-owned model tools over the existing store:
- `memory_search` — find active Items by exact or prefix key under the current Runtime-authorized Scope;
- `memory_get` — read one authorized Item by ID with its current version and provenance metadata.
No storage migration, Plugin migration, derived memory layer, vector dependency, or new background process is required.
## Current implementation gap
At the reviewed `main` commit, Maka already has:
- atomic `memory_item` records with `global` and `workspace` Scope, temporal fields, lifecycle state, typed keys, and source event identities;
- `MemoryItemStore.readItem(itemId)`;
- `MemoryItemStore.searchByKeys({ terms, match, workspaceKey, includeArchived, limit })`;
- exact and prefix matching with deterministic normalization and bounded term/result counts;
- Runtime Policy fields `memory.enabled` and `memory.agentReadEnabled`, with Agent reads disabled by default;
- Incognito and extraction policy enforcement on the write path.
What it does not have is a model-facing tool wired to `readItem` or `searchByKeys`. The current prompt projection reads the separate local-memory document; it does not expose the accepted SQLite Item store to the Agent.
This proposal connects that existing read capability. It does not redesign the memory lifecycle.
## Proposed first slice
### 1. Runtime Host owns authorization
Runtime Host derives the current Workspace identity and applies Runtime Policy before a tool is admitted or executed.
- Tool input must not accept `workspaceKey`, Profile ID, Session ID, or another caller-selected Scope.
- Search covers active Global Items plus active Items for the current Workspace.
- A Workspace-scoped Item must never be visible from another Workspace.
- Incognito, `memory.enabled = false`, or `memory.agentReadEnabled = false` makes the read tools unavailable or returns a policy-denied result without querying storage.
- Archived Items are excluded from Agent reads in this slice.
### 2. `memory_search`
Suggested input:
```ts
{
terms: string[];
match?: 'exact' | 'prefix';
limit?: number;
}
```
V1 should preserve the current store semantics: match any distinct normalized term and rank by the number of matched terms. The model-facing limit should default to 5 and be capped at 10, below the storage ceiling.
Each result should contain only what is needed to choose or use an Item:
```ts
{
itemId: string;
version: number;
content: string;
kind: string;
statementType: string;
temporalType: string;
eventStartedAt: number | null;
eventEndedAt: number | null;
observedAt: number;
matchedKeys: string[];
sourceCount: number;
}
```
The output must have a hard aggregate size limit and an explicit truncation indicator. It must not expose records from a broader Scope when the result budget is exhausted or a Scope identity is unavailable.
### 3. `memory_get`
Suggested input:
```ts
{ itemId: string }
```
The Host resolves the Item, checks that it is active and belongs to Global or the current Workspace Scope, then returns the current Item, keys, version, temporal state, and source identities. A missing, archived, or unauthorized Item should produce the same non-disclosing not-found result.
`memory_get` does not retrieve raw event content. Source-range recall is a separate capability that should be added only if evaluation shows that Item content and provenance identities are insufficient for trustworthy answers.
### 4. No implicit prompt injection
This slice adds explicit tools only. It does not automatically inject SQLite Items into every prompt and does not change the existing local-memory document projection.
That keeps cost and behavior observable: an Item enters model context only through a recorded tool call and bounded tool result.
## Acceptance gates
### Deterministic CI
- exact-key and prefix-key search return the expected active Items in deterministic order;
- Global Items are visible from any normal Workspace, while Workspace Items are visible only from their owning Workspace;
- Incognito and both Memory policy gates prevent storage reads;
- archived Items are absent from `memory_search` and indistinguishable from missing Items in `memory_get`;
- the model cannot supply or widen Scope identifiers;
- result count and aggregate output budgets are enforced with explicit truncation metadata;
- Item version, temporal state, matched keys, and provenance availability survive the tool projection;
- CJK two-character keys, mixed-language keys, code identifiers, duplicate terms, empty terms, and over-limit inputs are covered;
- one Run keeps the tool composition admitted at its start across a concurrent policy change.
### Capability evaluation
Use fixture conversations in which a later Session asks about a durable preference, project fact, or prior decision established in an earlier Session.
Compare:
1. exact recent history only;
2. exact recent history plus `memory_search`/`memory_get`.
Report:
- continuity answer accuracy;
- preference and constraint adherence;
- unsupported-memory usage;
- correct abstention when no matching Item exists;
- cross-Scope leakage;
- retrieved Item precision;
- tool-result characters/tokens;
- added latency.
The first slice succeeds only if it improves later-session continuity without increasing unsupported claims or Scope leakage.
## Explicit non-goals
The following are not prerequisites and are not part of this proposal:
- moving Memory into Plugin-owned state;
- completing the Stateful Plugin Platform;
- generic RuntimeEvent observation or Context contribution APIs;
- source-range event recall;
- Working Projection or automatic pinning;
- Observation or Reflection;
- lexical, vector, entity, or graph indexes;
- background consolidation;
- new governance UI;
- feedback, forgetting, or automatic cross-session injection;
- changing the existing extraction pipeline or SQLite Schema.
## What would justify another layer
Additional mechanisms should be proposed only against a measured failure:
- add source-range recall if unsupported answers or trust failures require original evidence;
- add a small Working Projection if repeatedly retrieving ubiquitous preferences creates measurable cost or misses;
- add Observation/Reflection if atomic Item recall fails on episode-level questions;
- add lexical or vector indexing if exact/prefix key search has inadequate measured coverage;
- consider a Stateful Plugin boundary separately if there is a platform ownership or deployment objective independent of this read-path slice.
## Questions for maintainers
1. Is a Host-owned `memory_search`/`memory_get` pair the right smallest next slice under #1615?
2. Should `memory.agentReadEnabled` gate both tools, matching the existing Agent-read authority?
3. Are default 5 / maximum 10 search results appropriately bounded for V1?
4. Should the tool projection include source event identities, or only `sourceCount` until a source-range design exists?
5. If this direction is accepted, should implementation continue as the recall slice of #1615 rather than as a separate lifecycle project?
## Relationship to existing work
- #1615 remains the authority for the automatic long-term-memory lifecycle. This proposal narrows only its missing model-facing recall slice.
- #2335 was already consolidated into #1615 and should not be reopened as a separate retrieval architecture.
- #2973 and #3729 concern the Extension/Plugin Platform. They are not prerequisites for this slice.
- #2986 remains separate Workspace-identity work and is not taken over here.
## References
- Reviewed Maka main commit: https://github.com/apache/maka/commit/3db83c26a387160dd85d8af96472e88986dab51e
- Item and search contracts: https://github.com/apache/maka/blob/3db83c26a387160dd85d8af96472e88986dab51e/packages/core/src/long-term-memory.ts#L75-L111
- Store read interface: https://github.com/apache/maka/blob/3db83c26a387160dd85d8af96472e88986dab51e/packages/core/src/long-term-memory.ts#L295-L332
- SQLite read implementation: https://github.com/apache/maka/blob/3db83c26a387160dd85d8af96472e88986dab51e/packages/storage/src/sqlite-long-term-memory-store.ts#L842-L885
- Runtime Memory policy: https://github.com/apache/maka/blob/3db83c26a387160dd85d8af96472e88986dab51e/packages/core/src/runtime-policy.ts#L128-L130
- Long-term-memory lifecycle: https://github.com/apache/maka/issues/1615
GitHub link: https://github.com/apache/maka/discussions/4426
----
This is an automatically sent email for dev@maka.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@maka.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maka.apache.org
For additional commands, e-mail: dev-help@maka.apache.org