@gmickel/gno 1.18.0 → 1.19.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 +5 -3
- package/assets/skill/SKILL.md +27 -0
- package/package.json +2 -1
- package/spec/AGENTS.md +83 -0
- package/spec/CLAUDE.md +83 -0
- package/spec/bench-fixture.schema.json +137 -0
- package/spec/cli.md +2894 -0
- package/spec/db/schema.sql +442 -0
- package/spec/evals-agentic.md +510 -0
- package/spec/evals.md +1106 -0
- package/spec/mcp.md +2229 -0
- package/spec/output-schemas/activation-verification.schema.json +515 -0
- package/spec/output-schemas/ask.schema.json +366 -0
- package/spec/output-schemas/backlinks.schema.json +131 -0
- package/spec/output-schemas/bench-result.schema.json +120 -0
- package/spec/output-schemas/capture-receipt.schema.json +143 -0
- package/spec/output-schemas/collection-list.schema.json +45 -0
- package/spec/output-schemas/context-capsule-v1.schema.json +691 -0
- package/spec/output-schemas/context-capsule-verification.schema.json +1338 -0
- package/spec/output-schemas/context-list.schema.json +21 -0
- package/spec/output-schemas/doctor.schema.json +313 -0
- package/spec/output-schemas/error.schema.json +30 -0
- package/spec/output-schemas/expansion.schema.json +37 -0
- package/spec/output-schemas/get.schema.json +140 -0
- package/spec/output-schemas/graph-query.schema.json +99 -0
- package/spec/output-schemas/graph.schema.json +371 -0
- package/spec/output-schemas/links-list.schema.json +186 -0
- package/spec/output-schemas/mcp-add-collection-result.schema.json +23 -0
- package/spec/output-schemas/mcp-capture-result.schema.json +152 -0
- package/spec/output-schemas/mcp-http-error.schema.json +30 -0
- package/spec/output-schemas/mcp-job-list.schema.json +58 -0
- package/spec/output-schemas/mcp-job-status.schema.json +224 -0
- package/spec/output-schemas/mcp-remove-result.schema.json +39 -0
- package/spec/output-schemas/mcp-sync-result.schema.json +41 -0
- package/spec/output-schemas/mcp-tag-result.schema.json +33 -0
- package/spec/output-schemas/models-list.schema.json +93 -0
- package/spec/output-schemas/multi-get.schema.json +103 -0
- package/spec/output-schemas/process-status.schema.json +119 -0
- package/spec/output-schemas/query-diagnose.schema.json +123 -0
- package/spec/output-schemas/resident-status.schema.json +154 -0
- package/spec/output-schemas/retrieval-trace-common.schema.json +492 -0
- package/spec/output-schemas/retrieval-trace-delete.schema.json +16 -0
- package/spec/output-schemas/retrieval-trace-export.schema.json +61 -0
- package/spec/output-schemas/retrieval-trace-filters.schema.json +139 -0
- package/spec/output-schemas/retrieval-trace-judgment.schema.json +15 -0
- package/spec/output-schemas/retrieval-trace-list.schema.json +18 -0
- package/spec/output-schemas/retrieval-trace-payloads.schema.json +178 -0
- package/spec/output-schemas/retrieval-trace-purge.schema.json +31 -0
- package/spec/output-schemas/retrieval-trace-qrels.schema.json +303 -0
- package/spec/output-schemas/retrieval-trace-replay.schema.json +286 -0
- package/spec/output-schemas/retrieval-trace-show.schema.json +69 -0
- package/spec/output-schemas/retrieval-trace-summary.schema.json +65 -0
- package/spec/output-schemas/search-result.schema.json +154 -0
- package/spec/output-schemas/search-results.schema.json +338 -0
- package/spec/output-schemas/similar.schema.json +84 -0
- package/spec/output-schemas/status.schema.json +676 -0
- package/spec/output-schemas/tags-list.schema.json +48 -0
- package/src/app/context-runtime-types.ts +3 -0
- package/src/app/context-runtime.ts +15 -1
- package/src/cli/commands/ask.ts +106 -36
- package/src/cli/commands/context-build.ts +56 -9
- package/src/cli/commands/get.ts +64 -3
- package/src/cli/commands/query.ts +62 -23
- package/src/cli/commands/replay.ts +140 -0
- package/src/cli/commands/search.ts +48 -3
- package/src/cli/commands/shared.ts +3 -1
- package/src/cli/commands/trace.ts +200 -0
- package/src/cli/commands/vsearch.ts +75 -53
- package/src/cli/program.ts +255 -0
- package/src/config/index.ts +9 -0
- package/src/config/retrieval-traces.ts +56 -0
- package/src/config/types.ts +4 -0
- package/src/core/context-compiler.ts +11 -4
- package/src/core/retrieval-qrels.ts +405 -0
- package/src/core/retrieval-replay-candidate.ts +368 -0
- package/src/core/retrieval-replay-types.ts +109 -0
- package/src/core/retrieval-replay-validation.ts +89 -0
- package/src/core/retrieval-replay.ts +441 -0
- package/src/core/retrieval-trace-evidence-origin.ts +175 -0
- package/src/core/retrieval-trace-export.ts +113 -0
- package/src/core/retrieval-trace-filter-normalization.ts +27 -0
- package/src/core/retrieval-trace-filters.ts +19 -0
- package/src/core/retrieval-trace-management-helpers.ts +247 -0
- package/src/core/retrieval-trace-management-types.ts +132 -0
- package/src/core/retrieval-trace-management.ts +422 -0
- package/src/core/retrieval-trace-request.ts +141 -0
- package/src/core/retrieval-trace-session.ts +494 -0
- package/src/core/retrieval-trace.ts +472 -0
- package/src/mcp/tools/context.ts +59 -8
- package/src/mcp/tools/get.ts +35 -1
- package/src/mcp/tools/index.ts +74 -0
- package/src/mcp/tools/query.ts +95 -64
- package/src/mcp/tools/search.ts +36 -13
- package/src/mcp/tools/trace.ts +143 -0
- package/src/mcp/tools/vsearch.ts +71 -38
- package/src/pipeline/answer.ts +167 -26
- package/src/pipeline/graph-retrieval.ts +15 -1
- package/src/pipeline/hybrid.ts +151 -43
- package/src/pipeline/search.ts +36 -3
- package/src/pipeline/trace-metadata.ts +47 -0
- package/src/pipeline/types.ts +43 -0
- package/src/pipeline/vsearch.ts +101 -38
- package/src/sdk/client.ts +380 -71
- package/src/sdk/documents.ts +48 -1
- package/src/sdk/index.ts +17 -0
- package/src/sdk/types.ts +28 -0
- package/src/serve/context-capsule.ts +67 -8
- package/src/serve/public/app.tsx +12 -1
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/lib/workspace-tabs.ts +2 -0
- package/src/serve/public/pages/Dashboard.tsx +10 -0
- package/src/serve/public/pages/TraceHistory.tsx +478 -0
- package/src/serve/public/pages/trace-history-detail.tsx +224 -0
- package/src/serve/retrieval-trace.ts +28 -0
- package/src/serve/routes/api.ts +366 -72
- package/src/serve/routes/traces.ts +156 -0
- package/src/serve/server.ts +87 -2
- package/src/store/index.ts +31 -0
- package/src/store/migrations/014-retrieval-traces.ts +303 -0
- package/src/store/migrations/index.ts +2 -0
- package/src/store/retrieval-trace-codec.ts +384 -0
- package/src/store/sqlite/adapter.ts +153 -1
- package/src/store/sqlite/retrieval-trace-management-store.ts +341 -0
- package/src/store/sqlite/retrieval-trace-retention.ts +349 -0
- package/src/store/sqlite/retrieval-trace-rows.ts +267 -0
- package/src/store/sqlite/retrieval-trace-store.ts +515 -0
- package/src/store/types.ts +297 -0
- package/src/store/vector/sqlite-vec.ts +76 -1
- package/src/store/vector/types.ts +1 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/** SQLite row codecs and shared validation for retrieval trace storage. */
|
|
2
|
+
|
|
3
|
+
import type { Database } from "bun:sqlite";
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
RetrievalTraceDeleteCounts,
|
|
7
|
+
RetrievalTraceEventInput,
|
|
8
|
+
RetrievalTraceEventRow,
|
|
9
|
+
RetrievalTraceExportInput,
|
|
10
|
+
RetrievalTraceExportRow,
|
|
11
|
+
RetrievalTraceJudgmentInput,
|
|
12
|
+
RetrievalTraceJudgmentRow,
|
|
13
|
+
RetrievalTraceRow,
|
|
14
|
+
RetrievalTraceRunInput,
|
|
15
|
+
RetrievalTraceRunRow,
|
|
16
|
+
StoreResult,
|
|
17
|
+
} from "../types";
|
|
18
|
+
|
|
19
|
+
import { traceJsonObjectSchema } from "../retrieval-trace-codec";
|
|
20
|
+
import { err } from "../types";
|
|
21
|
+
|
|
22
|
+
export interface DbRetrievalTraceRow {
|
|
23
|
+
trace_id: string;
|
|
24
|
+
schema_version: "1.0";
|
|
25
|
+
redaction_mode: "metadata" | "replay";
|
|
26
|
+
replay_capable: number;
|
|
27
|
+
query_text: string | null;
|
|
28
|
+
query_digest: string | null;
|
|
29
|
+
query_shape_json: string;
|
|
30
|
+
goal_text: string | null;
|
|
31
|
+
goal_digest: string | null;
|
|
32
|
+
goal_shape_json: string;
|
|
33
|
+
filters_json: string;
|
|
34
|
+
pipeline_fingerprint: string;
|
|
35
|
+
model_fingerprint: string;
|
|
36
|
+
config_fingerprint: string;
|
|
37
|
+
index_fingerprint: string;
|
|
38
|
+
status: RetrievalTraceRow["status"];
|
|
39
|
+
created_at_ms: number;
|
|
40
|
+
updated_at_ms: number;
|
|
41
|
+
expires_at_ms: number;
|
|
42
|
+
byte_size: number;
|
|
43
|
+
creation_digest: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface DbRetrievalTraceRunRow {
|
|
47
|
+
run_id: string;
|
|
48
|
+
trace_id: string;
|
|
49
|
+
idempotency_key: string;
|
|
50
|
+
kind: RetrievalTraceRunInput["kind"];
|
|
51
|
+
payload_json: string;
|
|
52
|
+
payload_bytes: number;
|
|
53
|
+
canonical_digest: string;
|
|
54
|
+
created_at_ms: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface DbRetrievalTraceEventRow {
|
|
58
|
+
event_id: string;
|
|
59
|
+
trace_id: string;
|
|
60
|
+
run_id: string | null;
|
|
61
|
+
idempotency_key: string;
|
|
62
|
+
kind: RetrievalTraceEventInput["kind"];
|
|
63
|
+
payload_json: string;
|
|
64
|
+
payload_bytes: number;
|
|
65
|
+
canonical_digest: string;
|
|
66
|
+
created_at_ms: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface DbRetrievalTraceJudgmentRow {
|
|
70
|
+
judgment_id: string;
|
|
71
|
+
trace_id: string;
|
|
72
|
+
run_id: string | null;
|
|
73
|
+
idempotency_key: string;
|
|
74
|
+
label: RetrievalTraceJudgmentInput["label"];
|
|
75
|
+
target_kind: RetrievalTraceJudgmentInput["targetKind"];
|
|
76
|
+
target_ref: string;
|
|
77
|
+
target_json: string;
|
|
78
|
+
target_bytes: number;
|
|
79
|
+
canonical_digest: string;
|
|
80
|
+
created_at_ms: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface DbRetrievalTraceExportRow {
|
|
84
|
+
export_id: string;
|
|
85
|
+
trace_id: string;
|
|
86
|
+
format: RetrievalTraceExportInput["format"];
|
|
87
|
+
artifact_hash: string;
|
|
88
|
+
created_at_ms: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const parseJsonObject = (raw: string): Record<string, unknown> =>
|
|
92
|
+
traceJsonObjectSchema.parse(JSON.parse(raw));
|
|
93
|
+
|
|
94
|
+
export const mapTraceRow = (row: DbRetrievalTraceRow): RetrievalTraceRow => ({
|
|
95
|
+
traceId: row.trace_id,
|
|
96
|
+
schemaVersion: row.schema_version,
|
|
97
|
+
redactionMode: row.redaction_mode,
|
|
98
|
+
replayCapable: row.replay_capable === 1,
|
|
99
|
+
queryText: row.query_text,
|
|
100
|
+
queryDigest: row.query_digest,
|
|
101
|
+
queryShape: JSON.parse(
|
|
102
|
+
row.query_shape_json
|
|
103
|
+
) as RetrievalTraceRow["queryShape"],
|
|
104
|
+
goalText: row.goal_text,
|
|
105
|
+
goalDigest: row.goal_digest,
|
|
106
|
+
goalShape: JSON.parse(row.goal_shape_json) as RetrievalTraceRow["goalShape"],
|
|
107
|
+
filters: parseJsonObject(row.filters_json),
|
|
108
|
+
fingerprints: {
|
|
109
|
+
pipeline: row.pipeline_fingerprint,
|
|
110
|
+
model: row.model_fingerprint,
|
|
111
|
+
config: row.config_fingerprint,
|
|
112
|
+
index: row.index_fingerprint,
|
|
113
|
+
},
|
|
114
|
+
status: row.status,
|
|
115
|
+
createdAtMs: row.created_at_ms,
|
|
116
|
+
updatedAtMs: row.updated_at_ms,
|
|
117
|
+
expiresAtMs: row.expires_at_ms,
|
|
118
|
+
byteSize: row.byte_size,
|
|
119
|
+
creationDigest: row.creation_digest,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export const mapRunRow = (
|
|
123
|
+
row: DbRetrievalTraceRunRow
|
|
124
|
+
): RetrievalTraceRunRow => ({
|
|
125
|
+
runId: row.run_id,
|
|
126
|
+
traceId: row.trace_id,
|
|
127
|
+
idempotencyKey: row.idempotency_key,
|
|
128
|
+
kind: row.kind,
|
|
129
|
+
payload: parseJsonObject(row.payload_json),
|
|
130
|
+
payloadBytes: row.payload_bytes,
|
|
131
|
+
canonicalDigest: row.canonical_digest,
|
|
132
|
+
createdAtMs: row.created_at_ms,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const mapEventRow = (
|
|
136
|
+
row: DbRetrievalTraceEventRow
|
|
137
|
+
): RetrievalTraceEventRow => ({
|
|
138
|
+
eventId: row.event_id,
|
|
139
|
+
traceId: row.trace_id,
|
|
140
|
+
runId: row.run_id,
|
|
141
|
+
idempotencyKey: row.idempotency_key,
|
|
142
|
+
kind: row.kind,
|
|
143
|
+
payload: parseJsonObject(row.payload_json),
|
|
144
|
+
payloadBytes: row.payload_bytes,
|
|
145
|
+
canonicalDigest: row.canonical_digest,
|
|
146
|
+
createdAtMs: row.created_at_ms,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export const mapJudgmentRow = (
|
|
150
|
+
row: DbRetrievalTraceJudgmentRow
|
|
151
|
+
): RetrievalTraceJudgmentRow => ({
|
|
152
|
+
judgmentId: row.judgment_id,
|
|
153
|
+
traceId: row.trace_id,
|
|
154
|
+
runId: row.run_id,
|
|
155
|
+
idempotencyKey: row.idempotency_key,
|
|
156
|
+
label: row.label,
|
|
157
|
+
targetKind: row.target_kind,
|
|
158
|
+
targetRef: row.target_ref,
|
|
159
|
+
target: parseJsonObject(row.target_json),
|
|
160
|
+
targetBytes: row.target_bytes,
|
|
161
|
+
canonicalDigest: row.canonical_digest,
|
|
162
|
+
createdAtMs: row.created_at_ms,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export const mapExportRow = (
|
|
166
|
+
row: DbRetrievalTraceExportRow
|
|
167
|
+
): RetrievalTraceExportRow => ({
|
|
168
|
+
exportId: row.export_id,
|
|
169
|
+
traceId: row.trace_id,
|
|
170
|
+
format: row.format,
|
|
171
|
+
artifactHash: row.artifact_hash,
|
|
172
|
+
createdAtMs: row.created_at_ms,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export class RetrievalTraceConflictError extends Error {
|
|
176
|
+
constructor(message: string) {
|
|
177
|
+
super(message);
|
|
178
|
+
this.name = "RetrievalTraceConflictError";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export const validateTraceId = (value: string, label: string): void => {
|
|
183
|
+
if (value.length < 1 || value.length > 128) {
|
|
184
|
+
throw new RangeError(`${label} must be from 1 to 128 characters`);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const traceWriteError = <T>(
|
|
189
|
+
cause: unknown,
|
|
190
|
+
fallback: string
|
|
191
|
+
): StoreResult<T> => {
|
|
192
|
+
const message = cause instanceof Error ? cause.message : fallback;
|
|
193
|
+
if (
|
|
194
|
+
cause instanceof RetrievalTraceConflictError ||
|
|
195
|
+
message.includes("constraint failed") ||
|
|
196
|
+
message.includes("FOREIGN KEY constraint") ||
|
|
197
|
+
message.includes("retrieval trace record cap exceeded")
|
|
198
|
+
) {
|
|
199
|
+
return err("CONSTRAINT_VIOLATION", message, cause);
|
|
200
|
+
}
|
|
201
|
+
if (
|
|
202
|
+
cause instanceof RangeError ||
|
|
203
|
+
(cause instanceof Error && cause.name === "ZodError")
|
|
204
|
+
) {
|
|
205
|
+
return err("INVALID_INPUT", message, cause);
|
|
206
|
+
}
|
|
207
|
+
return err("QUERY_FAILED", message, cause);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export const traceReadError = <T>(
|
|
211
|
+
cause: unknown,
|
|
212
|
+
fallback: string
|
|
213
|
+
): StoreResult<T> =>
|
|
214
|
+
cause instanceof RangeError
|
|
215
|
+
? err("INVALID_INPUT", cause.message, cause)
|
|
216
|
+
: err(
|
|
217
|
+
"QUERY_FAILED",
|
|
218
|
+
cause instanceof Error ? cause.message : fallback,
|
|
219
|
+
cause
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const countRows = (db: Database, table: string, traceId?: string): number => {
|
|
223
|
+
if (traceId === undefined) {
|
|
224
|
+
return (
|
|
225
|
+
db
|
|
226
|
+
.query<{ count: number }, []>(`SELECT COUNT(*) AS count FROM ${table}`)
|
|
227
|
+
.get()?.count ?? 0
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
return (
|
|
231
|
+
db
|
|
232
|
+
.query<{ count: number }, [string]>(
|
|
233
|
+
`SELECT COUNT(*) AS count FROM ${table} WHERE trace_id = ?`
|
|
234
|
+
)
|
|
235
|
+
.get(traceId)?.count ?? 0
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const countTraceContent = (
|
|
240
|
+
db: Database,
|
|
241
|
+
traceId?: string
|
|
242
|
+
): RetrievalTraceDeleteCounts => {
|
|
243
|
+
const exportCount =
|
|
244
|
+
traceId === undefined
|
|
245
|
+
? countRows(db, "retrieval_trace_exports")
|
|
246
|
+
: (db
|
|
247
|
+
.query<{ count: number }, [string, string]>(
|
|
248
|
+
`SELECT COUNT(*) AS count FROM retrieval_trace_exports x
|
|
249
|
+
WHERE EXISTS (
|
|
250
|
+
SELECT 1 FROM retrieval_trace_export_traces own
|
|
251
|
+
WHERE own.export_id = x.export_id AND own.trace_id = ?
|
|
252
|
+
)
|
|
253
|
+
AND NOT EXISTS (
|
|
254
|
+
SELECT 1 FROM retrieval_trace_export_traces other
|
|
255
|
+
WHERE other.export_id = x.export_id AND other.trace_id != ?
|
|
256
|
+
)`
|
|
257
|
+
)
|
|
258
|
+
.get(traceId, traceId)?.count ?? 0);
|
|
259
|
+
return {
|
|
260
|
+
traces: countRows(db, "retrieval_traces", traceId),
|
|
261
|
+
runs: countRows(db, "retrieval_trace_runs", traceId),
|
|
262
|
+
events: countRows(db, "retrieval_trace_events", traceId),
|
|
263
|
+
judgments: countRows(db, "retrieval_trace_judgments", traceId),
|
|
264
|
+
exports: exportCount,
|
|
265
|
+
exportLinks: countRows(db, "retrieval_trace_export_traces", traceId),
|
|
266
|
+
};
|
|
267
|
+
};
|