querysub 0.402.0 → 0.404.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 (107) hide show
  1. package/.cursorrules +2 -0
  2. package/bin/audit-imports.js +4 -0
  3. package/package.json +7 -4
  4. package/spec.txt +77 -0
  5. package/src/-a-archives/archiveCache.ts +9 -4
  6. package/src/-a-archives/archivesBackBlaze.ts +1039 -1039
  7. package/src/-a-auth/certs.ts +0 -12
  8. package/src/-c-identity/IdentityController.ts +12 -3
  9. package/src/-f-node-discovery/NodeDiscovery.ts +32 -26
  10. package/src/-g-core-values/NodeCapabilities.ts +12 -2
  11. package/src/0-path-value-core/AuthorityLookup.ts +239 -0
  12. package/src/0-path-value-core/LockWatcher2.ts +150 -0
  13. package/src/0-path-value-core/PathRouter.ts +535 -0
  14. package/src/0-path-value-core/PathRouterRouteOverride.ts +72 -0
  15. package/src/0-path-value-core/PathRouterServerAuthoritySpec.tsx +65 -0
  16. package/src/0-path-value-core/PathValueCommitter.ts +222 -488
  17. package/src/0-path-value-core/PathValueController.ts +277 -239
  18. package/src/0-path-value-core/PathWatcher.ts +534 -0
  19. package/src/0-path-value-core/ShardPrefixes.ts +31 -0
  20. package/src/0-path-value-core/ValidStateComputer.ts +303 -0
  21. package/src/0-path-value-core/archiveLocks/ArchiveLocks.ts +1 -1
  22. package/src/0-path-value-core/archiveLocks/ArchiveLocks2.ts +80 -44
  23. package/src/0-path-value-core/archiveLocks/archiveSnapshots.ts +13 -16
  24. package/src/0-path-value-core/auditLogs.ts +2 -0
  25. package/src/0-path-value-core/hackedPackedPathParentFiltering.ts +97 -0
  26. package/src/0-path-value-core/pathValueArchives.ts +490 -492
  27. package/src/0-path-value-core/pathValueCore.ts +195 -1492
  28. package/src/0-path-value-core/startupAuthority.ts +74 -0
  29. package/src/1-path-client/RemoteWatcher.ts +100 -83
  30. package/src/1-path-client/pathValueClientWatcher.ts +808 -815
  31. package/src/2-proxy/PathValueProxyWatcher.ts +10 -8
  32. package/src/2-proxy/archiveMoveHarness.ts +182 -214
  33. package/src/2-proxy/garbageCollection.ts +9 -8
  34. package/src/2-proxy/schema2.ts +21 -1
  35. package/src/3-path-functions/PathFunctionHelpers.ts +206 -180
  36. package/src/3-path-functions/PathFunctionRunner.ts +943 -766
  37. package/src/3-path-functions/PathFunctionRunnerMain.ts +5 -3
  38. package/src/3-path-functions/pathFunctionLoader.ts +2 -2
  39. package/src/3-path-functions/syncSchema.ts +592 -521
  40. package/src/4-deploy/deployFunctions.ts +19 -4
  41. package/src/4-deploy/deployGetFunctionsInner.ts +8 -2
  42. package/src/4-deploy/deployMain.ts +51 -68
  43. package/src/4-deploy/edgeClientWatcher.tsx +1 -1
  44. package/src/4-deploy/edgeNodes.ts +2 -2
  45. package/src/4-dom/qreact.tsx +2 -4
  46. package/src/4-dom/qreactTest.tsx +7 -13
  47. package/src/4-querysub/Querysub.ts +21 -8
  48. package/src/4-querysub/QuerysubController.ts +45 -29
  49. package/src/4-querysub/permissions.ts +2 -2
  50. package/src/4-querysub/querysubPrediction.ts +80 -70
  51. package/src/4-querysub/schemaHelpers.ts +5 -1
  52. package/src/5-diagnostics/GenericFormat.tsx +14 -9
  53. package/src/archiveapps/archiveGCEntry.tsx +9 -2
  54. package/src/archiveapps/archiveJoinEntry.ts +87 -84
  55. package/src/archiveapps/archiveMergeEntry.tsx +2 -0
  56. package/src/bits.ts +19 -0
  57. package/src/config.ts +21 -3
  58. package/src/config2.ts +23 -48
  59. package/src/deployManager/components/DeployPage.tsx +7 -3
  60. package/src/deployManager/machineSchema.ts +4 -1
  61. package/src/diagnostics/ActionsHistory.ts +3 -8
  62. package/src/diagnostics/AuditLogPage.tsx +2 -3
  63. package/src/diagnostics/FunctionCallInfo.tsx +141 -0
  64. package/src/diagnostics/FunctionCallInfoState.ts +162 -0
  65. package/src/diagnostics/MachineThreadInfo.tsx +1 -1
  66. package/src/diagnostics/NodeViewer.tsx +37 -48
  67. package/src/diagnostics/SyncTestPage.tsx +241 -0
  68. package/src/diagnostics/auditImportViolations.ts +185 -0
  69. package/src/diagnostics/listenOnDebugger.ts +3 -3
  70. package/src/diagnostics/logs/IndexedLogs/BufferUnitSet.ts +10 -4
  71. package/src/diagnostics/logs/IndexedLogs/IndexedLogs.ts +2 -2
  72. package/src/diagnostics/logs/IndexedLogs/LogViewer3.tsx +24 -22
  73. package/src/diagnostics/logs/IndexedLogs/moveIndexLogsToPublic.ts +1 -1
  74. package/src/diagnostics/logs/diskLogGlobalContext.ts +1 -0
  75. package/src/diagnostics/logs/errorNotifications2/logWatcher.ts +1 -3
  76. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCycleEntryEditor.tsx +39 -17
  77. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCycleEntryReadMode.tsx +4 -6
  78. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCycleInstanceTableView.tsx +36 -5
  79. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCyclePage.tsx +19 -5
  80. package/src/diagnostics/logs/lifeCycleAnalysis/LifeCycleRenderer.tsx +15 -7
  81. package/src/diagnostics/logs/lifeCycleAnalysis/NestedLifeCycleInfo.tsx +28 -106
  82. package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycleMatching.ts +2 -0
  83. package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycleMisc.ts +0 -0
  84. package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycleSearch.tsx +18 -7
  85. package/src/diagnostics/logs/lifeCycleAnalysis/lifeCycles.tsx +3 -0
  86. package/src/diagnostics/managementPages.tsx +10 -3
  87. package/src/diagnostics/misc-pages/ArchiveViewer.tsx +20 -26
  88. package/src/diagnostics/misc-pages/ArchiveViewerTree.tsx +6 -4
  89. package/src/diagnostics/misc-pages/ComponentSyncStats.tsx +2 -2
  90. package/src/diagnostics/misc-pages/LocalWatchViewer.tsx +7 -9
  91. package/src/diagnostics/misc-pages/SnapshotViewer.tsx +23 -12
  92. package/src/diagnostics/misc-pages/archiveViewerShared.tsx +1 -1
  93. package/src/diagnostics/pathAuditer.ts +486 -0
  94. package/src/diagnostics/pathAuditerCallback.ts +20 -0
  95. package/src/diagnostics/watchdog.ts +8 -1
  96. package/src/library-components/URLParam.ts +1 -1
  97. package/src/misc/hash.ts +1 -0
  98. package/src/path.ts +21 -7
  99. package/src/server.ts +54 -47
  100. package/src/user-implementation/loginEmail.tsx +1 -1
  101. package/tempnotes.txt +67 -0
  102. package/test.ts +288 -95
  103. package/src/0-path-value-core/NodePathAuthorities.ts +0 -1057
  104. package/src/0-path-value-core/PathController.ts +0 -1
  105. package/src/5-diagnostics/diskValueAudit.ts +0 -218
  106. package/src/5-diagnostics/memoryValueAudit.ts +0 -438
  107. package/src/archiveapps/lockTest.ts +0 -127
