@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.
Files changed (129) hide show
  1. package/README.md +5 -3
  2. package/assets/skill/SKILL.md +27 -0
  3. package/package.json +2 -1
  4. package/spec/AGENTS.md +83 -0
  5. package/spec/CLAUDE.md +83 -0
  6. package/spec/bench-fixture.schema.json +137 -0
  7. package/spec/cli.md +2894 -0
  8. package/spec/db/schema.sql +442 -0
  9. package/spec/evals-agentic.md +510 -0
  10. package/spec/evals.md +1106 -0
  11. package/spec/mcp.md +2229 -0
  12. package/spec/output-schemas/activation-verification.schema.json +515 -0
  13. package/spec/output-schemas/ask.schema.json +366 -0
  14. package/spec/output-schemas/backlinks.schema.json +131 -0
  15. package/spec/output-schemas/bench-result.schema.json +120 -0
  16. package/spec/output-schemas/capture-receipt.schema.json +143 -0
  17. package/spec/output-schemas/collection-list.schema.json +45 -0
  18. package/spec/output-schemas/context-capsule-v1.schema.json +691 -0
  19. package/spec/output-schemas/context-capsule-verification.schema.json +1338 -0
  20. package/spec/output-schemas/context-list.schema.json +21 -0
  21. package/spec/output-schemas/doctor.schema.json +313 -0
  22. package/spec/output-schemas/error.schema.json +30 -0
  23. package/spec/output-schemas/expansion.schema.json +37 -0
  24. package/spec/output-schemas/get.schema.json +140 -0
  25. package/spec/output-schemas/graph-query.schema.json +99 -0
  26. package/spec/output-schemas/graph.schema.json +371 -0
  27. package/spec/output-schemas/links-list.schema.json +186 -0
  28. package/spec/output-schemas/mcp-add-collection-result.schema.json +23 -0
  29. package/spec/output-schemas/mcp-capture-result.schema.json +152 -0
  30. package/spec/output-schemas/mcp-http-error.schema.json +30 -0
  31. package/spec/output-schemas/mcp-job-list.schema.json +58 -0
  32. package/spec/output-schemas/mcp-job-status.schema.json +224 -0
  33. package/spec/output-schemas/mcp-remove-result.schema.json +39 -0
  34. package/spec/output-schemas/mcp-sync-result.schema.json +41 -0
  35. package/spec/output-schemas/mcp-tag-result.schema.json +33 -0
  36. package/spec/output-schemas/models-list.schema.json +93 -0
  37. package/spec/output-schemas/multi-get.schema.json +103 -0
  38. package/spec/output-schemas/process-status.schema.json +119 -0
  39. package/spec/output-schemas/query-diagnose.schema.json +123 -0
  40. package/spec/output-schemas/resident-status.schema.json +154 -0
  41. package/spec/output-schemas/retrieval-trace-common.schema.json +492 -0
  42. package/spec/output-schemas/retrieval-trace-delete.schema.json +16 -0
  43. package/spec/output-schemas/retrieval-trace-export.schema.json +61 -0
  44. package/spec/output-schemas/retrieval-trace-filters.schema.json +139 -0
  45. package/spec/output-schemas/retrieval-trace-judgment.schema.json +15 -0
  46. package/spec/output-schemas/retrieval-trace-list.schema.json +18 -0
  47. package/spec/output-schemas/retrieval-trace-payloads.schema.json +178 -0
  48. package/spec/output-schemas/retrieval-trace-purge.schema.json +31 -0
  49. package/spec/output-schemas/retrieval-trace-qrels.schema.json +303 -0
  50. package/spec/output-schemas/retrieval-trace-replay.schema.json +286 -0
  51. package/spec/output-schemas/retrieval-trace-show.schema.json +69 -0
  52. package/spec/output-schemas/retrieval-trace-summary.schema.json +65 -0
  53. package/spec/output-schemas/search-result.schema.json +154 -0
  54. package/spec/output-schemas/search-results.schema.json +338 -0
  55. package/spec/output-schemas/similar.schema.json +84 -0
  56. package/spec/output-schemas/status.schema.json +676 -0
  57. package/spec/output-schemas/tags-list.schema.json +48 -0
  58. package/src/app/context-runtime-types.ts +3 -0
  59. package/src/app/context-runtime.ts +15 -1
  60. package/src/cli/commands/ask.ts +106 -36
  61. package/src/cli/commands/context-build.ts +56 -9
  62. package/src/cli/commands/get.ts +64 -3
  63. package/src/cli/commands/query.ts +62 -23
  64. package/src/cli/commands/replay.ts +140 -0
  65. package/src/cli/commands/search.ts +48 -3
  66. package/src/cli/commands/shared.ts +3 -1
  67. package/src/cli/commands/trace.ts +200 -0
  68. package/src/cli/commands/vsearch.ts +75 -53
  69. package/src/cli/program.ts +255 -0
  70. package/src/config/index.ts +9 -0
  71. package/src/config/retrieval-traces.ts +56 -0
  72. package/src/config/types.ts +4 -0
  73. package/src/core/context-compiler.ts +11 -4
  74. package/src/core/retrieval-qrels.ts +405 -0
  75. package/src/core/retrieval-replay-candidate.ts +368 -0
  76. package/src/core/retrieval-replay-types.ts +109 -0
  77. package/src/core/retrieval-replay-validation.ts +89 -0
  78. package/src/core/retrieval-replay.ts +441 -0
  79. package/src/core/retrieval-trace-evidence-origin.ts +175 -0
  80. package/src/core/retrieval-trace-export.ts +113 -0
  81. package/src/core/retrieval-trace-filter-normalization.ts +27 -0
  82. package/src/core/retrieval-trace-filters.ts +19 -0
  83. package/src/core/retrieval-trace-management-helpers.ts +247 -0
  84. package/src/core/retrieval-trace-management-types.ts +132 -0
  85. package/src/core/retrieval-trace-management.ts +422 -0
  86. package/src/core/retrieval-trace-request.ts +141 -0
  87. package/src/core/retrieval-trace-session.ts +494 -0
  88. package/src/core/retrieval-trace.ts +472 -0
  89. package/src/mcp/tools/context.ts +59 -8
  90. package/src/mcp/tools/get.ts +35 -1
  91. package/src/mcp/tools/index.ts +74 -0
  92. package/src/mcp/tools/query.ts +95 -64
  93. package/src/mcp/tools/search.ts +36 -13
  94. package/src/mcp/tools/trace.ts +143 -0
  95. package/src/mcp/tools/vsearch.ts +71 -38
  96. package/src/pipeline/answer.ts +167 -26
  97. package/src/pipeline/graph-retrieval.ts +15 -1
  98. package/src/pipeline/hybrid.ts +151 -43
  99. package/src/pipeline/search.ts +36 -3
  100. package/src/pipeline/trace-metadata.ts +47 -0
  101. package/src/pipeline/types.ts +43 -0
  102. package/src/pipeline/vsearch.ts +101 -38
  103. package/src/sdk/client.ts +380 -71
  104. package/src/sdk/documents.ts +48 -1
  105. package/src/sdk/index.ts +17 -0
  106. package/src/sdk/types.ts +28 -0
  107. package/src/serve/context-capsule.ts +67 -8
  108. package/src/serve/public/app.tsx +12 -1
  109. package/src/serve/public/globals.built.css +1 -1
  110. package/src/serve/public/lib/workspace-tabs.ts +2 -0
  111. package/src/serve/public/pages/Dashboard.tsx +10 -0
  112. package/src/serve/public/pages/TraceHistory.tsx +478 -0
  113. package/src/serve/public/pages/trace-history-detail.tsx +224 -0
  114. package/src/serve/retrieval-trace.ts +28 -0
  115. package/src/serve/routes/api.ts +366 -72
  116. package/src/serve/routes/traces.ts +156 -0
  117. package/src/serve/server.ts +87 -2
  118. package/src/store/index.ts +31 -0
  119. package/src/store/migrations/014-retrieval-traces.ts +303 -0
  120. package/src/store/migrations/index.ts +2 -0
  121. package/src/store/retrieval-trace-codec.ts +384 -0
  122. package/src/store/sqlite/adapter.ts +153 -1
  123. package/src/store/sqlite/retrieval-trace-management-store.ts +341 -0
  124. package/src/store/sqlite/retrieval-trace-retention.ts +349 -0
  125. package/src/store/sqlite/retrieval-trace-rows.ts +267 -0
  126. package/src/store/sqlite/retrieval-trace-store.ts +515 -0
  127. package/src/store/types.ts +297 -0
  128. package/src/store/vector/sqlite-vec.ts +76 -1
  129. package/src/store/vector/types.ts +1 -1
