querysub 0.403.0 → 0.405.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 (108) hide show
  1. package/.cursorrules +2 -0
  2. package/bin/audit-imports.js +4 -0
  3. package/bin/join.js +1 -1
  4. package/package.json +7 -4
  5. package/spec.txt +77 -0
  6. package/src/-a-archives/archiveCache.ts +9 -4
  7. package/src/-a-archives/archivesBackBlaze.ts +1039 -1039
  8. package/src/-a-auth/certs.ts +0 -12
  9. package/src/-c-identity/IdentityController.ts +12 -3
  10. package/src/-f-node-discovery/NodeDiscovery.ts +32 -26
  11. package/src/-g-core-values/NodeCapabilities.ts +12 -2
  12. package/src/0-path-value-core/AuthorityLookup.ts +239 -0
  13. package/src/0-path-value-core/LockWatcher2.ts +150 -0
  14. package/src/0-path-value-core/PathRouter.ts +543 -0
  15. package/src/0-path-value-core/PathRouterRouteOverride.ts +72 -0
  16. package/src/0-path-value-core/PathRouterServerAuthoritySpec.tsx +73 -0
  17. package/src/0-path-value-core/PathValueCommitter.ts +222 -488
  18. package/src/0-path-value-core/PathValueController.ts +277 -239
  19. package/src/0-path-value-core/PathWatcher.ts +534 -0
  20. package/src/0-path-value-core/ShardPrefixes.ts +31 -0
  21. package/src/0-path-value-core/ValidStateComputer.ts +303 -0
  22. package/src/0-path-value-core/archiveLocks/ArchiveLocks.ts +1 -1
  23. package/src/0-path-value-core/archiveLocks/ArchiveLocks2.ts +80 -44
  24. package/src/0-path-value-core/archiveLocks/archiveSnapshots.ts +13 -16
  25. package/src/0-path-value-core/auditLogs.ts +2 -0
  26. package/src/0-path-value-core/hackedPackedPathParentFiltering.ts +97 -0
  27. package/src/0-path-value-core/pathValueArchives.ts +491 -492
  28. package/src/0-path-value-core/pathValueCore.ts +195 -1496
  29. package/src/0-path-value-core/startupAuthority.ts +74 -0
  30. package/src/1-path-client/RemoteWatcher.ts +90 -82
  31. package/src/1-path-client/pathValueClientWatcher.ts +808 -815
  32. package/src/2-proxy/PathValueProxyWatcher.ts +10 -8
  33. package/src/2-proxy/archiveMoveHarness.ts +182 -214
  34. package/src/2-proxy/garbageCollection.ts +9 -8
  35. package/src/2-proxy/schema2.ts +21 -1
  36. package/src/3-path-functions/PathFunctionHelpers.ts +206 -180
  37. package/src/3-path-functions/PathFunctionRunner.ts +943 -766
  38. package/src/3-path-functions/PathFunctionRunnerMain.ts +5 -3
  39. package/src/3-path-functions/pathFunctionLoader.ts +2 -2
  40. package/src/3-path-functions/syncSchema.ts +596 -521
  41. package/src/4-deploy/deployFunctions.ts +19 -4
  42. package/src/4-deploy/deployGetFunctionsInner.ts +8 -2
  43. package/src/4-deploy/deployMain.ts +51 -68
  44. package/src/4-deploy/edgeClientWatcher.tsx +6 -1
  45. package/src/4-deploy/edgeNodes.ts +2 -2
  46. package/src/4-dom/qreact.tsx +2 -4
  47. package/src/4-dom/qreactTest.tsx +7 -13
  48. package/src/4-querysub/Querysub.ts +21 -8
  49. package/src/4-querysub/QuerysubController.ts +45 -29
  50. package/src/4-querysub/permissions.ts +2 -2
  51. package/src/4-querysub/querysubPrediction.ts +80 -70
  52. package/src/4-querysub/schemaHelpers.ts +5 -1
  53. package/src/5-diagnostics/GenericFormat.tsx +14 -9
  54. package/src/archiveapps/archiveGCEntry.tsx +9 -2
  55. package/src/archiveapps/archiveJoinEntry.ts +96 -84
  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 +34 -16
  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 +65 -0
  102. package/test.ts +298 -97
  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/archiveMergeEntry.tsx +0 -48
  108. package/src/archiveapps/lockTest.ts +0 -127
package/.cursorrules CHANGED
@@ -1,5 +1,7 @@
1
1
  The code automatically updates on save, so you do not need to ever run commands to run the site.
2
2
 
