-
Notifications
You must be signed in to change notification settings - Fork 0
feat(P3): WebGL provider, ExperienceReplay, ClusterStability, benchmark suite, hotpath guard, docs #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(P3): WebGL provider, ExperienceReplay, ClusterStability, benchmark suite, hotpath guard, docs #73
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
48e9f29
Initial plan
Copilot 6321731
feat: implement P3 tasks — WebGL provider, ExperienceReplay, ClusterS…
Copilot a5e38e8
Potential fix for pull request finding
devlux76 91a74d3
Potential fix for pull request finding
devlux76 02d8968
Potential fix for pull request finding
devlux76 0a1dc36
Potential fix for pull request finding
devlux76 4064892
Potential fix for pull request finding
devlux76 2d5a9c8
Potential fix for pull request finding
devlux76 dd56622
Potential fix for pull request finding
devlux76 0341e62
fix: align with main's P1 API renames, add deleteVolume, fix guard fa…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # CORTEX Benchmark Baselines | ||
|
|
||
| > **Status:** Baseline measurements pending a hardware CI run. | ||
| > The values below are illustrative targets; replace with real output from | ||
| > `npm run benchmark:all` on representative hardware. | ||
|
|
||
| ## 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 | | ||
|
|
||
| Key invariant: H(t)/t strictly decreases as t grows. | ||
|
|
||
| --- | ||
|
|
||
| ## Dummy Embedder Hotpath | ||
|
|
||
| Run: `npm run benchmark:dummy` | ||
|
|
||
| | Benchmark | Mean latency (ms) | Throughput | | ||
| |-------------------------|------------------:|----------:| | ||
| | Single short input | TBD | TBD | | ||
| | Batch 16 medium inputs | TBD | TBD | | ||
| | Batch 64 short inputs | TBD | TBD | | ||
|
|
||
| --- | ||
|
|
||
| ## Query Latency vs Corpus Size | ||
|
|
||
| Run: `npm run benchmark:query-latency` | ||
|
|
||
| | Corpus size | Mean query latency (ms) | | ||
| |------------:|------------------------:| | ||
| | 100 pages | TBD | | ||
| | 500 pages | TBD | | ||
|
|
||
| Expected: latency grows sub-linearly because hotpath residents are scored | ||
| first and most queries are served without scanning the full corpus. | ||
|
|
||
| --- | ||
|
|
||
| ## Storage Overhead | ||
|
|
||
| Run: `npm run benchmark:storage-overhead` | ||
|
|
||
| | Page count | Vector store size (bytes) | Bytes per page | | ||
| |-----------:|--------------------------:|---------------:| | ||
| | 50 | TBD | TBD | | ||
| | 200 | TBD | TBD | | ||
|
|
||
| Expected: linear growth (no hidden quadratic allocations). | ||
|
|
||
| --- | ||
|
|
||
| ## Hotpath Scaling | ||
|
|
||
| Run: `npm run benchmark:hotpath-scaling` | ||
|
|
||
| | Graph mass | H(t) capacity | Resident count | Promotion sweep (ms) | | ||
| |-----------:|--------------:|---------------:|---------------------:| | ||
| | 1 000 | ~22 | TBD | TBD | | ||
| | 5 000 | ~55 | TBD | TBD | | ||
|
|
||
| Invariant: Resident count never exceeds H(t). | ||
|
|
||
| --- | ||
|
|
||
| ## How to Update Baselines | ||
|
|
||
| 1. Run `npm run benchmark:all` on the target hardware. | ||
| 2. Copy the `mean` column values from the Vitest bench output. | ||
| 3. Replace every `TBD` cell in this file with the measured value. | ||
| 4. Commit with message `chore: update benchmark baselines — <hardware>`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import type { Hash } from "../core/types"; | ||
| import type { ModelProfile } from "../core/ModelProfile"; | ||
| import { hashText } from "../core/crypto/hash"; | ||
| import type { Metroid } from "./MetroidBuilder"; | ||
|
|
||
| export interface KnowledgeGap { | ||
| queryText: string; | ||
| queryEmbedding: Float32Array; | ||
| knowledgeBoundary: Hash | null; | ||
| detectedAt: string; | ||
| } | ||
|
|
||
| export interface CuriosityProbe { | ||
| probeId: Hash; | ||
| queryText: string; | ||
| queryEmbedding: Float32Array; | ||
| knowledgeBoundary: Hash | null; | ||
| mimeType: string; | ||
| modelUrn: string; | ||
| createdAt: string; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a KnowledgeGap when the metroid signals that m2 could not be found | ||
| * (i.e. the engine has no antithesis for this query). Returns null when the | ||
| * metroid is complete and no gap was detected. | ||
| */ | ||
| export async function detectKnowledgeGap( | ||
| queryText: string, | ||
| queryEmbedding: Float32Array, | ||
| metroid: Metroid, | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars -- reserved for future model-aware gap categorisation | ||
| _modelProfile: ModelProfile, | ||
| ): Promise<KnowledgeGap | null> { | ||
| if (!metroid.knowledgeGap) return null; | ||
|
|
||
| return { | ||
| queryText, | ||
| queryEmbedding, | ||
| knowledgeBoundary: metroid.m1 !== "" ? metroid.m1 : null, | ||
| detectedAt: new Date().toISOString(), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Builds a serialisable CuriosityProbe from a detected KnowledgeGap. | ||
| * The probeId is the SHA-256 of (queryText + detectedAt) so it is | ||
| * deterministic for the same gap inputs. | ||
| */ | ||
| export async function buildCuriosityProbe( | ||
| gap: KnowledgeGap, | ||
| modelProfile: ModelProfile, | ||
| mimeType = "text/plain", | ||
| ): Promise<CuriosityProbe> { | ||
| const probeId = await hashText(gap.queryText + gap.detectedAt); | ||
|
|
||
| return { | ||
| probeId, | ||
| queryText: gap.queryText, | ||
| queryEmbedding: gap.queryEmbedding, | ||
| knowledgeBoundary: gap.knowledgeBoundary, | ||
| mimeType, | ||
| modelUrn: `urn:model:${modelProfile.modelId}`, | ||
| createdAt: new Date().toISOString(), | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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