@@ -0,0 +1,97 @@
1
+ import { measureWrap } from "socket-function/src/profiling/measure";
2
+ import { getPathDepth, getPathIndexAssert, hack_getPackedPathSuffix, hack_setPackedPathSuffix, hack_stripPackedPath } from "../path";
3
+ import { PathRouter } from "./PathRouter";
4
+ import { cache } from "socket-function/src/caching";
5
+ import { authorityLookup } from "./AuthorityLookup";
6
+
7
+ // NOTE: This code has been moved into PathRouter
8
+ // /** Returns a number between 0 (inclusive) and 1 (exclusive)
9
+ // * - See matchesParentRangeFilter, matchesParentRangeFilterPart, and filterChildPaths.
10
+ // */
11
+ // export function __getRoutingHash(key: string): number {
12
+ // // Using fastHash is about twice as fast as sha256 (although that might be due to the buffer allocation?)
13
+ // let hash = fastHash(key);
14
+ // return hash % (1000 * 1000 * 1000) / (1000 * 1000 * 1000);
15
+ // // let hash = sha256(key);
16
+ // // return getBufferFraction(Buffer.from(hash, "hex"));
17
+ // }
18
+
19
+ let isPrefix = cache((path: string) => {
20
+ let spec = authorityLookup.getOurSpec();
21
+ if (!spec) return false;
22
+ for (let prefix of spec.prefixes) {
23
+ if (path.startsWith(prefix.prefix)) return true;
24
+ }
25
+ return false;
26
+ });
27
+
28
+ // NOTE: Assumes fullPath is already a child of parentPath, and only checks for hash
29
+ export function matchesParentRangeFilter(config: {
30
+ parentPath: string;
31
+ fullPath: string;
32
+ packedPath: string;
33
+ }) {
34
+ if (config.packedPath === config.packedPath) return true;
35
+ let filter = decodeParentFilter(config.packedPath);
36
+ if (!filter) return true;
37
+ if (filter.useFullPathHash) {
38
+ let route = PathRouter.getSingleKeyRoute(config.fullPath);
39
+ return filter.start <= route && route < filter.end;
40
+ }
41
+ let route = PathRouter.getRouteChildKey(config.fullPath);
42
+ return filter.start <= route && route < filter.end;
43
+ }
44
+ // export function matchesParentRangeFilterPart(config: {
45
+ // part: string;
46
+ // start: number;
47
+ // end: number;
48
+ // }) {
49
+ // if (config.start === 0 && config.end === 1) return true;
50
+ // let hash = __getRoutingHash(config.part);
51
+ // return config.start <= hash && hash < config.end;
52
+ // }
53
+
54
+ export const filterChildPathsBase = measureWrap(
55
+ function filterChildPathsBase(parentPath: string, packedSuffix: string, paths: Set<string>): Set<string> {
56
+ let [startFractionStr, endFractionStr, useFullPathHash] = packedSuffix.split("|");
57
+ let startFraction = Number(startFractionStr);
58
+ let endFraction = Number(endFractionStr);
59
+
60
+ let depth = getPathDepth(parentPath);
61
+
62
+ let filtered = new Set<string>();
63
+ for (let path of paths) {
64
+ if (useFullPathHash) {
65
+ let route = PathRouter.getSingleKeyRoute(path);
66
+ if (startFraction <= route && route < endFraction) {
67
+ filtered.add(path);
68
+ }
69
+ } else {
70
+ let key = getPathIndexAssert(path, depth);
71
+ let hash = PathRouter.getSingleKeyRoute(key);
72
+ if (startFraction <= hash && hash < endFraction) {
73
+ filtered.add(path);
74
+ }
75
+ }
76
+ }
77
+ //console.log(`Filtered ${paths.size} paths to ${filtered.size} paths`);
78
+ return filtered;
79
+ }
80
+ );
81
+
82
+ export function encodeParentFilter(config: {
83
+ path: string;
84
+ startFraction: number;
85
+ endFraction: number;
86
+ useFullPathHash?: boolean;
87
+ }) {
88
+ return hack_setPackedPathSuffix(config.path, `${config.startFraction}|${config.endFraction}|${config.useFullPathHash ? "F" : ""}`);
89
+ }
90
+ export function decodeParentFilter(path: string): { path: string; start: number, end: number, useFullPathHash?: boolean } | undefined {
91
+ let packedSuffix = hack_getPackedPathSuffix(path);
92
+ if (!packedSuffix) return undefined;
93
+ let [startStr, endStr, useFullPathHash] = packedSuffix.split("|");
94
+ let unpackedPath = hack_stripPackedPath(path);
95
+ return { path: unpackedPath, start: Number(startStr), end: Number(endStr), useFullPathHash: !!useFullPathHash };
96
+
97
+ }