@tangle-network/agent-knowledge 4.0.1 → 5.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.
Files changed (37) hide show
  1. package/AGENTS.md +35 -19
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +220 -943
  4. package/dist/benchmarks/index.d.ts +3 -2
  5. package/dist/benchmarks/index.js +1 -1
  6. package/dist/{chunk-EUAXSBMH.js → chunk-AKYJG2MR.js} +224 -224
  7. package/dist/chunk-AKYJG2MR.js.map +1 -0
  8. package/dist/{chunk-BBCIB4UL.js → chunk-EYIA5PLQ.js} +27 -195
  9. package/dist/chunk-EYIA5PLQ.js.map +1 -0
  10. package/dist/{chunk-3CAAGJCE.js → chunk-LMR53POQ.js} +1227 -574
  11. package/dist/chunk-LMR53POQ.js.map +1 -0
  12. package/dist/{chunk-WCYW2GDA.js → chunk-MYFM6LKH.js} +2 -2
  13. package/dist/chunk-MYFM6LKH.js.map +1 -0
  14. package/dist/cli.js +1 -1
  15. package/dist/index-Cf7txrYP.d.ts +790 -0
  16. package/dist/index.d.ts +252 -73
  17. package/dist/index.js +2813 -2229
  18. package/dist/index.js.map +1 -1
  19. package/dist/memory/index.d.ts +8 -709
  20. package/dist/memory/index.js +2 -2
  21. package/dist/sources/index.d.ts +17 -33
  22. package/dist/sources/index.js +1 -1
  23. package/dist/{types-ZzY_x0r7.d.ts → types-BY-xLVw-.d.ts} +28 -67
  24. package/docs/eval/investment-material-facts.md +28 -29
  25. package/docs/eval/rag-eval-roadmap.md +21 -17
  26. package/docs/results/adaptive.md +13 -13
  27. package/docs/results/claim-grounding.md +11 -11
  28. package/docs/results/cost-quality.md +4 -4
  29. package/docs/results/investment-thesis.md +56 -56
  30. package/docs/results/research-driving.md +54 -54
  31. package/docs/two-agent-research-ab.md +94 -94
  32. package/package.json +11 -11
  33. package/skills/build-with-agent-knowledge/SKILL.md +97 -0
  34. package/dist/chunk-3CAAGJCE.js.map +0 -1
  35. package/dist/chunk-BBCIB4UL.js.map +0 -1
  36. package/dist/chunk-EUAXSBMH.js.map +0 -1
  37. package/dist/chunk-WCYW2GDA.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { S as SourceRecord, c as KnowledgeIndex, d as KnowledgeSearchResult, e as SourceRegistry, f as KnowledgeEvent, g as KnowledgeLintFinding, h as KnowledgeEventType, i as KnowledgePage, b as KnowledgeGraph, j as KnowledgeWriteBlock, k as KnowledgeClaim, l as KnowledgeRelease, m as KnowledgeWriteParseResult } from './types-6x0OpfW6.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-6x0OpfW6.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 { AgentImprovementActivation, AgentImprovementActivationResult, AgentCandidateKnowledgeRef } from '@tangle-network/agent-interface';
3
+ import { KnowledgeRequirementCategory, KnowledgeAcquisitionMode, KnowledgeImportance, KnowledgeFreshness, KnowledgeSensitivity, KnowledgeRequirement, KnowledgeBundle, KnowledgeReadinessReport, UserQuestion, DataAcquisitionPlan, ControlRuntimeConfig, ControlEvalResult, RunRecord, AnalystSeverity, AnalystFinding, ReleaseTraceEvidence, GateDecision, DatasetScenario, ReleaseConfidenceScorecard } from '@tangle-network/agent-eval';
4
+ import { AgentCandidateJsonValue, AgentImprovementActivation, AgentImprovementActivationResult, AgentCandidateKnowledgeRef } from '@tangle-network/agent-interface';
5
5
  import { z } from 'zod';
