Conversation
…tability, benchmarks, hotpath guard, docs Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds P3 “polish/ship” features across embeddings, Daydreamer background maintenance, benchmarking, policy-constant enforcement, and documentation to round out developer experience and operational safeguards.
Changes:
- Adds a WebGL-based embedding backend (
OrtWebglEmbeddingBackend) and a resolver candidate (createWebglProviderCandidate) as a hardware-accelerated fallback tier. - Introduces Daydreamer maintenance modules (
ExperienceReplay,ClusterStability) plus new benchmark suites for query latency, storage overhead, and hotpath scaling. - Adds a CI guard script for preventing hardcoded hotpath policy constants outside
core/HotpathPolicy.ts, plus documentation updates.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| embeddings/OrtWebglEmbeddingBackend.ts | New embedding backend using Transformers.js with device: "webgl". |
| embeddings/ProviderResolver.ts | Adds createWebglProviderCandidate() for WebGL capability-gated selection. |
| daydreamer/ExperienceReplay.ts | Implements idle-time synthetic queries that apply Hebbian LTP edge reinforcement. |
| daydreamer/ClusterStability.ts | Implements volume split/merge maintenance and PageActivity community relabeling. |
| scripts/guard-hotpath-policy.mjs | New source guard to prevent hardcoded hotpath policy constants outside core/HotpathPolicy.ts. |
| package.json | Adds guard:hotpath-policy and benchmark scripts. |
| tests/embeddings/OrtWebglEmbeddingBackend.test.ts | Unit tests for WebGL embedding backend and provider candidate support gating. |
| tests/daydreamer/ExperienceReplay.test.ts | Unit tests for replay cycle behavior and edge weight clamping. |
| tests/daydreamer/ClusterStability.test.ts | Unit tests for split/merge behavior and community label updates. |
| tests/benchmarks/QueryLatency.bench.ts | New query latency benchmark vs corpus size. |
| tests/benchmarks/StorageOverhead.bench.ts | New storage overhead benchmark via ingest + vector reads. |
| tests/benchmarks/HotpathScaling.bench.ts | New hotpath promotion-sweep scaling benchmark + Williams Bound invariant checks. |
| benchmarks/BASELINES.md | Template baseline recording doc for benchmark output. |
| docs/api.md | Adds/updates API reference sections for ingest/query/Daydreamer modules. |
| docs/development.md | Adds guard usage, troubleshooting, performance tuning, and benchmark instructions. |
| docs/product-surfaces.md | Defines UX/privacy contracts for app-vs-library product surfaces. |
| // --- Pass 1: split high-variance volumes --- | ||
| for (const volume of volumes) { | ||
| if ( | ||
| volume.variance > this.varianceThreshold && | ||
| volume.bookIds.length >= 2 | ||
| ) { | ||
| const splits = await this.splitVolume(volume, metadataStore); | ||
| if (splits !== null) { | ||
| splitCount++; | ||
| communityUpdates += await this.updateCommunityLabels( | ||
| splits, | ||
| metadataStore, | ||
| ); | ||
| // Remove the original volume from storage (replace with two new ones) | ||
| await this.replaceVolumeInShelves( | ||
| volume.volumeId, | ||
| splits, | ||
| metadataStore, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Fixed in 0341e62. Three changes made:
-
deleteVolume(volumeId)added toMetadataStoreinterface — removes the volume record, cleans upbookToVolumereverse-index entries for each of the volume's books, and deletes thevolumeToShelfindex entry. -
IndexedDbMetadataStore.deleteVolume— implemented as a single atomic IDB transaction spanningvolumes,bookToVolume, andvolumeToShelfstores. -
ClusterStability.run()— now callsmetadataStore.deleteVolume(oldVolumeId)afterreplaceVolumeInShelvesfor every split parent and every merge source; tests assertgetVolume(oldId) === undefinedafter both operations.
Also took the opportunity to fix the O(n²) indexOf inside kmeansAssign — replaced with a precomputed Map<bookId, index> so each K-means iteration is O(n).
| | Data | Stays local? | Notes | | ||
| |---------------------------------|:--------------:|--------------------------------------------| | ||
| | Page content | Yes | Stored in OPFS; never leaves the device. | | ||
| | Embeddings | Yes | Stored in OPFS; never leaves the device. | | ||
| | Hotpath index | Yes | IndexedDB; never leaves the device. | | ||
| | Query text | Yes | Never logged or transmitted. | | ||
| | P2P curiosity probe (opt-in) | Partial | Public-interest graph slice only; no PII. | | ||
| | Model weights | Fetched once | Cached locally via `@huggingface/transformers`. | | ||
|
|
| ## Williams Bound H(t) — Sublinear Growth Curve | ||
|
|
||
| | Graph mass (t) | H(t) = ceil(0.5 * sqrt(t * log2(1+t))) | H(t)/t ratio | | ||
| |---------------:|----------------------------------------:|-------------:| | ||
| | 1 000 | ~22 | 0.022 | | ||
| | 10 000 | ~99 | 0.010 | | ||
| | 100 000 | ~408 | 0.004 | | ||
| | 1 000 000 | ~1 576 | 0.002 | | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…lse positives, fix CI typecheck Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
embeddings/OrtWebglEmbeddingBackend.ts+createWebglProviderCandidatein ProviderResolver + 13 tests)daydreamer/ExperienceReplay.ts+ 7 tests)daydreamer/ClusterStability.ts+ 9 tests)QueryLatency.bench.ts,StorageOverhead.bench.ts,HotpathScaling.bench.ts+benchmarks/BASELINES.md+benchmark:*npm scripts)scripts/guard-hotpath-policy.mjs+guard:hotpath-policynpm script)docs/api.md,docs/development.md)docs/product-surfaces.md)deleteVolume(volumeId)toMetadataStoreinterface andIndexedDbMetadataStore—ClusterStabilitynow deletes orphan volume records after split/merge; tests assert old volumes are goneindexOfinkmeansAssignwith precomputedMap<bookId, index>SemanticNeighbor*renames,QueryOptionswithoutvectorBackend); brought all foundation files (core/types.ts,cortex/Query.ts,storage/IndexedDbMetadataStore.ts, P1 source + tests) to currentmainstatealpha/beta/gamma/salienceWeights/tierQuotaRatios; quota fields enforced by TypeScript typesOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.