@gmickel/gno 1.19.0 → 1.21.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 +28 -8
- package/assets/skill/SKILL.md +73 -27
- package/assets/skill/mcp-reference.md +7 -2
- package/assets/skill/recipes/citation-and-provenance.md +32 -9
- package/package.json +1 -1
- package/spec/cli.md +142 -17
- package/spec/db/schema.sql +170 -0
- package/spec/evals-agentic.md +87 -5
- package/spec/mcp.md +75 -3
- package/spec/output-schemas/ask.schema.json +198 -0
- package/spec/output-schemas/capsule-reverified-event.schema.json +47 -0
- package/spec/output-schemas/changes.schema.json +280 -0
- package/spec/output-schemas/claim-verification.schema.json +291 -0
- package/spec/output-schemas/context-capsule-v1.schema.json +36 -1
- package/spec/output-schemas/document-diff.schema.json +185 -0
- package/spec/output-schemas/impact.schema.json +122 -0
- package/spec/output-schemas/saved-capsule-list.schema.json +16 -0
- package/spec/output-schemas/saved-capsule-registration.schema.json +172 -0
- package/spec/output-schemas/saved-capsule-reverification.schema.json +59 -0
- package/spec/output-schemas/saved-capsule-unwatch.schema.json +16 -0
- package/spec/output-schemas/saved-capsule-watch.schema.json +17 -0
- package/src/app/context-runtime-contract.ts +10 -5
- package/src/app/context-runtime-input.ts +29 -1
- package/src/app/context-runtime-types.ts +4 -0
- package/src/app/context-runtime.ts +5 -1
- package/src/app/context-surface.ts +4 -0
- package/src/app/verified-ask.ts +291 -0
- package/src/cli/commands/ask-format.ts +255 -0
- package/src/cli/commands/ask.ts +40 -149
- package/src/cli/commands/changes.ts +160 -0
- package/src/cli/commands/context-saved.ts +189 -0
- package/src/cli/options.ts +8 -0
- package/src/cli/program.ts +227 -1
- package/src/core/capsule-registry.ts +279 -0
- package/src/core/capsule-reverification-scheduler.ts +218 -0
- package/src/core/capsule-reverification.ts +289 -0
- package/src/core/change-diff.ts +182 -0
- package/src/core/change-journal.ts +228 -0
- package/src/core/context-budget.ts +6 -0
- package/src/core/context-capsule-retrieval-schema.ts +4 -0
- package/src/core/context-capsule-schema.ts +17 -0
- package/src/core/context-capsule-validation.ts +3 -2
- package/src/core/context-capsule.ts +18 -0
- package/src/core/context-compiler.ts +33 -21
- package/src/core/context-evidence.ts +6 -0
- package/src/core/knowledge-delta.ts +395 -0
- package/src/core/knowledge-impact.ts +202 -0
- package/src/core/retrieval-trace-evidence-origin.ts +3 -0
- package/src/core/retrieval-trace-session.ts +15 -2
- package/src/ingestion/sync.ts +214 -165
- package/src/llm/errors.ts +10 -1
- package/src/llm/httpGeneration.ts +11 -1
- package/src/llm/nodeLlamaCpp/generation.ts +54 -10
- package/src/llm/types.ts +6 -0
- package/src/mcp/tools/ask.ts +228 -0
- package/src/mcp/tools/changes.ts +80 -0
- package/src/mcp/tools/context.ts +28 -7
- package/src/mcp/tools/index.ts +38 -0
- package/src/pipeline/claim-verification-schema.ts +235 -0
- package/src/pipeline/claim-verification.ts +487 -0
- package/src/pipeline/claim-verifier.ts +474 -0
- package/src/pipeline/types.ts +25 -0
- package/src/sdk/client.ts +77 -2
- package/src/sdk/index.ts +7 -0
- package/src/sdk/types.ts +22 -0
- package/src/serve/doc-events.ts +12 -1
- package/src/serve/public/components/AskVerificationPanel.tsx +189 -0
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/pages/Ask.tsx +42 -4
- package/src/serve/resident-runtime.ts +22 -0
- package/src/serve/routes/api.ts +162 -3
- package/src/serve/routes/changes.ts +102 -0
- package/src/serve/server.ts +34 -0
- package/src/serve/watch-service.ts +9 -0
- package/src/store/index.ts +21 -0
- package/src/store/migrations/015-document-change-journal.ts +85 -0
- package/src/store/migrations/016-saved-capsules.ts +131 -0
- package/src/store/migrations/017-document-change-retention-counters.ts +33 -0
- package/src/store/migrations/018-saved-capsule-registration-epoch.ts +24 -0
- package/src/store/migrations/019-saved-capsule-registration-generation.ts +53 -0
- package/src/store/migrations/index.ts +10 -0
- package/src/store/sqlite/adapter.ts +291 -7
- package/src/store/sqlite/capsule-registry-store.ts +534 -0
- package/src/store/sqlite/change-journal-store.ts +473 -0
- package/src/store/types.ts +262 -0
package/src/store/types.ts
CHANGED
|
@@ -306,6 +306,17 @@ export interface DocumentInput {
|
|
|
306
306
|
ingestVersion?: number;
|
|
307
307
|
/** Fingerprint of normalized content type rules used for derived metadata */
|
|
308
308
|
contentTypeRulesFingerprint?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Change-journal metadata for a source lifecycle write. Conversion failures
|
|
311
|
+
* that change source/evidence identity are lifecycle writes; set false only
|
|
312
|
+
* for bookkeeping or repair that must not represent a source change.
|
|
313
|
+
*/
|
|
314
|
+
changeJournal?:
|
|
315
|
+
| false
|
|
316
|
+
| {
|
|
317
|
+
observedAtMs?: number;
|
|
318
|
+
structureDelta?: Partial<DocumentChangeStructureDelta>;
|
|
319
|
+
};
|
|
309
320
|
}
|
|
310
321
|
|
|
311
322
|
/** Result of upserting a document */
|
|
@@ -316,6 +327,174 @@ export interface UpsertDocumentResult {
|
|
|
316
327
|
docid: string;
|
|
317
328
|
}
|
|
318
329
|
|
|
330
|
+
/** Lifecycle transition persisted in the metadata-only document journal. */
|
|
331
|
+
export type DocumentChangeKind =
|
|
332
|
+
| "create"
|
|
333
|
+
| "update"
|
|
334
|
+
| "rename"
|
|
335
|
+
| "inactivate"
|
|
336
|
+
| "reactivate";
|
|
337
|
+
|
|
338
|
+
/** Bounded normalized additions/removals for one structural dimension. */
|
|
339
|
+
export interface DocumentChangeSet {
|
|
340
|
+
added: string[];
|
|
341
|
+
removed: string[];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Bounded normalized date-field changes. */
|
|
345
|
+
export interface DocumentChangeDateDelta extends DocumentChangeSet {
|
|
346
|
+
changed: string[];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** Reserved structural summaries populated by the sync delta pipeline. */
|
|
350
|
+
export interface DocumentChangeStructureDelta {
|
|
351
|
+
headings: DocumentChangeSet;
|
|
352
|
+
links: DocumentChangeSet;
|
|
353
|
+
typedEdges: DocumentChangeSet;
|
|
354
|
+
dates: DocumentChangeDateDelta;
|
|
355
|
+
truncated: boolean;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** One committed metadata-only document lifecycle transition. */
|
|
359
|
+
export interface DocumentChangeRow {
|
|
360
|
+
sequence: number;
|
|
361
|
+
documentId: number;
|
|
362
|
+
collection: string;
|
|
363
|
+
kind: DocumentChangeKind;
|
|
364
|
+
oldRelPath: string | null;
|
|
365
|
+
newRelPath: string | null;
|
|
366
|
+
oldDocid: string | null;
|
|
367
|
+
newDocid: string | null;
|
|
368
|
+
oldUri: string | null;
|
|
369
|
+
newUri: string | null;
|
|
370
|
+
oldSourceHash: string | null;
|
|
371
|
+
newSourceHash: string | null;
|
|
372
|
+
oldMirrorHash: string | null;
|
|
373
|
+
newMirrorHash: string | null;
|
|
374
|
+
oldActive: boolean | null;
|
|
375
|
+
newActive: boolean | null;
|
|
376
|
+
structureDelta: DocumentChangeStructureDelta;
|
|
377
|
+
observedAtMs: number;
|
|
378
|
+
byteSize: number;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Stable cursor page over retained document changes. */
|
|
382
|
+
export interface DocumentChangePage {
|
|
383
|
+
changes: DocumentChangeRow[];
|
|
384
|
+
nextCursor: string | null;
|
|
385
|
+
earliestCursor: string;
|
|
386
|
+
latestCursor: string;
|
|
387
|
+
cursorExpired: boolean;
|
|
388
|
+
truncated: boolean;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface DocumentChangeListOptions {
|
|
392
|
+
cursor?: string;
|
|
393
|
+
collection?: string;
|
|
394
|
+
documentId?: number;
|
|
395
|
+
/** Inclusive observed-time lower bound in Unix milliseconds. */
|
|
396
|
+
observedAfterMs?: number;
|
|
397
|
+
limit?: number;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Prefix-retention limits; all three are enforced together. */
|
|
401
|
+
export interface DocumentChangeRetentionPolicy {
|
|
402
|
+
maxAgeDays: number;
|
|
403
|
+
maxEntries: number;
|
|
404
|
+
maxBytes: number;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface DocumentChangeRetentionResult {
|
|
408
|
+
deleted: number;
|
|
409
|
+
remainingEntries: number;
|
|
410
|
+
remainingBytes: number;
|
|
411
|
+
earliestCursor: string;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export interface DocumentChangePurgeResult {
|
|
415
|
+
deleted: number;
|
|
416
|
+
earliestCursor: string;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export type SavedCapsuleNotificationPreference = "none" | "local";
|
|
420
|
+
export type SavedCapsuleTriggerKind = "manual" | "journal";
|
|
421
|
+
export type SavedCapsuleOperationStatus = "completed" | "failed";
|
|
422
|
+
export type SavedCapsuleAffectedQuestionState =
|
|
423
|
+
| "unaffected"
|
|
424
|
+
| "affected"
|
|
425
|
+
| "unknown";
|
|
426
|
+
|
|
427
|
+
export interface SavedCapsuleEvidenceReference {
|
|
428
|
+
evidenceId: string;
|
|
429
|
+
canonicalUri: string;
|
|
430
|
+
collection: string;
|
|
431
|
+
sourceHash: string;
|
|
432
|
+
mirrorHash: string;
|
|
433
|
+
passageHash: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface SavedCapsuleRegistration {
|
|
437
|
+
registrationId: string;
|
|
438
|
+
filePath: string;
|
|
439
|
+
fileHash: string;
|
|
440
|
+
capsuleId: string;
|
|
441
|
+
indexName: string;
|
|
442
|
+
question: string | null;
|
|
443
|
+
label: string | null;
|
|
444
|
+
notificationPreference: SavedCapsuleNotificationPreference;
|
|
445
|
+
registeredAtMs: number;
|
|
446
|
+
updatedAtMs: number;
|
|
447
|
+
lastAttemptedSequence: number;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export interface SavedCapsuleRegistrationRecord extends SavedCapsuleRegistration {
|
|
451
|
+
evidence: SavedCapsuleEvidenceReference[];
|
|
452
|
+
verification: SavedCapsuleVerificationRecord | null;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface SavedCapsuleVerificationRecord {
|
|
456
|
+
registrationId: string;
|
|
457
|
+
triggerKind: SavedCapsuleTriggerKind;
|
|
458
|
+
fromSequence: number;
|
|
459
|
+
throughSequence: number;
|
|
460
|
+
operationStatus: SavedCapsuleOperationStatus;
|
|
461
|
+
affectedQuestionState: SavedCapsuleAffectedQuestionState;
|
|
462
|
+
affectedReasons: string[];
|
|
463
|
+
receiptJson: string | null;
|
|
464
|
+
receiptHash: string | null;
|
|
465
|
+
errorCode: string | null;
|
|
466
|
+
errorMessage: string | null;
|
|
467
|
+
verifiedAtMs: number;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface SavedCapsuleVerificationExpectation {
|
|
471
|
+
registrationGeneration: number;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export interface SavedCapsuleReverificationState {
|
|
475
|
+
lastProcessedSequence: number;
|
|
476
|
+
registrationEpoch: number;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface SavedCapsuleRegistrationSnapshot {
|
|
480
|
+
registration: SavedCapsuleRegistrationRecord;
|
|
481
|
+
registrationGeneration: number;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export interface SavedCapsuleRegistrationInput extends Omit<
|
|
485
|
+
SavedCapsuleRegistration,
|
|
486
|
+
"registeredAtMs" | "updatedAtMs"
|
|
487
|
+
> {
|
|
488
|
+
registeredAtMs: number;
|
|
489
|
+
updatedAtMs: number;
|
|
490
|
+
evidence: SavedCapsuleEvidenceReference[];
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface RenameDocumentOptions {
|
|
494
|
+
observedAtMs?: number;
|
|
495
|
+
structureDelta?: Partial<DocumentChangeStructureDelta>;
|
|
496
|
+
}
|
|
497
|
+
|
|
319
498
|
/** Input for a single chunk */
|
|
320
499
|
export interface ChunkInput {
|
|
321
500
|
seq: number;
|
|
@@ -1234,6 +1413,17 @@ export interface StorePort {
|
|
|
1234
1413
|
doc: DocumentInput
|
|
1235
1414
|
): Promise<StoreResult<UpsertDocumentResult>>;
|
|
1236
1415
|
|
|
1416
|
+
/**
|
|
1417
|
+
* Explicitly rename one document while preserving its stable database id.
|
|
1418
|
+
* External move inference deliberately remains outside this contract.
|
|
1419
|
+
*/
|
|
1420
|
+
renameDocument(
|
|
1421
|
+
collection: string,
|
|
1422
|
+
oldRelPath: string,
|
|
1423
|
+
newRelPath: string,
|
|
1424
|
+
options?: RenameDocumentOptions
|
|
1425
|
+
): Promise<StoreResult<DocumentRow>>;
|
|
1426
|
+
|
|
1237
1427
|
/**
|
|
1238
1428
|
* Get document by collection and relative path.
|
|
1239
1429
|
*/
|
|
@@ -1316,6 +1506,78 @@ export interface StorePort {
|
|
|
1316
1506
|
relPaths: string[]
|
|
1317
1507
|
): Promise<StoreResult<number>>;
|
|
1318
1508
|
|
|
1509
|
+
/** List retained document changes using an opaque monotonic cursor. */
|
|
1510
|
+
listDocumentChanges(
|
|
1511
|
+
options?: DocumentChangeListOptions
|
|
1512
|
+
): Promise<StoreResult<DocumentChangePage>>;
|
|
1513
|
+
|
|
1514
|
+
/** Enforce age, entry-count, and byte limits by deleting an oldest prefix. */
|
|
1515
|
+
enforceDocumentChangeRetention(
|
|
1516
|
+
policy: DocumentChangeRetentionPolicy,
|
|
1517
|
+
nowMs: number
|
|
1518
|
+
): Promise<StoreResult<DocumentChangeRetentionResult>>;
|
|
1519
|
+
|
|
1520
|
+
/** Purge the journal while retaining a cursor-expiry boundary. */
|
|
1521
|
+
purgeDocumentChanges(): Promise<StoreResult<DocumentChangePurgeResult>>;
|
|
1522
|
+
|
|
1523
|
+
/** Register one user-owned Capsule file and its metadata-only evidence refs. */
|
|
1524
|
+
upsertSavedCapsuleRegistration(
|
|
1525
|
+
input: SavedCapsuleRegistrationInput
|
|
1526
|
+
): Promise<StoreResult<SavedCapsuleRegistrationRecord>>;
|
|
1527
|
+
|
|
1528
|
+
/** List saved Capsule registrations in deterministic identity order. */
|
|
1529
|
+
listSavedCapsuleRegistrations(): Promise<
|
|
1530
|
+
StoreResult<SavedCapsuleRegistrationRecord[]>
|
|
1531
|
+
>;
|
|
1532
|
+
|
|
1533
|
+
/** Read one saved Capsule registration and its latest verification. */
|
|
1534
|
+
getSavedCapsuleRegistration(
|
|
1535
|
+
registrationId: string
|
|
1536
|
+
): Promise<StoreResult<SavedCapsuleRegistrationRecord | null>>;
|
|
1537
|
+
|
|
1538
|
+
/** Read one registration with its internal CAS generation atomically. */
|
|
1539
|
+
getSavedCapsuleRegistrationSnapshot(
|
|
1540
|
+
registrationId: string
|
|
1541
|
+
): Promise<StoreResult<SavedCapsuleRegistrationSnapshot | null>>;
|
|
1542
|
+
|
|
1543
|
+
/** Remove one saved Capsule registration and its subordinate metadata. */
|
|
1544
|
+
deleteSavedCapsuleRegistration(
|
|
1545
|
+
registrationId: string
|
|
1546
|
+
): Promise<StoreResult<boolean>>;
|
|
1547
|
+
|
|
1548
|
+
/** Find registrations whose evidence intersects a retained journal range. */
|
|
1549
|
+
listSavedCapsuleIdsAffectedByChanges(
|
|
1550
|
+
afterSequence: number,
|
|
1551
|
+
throughSequence: number,
|
|
1552
|
+
limit: number
|
|
1553
|
+
): Promise<StoreResult<{ registrationIds: string[]; truncated: boolean }>>;
|
|
1554
|
+
|
|
1555
|
+
/**
|
|
1556
|
+
* Persist a receipt/failure only for the expected registration identity.
|
|
1557
|
+
* Returns false without advancing sequence state when the snapshot is stale.
|
|
1558
|
+
*/
|
|
1559
|
+
upsertSavedCapsuleVerification(
|
|
1560
|
+
verification: SavedCapsuleVerificationRecord,
|
|
1561
|
+
expectedRegistration: SavedCapsuleVerificationExpectation
|
|
1562
|
+
): Promise<StoreResult<boolean>>;
|
|
1563
|
+
|
|
1564
|
+
/** Read the resident scheduler's durable journal high-water sequence. */
|
|
1565
|
+
getSavedCapsuleReverificationSequence(): Promise<StoreResult<number>>;
|
|
1566
|
+
|
|
1567
|
+
/** Atomically read the high-water sequence and registration generation. */
|
|
1568
|
+
getSavedCapsuleReverificationState(): Promise<
|
|
1569
|
+
StoreResult<SavedCapsuleReverificationState>
|
|
1570
|
+
>;
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Advance the high-water sequence only when no registration changed during
|
|
1574
|
+
* the scheduler drain. Returns false when the caller must retry.
|
|
1575
|
+
*/
|
|
1576
|
+
setSavedCapsuleReverificationSequence(
|
|
1577
|
+
sequence: number,
|
|
1578
|
+
expectedRegistrationEpoch: number
|
|
1579
|
+
): Promise<StoreResult<boolean>>;
|
|
1580
|
+
|
|
1319
1581
|
// ─────────────────────────────────────────────────────────────────────────
|
|
1320
1582
|
// Content (content-addressed)
|
|
1321
1583
|
// ─────────────────────────────────────────────────────────────────────────
|