6
- import { JsonValue, Scenario, JudgeConfig } from '@tangle-network/agent-eval/campaign';
7
- import { R as RunRetrievalImprovementLoopResult, a as RunRetrievalImprovementLoopOptions } from './types-ZzY_x0r7.js';
8
- export { A as AgentMemoryAcquireRunLease, b as AgentMemoryAdapter, c as AgentMemoryBranchIsolation, d as AgentMemoryContext, e as AgentMemoryControllerMode, f as AgentMemoryHit, g as AgentMemoryKind, h as AgentMemoryRunLease, i as AgentMemoryScope, j as AgentMemorySearchOptions, k as AgentMemoryWriteInput, l as AgentMemoryWriteResult, B as BuildRetrievalBenchmarkCasesFromQrelsOptions, m as BuildRetrievalEvalDispatchOptions, n as BuildRetrievalParameterCandidatesOptions, K as KnowledgeAnswerBenchmarkCase, o as KnowledgeAnswerBenchmarkTaskKind, p as KnowledgeBenchmarkArtifact, q as KnowledgeBenchmarkCase, r as KnowledgeBenchmarkCaseBase, s as KnowledgeBenchmarkDistribution, t as KnowledgeBenchmarkEvaluation, u as KnowledgeBenchmarkFamily, v as KnowledgeBenchmarkReport, w as KnowledgeBenchmarkResponder, x as KnowledgeBenchmarkScenario, y as KnowledgeBenchmarkSliceSummary, z as KnowledgeBenchmarkSource, C as KnowledgeBenchmarkSpec, D as KnowledgeBenchmarkSplit, E as KnowledgeBenchmarkTaskKind, F as KnowledgeClaimMatcher, G as KnowledgeMemoryBenchmarkCase, H as KnowledgeMemoryBenchmarkTaskKind, I as KnowledgeMemoryEvent, J as KnowledgeMemoryFactMatcher, L as KnowledgeRetrievalBenchmarkCase, M as KnowledgeRetrievalBenchmarkQrel, N as KnowledgeRetrievalBenchmarkQuery, O as MemoryAdapterBenchmarkCandidate, P as MemoryAdapterBenchmarkRankingRow, Q as OwnedAgentMemoryRunLease, S as RetrievalConfig, T as RetrievalEvalArtifact, U as RetrievalEvalRetriever, V as RetrievalEvalRetrieverInput, W as RetrievalEvalRetrieverResult, X as RetrievalEvalScenario, Y as RetrievalGoldTarget, Z as RetrievalHoldoutBypassReason, _ as RetrievalHoldoutCallContext, $ as RetrievalHoldoutConfig, a0 as RetrievalHoldoutEligibleItem, a1 as RetrievalHoldoutEvent, a2 as RetrievalHoldoutResult, a3 as RetrievalHoldoutSessionState, a4 as RetrievalMetricSummary, a5 as RetrievalMetricWeights, a6 as RetrievalParameterSearchSpace, a7 as RetrievalParameterSweepProposerOptions, a8 as RetrievalRecallJudgeOptions, a9 as RetrievedKnowledgeHit, aa as RetrievedSourceSpan, ab as RunKnowledgeBenchmarkSuiteOptions, ac as RunKnowledgeBenchmarkSuiteResult, ad as RunMemoryAdapterBenchmarkOptions, ae as RunMemoryAdapterBenchmarkResult, af as acquireAgentMemoryRunLease, ag as buildRetrievalEvalDispatch, ah as buildRetrievalParameterCandidates, ai as retrievalConfigFromSurface, aj as retrievalConfigSurface, ak as retrievalParameterSweepProposer, al as retrievalRecallJudge, am as runRetrievalImprovementLoop, an as scoreRetrievalArtifact } from './types-ZzY_x0r7.js';
6
+ import { OptimizationMethod, DispatchContext, JudgeConfig, ComparisonCost, Scenario } from '@tangle-network/agent-eval/campaign';
7
+ import { R as RunSerializedKnowledgeOptimizationResult, a as RunSerializedKnowledgeOptimizationOptions } from './index-Cf7txrYP.js';
8
+ export { A as AgentMemoryActivation, b as AgentMemoryActivationDriver, c as AgentMemoryAttemptEvent, d as AgentMemoryBranch, e as AgentMemoryBranchLifetime, f as AgentMemoryBranchSnapshot, g as AgentMemoryDimensionComparison, h as AgentMemoryExecutionContext, i as AgentMemoryExecutionCostMeter, j as AgentMemoryExecutionCostReceipt, k as AgentMemoryExecutionPaidCallInput, l as AgentMemoryExecutionPaidCallResult, m as AgentMemoryExecutionStep, n as AgentMemoryExperimentCandidate, o as AgentMemoryExperimentRankingRow, p as AgentMemoryExperimentRunLease, q as AgentMemoryFinalEvaluation, r as AgentMemoryFinalPair, s as AgentMemoryHitSchema, t as AgentMemoryImprovementRunLease, u as AgentMemoryJournalEntry, v as AgentMemoryKindSchema, w as AgentMemoryLifecycleTimeoutError, x as AgentMemoryLifecycleUnsafeError, y as AgentMemoryPromotionDecision, z as AgentMemoryScopeSchema, B as AgentMemorySequence, C as AgentMemorySequenceArtifact, D as AgentMemorySequenceProbe, E as AgentMemorySequenceProbeResult, F as AgentMemorySequenceScenario, G as AgentMemorySequenceStep, H as AgentMemorySharingPolicy, I as AgentMemoryVisibility, J as AgentMemoryWriteInputSchema, K as BuildAgentMemorySequencesFromBenchmarkCasesOptions, L as CreateAgentMemoryBranchOptions, M as DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, N as ForkAgentMemoryBranchSnapshotOptions, O as GraphitiMcpClientLike, P as GraphitiMemoryAdapterOptions, Q as GraphitiToolNames, S as Mem0ClientLike, T as Mem0ClientMode, U as Mem0MemoryAdapterOptions, V as MemoryConfigScenario, W as Neo4jAgentMemoryAdapterOptions, X as RetrievalHoldoutOffPolicyOptions, Y as RetrievalHoldoutOffPolicyResult, Z as RetrievalHoldoutSessionSummary, _ as RunAgentMemoryExperimentOptions, $ as RunAgentMemoryExperimentResult, a0 as RunAgentMemoryImprovementOptions, a1 as RunAgentMemoryImprovementResult, a2 as SerializedCandidate, a3 as SerializedCandidateCodec, a4 as agentMemorySequenceJudge, a5 as applyRetrievalHoldout, a6 as applySessionStickyRetrievalHoldout, a7 as buildAgentMemorySequenceScenarios, a8 as buildAgentMemorySequencesFromBenchmarkCases, a9 as createAgentMemoryBranch, aa as createGraphitiMemoryAdapter, ab as createMem0MemoryAdapter, ac as createMemoryExecutionPool, ad as createNeo4jAgentMemoryAdapter, ae as defaultGetMemoryContext, af as deterministicRng, ag as emitRetrievalHoldoutBypass, ah as forkAgentMemoryBranchSnapshot, ai as graphitiMemoryAdapterIdentity, aj as jsonCandidateCodec, ak as jsonObjectCandidateCodec, al as mem0MemoryAdapterIdentity, am as memoryHitToSourceRecord, an as memoryRecoveryDelayMs, ao as memoryWriteResultToSourceRecord, ap as renderMemoryContext, aq as resetRetrievalHoldoutRegistry, ar as resolveMemoryCleanupTimeoutMs, as as retrievalHoldoutConfigHash, at as runAgentMemoryExperiment, au as runAgentMemoryImprovement, av as runBoundedMemoryLifecycle, aw as runSerializedKnowledgeOptimization, ax as scenarioContentFingerprint, ay as sleepForMemoryRecovery, az as toOffPolicyTrajectory } from './index-Cf7txrYP.js';
9
+ import { R as RetrievalConfig, a as RetrievalEvalScenario, b as RetrievalEvalArtifact, c as RetrievalEvalRetriever, d as RetrievalMetricWeights, e as RetrievedKnowledgeHit } from './types-BY-xLVw-.js';
10
+ export { A as AgentMemoryAcquireRunLease, f as AgentMemoryAdapter, g as AgentMemoryBranchIsolation, h as AgentMemoryContext, i as AgentMemoryControllerMode, j as AgentMemoryHit, k as AgentMemoryKind, l as AgentMemoryRunLease, m as AgentMemoryScope, n as AgentMemorySearchOptions, o as AgentMemoryWriteInput, p as AgentMemoryWriteResult, B as BuildRetrievalBenchmarkCasesFromQrelsOptions, q as BuildRetrievalEvalDispatchOptions, K as KnowledgeAnswerBenchmarkCase, r as KnowledgeAnswerBenchmarkTaskKind, s as KnowledgeBenchmarkArtifact, t as KnowledgeBenchmarkCase, u as KnowledgeBenchmarkCaseBase, v as KnowledgeBenchmarkDistribution, w as KnowledgeBenchmarkEvaluation, x as KnowledgeBenchmarkFamily, y as KnowledgeBenchmarkReport, z as KnowledgeBenchmarkResponder, C as KnowledgeBenchmarkScenario, D as KnowledgeBenchmarkSliceSummary, E as KnowledgeBenchmarkSource, F as KnowledgeBenchmarkSpec, G as KnowledgeBenchmarkSplit, H as KnowledgeBenchmarkTaskKind, I as KnowledgeClaimMatcher, J as KnowledgeMemoryBenchmarkCase, L as KnowledgeMemoryBenchmarkTaskKind, M as KnowledgeMemoryEvent, N as KnowledgeMemoryFactMatcher, O as KnowledgeRetrievalBenchmarkCase, P as KnowledgeRetrievalBenchmarkQrel, Q as KnowledgeRetrievalBenchmarkQuery, S as MemoryAdapterBenchmarkCandidate, T as MemoryAdapterBenchmarkRankingRow, U as OwnedAgentMemoryRunLease, V as PartitionRetrievalScenariosOptions, W as RetrievalEvalRetrieverInput, X as RetrievalEvalRetrieverResult, Y as RetrievalGoldTarget, Z as RetrievalHoldoutBypassReason, _ as RetrievalHoldoutCallContext, $ as RetrievalHoldoutConfig, a0 as RetrievalHoldoutEligibleItem, a1 as RetrievalHoldoutEvent, a2 as RetrievalHoldoutResult, a3 as RetrievalHoldoutSessionState, a4 as RetrievalMetricSummary, a5 as RetrievalRecallJudgeOptions, a6 as RetrievalScenarioPartitions, a7 as RetrievedSourceSpan, a8 as RunKnowledgeBenchmarkSuiteOptions, a9 as RunKnowledgeBenchmarkSuiteResult, aa as RunMemoryAdapterBenchmarkOptions, ab as RunMemoryAdapterBenchmarkResult, ac as acquireAgentMemoryRunLease, ad as buildRetrievalEvalDispatch, ae as partitionRetrievalScenarios, af as retrievalConfigFromSurface, ag as retrievalConfigSurface, ah as retrievalRecallJudge, ai as scoreRetrievalArtifact } from './types-BY-xLVw-.js';
9
11
  export { INDUSTRY_MEMORY_BENCHMARKS, INDUSTRY_RAG_BENCHMARKS, buildFirstPartyMemoryLifecycleBenchmarkCases, buildIndustryMemoryBenchmarkSmokeCases, buildIndustryRagBenchmarkSmokeCases, buildKnowledgeBenchmarkScenarios, buildRetrievalBenchmarkCasesFromQrels, createInMemoryBenchmarkAdapter, createNoopMemoryBenchmarkAdapter, isKnowledgeMemoryBenchmarkCase, knowledgeBenchmarkJudge, parseKnowledgeBenchmarkJsonl, parseKnowledgeBenchmarkQrels, renderKnowledgeBenchmarkReportMarkdown, respondToIndustryMemoryBenchmarkSmokeCase, respondToIndustryRagBenchmarkSmokeCase, runKnowledgeBenchmarkSuite, runMemoryAdapterBenchmark, scoreKnowledgeBenchmarkArtifact, scoreMemoryBenchmarkArtifact, summarizeKnowledgeBenchmarkCampaign } from './benchmarks/index.js';
10
12
  import { KnowledgeFragment } from './sources/index.js';
11
13
  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';
