Files
loki/scripts/test/knowledge-map-workspace.ts
Cato 964777b7ac Make Memory explain projects, next actions and the research behind them (#1740)
* feat: connect project purpose, next actions and research in Memory

* test: resolve superseding essays through the real dynamic route
2026-11-30 05:51:51 +01:00

89 lines
3.4 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { buildKnowledgeMap, type MapInputs } from "../../src/lib/knowledge-map/build";
import { nextMove, projectConnections } from "../../src/lib/knowledge-map/projects";
import { workspaceProgramme } from "../../src/lib/knowledge-map/programme";
import { projectHandoff } from "../../src/lib/knowledge-map/model";
import { mapConnectionFacts } from "../../src/lib/knowledge-map/facts";
import { PROJECT_ATTR } from "../../src/config/project-attrs";
import { MAP_FIXTURE } from "../preview/knowledge-map.fixture";
const at = new Date("2026-11-15");
const row = { userId: "alice", updatedAt: at, description: "Fallback purpose", devLog: null };
const input: MapInputs = {
projects: [
{
...row,
id: "l",
name: "Loki",
entityProjectId: "e",
gitUrl: "https://github.com/bitbaum/loki",
},
{
...row,
id: "fake",
name: "Orangecat",
entityProjectId: null,
gitUrl: "https://github.com/someone/orangecat",
},
],
things: [{ ...row, id: "e", name: "loki", title: "Loki", type: "project" }],
relations: [],
goals: [],
packages: [],
attributes: [
{
userId: "alice",
entityId: "e",
key: PROJECT_ATTR.MISSION,
value: "Build and verify software",
},
{
userId: "alice",
entityId: "e",
key: PROJECT_ATTR.NEXT_STEP,
value: "Try the guided workflow",
},
{ userId: "bob", entityId: "e", key: PROJECT_ATTR.NEXT_STEP, value: "PRIVATE" },
],
};
const map = buildKnowledgeMap("alice", input);
assert.equal(map.nodes.find((n) => n.id === "project:l")?.role?.label, "Work & agents");
assert.equal(
map.nodes.find((n) => n.id === "project:fake")?.role,
undefined,
"display names and foreign repos do not establish ecosystem roles",
);
assert.equal(map.nodes[0].description, "Build and verify software");
assert.equal(nextMove(map, map.nodes[0])?.text, "Try the guided workflow");
assert(!JSON.stringify(map).includes("PRIVATE"));
const malformed = buildKnowledgeMap("alice", { ...input, things: [] });
assert(
!JSON.stringify(malformed).includes("Try the guided workflow"),
"attributes need an owned entity endpoint",
);
const sharedOnly = { ...MAP_FIXTURE, edges: MAP_FIXTURE.edges.filter((e) => e.id !== "e") };
assert.equal(projectConnections(sharedOnly, "project:atlas").direct.length, 0);
assert.equal(
projectConnections(sharedOnly, "project:atlas").shared.length,
1,
"shared packages remain reuse, not integration",
);
const programme = workspaceProgramme();
assert.equal(programme.available, true);
assert.equal(programme.tracks.length, 2);
assert(programme.tracks.every((t) => t.steps.length >= 5));
const enriched = { ...MAP_FIXTURE, programme };
const brief = projectHandoff(enriched, "project:atlas");
assert(brief.includes("Acceptance:"));
assert(brief.includes("/thoughts/proof-before-autonomy"));
assert(JSON.stringify(mapConnectionFacts(enriched, "ecosystem")).includes("Canonical roadmap"));
for (const slug of ["a-connected-workspace-that-earns-its-place", "proof-before-autonomy"]) {
const article = readFileSync(`content/thoughts/${slug}.md`, "utf8");
assert(article.includes("garrytan/g-harness-evals"));
assert(article.includes("2114338456750997922"));
assert(article.includes("/roadmap"));
}
console.log(
"workspace: canonical roles, owned profiles, actionable handoffs, honest relationships and research/roadmap continuity passed",
);