@gmickel/gno 1.34.5 → 1.35.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 (49) hide show
  1. package/README.md +22 -1
  2. package/browser-extension/artifacts/{gno-browser-clipper-v1.34.5.zip → gno-browser-clipper-v1.35.0.zip} +0 -0
  3. package/browser-extension/artifacts/gno-browser-clipper-v1.35.0.zip.sha256 +1 -0
  4. package/browser-extension/dist/manifest.json +1 -1
  5. package/package.json +4 -1
  6. package/spec/cli.md +43 -0
  7. package/spec/output-schemas/mcp-job-status.schema.json +6 -2
  8. package/src/config/index.ts +4 -0
  9. package/src/config/types.ts +14 -0
  10. package/src/core/path-rules.ts +34 -0
  11. package/src/ingestion/index.ts +21 -0
  12. package/src/ingestion/record-container.ts +23 -1
  13. package/src/ingestion/source-availability/darwin-io.ts +295 -0
  14. package/src/ingestion/source-availability/darwin-path.ts +58 -0
  15. package/src/ingestion/source-availability/directory.ts +402 -0
  16. package/src/ingestion/source-availability/index.ts +74 -0
  17. package/src/ingestion/source-availability/readers.ts +360 -0
  18. package/src/ingestion/source-availability/resolve.ts +28 -0
  19. package/src/ingestion/source-availability/types.ts +170 -0
  20. package/src/ingestion/sync.ts +565 -108
  21. package/src/ingestion/types.ts +45 -3
  22. package/src/ingestion/walker.ts +263 -5
  23. package/src/serve/public/globals.built.css +1 -1
  24. package/src/serve/watch-reconciliation-fallback-disk.ts +359 -0
  25. package/src/serve/watch-reconciliation-fallback.ts +434 -0
  26. package/src/serve/watch-reconciliation-shared.ts +348 -0
  27. package/src/serve/watch-reconciliation.ts +129 -0
  28. package/src/serve/watch-service-events.ts +261 -0
  29. package/src/serve/watch-service-flush-generation.ts +140 -0
  30. package/src/serve/watch-service-flush-helpers.ts +147 -0
  31. package/src/serve/watch-service-flush.ts +443 -0
  32. package/src/serve/watch-service-hosts.ts +109 -0
  33. package/src/serve/watch-service-lifecycle.ts +221 -0
  34. package/src/serve/watch-service-run-flush.ts +236 -0
  35. package/src/serve/watch-service-snapshot.ts +125 -0
  36. package/src/serve/watch-service-state.ts +146 -0
  37. package/src/serve/watch-service.ts +266 -306
  38. package/src/serve/watch-snapshot-availability.ts +51 -0
  39. package/src/serve/watch-snapshot-handles.ts +365 -0
  40. package/src/serve/watch-snapshot-libc.ts +510 -0
  41. package/src/serve/watch-snapshot-ops.ts +541 -0
  42. package/src/serve/watch-snapshot-resolve.ts +246 -0
  43. package/src/serve/watch-snapshot-scan.ts +300 -0
  44. package/src/serve/watch-snapshot-types.ts +392 -0
  45. package/src/serve/watch-snapshot.ts +51 -0
  46. package/src/store/index.ts +1 -1
  47. package/src/store/sqlite/adapter.ts +191 -0
  48. package/src/store/types.ts +66 -0
  49. package/browser-extension/artifacts/gno-browser-clipper-v1.34.5.zip.sha256 +0 -1
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Per-collection pending queues, caps, and flush scheduling helpers.
3
+ *
4
+ * @module src/serve/watch-service-state
5
+ */
6
+
7
+ import {
8
+ WATCHER_MAX_DIRTY_HINTS,
9
+ WATCHER_MAX_EXACT_PATHS,
10
+ WATCHER_MAX_FLUSH_DELAY_MS,
11
+ WATCHER_FLUSH_DEBOUNCE_MS,
12
+ addToCappedSet,
13
+ } from "./watch-reconciliation";
14
+
15
+ export interface CollectionPending {
16
+ exact: Set<string>;
17
+ dirty: Set<string>;
18
+ /** When true, dirty overflow forced a root-wide fallback hint. */
19
+ overflow: boolean;
20
+ /**
21
+ * Ambiguous work arrived before snapshot readiness for this generation.
22
+ * Classification must use store/disk fallback so baseline absorption cannot
23
+ * suppress content-hash of present eligible finals.
24
+ */
25
+ forceFallback: boolean;
26
+ /**
27
+ * Config-generation full reconcile failed or was interrupted; next flush must
28
+ * retry even if exact/dirty event hints are exhausted.
29
+ */
30
+ generationReconcile: boolean;
31
+ }
32
+
33
+ export function emptyPending(): CollectionPending {
34
+ return {
35
+ exact: new Set(),
36
+ dirty: new Set(),
37
+ overflow: false,
38
+ forceFallback: false,
39
+ generationReconcile: false,
40
+ };
41
+ }
42
+
43
+ export function pendingHasWork(
44
+ pending: CollectionPending | undefined
45
+ ): boolean {
46
+ return Boolean(
47
+ pending &&
48
+ (pending.exact.size > 0 ||
49
+ pending.dirty.size > 0 ||
50
+ pending.generationReconcile)
51
+ );
52
+ }
53
+
54
+ export function queueExactPath(
55
+ pending: CollectionPending,
56
+ relPath: string,
57
+ maxExact: number = WATCHER_MAX_EXACT_PATHS
58
+ ): CollectionPending {
59
+ const result = addToCappedSet(pending.exact, relPath, maxExact);
60
+ if (result === "overflow") {
61
+ pending.overflow = true;
62
+ pending.dirty.add("");
63
+ }
64
+ return pending;
65
+ }
66
+
67
+ export function queueDirtyHint(
68
+ pending: CollectionPending,
69
+ hint: string,
70
+ maxDirty: number = WATCHER_MAX_DIRTY_HINTS
71
+ ): CollectionPending {
72
+ const result = addToCappedSet(pending.dirty, hint, maxDirty);
73
+ if (result === "overflow") {
74
+ pending.overflow = true;
75
+ pending.dirty.clear();
76
+ pending.dirty.add("");
77
+ }
78
+ return pending;
79
+ }
80
+
81
+ /** Flags that must survive take → failed flush → requeue. */
82
+ export interface PendingForceFlags {
83
+ forceFallback: boolean;
84
+ overflow: boolean;
85
+ }
86
+
87
+ /** Drain pending work for one flush attempt. */
88
+ export function takePending(pending: CollectionPending): {
89
+ exact: string[];
90
+ dirty: string[];
91
+ forceFallback: boolean;
92
+ overflow: boolean;
93
+ generationReconcile: boolean;
94
+ } {
95
+ return {
96
+ exact: [...pending.exact],
97
+ dirty: pending.overflow ? ["", ...pending.dirty] : [...pending.dirty],
98
+ forceFallback: pending.forceFallback || pending.overflow,
99
+ overflow: pending.overflow,
100
+ generationReconcile: pending.generationReconcile,
101
+ };
102
+ }
103
+
104
+ /** Restore durable force flags after a failed classification/sync attempt. */
105
+ export function applyPendingForceFlags(
106
+ pending: CollectionPending,
107
+ flags: PendingForceFlags | undefined
108
+ ): CollectionPending {
109
+ if (!flags) {
110
+ return pending;
111
+ }
112
+ if (flags.forceFallback) {
113
+ pending.forceFallback = true;
114
+ }
115
+ if (flags.overflow) {
116
+ pending.overflow = true;
117
+ pending.dirty.add("");
118
+ }
119
+ return pending;
120
+ }
121
+
122
+ export interface FlushSchedule {
123
+ delayMs: number;
124
+ deadlineAt: number;
125
+ }
126
+
127
+ /**
128
+ * Compute debounce delay respecting the hard maximum flush deadline.
129
+ * `deadlineAt` is created on the first event of a window and retained until drain.
130
+ */
131
+ export function computeFlushDelay(options: {
132
+ nowMs: number;
133
+ existingDeadlineAt: number | undefined;
134
+ debounceMs?: number;
135
+ maxFlushDelayMs?: number;
136
+ }): FlushSchedule {
137
+ const debounceMs = options.debounceMs ?? WATCHER_FLUSH_DEBOUNCE_MS;
138
+ const maxFlushDelayMs = options.maxFlushDelayMs ?? WATCHER_MAX_FLUSH_DELAY_MS;
139
+ const deadlineAt =
140
+ options.existingDeadlineAt ?? options.nowMs + maxFlushDelayMs;
141
+ const untilDeadline = Math.max(0, deadlineAt - options.nowMs);
142
+ return {
143
+ delayMs: Math.min(debounceMs, untilDeadline),
144
+ deadlineAt,
145
+ };
146
+ }