12
- export { AgentMemoryActivation, AgentMemoryActivationDriver, AgentMemoryAttemptEvent, AgentMemoryBranch, AgentMemoryBranchLifetime, AgentMemoryBranchSnapshot, AgentMemoryDimensionComparison, AgentMemoryExperimentCandidate, AgentMemoryExperimentRankingRow, AgentMemoryExperimentRunLease, AgentMemoryGovernor, AgentMemoryHitSchema, AgentMemoryImprovementRunLease, AgentMemoryImprovementSeed, AgentMemoryJournalEntry, AgentMemoryKindSchema, AgentMemoryLifecycleTimeoutError, AgentMemoryLifecycleUnsafeError, AgentMemoryPromotionDecision, AgentMemoryScopeSchema, AgentMemorySequence, AgentMemorySequenceArtifact, AgentMemorySequenceProbe, AgentMemorySequenceProbeResult, AgentMemorySequenceScenario, AgentMemorySequenceStep, AgentMemorySharingPolicy, AgentMemoryVisibility, AgentMemoryWriteInputSchema, BuildAgentMemorySequencesFromBenchmarkCasesOptions, CreateAgentMemoryBranchOptions, DEFAULT_MEMORY_CLEANUP_TIMEOUT_MS, ForkAgentMemoryBranchSnapshotOptions, GraphitiMcpClientLike, GraphitiMemoryAdapterOptions, GraphitiToolNames, Mem0ClientLike, Mem0ClientMode, Mem0MemoryAdapterOptions, Neo4jAgentMemoryAdapterOptions, RetrievalHoldoutOffPolicyOptions, RetrievalHoldoutOffPolicyResult, RetrievalHoldoutSessionSummary, RunAgentMemoryExperimentOptions, RunAgentMemoryExperimentResult, RunAgentMemoryImprovementOptions, RunAgentMemoryImprovementResult, agentMemorySequenceJudge, applyRetrievalHoldout, applySessionStickyRetrievalHoldout, buildAgentMemorySequenceScenarios, buildAgentMemorySequencesFromBenchmarkCases, createAgentMemoryBranch, createGraphitiMemoryAdapter, createMem0MemoryAdapter, createMemoryExecutionPool, createNeo4jAgentMemoryAdapter, defaultGetMemoryContext, deterministicRng, emitRetrievalHoldoutBypass, forkAgentMemoryBranchSnapshot, graphitiMemoryAdapterIdentity, mem0MemoryAdapterIdentity, memoryHitToSourceRecord, memoryRecoveryDelayMs, memoryWriteResultToSourceRecord, renderMemoryContext, resetRetrievalHoldoutRegistry, resolveMemoryCleanupTimeoutMs, retrievalHoldoutConfigHash, runAgentMemoryExperiment, runAgentMemoryImprovement, runBoundedMemoryLifecycle, sleepForMemoryRecovery, toOffPolicyTrajectory } from './memory/index.js';
13
14
  import '@tangle-network/agent-eval/rl';
14
15
 
