feat(memory): add memory extension with core functionality and tests
- Implemented MemoryStore class for managing concepts with YAML frontmatter. - Added methods for creating, reading, updating, and deleting concepts. - Introduced locking mechanism for concurrent access. - Developed search and hinting capabilities for concept retrieval. - Created tests for access control and store functionality. - Added long-term memory skill documentation and operational guidelines. - Included package.json and package-lock.json for dependency management.
This commit is contained in:
31
extensions/memory/test/access.test.mjs
Normal file
31
extensions/memory/test/access.test.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { MemoryTurnAccess } from "../access.mjs";
|
||||
|
||||
test("requires current-turn search and read before updating an existing concept", () => {
|
||||
const access = new MemoryTurnAccess();
|
||||
assert.throws(() => access.requireWrite("projects/atlas", true), /memory_search/);
|
||||
|
||||
access.recordSearch(["projects/atlas"]);
|
||||
assert.throws(() => access.requireWrite("projects/atlas", true), /read existing concept/);
|
||||
|
||||
access.recordRead(["projects/atlas"]);
|
||||
assert.doesNotThrow(() => access.requireWrite("projects/atlas", true));
|
||||
});
|
||||
|
||||
test("new concepts require duplicate search but cannot be read unless returned", () => {
|
||||
const access = new MemoryTurnAccess();
|
||||
access.recordSearch([]);
|
||||
assert.doesNotThrow(() => access.requireWrite("projects/new-project", false));
|
||||
assert.throws(() => access.requireSearchedId("projects/new-project"), /exact concept/);
|
||||
});
|
||||
|
||||
test("turn reset removes prior authorization", () => {
|
||||
const access = new MemoryTurnAccess();
|
||||
access.recordSearch(["people/alice"]);
|
||||
access.recordRead(["people/alice"]);
|
||||
assert.doesNotThrow(() => access.requireForget("people/alice"));
|
||||
|
||||
access.reset();
|
||||
assert.throws(() => access.requireForget("people/alice"), /this user turn/);
|
||||
});
|
||||
Reference in New Issue
Block a user