@@ -0,0 +1,224 @@
1
+ import { Loader2Icon } from "lucide-react";
2
+
3
+ import type {
4
+ RetrievalTraceDetail,
5
+ RetrievalTracePurgeResult,
6
+ } from "../../../core/retrieval-trace-management";
7
+
8
+ import { Button } from "../components/ui/button";
9
+ import { Input } from "../components/ui/input";
10
+ import {
11
+ Select,
12
+ SelectContent,
13
+ SelectItem,
14
+ SelectTrigger,
15
+ SelectValue,
16
+ } from "../components/ui/select";
17
+
18
+ export interface TraceEvidenceSelection {
19
+ ref: string;
20
+ targetKind: "document" | "chunk" | "span";
21
+ startLine?: number;
22
+ endLine?: number;
23
+ sourceHash?: string;
24
+ docid?: string;
25
+ }
26
+
27
+ const evidenceFromPayload = (
28
+ payload: Record<string, unknown>
29
+ ): TraceEvidenceSelection[] => {
30
+ const selections: TraceEvidenceSelection[] = [];
31
+ for (const key of ["ranked", "evidence"] as const) {
32
+ const values = payload[key];
33
+ if (!Array.isArray(values)) continue;
34
+ for (const value of values) {
35
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
36
+ const target = value as Record<string, unknown>;
37
+ const ref = [
38
+ target.uri,
39
+ target.docid,
40
+ target.sourceHash,
41
+ target.mirrorHash,
42
+ target.passageHash,
43
+ ].find((candidate): candidate is string => typeof candidate === "string");
44
+ if (!ref) continue;
45
+ const startLine =
46
+ typeof target.startLine === "number" ? target.startLine : undefined;
47
+ const endLine =
48
+ typeof target.endLine === "number" ? target.endLine : undefined;
49
+ const seq = typeof target.seq === "number" ? target.seq : undefined;
50
+ selections.push({
51
+ ref,
52
+ targetKind:
53
+ startLine !== undefined && endLine !== undefined
54
+ ? "span"
55
+ : seq === undefined
56
+ ? "document"
57
+ : "chunk",
58
+ ...(startLine === undefined ? {} : { startLine }),
59
+ ...(endLine === undefined ? {} : { endLine }),
60
+ ...(typeof target.sourceHash === "string"
61
+ ? { sourceHash: target.sourceHash }
62
+ : {}),
63
+ ...(typeof target.docid === "string" ? { docid: target.docid } : {}),
64
+ });
65
+ }
66
+ }
67
+ return selections;
68
+ };
69
+
70
+ export const traceEvidenceSelections = (
71
+ detail: RetrievalTraceDetail
72
+ ): TraceEvidenceSelection[] => {
73
+ const unique = new Map<string, TraceEvidenceSelection>();
74
+ for (const record of [...detail.runs, ...detail.events]) {
75
+ for (const selection of evidenceFromPayload(record.payload)) {
76
+ const key = JSON.stringify(selection);
77
+ if (!unique.has(key)) unique.set(key, selection);
78
+ }
79
+ }
80
+ return [...unique.values()];
81
+ };
82
+
83
+ export function TraceEvidenceList({
84
+ detail,
85
+ onSelect,
86
+ }: {
87
+ detail: RetrievalTraceDetail;
88
+ onSelect: (selection: TraceEvidenceSelection) => void;
89
+ }) {
90
+ const selections = traceEvidenceSelections(detail);
91
+ return (
92
+ <div className="space-y-3 border-t border-border/50 pt-4">
93
+ <div>
94
+ <h2 className="font-medium">Recorded evidence</h2>
95
+ <p className="text-xs text-muted-foreground">
96
+ Select a document, chunk, or exact line span to label.
97
+ </p>
98
+ </div>
99
+ {selections.length === 0 ? (
100
+ <p className="text-xs text-muted-foreground">
101
+ No bounded evidence references were retained for this trace.
102
+ </p>
103
+ ) : (
104
+ <div className="max-h-56 space-y-2 overflow-y-auto">
105
+ {selections.map((selection) => (
106
+ <div
107
+ className="rounded-md border border-border/60 p-2"
108
+ key={JSON.stringify(selection)}
109
+ >
110
+ <div className="break-all font-mono text-xs">{selection.ref}</div>
111
+ <div className="mt-1 flex items-center justify-between gap-2 text-xs text-muted-foreground">
112
+ <span>
113
+ {selection.targetKind}
114
+ {selection.startLine !== undefined &&
115
+ ` · lines ${selection.startLine}–${selection.endLine}`}
116
+ </span>
117
+ <Button
118
+ onClick={() => onSelect(selection)}
119
+ size="sm"
120
+ type="button"
121
+ variant="outline"
122
+ >
123
+ Label this evidence
124
+ </Button>
125
+ </div>
126
+ </div>
127
+ ))}
128
+ </div>
129
+ )}
130
+ </div>
131
+ );
132
+ }
133
+
134
+ export function TracePurgeNotice({
135
+ receipt,
136
+ }: {
137
+ receipt: RetrievalTracePurgeResult | null;
138
+ }) {
139
+ if (!receipt) return null;
140
+ const complete = receipt.physicalCleanup === "completed";
141
+ return (
142
+ <div
143
+ className={`rounded-md border p-3 text-sm ${
144
+ complete
145
+ ? "border-emerald-500/40 bg-emerald-500/10"
146
+ : "border-amber-500/40 bg-amber-500/10"
147
+ }`}
148
+ data-testid="trace-purge-receipt"
149
+ >
150
+ <div className="font-medium">
151
+ {complete
152
+ ? "Trace purge completed"
153
+ : `Trace rows deleted; physical cleanup ${receipt.physicalCleanup.replace("_", " ")}`}
154
+ </div>
155
+ <div className="mt-1 text-xs text-muted-foreground">
156
+ Deleted {receipt.traces} traces, {receipt.runs} runs, {receipt.events}{" "}
157
+ events, and {receipt.judgments} judgments.
158
+ {!complete &&
159
+ " Retry Full purge after active readers finish; the cleanup receipt remains visible until then."}
160
+ </div>
161
+ </div>
162
+ );
163
+ }
164
+
165
+ export function TraceLabelForm({
166
+ busy,
167
+ label,
168
+ onLabelChange,
169
+ onSourceHashChange,
170
+ onSubmit,
171
+ onTargetRefChange,
172
+ sourceHash,
173
+ targetRef,
174
+ }: {
175
+ busy: boolean;
176
+ label: "relevant" | "irrelevant" | "missing_expected";
177
+ onLabelChange: (
178
+ value: "relevant" | "irrelevant" | "missing_expected"
179
+ ) => void;
180
+ onSourceHashChange: (value: string) => void;
181
+ onSubmit: () => void;
182
+ onTargetRefChange: (value: string) => void;
183
+ sourceHash: string;
184
+ targetRef: string;
185
+ }) {
186
+ return (
187
+ <div className="space-y-3 border-t border-border/50 pt-4">
188
+ <h2 className="font-medium">Add explicit judgment</h2>
189
+ <Select
190
+ onValueChange={(value) =>
191
+ onLabelChange(value as "relevant" | "irrelevant" | "missing_expected")
192
+ }
193
+ value={label}
194
+ >
195
+ <SelectTrigger>
196
+ <SelectValue />
197
+ </SelectTrigger>
198
+ <SelectContent>
199
+ <SelectItem value="relevant">Relevant</SelectItem>
200
+ <SelectItem value="irrelevant">Irrelevant</SelectItem>
201
+ <SelectItem value="missing_expected">
202
+ Missing expected document
203
+ </SelectItem>
204
+ </SelectContent>
205
+ </Select>
206
+ <Input
207
+ onChange={(event) => onTargetRefChange(event.target.value)}
208
+ placeholder="gno:// URI, docid, or recorded evidence ref"
209
+ value={targetRef}
210
+ />
211
+ {label === "missing_expected" && (
212
+ <Input
213
+ onChange={(event) => onSourceHashChange(event.target.value)}
214
+ placeholder="Optional immutable source SHA-256"
215
+ value={sourceHash}
216
+ />
217
+ )}
218
+ <Button disabled={!targetRef.trim() || busy} onClick={onSubmit} size="sm">
219
+ {busy && <Loader2Icon className="mr-2 size-4 animate-spin" />}
220
+ Record judgment
221
+ </Button>
222
+ </div>
223
+ );
224
+ }
@@ -0,0 +1,28 @@
1
+ /** REST-only retrieval trace transport metadata. */
2
+
3
+ import type { RetrievalTraceSession } from "../core/retrieval-trace-session";
4
+
5
+ export const RETRIEVAL_TRACE_HEADER = "X-GNO-Trace-ID";
6
+
7
+ export const requestRetrievalTraceId = (
8
+ request: Request
9
+ ): string | undefined => {
10
+ const value = request.headers.get(RETRIEVAL_TRACE_HEADER)?.trim();
11
+ return value || undefined;
12
+ };
13
+
14
+ /** Preserve status/body bytes while adding transport-only trace identity. */
15
+ export const withRetrievalTraceHeader = (
16
+ response: Response,
17
+ session: RetrievalTraceSession | null | undefined
18
+ ): Response => {
19
+ const traceId = session?.metadata()?.traceId;
20
+ if (!traceId) return response;
21
+ const headers = new Headers(response.headers);
22
+ headers.set(RETRIEVAL_TRACE_HEADER, traceId);
23
+ return new Response(response.body, {
24
+ headers,
25
+ status: response.status,
26
+ statusText: response.statusText,
27
+ });
28
+ };