@git-stunts/git-warp 11.5.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +142 -10
  2. package/bin/cli/commands/registry.js +4 -0
  3. package/bin/cli/commands/reindex.js +41 -0
  4. package/bin/cli/commands/verify-index.js +59 -0
  5. package/bin/cli/infrastructure.js +7 -2
  6. package/bin/cli/schemas.js +19 -0
  7. package/bin/cli/types.js +2 -0
  8. package/index.d.ts +49 -12
  9. package/package.json +2 -2
  10. package/src/domain/WarpGraph.js +40 -0
  11. package/src/domain/errors/ShardIdOverflowError.js +28 -0
  12. package/src/domain/errors/index.js +1 -0
  13. package/src/domain/services/AdjacencyNeighborProvider.js +140 -0
  14. package/src/domain/services/BitmapNeighborProvider.js +178 -0
  15. package/src/domain/services/CheckpointMessageCodec.js +3 -3
  16. package/src/domain/services/CheckpointService.js +77 -12
  17. package/src/domain/services/GraphTraversal.js +1239 -0
  18. package/src/domain/services/IncrementalIndexUpdater.js +765 -0
  19. package/src/domain/services/JoinReducer.js +233 -5
  20. package/src/domain/services/LogicalBitmapIndexBuilder.js +323 -0
  21. package/src/domain/services/LogicalIndexBuildService.js +108 -0
  22. package/src/domain/services/LogicalIndexReader.js +315 -0
  23. package/src/domain/services/LogicalTraversal.js +321 -202
  24. package/src/domain/services/MaterializedViewService.js +379 -0
  25. package/src/domain/services/ObserverView.js +138 -47
  26. package/src/domain/services/PatchBuilderV2.js +3 -3
  27. package/src/domain/services/PropertyIndexBuilder.js +64 -0
  28. package/src/domain/services/PropertyIndexReader.js +111 -0
  29. package/src/domain/services/TemporalQuery.js +128 -14
  30. package/src/domain/types/PatchDiff.js +90 -0
  31. package/src/domain/types/WarpTypesV2.js +4 -4
  32. package/src/domain/utils/MinHeap.js +45 -17
  33. package/src/domain/utils/canonicalCbor.js +36 -0
  34. package/src/domain/utils/fnv1a.js +20 -0
  35. package/src/domain/utils/roaring.js +14 -3
  36. package/src/domain/utils/shardKey.js +40 -0
  37. package/src/domain/utils/toBytes.js +17 -0
  38. package/src/domain/warp/_wiredMethods.d.ts +7 -1
  39. package/src/domain/warp/checkpoint.methods.js +21 -5
  40. package/src/domain/warp/materialize.methods.js +17 -5
  41. package/src/domain/warp/materializeAdvanced.methods.js +142 -3
  42. package/src/domain/warp/query.methods.js +78 -12
  43. package/src/infrastructure/adapters/CasSeekCacheAdapter.js +26 -5
  44. package/src/ports/BlobPort.js +1 -1
  45. package/src/ports/NeighborProviderPort.js +59 -0
  46. package/src/ports/SeekCachePort.js +4 -3
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Port interface for neighbor lookups on any graph.
3
+ *
4
+ * Concrete providers back this with in-memory adjacency maps, bitmap indexes,
5
+ * or remote APIs. All providers MUST return edges sorted by (neighborId, label)
6
+ * using strict codepoint comparison (never localeCompare).
7
+ *
8
+ * @abstract
9
+ */
10
+
11
+ /** @typedef {'out' | 'in' | 'both'} Direction */
12
+ /** @typedef {{ labels?: Set<string> }} NeighborOptions */
13
+ /** @typedef {{ neighborId: string, label: string }} NeighborEdge */
14
+
15
+ export default class NeighborProviderPort {
16
+ /**
17
+ * Returns neighbor edges for a node, sorted by (neighborId, label).
18
+ *
19
+ * For direction 'both', returns the union of out and in edges
20
+ * deduped by (neighborId, label). A consumer cannot tell if an
21
+ * edge was outgoing or incoming — this is intentionally lossy.
22
+ *
23
+ * @param {string} _nodeId - The node to look up
24
+ * @param {Direction} _direction - Edge direction: 'out', 'in', or 'both'
25
+ * @param {NeighborOptions} [_options] - Optional label filter
26
+ * @returns {Promise<NeighborEdge[]>} Sorted by (neighborId, label) via codepoint comparison
27
+ * @throws {Error} If not implemented by a concrete provider
28
+ */
29
+ async getNeighbors(_nodeId, _direction, _options) {
30
+ throw new Error('NeighborProviderPort.getNeighbors() not implemented');
31
+ }
32
+
33
+ /**
34
+ * Checks whether a node is alive in this view.
35
+ *
36
+ * Semantics: "alive in this view" (visible projection), NOT "ever existed."
37
+ *
38
+ * @param {string} _nodeId - The node to check
39
+ * @returns {Promise<boolean>} True if the node is alive
40
+ * @throws {Error} If not implemented by a concrete provider
41
+ */
42
+ async hasNode(_nodeId) {
43
+ throw new Error('NeighborProviderPort.hasNode() not implemented');
44
+ }
45
+
46
+ /**
47
+ * Returns the latency class of this provider.
48
+ *
49
+ * Used by GraphTraversal to decide whether to enable neighbor memoization.
50
+ * - 'sync': in-memory, no benefit from caching (e.g., AdjacencyNeighborProvider)
51
+ * - 'async-local': disk-backed, caching avoids repeated reads (e.g., BitmapNeighborProvider)
52
+ * - 'async-remote': network-backed, caching critical
53
+ *
54
+ * @returns {'sync' | 'async-local' | 'async-remote'}
55
+ */
56
+ get latencyClass() {
57
+ return 'async-local';
58
+ }
59
+ }
@@ -14,7 +14,7 @@ export default class SeekCachePort {
14
14
  /**
15
15
  * Retrieves a cached state buffer by key.
16
16
  * @param {string} _key - Cache key (e.g., 'v1:t42-<frontierHash>')
17
- * @returns {Promise<Buffer|null>} The cached buffer, or null on miss
17
+ * @returns {Promise<{ buffer: Buffer|Uint8Array, indexTreeOid?: string } | null>} The cached entry, or null on miss
18
18
  * @throws {Error} If not implemented by a concrete adapter
19
19
  */
20
20
  async get(_key) {
@@ -24,11 +24,12 @@ export default class SeekCachePort {
24
24
  /**
25
25
  * Stores a state buffer under the given key.
26
26
  * @param {string} _key - Cache key
27
- * @param {Buffer} _buffer - Serialized state to cache
27
+ * @param {Buffer|Uint8Array} _buffer - Serialized state to cache
28
+ * @param {{ indexTreeOid?: string }} [_options] - Optional metadata
28
29
  * @returns {Promise<void>}
29
30
  * @throws {Error} If not implemented by a concrete adapter
30
31
  */
31
- async set(_key, _buffer) {
32
+ async set(_key, _buffer, _options) {
32
33
  throw new Error('SeekCachePort.set() not implemented');
33
34
  }
34
35