@tangle-network/agent-knowledge 1.12.1 → 2.0.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/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { S as SourceRecord, c as KnowledgeIndex, d as KnowledgeSearchResult, e as SourceRegistry, f as KnowledgeEvent, g as KnowledgeEventType, h as KnowledgePage, b as KnowledgeGraph, i as KnowledgeLintFinding, j as KnowledgeWriteBlock, k as KnowledgeClaim, l as KnowledgeRelease, m as KnowledgeWriteParseResult } from './types-C17sAROL.js';
2
2
  export { C as ClaimRef, n as KnowledgeBaseCandidate, K as KnowledgeGraphEdge, a as KnowledgeGraphNode, o as KnowledgeId, p as KnowledgePolicy, q as KnowledgeRelation, r as KnowledgeUnit, s as SourceAnchor } from './types-C17sAROL.js';
3
- import { KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan, ControlRuntimeConfig, ControlEvalResult, AnalystSeverity, AnalystFinding, RunRecord, ReleaseTraceEvidence, GateDecision, ReleaseConfidenceScorecard } from '@tangle-network/agent-eval';
4
- import { R as RunRetrievalImprovementLoopResult, a as RunRetrievalImprovementLoopOptions, b as RetrievalConfig } from './index-Cj5jRXOz.js';
5
- export { B as BuildRetrievalBenchmarkCasesFromQrelsOptions, c as BuildRetrievalEvalDispatchOptions, d as BuildRetrievalParameterCandidatesOptions, I as INDUSTRY_MEMORY_BENCHMARKS, e as INDUSTRY_RAG_BENCHMARKS, K as KnowledgeAnswerBenchmarkCase, f as KnowledgeAnswerBenchmarkTaskKind, g as KnowledgeBenchmarkArtifact, h as KnowledgeBenchmarkCase, i as KnowledgeBenchmarkCaseBase, j as KnowledgeBenchmarkDistribution, k as KnowledgeBenchmarkEvaluation, l as KnowledgeBenchmarkFamily, m as KnowledgeBenchmarkReport, n as KnowledgeBenchmarkResponder, o as KnowledgeBenchmarkScenario, p as KnowledgeBenchmarkSliceSummary, q as KnowledgeBenchmarkSource, r as KnowledgeBenchmarkSpec, s as KnowledgeBenchmarkSplit, t as KnowledgeBenchmarkTaskKind, u as KnowledgeClaimMatcher, v as KnowledgeMemoryBenchmarkCase, w as KnowledgeMemoryBenchmarkTaskKind, x as KnowledgeMemoryEvent, y as KnowledgeMemoryFactMatcher, z as KnowledgeRetrievalBenchmarkCase, A as KnowledgeRetrievalBenchmarkQrel, C as KnowledgeRetrievalBenchmarkQuery, M as MemoryAdapterBenchmarkCandidate, D as MemoryAdapterBenchmarkRankingRow, E as RetrievalEvalArtifact, F as RetrievalEvalRetriever, G as RetrievalEvalRetrieverInput, H as RetrievalEvalRetrieverResult, J as RetrievalEvalScenario, L as RetrievalGoldTarget, N as RetrievalMetricSummary, O as RetrievalMetricWeights, P as RetrievalParameterSearchSpace, Q as RetrievalParameterSweepProposerOptions, S as RetrievalRecallJudgeOptions, T as RetrievedKnowledgeHit, U as RetrievedSourceSpan, V as RunKnowledgeBenchmarkSuiteOptions, W as RunKnowledgeBenchmarkSuiteResult, X as RunMemoryAdapterBenchmarkOptions, Y as RunMemoryAdapterBenchmarkResult, Z as buildFirstPartyMemoryLifecycleBenchmarkCases, _ as buildIndustryMemoryBenchmarkSmokeCases, $ as buildIndustryRagBenchmarkSmokeCases, a0 as buildKnowledgeBenchmarkScenarios, a1 as buildRetrievalBenchmarkCasesFromQrels, a2 as buildRetrievalEvalDispatch, a3 as buildRetrievalParameterCandidates, a4 as createInMemoryBenchmarkAdapter, a5 as createMemoryAdapterBenchmarkResponder, a6 as createNoopMemoryBenchmarkAdapter, a7 as isKnowledgeMemoryBenchmarkCase, a8 as knowledgeBenchmarkJudge, a9 as parseKnowledgeBenchmarkJsonl, aa as parseKnowledgeBenchmarkQrels, ab as renderKnowledgeBenchmarkReportMarkdown, ac as respondToIndustryMemoryBenchmarkSmokeCase, ad as respondToIndustryRagBenchmarkSmokeCase, ae as retrievalConfigFromSurface, af as retrievalConfigSurface, ag as retrievalParameterSweepProposer, ah as retrievalRecallJudge, ai as runKnowledgeBenchmarkSuite, aj as runMemoryAdapterBenchmark, ak as runRetrievalImprovementLoop, al as scoreKnowledgeBenchmarkArtifact, am as scoreMemoryBenchmarkArtifact, an as scoreRetrievalArtifact, ao as summarizeKnowledgeBenchmarkCampaign } from './index-Cj5jRXOz.js';
3
+ import { KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan, ControlRuntimeConfig, ControlEvalResult, RunRecord, AnalystSeverity, AnalystFinding, ReleaseTraceEvidence, GateDecision, ReleaseConfidenceScorecard } from '@tangle-network/agent-eval';
4
+ import { R as RunRetrievalImprovementLoopResult, a as RunRetrievalImprovementLoopOptions } from './index-BLxw1I_F.js';
5
+ export { B as BuildRetrievalBenchmarkCasesFromQrelsOptions, b as BuildRetrievalEvalDispatchOptions, c as BuildRetrievalParameterCandidatesOptions, I as INDUSTRY_MEMORY_BENCHMARKS, d as INDUSTRY_RAG_BENCHMARKS, K as KnowledgeAnswerBenchmarkCase, e as KnowledgeAnswerBenchmarkTaskKind, f as KnowledgeBenchmarkArtifact, g as KnowledgeBenchmarkCase, h as KnowledgeBenchmarkCaseBase, i as KnowledgeBenchmarkDistribution, j as KnowledgeBenchmarkEvaluation, k as KnowledgeBenchmarkFamily, l as KnowledgeBenchmarkReport, m as KnowledgeBenchmarkResponder, n as KnowledgeBenchmarkScenario, o as KnowledgeBenchmarkSliceSummary, p as KnowledgeBenchmarkSource, q as KnowledgeBenchmarkSpec, r as KnowledgeBenchmarkSplit, s as KnowledgeBenchmarkTaskKind, t as KnowledgeClaimMatcher, u as KnowledgeMemoryBenchmarkCase, v as KnowledgeMemoryBenchmarkTaskKind, w as KnowledgeMemoryEvent, x as KnowledgeMemoryFactMatcher, y as KnowledgeRetrievalBenchmarkCase, z as KnowledgeRetrievalBenchmarkQrel, A as KnowledgeRetrievalBenchmarkQuery, M as MemoryAdapterBenchmarkCandidate, C as MemoryAdapterBenchmarkRankingRow, D as RetrievalConfig, E as RetrievalEvalArtifact, F as RetrievalEvalRetriever, G as RetrievalEvalRetrieverInput, H as RetrievalEvalRetrieverResult, J as RetrievalEvalScenario, L as RetrievalGoldTarget, N as RetrievalMetricSummary, O as RetrievalMetricWeights, P as RetrievalParameterSearchSpace, Q as RetrievalParameterSweepProposerOptions, S as RetrievalRecallJudgeOptions, T as RetrievedKnowledgeHit, U as RetrievedSourceSpan, V as RunKnowledgeBenchmarkSuiteOptions, W as RunKnowledgeBenchmarkSuiteResult, X as RunMemoryAdapterBenchmarkOptions, Y as RunMemoryAdapterBenchmarkResult, Z as buildFirstPartyMemoryLifecycleBenchmarkCases, _ as buildIndustryMemoryBenchmarkSmokeCases, $ as buildIndustryRagBenchmarkSmokeCases, a0 as buildKnowledgeBenchmarkScenarios, a1 as buildRetrievalBenchmarkCasesFromQrels, a2 as buildRetrievalEvalDispatch, a3 as buildRetrievalParameterCandidates, a4 as createInMemoryBenchmarkAdapter, a5 as createMemoryAdapterBenchmarkResponder, a6 as createNoopMemoryBenchmarkAdapter, a7 as isKnowledgeMemoryBenchmarkCase, a8 as knowledgeBenchmarkJudge, a9 as parseKnowledgeBenchmarkJsonl, aa as parseKnowledgeBenchmarkQrels, ab as renderKnowledgeBenchmarkReportMarkdown, ac as respondToIndustryMemoryBenchmarkSmokeCase, ad as respondToIndustryRagBenchmarkSmokeCase, ae as retrievalConfigFromSurface, af as retrievalConfigSurface, ag as retrievalParameterSweepProposer, ah as retrievalRecallJudge, ai as runKnowledgeBenchmarkSuite, aj as runMemoryAdapterBenchmark, ak as runRetrievalImprovementLoop, al as scoreKnowledgeBenchmarkArtifact, am as scoreMemoryBenchmarkArtifact, an as scoreRetrievalArtifact, ao as summarizeKnowledgeBenchmarkCampaign } from './index-BLxw1I_F.js';
6
6
  import { KnowledgeFragment } from './sources/index.js';