15
16
  interface SourceAdapterInput {
@@ -633,6 +634,33 @@ interface AdaptiveResearchDriver {
633
634
  */
634
635
  declare function createAdaptiveResearchDriver(options?: AdaptiveDriverOptions): AdaptiveResearchDriver;
635
636
 
637
+ type RagOptimizationConfig = Record<string, AgentCandidateJsonValue>;
638
+ type RagOptimizationBaseOptions = Omit<RunSerializedKnowledgeOptimizationOptions<RagOptimizationConfig, RagAnswerEvalScenario, RagAnswerEvalArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'dispatchCandidate' | 'judges' | 'codec' | 'scenarioFingerprint'>;
639
+ interface RunRagOptimizationOptions extends RagOptimizationBaseOptions {
640
+ baseline: RagOptimizationConfig;
641
+ method: OptimizationMethod<RagAnswerEvalScenario, RagAnswerEvalArtifact>;
642
+ trainScenarios: readonly RagAnswerEvalScenario[];
643
+ selectionScenarios: readonly RagAnswerEvalScenario[];
644
+ finalScenarios: readonly RagAnswerEvalScenario[];
645
+ run(input: {
646
+ config: RagOptimizationConfig;
647
+ configSurface: string;
648
+ configSurfaceHash: string;
649
+ scenario: RagAnswerEvalScenario;
650
+ context: DispatchContext;
651
+ }): Promise<RagAnswerEvalArtifact>;
652
+ judges?: readonly JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>[];
653
+ }
654
+ interface RunRagOptimizationResult extends RunSerializedKnowledgeOptimizationResult<RagOptimizationConfig> {
655
+ baselineConfig: RagOptimizationConfig;
656
+ winnerConfig: RagOptimizationConfig;
657
+ trainScenarios: readonly RagAnswerEvalScenario[];
658
+ selectionScenarios: readonly RagAnswerEvalScenario[];
659
+ finalScenarios: readonly RagAnswerEvalScenario[];
660
+ }
661
+ /** Optimizes retrieval and answer behavior together as one serialized RAG configuration. */
662
+ declare function runRagOptimization(options: RunRagOptimizationOptions): Promise<RunRagOptimizationResult>;
663
+
636
664
  interface ApplyWriteBlocksResult {
637
665
  written: string[];
638
666
  warnings: string[];
@@ -746,7 +774,29 @@ type KnowledgeControlLoopAdapter = Pick<ControlRuntimeConfig<KnowledgeControlLoo
746
774
  declare function createKnowledgeControlLoopAdapter(options: KnowledgeControlLoopAdapterOptions): KnowledgeControlLoopAdapter;
747
775
  declare function runKnowledgeResearchLoop(options: RunKnowledgeResearchLoopOptions): Promise<KnowledgeResearchLoopResult>;
748
776
 
749
- type RagKnowledgeImprovementPhase = 'retrieval-tuning' | 'gap-diagnosis' | 'knowledge-acquisition' | 'knowledge-update' | 'answer-quality' | 'promotion';
777
+ type RetrievalOptimizationBaseOptions = Omit<RunSerializedKnowledgeOptimizationOptions<RetrievalConfig, RetrievalEvalScenario, RetrievalEvalArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'dispatchCandidate' | 'judges' | 'codec' | 'scenarioFingerprint'>;
778
+ interface RunRetrievalImprovementLoopOptions extends RetrievalOptimizationBaseOptions {
779
+ baseline: RetrievalConfig;
780
+ trainScenarios: readonly RetrievalEvalScenario[];
781
+ selectionScenarios: readonly RetrievalEvalScenario[];
782
+ finalScenarios: readonly RetrievalEvalScenario[];
783
+ method: OptimizationMethod<RetrievalEvalScenario, RetrievalEvalArtifact>;
784
+ index?: KnowledgeIndex;
785
+ defaultK?: number;
786
+ retrieve?: RetrievalEvalRetriever;
787
+ judges?: readonly JudgeConfig<RetrievalEvalArtifact, RetrievalEvalScenario>[];
788
+ metricWeights?: RetrievalMetricWeights;
789
+ }
790
+ interface RunRetrievalImprovementLoopResult extends RunSerializedKnowledgeOptimizationResult<RetrievalConfig> {
791
+ baselineConfig: RetrievalConfig;
792
+ winnerConfig: RetrievalConfig;
793
+ trainScenarios: readonly RetrievalEvalScenario[];
794
+ selectionScenarios: readonly RetrievalEvalScenario[];
795
+ finalScenarios: readonly RetrievalEvalScenario[];
796
+ }
797
+ declare function runRetrievalImprovementLoop(options: RunRetrievalImprovementLoopOptions): Promise<RunRetrievalImprovementLoopResult>;
798
+
799
+ type RagKnowledgeImprovementPhase = 'rag-optimization' | 'retrieval-tuning' | 'gap-diagnosis' | 'knowledge-acquisition' | 'knowledge-update' | 'answer-quality' | 'promotion';
750
800
  type RagKnowledgeImprovementPhaseStatus = 'completed' | 'skipped' | 'failed';
751
801
  type RagGapKind = 'missing-source' | 'stale-source' | 'retrieval-miss' | 'retrieval-noise' | 'chunking-mismatch' | 'missing-multihop-evidence' | 'generator-unsupported-claim' | 'citation-mismatch' | 'incorrect-abstention' | 'unknown';
752
802
  type RagGapSeverity = 'info' | 'warning' | 'error' | 'critical';
@@ -756,7 +806,7 @@ interface RagGapFinding {
756
806
  severity: RagGapSeverity;
757
807
  message: string;
758
808
  scenarioId?: string;
759
- evidence?: Record<string, JsonValue>;
809
+ evidence?: Record<string, AgentCandidateJsonValue>;
760
810
  }
761
811
  interface RagKnowledgeImprovementPhaseResult {
762
812
  phase: RagKnowledgeImprovementPhase;
@@ -764,22 +814,26 @@ interface RagKnowledgeImprovementPhaseResult {
764
814
  summary: string;
765
815
  startedAt: string;
766
816
  finishedAt: string;
767
- metadata?: Record<string, JsonValue>;
817
+ metadata?: Record<string, AgentCandidateJsonValue>;
768
818
  }
819
+ type RagOptimizationSelection = Pick<RunRagOptimizationResult, 'methodName' | 'baseline' | 'winner' | 'baselineConfig' | 'winnerConfig'>;
820
+ type RetrievalOptimizationSelection = Pick<RunRetrievalImprovementLoopResult, 'methodName' | 'baseline' | 'winner' | 'baselineConfig' | 'winnerConfig'>;
769
821
  interface RagPhaseInputBase {
770
822
  goal: string;
771
823
  phases: readonly RagKnowledgeImprovementPhaseResult[];
824
+ /** Selected candidate only. Adaptive update callbacks run before final scoring starts. */
825
+ optimization?: RagOptimizationSelection;
772
826
  signal?: AbortSignal;
773
827
  }
774
828
  interface RagDiagnosisInput extends RagPhaseInputBase {
775
- retrieval?: RunRetrievalImprovementLoopResult;
829
+ retrieval?: RetrievalOptimizationSelection;
776
830
  }
777
831
  interface RagKnowledgeAcquisitionInput extends RagPhaseInputBase {
778
- retrieval?: RunRetrievalImprovementLoopResult;
832
+ retrieval?: RetrievalOptimizationSelection;
779
833
  findings: readonly RagGapFinding[];
780
834
  }
781
835
  interface RagKnowledgeUpdateInput extends RagPhaseInputBase {
782
- retrieval?: RunRetrievalImprovementLoopResult;
836
+ retrieval?: RetrievalOptimizationSelection;
783
837
  findings: readonly RagGapFinding[];
784
838
  acquisition?: KnowledgeResearchLoopDecision;
785
839
  }
@@ -787,10 +841,10 @@ interface RagKnowledgeUpdateResult {
787
841
  applied: boolean;
788
842
  summary: string;
789
843
  research?: KnowledgeResearchLoopResult;
790
- metadata?: Record<string, JsonValue>;
844
+ metadata?: Record<string, AgentCandidateJsonValue>;
791
845
  }
792
846
  interface RagAnswerQualityInput extends RagPhaseInputBase {
793
- retrieval?: RunRetrievalImprovementLoopResult;
847
+ retrieval?: RetrievalOptimizationSelection;
794
848
  findings: readonly RagGapFinding[];
795
849
  acquisition?: KnowledgeResearchLoopDecision;
796
850
  knowledgeUpdate?: RagKnowledgeUpdateResult;
@@ -798,11 +852,19 @@ interface RagAnswerQualityInput extends RagPhaseInputBase {
798
852
  interface RagAnswerQualityResult {
799
853
  passed: boolean;
800
854
  metrics: Record<string, number>;
855
+ finalScenarioIds: readonly string[];
856
+ datasetRef: string;
857
+ evaluatorRef: string;
858
+ cost: ComparisonCost;
801
859
  findings?: readonly RagGapFinding[];
802
- metadata?: Record<string, JsonValue>;
860
+ metadata?: Record<string, AgentCandidateJsonValue>;
803
861
  }
804
862
  interface RagPromotionInput extends RagPhaseInputBase {
805
- retrieval?: RunRetrievalImprovementLoopResult;
863
+ retrieval?: RetrievalOptimizationSelection;
864
+ /** Full final-case result available only to the terminal promotion decision. */
865
+ optimizationComparison?: RunRagOptimizationResult['comparison'];
866
+ /** Full final-case result available only to the terminal promotion decision. */
867
+ retrievalComparison?: RunRetrievalImprovementLoopResult['comparison'];
806
868
  findings: readonly RagGapFinding[];
807
869
  acquisition?: KnowledgeResearchLoopDecision;
808
870
  knowledgeUpdate?: RagKnowledgeUpdateResult;
@@ -811,7 +873,7 @@ interface RagPromotionInput extends RagPhaseInputBase {
811
873
  interface RagPromotionResult {
812
874
  promoted: boolean;
813
875
  reason: string;
814
- metadata?: Record<string, JsonValue>;
876
+ metadata?: Record<string, AgentCandidateJsonValue>;
815
877
  }
816
878
  interface RagKnowledgeResearchOptions extends Omit<RunKnowledgeResearchLoopOptions, 'goal' | 'signal' | 'step'> {
817
879
  goal?: string;
@@ -819,13 +881,20 @@ interface RagKnowledgeResearchOptions extends Omit<RunKnowledgeResearchLoopOptio
819
881
  }
820
882
  interface RunRagKnowledgeImprovementLoopOptions {
821
883
  goal: string;
884
+ optimization?: RunRagOptimizationOptions;
822
885
  retrieval?: RunRetrievalImprovementLoopOptions;
823
886
  diagnose?: (input: RagDiagnosisInput) => MaybePromise$1<readonly RagGapFinding[]>;
824
887
  acquireKnowledge?: (input: RagKnowledgeAcquisitionInput) => MaybePromise$1<KnowledgeResearchLoopDecision>;
825
888
  knowledgeResearch?: RagKnowledgeResearchOptions;
826
889
  updateKnowledge?: (input: RagKnowledgeUpdateInput) => MaybePromise$1<RagKnowledgeUpdateResult>;
827
890
  evaluateAnswers?: (input: RagAnswerQualityInput) => MaybePromise$1<RagAnswerQualityResult>;
828
- promote?: (input: RagPromotionInput) => MaybePromise$1<RagPromotionResult>;
891
+ /** Maximum total answer-evaluation spend accepted for promotion. */
892
+ answerQualityCostCeiling?: number;
893
+ /**
894
+ * Makes a side-effect-free promotion decision after the library has rejected
895
+ * missing, regressing, unaccounted, or over-budget final evidence.
896
+ */
897
+ decidePromotion?: (input: RagPromotionInput) => MaybePromise$1<RagPromotionResult>;
829
898
  enabledPhases?: readonly RagKnowledgeImprovementPhase[];
830
899
  requiredPhases?: readonly RagKnowledgeImprovementPhase[];
831
900
  signal?: AbortSignal;
@@ -834,6 +903,7 @@ interface RunRagKnowledgeImprovementLoopOptions {
834
903
  interface RunRagKnowledgeImprovementLoopResult {
835
904
  goal: string;
836
905
  phases: readonly RagKnowledgeImprovementPhaseResult[];
906
+ optimization?: RunRagOptimizationResult;
837
907
  retrieval?: RunRetrievalImprovementLoopResult;
838
908
  findings: readonly RagGapFinding[];
839
909
  acquisition?: KnowledgeResearchLoopDecision;
@@ -855,7 +925,7 @@ interface RagEvalContext {
855
925
  sourceId?: string;
856
926
  anchorId?: string;
857
927
  stale?: boolean;
858
- metadata?: Record<string, JsonValue>;
928
+ metadata?: Record<string, AgentCandidateJsonValue>;
859
929
  }
860
930
  interface RagEvalCitation {
861
931
  id: string;
@@ -865,13 +935,13 @@ interface RagEvalCitation {
865
935
  sourceId?: string;
866
936
  anchorId?: string;
867
937
  quote?: string;
868
- metadata?: Record<string, JsonValue>;
938
+ metadata?: Record<string, AgentCandidateJsonValue>;
869
939
  }
870
940
  interface RagEvalClaim {
871
941
  id: string;
872
942
  text: string;
873
943
  citationIds?: readonly string[];
874
- metadata?: Record<string, JsonValue>;
944
+ metadata?: Record<string, AgentCandidateJsonValue>;
875
945
  }
876
946
  interface RagRequiredContext {
877
947
  id?: string;
@@ -896,7 +966,7 @@ interface ExternalRagEvalScore {
896
966
  provider: RagEvalProvider | string;
897
967
  scores: Record<string, number>;
898
968
  reasons?: Record<string, string>;
899
- metadata?: Record<string, JsonValue>;
969
+ metadata?: Record<string, AgentCandidateJsonValue>;
900
970
  }
901
971
  interface RagAnswerEvalArtifact {
902
972
  query: string;
@@ -908,7 +978,7 @@ interface RagAnswerEvalArtifact {
908
978
  durationMs?: number;
909
979
  costUsd?: number;
910
980
  externalScores?: readonly ExternalRagEvalScore[];
911
- metadata?: Record<string, JsonValue>;
981
+ metadata?: Record<string, AgentCandidateJsonValue>;
912
982
  }
913
983
  interface RagAnswerMetricSummary {
914
984
  metrics: Record<RagEvalMetricKey, number>;
@@ -936,6 +1006,10 @@ interface RagAnswerEvalCase {
936
1006
  }
937
1007
  interface RagAnswerQualityHookOptions {
938
1008
  scenarios: readonly RagAnswerEvalScenario[];
1009
+ /** Immutable identity of generation, scoring, models, and external evaluator behavior. */
1010
+ evaluatorRef: string;
1011
+ /** Return observed spend after all generation and evaluation calls finish. */
1012
+ cost: ComparisonCost | (() => MaybePromise<ComparisonCost>);
939
1013
  run: (scenario: RagAnswerEvalScenario) => MaybePromise<RagAnswerEvalArtifact>;
940
1014
  externalEvaluator?: (item: RagAnswerEvalCase) => MaybePromise<ExternalRagEvalScore | readonly ExternalRagEvalScore[] | undefined>;
941
1015
  thresholds?: Partial<Record<RagEvalMetricKey, number>>;
@@ -977,11 +1051,12 @@ interface KnowledgeBaseQualityReport {
977
1051
  findings: readonly RagGapFinding[];
978
1052
  }
979
1053
  type MaybePromise<T> = T | Promise<T>;
980
- declare function ragAnswerQualityJudge(options?: RagAnswerQualityJudgeOptions): JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>;
981
- declare function scoreRagAnswerArtifact(artifact: RagAnswerEvalArtifact, scenario: RagAnswerEvalScenario, options?: RagAnswerQualityJudgeOptions): RagAnswerMetricSummary;
982
- declare function diagnoseRagAnswerFailure(metrics: Record<RagEvalMetricKey, number>, scenario: RagAnswerEvalScenario, thresholds?: Partial<Record<RagEvalMetricKey, number>>): RagGapFinding[];
1054
+
983
1055
  declare function createRagAnswerQualityHook(options: RagAnswerQualityHookOptions): () => Promise<RagAnswerQualityResult>;
984
1056
  declare function calibrateRagAnswerJudge(options: RagCalibrationOptions): Promise<RagCalibrationResult>;
1057
+
1058
+ declare function scoreKnowledgeBaseIndex(index: KnowledgeIndex, options?: KnowledgeBaseQualityOptions): KnowledgeBaseQualityReport;
1059
+
985
1060
  declare function normalizeExternalRagScores(scores: readonly ExternalRagEvalScore[]): Record<string, Record<RagEvalMetricKey, number>>;
986
1061
  declare function toRagasEvaluationRows(cases: readonly RagAnswerEvalCase[]): {
987
1062
  user_input: string;
@@ -1013,7 +1088,10 @@ declare function toRagCheckerRecords(cases: readonly RagAnswerEvalCase[]): {
1013
1088
  }[];
1014
1089
  claims: string[];
1015
1090
  }[];
1016
- declare function scoreKnowledgeBaseIndex(index: KnowledgeIndex, options?: KnowledgeBaseQualityOptions): KnowledgeBaseQualityReport;
1091
+
1092
+ declare function ragAnswerQualityJudge(options?: RagAnswerQualityJudgeOptions): JudgeConfig<RagAnswerEvalArtifact, RagAnswerEvalScenario>;
1093
+ declare function scoreRagAnswerArtifact(artifact: RagAnswerEvalArtifact, scenario: RagAnswerEvalScenario, options?: RagAnswerQualityJudgeOptions): RagAnswerMetricSummary;
1094
+ declare function diagnoseRagAnswerFailure(metrics: Record<RagEvalMetricKey, number>, scenario: RagAnswerEvalScenario, thresholds?: Partial<Record<RagEvalMetricKey, number>>): RagGapFinding[];
1017
1095
 
1018
1096
  type KnowledgeImprovementStatus = 'running' | 'candidate-ready' | 'promoted' | 'rejected' | 'blocked';
1019
1097
  interface KnowledgeImprovementMetricProvenanceBase {
@@ -1063,6 +1141,8 @@ interface KnowledgeImprovementCandidateRecord {
1063
1141
  candidateHash?: string;
1064
1142
  evidenceHash?: string;
1065
1143
  promotionPlanHash?: string;
1144
+ /** Durable one-way boundary preventing final-case reuse after interruption. */
1145
+ finalEvaluationStartedAt?: string;
1066
1146
  status: KnowledgeImprovementStatus;
1067
1147
  createdAt: string;
1068
1148
  updatedAt: string;
@@ -1071,6 +1151,7 @@ interface KnowledgeImprovementRunState {
1071
1151
  runId: string;
1072
1152
  root: string;
1073
1153
  goal: string;
1154
+ implementationRef: string;
1074
1155
  status: KnowledgeImprovementStatus;
1075
1156
  baseHash: string;
1076
1157
  createdAt: string;
@@ -1114,6 +1195,7 @@ declare const KnowledgeImprovementRunStateSchema: z.ZodObject<{
1114
1195
  runId: z.ZodString;
1115
1196
  root: z.ZodString;
1116
1197
  goal: z.ZodString;
1198
+ implementationRef: z.ZodString;
1117
1199
  status: z.ZodEnum<{
1118
1200
  rejected: "rejected";
1119
1201
  promoted: "promoted";
@@ -1132,6 +1214,7 @@ declare const KnowledgeImprovementRunStateSchema: z.ZodObject<{
1132
1214
  candidateHash: z.ZodOptional<z.ZodString>;
1133
1215
  evidenceHash: z.ZodOptional<z.ZodString>;
1134
1216
  promotionPlanHash: z.ZodOptional<z.ZodString>;
1217
+ finalEvaluationStartedAt: z.ZodOptional<z.ZodISODateTime>;
1135
1218
  status: z.ZodEnum<{
1136
1219
  rejected: "rejected";
1137
1220
  promoted: "promoted";
@@ -1151,6 +1234,7 @@ declare const KnowledgeImprovementEvidenceSchema: z.ZodObject<{
1151
1234
  candidateId: z.ZodString;
1152
1235
  iteration: z.ZodNumber;
1153
1236
  goalHash: z.ZodString;
1237
+ implementationRef: z.ZodString;
1154
1238
  baseHash: z.ZodString;
1155
1239
  candidateHash: z.ZodString;
1156
1240
  promotionPlanHash: z.ZodString;
@@ -1237,6 +1321,20 @@ interface ResolvedKnowledgeImprovementCandidate {
1237
1321
  interface KnowledgeImprovementRetrievalOptions extends Omit<RunRetrievalImprovementLoopOptions, 'index' | 'runDir'> {
1238
1322
  runDir?: RunRetrievalImprovementLoopOptions['runDir'];
1239
1323
  }
1324
+ type KnowledgeImprovementRagOptimizationRunInput = Parameters<RunRagOptimizationOptions['run']>[0] & {
1325
+ runId: string;
1326
+ iteration: number;
1327
+ candidateId: string;
1328
+ root: string;
1329
+ baselineRoot: string;
1330
+ candidateRoot: string;
1331
+ candidateIndex: KnowledgeIndex;
1332
+ baseHash: string;
1333
+ };
1334
+ interface KnowledgeImprovementRagOptimizationOptions extends Omit<RunRagOptimizationOptions, 'run' | 'runDir'> {
1335
+ runDir?: RunRagOptimizationOptions['runDir'];
1336
+ run(input: KnowledgeImprovementRagOptimizationRunInput): Promise<RagAnswerEvalArtifact>;
1337
+ }
1240
1338
  interface KnowledgeImprovementUpdateInput extends RagKnowledgeUpdateInput {
1241
1339
  runId: string;
1242
1340
  iteration: number;
@@ -1250,6 +1348,11 @@ type KnowledgeImprovementUpdate = (input: KnowledgeImprovementUpdateInput) => Pr
1250
1348
  interface KnowledgeImprovementOptions {
1251
1349
  root: string;
1252
1350
  goal: string;
1351
+ /**
1352
+ * Immutable identity covering callbacks, evaluation policy, models, indexes,
1353
+ * external services, and all other behavior that can affect this run.
1354
+ */
1355
+ implementationRef: string;
1253
1356
  runId?: string;
1254
1357
  ownerId?: string;
1255
1358
  leaseTtlMs?: number;
@@ -1263,40 +1366,93 @@ interface KnowledgeImprovementOptions {
1263
1366
  kbQuality?: KnowledgeBaseQualityOptions;
1264
1367
  step?: RunKnowledgeResearchLoopOptions['step'];
1265
1368
  knowledgeResearch?: Omit<RagKnowledgeResearchOptions, 'root'>;
1369
+ ragOptimization?: KnowledgeImprovementRagOptimizationOptions;
1266
1370
  retrieval?: KnowledgeImprovementRetrievalOptions;
1267
1371
  diagnose?: NonNullable<RunRagKnowledgeImprovementLoopOptions['diagnose']>;
1268
1372
  acquireKnowledge?: NonNullable<RunRagKnowledgeImprovementLoopOptions['acquireKnowledge']>;
1269
1373
  updateKnowledge?: KnowledgeImprovementUpdate;
1270
1374
  evaluateAnswers?: NonNullable<RunRagKnowledgeImprovementLoopOptions['evaluateAnswers']>;
1271
- decidePromotion?: NonNullable<RunRagKnowledgeImprovementLoopOptions['promote']>;
1375
+ answerQualityCostCeiling?: RunRagKnowledgeImprovementLoopOptions['answerQualityCostCeiling'];
1376
+ decidePromotion?: NonNullable<RunRagKnowledgeImprovementLoopOptions['decidePromotion']>;
1272
1377
  enabledPhases?: readonly RagKnowledgeImprovementPhase[];
1273
1378
  requiredPhases?: readonly RagKnowledgeImprovementPhase[];
1379
+ /** Repeatable candidate screening that must not use final cases. */
1380
+ evaluateDevelopment?: KnowledgeImprovementEvaluator;
1381
+ /** Single-use final evaluator. A failure ends the run. */
1274
1382
  evaluate?: KnowledgeImprovementEvaluator;
1275
1383
  signal?: AbortSignal;
1276
1384
  now?: () => Date;
1277
1385
  onState?: (state: KnowledgeImprovementRunState) => Promise<void> | void;
1278
1386
  }
1387
+
1388
+ /** Load the durable result for one exact activation without changing knowledge or run state. */
1389
+ declare function loadKnowledgeImprovementActivationResult(options: LoadKnowledgeImprovementActivationResultOptions): Promise<AgentImprovementActivationResult | null>;
1390
+
1391
+ type PolicyCandidateOptions = Omit<KnowledgeImprovementOptions, 'root' | 'goal' | 'implementationRef' | 'runId' | 'maxCandidates' | 'step' | 'knowledgeResearch' | 'updateKnowledge'>;
1392
+ type PolicyOptimizationBaseOptions<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> = Omit<RunSerializedKnowledgeOptimizationOptions<TPolicy, TScenario, TArtifact>, 'baseline' | 'method' | 'trainScenarios' | 'selectionScenarios' | 'finalScenarios' | 'executionRef'>;
1393
+ interface OptimizeKnowledgeBasePolicyOptions<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> extends PolicyOptimizationBaseOptions<TPolicy, TScenario, TArtifact> {
1394
+ root: string;
1395
+ goal: string;
1396
+ baselinePolicy: TPolicy;
1397
+ method: OptimizationMethod<TScenario, TArtifact>;
1398
+ trainScenarios: readonly TScenario[];
1399
+ selectionScenarios: readonly TScenario[];
1400
+ finalScenarios: readonly TScenario[];
1401
+ /** Commit or content identity for evaluation, applyPolicy, and external dependencies. */
1402
+ policyApplicationRef: string;
1403
+ /** Optional namespace for parallel materialization of the same measured policy. */
1404
+ candidateRunLabel?: string;
1405
+ candidate?: PolicyCandidateOptions;
1406
+ applyPolicy(input: KnowledgeImprovementUpdateInput & {
1407
+ policy: TPolicy;
1408
+ policySurface: string;
1409
+ policySurfaceHash: string;
1410
+ optimizationMethod: string;
1411
+ }): Promise<{
1412
+ applied: boolean;
1413
+ summary: string;
1414
+ metadata?: Record<string, AgentCandidateJsonValue>;
1415
+ }>;
1416
+ }
1417
+ interface OptimizeKnowledgeBasePolicyResult<TPolicy extends AgentCandidateJsonValue> {
1418
+ optimization: RunSerializedKnowledgeOptimizationResult<TPolicy>;
1419
+ improvement: KnowledgeImprovementResult;
1420
+ }
1421
+ /**
1422
+ * Optimizes a serialized KB-maintenance policy, then materializes the selected
1423
+ * policy in one isolated knowledge candidate. Activation remains explicit.
1424
+ */
1425
+ declare function optimizeKnowledgeBasePolicy<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact>(options: OptimizeKnowledgeBasePolicyOptions<TPolicy, TScenario, TArtifact>): Promise<OptimizeKnowledgeBasePolicyResult<TPolicy>>;
1426
+ type KnowledgePolicyDispatch<TPolicy extends AgentCandidateJsonValue, TScenario extends Scenario, TArtifact> = (input: {
1427
+ candidate: TPolicy;
1428
+ candidateSurface: string;
1429
+ candidateSurfaceHash: string;
1430
+ scenario: TScenario;
1431
+ context: DispatchContext;
1432
+ }) => Promise<TArtifact>;
1433
+
1434
+ declare function improveKnowledgeBase(options: KnowledgeImprovementOptions): Promise<KnowledgeImprovementResult>;
1435
+
1279
1436
  declare function knowledgeImprovementRunId(root: string, goal: string): string;
1280
1437
  declare function knowledgeImprovementRunDir(root: string, runId: string): string;
1281
1438
  declare function loadKnowledgeImprovementState(root: string, runId: string): Promise<KnowledgeImprovementRunState | null>;
1282
- /** Load the durable result for one exact activation without changing knowledge or run state. */
1283
- declare function loadKnowledgeImprovementActivationResult(options: LoadKnowledgeImprovementActivationResultOptions): Promise<AgentImprovementActivationResult | null>;
1439
+ interface KnowledgeImprovementEvent extends Record<string, unknown> {
1440
+ at: string;
1441
+ type: string;
1442
+ }
1443
+ declare function loadKnowledgeImprovementEvents(root: string, runId: string): Promise<KnowledgeImprovementEvent[]>;
1444
+
1445
+ /** Promote one previously measured candidate without rerunning research or evaluation. */
1446
+ declare function promoteKnowledgeCandidate(options: PromoteKnowledgeCandidateOptions): Promise<KnowledgeImprovementMutationResult>;
1447
+ /** Restore the frozen baseline paired with one previously measured candidate. */
1448
+ declare function restoreKnowledgeCandidateBaseline(options: RestoreKnowledgeCandidateBaselineOptions): Promise<KnowledgeImprovementMutationResult>;
1449
+
1284
1450
  /** Freeze the exact knowledge bytes and measured evidence a later approval may promote. */
1285
1451
  declare function knowledgeImprovementCandidateRef(result: Pick<KnowledgeImprovementResult, 'runId' | 'state' | 'candidate'>): KnowledgeImprovementCandidateRef;
1286
1452
  /** Use both frozen sides of one measured comparison in isolated, integrity-checked copies. */
1287
1453
  declare function withKnowledgeImprovementComparison<T>(options: UseKnowledgeImprovementCandidateOptions, use: (comparison: ResolvedKnowledgeImprovementComparison) => Promise<T> | T): Promise<T>;
1288
1454
  /** Use the frozen candidate side of one measured comparison. */
1289
1455
  declare function withKnowledgeImprovementCandidate<T>(options: UseKnowledgeImprovementCandidateOptions, use: (candidate: ResolvedKnowledgeImprovementCandidate) => Promise<T> | T): Promise<T>;
1290
- /** Promote one previously measured candidate without rerunning research or evaluation. */
1291
- declare function promoteKnowledgeCandidate(options: PromoteKnowledgeCandidateOptions): Promise<KnowledgeImprovementMutationResult>;
1292
- /** Restore the frozen baseline paired with one previously measured candidate. */
1293
- declare function restoreKnowledgeCandidateBaseline(options: RestoreKnowledgeCandidateBaselineOptions): Promise<KnowledgeImprovementMutationResult>;
1294
- declare function improveKnowledgeBase(options: KnowledgeImprovementOptions): Promise<KnowledgeImprovementResult>;
1295
- interface KnowledgeImprovementEvent extends Record<string, unknown> {
1296
- at: string;
1297
- type: string;
1298
- }
1299
- declare function loadKnowledgeImprovementEvents(root: string, runId: string): Promise<KnowledgeImprovementEvent[]>;
1300
1456
  declare function hashKnowledgeBase(root: string): Promise<string>;
1301
1457
 
1302
1458
  /** Convert a measured knowledge candidate into the shared review and execution identity. */
@@ -1510,8 +1666,7 @@ interface ClaimGroundingDriverOptions extends GroundClaimOptions {
1510
1666
  * What to do when a proposal carries NO cited claim. `'reject'` (default) is
1511
1667
  * fail-closed: in claim-grounding mode every source must declare what it is
1512
1668
  * cited for, so an un-annotated source is treated as ungrounded. `'accept'`
1513
- * lets un-annotated sources through to the relevance verifier (if any) —
1514
- * useful when mixing annotated and legacy proposals.
1669
+ * lets unannotated sources through to the relevance verifier, if present.
1515
1670
  */
1516
1671
  onMissingClaim?: 'reject' | 'accept';
1517
1672
  }
@@ -1660,11 +1815,48 @@ declare function createKnowledgeEvent(input: {
1660
1815
  now?: () => Date;
1661
1816
  }): KnowledgeEvent;
1662
1817
 
1818
+ interface FileSystemSearchProviderOptions {
1819
+ /** Knowledge-base root containing `knowledge/` and `.agent-knowledge/`. */
1820
+ root: string;
1821
+ /** Optional warm index, useful when the caller already built one. */
1822
+ index?: KnowledgeIndex;
1823
+ /** Default result count for `search()`. Defaults to 10. */
1824
+ defaultLimit?: number;
1825
+ /**
1826
+ * `manual` caches the index until `refresh: true` or `invalidate()`.
1827
+ * `always` rebuilds from disk on every search.
1828
+ */
1829
+ refresh?: 'manual' | 'always';
1830
+ }
1831
+ interface FileSystemSearchOptions {
1832
+ limit?: number;
1833
+ refresh?: boolean;
1834
+ }
1835
+ /**
1836
+ * File-first retrieval over an `agent-knowledge` KB.
1837
+ *
1838
+ * This is the simple backend for products that want deterministic search over
1839
+ * markdown knowledge files before adding embeddings, rerankers, or a vector DB.
1840
+ */
1841
+ declare class FileSystemSearchProvider {
1842
+ readonly root: string;
1843
+ private index;
1844
+ private readonly defaultLimit;
1845
+ private readonly refreshMode;
1846
+ constructor(options: FileSystemSearchProviderOptions);
1847
+ getIndex(options?: FileSystemSearchOptions): Promise<KnowledgeIndex>;
1848
+ search(query: string, options?: FileSystemSearchOptions): Promise<KnowledgeSearchResult[]>;
1849
+ retrieve(query: string, options?: FileSystemSearchOptions): Promise<RetrievedKnowledgeHit[]>;
1850
+ asRetrievalEvalRetriever(): RetrievalEvalRetriever;
1851
+ invalidate(): void;
1852
+ }
1853
+ declare function createFileSystemSearchProvider(options: FileSystemSearchProviderOptions): FileSystemSearchProvider;
1854
+
1663
1855
  /**
1664
1856
  * Knowledge freshness store: tracks when each `(workspaceId, sourceId)` pair
1665
1857
  * was last successfully refreshed, and reports staleness against a TTL.
1666
1858
  *
1667
- * The contract is intentionally minimal just enough to drive a cron loop:
1859
+ * The contract is intentionally minimal and supports scheduled refresh loops:
1668
1860
  *
1669
1861
  * ```ts
1670
1862
  * const store = createFileSystemFreshnessStore({ root: '.agent-knowledge' })
@@ -1677,20 +1869,16 @@ declare function createKnowledgeEvent(input: {
1677
1869
  * }
1678
1870
  * ```
1679
1871
  *
1680
- * Per-tenant isolation is enforced by `workspaceId` keying there is no
1872
+ * Per-tenant isolation is enforced by `workspaceId` keying. There is no
1681
1873
  * global mutable state across workspaces.
1682
1874
  *
1683
1875
  * Two adapters ship in-package:
1684
1876
  *
1685
- * - `createFileSystemFreshnessStore` JSON file under the knowledge root,
1877
+ * - `createFileSystemFreshnessStore`: JSON file under the knowledge root,
1686
1878
  * mirrors the layout convention already used by `sources.json`.
1687
- * - `createD1FreshnessStoreStub` adapter scaffold for Cloudflare D1 /
1688
- * Postgres. Production consumers should implement the `D1Adapter`
1689
- * interface inside their own app; this stub exists to anchor the shape.
1690
- *
1691
- * @stable contract — interface is frozen at 0.x within this major.
1692
- * @stable filesystem adapter
1693
- * @experimental D1 stub — interface will evolve as real consumers wire it.
1879
+ * - `createD1FreshnessStoreStub`: complete bridge from the `D1Adapter` port
1880
+ * to this package's freshness interface. The port can be backed by D1,
1881
+ * PostgreSQL, SQLite, or another application-owned store.
1694
1882
  */
1695
1883
  /** Identity for one freshness record. */
1696
1884
  interface FreshnessKey {
@@ -1699,7 +1887,7 @@ interface FreshnessKey {
1699
1887
  }
1700
1888
  /** TTL bound for staleness checks. */
1701
1889
  interface FreshnessTtl extends FreshnessKey {
1702
- /** Milliseconds `Date.now() - last() > ttlMs` ⇒ stale. */
1890
+ /** Milliseconds; the record is stale when `Date.now() - last() > ttlMs`. */
1703
1891
  ttlMs: number;
1704
1892
  /** Injected clock for deterministic tests; defaults to system time. */
1705
1893
  now?: Date;
@@ -1717,7 +1905,7 @@ interface KnowledgeFreshnessStore {
1717
1905
  mark(input: FreshnessMark): Promise<void>;
1718
1906
  /** True iff `last(key)` is null or older than `ttlMs`. */
1719
1907
  stale(input: FreshnessTtl): Promise<boolean>;
1720
- /** All records for a workspace — useful for dashboards / debugging. */
1908
+ /** All records for a workspace. */
1721
1909
  list(workspaceId: string): Promise<FreshnessRecord[]>;
1722
1910
  }
1723
1911
  interface FreshnessRecord {
@@ -1735,7 +1923,7 @@ interface FileSystemFreshnessStoreOptions {
1735
1923
  }
1736
1924
  /**
1737
1925
  * Filesystem-backed implementation. Single JSON file per knowledge root,
1738
- * indexed by `${workspaceId}::${sourceId}`. Reads parse on every call
1926
+ * indexed by `${workspaceId}::${sourceId}`. Reads parse on every call;
1739
1927
  * cron tick rate is well below the cost of one JSON parse.
1740
1928
  *
1741
1929
  * Writes share the package-wide filesystem lock, so multiple workers cannot
@@ -1743,10 +1931,8 @@ interface FileSystemFreshnessStoreOptions {
1743
1931
  */
1744
1932
  declare function createFileSystemFreshnessStore(options: FileSystemFreshnessStoreOptions): KnowledgeFreshnessStore;
1745
1933
  /**
1746
- * D1 / Postgres adapter scaffold. Production consumers implement
1747
- * `D1Adapter` against their own driver (better-sqlite3, postgres,
1748
- * Cloudflare D1 binding, ...). This factory wires the adapter to the
1749
- * `KnowledgeFreshnessStore` interface.
1934
+ * Bridge an application-owned database adapter to `KnowledgeFreshnessStore`.
1935
+ * The adapter may use D1, PostgreSQL, SQLite, or another durable store.
1750
1936
  *
1751
1937
  * The expected schema:
1752
1938
  *
@@ -2311,12 +2497,8 @@ interface KnowledgeReleaseReport {
2311
2497
  baselineRuns: RunRecord[];
2312
2498
  }
2313
2499
  /**
2314
- * Campaign-native release report. The caller (a consumer's KB self-improvement
2315
- * loop) supplies the candidate/baseline `RunRecord[]` (e.g. via
2316
- * `campaignToRunRecords`) + optional per-instance `ReleaseTraceEvidence` + the
2317
- * gate decision; this folds them into a `ReleaseConfidenceScorecard` + a
2318
- * `KnowledgeRelease`. Release confidence is computed from run records + traces,
2319
- * independent of any optimizer result shape.
2500
+ * Build a knowledge release report from candidate and baseline run records,
2501
+ * optional trace evidence, and an optional decision record.
2320
2502
  */
2321
2503
  interface KnowledgeReleaseInput {
2322
2504
  candidateId: string;
@@ -2325,14 +2507,11 @@ interface KnowledgeReleaseInput {
2325
2507
  baselineRuns?: RunRecord[];
2326
2508
  traces?: ReleaseTraceEvidence[];
2327
2509
  gateDecision?: GateDecision | null;
2510
+ /** Scenario corpus used to prove train and holdout split coverage. */
2511
+ scenarios?: readonly DatasetScenario[];
2328
2512
  /**
2329
- * True when a held-out split was evaluated (drives the holdout threshold).
2330
- *
2331
- * Constraint: the substrate gate keys the holdout requirement off a scenario
2332
- * corpus, which this run-only report does not carry. With `hasHoldout: true`
2333
- * the gate fails closed (`missing_holdout_split`) even when holdout RunRecords
2334
- * are supplied. Callers that gate on a real held-out split should drive
2335
- * `evaluateReleaseConfidence` directly with a dataset/scenarios.
2513
+ * Require both a holdout scenario and a holdout run.
2514
+ * Provide `scenarios` with at least one `split: 'holdout'` item when true.
2336
2515
  */
2337
2516
  hasHoldout?: boolean;
2338
2517
  /** Candidate is the search-best variant — a promotion precondition. Default true. */
@@ -2710,4 +2889,4 @@ declare function normalizeLinkTarget(target: string): string;
2710
2889
  declare function isSafeKnowledgePath(path: string, allowedPrefixes?: string[]): boolean;
2711
2890
  declare function parseKnowledgeWriteBlocks(text: string, allowedPrefixes?: string[]): KnowledgeWriteParseResult;
2712
2891
 
2713
- 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 KnowledgeImprovementActivationPersistence, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementCandidateRef, KnowledgeImprovementCandidateRefSchema, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementEvent, type KnowledgeImprovementEvidence, KnowledgeImprovementEvidenceSchema, type KnowledgeImprovementMetric, type KnowledgeImprovementMetricProvenance, type KnowledgeImprovementMutationReceipt, type KnowledgeImprovementMutationResult, type KnowledgeImprovementOptions, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, KnowledgeImprovementRunStateSchema, type KnowledgeImprovementStatus, type KnowledgeImprovementTarget, 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 LoadKnowledgeImprovementActivationResultOptions, 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 ResolvedKnowledgeImprovementComparison, type ResolvedKnowledgeImprovementComparisonSnapshot, type RestoreKnowledgeCandidateBaselineOptions, 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, fromAgentCandidateKnowledgeRef, gradeCompanyAgainstText, gradeFactAgainstText, groundClaimInText, hashKnowledgeBase, improveKnowledgeBase, initKnowledgeBase, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isSafeKnowledgePath, isScaffoldPath, kbIndexToText, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, normalizeExternalRagScores, normalizeLinkTarget, parseFrontmatter, parseKnowledgeWriteBlocks, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, recoverPendingKnowledgeMutation, restoreKnowledgeCandidateBaseline, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeResearchLoop, runRagKnowledgeImprovementLoop, runTwoAgentResearchLoop, runVerifiedResearchLoop, scoreKnowledgeBaseIndex, scoreRagAnswerArtifact, searchKnowledge, sha256, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, thesisReadinessSpecs, toAgentCandidateKnowledgeRef, toDeepEvalTestCases, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, withKnowledgeImprovementComparison, writeJson, writeKnowledgeIndex, writeSourceRegistry };
2892
+ 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 FileSystemSearchOptions, FileSystemSearchProvider, type FileSystemSearchProviderOptions, 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 KnowledgeImprovementActivationPersistence, type KnowledgeImprovementCandidateRecord, type KnowledgeImprovementCandidateRef, KnowledgeImprovementCandidateRefSchema, type KnowledgeImprovementEvaluationInput, type KnowledgeImprovementEvaluator, type KnowledgeImprovementEvent, type KnowledgeImprovementEvidence, KnowledgeImprovementEvidenceSchema, type KnowledgeImprovementMetric, type KnowledgeImprovementMetricProvenance, type KnowledgeImprovementMutationReceipt, type KnowledgeImprovementMutationResult, type KnowledgeImprovementOptions, type KnowledgeImprovementRagOptimizationOptions, type KnowledgeImprovementRagOptimizationRunInput, type KnowledgeImprovementResult, type KnowledgeImprovementRetrievalOptions, type KnowledgeImprovementRunState, KnowledgeImprovementRunStateSchema, type KnowledgeImprovementStatus, type KnowledgeImprovementTarget, type KnowledgeImprovementUpdate, type KnowledgeImprovementUpdateInput, KnowledgeIndex, KnowledgeIndexSchema, type KnowledgeInspection, type KnowledgeLayout, KnowledgeLintFinding, KnowledgePage, KnowledgePageSchema, type KnowledgePolicyDispatch, type KnowledgeProposal, KnowledgeProposalParseError, type KnowledgeReadinessSpec, KnowledgeRelease, type KnowledgeReleaseInput, type KnowledgeReleaseReport, type KnowledgeResearchLoopContext, type KnowledgeResearchLoopDecision, type KnowledgeResearchLoopResult, type KnowledgeResearchLoopStep, KnowledgeSearchResult, KnowledgeWriteBlock, KnowledgeWriteParseResult, type LoadKnowledgeImprovementActivationResultOptions, type MaterialFact, type MaterialFactLens, type MaterialFactsResult, MemoryKbStore, type OptimizeKnowledgeBasePolicyOptions, type OptimizeKnowledgeBasePolicyResult, 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 RagOptimizationConfig, type RagOptimizationSelection, 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 ResolvedKnowledgeImprovementComparison, type ResolvedKnowledgeImprovementComparisonSnapshot, type RestoreKnowledgeCandidateBaselineOptions, RetrievalConfig, RetrievalEvalArtifact, RetrievalEvalRetriever, RetrievalEvalScenario, RetrievalMetricWeights, type RetrievalOptimizationSelection, RetrievedKnowledgeHit, type RouterClient, RouterError, type RouterUsage, type RunDiscoveryLoopOptions, type RunKnowledgeResearchLoopOptions, type RunRagKnowledgeImprovementLoopOptions, type RunRagKnowledgeImprovementLoopResult, type RunRagOptimizationOptions, type RunRagOptimizationResult, type RunRetrievalImprovementLoopOptions, type RunRetrievalImprovementLoopResult, RunSerializedKnowledgeOptimizationOptions, RunSerializedKnowledgeOptimizationResult, 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, createFileSystemSearchProvider, createKnowledgeControlLoopAdapter, createKnowledgeEvent, createLocalDiscoveryDispatcher, createRagAnswerQualityHook, createResearchDrivingDriver, createTangleRouterClient, createVerifyingResearchDriver, createWebResearchWorker, defineReadinessSpec, detectChanges, diagnoseRagAnswerFailure, evaluateKnowledgeBaseReadiness, explainKnowledgeTarget, extractWikilinks, formatFrontmatter, fromAgentCandidateKnowledgeRef, gradeCompanyAgainstText, gradeFactAgainstText, groundClaimInText, hashKnowledgeBase, improveKnowledgeBase, initKnowledgeBase, inspectKnowledgeIndex, inspectPendingKnowledgeMutation, investmentThesisSet, isSafeKnowledgePath, isScaffoldPath, kbIndexToText, knowledgeImprovementCandidateRef, knowledgeImprovementRunDir, knowledgeImprovementRunId, knowledgeReleaseReport, layoutFor, lensDistribution, lintKnowledgeIndex, loadKnowledgeImprovementActivationResult, loadKnowledgeImprovementEvents, loadKnowledgeImprovementState, loadKnowledgePages, loadSourceRegistry, materialFactsSurfaced, materialFactsSurfacedInText, mediaTypeFor, normalizeExternalRagScores, normalizeLinkTarget, optimizeKnowledgeBasePolicy, parseFrontmatter, parseKnowledgeWriteBlocks, promoteKnowledgeCandidate, proposeFromFinding, proposeFromFindings, ragAnswerQualityJudge, reciprocalRankFusion, recoverPendingKnowledgeMutation, restoreKnowledgeCandidateBaseline, runDiscoveryLoop, runInvestmentThesisTask, runKnowledgeResearchLoop, runRagKnowledgeImprovementLoop, runRagOptimization, runRetrievalImprovementLoop, runTwoAgentResearchLoop, runVerifiedResearchLoop, scoreKnowledgeBaseIndex, scoreRagAnswerArtifact, searchKnowledge, sha256, slugify, sourceMatchesGaps, sourceRegistryPath, stableId, stripFrontmatter, textSourceAdapter, thesisReadinessSpecs, toAgentCandidateKnowledgeRef, toDeepEvalTestCases, toRagCheckerRecords, toRagasEvaluationRows, toTruLensRecords, tokenizeQuery, totalMaterialFacts, triageSource, validateKnowledgeIndex, withCitedClaim, withKnowledgeImprovementCandidate, withKnowledgeImprovementComparison, writeJson, writeKnowledgeIndex, writeSourceRegistry };