@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
package/src/sessions/service.ts
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from "./archive";
|
|
41
41
|
import { readAutomationStatus } from "./automation-status";
|
|
42
42
|
import { canonicalConfigPath, writeIndexBinding } from "./binding";
|
|
43
|
-
import { redactionStamp, sanitizeValue } from "./sanitize";
|
|
43
|
+
import { redactionStamp, sanitizeValue, ThreadSanitizer } from "./sanitize";
|
|
44
44
|
import {
|
|
45
45
|
archiveCollection,
|
|
46
46
|
protectedRoots,
|
|
@@ -92,6 +92,29 @@ import {
|
|
|
92
92
|
const IMPORT_LOCK_WAIT_MS = 2_000;
|
|
93
93
|
const DISCOVERY_UNIT_LIMIT = 20_000;
|
|
94
94
|
const PATH_SOURCE_PREFIX = "path-";
|
|
95
|
+
const FINGERPRINT_CONCURRENCY = 16;
|
|
96
|
+
|
|
97
|
+
async function mapWithConcurrency<T, R>(
|
|
98
|
+
items: readonly T[],
|
|
99
|
+
concurrency: number,
|
|
100
|
+
worker: (item: T, index: number) => Promise<R>
|
|
101
|
+
): Promise<R[]> {
|
|
102
|
+
if (items.length === 0) return [];
|
|
103
|
+
const results = Array.from<R>({ length: items.length });
|
|
104
|
+
let nextIndex = 0;
|
|
105
|
+
const workerCount = Math.min(concurrency, items.length);
|
|
106
|
+
await Promise.all(
|
|
107
|
+
Array.from({ length: workerCount }, async () => {
|
|
108
|
+
while (true) {
|
|
109
|
+
const index = nextIndex;
|
|
110
|
+
nextIndex += 1;
|
|
111
|
+
if (index >= items.length) return;
|
|
112
|
+
results[index] = await worker(items[index]!, index);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
95
118
|
|
|
96
119
|
export interface SessionsServiceDeps {
|
|
97
120
|
config: Config;
|
|
@@ -349,10 +372,11 @@ export class SessionsService {
|
|
|
349
372
|
collection: source.collection,
|
|
350
373
|
projects: source.projects ?? [],
|
|
351
374
|
});
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
375
|
+
// Bounded batch of stats: status stays responsive without FD spikes.
|
|
376
|
+
const fingerprints = await mapWithConcurrency(
|
|
377
|
+
units,
|
|
378
|
+
FINGERPRINT_CONCURRENCY,
|
|
379
|
+
(unit) => unitFingerprint(unit).catch(() => "")
|
|
356
380
|
);
|
|
357
381
|
for (const [index, unit] of units.entries()) {
|
|
358
382
|
const key = unitKey(source.id, unit.locator);
|
|
@@ -607,6 +631,11 @@ export class SessionsService {
|
|
|
607
631
|
const changed = new Map<string, Set<string>>();
|
|
608
632
|
const excluded = protectedRoots(sessions);
|
|
609
633
|
const redaction = { literals: sessions.redaction?.literals ?? [] };
|
|
634
|
+
const sharedSanitizer = new ThreadSanitizer(redaction);
|
|
635
|
+
const sanitizeLocator = (value: string): string => {
|
|
636
|
+
sharedSanitizer.reset();
|
|
637
|
+
return sharedSanitizer.sanitize(value);
|
|
638
|
+
};
|
|
610
639
|
const stamp = redactionStamp(redaction);
|
|
611
640
|
// Units whose state changed this run; reverted if the index sync fails so
|
|
612
641
|
// completion is only recorded once the archive is searchable.
|
|
@@ -667,9 +696,7 @@ export class SessionsService {
|
|
|
667
696
|
recordUnit({
|
|
668
697
|
sourceId: source.id,
|
|
669
698
|
harness: null,
|
|
670
|
-
locator: selectedFile
|
|
671
|
-
? sanitizeValue(basename(root), redaction)
|
|
672
|
-
: ".",
|
|
699
|
+
locator: selectedFile ? sanitizeLocator(basename(root)) : ".",
|
|
673
700
|
outcome: "unsupported",
|
|
674
701
|
reason: "format_not_recognised",
|
|
675
702
|
threads: 0,
|
|
@@ -713,9 +740,7 @@ export class SessionsService {
|
|
|
713
740
|
sourceId: source.id,
|
|
714
741
|
harness: source.harness,
|
|
715
742
|
locator:
|
|
716
|
-
entry.locator === null
|
|
717
|
-
? "."
|
|
718
|
-
: sanitizeValue(entry.locator, redaction),
|
|
743
|
+
entry.locator === null ? "." : sanitizeLocator(entry.locator),
|
|
719
744
|
outcome: "failed",
|
|
720
745
|
reason: entry.reason,
|
|
721
746
|
threads: 0,
|
|
@@ -725,97 +750,147 @@ export class SessionsService {
|
|
|
725
750
|
}
|
|
726
751
|
const present = new Set<string>();
|
|
727
752
|
const destinations = destinationsStamp(source);
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
locator
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
753
|
+
// Fingerprint in bounded lookahead windows; if an earlier unit in a window
|
|
754
|
+
// is imported (advancing wall-clock time), re-stat a prefetched match before
|
|
755
|
+
// skipping it so live appends to archived sessions are never missed.
|
|
756
|
+
for (
|
|
757
|
+
let windowStart = 0;
|
|
758
|
+
windowStart < enumerated.units.length;
|
|
759
|
+
windowStart += FINGERPRINT_CONCURRENCY
|
|
760
|
+
) {
|
|
761
|
+
const windowUnits = enumerated.units.slice(
|
|
762
|
+
windowStart,
|
|
763
|
+
windowStart + FINGERPRINT_CONCURRENCY
|
|
764
|
+
);
|
|
765
|
+
const fingerprinted = await mapWithConcurrency(
|
|
766
|
+
windowUnits,
|
|
767
|
+
FINGERPRINT_CONCURRENCY,
|
|
768
|
+
async (found) => {
|
|
769
|
+
try {
|
|
770
|
+
return {
|
|
771
|
+
ok: true as const,
|
|
772
|
+
fingerprint: await unitFingerprint(found),
|
|
773
|
+
};
|
|
774
|
+
} catch (error) {
|
|
775
|
+
return { ok: false as const, error };
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
let importedInWindow = false;
|
|
780
|
+
for (let i = 0; i < windowUnits.length; i += 1) {
|
|
781
|
+
const found = windowUnits[i]!;
|
|
782
|
+
const fp = fingerprinted[i]!;
|
|
783
|
+
const key = unitKey(source.id, found.locator);
|
|
784
|
+
if (present.has(key)) {
|
|
785
|
+
// Two units with the same locator would share archive files.
|
|
786
|
+
counts.failed += 1;
|
|
787
|
+
recordUnit({
|
|
788
|
+
sourceId: source.id,
|
|
789
|
+
harness: found.harness,
|
|
790
|
+
locator: sanitizeLocator(found.locator),
|
|
791
|
+
outcome: "failed",
|
|
792
|
+
reason: "unit_conflict",
|
|
793
|
+
threads: 0,
|
|
794
|
+
turns: 0,
|
|
795
|
+
collections: [],
|
|
796
|
+
});
|
|
797
|
+
continue;
|
|
798
|
+
}
|
|
799
|
+
present.add(key);
|
|
800
|
+
if (!fp.ok) {
|
|
801
|
+
counts.failed += 1;
|
|
802
|
+
recordUnit({
|
|
803
|
+
sourceId: source.id,
|
|
804
|
+
harness: found.harness,
|
|
805
|
+
locator: sanitizeLocator(found.locator),
|
|
806
|
+
outcome: "failed",
|
|
807
|
+
reason: unitReason(fp.error),
|
|
808
|
+
threads: 0,
|
|
809
|
+
turns: 0,
|
|
810
|
+
collections: [],
|
|
811
|
+
});
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
let fingerprint = fp.fingerprint;
|
|
815
|
+
const previous = sourceState.units[key];
|
|
816
|
+
let current =
|
|
817
|
+
previous?.status === "complete" &&
|
|
818
|
+
previous.fingerprint === fingerprint &&
|
|
819
|
+
previous.parser ===
|
|
820
|
+
SESSION_PARSERS[previous.harness ?? found.harness] &&
|
|
821
|
+
previous.redaction === stamp &&
|
|
822
|
+
previous.destinations === destinations &&
|
|
823
|
+
previous.format === SESSION_ARCHIVE_FORMAT_VERSION;
|
|
824
|
+
if (current && previous && importedInWindow) {
|
|
825
|
+
try {
|
|
826
|
+
fingerprint = await unitFingerprint(found);
|
|
827
|
+
current = previous.fingerprint === fingerprint;
|
|
828
|
+
} catch (error) {
|
|
829
|
+
counts.failed += 1;
|
|
830
|
+
recordUnit({
|
|
831
|
+
sourceId: source.id,
|
|
832
|
+
harness: found.harness,
|
|
833
|
+
locator: sanitizeLocator(found.locator),
|
|
834
|
+
outcome: "failed",
|
|
835
|
+
reason: unitReason(error),
|
|
836
|
+
threads: 0,
|
|
837
|
+
turns: 0,
|
|
838
|
+
collections: [],
|
|
839
|
+
});
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (current && previous) {
|
|
844
|
+
// Already archived and up to date: reported, not re-read or sanitized.
|
|
845
|
+
counts.unchanged += previous.threads.length;
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
if (options.limit !== undefined && processed >= options.limit) {
|
|
849
|
+
deferred += 1;
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
processed += 1;
|
|
853
|
+
importedInWindow = true;
|
|
854
|
+
// Receipts, warnings and checkpoint state show the locator with the
|
|
855
|
+
// owner's redaction applied; identity stays in the opaque key.
|
|
856
|
+
const unit: SessionUnit = {
|
|
857
|
+
...found,
|
|
858
|
+
locator: sanitizeLocator(found.locator),
|
|
859
|
+
};
|
|
860
|
+
if (unit.size > SESSION_LIMITS.maxSourceBytes) {
|
|
861
|
+
counts.skippedPolicy += 1;
|
|
862
|
+
recordUnit({
|
|
863
|
+
sourceId: source.id,
|
|
864
|
+
harness: unit.harness,
|
|
865
|
+
locator: unit.locator,
|
|
866
|
+
outcome: "skipped_policy",
|
|
867
|
+
reason: "over_limit",
|
|
868
|
+
threads: 0,
|
|
869
|
+
turns: 0,
|
|
870
|
+
collections: [],
|
|
871
|
+
});
|
|
872
|
+
continue;
|
|
873
|
+
}
|
|
874
|
+
touched.push({ units: sourceState.units, key });
|
|
875
|
+
const outcome = await this.importUnit({
|
|
876
|
+
source,
|
|
877
|
+
unit,
|
|
878
|
+
key,
|
|
879
|
+
destinations,
|
|
880
|
+
fingerprint,
|
|
881
|
+
previous,
|
|
882
|
+
sourceState,
|
|
883
|
+
dryRun: options.dryRun,
|
|
884
|
+
redaction,
|
|
885
|
+
redactionStampValue: stamp,
|
|
886
|
+
sharedSanitizer,
|
|
887
|
+
counts,
|
|
888
|
+
turns,
|
|
889
|
+
markChanged,
|
|
890
|
+
pendingWithdrawals,
|
|
799
891
|
});
|
|
800
|
-
|
|
892
|
+
recordUnit(outcome);
|
|
801
893
|
}
|
|
802
|
-
touched.push({ units: sourceState.units, key });
|
|
803
|
-
const outcome = await this.importUnit({
|
|
804
|
-
source,
|
|
805
|
-
unit,
|
|
806
|
-
key,
|
|
807
|
-
destinations,
|
|
808
|
-
fingerprint,
|
|
809
|
-
previous,
|
|
810
|
-
sourceState,
|
|
811
|
-
dryRun: options.dryRun,
|
|
812
|
-
redaction,
|
|
813
|
-
counts,
|
|
814
|
-
turns,
|
|
815
|
-
markChanged,
|
|
816
|
-
pendingWithdrawals,
|
|
817
|
-
});
|
|
818
|
-
recordUnit(outcome);
|
|
819
894
|
}
|
|
820
895
|
|
|
821
896
|
// Units whose source vanished keep their archive. Stale redaction is
|
|
@@ -823,7 +898,7 @@ export class SessionsService {
|
|
|
823
898
|
for (const [key, unitState] of Object.entries(sourceState.units)) {
|
|
824
899
|
if (present.has(key)) continue;
|
|
825
900
|
// Retained locators follow the current redaction policy too.
|
|
826
|
-
const locator =
|
|
901
|
+
const locator = sanitizeLocator(unitState.locator);
|
|
827
902
|
if (!options.dryRun) unitState.locator = locator;
|
|
828
903
|
if (unitState.redaction !== stamp && !options.dryRun) {
|
|
829
904
|
const previousStamp = unitState.redaction;
|
|
@@ -939,6 +1014,8 @@ export class SessionsService {
|
|
|
939
1014
|
sourceState: SourceState;
|
|
940
1015
|
dryRun: boolean;
|
|
941
1016
|
redaction: { literals: readonly string[] };
|
|
1017
|
+
redactionStampValue: string;
|
|
1018
|
+
sharedSanitizer: ThreadSanitizer;
|
|
942
1019
|
counts: SessionImportCounts;
|
|
943
1020
|
turns: SessionTurnCounts;
|
|
944
1021
|
markChanged: (collection: string, relPath: string) => void;
|
|
@@ -963,7 +1040,7 @@ export class SessionsService {
|
|
|
963
1040
|
fingerprint: options.fingerprint,
|
|
964
1041
|
status: "failed",
|
|
965
1042
|
parser: null,
|
|
966
|
-
redaction:
|
|
1043
|
+
redaction: options.redactionStampValue,
|
|
967
1044
|
destinations: options.destinations,
|
|
968
1045
|
format: SESSION_ARCHIVE_FORMAT_VERSION,
|
|
969
1046
|
threads: options.previous?.threads ?? [],
|
|
@@ -1084,6 +1161,7 @@ export class SessionsService {
|
|
|
1084
1161
|
unitLocator: unit.locator,
|
|
1085
1162
|
parser: parsed.parser,
|
|
1086
1163
|
redaction: options.redaction,
|
|
1164
|
+
sanitizer: options.sharedSanitizer,
|
|
1087
1165
|
});
|
|
1088
1166
|
if (rendered.overLimit) {
|
|
1089
1167
|
withhold(
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: track whether each partition's vec0 mirror may be stale.
|
|
3
|
+
*
|
|
4
|
+
* `VectorVariantStore` keeps the vec0 mirror in step with `vector_variants`
|
|
5
|
+
* in the same transaction as every write it makes, and leaves this mark as it
|
|
6
|
+
* found it. Any other change to stored vectors (raw SQL, older tools, a write
|
|
7
|
+
* made while sqlite-vec was unavailable) fires these triggers and removes the
|
|
8
|
+
* partition's clean mark. `syncIndex()` and a verified activation mark it clean, so
|
|
9
|
+
* the end of an embed pass can skip re-verifying an activated partition while
|
|
10
|
+
* its mirror is known to be current, instead of scanning the whole index.
|
|
11
|
+
*
|
|
12
|
+
* @module src/store/migrations/036-vector-mirror-state
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { Database } from "bun:sqlite";
|
|
16
|
+
|
|
17
|
+
import type { Migration } from "./runner";
|
|
18
|
+
|
|
19
|
+
export const migration: Migration = {
|
|
20
|
+
version: 36,
|
|
21
|
+
name: "vector_mirror_state",
|
|
22
|
+
|
|
23
|
+
up(db: Database): void {
|
|
24
|
+
// A partition is clean only while it has a row with dirty = 0. Triggers
|
|
25
|
+
// only delete rows, which never conflicts, so an outer statement's
|
|
26
|
+
// conflict clause (UPDATE OR IGNORE, INSERT OR REPLACE) cannot cancel the
|
|
27
|
+
// invalidation. The BEFORE triggers also invalidate partitions whose rows
|
|
28
|
+
// a REPLACE would displace (their delete triggers do not fire unless
|
|
29
|
+
// recursive_triggers is on). Each conflict is its own unique-key lookup:
|
|
30
|
+
// as one OR, statistics gathered while vector_variants was small made
|
|
31
|
+
// SQLite scan the table's index on every write.
|
|
32
|
+
db.exec(`
|
|
33
|
+
CREATE TABLE IF NOT EXISTS vector_mirror_state (
|
|
34
|
+
partition_id TEXT PRIMARY KEY,
|
|
35
|
+
dirty INTEGER NOT NULL CHECK (dirty IN (0, 1))
|
|
36
|
+
);
|
|
37
|
+
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_before_insert
|
|
38
|
+
BEFORE INSERT ON vector_variants BEGIN
|
|
39
|
+
DELETE FROM vector_mirror_state WHERE partition_id IN (
|
|
40
|
+
SELECT partition_id FROM vector_variants
|
|
41
|
+
WHERE variant_id = NEW.variant_id
|
|
42
|
+
UNION ALL
|
|
43
|
+
SELECT partition_id FROM vector_variants
|
|
44
|
+
WHERE partition_id = NEW.partition_id AND input_hash = NEW.input_hash
|
|
45
|
+
);
|
|
46
|
+
END;
|
|
47
|
+
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_insert
|
|
48
|
+
AFTER INSERT ON vector_variants BEGIN
|
|
49
|
+
DELETE FROM vector_mirror_state WHERE partition_id = NEW.partition_id;
|
|
50
|
+
END;
|
|
51
|
+
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_before_update
|
|
52
|
+
BEFORE UPDATE ON vector_variants BEGIN
|
|
53
|
+
DELETE FROM vector_mirror_state WHERE partition_id IN (
|
|
54
|
+
SELECT partition_id FROM vector_variants
|
|
55
|
+
WHERE variant_id = NEW.variant_id
|
|
56
|
+
UNION ALL
|
|
57
|
+
SELECT partition_id FROM vector_variants
|
|
58
|
+
WHERE partition_id = NEW.partition_id AND input_hash = NEW.input_hash
|
|
59
|
+
);
|
|
60
|
+
END;
|
|
61
|
+
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_update
|
|
62
|
+
AFTER UPDATE ON vector_variants BEGIN
|
|
63
|
+
DELETE FROM vector_mirror_state
|
|
64
|
+
WHERE partition_id IN (OLD.partition_id, NEW.partition_id);
|
|
65
|
+
END;
|
|
66
|
+
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_delete
|
|
67
|
+
AFTER DELETE ON vector_variants BEGIN
|
|
68
|
+
DELETE FROM vector_mirror_state WHERE partition_id = OLD.partition_id;
|
|
69
|
+
END;
|
|
70
|
+
`);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
down(db: Database): void {
|
|
74
|
+
db.exec(`
|
|
75
|
+
DROP TRIGGER IF EXISTS vector_variants_mirror_before_insert;
|
|
76
|
+
DROP TRIGGER IF EXISTS vector_variants_mirror_insert;
|
|
77
|
+
DROP TRIGGER IF EXISTS vector_variants_mirror_before_update;
|
|
78
|
+
DROP TRIGGER IF EXISTS vector_variants_mirror_update;
|
|
79
|
+
DROP TRIGGER IF EXISTS vector_variants_mirror_delete;
|
|
80
|
+
DROP TABLE IF EXISTS vector_mirror_state;
|
|
81
|
+
`);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: add covering and lookup indexes for vector owners, traces,
|
|
3
|
+
* document listing, and tag counts; drop strictly redundant left-prefix indexes.
|
|
4
|
+
*
|
|
5
|
+
* @module src/store/migrations/037-performance-indexes
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Database } from "bun:sqlite";
|
|
9
|
+
|
|
10
|
+
import type { Migration } from "./runner";
|
|
11
|
+
|
|
12
|
+
export const migration: Migration = {
|
|
13
|
+
version: 37,
|
|
14
|
+
name: "performance_indexes",
|
|
15
|
+
|
|
16
|
+
up(db: Database): void {
|
|
17
|
+
db.exec(`
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_vector_owners_partition_variant
|
|
19
|
+
ON vector_owners(partition_id, variant_id, mirror_hash, seq, document_id);
|
|
20
|
+
CREATE INDEX IF NOT EXISTS idx_vector_owners_doc_part
|
|
21
|
+
ON vector_owners(document_id, partition_id, seq, mirror_hash, variant_id);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS idx_vector_owners_mirror_seq
|
|
23
|
+
ON vector_owners(mirror_hash, seq);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_retrieval_traces_created
|
|
25
|
+
ON retrieval_traces(created_at_ms DESC, trace_id ASC);
|
|
26
|
+
CREATE INDEX IF NOT EXISTS idx_documents_collection_mtime
|
|
27
|
+
ON documents(collection, source_mtime DESC, id ASC)
|
|
28
|
+
WHERE active = 1;
|
|
29
|
+
DROP INDEX IF EXISTS idx_doc_tags_tag;
|
|
30
|
+
CREATE INDEX IF NOT EXISTS idx_doc_tags_tag_doc
|
|
31
|
+
ON doc_tags(tag, document_id);
|
|
32
|
+
DROP INDEX IF EXISTS idx_chunks_mirror_hash;
|
|
33
|
+
DROP INDEX IF EXISTS idx_doc_links_source_doc;
|
|
34
|
+
DROP INDEX IF EXISTS idx_doc_edges_src_type;
|
|
35
|
+
DROP INDEX IF EXISTS idx_doc_edges_dst_type;
|
|
36
|
+
DROP INDEX IF EXISTS idx_vectors_model;
|
|
37
|
+
`);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
down(db: Database): void {
|
|
41
|
+
db.exec(`
|
|
42
|
+
DROP INDEX IF EXISTS idx_vector_owners_partition_variant;
|
|
43
|
+
DROP INDEX IF EXISTS idx_vector_owners_doc_part;
|
|
44
|
+
DROP INDEX IF EXISTS idx_vector_owners_mirror_seq;
|
|
45
|
+
DROP INDEX IF EXISTS idx_retrieval_traces_created;
|
|
46
|
+
DROP INDEX IF EXISTS idx_documents_collection_mtime;
|
|
47
|
+
DROP INDEX IF EXISTS idx_doc_tags_tag_doc;
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_doc_tags_tag ON doc_tags(tag);
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_chunks_mirror_hash ON content_chunks(mirror_hash);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS idx_doc_links_source_doc ON doc_links(source_doc_id);
|
|
51
|
+
CREATE INDEX IF NOT EXISTS idx_doc_edges_src_type ON doc_edges(src_doc_id, edge_type);
|
|
52
|
+
CREATE INDEX IF NOT EXISTS idx_doc_edges_dst_type ON doc_edges(dst_doc_id, edge_type);
|
|
53
|
+
CREATE INDEX IF NOT EXISTS idx_vectors_model ON content_vectors(model);
|
|
54
|
+
`);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -49,6 +49,8 @@ import { migration as m032 } from "./032-vector-runtime-callers";
|
|
|
49
49
|
import { migration as m033 } from "./033-drop-documents-active-index";
|
|
50
50
|
import { migration as m034 } from "./034-collection-link-workspace";
|
|
51
51
|
import { migration as m035 } from "./035-vector-length-index";
|
|
52
|
+
import { migration as m036 } from "./036-vector-mirror-state";
|
|
53
|
+
import { migration as m037 } from "./037-performance-indexes";
|
|
52
54
|
|
|
53
55
|
/** All migrations in order */
|
|
54
56
|
export const migrations = [
|
|
@@ -87,4 +89,6 @@ export const migrations = [
|
|
|
87
89
|
m033,
|
|
88
90
|
m034,
|
|
89
91
|
m035,
|
|
92
|
+
m036,
|
|
93
|
+
m037,
|
|
90
94
|
];
|