7
7
  export { CornellLiiSelector, CornellLiiSourceOptions, FetchOpts, FragmentProvenance, IRS_DIMENSION_HINTS, IrsPublicationsSourceOptions, KnowledgeSource, MAX_RESPONSE_BYTES, MIN_REQUEST_GAP_MS, POLITE_USER_AGENT, PoliteFetchOptions, PoliteFetchResult, StateSosEntity, StateSosSourceConfig, __resetHttpThrottle, createCornellLiiSource, createIrsPublicationsSource, createStateSosSource, extractLinks, firstMatch, htmlToText, innerHtmlById, looksLikeBlockPage, politeFetch } from './sources/index.js';
8
+ import { z } from 'zod';
8
9
  import { JsonValue, Scenario, JudgeConfig } from '@tangle-network/agent-eval/campaign';
9
10
  export { AgentMemoryHitSchema, AgentMemoryKindSchema, AgentMemoryScopeSchema, AgentMemoryWriteInputSchema, Neo4jAgentMemoryAdapterOptions, createNeo4jAgentMemoryAdapter, defaultGetMemoryContext, memoryHitToSourceRecord, memoryWriteResultToSourceRecord, renderMemoryContext } from './memory/index.js';
10
11
  export { A as AgentMemoryAdapter, b as AgentMemoryContext, c as AgentMemoryHit, d as AgentMemoryKind, a as AgentMemoryScope, e as AgentMemorySearchOptions, f as AgentMemoryWriteInput, g as AgentMemoryWriteResult, R as RetrievalHoldoutBypassReason, h as RetrievalHoldoutCallContext, i as RetrievalHoldoutConfig, j as RetrievalHoldoutEligibleItem, k as RetrievalHoldoutEvent, l as RetrievalHoldoutOffPolicyOptions, m as RetrievalHoldoutOffPolicyResult, n as RetrievalHoldoutResult, o as RetrievalHoldoutSessionState, p as RetrievalHoldoutSessionSummary, q as applyRetrievalHoldout, r as applySessionStickyRetrievalHoldout, s as deterministicRng, t as emitRetrievalHoldoutBypass, u as resetRetrievalHoldoutRegistry, v as retrievalHoldoutConfigHash, w as toOffPolicyTrajectory } from './types-CjqPcTTK.js';