3
+ NEVER copy and paste code. Use functions correctly, unless making it a function is more code than not making it a function.
4
+
3
5
  Always directly set the state (this.state.x = 1), and never use setState.
4
6
 
5
7
  Unless schema values use atomic or type they will always be returned as a value (as a proxy). Use "in" to check if a value is in a t.lookup.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ require("typenode");
4
+ require("../src/diagnostics/auditImportViolations");
package/bin/join.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  require("typenode");
4
- require("../src/archiveapps/archiveGCEntry");
4
+ require("../src/archiveapps/archiveJoinEntry");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.403.0",
3
+ "version": "0.405.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -17,7 +17,9 @@
17
17
  "test-wat": "yarn typenode ./src/wat/watCompiler.ts",
18
18
  "error-watch": "yarn typenode ./src/diagnostics/logs/errorNotifications2/errorWatchEntry.ts",
19
19
  "error-email": "yarn typenode ./src/diagnostics/logs/errorNotifications/errorDigestEntry.tsx",
20
- "build-native": "cd src/diagnostics/logs/IndexedLogs && node-gyp rebuild"
20
+ "build-native": "cd src/diagnostics/logs/IndexedLogs && node-gyp rebuild",
21
+ "audit-imports": "yarn typenode ./src/diagnostics/auditImportViolations.ts",
22
+ "test": "yarn typenode ./test.ts"
21
23
  },
22
24
  "bin": {
23
25
  "deploy": "./bin/deploy.js",
@@ -36,7 +38,8 @@
36
38
  "movelogs": "./bin/movelogs.js",
37
39
  "addsuperuser": "./bin/addsuperuser.js",
38
40
  "error-watch": "./bin/error-watch.js",
39
- "error-watch-public": "./bin/error-watch-public.js"
41
+ "error-watch-public": "./bin/error-watch-public.js",
42
+ "audit-imports": "./bin/audit-imports.js"
40
43
  },
