Skip to content

feat(P3): WebGL provider, ExperienceReplay, ClusterStability, benchmark suite, hotpath guard, docs#73

Merged
devlux76 merged 10 commits intomainfrom
copilot/p3-subtask-creation
Mar 14, 2026
Merged

feat(P3): WebGL provider, ExperienceReplay, ClusterStability, benchmark suite, hotpath guard, docs#73
devlux76 merged 10 commits intomainfrom
copilot/p3-subtask-creation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

  • P3-A: WebGL Embedding Provider (embeddings/OrtWebglEmbeddingBackend.ts + createWebglProviderCandidate in ProviderResolver + 13 tests)
  • P3-B: Experience Replay (daydreamer/ExperienceReplay.ts + 7 tests)
  • P3-C: Cluster Stability (daydreamer/ClusterStability.ts + 9 tests)
  • P3-D: Benchmark Suite (QueryLatency.bench.ts, StorageOverhead.bench.ts, HotpathScaling.bench.ts + benchmarks/BASELINES.md + benchmark:* npm scripts)
  • P3-E3: Hotpath policy constants guard (scripts/guard-hotpath-policy.mjs + guard:hotpath-policy npm script)
  • P3-F: Documentation (docs/api.md, docs/development.md)
  • P3-G: Product Surface UX Contract (docs/product-surfaces.md)
  • Reviewer feedback (comment 2934373021): Added deleteVolume(volumeId) to MetadataStore interface and IndexedDbMetadataStoreClusterStability now deletes orphan volume records after split/merge; tests assert old volumes are gone
  • Fixed O(n²) indexOf in kmeansAssign with precomputed Map<bookId, index>
  • CI typecheck failures fixed: aligned with main's P1 API (SemanticNeighbor* renames, QueryOptions without vectorBackend); brought all foundation files (core/types.ts, cortex/Query.ts, storage/IndexedDbMetadataStore.ts, P1 source + tests) to current main state
  • guard-hotpath-policy false positives fixed: narrowed pattern back to alpha/beta/gamma/salienceWeights/tierQuotaRatios; quota fields enforced by TypeScript types
  • Verified: build (tsc), lint (eslint), 309 unit tests pass, both guards pass, CodeQL clean
Original prompt

This section details on the original issue you should resolve

<issue_title>P3</issue_title>
<issue_description>All P3 tasks, issues and sub issues belong here, either directly or by reference. Please subtask every issue with P3 in its name for ease of tracking.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…tability, benchmarks, hotpath guard, docs

Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
Copilot AI changed the title [WIP] [P3] Create subtasks for all P3 issues feat(P3): WebGL provider, ExperienceReplay, ClusterStability, benchmark suite, hotpath guard, docs Mar 13, 2026
Copilot AI requested a review from devlux76 March 13, 2026 22:37
@devlux76 devlux76 mentioned this pull request Mar 14, 2026
Closed
@github-actions github-actions bot added layer: embeddings Embedding providers and resolver layer: daydreamer Background consolidation (LTP/LTD, recalc) layer: testing Test coverage and integration tests layer: documentation API docs, developer guide, architecture diagrams labels Mar 14, 2026
@devlux76 devlux76 marked this pull request as ready for review March 14, 2026 00:42
Copilot AI review requested due to automatic review settings March 14, 2026 00:42
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 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.

Comment on lines +117 to +136
// --- 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,
);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0341e62. Three changes made:

  1. deleteVolume(volumeId) added to MetadataStore interface — removes the volume record, cleans up bookToVolume reverse-index entries for each of the volume's books, and deletes the volumeToShelf index entry.

  2. IndexedDbMetadataStore.deleteVolume — implemented as a single atomic IDB transaction spanning volumes, bookToVolume, and volumeToShelf stores.

  3. ClusterStability.run() — now calls metadataStore.deleteVolume(oldVolumeId) after replaceVolumeInShelves for every split parent and every merge source; tests assert getVolume(oldId) === undefined after 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).

Comment on lines +47 to +55
| 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`. |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment on lines +7 to +15
## 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 |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

devlux76 and others added 3 commits March 13, 2026 18:56
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>
devlux76 and others added 5 commits March 13, 2026 18:58
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>
@github-actions github-actions bot added layer: foundation Core types, model profiles, crypto layer: storage OPFS vector store and IndexedDB metadata store labels Mar 14, 2026
@github-actions github-actions bot added layer: hippocampus Ingest orchestration (chunk → embed → persist) layer: cortex Retrieval orchestration (rank → expand → order) labels Mar 14, 2026
@devlux76 devlux76 merged commit f4dc669 into main Mar 14, 2026
3 of 4 checks passed
@devlux76 devlux76 deleted the copilot/p3-subtask-creation branch March 14, 2026 01:18
Copilot stopped work on behalf of devlux76 due to an error March 14, 2026 01:18
@devlux76 devlux76 mentioned this pull request Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 layer: testing Test coverage and integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P3

3 participants