11
- import { z } from 'zod';
12
12
  import '@tangle-network/agent-eval/rl';
13
13
 
14
14
  interface SourceAdapterInput {
@@ -1066,9 +1066,8 @@ interface FileSystemFreshnessStoreOptions {
1066
1066
  * indexed by `${workspaceId}::${sourceId}`. Reads parse on every call —
1067
1067
  * cron tick rate is well below the cost of one JSON parse.
1068
1068
  *
1069
- * Concurrent writes from a single process serialize through `writeQueue`.
1070
- * Cross-process concurrency is undefined; the consuming app should run the
1071
- * cron in a single worker.
1069
+ * Writes share the package-wide filesystem lock, so multiple workers cannot
1070
+ * overwrite one another or run through an interrupted knowledge promotion.
1072
1071
  */
1073
1072
  declare function createFileSystemFreshnessStore(options: FileSystemFreshnessStoreOptions): KnowledgeFreshnessStore;
1074
1073
  /**
@@ -1769,11 +1768,28 @@ declare function toRagCheckerRecords(cases: readonly RagAnswerEvalCase[]): {
1769
1768
  declare function scoreKnowledgeBaseIndex(index: KnowledgeIndex, options?: KnowledgeBaseQualityOptions): KnowledgeBaseQualityReport;
1770
1769
 
1771
1770
  type KnowledgeImprovementStatus = 'running' | 'candidate-ready' | 'promoted' | 'rejected' | 'blocked';
1771
+ interface KnowledgeImprovementMetricProvenanceBase {
1772
+ evaluator: string;
1773
+ version: string;
1774
+ }
1775
+ type KnowledgeImprovementMetricProvenance = (KnowledgeImprovementMetricProvenanceBase & {
1776
+ method: 'deterministic';
1777
+ }) | (KnowledgeImprovementMetricProvenanceBase & {
1778
+ method: 'sampled' | 'composite';
1779
+ corpusHash: string;
1780
+ runRecords: RunRecord[];
1781
+ }) | (KnowledgeImprovementMetricProvenanceBase & {
1782
+ method: 'model';
1783
+ model: string;
1784
+ corpusHash: string;
1785
+ runRecords: RunRecord[];
1786
+ });
1772
1787
  interface KnowledgeImprovementMetric {
1773
1788
  score: number;
1774
1789
  passed: boolean;
1775
1790
  dimensions?: Record<string, number>;
1776
1791
  notes?: string;
1792
+ provenance: KnowledgeImprovementMetricProvenance;
1777
1793
  }
1778
1794
  interface KnowledgeImprovementEvaluationInput {
1779
1795
  runId: string;
@@ -1792,35 +1808,19 @@ interface KnowledgeImprovementEvaluationInput {
1792
1808
  signal?: AbortSignal;
1793
1809
  }
1794
1810
  type KnowledgeImprovementEvaluator = (input: KnowledgeImprovementEvaluationInput) => Promise<KnowledgeImprovementMetric> | KnowledgeImprovementMetric;
1795
- interface KnowledgeImprovementLifecycleRecord {
1796
- stage: 'candidate-update' | 'candidate-evaluation';
1797
- phases: readonly RagKnowledgeImprovementPhaseResult[];
1798
- findingCount: number;
1799
- retrievalWinnerConfig?: RetrievalConfig;
1800
- answerQuality?: RagAnswerQualityResult;
1801
- promotionDecision?: RagPromotionResult;
1802
- }
1803
1811
  interface KnowledgeImprovementCandidateRecord {
1804
1812
  iteration: number;
1805
1813
  candidateId: string;
1806
- candidateRoot: string;
1807
1814
  baseHash: string;
1808
1815
  candidateHash?: string;
1816
+ evidenceHash?: string;
1817
+ promotionPlanHash?: string;
1809
1818
  status: KnowledgeImprovementStatus;
1810
1819
  createdAt: string;
1811
1820
  updatedAt: string;
1812
- validation?: ValidateKnowledgeResult;
1813
- kbQuality?: KnowledgeBaseQualityReport;
1814
- readinessBlockingMissing?: number;
1815
- evaluation?: KnowledgeImprovementMetric;
1816
- lifecycle?: readonly KnowledgeImprovementLifecycleRecord[];
1817
- retrievalWinnerConfig?: RetrievalConfig;
1818
- answerQuality?: RagAnswerQualityResult;
1819
- promotionDecision?: RagPromotionResult;
1820
- notes?: string;
1821
1821
  }
1822
1822
  interface KnowledgeImprovementRunState {
1823
- version: 1;
1823
+ schemaVersion: 1;
1824
1824
  runId: string;
1825
1825
  root: string;
1826
1826
  goal: string;
@@ -1835,13 +1835,122 @@ interface KnowledgeImprovementRunState {
1835
1835
  }
1836
1836
  interface KnowledgeImprovementResult {
1837
1837
  runId: string;
1838
- runDir: string;
1839
1838
  state: KnowledgeImprovementRunState;
1840
1839
  candidate?: KnowledgeImprovementCandidateRecord;
1840
+ evaluation?: KnowledgeImprovementMetric;
1841
1841
  lifecycle?: RunRagKnowledgeImprovementLoopResult;
1842
1842
  promoted: boolean;
1843
1843
  blocked: boolean;
1844
1844
  }
1845
+ declare const KnowledgeImprovementRunStateSchema: z.ZodObject<{
1846
+ schemaVersion: z.ZodLiteral<1>;
1847
+ runId: z.ZodString;
1848
+ root: z.ZodString;
1849
+ goal: z.ZodString;
1850
+ status: z.ZodEnum<{
1851
+ rejected: "rejected";
1852
+ promoted: "promoted";
1853
+ running: "running";
1854
+ "candidate-ready": "candidate-ready";
1855
+ blocked: "blocked";
1856
+ }>;
1857
+ baseHash: z.ZodString;
1858
+ createdAt: z.ZodISODateTime;
1859
+ updatedAt: z.ZodISODateTime;
1860
+ ownerId: z.ZodOptional<z.ZodString>;
1861
+ candidates: z.ZodArray<z.ZodObject<{
1862
+ iteration: z.ZodNumber;
1863
+ candidateId: z.ZodString;
1864
+ baseHash: z.ZodString;
1865
+ candidateHash: z.ZodOptional<z.ZodString>;
1866
+ evidenceHash: z.ZodOptional<z.ZodString>;
1867
+ promotionPlanHash: z.ZodOptional<z.ZodString>;
1868
+ status: z.ZodEnum<{
1869
+ rejected: "rejected";
1870
+ promoted: "promoted";
1871
+ running: "running";
1872
+ "candidate-ready": "candidate-ready";
1873
+ blocked: "blocked";
1874
+ }>;
1875
+ createdAt: z.ZodISODateTime;
1876
+ updatedAt: z.ZodISODateTime;
1877
+ }, z.core.$strict>>;
1878
+ promotedCandidateId: z.ZodOptional<z.ZodString>;
1879
+ blockedReason: z.ZodOptional<z.ZodString>;
1880
+ }, z.core.$strict>;
1881
+ declare const KnowledgeImprovementEvidenceSchema: z.ZodObject<{
1882
+ schemaVersion: z.ZodLiteral<1>;
1883
+ kind: z.ZodLiteral<"knowledge-improvement-evidence">;
1884
+ runId: z.ZodString;
1885
+ candidateId: z.ZodString;
1886
+ iteration: z.ZodNumber;
1887
+ goalHash: z.ZodString;
1888
+ baseHash: z.ZodString;
1889
+ candidateHash: z.ZodString;
1890
+ promotionPlanHash: z.ZodString;
1891
+ validation: z.ZodUnknown;
1892
+ readiness: z.ZodNullable<z.ZodUnknown>;
1893
+ kbQuality: z.ZodUnknown;
1894
+ evaluation: z.ZodObject<{
1895
+ score: z.ZodNumber;
1896
+ passed: z.ZodBoolean;
1897
+ dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
1898
+ notes: z.ZodOptional<z.ZodString>;
1899
+ provenance: z.ZodDiscriminatedUnion<[z.ZodObject<{
1900
+ evaluator: z.ZodString;
1901
+ version: z.ZodString;
1902
+ method: z.ZodLiteral<"deterministic">;
1903
+ }, z.core.$strict>, z.ZodObject<{
1904
+ evaluator: z.ZodString;
1905
+ version: z.ZodString;
1906
+ method: z.ZodEnum<{
1907
+ composite: "composite";
1908
+ sampled: "sampled";
1909
+ }>;
1910
+ corpusHash: z.ZodString;
1911
+ runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1912
+ }, z.core.$strict>, z.ZodObject<{
1913
+ evaluator: z.ZodString;
1914
+ version: z.ZodString;
1915
+ method: z.ZodLiteral<"model">;
1916
+ model: z.ZodString;
1917
+ corpusHash: z.ZodString;
1918
+ runRecords: z.ZodArray<z.ZodCustom<RunRecord, RunRecord>>;
1919
+ }, z.core.$strict>], "method">;
1920
+ }, z.core.$strict>;
1921
+ lifecycle: z.ZodNullable<z.ZodUnknown>;
1922
+ }, z.core.$strict>;
1923
+ type KnowledgeImprovementEvidence = z.infer<typeof KnowledgeImprovementEvidenceSchema>;
1924
+ /** Portable identity of one measured candidate. Paths and mutable run state are deliberately excluded. */
1925
+ declare const KnowledgeImprovementCandidateRefSchema: z.ZodObject<{
1926
+ schemaVersion: z.ZodLiteral<1>;
1927
+ kind: z.ZodLiteral<"knowledge-improvement-candidate">;
1928
+ runId: z.ZodString;
1929
+ candidateId: z.ZodString;
1930
+ goalHash: z.ZodString;
1931
+ baseHash: z.ZodString;
1932
+ candidateHash: z.ZodString;
1933
+ evidenceHash: z.ZodString;
1934
+ promotionPlanHash: z.ZodString;
1935
+ }, z.core.$strict>;
1936
+ type KnowledgeImprovementCandidateRef = z.infer<typeof KnowledgeImprovementCandidateRefSchema>;
1937
+ interface PromoteKnowledgeCandidateOptions {
1938
+ root: string;
1939
+ candidate: KnowledgeImprovementCandidateRef;
1940
+ ownerId?: string;
1941
+ leaseTtlMs?: number;
1942
+ now?: () => Date;
1943
+ onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1944
+ }
1945
+ interface UseKnowledgeImprovementCandidateOptions {
1946
+ root: string;
1947
+ candidate: KnowledgeImprovementCandidateRef;
1948
+ }
1949
+ interface ResolvedKnowledgeImprovementCandidate {
1950
+ root: string;
1951
+ candidate: KnowledgeImprovementCandidateRef;
1952
+ evaluation: KnowledgeImprovementMetric;
1953
+ }
1845
1954
  interface KnowledgeImprovementRetrievalOptions extends Omit<RunRetrievalImprovementLoopOptions, 'index' | 'runDir'> {
1846
1955
  runDir?: RunRetrievalImprovementLoopOptions['runDir'];
1847
1956
  }
@@ -1859,11 +1968,9 @@ interface KnowledgeImprovementOptions {
1859
1968
  root: string;
1860
1969
  goal: string;
1861
1970
  runId?: string;
1862
- runDir?: string;
1863
1971
  ownerId?: string;
1864
1972
  leaseTtlMs?: number;
1865
1973
  resume?: boolean;
1866
- promote?: boolean;
1867
1974
  maxCandidates?: number;
1868
1975
  candidateResearchIterations?: number;
1869
1976
  strict?: ValidateKnowledgeOptions['strict'];
@@ -1888,8 +1995,19 @@ interface KnowledgeImprovementOptions {
1888
1995
  }
1889
1996
  declare function knowledgeImprovementRunId(root: string, goal: string): string;
1890
1997
  declare function knowledgeImprovementRunDir(root: string, runId: string): string;
1891
- declare function loadKnowledgeImprovementState(root: string, runId: string, runDir?: string): Promise<KnowledgeImprovementRunState | null>;
1998
+ declare function loadKnowledgeImprovementState(root: string, runId: string): Promise<KnowledgeImprovementRunState | null>;
1999
+ /** Freeze the exact knowledge bytes and measured evidence a later approval may promote. */
2000
+ declare function knowledgeImprovementCandidateRef(result: Pick<KnowledgeImprovementResult, 'runId' | 'state' | 'candidate'>): KnowledgeImprovementCandidateRef;
2001
+ /** Use one measured snapshot while its directory identity remains open and stable. */
2002
+ declare function withKnowledgeImprovementCandidate<T>(options: UseKnowledgeImprovementCandidateOptions, use: (candidate: ResolvedKnowledgeImprovementCandidate) => Promise<T> | T): Promise<T>;
2003
+ /** Promote one previously measured candidate without rerunning research or evaluation. */
2004
+ declare function promoteKnowledgeCandidate(options: PromoteKnowledgeCandidateOptions): Promise<KnowledgeImprovementResult>;
1892
2005
  declare function improveKnowledgeBase(options: KnowledgeImprovementOptions): Promise<KnowledgeImprovementResult>;
2006
+ interface KnowledgeImprovementEvent extends Record<string, unknown> {
2007
+ at: string;
2008
+ type: string;
2009
+ }
2010
+ declare function loadKnowledgeImprovementEvents(root: string, runId: string): Promise<KnowledgeImprovementEvent[]>;
1893
2011
  declare function hashKnowledgeBase(root: string): Promise<string>;
1894
2012
 
1895
2013
  interface KbStore {
@@ -1920,12 +2038,22 @@ declare class MemoryKbStore implements KbStore {
1920
2038
  putEvent(event: KnowledgeEvent): Promise<void>;
1921
2039
  listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
1922
2040
  }
1923
- declare class FileSystemKbStore extends MemoryKbStore {
2041
+ declare class FileSystemKbStore implements KbStore {
1924
2042
  private readonly dir;
1925
2043
  constructor(dir: string);
2044
+ putSource(source: SourceRecord): Promise<void>;
2045
+ getSource(id: string): Promise<SourceRecord | null>;
2046
+ listSources(): Promise<SourceRecord[]>;
2047
+ putPage(page: KnowledgePage): Promise<void>;
2048
+ getPage(idOrPath: string): Promise<KnowledgePage | null>;
2049
+ listPages(): Promise<KnowledgePage[]>;
1926
2050
  putIndex(index: KnowledgeIndex): Promise<void>;
1927
2051
  getIndex(): Promise<KnowledgeIndex | null>;
1928
2052
  putEvent(event: KnowledgeEvent): Promise<void>;
2053
+ listEvents(query?: KnowledgeEventQuery): Promise<KnowledgeEvent[]>;
2054
+ private updateIndex;
2055
+ private readIndex;
2056
+ private readEvents;
1929
2057
  }
1930
2058
 
1931
2059
  declare function lintKnowledgeIndex(index: KnowledgeIndex): KnowledgeLintFinding[];
@@ -2004,6 +2132,20 @@ declare function materialFactsSurfacedInText(company: CompanyEvalCase, kbText: s
2004
2132
  */
2005
2133
  declare function materialFactsSurfaced(kb: string | KnowledgeIndex, checklist: CompanyEvalCase): Promise<MaterialFactsResult>;
2006
2134
 
2135
+ interface PendingKnowledgeMutation {
2136
+ transactionId: string;
2137
+ purpose: string;
2138
+ createdAt: string;
2139
+ direction: 'apply' | 'rollback';
2140
+ paths: string[];
2141
+ }
2142
+ interface RecoverPendingKnowledgeMutationOptions {
2143
+ transactionId: string;
2144
+ action: 'apply' | 'rollback';
2145
+ }
2146
+ declare function inspectPendingKnowledgeMutation(root: string): Promise<PendingKnowledgeMutation | null>;
2147
+ declare function recoverPendingKnowledgeMutation(root: string, options: RecoverPendingKnowledgeMutationOptions): Promise<void>;
2148
+
2007
2149
  /**
2008
2150
  * Bridge from `AnalystFinding` (agent-eval) to knowledge proposals.
2009
2151
  *
@@ -2335,6 +2477,8 @@ declare const SourceRecordSchema: z.ZodObject<{
2335
2477
  timestampMs: z.ZodOptional<z.ZodNumber>;
2336
2478
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2337
2479
  }, z.core.$strip>>>;
2480
+ validUntil: z.ZodOptional<z.ZodISODateTime>;
2481
+ lastVerifiedAt: z.ZodOptional<z.ZodISODateTime>;
2338
2482
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2339
2483
  createdAt: z.ZodString;
2340
2484
  }, z.core.$strip>;
@@ -2385,6 +2529,8 @@ declare const KnowledgeIndexSchema: z.ZodObject<{
2385
2529
  timestampMs: z.ZodOptional<z.ZodNumber>;
2386
2530
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2387
2531
  }, z.core.$strip>>>;
2532
+ validUntil: z.ZodOptional<z.ZodISODateTime>;
2533
+ lastVerifiedAt: z.ZodOptional<z.ZodISODateTime>;
2388
2534
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2389
2535
  createdAt: z.ZodString;
2390
2536
  }, z.core.$strip>>;
@@ -2516,4 +2662,4 @@ declare function normalizeLinkTarget(target: string): string;
2516
2662
  declare function isSafeKnowledgePath(path: string, allowedPrefixes?: string[]): boolean;
2517
2663
  declare function parseKnowledgeWriteBlocks(text: string, allowedPrefixes?: string[]): KnowledgeWriteParseResult;
2518
2664
 
2519
- export { type AdaptiveDecision, type AdaptiveDriverOptions, type AdaptiveResearchDriver, type AdaptiveStats, type AddSourceOptions, type AddSourceTextInput, type ApplyWriteBlocksResult, type BuildEvalKnowledgeBundleOptions, type ChunkingOptions, type ClaimGroundingDriverOptions, type CompanyEvalCase, type D1Adapter, type DedupReason, type DeepQuestion, type DeepQuestionKind, type DefineReadinessSpecInput, type DetectChangesOptions, type DetectChangesResult, type DiscoveryLoopResult, type DiscoveryLoopRound, type DiscoveryLoopStopReason, type DiscoveryResult, type DiscoveryTask, type DriverResearchContext, type EvalKnowledgeBundleBuildResult, type EvaluateKnowledgeBaseReadinessOptions, type ExpectedGroup, type ExternalRagEvalScore, type FactResult, type FileSystemFreshnessStoreOptions, FileSystemKbStore, type FreshnessKey, type FreshnessMark, type FreshnessRecord, type FreshnessTtl, type GroundClaimOptions, type GroundingResult, type KbStore, KnowledgeBaseCandidateSchema, type KnowledgeBaseQualityOptions, type KnowledgeBaseQualityReport, type KnowledgeBaseReadinessEvaluation, type KnowledgeChange, type KnowledgeChangeKind, type KnowledgeChunk, KnowledgeClaim, type KnowledgeControlLoopAction, type KnowledgeControlLoopActionResult, type KnowledgeControlLoopAdapter, type KnowledgeControlLoopAdapterOptions, type KnowledgeControlLoopState, type KnowledgeDiscoveryDispatcher, type KnowledgeDiscoveryWorker, KnowledgeEvent, type KnowledgeEventQuery, KnowledgeEventSchema, KnowledgeEventType, type KnowledgeExplanation, KnowledgeFragment, type KnowledgeFreshnessStore, type KnowledgeGap, KnowledgeGraph, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementLifecycleRecord, type KnowledgeImprovementMetric, type KnowledgeImprovementOptions, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, type KnowledgeImprovementStatus, type KnowledgeImprovementUpdate, type KnowledgeImprovementUpdateInput, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, KnowledgePage, KnowledgePageSchema, type KnowledgeProposal, KnowledgeProposalParseError, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseInput, type KnowledgeReleaseReport, type KnowledgeResearchLoopContext, type KnowledgeResearchLoopDecision, type KnowledgeResearchLoopResult, type KnowledgeResearchLoopStep, KnowledgeSearchResult, KnowledgeWriteBlock, KnowledgeWriteParseResult, type MaterialFact, type MaterialFactLens, type MaterialFactsResult, MemoryKbStore, type ParsedFrontmatter, type ProposeFromFindingsResult, READINESS_SPEC_DEFAULTS, type RagAnswerEvalArtifact, type RagAnswerEvalCase, type RagAnswerEvalScenario, type RagAnswerMetricSummary, type RagAnswerQualityHookOptions, type RagAnswerQualityInput, type RagAnswerQualityJudgeOptions, type RagAnswerQualityResult, type RagCalibrationOptions, type RagCalibrationResult, type RagDiagnosisInput, type RagEvalCitation, type RagEvalClaim, type RagEvalContext, type RagEvalMetricKey, type RagEvalProvider, type RagEvalSlice, type RagGapFinding, type RagGapKind, type RagGapSeverity, type RagKnowledgeAcquisitionInput, type RagKnowledgeImprovementPhase, type RagKnowledgeImprovementPhaseResult, type RagKnowledgeImprovementPhaseStatus, type RagKnowledgeResearchOptions, type RagKnowledgeUpdateInput, type RagKnowledgeUpdateResult, type RagPhaseInputBase, type RagPromotionInput, type RagPromotionResult, type RagRequiredContext, type RejectedSource, type ResearchContribution, type ResearchDriver, type ResearchDrivingDriver, type ResearchDrivingDriverOptions, type ResearchDrivingState, type ResearchDrivingSteer, type ResearchSourceProposal, type ResearchWorker, RetrievalConfig, type RouterClient, RouterError, type RouterUsage, type RunDiscoveryLoopOptions, type RunKnowledgeResearchLoopOptions, type RunRagKnowledgeImprovementLoopOptions, type RunRagKnowledgeImprovementLoopResult, RunRetrievalImprovementLoopOptions, RunRetrievalImprovementLoopResult, SCAFFOLD_PAGE_BASENAMES, type SourceAdapter, type SourceAdapterInput, type SourceAdapterOutput, SourceAnchorSchema, type SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, type SourceVerdict, type SourceVerificationContext, type TangleRouterOptions, type ThesisRunOptions, type ThesisRunResult, type ThesisTaskInput, type TrackedClaim, type TriageClass, type TwoAgentResearchLoopOptions, type TwoAgentResearchLoopResult, type TwoAgentResearchRound, type ValidateKnowledgeOptions, type ValidateKnowledgeResult, type VerifiedResearchLoopOptions, type VerifiedResearchLoopResult, type VerifiedResearchRound, type VerifyingDriverOptions, WIKILINK_REGEX, type WebResearchWorkerOptions, type WebSearchHit, type WorkerClaimDecorationOptions, type WorkerResearchContext, addSourcePath, addSourceText, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, buildEvalKnowledgeBundle, buildKnowledgeGraph, buildKnowledgeIndex, calibrateRagAnswerJudge, canonicalizeUrl, chunkMarkdown, citedClaimKey, citedClaimOf, contentKey, createAdaptiveResearchDriver, createClaimDecorator, createClaimGroundingVerifier, createCollectionResearchDriver, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createRagAnswerQualityHook, createResearchDrivingDriver, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, defineReadinessSpec, detectChanges, diagnoseRagAnswerFailure, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, gradeCompanyAgainstText, gradeFactAgainstText, groundClaimInText, hashKnowledgeBase, improveKnowledgeBase, initKnowledgeBase, inspectKnowledgeIndex, investmentThesisSet, isSafeKnowledgePath, isScaffoldPath, kbIndexToText, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, normalizeExternalRagScores, normalizeLinkTarget, parseFrontmatter, parseKnowledgeWriteBlocks, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeResearchLoop, runRagKnowledgeImprovementLoop, runTwoAgentResearchLoop, runVerifiedResearchLoop, scoreKnowledgeBaseIndex, scoreRagAnswerArtifact, searchKnowledge, sha256, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, thesisReadinessSpecs, toDeepEvalTestCases, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, writeJson, writeKnowledgeIndex, writeSourceRegistry };
2665
+ export { type AdaptiveDecision, type AdaptiveDriverOptions, type AdaptiveResearchDriver, type AdaptiveStats, type AddSourceOptions, type AddSourceTextInput, type ApplyWriteBlocksResult, type BuildEvalKnowledgeBundleOptions, type ChunkingOptions, type ClaimGroundingDriverOptions, type CompanyEvalCase, type D1Adapter, type DedupReason, type DeepQuestion, type DeepQuestionKind, type DefineReadinessSpecInput, type DetectChangesOptions, type DetectChangesResult, type DiscoveryLoopResult, type DiscoveryLoopRound, type DiscoveryLoopStopReason, type DiscoveryResult, type DiscoveryTask, type DriverResearchContext, type EvalKnowledgeBundleBuildResult, type EvaluateKnowledgeBaseReadinessOptions, type ExpectedGroup, type ExternalRagEvalScore, type FactResult, type FileSystemFreshnessStoreOptions, FileSystemKbStore, type FreshnessKey, type FreshnessMark, type FreshnessRecord, type FreshnessTtl, type GroundClaimOptions, type GroundingResult, type KbStore, KnowledgeBaseCandidateSchema, type KnowledgeBaseQualityOptions, type KnowledgeBaseQualityReport, type KnowledgeBaseReadinessEvaluation, type KnowledgeChange, type KnowledgeChangeKind, type KnowledgeChunk, KnowledgeClaim, type KnowledgeControlLoopAction, type KnowledgeControlLoopActionResult, type KnowledgeControlLoopAdapter, type KnowledgeControlLoopAdapterOptions, type KnowledgeControlLoopState, type KnowledgeDiscoveryDispatcher, type KnowledgeDiscoveryWorker, KnowledgeEvent, type KnowledgeEventQuery, KnowledgeEventSchema, KnowledgeEventType, type KnowledgeExplanation, KnowledgeFragment, type KnowledgeFreshnessStore, type KnowledgeGap, KnowledgeGraph, KnowledgeGraphEdgeSchema, KnowledgeGraphNodeSchema, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementCandidateRef, KnowledgeImprovementCandidateRefSchema, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementEvent, type KnowledgeImprovementEvidence, KnowledgeImprovementEvidenceSchema, type KnowledgeImprovementMetric, type KnowledgeImprovementMetricProvenance, type KnowledgeImprovementOptions, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, KnowledgeImprovementRunStateSchema, type KnowledgeImprovementStatus, type KnowledgeImprovementUpdate, type KnowledgeImprovementUpdateInput, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, KnowledgePage, KnowledgePageSchema, type KnowledgeProposal, KnowledgeProposalParseError, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseInput, type KnowledgeReleaseReport, type KnowledgeResearchLoopContext, type KnowledgeResearchLoopDecision, type KnowledgeResearchLoopResult, type KnowledgeResearchLoopStep, KnowledgeSearchResult, KnowledgeWriteBlock, KnowledgeWriteParseResult, type MaterialFact, type MaterialFactLens, type MaterialFactsResult, MemoryKbStore, type ParsedFrontmatter, type PendingKnowledgeMutation, type PromoteKnowledgeCandidateOptions, type ProposeFromFindingsResult, READINESS_SPEC_DEFAULTS, type RagAnswerEvalArtifact, type RagAnswerEvalCase, type RagAnswerEvalScenario, type RagAnswerMetricSummary, type RagAnswerQualityHookOptions, type RagAnswerQualityInput, type RagAnswerQualityJudgeOptions, type RagAnswerQualityResult, type RagCalibrationOptions, type RagCalibrationResult, type RagDiagnosisInput, type RagEvalCitation, type RagEvalClaim, type RagEvalContext, type RagEvalMetricKey, type RagEvalProvider, type RagEvalSlice, type RagGapFinding, type RagGapKind, type RagGapSeverity, type RagKnowledgeAcquisitionInput, type RagKnowledgeImprovementPhase, type RagKnowledgeImprovementPhaseResult, type RagKnowledgeImprovementPhaseStatus, type RagKnowledgeResearchOptions, type RagKnowledgeUpdateInput, type RagKnowledgeUpdateResult, type RagPhaseInputBase, type RagPromotionInput, type RagPromotionResult, type RagRequiredContext, type RecoverPendingKnowledgeMutationOptions, type RejectedSource, type ResearchContribution, type ResearchDriver, type ResearchDrivingDriver, type ResearchDrivingDriverOptions, type ResearchDrivingState, type ResearchDrivingSteer, type ResearchSourceProposal, type ResearchWorker, type ResolvedKnowledgeImprovementCandidate, type RouterClient, RouterError, type RouterUsage, type RunDiscoveryLoopOptions, type RunKnowledgeResearchLoopOptions, type RunRagKnowledgeImprovementLoopOptions, type RunRagKnowledgeImprovementLoopResult, RunRetrievalImprovementLoopOptions, RunRetrievalImprovementLoopResult, SCAFFOLD_PAGE_BASENAMES, type SourceAdapter, type SourceAdapterInput, type SourceAdapterOutput, SourceAnchorSchema, type SourceFreshnessInspection, SourceRecord, SourceRecordSchema, SourceRegistry, type SourceVerdict, type SourceVerificationContext, type TangleRouterOptions, type ThesisRunOptions, type ThesisRunResult, type ThesisTaskInput, type TrackedClaim, type TriageClass, type TwoAgentResearchLoopOptions, type TwoAgentResearchLoopResult, type TwoAgentResearchRound, type UseKnowledgeImprovementCandidateOptions, type ValidateKnowledgeOptions, type ValidateKnowledgeResult, type VerifiedResearchLoopOptions, type VerifiedResearchLoopResult, type VerifiedResearchRound, type VerifyingDriverOptions, WIKILINK_REGEX, type WebResearchWorkerOptions, type WebSearchHit, type WorkerClaimDecorationOptions, type WorkerResearchContext, addSourcePath, addSourceText, applyKnowledgeWriteBlocks, applyKnowledgeWriteBlocksFile, buildEvalKnowledgeBundle, buildKnowledgeGraph, buildKnowledgeIndex, calibrateRagAnswerJudge, canonicalizeUrl, chunkMarkdown, citedClaimKey, citedClaimOf, contentKey, createAdaptiveResearchDriver, createClaimDecorator, createClaimGroundingVerifier, createCollectionResearchDriver, createD1FreshnessStoreStub, createFileSystemFreshnessStore, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createRagAnswerQualityHook, createResearchDrivingDriver, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, defineReadinessSpec, detectChanges, diagnoseRagAnswerFailure, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, gradeCompanyAgainstText, gradeFactAgainstText, groundClaimInText, hashKnowledgeBase, improveKnowledgeBase, initKnowledgeBase, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isSafeKnowledgePath, isScaffoldPath, kbIndexToText, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, normalizeExternalRagScores, normalizeLinkTarget, parseFrontmatter, parseKnowledgeWriteBlocks, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, recoverPendingKnowledgeMutation, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeResearchLoop, runRagKnowledgeImprovementLoop, runTwoAgentResearchLoop, runVerifiedResearchLoop, scoreKnowledgeBaseIndex, scoreRagAnswerArtifact, searchKnowledge, sha256, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, thesisReadinessSpecs, toDeepEvalTestCases, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, writeJson, writeKnowledgeIndex, writeSourceRegistry };