41
44
  "dependencies": {
42
45
  "@types/fs-ext": "^2.0.3",
@@ -57,7 +60,7 @@
57
60
  "pako": "^2.1.0",
58
61
  "peggy": "^5.0.6",
59
62
  "querysub": "^0.357.0",
60
- "socket-function": "^1.1.5",
63
+ "socket-function": "^1.1.11",
61
64
  "terser": "^5.31.0",
62
65
  "typesafecss": "^0.28.0",
63
66
  "yaml": "^2.5.0",
package/spec.txt CHANGED
@@ -1,3 +1,80 @@
1
+
2
+
3
+ Trigger values
4
+ 1) validStateComputer.ingestValuesAndValidStates
5
+ 1.5) authorityStorage.ingestValues
6
+ 2) authorityStorage.ingestValues
7
+ 3) lockWatcher2.watchValueLocks
8
+ 4) validStateComputer.computeValidStates
9
+ 5) lockWatcher2.getValuePathWatchers
10
+ 6) pathWatcher.triggerValuesChanged
11
+ 7) pathWatcher.triggerLatestWatcher
12
+ 8) PathValueControllerBase/clientWatcher.localOnValueCallback
13
+
14
+ Source of values
15
+ 1) clientWatcher.setValues
16
+ 2) PathValueCommitter.commitValues
17
+ 3) (predictions) validStateComputer.ingestValuesAndValidStates
18
+ 4) (non-predictions) PathValueControllerBase.createValues
19
+ 5) validStateComputer.ingestValuesAndValidStates
20
+
21
+ Archiving values
22
+ 1) authorityStorage.ingestValues
23
+ 2) pathValueArchives.archiveValues
24
+
25
+ TODO: pathValueAuthority detection
26
+
27
+
28
+ Core parts
29
+ - Valid evaluation
30
+ - Needs external value syncing, which can give it all past values, and all future values for a path
31
+ - Value syncer
32
+ - Needs someone to give it authorities, and tell it when an authority goes down (at which point it finds a new authority and syncs the new values)
33
+ - Authority tracker (supports registering, checking, notifying, and generally synchronizing all authority information between all authorities)
34
+ - No requirements
35
+ - Authority setuper
36
+ - Needs authority tracker
37
+ - Needs value syncer
38
+ - Authority (stitches together functionality)
39
+ - Needs authority tracker
40
+ - Needs authority setuper
41
+ - Needs value syncer
42
+ - Needs valid evaluation
43
+ - Disk value saving/retrieval
44
+
45
+ FunctionRunner is funny. It wants a full history, for reading, but does not calculate the valid states of PathValues.
46
+
47
+
48
+ Optimization / optional features list
49
+ Valid Evaluation
50
+ - Only need to sync some data, not all data.
51
+ - event: sometimes we discard data
52
+ - isTransparent: Sometimes, even though two values are different, they can be considered equivalent.
53
+ - gc: Older values won't change their valid state, so we can discard their locks.
54
+ Value Syncer
55
+ - Path watches
56
+ - Parent path watches
57
+ - Authority path (tree) watches
58
+ - Valid watching (authorities know this, so it's free to also sync this)
59
+ - Only latest/valid state watches (no history, just latest, more efficient)
60
+ - Special connection clobber logic (you can't store the history after you disconnect if you are not the authority)
61
+ - Special logic
62
+ - Reused for internal watches (rendering, etc)
63
+ Authority tracker
64
+ - Immutable authorities, to simplify usages
65
+ - Path requests => authorities might take slices from multiple authorities
66
+ Authority setuper
67
+ - Once on startup, so we don't change authorities, to simplify implementation
68
+ - Leverage disk snapshots to make loading faster and lighter for existing nodes
69
+ Authority
70
+ - The stitching together of all the values is reused by the function runner in order to rerun functions when they are invalidated
71
+ Disk value saving/retrieval
72
+ - Only old values with discarded locks are written, and the history is compressed occasionally
73
+
74
+
75
+
76
+
77
+
1
78
  *** Goal is to get to === Full public website stack milestone === ***
2
79
  === 3 tasks to fully fledged syncing KVP database, 2023 / 25 / 2 ===
3
80
  === 1 tasks to fully fledged syncing KVP database, 2023 / 26 / 2 ===
@@ -4,7 +4,7 @@ import fs from "fs";
4
4
 
5
5
  import { list, nextId, timeInHour, timeInMinute } from "socket-function/src/misc";
6
6
  import { cache, lazy } from "socket-function/src/caching";
7
- import { runInSerial, runInfinitePoll } from "socket-function/src/batching";
7
+ import { runInParallel, runInSerial, runInfinitePoll } from "socket-function/src/batching";
8
8
  import { sha256 } from "js-sha256";
9
9
  import child_process from "child_process";
10
10
  import { getPPID } from "../misc/getParentProcessId";
@@ -13,6 +13,7 @@ import { getArchivesBackblaze } from "./archivesBackBlaze";
13
13
  import { formatNumber } from "socket-function/src/formatting/format";
14
14
  import { SizeLimiter } from "../diagnostics/SizeLimiter";
15
15
  import { isPublic } from "../config";
16
+ import { measureWrap } from "socket-function/src/profiling/measure";
16
17
 
17
18
  const SIZE_LIMIT = new SizeLimiter({
18
19
  diskRoot: getStorageDir(),
@@ -56,7 +57,7 @@ const getDiskMetricsBase = async () => {
56
57
  let usedCacheBytes = 0;
57
58
  let usedCacheFiles = 0;
58
59
  let cacheFiles = await fs.promises.readdir(cacheArchives2);
59
- for (let file of cacheFiles) {
60
+ async function processFile(file: string) {
60
61
  if (file.endsWith(LOCK_SUFFIX)) {
61
62
  let base = file.slice(0, -LOCK_SUFFIX.length);
62
63
  if (!fs.existsSync(base) && !await isLocked(cacheArchives2 + base)) {
@@ -72,7 +73,7 @@ const getDiskMetricsBase = async () => {
72
73
  try {
73
74
  info = await fs.promises.stat(file);
74
75
  } catch { }
75
- if (!info) continue;
76
+ if (!info) return;
76
77
  fileSizes.push({
77
78
  path: file,
78
79
  time: info.atimeMs,
@@ -92,6 +93,8 @@ const getDiskMetricsBase = async () => {
92
93
  }
93
94
  }
94
95
  }
96
+ let processFileParallel = runInParallel({ parallelCount: 32 }, processFile);
97
+ await Promise.all(cacheFiles.map(processFileParallel));
95
98
 
96
99
  let { remove, availableBytes, availableFiles } = await SIZE_LIMIT.limit(fileSizes);
97
100
  for (let file of remove) {
@@ -552,7 +555,9 @@ export function wrapArchivesWithCache(archives: Archives): Archives & {
552
555
  // IMPORTANT. Unwrap, otherwise move will get a get, which might cause our value to be cached again
553
556
  if (cacheArchivesSymbol in config.target) {
554
557
  config = { ...config };
555
- config.target = config.target.getBaseArchives!()!.archives;
558
+ let base = config.target.getBaseArchives!()!;
559
+ config.target = base.archives;
560
+ config.targetPath = base.parentPath + config.targetPath;
556
561
  }
557
562
  await archives.move(config);
558
563
  },