Files
learnharness/eslint.config.mjs
T
Amos 1167157c23 Storage ports: ChatStore/GraphStore/JobStore + adapters + core inversion (stage 3)
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.
2026-08-31 20:00:12 +03:00

64 lines
2.2 KiB
JavaScript

import { defineConfig, globalIgnores } from "eslint/config";
import nextPlugin from "@next/eslint-plugin-next";
import tsParser from "@typescript-eslint/parser";
import importPlugin from "eslint-plugin-import";
/**
* ESLint with one job here: ENFORCE THE IMPORT LAW (the shell/core
* architecture, docs/architecture.md). Everything else stays out of the
* way — this is not a style linter.
*
* components/** → "@/src/core" (the pure core barrel) — ONLY
* app/** → "@/src/core" + "@/src/server" (the server barrel) — ONLY
* src/core/** → never imports src/agent, src/server, src/store (pure
* core: adapters implement core/ports.ts, never the reverse)
*
* tests/ and scripts/ are internal — unrestricted.
*/
export default defineConfig([
globalIgnores([".next/**", "node_modules/**", "data/**", "next-env.d.ts", "scripts/**"]),
{
files: ["**/*.{js,mjs,ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
},
plugins: { "@next/next": nextPlugin, import: importPlugin },
settings: {
"import/resolver": { typescript: { alwaysTryTypes: true } },
},
rules: {
...nextPlugin.configs.recommended.rules,
"import/no-restricted-paths": [
"error",
{
zones: [
{
target: "./components",
from: "./src",
// NOTE: the plugin resolves `except` relative to the zone's `from` path.
except: ["./core/index.ts"],
message:
"Browser shell imports ONLY the pure core barrel: `from \"@/src/core\"` (architecture: docs/architecture.md).",
},
{
target: "./app",
from: "./src",
except: ["./core/index.ts", "./server/index.ts"],
message:
"app/ (transport + server components) imports ONLY the barrels: `@/src/core` and `@/src/server` (architecture: docs/architecture.md).",
},
{
target: "./src/core",
from: ["./src/agent", "./src/server", "./src/store"],
message:
"Pure core never imports IO layers (agent/server/store): adapters implement core/ports.ts, and the composition root (src/server/stores.ts) passes them in (architecture: docs/architecture.md).",
},
],
},
],
},
},
]);