@gmickel/gno 2.15.0 → 2.17.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/SKILL.md +27 -0
- package/assets/skill/cli-reference.md +24 -15
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.15.0.zip → gno-browser-clipper-v2.17.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.17.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +43 -3
- package/spec/db/schema.sql +53 -1
- package/spec/mcp.md +9 -3
- package/spec/output-schemas/doctor.schema.json +27 -0
- package/spec/output-schemas/retrieval-trace-payloads.schema.json +14 -0
- package/spec/output-schemas/search-results.schema.json +14 -0
- package/spec/output-schemas/status.schema.json +22 -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/doctor.ts +101 -29
- package/src/cli/commands/embed.ts +2 -2
- package/src/cli/commands/links.ts +30 -6
- 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/commands/vec.ts +180 -8
- package/src/cli/config-cache.ts +86 -0
- package/src/cli/globals.ts +64 -0
- package/src/cli/program.ts +63 -36
- 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/config/types.ts +6 -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/retrieval-trace-session.ts +3 -0
- package/src/core/retrieval-trace.ts +9 -0
- package/src/core/section-parse.ts +16 -6
- package/src/core/typed-metadata.ts +68 -0
- package/src/core/vector-partition-status.ts +13 -0
- package/src/core/wiki-link-syntax.ts +88 -0
- package/src/embed/backlog.ts +142 -60
- package/src/embed/retry.ts +39 -33
- package/src/embed/variant-backlog.ts +582 -116
- package/src/embed/variant-retry.ts +157 -48
- 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 +14 -6
- 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/explain.ts +17 -2
- package/src/pipeline/filters.ts +169 -33
- package/src/pipeline/graph-retrieval.ts +117 -61
- package/src/pipeline/hybrid.ts +626 -330
- 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/types.ts +7 -0
- package/src/pipeline/vsearch.ts +269 -154
- 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 +25 -5
- 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/037-performance-indexes.ts +56 -0
- package/src/store/migrations/038-vector-mirror-null-cosine.ts +47 -0
- package/src/store/migrations/039-vector-mirror-v2.ts +94 -0
- package/src/store/migrations/index.ts +6 -0
- package/src/store/sqlite/adapter.ts +1260 -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/coarse-router.ts +312 -0
- package/src/store/vector/eligibility.ts +39 -0
- package/src/store/vector/lazy.ts +17 -0
- package/src/store/vector/partition-index.ts +333 -59
- package/src/store/vector/proof-cache.ts +209 -0
- package/src/store/vector/runtime-compat.ts +6 -0
- package/src/store/vector/sqlite-vec.ts +270 -162
- package/src/store/vector/stats.ts +37 -73
- package/src/store/vector/status.ts +169 -53
- package/src/store/vector/stored-vectors.ts +131 -45
- package/src/store/vector/types.ts +19 -0
- package/src/store/vector/v2-mirror.ts +669 -0
- package/src/store/vector/variant-search.ts +1187 -111
- package/src/store/vector/variants.ts +964 -160
- package/browser-extension/artifacts/gno-browser-clipper-v2.15.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,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
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: persist per-partition null-cosine state on `vector_mirror_state`.
|
|
3
|
+
*
|
|
4
|
+
* `hasNullCosineVariant` is consulted only after `isMirrorClean` passes, so
|
|
5
|
+
* storing `null_cosine` (0 = clean of null-cosine vectors, 1 = contains at
|
|
6
|
+
* least one null-cosine vector, NULL = unknown) directly on the clean mirror
|
|
7
|
+
* row reuses migration 036's delete-only `vector_variants` triggers with no
|
|
8
|
+
* extra table or triggers. Older binaries that overwrite the row with
|
|
9
|
+
* `(partition_id, dirty)` reset `null_cosine` to NULL (safe unknown fallback).
|
|
10
|
+
*
|
|
11
|
+
* @module src/store/migrations/038-vector-mirror-null-cosine
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Database } from "bun:sqlite";
|
|
15
|
+
|
|
16
|
+
import type { Migration } from "./runner";
|
|
17
|
+
|
|
18
|
+
export const migration: Migration = {
|
|
19
|
+
version: 38,
|
|
20
|
+
name: "vector_mirror_null_cosine",
|
|
21
|
+
|
|
22
|
+
up(db: Database): void {
|
|
23
|
+
const hasColumn = db
|
|
24
|
+
.query<{ name: string }, []>(
|
|
25
|
+
"SELECT name FROM pragma_table_info('vector_mirror_state') WHERE name = 'null_cosine'"
|
|
26
|
+
)
|
|
27
|
+
.get();
|
|
28
|
+
if (!hasColumn) {
|
|
29
|
+
db.exec(`
|
|
30
|
+
ALTER TABLE vector_mirror_state
|
|
31
|
+
ADD COLUMN null_cosine INTEGER
|
|
32
|
+
CHECK (null_cosine IS NULL OR null_cosine IN (0, 1));
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
down(db: Database): void {
|
|
38
|
+
const hasColumn = db
|
|
39
|
+
.query<{ name: string }, []>(
|
|
40
|
+
"SELECT name FROM pragma_table_info('vector_mirror_state') WHERE name = 'null_cosine'"
|
|
41
|
+
)
|
|
42
|
+
.get();
|
|
43
|
+
if (hasColumn) {
|
|
44
|
+
db.exec("ALTER TABLE vector_mirror_state DROP COLUMN null_cosine;");
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 039: bit coarse vec0 mirror mapping, state table, and delete-only
|
|
3
|
+
* invalidation triggers (fn-235).
|
|
4
|
+
*
|
|
5
|
+
* Adds:
|
|
6
|
+
* - `vector_partition_rows`: stable integer rowids mapping `(partition_id, collection, variant_id)`
|
|
7
|
+
* to `vec_v2_<partitionId>` rowids.
|
|
8
|
+
* - `vector_mirror_v2_state`: per-partition clean mark plus build-time recall
|
|
9
|
+
* self-check results (`check_recall`, `check_queries`, `check_coarse_k`).
|
|
10
|
+
* - Delete-only triggers on `vector_variants` (I/U/D) and `vector_owners` (I/U)
|
|
11
|
+
* that write ONLY to the plain `vector_mirror_v2_state` table (never referencing
|
|
12
|
+
* any `vec0` table and never adding triggers to `documents`).
|
|
13
|
+
*/
|
|
14
|
+
import type { Database } from "bun:sqlite";
|
|
15
|
+
|
|
16
|
+
import type { Migration } from "./index";
|
|
17
|
+
|
|
18
|
+
export const migration: Migration = {
|
|
19
|
+
version: 39,
|
|
20
|
+
name: "vector_mirror_v2",
|
|
21
|
+
|
|
22
|
+
up(db: Database): void {
|
|
23
|
+
db.exec(`
|
|
24
|
+
CREATE TABLE IF NOT EXISTS vector_partition_rows (
|
|
25
|
+
id INTEGER PRIMARY KEY,
|
|
26
|
+
partition_id TEXT NOT NULL,
|
|
27
|
+
collection TEXT NOT NULL,
|
|
28
|
+
variant_id INTEGER NOT NULL,
|
|
29
|
+
UNIQUE(partition_id, collection, variant_id)
|
|
30
|
+
)
|
|
31
|
+
`);
|
|
32
|
+
db.exec(`
|
|
33
|
+
CREATE INDEX IF NOT EXISTS idx_vector_partition_rows_part_var
|
|
34
|
+
ON vector_partition_rows(partition_id, variant_id)
|
|
35
|
+
`);
|
|
36
|
+
db.exec(`
|
|
37
|
+
CREATE TABLE IF NOT EXISTS vector_mirror_v2_state (
|
|
38
|
+
partition_id TEXT PRIMARY KEY,
|
|
39
|
+
dirty INTEGER NOT NULL CHECK (dirty IN (0, 1)),
|
|
40
|
+
check_recall REAL,
|
|
41
|
+
check_queries INTEGER,
|
|
42
|
+
check_coarse_k INTEGER
|
|
43
|
+
)
|
|
44
|
+
`);
|
|
45
|
+
db.exec(`
|
|
46
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_insert
|
|
47
|
+
AFTER INSERT ON vector_variants
|
|
48
|
+
BEGIN
|
|
49
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
50
|
+
END
|
|
51
|
+
`);
|
|
52
|
+
db.exec(`
|
|
53
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_update
|
|
54
|
+
AFTER UPDATE ON vector_variants
|
|
55
|
+
BEGIN
|
|
56
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
57
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
58
|
+
END
|
|
59
|
+
`);
|
|
60
|
+
db.exec(`
|
|
61
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_delete
|
|
62
|
+
AFTER DELETE ON vector_variants
|
|
63
|
+
BEGIN
|
|
64
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
65
|
+
END
|
|
66
|
+
`);
|
|
67
|
+
db.exec(`
|
|
68
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_owners_v2_insert
|
|
69
|
+
AFTER INSERT ON vector_owners
|
|
70
|
+
BEGIN
|
|
71
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
72
|
+
END
|
|
73
|
+
`);
|
|
74
|
+
db.exec(`
|
|
75
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_owners_v2_update
|
|
76
|
+
AFTER UPDATE ON vector_owners
|
|
77
|
+
BEGIN
|
|
78
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
79
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
80
|
+
END
|
|
81
|
+
`);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
down(db: Database): void {
|
|
85
|
+
db.exec("DROP TRIGGER IF EXISTS trg_vector_owners_v2_update");
|
|
86
|
+
db.exec("DROP TRIGGER IF EXISTS trg_vector_owners_v2_insert");
|
|
87
|
+
db.exec("DROP TRIGGER IF EXISTS trg_vector_variants_v2_delete");
|
|
88
|
+
db.exec("DROP TRIGGER IF EXISTS trg_vector_variants_v2_update");
|
|
89
|
+
db.exec("DROP TRIGGER IF EXISTS trg_vector_variants_v2_insert");
|
|
90
|
+
db.exec("DROP TABLE IF EXISTS vector_mirror_v2_state");
|
|
91
|
+
db.exec("DROP INDEX IF EXISTS idx_vector_partition_rows_part_var");
|
|
92
|
+
db.exec("DROP TABLE IF EXISTS vector_partition_rows");
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -50,6 +50,9 @@ 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
52
|
import { migration as m036 } from "./036-vector-mirror-state";
|
|
53
|
+
import { migration as m037 } from "./037-performance-indexes";
|
|
54
|
+
import { migration as m038 } from "./038-vector-mirror-null-cosine";
|
|
55
|
+
import { migration as m039 } from "./039-vector-mirror-v2";
|
|
53
56
|
|
|
54
57
|
/** All migrations in order */
|
|
55
58
|
export const migrations = [
|
|
@@ -89,4 +92,7 @@ export const migrations = [
|
|
|
89
92
|
m034,
|
|
90
93
|
m035,
|
|
91
94
|
m036,
|
|
95
|
+
m037,
|
|
96
|
+
m038,
|
|
97
|
+
m039,
|
|
92
98
|
];
|