Skip to content

refactor: move core engine into lib/ and harness into ui/#85

Merged
devlux76 merged 5 commits intomainfrom
refactor/lib-ui-structure
Mar 14, 2026
Merged

refactor: move core engine into lib/ and harness into ui/#85
devlux76 merged 5 commits intomainfrom
refactor/lib-ui-structure

Conversation

@devlux76
Copy link
Copy Markdown
Owner

Summary\n\nThis PR reorganizes the repository to make a clean separation between the core engine code () and UI/runtime harness code ().\n\n### Changes\n- Moved all engine modules (core, cortex, embeddings, hippocampus, daydreamer, sharing, storage, and root helpers) into \n- Kept existing root-level exports as lightweight shims for backwards compatibility\n- Moved the runtime legacy harness to and updated the harness server script accordingly\n- Updated includes and docs/plan references\n\n### Notes\n- All unit tests pass (

�[1m�[46m RUN �[49m�[22m �[36mv4.1.0 �[39m�[90m/home/user/Projects/cortex�[39m

�[32m✓�[39m tests/embeddings/DeterministicDummyEmbeddingBackend.test.ts �[2m(�[22m�[2m6 tests�[22m�[2m)�[22m�[32m 27�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/HebbianUpdater.test.ts �[2m(�[22m�[2m11 tests�[22m�[2m)�[22m�[32m 23�[2mms�[22m�[39m
�[32m✓�[39m tests/Persistence.test.ts �[2m(�[22m�[2m45 tests�[22m�[2m)�[22m�[32m 60�[2mms�[22m�[39m
�[32m✓�[39m tests/hippocampus/Ingest.test.ts �[2m(�[22m�[2m1 test�[22m�[2m)�[22m�[32m 48�[2mms�[22m�[39m
�[32m✓�[39m tests/hippocampus/FastNeighborInsert.test.ts �[2m(�[22m�[2m8 tests�[22m�[2m)�[22m�[32m 129�[2mms�[22m�[39m
�[32m✓�[39m tests/cortex/Ranking.test.ts �[2m(�[22m�[2m12 tests�[22m�[2m)�[22m�[32m 116�[2mms�[22m�[39m
�[32m✓�[39m tests/cortex/Query.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 103�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/ExperienceReplay.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 182�[2mms�[22m�[39m
�[32m✓�[39m tests/integration/IngestQuery.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[32m 149�[2mms�[22m�[39m
�[32m✓�[39m tests/HotpathPolicy.test.ts �[2m(�[22m�[2m40 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
�[32m✓�[39m tests/SalienceEngine.test.ts �[2m(�[22m�[2m40 tests�[22m�[2m)�[22m�[32m 32�[2mms�[22m�[39m
�[32m✓�[39m tests/crypto/sign.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[32m 24�[2mms�[22m�[39m
�[32m✓�[39m tests/hippocampus/HierarchyBuilder.test.ts �[2m(�[22m�[2m12 tests�[22m�[2m)�[22m�[32m 288�[2mms�[22m�[39m
�[32m✓�[39m tests/sharing/SubgraphExchange.test.ts �[2m(�[22m�[2m13 tests�[22m�[2m)�[22m�[32m 42�[2mms�[22m�[39m
�[32m✓�[39m tests/hippocampus/Chunker.test.ts �[2m(�[22m�[2m8 tests�[22m�[2m)�[22m�[32m 24�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/IdleScheduler.test.ts �[2m(�[22m�[2m8 tests�[22m�[2m)�[22m�[32m 24�[2mms�[22m�[39m
�[32m✓�[39m tests/sharing/EligibilityClassifier.test.ts �[2m(�[22m�[2m14 tests�[22m�[2m)�[22m�[32m 13�[2mms�[22m�[39m
�[32m✓�[39m tests/integration/Daydreamer.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 128�[2mms�[22m�[39m
�[32m✓�[39m tests/embeddings/ProviderResolver.test.ts �[2m(�[22m�[2m13 tests�[22m�[2m)�[22m�[32m 19�[2mms�[22m�[39m
�[32m✓�[39m tests/crypto/verify.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 27�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/FullNeighborRecalc.test.ts �[2m(�[22m�[2m8 tests�[22m�[2m)�[22m�[32m 26�[2mms�[22m�[39m
�[32m✓�[39m tests/hippocampus/PageBuilder.test.ts �[2m(�[22m�[2m2 tests�[22m�[2m)�[22m�[32m 22�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/PrototypeRecomputer.test.ts �[2m(�[22m�[2m11 tests�[22m�[2m)�[22m�[32m 14�[2mms�[22m�[39m
�[32m✓�[39m tests/embeddings/TransformersJsEmbeddingBackend.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 16�[2mms�[22m�[39m
�[32m✓�[39m tests/daydreamer/ClusterStability.test.ts �[2m(�[22m�[2m21 tests�[22m�[2m)�[22m�[32m 30�[2mms�[22m�[39m
�[32m✓�[39m tests/sharing/CuriosityBroadcaster.test.ts �[2m(�[22m�[2m11 tests�[22m�[2m)�[22m�[32m 21�[2mms�[22m�[39m
�[32m✓�[39m tests/crypto/hash.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 18�[2mms�[22m�[39m
�[32m✓�[39m tests/cortex/KnowledgeGapDetector.test.ts �[2m(�[22m�[2m14 tests�[22m�[2m)�[22m�[32m 21�[2mms�[22m�[39m
�[32m✓�[39m tests/embeddings/OrtWebglEmbeddingBackend.test.ts �[2m(�[22m�[2m13 tests�[22m�[2m)�[22m�[32m 14�[2mms�[22m�[39m
�[32m✓�[39m tests/model/ModelDefaults.test.ts �[2m(�[22m�[2m6 tests�[22m�[2m)�[22m�[32m 8�[2mms�[22m�[39m
�[32m✓�[39m tests/cortex/MetroidBuilder.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[32m 13�[2mms�[22m�[39m
�[32m✓�[39m tests/cortex/OpenTSPSolver.test.ts �[2m(�[22m�[2m9 tests�[22m�[2m)�[22m�[32m 10�[2mms�[22m�[39m
�[32m✓�[39m tests/model/RoutingPolicy.test.ts �[2m(�[22m�[2m6 tests�[22m�[2m)�[22m�[32m 6�[2mms�[22m�[39m
�[32m✓�[39m tests/BackendSmoke.test.ts �[2m(�[22m�[2m3 tests�[22m�[2m)�[22m�[32m 8�[2mms�[22m�[39m
�[32m✓�[39m tests/embeddings/EmbeddingRunner.test.ts �[2m(�[22m�[2m2 tests�[22m�[2m)�[22m�[32m 5�[2mms�[22m�[39m
�[32m✓�[39m tests/model/ModelProfileResolver.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 5�[2mms�[22m�[39m
�[32m✓�[39m tests/model/BuiltInModelProfiles.test.ts �[2m(�[22m�[2m5 tests�[22m�[2m)�[22m�[32m 4�[2mms�[22m�[39m

�[2m Test Files �[22m �[1m�[32m37 passed�[39m�[22m�[90m (37)�[39m
�[2m Tests �[22m �[1m�[32m418 passed�[39m�[22m�[90m (418)�[39m
�[2m Start at �[22m 02:56:55
�[2m Duration �[22m 1.50s�[2m (transform 2.98s, setup 0ms, import 5.05s, tests 1.73s, environment 6ms)�[22m).\n- No functional behavior was changed; this is purely structural.\n

Copilot AI review requested due to automatic review settings March 14, 2026 08:57
@github-actions github-actions bot added layer: foundation Core types, model profiles, crypto layer: storage OPFS vector store and IndexedDB metadata store layer: compute WebGPU / WebGL / WebNN / WASM vector backends layer: embeddings Embedding providers and resolver layer: hippocampus Ingest orchestration (chunk → embed → persist) layer: cortex Retrieval orchestration (rank → expand → order) layer: daydreamer Background consolidation (LTP/LTD, recalc) layer: documentation API docs, developer guide, architecture diagrams labels Mar 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the repository to separate the core engine from the runtime/UI harness by moving engine code under lib/ and the harness under ui/, while keeping the previous module paths working via re-export shims.

Changes:

  • Updated TypeScript project includes to target lib/** (and tests) instead of the previous top-level engine directories.
  • Replaced prior top-level engine modules with thin shims that re-export from lib/ for backward compatibility.
  • Moved the legacy runtime harness to ui/harness and updated the harness server script + docs references accordingly.

Reviewed changes

Copilot reviewed 109 out of 116 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsconfig.json Updates compilation include paths to focus on lib/** (+ tests).
scripts/runtime-harness-server.mjs Serves harness content from ui/harness instead of runtime/harness.
docs/development.md Updates harness path reference in development docs.
PLAN.md Updates harness file path references in the plan.
storage/OPFSVectorStore.ts Back-compat shim re-exporting lib/storage/OPFSVectorStore.
storage/MemoryVectorStore.ts Back-compat shim re-exporting lib/storage/MemoryVectorStore.
sharing/types.ts Back-compat shim re-exporting lib/sharing/types.
sharing/SubgraphImporter.ts Back-compat shim re-exporting lib/sharing/SubgraphImporter.
sharing/SubgraphExporter.ts Back-compat shim re-exporting lib/sharing/SubgraphExporter.
sharing/PeerExchange.ts Back-compat shim re-exporting lib/sharing/PeerExchange.
sharing/EligibilityClassifier.ts Back-compat shim re-exporting lib/sharing/EligibilityClassifier.
sharing/CuriosityBroadcaster.ts Back-compat shim re-exporting lib/sharing/CuriosityBroadcaster.
hippocampus/PageBuilder.ts Back-compat shim re-exporting lib/hippocampus/PageBuilder.
hippocampus/Ingest.ts Back-compat shim re-exporting lib/hippocampus/Ingest.
hippocampus/Chunker.ts Back-compat shim re-exporting lib/hippocampus/Chunker.
embeddings/TransformersJsEmbeddingBackend.ts Back-compat shim re-exporting lib/embeddings/TransformersJsEmbeddingBackend.
embeddings/OrtWebglEmbeddingBackend.ts Back-compat shim re-exporting lib/embeddings/OrtWebglEmbeddingBackend.
embeddings/EmbeddingRunner.ts Back-compat shim re-exporting lib/embeddings/EmbeddingRunner.
embeddings/EmbeddingBackend.ts Back-compat shim re-exporting lib/embeddings/EmbeddingBackend.
embeddings/DeterministicDummyEmbeddingBackend.ts Back-compat shim re-exporting lib/embeddings/DeterministicDummyEmbeddingBackend.
daydreamer/IdleScheduler.ts Back-compat shim re-exporting lib/daydreamer/IdleScheduler.
daydreamer/HebbianUpdater.ts Back-compat shim re-exporting lib/daydreamer/HebbianUpdater.
daydreamer/FullNeighborRecalc.ts Back-compat shim re-exporting lib/daydreamer/FullNeighborRecalc.
daydreamer/ExperienceReplay.ts Back-compat shim re-exporting lib/daydreamer/ExperienceReplay.
cortex/Ranking.ts Back-compat shim re-exporting lib/cortex/Ranking.
cortex/QueryResult.ts Back-compat shim re-exporting lib/cortex/QueryResult.
cortex/Query.ts Back-compat shim re-exporting lib/cortex/Query.
cortex/OpenTSPSolver.ts Back-compat shim re-exporting lib/cortex/OpenTSPSolver.
cortex/KnowledgeGapDetector.ts Back-compat shim re-exporting lib/cortex/KnowledgeGapDetector.
core/crypto/verify.ts Back-compat shim re-exporting lib/core/crypto/verify.
core/crypto/uuid.ts Back-compat shim re-exporting lib/core/crypto/uuid.
core/crypto/sign.ts Back-compat shim re-exporting lib/core/crypto/sign.
core/crypto/hash.ts Back-compat shim re-exporting lib/core/crypto/hash.
core/NumericConstants.ts Back-compat shim re-exporting lib/core/NumericConstants.
core/ModelProfileResolver.ts Back-compat shim re-exporting lib/core/ModelProfileResolver.
core/ModelProfile.ts Back-compat shim re-exporting lib/core/ModelProfile.
core/ModelDefaults.ts Back-compat shim re-exporting lib/core/ModelDefaults.
core/BuiltInModelProfiles.ts Back-compat shim re-exporting lib/core/BuiltInModelProfiles.
BackendKind.ts Back-compat shim re-exporting lib/BackendKind.
CreateVectorBackend.ts Back-compat shim re-exporting lib/CreateVectorBackend.
Policy.ts Back-compat shim re-exporting lib/Policy.
TopK.ts Back-compat shim re-exporting lib/TopK.
VectorBackend.ts Back-compat shim re-exporting lib/VectorBackend.
WasmVectorBackend.ts Back-compat shim re-exporting lib/WasmVectorBackend.
WebNNVectorBackend.ts Back-compat shim re-exporting lib/WebNNVectorBackend.
WebNNTypes.d.ts Back-compat shim intended to forward WebNN global typings.
lib/storage/OPFSVectorStore.ts Canonical engine implementation location under lib/.
lib/storage/MemoryVectorStore.ts Canonical engine implementation location under lib/.
lib/sharing/types.ts Canonical sharing schema/types under lib/.
lib/sharing/SubgraphImporter.ts Canonical importer implementation under lib/.
lib/sharing/SubgraphExporter.ts Canonical exporter implementation under lib/.
lib/sharing/PeerExchange.ts Canonical peer exchange orchestration under lib/.
lib/sharing/EligibilityClassifier.ts Canonical eligibility classifier under lib/.
lib/sharing/CuriosityBroadcaster.ts Canonical broadcaster under lib/.
lib/hippocampus/PageBuilder.ts Canonical hippocampus implementation under lib/.
lib/hippocampus/Ingest.ts Canonical hippocampus implementation under lib/.
lib/hippocampus/Chunker.ts Canonical hippocampus implementation under lib/.
lib/embeddings/TransformersJsEmbeddingBackend.ts Canonical embeddings backend under lib/.
lib/embeddings/OrtWebglEmbeddingBackend.ts Canonical embeddings backend under lib/.
lib/embeddings/EmbeddingRunner.ts Canonical embeddings runner under lib/.
lib/embeddings/EmbeddingBackend.ts Canonical embeddings interface under lib/.
lib/embeddings/DeterministicDummyEmbeddingBackend.ts Canonical dummy embeddings backend under lib/.
lib/daydreamer/IdleScheduler.ts Canonical daydreamer scheduler under lib/.
lib/cortex/Ranking.ts Canonical cortex ranking under lib/.
lib/cortex/QueryResult.ts Canonical cortex result type under lib/.
lib/cortex/Query.ts Canonical cortex query path under lib/.
lib/cortex/OpenTSPSolver.ts Canonical cortex TSP solver under lib/.
lib/cortex/KnowledgeGapDetector.ts Canonical cortex gap detector under lib/.
lib/core/crypto/verify.ts Canonical crypto verify under lib/.
lib/core/crypto/uuid.ts Canonical UUID helper under lib/.
lib/core/crypto/sign.ts Canonical crypto signing under lib/.
lib/core/crypto/hash.ts Canonical crypto hashing under lib/.
lib/core/NumericConstants.ts Canonical shared numeric constants under lib/.
lib/core/ModelProfileResolver.ts Canonical model profile resolver under lib/.
lib/core/ModelProfile.ts Canonical model profile types under lib/.
lib/core/ModelDefaults.ts Canonical model-derived defaults under lib/.
lib/core/BuiltInModelProfiles.ts Canonical built-in model registry under lib/.
lib/BackendKind.ts Canonical backend detection under lib/.
lib/CreateVectorBackend.ts Canonical vector backend factory under lib/.
lib/Policy.ts Canonical routing policy resolution under lib/.
lib/VectorBackend.ts Canonical vector backend interface under lib/.
lib/TopK.ts Canonical Top-K helpers under lib/.
lib/WasmVectorBackend.ts Canonical WASM backend under lib/.
lib/WebNNVectorBackend.ts Canonical WebNN backend under lib/.
lib/WebNNTypes.d.ts Canonical WebNN ambient typings under lib/.
lib/Vectors.glsl Shader source asset moved/added under lib/.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

@devlux76 I've opened a new pull request, #86, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 14, 2026 03:35
* Initial plan

* fix: wrap WebGlVectorBackend.create() in .then() to capture synchronous throws for WASM fallback

Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
@devlux76 devlux76 merged commit 0a2d2c6 into main Mar 14, 2026
1 of 3 checks passed
@devlux76 devlux76 deleted the refactor/lib-ui-structure branch March 14, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

layer: compute WebGPU / WebGL / WebNN / WASM vector backends layer: cortex Retrieval orchestration (rank → expand → order) layer: daydreamer Background consolidation (LTP/LTD, recalc) layer: documentation API docs, developer guide, architecture diagrams layer: embeddings Embedding providers and resolver layer: foundation Core types, model profiles, crypto layer: hippocampus Ingest orchestration (chunk → embed → persist) layer: storage OPFS vector store and IndexedDB metadata store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants