@gmickel/gno 2.14.0 → 2.16.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.
- package/README.md +1 -1
- package/assets/skill/cli-reference.md +4 -2
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.14.0.zip → gno-browser-clipper-v2.16.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.16.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +88 -45
- package/spec/db/schema.sql +45 -0
- package/spec/output-schemas/embed-receipt.schema.json +89 -0
- package/src/cli/commands/agents/commands.ts +1 -1
- package/src/cli/commands/ask.ts +1 -1
- package/src/cli/commands/context-build.ts +1 -1
- package/src/cli/commands/embed.ts +341 -20
- package/src/cli/commands/links.ts +1 -1
- package/src/cli/commands/mcp/install.ts +2 -2
- package/src/cli/commands/mcp/status.ts +1 -1
- package/src/cli/commands/mcp/uninstall.ts +1 -1
- package/src/cli/commands/query.ts +1 -1
- package/src/cli/commands/shared.ts +4 -4
- package/src/cli/commands/skill/install.ts +1 -1
- package/src/cli/commands/skill/paths-cmd.ts +1 -1
- package/src/cli/commands/skill/uninstall.ts +1 -1
- package/src/cli/commands/status.ts +75 -58
- package/src/cli/config-cache.ts +86 -0
- package/src/cli/globals.ts +64 -0
- package/src/cli/options.ts +23 -0
- package/src/cli/program.ts +44 -37
- package/src/cli/run.ts +121 -67
- package/src/cli/runtime-health.ts +132 -122
- package/src/cli/session-binding.ts +11 -2
- package/src/config/saver.ts +8 -0
- package/src/converters/adapters/browser-export/formats.ts +25 -15
- package/src/converters/adapters/email/adapter.ts +37 -53
- package/src/converters/adapters/email/html.ts +37 -20
- package/src/converters/adapters/email/mime.ts +71 -39
- package/src/converters/adapters/ical/adapter.ts +20 -12
- package/src/converters/adapters/jsonl/adapter.ts +8 -6
- package/src/converters/adapters/shared/html-text.ts +55 -37
- package/src/converters/adapters/shared/ooxml-protection.ts +5 -13
- package/src/converters/adapters/shared/utf8-lines.ts +69 -31
- package/src/converters/adapters/transcript/adapter.ts +12 -7
- package/src/converters/adapters/xlsx/adapter.ts +10 -7
- package/src/converters/adapters/xlsx/sheet-markdown.ts +93 -50
- package/src/converters/canonicalize.ts +17 -3
- package/src/converters/native/markdown.ts +24 -17
- package/src/converters/native/plaintext.ts +5 -6
- package/src/converters/registry.ts +130 -8
- package/src/core/activation-status.ts +4 -8
- package/src/core/change-diff.ts +38 -11
- package/src/core/context-compiler.ts +17 -18
- package/src/core/context-evidence.ts +116 -25
- package/src/core/context-verifier.ts +70 -31
- package/src/core/file-lock.ts +10 -2
- package/src/core/graph-analysis.ts +3 -3
- package/src/core/link-inventory-markdown.ts +2 -2
- package/src/core/links.ts +20 -87
- package/src/core/memory-fence.ts +16 -9
- package/src/core/memory-recall.ts +168 -34
- package/src/core/path-rules.ts +143 -0
- package/src/core/section-parse.ts +16 -6
- package/src/core/typed-metadata.ts +68 -0
- package/src/core/wiki-link-syntax.ts +88 -0
- package/src/embed/backlog.ts +173 -60
- package/src/embed/batch.ts +83 -12
- package/src/embed/resume-cursor.ts +103 -0
- package/src/embed/retry.ts +41 -32
- package/src/embed/variant-backlog.ts +697 -63
- package/src/embed/variant-plan.ts +41 -45
- package/src/embed/variant-retry.ts +157 -44
- package/src/index.ts +3 -3
- package/src/ingestion/budget-error-codes.ts +13 -0
- package/src/ingestion/chunker.ts +60 -49
- package/src/ingestion/compiled-context.ts +4 -5
- package/src/ingestion/convert-file.ts +1 -1
- package/src/ingestion/document-metadata.ts +16 -9
- package/src/ingestion/excluded-ranges.ts +97 -0
- package/src/ingestion/file-processor.ts +122 -37
- package/src/ingestion/frontmatter.ts +35 -7
- package/src/ingestion/graph-reconciliation.ts +187 -51
- package/src/ingestion/language.ts +66 -61
- package/src/ingestion/position.ts +5 -5
- package/src/ingestion/prepare-file.ts +50 -29
- package/src/ingestion/record-adapter-canonical.ts +37 -26
- package/src/ingestion/record-adapter.ts +46 -26
- package/src/ingestion/record-container.ts +121 -53
- package/src/ingestion/record-path.ts +5 -2
- package/src/ingestion/source-availability/darwin-io.ts +10 -7
- package/src/ingestion/source-availability/darwin-path.ts +21 -3
- package/src/ingestion/source-availability/readers.ts +51 -0
- package/src/ingestion/strip.ts +39 -105
- package/src/ingestion/sync.ts +692 -386
- package/src/ingestion/typed-metadata.ts +10 -4
- package/src/ingestion/walker.ts +485 -158
- package/src/llm/cache.ts +128 -84
- package/src/llm/http-inference.ts +112 -35
- package/src/llm/http-policy.ts +101 -0
- package/src/llm/httpEmbedding.ts +8 -1
- package/src/llm/httpGeneration.ts +5 -1
- package/src/llm/httpRerank.ts +5 -1
- package/src/llm/inference-scope.ts +15 -2
- package/src/llm/lazy-ports.ts +33 -3
- package/src/llm/lockfile.ts +34 -7
- package/src/llm/model-cleanup.ts +24 -0
- package/src/llm/native-worker/client.ts +23 -12
- package/src/llm/native-worker/dispatcher.ts +19 -9
- package/src/llm/native-worker/embedding-identity.ts +42 -16
- package/src/llm/native-worker/entry.ts +2 -1
- package/src/llm/native-worker/owner.ts +1 -0
- package/src/llm/native-worker/ports.ts +86 -23
- package/src/llm/native-worker/protocol.ts +386 -55
- package/src/llm/nodeLlamaCpp/adapter.ts +46 -29
- package/src/llm/nodeLlamaCpp/embedding.ts +93 -40
- package/src/llm/nodeLlamaCpp/generation.ts +194 -30
- package/src/llm/nodeLlamaCpp/lifecycle.ts +2 -0
- package/src/llm/nodeLlamaCpp/rerank-capacity.ts +101 -23
- package/src/llm/nodeLlamaCpp/rerank.ts +253 -44
- package/src/llm/types.ts +14 -0
- package/src/mcp/context.ts +342 -23
- package/src/mcp/http-transport.ts +21 -3
- package/src/mcp/tool-profile-types.ts +62 -0
- package/src/mcp/tool-profile.ts +32 -56
- package/src/mcp/tools/context.ts +5 -1
- package/src/mcp/tools/index.ts +269 -191
- package/src/mcp/tools/links.ts +7 -5
- package/src/mcp/tools/query.ts +60 -37
- package/src/mcp/tools/vsearch.ts +25 -14
- package/src/pipeline/answer.ts +133 -40
- package/src/pipeline/claim-verification.ts +293 -189
- package/src/pipeline/claim-verifier.ts +6 -7
- package/src/pipeline/egress-lineage.ts +37 -26
- package/src/pipeline/exclude.ts +34 -11
- package/src/pipeline/expansion.ts +233 -19
- package/src/pipeline/filters.ts +169 -33
- package/src/pipeline/graph-retrieval.ts +117 -61
- package/src/pipeline/hybrid.ts +598 -329
- package/src/pipeline/hydration.ts +86 -24
- package/src/pipeline/intent.ts +15 -7
- package/src/pipeline/owner-fusion.ts +61 -19
- package/src/pipeline/query-language.ts +15 -2
- package/src/pipeline/rerank.ts +15 -22
- package/src/pipeline/search.ts +193 -72
- package/src/pipeline/snippet.ts +15 -2
- package/src/pipeline/temporal.ts +51 -10
- package/src/pipeline/vsearch.ts +250 -152
- package/src/publish/attachment-raster.ts +2 -16
- package/src/publish/encrypted-export.ts +15 -5
- package/src/serve/browse-tree.ts +50 -42
- package/src/serve/connectors.ts +2 -1
- package/src/serve/context.ts +13 -4
- package/src/serve/doc-events.ts +3 -0
- package/src/serve/public/app.tsx +49 -21
- package/src/serve/public/components/BrowseTreeSidebar.tsx +163 -23
- package/src/serve/public/components/CaptureModal.tsx +14 -10
- package/src/serve/public/components/ai-elements/code-block.tsx +87 -50
- package/src/serve/public/components/editor/MarkdownPreview.tsx +99 -67
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/globals.css +19 -0
- package/src/serve/public/hooks/useCaptureModal.tsx +23 -10
- package/src/serve/public/lib/metadata-filter.ts +234 -9
- package/src/serve/public/pages/Browse.tsx +61 -27
- package/src/serve/public/pages/DocView.tsx +44 -25
- package/src/serve/public/pages/GraphView.tsx +8 -3
- package/src/serve/resident-runtime.ts +199 -48
- package/src/serve/routes/api.ts +98 -67
- package/src/serve/routes/links.ts +18 -4
- package/src/serve/server.ts +1370 -1180
- package/src/serve/spa-bundle-source.ts +52 -27
- package/src/serve/status.ts +101 -52
- package/src/serve/watch-reconciliation-fallback.ts +11 -7
- package/src/serve/watch-reconciliation-shared.ts +42 -4
- package/src/serve/watch-reconciliation.ts +21 -8
- package/src/serve/watch-service-events.ts +7 -1
- package/src/serve/watch-service-hosts.ts +3 -1
- package/src/serve/watch-service.ts +46 -21
- package/src/serve/watch-snapshot-scan.ts +6 -15
- package/src/sessions/archive.ts +20 -8
- package/src/sessions/sanitize.ts +38 -18
- package/src/sessions/service.ts +180 -102
- package/src/store/migrations/036-vector-mirror-state.ts +83 -0
- package/src/store/migrations/037-performance-indexes.ts +56 -0
- package/src/store/migrations/index.ts +4 -0
- package/src/store/sqlite/adapter.ts +1217 -651
- package/src/store/sqlite/chunking-policy.ts +15 -1
- package/src/store/sqlite/eligibility.ts +110 -70
- package/src/store/sqlite/graph-neighbors.ts +71 -46
- package/src/store/sqlite/graph-reference-state.ts +27 -3
- package/src/store/sqlite/graph-similarity.ts +59 -12
- package/src/store/sqlite/metadata-predicate.ts +123 -28
- package/src/store/sqlite/retrieval-trace-management-store.ts +126 -33
- package/src/store/sqlite/retrieval-trace-retention.ts +88 -76
- package/src/store/sqlite/retrieval-trace-rows.ts +7 -3
- package/src/store/types.ts +32 -0
- package/src/store/vector/eligibility.ts +39 -0
- package/src/store/vector/lazy.ts +17 -0
- package/src/store/vector/partition-index.ts +49 -47
- package/src/store/vector/proof-cache.ts +103 -0
- package/src/store/vector/sqlite-vec.ts +230 -139
- package/src/store/vector/stats.ts +29 -73
- package/src/store/vector/status.ts +151 -52
- package/src/store/vector/stored-vectors.ts +131 -45
- package/src/store/vector/types.ts +10 -0
- package/src/store/vector/variant-search.ts +771 -109
- package/src/store/vector/variants.ts +785 -144
- package/browser-extension/artifacts/gno-browser-clipper-v2.14.0.zip.sha256 +0 -1
|
@@ -61,43 +61,68 @@ export async function createSpaBundleSource(
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
return createSplitProductionSource(entryPath
|
|
64
|
+
return createSplitProductionSource(entryPath);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
async function createSplitProductionSource(
|
|
68
|
-
entryPath: string
|
|
69
|
-
nonce: string
|
|
68
|
+
entryPath: string
|
|
70
69
|
): Promise<SpaBundleSource> {
|
|
71
70
|
const assets = await getProductionSpaAssets();
|
|
72
|
-
return
|
|
71
|
+
return createInProcessProductionSource(assets, entryPath);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Serve pre-built in-memory production SPA assets directly in-process without
|
|
76
|
+
* spawning a second Bun.serve() or Unix-domain socket proxy hop.
|
|
77
|
+
*/
|
|
78
|
+
function createInProcessProductionSource(
|
|
76
79
|
assets: ProductionSpaAssets,
|
|
77
|
-
entryPath: string
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const file = assets.files[pathname];
|
|
87
|
-
if (!file) {
|
|
88
|
-
return notFound();
|
|
89
|
-
}
|
|
90
|
-
return new Response(file.text, {
|
|
91
|
-
headers: { "Content-Type": file.type },
|
|
92
|
-
});
|
|
93
|
-
};
|
|
80
|
+
entryPath: string
|
|
81
|
+
): SpaBundleSource {
|
|
82
|
+
const encoder = new TextEncoder();
|
|
83
|
+
const htmlBytes = encoder.encode(assets.html);
|
|
84
|
+
const htmlEtag = `W/"${Bun.hash(htmlBytes).toString(16)}"`;
|
|
85
|
+
const encodedFiles = new Map<
|
|
86
|
+
string,
|
|
87
|
+
{ bytes: Uint8Array<ArrayBuffer>; type: string }
|
|
88
|
+
>();
|
|
94
89
|
|
|
95
|
-
return
|
|
90
|
+
return {
|
|
96
91
|
entryPath,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
close: async (): Promise<void> => {},
|
|
93
|
+
fetch: async (request: Request): Promise<Response> => {
|
|
94
|
+
const pathname = new URL(request.url).pathname;
|
|
95
|
+
const isHead = request.method === "HEAD";
|
|
96
|
+
if (pathname === entryPath) {
|
|
97
|
+
return new Response(isHead ? null : htmlBytes, {
|
|
98
|
+
headers: {
|
|
99
|
+
"Content-Type": "text/html;charset=utf-8",
|
|
100
|
+
"Content-Length": String(htmlBytes.byteLength),
|
|
101
|
+
ETag: htmlEtag,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const file = assets.files[pathname];
|
|
106
|
+
if (!file) {
|
|
107
|
+
return notFound();
|
|
108
|
+
}
|
|
109
|
+
let cached = encodedFiles.get(pathname);
|
|
110
|
+
if (!cached) {
|
|
111
|
+
const raw = encoder.encode(file.text);
|
|
112
|
+
// Copy into a guaranteed ArrayBuffer-backed view for BodyInit.
|
|
113
|
+
const bytes = new Uint8Array(raw.byteLength);
|
|
114
|
+
bytes.set(raw);
|
|
115
|
+
cached = { bytes, type: file.type };
|
|
116
|
+
encodedFiles.set(pathname, cached);
|
|
117
|
+
}
|
|
118
|
+
return new Response(isHead ? null : cached.bytes, {
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": cached.type,
|
|
121
|
+
"Content-Length": String(cached.bytes.byteLength),
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
};
|
|
101
126
|
}
|
|
102
127
|
|
|
103
128
|
async function hostPrivateSource(options: {
|
package/src/serve/status.ts
CHANGED
|
@@ -166,20 +166,24 @@ async function inspectDisk(path: string): Promise<DiskSnapshot | null> {
|
|
|
166
166
|
|
|
167
167
|
async function listSuggestedCollections(): Promise<SuggestedCollection[]> {
|
|
168
168
|
const home = homedir();
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
169
|
+
const checked = await Promise.all(
|
|
170
|
+
SUGGESTED_FOLDERS.map(
|
|
171
|
+
async (candidate): Promise<SuggestedCollection | null> => {
|
|
172
|
+
const path = join(home, candidate.suffix);
|
|
173
|
+
return (await pathExists(path))
|
|
174
|
+
? {
|
|
175
|
+
label: candidate.label,
|
|
176
|
+
path,
|
|
177
|
+
reason: candidate.reason,
|
|
178
|
+
}
|
|
179
|
+
: null;
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
);
|
|
181
183
|
|
|
182
|
-
return
|
|
184
|
+
return checked
|
|
185
|
+
.filter((item): item is SuggestedCollection => item !== null)
|
|
186
|
+
.slice(0, 4);
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
function getCheckState(checks: HealthCheck[]): HealthCenterState["state"] {
|
|
@@ -343,20 +347,69 @@ function buildIndexingCheck(status: IndexStatus): HealthCheck {
|
|
|
343
347
|
};
|
|
344
348
|
}
|
|
345
349
|
|
|
346
|
-
|
|
350
|
+
interface ModelInspectionSnapshot {
|
|
351
|
+
cacheDir: string;
|
|
352
|
+
entries: Awaited<ReturnType<ModelCache["list"]>>;
|
|
353
|
+
totalSizeBytes: number;
|
|
354
|
+
cachedPathByUri: ReadonlyMap<string, string | null>;
|
|
355
|
+
isCachedByUri: ReadonlyMap<string, boolean>;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Inspect model cache once per buildAppStatus call: read manifest.json once and
|
|
360
|
+
* validate each unique preset URI once in parallel instead of instantiating
|
|
361
|
+
* multiple ModelCaches and validating the same GGUFs repeatedly.
|
|
362
|
+
*/
|
|
363
|
+
async function inspectPresetModelsOnce(
|
|
347
364
|
ctx: ServerContext,
|
|
348
365
|
deps: StatusBuildDeps
|
|
349
|
-
): Promise<
|
|
366
|
+
): Promise<ModelInspectionSnapshot> {
|
|
350
367
|
const preset = getActivePreset(ctx.config);
|
|
351
368
|
const cache = new ModelCache(getModelsCachePath());
|
|
352
|
-
const
|
|
353
|
-
|
|
369
|
+
const uniqueUris = [
|
|
370
|
+
...new Set([
|
|
371
|
+
preset.embed,
|
|
372
|
+
preset.rerank,
|
|
373
|
+
preset.expand ?? preset.gen,
|
|
374
|
+
preset.gen,
|
|
375
|
+
]),
|
|
376
|
+
];
|
|
354
377
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
378
|
+
// Read manifest.json once (populates cache's internal manifest).
|
|
379
|
+
const entries = await cache.list();
|
|
380
|
+
const totalSizeBytes = entries.reduce((sum, m) => sum + (m.size || 0), 0);
|
|
381
|
+
|
|
382
|
+
const cachedPathByUri = new Map<string, string | null>();
|
|
383
|
+
const isCachedByUri = new Map<string, boolean>();
|
|
384
|
+
|
|
385
|
+
await Promise.all(
|
|
386
|
+
uniqueUris.map(async (uri) => {
|
|
387
|
+
const path = await cache.getCachedPath(uri);
|
|
388
|
+
cachedPathByUri.set(uri, path);
|
|
389
|
+
const cached = deps.isModelCached
|
|
390
|
+
? await deps.isModelCached(uri)
|
|
391
|
+
: path !== null;
|
|
392
|
+
isCachedByUri.set(uri, cached);
|
|
393
|
+
})
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
return {
|
|
397
|
+
cacheDir: cache.dir,
|
|
398
|
+
entries,
|
|
399
|
+
totalSizeBytes,
|
|
400
|
+
cachedPathByUri,
|
|
401
|
+
isCachedByUri,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function buildModelCheck(
|
|
406
|
+
ctx: ServerContext,
|
|
407
|
+
inspection: ModelInspectionSnapshot
|
|
408
|
+
): HealthCheck {
|
|
409
|
+
const preset = getActivePreset(ctx.config);
|
|
410
|
+
const embedCached = inspection.isCachedByUri.get(preset.embed) ?? false;
|
|
411
|
+
const rerankCached = inspection.isCachedByUri.get(preset.rerank) ?? false;
|
|
412
|
+
const genCached = inspection.isCachedByUri.get(preset.gen) ?? false;
|
|
360
413
|
|
|
361
414
|
if (downloadState.active) {
|
|
362
415
|
return {
|
|
@@ -492,12 +545,14 @@ async function buildDiskCheck(
|
|
|
492
545
|
};
|
|
493
546
|
}
|
|
494
547
|
|
|
495
|
-
|
|
496
|
-
ctx: ServerContext
|
|
497
|
-
|
|
548
|
+
function buildBootstrapState(
|
|
549
|
+
ctx: ServerContext,
|
|
550
|
+
inspection: ModelInspectionSnapshot
|
|
551
|
+
): AppStatusResponse["bootstrap"] {
|
|
498
552
|
const preset = getActivePreset(ctx.config);
|
|
499
|
-
const
|
|
500
|
-
|
|
553
|
+
const entryByUri = new Map(
|
|
554
|
+
inspection.entries.map((entry) => [entry.uri, entry] as const)
|
|
555
|
+
);
|
|
501
556
|
const policy = resolveDownloadPolicy(process.env, {});
|
|
502
557
|
const policySource = resolvePolicySource(process.env);
|
|
503
558
|
const roleUris = [
|
|
@@ -507,24 +562,22 @@ async function buildBootstrapState(
|
|
|
507
562
|
{ role: "gen" as const, uri: preset.gen },
|
|
508
563
|
];
|
|
509
564
|
|
|
510
|
-
const modelEntries =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
})
|
|
523
|
-
);
|
|
565
|
+
const modelEntries = roleUris.map(({ role, uri }) => {
|
|
566
|
+
const path = inspection.cachedPathByUri.get(uri) ?? null;
|
|
567
|
+
const entry = entryByUri.get(uri);
|
|
568
|
+
return {
|
|
569
|
+
role,
|
|
570
|
+
uri,
|
|
571
|
+
cached: path !== null,
|
|
572
|
+
path,
|
|
573
|
+
sizeBytes: entry?.size ?? null,
|
|
574
|
+
statusLabel: path !== null ? "Ready" : "Needs download",
|
|
575
|
+
};
|
|
576
|
+
});
|
|
524
577
|
|
|
525
578
|
const cachedCount = modelEntries.filter((entry) => entry.cached).length;
|
|
526
579
|
const totalCount = modelEntries.length;
|
|
527
|
-
const totalSizeBytes =
|
|
580
|
+
const totalSizeBytes = inspection.totalSizeBytes;
|
|
528
581
|
|
|
529
582
|
const policySummary = policy.offline
|
|
530
583
|
? "Offline mode. Cached models only."
|
|
@@ -551,7 +604,7 @@ async function buildBootstrapState(
|
|
|
551
604
|
summary: policySummary,
|
|
552
605
|
},
|
|
553
606
|
cache: {
|
|
554
|
-
path:
|
|
607
|
+
path: inspection.cacheDir,
|
|
555
608
|
totalSizeBytes,
|
|
556
609
|
totalSizeLabel: formatBytes(totalSizeBytes),
|
|
557
610
|
},
|
|
@@ -701,26 +754,22 @@ export async function buildAppStatus(
|
|
|
701
754
|
|
|
702
755
|
const status = result.value;
|
|
703
756
|
const preset = getActivePreset(ctx.config);
|
|
704
|
-
const cache = new ModelCache(getModelsCachePath());
|
|
705
|
-
const isModelCached =
|
|
706
|
-
deps.isModelCached ?? ((uri: string) => cache.isCached(uri));
|
|
707
757
|
const [
|
|
708
|
-
|
|
758
|
+
modelInspection,
|
|
709
759
|
diskCheck,
|
|
710
760
|
suggestions,
|
|
711
|
-
bootstrap,
|
|
712
|
-
embedCached,
|
|
713
761
|
connectorTargets,
|
|
714
762
|
rootErrors,
|
|
715
763
|
] = await Promise.all([
|
|
716
|
-
|
|
764
|
+
inspectPresetModelsOnce(ctx, deps),
|
|
717
765
|
buildDiskCheck(status, deps),
|
|
718
766
|
deps.listSuggestedCollections?.() ?? listSuggestedCollections(),
|
|
719
|
-
buildBootstrapState(ctx),
|
|
720
|
-
isModelCached(preset.embed),
|
|
721
767
|
(deps.listConnectorTargets ?? getConnectorVerificationTargets)(),
|
|
722
768
|
checkCollectionRoots(ctx.config.collections),
|
|
723
769
|
]);
|
|
770
|
+
const modelCheck = buildModelCheck(ctx, modelInspection);
|
|
771
|
+
const bootstrap = buildBootstrapState(ctx, modelInspection);
|
|
772
|
+
const embedCached = modelInspection.isCachedByUri.get(preset.embed) ?? false;
|
|
724
773
|
const activation = await (deps.buildActivation ?? buildActivationStatus)(
|
|
725
774
|
ctx.store,
|
|
726
775
|
ctx.config.collections.map(({ name }) => name),
|
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
type FallbackBudget,
|
|
32
32
|
} from "./watch-reconciliation-fallback-disk";
|
|
33
33
|
import {
|
|
34
|
+
mapWithBoundedConcurrency,
|
|
34
35
|
WATCHER_FALLBACK_BUDGET,
|
|
36
|
+
WATCHER_PRESENCE_CONCURRENCY,
|
|
35
37
|
type ClassificationResult,
|
|
36
38
|
} from "./watch-reconciliation-shared";
|
|
37
39
|
import { openDirByRel } from "./watch-snapshot-scan";
|
|
@@ -207,14 +209,16 @@ export async function fallbackClassifyDirtyHints(options: {
|
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
const removalPaths = [...removals];
|
|
213
|
+
const removalPresences = await mapWithBoundedConcurrency(
|
|
214
|
+
removalPaths,
|
|
215
|
+
WATCHER_PRESENCE_CONCURRENCY,
|
|
216
|
+
(path) => inspectNoFollowPresence(root, path, fs, directoryAvailability)
|
|
217
|
+
);
|
|
210
218
|
const provenRemovals: string[] = [];
|
|
211
|
-
for (
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
path,
|
|
215
|
-
fs,
|
|
216
|
-
directoryAvailability
|
|
217
|
-
);
|
|
219
|
+
for (let i = 0; i < removalPaths.length; i += 1) {
|
|
220
|
+
const path = removalPaths[i]!;
|
|
221
|
+
const presence = removalPresences[i]!;
|
|
218
222
|
if (presence.status === "missing") {
|
|
219
223
|
provenRemovals.push(path);
|
|
220
224
|
} else if (presence.status === "present") {
|
|
@@ -149,7 +149,8 @@ export function failedSyncPaths(
|
|
|
149
149
|
*/
|
|
150
150
|
export function classifyWatcherFilename(
|
|
151
151
|
filename: string | Buffer | null | undefined,
|
|
152
|
-
collection: Collection
|
|
152
|
+
collection: Collection,
|
|
153
|
+
cachedWalkConfig?: ReturnType<typeof collectionToWalkConfig>
|
|
153
154
|
): WatcherEventClassification {
|
|
154
155
|
if (filename === null || filename === undefined) {
|
|
155
156
|
return { kind: "dirty", hint: "" };
|
|
@@ -164,7 +165,7 @@ export function classifyWatcherFilename(
|
|
|
164
165
|
return { kind: "reject" };
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
const walkConfig = collectionToWalkConfig(collection, 0);
|
|
168
|
+
const walkConfig = cachedWalkConfig ?? collectionToWalkConfig(collection, 0);
|
|
168
169
|
if (
|
|
169
170
|
relPath !== "" &&
|
|
170
171
|
matchesCollectionExclusion(relPath, walkConfig.exclude)
|
|
@@ -289,6 +290,37 @@ export async function inspectPathPresence(
|
|
|
289
290
|
* - Uncertain lstat failures never stay exact-only (avoids NOT_FILE loops);
|
|
290
291
|
* they dirty + force fallback for durable reclassification.
|
|
291
292
|
*/
|
|
293
|
+
/** Bounded concurrency for watcher presence/lstat loops. */
|
|
294
|
+
export const WATCHER_PRESENCE_CONCURRENCY = 32;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Run an async mapper over `items` with bounded concurrency while preserving
|
|
298
|
+
* deterministic input order.
|
|
299
|
+
*/
|
|
300
|
+
export async function mapWithBoundedConcurrency<T, R>(
|
|
301
|
+
items: readonly T[],
|
|
302
|
+
concurrency: number,
|
|
303
|
+
worker: (item: T, index: number) => Promise<R>
|
|
304
|
+
): Promise<R[]> {
|
|
305
|
+
if (items.length === 0) {
|
|
306
|
+
return [];
|
|
307
|
+
}
|
|
308
|
+
const results = Array.from<R>({ length: items.length });
|
|
309
|
+
const limit = Math.max(1, Math.min(concurrency, items.length));
|
|
310
|
+
let cursor = 0;
|
|
311
|
+
|
|
312
|
+
await Promise.all(
|
|
313
|
+
Array.from({ length: limit }, async () => {
|
|
314
|
+
while (cursor < items.length) {
|
|
315
|
+
const index = cursor++;
|
|
316
|
+
results[index] = await worker(items[index]!, index);
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
return results;
|
|
322
|
+
}
|
|
323
|
+
|
|
292
324
|
export async function widenVanishedExactPaths(
|
|
293
325
|
rootAbs: string,
|
|
294
326
|
exactPaths: readonly string[]
|
|
@@ -298,11 +330,17 @@ export async function widenVanishedExactPaths(
|
|
|
298
330
|
/** Non-source present paths (dir/other) or uncertain — force store/disk. */
|
|
299
331
|
directoryDirty: string[];
|
|
300
332
|
}> {
|
|
333
|
+
const presences = await mapWithBoundedConcurrency(
|
|
334
|
+
exactPaths,
|
|
335
|
+
WATCHER_PRESENCE_CONCURRENCY,
|
|
336
|
+
(relPath) => inspectPathPresence(rootAbs, relPath)
|
|
337
|
+
);
|
|
301
338
|
const keepExact: string[] = [];
|
|
302
339
|
const extraDirty: string[] = [];
|
|
303
340
|
const directoryDirty: string[] = [];
|
|
304
|
-
for (
|
|
305
|
-
const
|
|
341
|
+
for (let i = 0; i < exactPaths.length; i += 1) {
|
|
342
|
+
const relPath = exactPaths[i]!;
|
|
343
|
+
const presence = presences[i]!;
|
|
306
344
|
if (presence.status === "error") {
|
|
307
345
|
// Uncertainty: durable dirty/full path — never exact NOT_FILE churn.
|
|
308
346
|
extraDirty.push(relPath);
|
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
} from "./watch-reconciliation-fallback-disk";
|
|
20
20
|
import {
|
|
21
21
|
filterEligiblePaths,
|
|
22
|
+
mapWithBoundedConcurrency,
|
|
23
|
+
WATCHER_PRESENCE_CONCURRENCY,
|
|
22
24
|
type ClassificationResult,
|
|
23
25
|
} from "./watch-reconciliation-shared";
|
|
24
26
|
import {
|
|
@@ -134,7 +136,7 @@ async function storeOnlyRemovals(options: {
|
|
|
134
136
|
|
|
135
137
|
const unproven = [...(next?.unprovenSubtrees ?? [])];
|
|
136
138
|
const fs = options.snapshotOptions?.fs ?? fallbackFs();
|
|
137
|
-
const
|
|
139
|
+
const candidatesToProbe: string[] = [];
|
|
138
140
|
for (const path of storePaths) {
|
|
139
141
|
if (relPathUnderAnyPrefix(path, unproven)) continue;
|
|
140
142
|
const slash = path.lastIndexOf("/");
|
|
@@ -143,17 +145,28 @@ async function storeOnlyRemovals(options: {
|
|
|
143
145
|
.get(parent)
|
|
144
146
|
?.get(path.slice(slash + 1))?.kind;
|
|
145
147
|
if (kind === "file" || kind === "symlink") continue;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
candidatesToProbe.push(path);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const presences = await mapWithBoundedConcurrency(
|
|
152
|
+
candidatesToProbe,
|
|
153
|
+
WATCHER_PRESENCE_CONCURRENCY,
|
|
154
|
+
(path) =>
|
|
155
|
+
inspectNoFollowPresence(
|
|
156
|
+
rootAbs,
|
|
157
|
+
path,
|
|
158
|
+
fs,
|
|
159
|
+
options.snapshotOptions?.directoryAvailability
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
const removals: string[] = [];
|
|
163
|
+
for (let i = 0; i < candidatesToProbe.length; i += 1) {
|
|
164
|
+
const presence = presences[i]!;
|
|
152
165
|
if (presence.status === "error") {
|
|
153
166
|
return { status: "error", cause: presence.cause, stage: "scan" };
|
|
154
167
|
}
|
|
155
168
|
if (presence.status === "missing" || !presence.indexable) {
|
|
156
|
-
removals.push(
|
|
169
|
+
removals.push(candidatesToProbe[i]!);
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
172
|
return { status: "ok", paths: removals };
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { join, normalize } from "node:path";
|
|
9
9
|
|
|
10
10
|
import type { Collection } from "../config/types";
|
|
11
|
+
import type { WalkConfig } from "../ingestion";
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
14
|
WATCHER_FLUSH_DEBOUNCE_MS,
|
|
@@ -34,6 +35,7 @@ export type WatcherRetryKind = "backoff" | "fixed";
|
|
|
34
35
|
export interface WatchEventHost {
|
|
35
36
|
disposed: () => boolean;
|
|
36
37
|
findCollection: (collectionName: string) => Collection | undefined;
|
|
38
|
+
getWalkConfig?: (collectionName: string) => WalkConfig | undefined;
|
|
37
39
|
clock: () => number;
|
|
38
40
|
suppressedPaths: Map<string, number>;
|
|
39
41
|
setLastEventAt: (iso: string) => void;
|
|
@@ -77,7 +79,11 @@ export function handleWatchEvent(
|
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
const classified = classifyWatcherFilename(
|
|
82
|
+
const classified = classifyWatcherFilename(
|
|
83
|
+
filename,
|
|
84
|
+
currentCollection,
|
|
85
|
+
host.getWalkConfig?.(collectionName)
|
|
86
|
+
);
|
|
81
87
|
if (classified.kind === "reject" || classified.kind === "ignore") {
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { FSWatcher } from "node:fs";
|
|
8
8
|
|
|
9
9
|
import type { Collection } from "../config/types";
|
|
10
|
-
import type { SyncOptions } from "../ingestion";
|
|
10
|
+
import type { SyncOptions, WalkConfig } from "../ingestion";
|
|
11
11
|
import type {
|
|
12
12
|
WatchEventHost,
|
|
13
13
|
WatchQueueHost,
|
|
@@ -39,6 +39,7 @@ export interface WatchServiceHostState {
|
|
|
39
39
|
watchFactory: WatchLifecycleHost["watchFactory"];
|
|
40
40
|
onWatchEvent: WatchLifecycleHost["onWatchEvent"];
|
|
41
41
|
findCollection: (collectionName: string) => Collection | undefined;
|
|
42
|
+
getWalkConfig?: (collectionName: string) => WalkConfig | undefined;
|
|
42
43
|
clock: () => number;
|
|
43
44
|
suppressedPaths: Map<string, number>;
|
|
44
45
|
setLastEventAt: (iso: string) => void;
|
|
@@ -90,6 +91,7 @@ export function buildEventHost(state: WatchServiceHostState): WatchEventHost {
|
|
|
90
91
|
return {
|
|
91
92
|
disposed: state.disposed,
|
|
92
93
|
findCollection: state.findCollection,
|
|
94
|
+
getWalkConfig: state.getWalkConfig,
|
|
93
95
|
clock: state.clock,
|
|
94
96
|
suppressedPaths: state.suppressedPaths,
|
|
95
97
|
setLastEventAt: state.setLastEventAt,
|