Implement Williams Bound HotpathPolicy foundation#45
Conversation
Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
- Add HotpathPolicy module with computeCapacity, computeSalience, deriveTierQuotas, deriveCommunityQuotas, and DEFAULT_HOTPATH_POLICY - Add PageActivity, HotpathEntry, TierQuotas types to core/types.ts - Add hotpath method signatures to MetadataStore interface - Implement hotpath_index and page_activity stores in IndexedDbMetadataStore - Add comprehensive test coverage for all new functionality Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Implements the Williams Bound hotpath policy foundation and adds IndexedDB persistence primitives for hotpath state, enabling future hotpath-aware modules (ingest/query/hierarchy/Daydreamer) to share a single policy + storage substrate.
Changes:
- Added
core/HotpathPolicy.ts(capacity, salience, tier quotas, community quotas) plusDEFAULT_HOTPATH_POLICY. - Extended
core/types.tswith hotpath/page-activity types and newMetadataStorehotpath APIs. - Upgraded
storage/IndexedDbMetadataStore.tsto DB v2 with newhotpath_indexandpage_activitystores and corresponding CRUD/eviction methods; added unit tests.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
core/HotpathPolicy.ts |
Adds Williams Bound capacity/salience/quota utilities and default policy constants. |
core/types.ts |
Introduces HotpathEntry, PageActivity, TierQuotas and new MetadataStore hotpath method signatures. |
storage/IndexedDbMetadataStore.ts |
Bumps IndexedDB schema to v2 and implements hotpath/page-activity storage + eviction. |
tests/HotpathPolicy.test.ts |
Adds unit coverage for capacity/salience/quota logic and edge cases. |
tests/Persistence.test.ts |
Adds IndexedDB persistence tests for hotpath entries and page activity. |
package-lock.json |
Adds npm lockfile (not described in PR text). |
| if (remaining < 0) { | ||
| // Budget < n communities — give 1 to the first `budget` communities | ||
| const result = new Array<number>(n).fill(0); | ||
| for (let i = 0; i < budget; i++) result[i] = 1; | ||
| return result; | ||
| } | ||
|
|
There was a problem hiding this comment.
@copilot Please fix using your best judgement given the docs, this might be a place where the docs didn't quite adequately specify or it might be an error in the implementation. In any event please fix it the best you can.
There was a problem hiding this comment.
Removed the dead branch in c65bbf1. The remaining < 0 condition was unreachable because when budget < n, minPerCommunity is set to 0, making remaining = budget ≥ 0. The budget < n case is already handled correctly by the proportional largest-remainder distribution that follows (each community starts at 0 and the budget slots are distributed proportionally by size).
The `remaining < 0` branch was unreachable because when budget < n, minPerCommunity is 0, making remaining = budget >= 0. The budget < n case is already handled correctly by the proportional largest-remainder distribution that follows. Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
core/HotpathPolicy.tswithcomputeCapacity,computeSalience,deriveTierQuotas,deriveCommunityQuotas, and frozenDEFAULT_HOTPATH_POLICYtests/HotpathPolicy.test.tswith full test coverage (26 tests: sublinear growth, monotonicity, edge inputs, tier quota sums, community quotas, salience determinism/clamping)core/types.tswithPageActivity,HotpathEntry,TierQuotasinterfaces and hotpath method signatures onMetadataStorestorage/IndexedDbMetadataStore.tswithhotpath_indexandpage_activityobject stores + implement all six hotpath methodstests/Persistence.test.tswith hotpath store tests (11 tests: put/get/evict cycle, page activity, resident count)deriveCommunityQuotasOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.