ReMe/reme_studio/tests/memory-graph.test.mjs
jinliyl ef3f99f019
refactor(packaging): reorganize published packages (#495)
* refactor(packaging): reorganize published packages

* fix(packaging): install AgentScope extra in wheel smoke

* docs: align package guides and documentation site

* ci(workflow): add core dependency verification step in Python package build

- Add a workflow step to verify released core dependencies by installing the wheel with core extras
- Assert the presence of the static index.html file to ensure proper package contents
- Create and use a temporary virtual environment for isolation during verification
- Keep existing artifacts upload step intact and conditional on inputs.upload_artifacts flag

* fix(ci): update package installation dependencies in Windows workflow

- Change pip install from editable reme_studio and core to only dev and as extras
- Remove installation of reme_studio and core to streamline dependency setup
- Ensure Windows CI uses the correct extras for testing environment

* fix(tests): add missing commas in toml file reads in package version tests

- Added trailing commas in the tomllib.loads calls for auto-fin and daily_paper configs
- Ensured consistent syntax to prevent potential tuple misinterpretation
- Improved readability and correctness of the test setup code

* fix(packaging): protect qwenpaw releases and test Studio health
2026-08-27 14:02:09 +08:00

156 lines
3.7 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import {
edgePath,
graphBelowRoot,
layoutGraph,
reciprocalEdgeKeys,
} from "../app/files-workspace/memory-graph.ts";
const snapshot = {
version: 1,
nodes: [
{
id: "virtual:wiki",
path: "digest/wiki",
name: "wiki",
description: "",
indexed: false,
virtual: true,
},
{
id: "virtual:personal",
path: "digest/personal",
name: "personal",
description: "",
indexed: false,
virtual: true,
},
{
id: "digest/wiki/a.md",
path: "digest/wiki/a.md",
name: "A",
description: "",
indexed: true,
virtual: false,
},
{
id: "digest/personal/b.md",
path: "digest/personal/b.md",
name: "B",
description: "",
indexed: true,
virtual: false,
},
{
id: "daily/note.md",
path: "daily/note.md",
name: "Note",
description: "",
indexed: true,
virtual: false,
},
{
id: "virtual:procedure",
path: "digest/procedure",
name: "procedure",
description: "",
indexed: false,
virtual: true,
},
{
id: "digest/procedure/c.md",
path: "digest/procedure/c.md",
name: "C",
description: "",
indexed: true,
virtual: false,
},
{
id: "daily/unrelated.md",
path: "daily/unrelated.md",
name: "Unrelated",
description: "",
indexed: true,
virtual: false,
},
],
edges: [
{ source: "virtual:wiki", target: "digest/wiki/a.md", target_anchor: null },
{
source: "virtual:personal",
target: "digest/personal/b.md",
target_anchor: null,
},
{
source: "digest/wiki/a.md",
target: "daily/note.md",
target_anchor: null,
},
{
source: "digest/wiki/a.md",
target: "digest/personal/b.md",
target_anchor: null,
},
{
source: "digest/personal/b.md",
target: "digest/wiki/a.md",
target_anchor: null,
},
{
source: "virtual:procedure",
target: "digest/procedure/c.md",
target_anchor: null,
},
{
source: "digest/procedure/c.md",
target: "daily/unrelated.md",
target_anchor: null,
},
],
};
test("memory graph keeps only nodes reachable below the selected category", () => {
const graph = graphBelowRoot(snapshot, "wiki");
assert.deepEqual(
graph.nodes.map((node) => node.id),
[
"virtual:wiki",
"digest/wiki/a.md",
"digest/personal/b.md",
"daily/note.md",
],
);
assert.equal(graph.edges.length, 4);
});
test("memory graph excludes daily nodes below another category", () => {
const graph = graphBelowRoot(snapshot, "wiki");
assert.ok(!graph.nodes.some((node) => node.id === "daily/unrelated.md"));
assert.ok(!graph.nodes.some((node) => node.id === "digest/procedure/c.md"));
});
test("memory graph uses stable radial layers and curves reciprocal links", () => {
const graph = graphBelowRoot(snapshot, "wiki");
const positioned = layoutGraph(graph);
const root = positioned.byId.get("virtual:wiki");
const direct = positioned.byId.get("digest/wiki/a.md");
const leaf = positioned.byId.get("daily/note.md");
assert.deepEqual(
{ x: root.x, y: root.y, layer: root.layer },
{ x: 540, y: 340, layer: 0 },
);
assert.equal(direct.layer, 1);
assert.equal(leaf.layer, 2);
const reciprocal = reciprocalEdgeKeys(graph.edges);
const edge = graph.edges.find(
(item) =>
item.source === "digest/wiki/a.md" &&
item.target === "digest/personal/b.md",
);
assert.match(edgePath(edge, positioned.byId, reciprocal), / Q /);
});