Per-entity semantic ports (src/core/ports.ts), one adapter family
(src/store/*, fs JSON/JSONL), exactly one composition point
(src/server/stores.ts). Dependency direction is now machine-checked:
adapters implement core interfaces; core never imports an adapter.
The inversion:
- core/graph.ts (emitChat/getGraph/graphSnapshot/foldStaleChats) is now
pure — it takes the storage ports as explicit parameters (GraphDeps).
No store imports; newGraphNodeId is local; node id format unchanged.
- core/graph-context.ts buildGraphContext() no longer defaults to the
live ledgers: the chat-handler hands in getGraph(graphStore) per turn.
- store adapters export exactly one object each implementing their port
(chatStore/graphStore/jobStore); bodies otherwise verbatim.
NodeMapping + SessionCheckpoint moved store/graph -> core/contracts
(they ARE contract shapes); CreateJobInit/JobPatch live in ports.
- titleFromPrompt moved store/chats -> core/contracts (pure helper,
planNodeStatus precedent). Store modules now contain persistence only.
- server/stores.ts is the composition root; server/{chats,graph,jobs}.ts
and chat-handler wire from it; agent (plan tools, sub-agent runner)
call the port objects. The shell surface (@/src/server exports) is
unchanged.
Lint law extended: the whole of src/core is now a purity zone (was a
file glob with a graph/graph-context exemption). Verified it fires on
core->store imports; tsc clean, 190/190 tests, eslint clean, prod build
clean (prerender 6/6). Tests pass deps explicitly — graph.test uses the
same fs-adapter pair stores.ts wires in production; graph-context.test
keeps its in-memory ledgers as a GraphStore implementation.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* THE CORE PUBLIC API — the only module the shell (app/, components/) may
|
|
* import. Everything exported here is browser-safe: pure logic + types,
|
|
* no node builtins, no fs, no network.
|
|
*
|
|
* Server-side surfaces (chat streaming, store reads) live behind
|
|
* src/server's barrel instead — the import law (eslint.config.mjs):
|
|
*
|
|
* components/** → "@/src/core" (this barrel, ONLY)
|
|
* app/** → "@/src/core" + "@/src/server"
|
|
*
|
|
* Server-only core modules (core/graph.ts emission/derivation,
|
|
* core/graph-context.ts) are pure but need storage ports passed in by a
|
|
* server caller, so they are deliberately NOT re-exported here — the
|
|
* server imports them directly. The storage PORT TYPES are types-only and
|
|
* browser-safe, hence re-exported.
|
|
*/
|
|
|
|
export * from "./contracts.ts";
|
|
export * from "./ports.ts";
|
|
|
|
export * from "./question-core.ts";
|
|
export * from "./plan-tree.ts";
|
|
export * from "./phases.ts";
|
|
export * from "./pending.ts";
|
|
export * from "./math-delims.ts";
|
|
export * from "./ui-message.ts";
|