@indexnetwork/protocol 10.1.3-rc.453.1 → 11.0.0-rc.454.1
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/capabilities/opportunities.facade.d.ts +2 -1
- package/dist/capabilities/opportunities.facade.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/opportunity/application/opportunity.graph.d.ts +9 -3
- package/dist/opportunity/application/opportunity.graph.js +26 -14
- package/dist/opportunity/discovery.env.d.ts +6 -0
- package/dist/opportunity/discovery.env.js +30 -0
- package/dist/opportunity/domain/opportunity.state.d.ts +0 -2
- package/dist/opportunity/public/index.d.ts +2 -1
- package/dist/opportunity/public/index.js +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +2 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { RadarGraphFactory } from "../opportunity/radar/radar.graph.js";
|
|
10
10
|
export { OpportunityGraphFactory } from "../opportunity/application/opportunity.graph.js";
|
|
11
|
+
export type { OpportunityGraphThresholdOverrides } from "../opportunity/application/opportunity.graph.js";
|
|
11
12
|
export type { StampNewbornOpportunitiesFn, StampNewbornOpportunitiesInput } from "../opportunity/application/opportunity.newborn-stamping.js";
|
|
12
13
|
export { hasUnsupportedOpportunityClaim, stripUnsupportedOpportunityClaims } from "../opportunity/domain/opportunity.claim-safety.js";
|
|
13
14
|
export { buildCandidateEvidence } from "../opportunity/domain/opportunity.evidence.js";
|
|
@@ -17,7 +18,7 @@ export { OpportunityPresenter, gatherPresenterContext } from "../opportunity/app
|
|
|
17
18
|
export type { PresenterDatabase } from "../opportunity/application/opportunity.presenter.js";
|
|
18
19
|
export { createOpportunityTools } from "../opportunity/application/opportunity.tools.js";
|
|
19
20
|
export type { OpportunityToolDeps } from "../opportunity/ports/index.js";
|
|
20
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "../opportunity/discovery.env.js";
|
|
21
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "../opportunity/discovery.env.js";
|
|
21
22
|
export type { DiscoveryMatchType, DiscoveryProfileSource } from "../opportunity/discovery.env.js";
|
|
22
23
|
export { PoolDiscriminatorMiner } from "../opportunity/discriminator/discriminator.miner.js";
|
|
23
24
|
export { PoolDiscriminatorAssigner } from "../opportunity/discriminator/discriminator.assigner.js";
|
|
@@ -19,7 +19,7 @@ export { OpportunityPresenter, gatherPresenterContext } from "../opportunity/app
|
|
|
19
19
|
// ── MCP tool factory ──────────────────────────────────────────────────────────
|
|
20
20
|
export { createOpportunityTools } from "../opportunity/application/opportunity.tools.js";
|
|
21
21
|
// ── Discovery env accessors ───────────────────────────────────────────────────
|
|
22
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "../opportunity/discovery.env.js";
|
|
22
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "../opportunity/discovery.env.js";
|
|
23
23
|
// ── Pool discriminator (Lens A) ───────────────────────────────────────────────
|
|
24
24
|
export { PoolDiscriminatorMiner } from "../opportunity/discriminator/discriminator.miner.js";
|
|
25
25
|
export { PoolDiscriminatorAssigner } from "../opportunity/discriminator/discriminator.assigner.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export { MaintenanceGraphFactory } from "./capabilities/interaction-composition.
|
|
|
51
51
|
export type { MaintenanceGraphDatabase, MaintenanceGraphCache, MaintenanceGraphQueue } from "./capabilities/interaction-composition.facade.js";
|
|
52
52
|
export { NegotiationGraphFactory, negotiateCandidates } from "./capabilities/negotiation.facade.js";
|
|
53
53
|
export { OpportunityGraphFactory } from "./capabilities/opportunities.facade.js";
|
|
54
|
+
export type { OpportunityGraphThresholdOverrides } from "./capabilities/opportunities.facade.js";
|
|
54
55
|
export { hasUnsupportedOpportunityClaim } from "./capabilities/opportunities.facade.js";
|
|
55
56
|
export type { StampNewbornOpportunitiesFn } from "./capabilities/opportunities.facade.js";
|
|
56
57
|
export { opportunityOwnerActionForStatus, bindOwnerApprovalProvenance } from "./capabilities/opportunities.facade.js";
|
|
@@ -89,7 +90,7 @@ export type { PoolDiscriminatorAssignmentInput, PoolDiscriminatorAssignedAxis }
|
|
|
89
90
|
export { runPoolDiscriminatorShadow } from "./capabilities/opportunities.facade.js";
|
|
90
91
|
export { poolQuestionsMiningMode, poolQuestionsMode, poolQuestionsPushMode, poolQuestionsStampNewborn, POOL_DISCRIMINATOR_MIN_POOL_SIZE, POOL_DISCRIMINATOR_MAX_CANDIDATES, POOL_DISCRIMINATOR_MAX_PUBLIC_CONTEXT_CHARS, POOL_QUESTION_MIN_VOI, POOL_QUESTION_MAX_PENDING_PER_INTENT, } from "./capabilities/opportunities.facade.js";
|
|
91
92
|
export { poolQuestionsRanking, POOL_RERUN_DEBOUNCE_MS } from "./capabilities/opportunities.facade.js";
|
|
92
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "./capabilities/opportunities.facade.js";
|
|
93
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "./capabilities/opportunities.facade.js";
|
|
93
94
|
export type { DiscoveryMatchType, DiscoveryProfileSource } from "./capabilities/opportunities.facade.js";
|
|
94
95
|
export { poolQuestionsVisitTrigger, POOL_VISIT_MINING_DEBOUNCE_MS } from "./capabilities/opportunities.facade.js";
|
|
95
96
|
export { buildPoolAdjustment, planPoolAdjustments, mergePoolAdjustment } from "./capabilities/opportunities.facade.js";
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ export { runPoolDiscriminatorShadow } from "./capabilities/opportunities.facade.
|
|
|
75
75
|
export { poolQuestionsMiningMode, poolQuestionsMode, poolQuestionsPushMode, poolQuestionsStampNewborn, POOL_DISCRIMINATOR_MIN_POOL_SIZE, POOL_DISCRIMINATOR_MAX_CANDIDATES, POOL_DISCRIMINATOR_MAX_PUBLIC_CONTEXT_CHARS, POOL_QUESTION_MIN_VOI, POOL_QUESTION_MAX_PENDING_PER_INTENT, } from "./capabilities/opportunities.facade.js";
|
|
76
76
|
export { poolQuestionsRanking, POOL_RERUN_DEBOUNCE_MS } from "./capabilities/opportunities.facade.js";
|
|
77
77
|
// Discovery env accessors (IND-XXX)
|
|
78
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "./capabilities/opportunities.facade.js";
|
|
78
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "./capabilities/opportunities.facade.js";
|
|
79
79
|
export { poolQuestionsVisitTrigger, POOL_VISIT_MINING_DEBOUNCE_MS } from "./capabilities/opportunities.facade.js";
|
|
80
80
|
export { buildPoolAdjustment, planPoolAdjustments, mergePoolAdjustment } from "./capabilities/opportunities.facade.js";
|
|
81
81
|
export { synthesizePoolQuestion, selectQuestionDiscriminators, toQuestionDiscriminator, BOTH_MATTER_LABEL } from "./capabilities/opportunities.facade.js";
|
|
@@ -51,6 +51,10 @@ import { type StampNewbornOpportunitiesFn } from './opportunity.newborn-stamping
|
|
|
51
51
|
export type { QueueOpportunityNotificationFn } from './opportunity.lifecycle.js';
|
|
52
52
|
export type { StampNewbornOpportunitiesFn, StampNewbornOpportunitiesInput } from './opportunity.newborn-stamping.js';
|
|
53
53
|
export { buildPrioritizedNegotiationIntents } from './opportunity.existing-negotiation.js';
|
|
54
|
+
export interface OpportunityGraphThresholdOverrides {
|
|
55
|
+
retrievalMinSimilarity?: number;
|
|
56
|
+
evaluatorMinScore?: number;
|
|
57
|
+
}
|
|
54
58
|
/**
|
|
55
59
|
* Error text can include provider response bodies, URLs, and credentials. Keep
|
|
56
60
|
* observability useful by retaining only a conservative error class at this
|
|
@@ -97,6 +101,8 @@ export declare class OpportunityGraphFactory {
|
|
|
97
101
|
private queueNegotiateExisting?;
|
|
98
102
|
/** Host-side P4b stamper. Omitted by manual/introducer/enrichment roots. */
|
|
99
103
|
private stampNewbornOpportunities?;
|
|
104
|
+
/** Eval/test-only overrides; production composition resolves from environment. */
|
|
105
|
+
private thresholdOverrides?;
|
|
100
106
|
constructor(database: OpportunityGraphDatabase, embedder: Embedder, hydeGenerator: {
|
|
101
107
|
invoke: (input: HydeGeneratorInvokeInput) => Promise<{
|
|
102
108
|
hydeEmbeddings: Record<string, number[]>;
|
|
@@ -123,7 +129,9 @@ export declare class OpportunityGraphFactory {
|
|
|
123
129
|
*/
|
|
124
130
|
queueNegotiateExisting?: ((opportunityId: string, userId: string) => Promise<void>) | undefined,
|
|
125
131
|
/** Host-side P4b stamper. Omitted by manual/introducer/enrichment roots. */
|
|
126
|
-
stampNewbornOpportunities?: StampNewbornOpportunitiesFn | undefined
|
|
132
|
+
stampNewbornOpportunities?: StampNewbornOpportunitiesFn | undefined,
|
|
133
|
+
/** Eval/test-only overrides; production composition resolves from environment. */
|
|
134
|
+
thresholdOverrides?: OpportunityGraphThresholdOverrides | undefined);
|
|
127
135
|
createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
|
|
128
136
|
userId: Id<"users">;
|
|
129
137
|
searchQuery: string | undefined;
|
|
@@ -1144,7 +1152,6 @@ export declare class OpportunityGraphFactory {
|
|
|
1144
1152
|
options: {
|
|
1145
1153
|
initialStatus: OpportunityStatus;
|
|
1146
1154
|
negotiationContinuation?: import("../../shared/interfaces/database.interface.js").NegotiationContinuationExecution;
|
|
1147
|
-
minScore?: number;
|
|
1148
1155
|
limit?: number;
|
|
1149
1156
|
lenses?: import("../../shared/hyde/lens.inferrer.js").Lens[];
|
|
1150
1157
|
hydeDescription?: string;
|
|
@@ -1169,7 +1176,6 @@ export declare class OpportunityGraphFactory {
|
|
|
1169
1176
|
options: {
|
|
1170
1177
|
initialStatus: OpportunityStatus;
|
|
1171
1178
|
negotiationContinuation?: import("../../shared/interfaces/database.interface.js").NegotiationContinuationExecution;
|
|
1172
|
-
minScore?: number;
|
|
1173
1179
|
limit?: number;
|
|
1174
1180
|
lenses?: import("../../shared/hyde/lens.inferrer.js").Lens[];
|
|
1175
1181
|
hydeDescription?: string;
|
|
@@ -31,7 +31,7 @@ import { renderNetworkContext } from '../../shared/network/metadata.renderer.js'
|
|
|
31
31
|
import { requestContext } from "../../shared/observability/request-context.js";
|
|
32
32
|
import { getAbortSignalConfig } from "../../shared/agent/model-signal.js";
|
|
33
33
|
import { mergeOpportunityEvidence, withCandidateEvidence, withMatchedStrategies } from '../domain/opportunity.evidence.js';
|
|
34
|
-
import { discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource } from '../discovery.env.js';
|
|
34
|
+
import { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity } from '../discovery.env.js';
|
|
35
35
|
import { normalizeOpportunityActorIntent, resolveOpportunityActorIntent } from '../domain/opportunity.actor.js';
|
|
36
36
|
import { approveOpportunityIntroduction, deleteOpportunityLifecycle, sendOpportunityLifecycle, updateOpportunityLifecycle } from './opportunity.lifecycle.js';
|
|
37
37
|
import { stampEligibleNewbornOpportunities } from './opportunity.newborn-stamping.js';
|
|
@@ -208,7 +208,9 @@ export class OpportunityGraphFactory {
|
|
|
208
208
|
*/
|
|
209
209
|
queueNegotiateExisting,
|
|
210
210
|
/** Host-side P4b stamper. Omitted by manual/introducer/enrichment roots. */
|
|
211
|
-
stampNewbornOpportunities
|
|
211
|
+
stampNewbornOpportunities,
|
|
212
|
+
/** Eval/test-only overrides; production composition resolves from environment. */
|
|
213
|
+
thresholdOverrides) {
|
|
212
214
|
this.database = database;
|
|
213
215
|
this.embedder = embedder;
|
|
214
216
|
this.hydeGenerator = hydeGenerator;
|
|
@@ -218,8 +220,15 @@ export class OpportunityGraphFactory {
|
|
|
218
220
|
this.agentDispatcher = agentDispatcher;
|
|
219
221
|
this.queueNegotiateExisting = queueNegotiateExisting;
|
|
220
222
|
this.stampNewbornOpportunities = stampNewbornOpportunities;
|
|
223
|
+
this.thresholdOverrides = thresholdOverrides;
|
|
221
224
|
}
|
|
222
225
|
createGraph() {
|
|
226
|
+
const retrievalMinSimilarity = this.thresholdOverrides?.retrievalMinSimilarity === undefined
|
|
227
|
+
? discoveryMinSimilarity()
|
|
228
|
+
: validateDiscoveryMinSimilarity(this.thresholdOverrides.retrievalMinSimilarity);
|
|
229
|
+
const evaluatorMinScore = this.thresholdOverrides?.evaluatorMinScore === undefined
|
|
230
|
+
? discoveryEvaluatorMinScore()
|
|
231
|
+
: validateDiscoveryEvaluatorMinScore(this.thresholdOverrides.evaluatorMinScore);
|
|
223
232
|
const evaluatorAgent = this.optionalEvaluator ?? new OpportunityEvaluator();
|
|
224
233
|
// ═══════════════════════════════════════════════════════════════
|
|
225
234
|
// NODE DEFINITIONS
|
|
@@ -743,8 +752,6 @@ export class OpportunityGraphFactory {
|
|
|
743
752
|
// (The options.limit controls final output, not search pool)
|
|
744
753
|
const limitPerStrategy = 30;
|
|
745
754
|
const perIndexLimit = 80;
|
|
746
|
-
// Similarity threshold for recall (0.30 = 30% similarity)
|
|
747
|
-
const minScore = 0.3;
|
|
748
755
|
// Discovery match-type gating (DISCOVERY_ALLOWED_TYPES / DISCOVERY_PROFILE_SOURCE).
|
|
749
756
|
// Result filtering below is defense-in-depth: corpusGating already scopes the
|
|
750
757
|
// embedder's corpus searches, but adapters may still return other types.
|
|
@@ -903,7 +910,7 @@ export class OpportunityGraphFactory {
|
|
|
903
910
|
excludeUserId: discoveryUserId,
|
|
904
911
|
limitPerStrategy,
|
|
905
912
|
limit: perIndexLimit,
|
|
906
|
-
minScore,
|
|
913
|
+
minScore: retrievalMinSimilarity,
|
|
907
914
|
corpusGating,
|
|
908
915
|
});
|
|
909
916
|
if (intentResultsEnabled)
|
|
@@ -1011,6 +1018,7 @@ export class OpportunityGraphFactory {
|
|
|
1011
1018
|
networkIds: targetNetworkIds,
|
|
1012
1019
|
excludeUserId: discoveryUserId,
|
|
1013
1020
|
limitPerSource: PREMISE_MATCH_LIMIT_PER_SOURCE,
|
|
1021
|
+
minScore: retrievalMinSimilarity,
|
|
1014
1022
|
})
|
|
1015
1023
|
: (await Promise.all(sourcePremises.map(async (sp) => {
|
|
1016
1024
|
const results = await self.database.searchPremisesBySimilarity({
|
|
@@ -1018,6 +1026,7 @@ export class OpportunityGraphFactory {
|
|
|
1018
1026
|
networkIds: targetNetworkIds,
|
|
1019
1027
|
excludeUserId: discoveryUserId,
|
|
1020
1028
|
limit: PREMISE_MATCH_LIMIT_PER_SOURCE,
|
|
1029
|
+
minScore: retrievalMinSimilarity,
|
|
1021
1030
|
});
|
|
1022
1031
|
return results.map((r) => ({ ...r, sourcePremiseId: sp.premiseId }));
|
|
1023
1032
|
}))).flat();
|
|
@@ -1090,7 +1099,7 @@ export class OpportunityGraphFactory {
|
|
|
1090
1099
|
excludeUserId: discoveryUserId,
|
|
1091
1100
|
limitPerStrategy: limitPerStrategy,
|
|
1092
1101
|
limit: 20,
|
|
1093
|
-
minScore,
|
|
1102
|
+
minScore: retrievalMinSimilarity,
|
|
1094
1103
|
corpusGating,
|
|
1095
1104
|
});
|
|
1096
1105
|
for (const r of results.filter(r => r.type === 'intent')) {
|
|
@@ -1114,7 +1123,7 @@ export class OpportunityGraphFactory {
|
|
|
1114
1123
|
networkIds: [ctx.networkId],
|
|
1115
1124
|
excludeUserId: discoveryUserId,
|
|
1116
1125
|
limit: 20,
|
|
1117
|
-
minScore:
|
|
1126
|
+
minScore: retrievalMinSimilarity,
|
|
1118
1127
|
});
|
|
1119
1128
|
for (const r of results) {
|
|
1120
1129
|
contextCandidates.push(withCandidateEvidence({
|
|
@@ -1169,7 +1178,7 @@ export class OpportunityGraphFactory {
|
|
|
1169
1178
|
networkIds: [ctx.networkId],
|
|
1170
1179
|
excludeUserId: discoveryUserId,
|
|
1171
1180
|
limit: 20,
|
|
1172
|
-
minScore,
|
|
1181
|
+
minScore: retrievalMinSimilarity,
|
|
1173
1182
|
});
|
|
1174
1183
|
for (const r of results) {
|
|
1175
1184
|
contextCandidates.push(withCandidateEvidence({
|
|
@@ -1302,7 +1311,7 @@ export class OpportunityGraphFactory {
|
|
|
1302
1311
|
excludeUserId: discoveryUserId,
|
|
1303
1312
|
limitPerStrategy,
|
|
1304
1313
|
limit: perIndexLimit,
|
|
1305
|
-
minScore,
|
|
1314
|
+
minScore: retrievalMinSimilarity,
|
|
1306
1315
|
corpusGating,
|
|
1307
1316
|
});
|
|
1308
1317
|
if (intentResultsEnabled)
|
|
@@ -1692,8 +1701,9 @@ export class OpportunityGraphFactory {
|
|
|
1692
1701
|
return evidenceByEntityKey.get(keys[0]);
|
|
1693
1702
|
return undefined;
|
|
1694
1703
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1704
|
+
const minScore = state.targetUserId
|
|
1705
|
+
? DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT
|
|
1706
|
+
: evaluatorMinScore;
|
|
1697
1707
|
const evaluatorSignalConfig = getAbortSignalConfig();
|
|
1698
1708
|
const evaluator = typeof evaluatorAgent.invokeEntityBundle === 'function'
|
|
1699
1709
|
? evaluatorAgent
|
|
@@ -1883,15 +1893,17 @@ export class OpportunityGraphFactory {
|
|
|
1883
1893
|
});
|
|
1884
1894
|
// Build detailed trace entries for each evaluated candidate
|
|
1885
1895
|
// Threshold filter trace: how many candidates in this batch were above/below similarity threshold
|
|
1886
|
-
const aboveThreshold = batchToEvaluate.filter(
|
|
1896
|
+
const aboveThreshold = batchToEvaluate.filter((candidate) => candidate.similarity >= retrievalMinSimilarity).length;
|
|
1887
1897
|
const belowThreshold = batchToEvaluate.length - aboveThreshold;
|
|
1888
1898
|
traceEntries.push({
|
|
1889
1899
|
node: "threshold_filter",
|
|
1890
|
-
detail: `${aboveThreshold} above
|
|
1900
|
+
detail: `${aboveThreshold} above ${retrievalMinSimilarity}, ${belowThreshold} below (batch of ${batchToEvaluate.length})`,
|
|
1891
1901
|
data: {
|
|
1892
1902
|
aboveThreshold,
|
|
1893
1903
|
belowThreshold,
|
|
1894
|
-
minScore:
|
|
1904
|
+
minScore: retrievalMinSimilarity,
|
|
1905
|
+
retrievalMinSimilarity,
|
|
1906
|
+
evaluatorMinScore: minScore,
|
|
1895
1907
|
batchSize: batchToEvaluate.length,
|
|
1896
1908
|
},
|
|
1897
1909
|
});
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export declare const DISCOVERY_MIN_SIMILARITY_DEFAULT = 0.3;
|
|
2
|
+
export declare const DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT = 50;
|
|
3
|
+
export declare function validateDiscoveryMinSimilarity(value: number): number;
|
|
4
|
+
export declare function validateDiscoveryEvaluatorMinScore(value: number): number;
|
|
5
|
+
export declare function discoveryMinSimilarity(): number;
|
|
6
|
+
export declare function discoveryEvaluatorMinScore(): number;
|
|
1
7
|
/** Data types allowed to participate in opportunity matching. */
|
|
2
8
|
export type DiscoveryMatchType = 'intent' | 'profile';
|
|
3
9
|
/** Test hook: clear warn-once state so each test observes warnings. */
|
|
@@ -21,6 +21,36 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { protocolLogger } from '../shared/observability/protocol.logger.js';
|
|
23
23
|
const envLog = protocolLogger('Discovery:env');
|
|
24
|
+
export const DISCOVERY_MIN_SIMILARITY_DEFAULT = 0.30;
|
|
25
|
+
export const DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT = 50;
|
|
26
|
+
const DECIMAL_VALUE = /^[+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
27
|
+
function validateThreshold(name, value, max) {
|
|
28
|
+
if (!Number.isFinite(value) || value < 0 || value > max) {
|
|
29
|
+
throw new Error(`${name} must be a finite decimal between 0 and ${max} (inclusive)`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function readThreshold(raw, name, fallback, max) {
|
|
34
|
+
if (raw === undefined || raw.trim() === '')
|
|
35
|
+
return fallback;
|
|
36
|
+
const normalized = raw.trim();
|
|
37
|
+
if (!DECIMAL_VALUE.test(normalized)) {
|
|
38
|
+
throw new Error(`${name} must be a finite decimal between 0 and ${max} (inclusive)`);
|
|
39
|
+
}
|
|
40
|
+
return validateThreshold(name, Number(normalized), max);
|
|
41
|
+
}
|
|
42
|
+
export function validateDiscoveryMinSimilarity(value) {
|
|
43
|
+
return validateThreshold('DISCOVERY_MIN_SIMILARITY', value, 1);
|
|
44
|
+
}
|
|
45
|
+
export function validateDiscoveryEvaluatorMinScore(value) {
|
|
46
|
+
return validateThreshold('DISCOVERY_EVALUATOR_MIN_SCORE', value, 100);
|
|
47
|
+
}
|
|
48
|
+
export function discoveryMinSimilarity() {
|
|
49
|
+
return readThreshold(process.env.DISCOVERY_MIN_SIMILARITY, 'DISCOVERY_MIN_SIMILARITY', DISCOVERY_MIN_SIMILARITY_DEFAULT, 1);
|
|
50
|
+
}
|
|
51
|
+
export function discoveryEvaluatorMinScore() {
|
|
52
|
+
return readThreshold(process.env.DISCOVERY_EVALUATOR_MIN_SCORE, 'DISCOVERY_EVALUATOR_MIN_SCORE', DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, 100);
|
|
53
|
+
}
|
|
24
54
|
const VALID_TOKENS = new Set(['intent', 'profile']);
|
|
25
55
|
const BOTH = new Set(['intent', 'profile']);
|
|
26
56
|
/** Tokens/values already warned about (warn-once per process). */
|
|
@@ -118,8 +118,6 @@ export interface OpportunityGraphOptions {
|
|
|
118
118
|
negotiationContinuation?: NegotiationContinuationExecution;
|
|
119
119
|
/** Initial status for created opportunities (default: 'pending') */
|
|
120
120
|
initialStatus?: OpportunityStatus;
|
|
121
|
-
/** Minimum score threshold (default: 50) */
|
|
122
|
-
minScore?: number;
|
|
123
121
|
/** Maximum opportunities to return (default: 20) */
|
|
124
122
|
limit?: number;
|
|
125
123
|
/** Pre-inferred lenses (if not provided, lens inference runs automatically in HyDE graph) */
|
|
@@ -24,7 +24,7 @@ export { buildDiscoverySummary, toDiscoveryNegotiation, } from "../domain/negoti
|
|
|
24
24
|
export type { NegotiationResolution } from "../domain/negotiation-summary.builder.js";
|
|
25
25
|
export type { PoolCandidate, DiscriminatorMiningInput, MinedDiscriminator, ScoredDiscriminator, DiscriminatorShadowResult, } from "../discriminator/discriminator.types.js";
|
|
26
26
|
export { poolQuestionsMiningMode, poolQuestionsMode, poolQuestionsPushMode, poolQuestionsStampNewborn, POOL_DISCRIMINATOR_MIN_POOL_SIZE, POOL_DISCRIMINATOR_MAX_CANDIDATES, POOL_DISCRIMINATOR_MAX_PUBLIC_CONTEXT_CHARS, POOL_QUESTION_MIN_VOI, POOL_QUESTION_MAX_PENDING_PER_INTENT, poolQuestionsRanking, POOL_RERUN_DEBOUNCE_MS, poolQuestionsVisitTrigger, POOL_VISIT_MINING_DEBOUNCE_MS, } from "../discriminator/discriminator.env.js";
|
|
27
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "../discovery.env.js";
|
|
27
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "../discovery.env.js";
|
|
28
28
|
export type { DiscoveryMatchType, DiscoveryProfileSource, } from "../discovery.env.js";
|
|
29
29
|
export { buildPoolAdjustment, planPoolAdjustments, mergePoolAdjustment, } from "../discriminator/discriminator.adjustments.js";
|
|
30
30
|
export type { PoolAdjustment, PoolAdjustmentSignal, } from "../discriminator/discriminator.adjustments.js";
|
|
@@ -38,6 +38,7 @@ export { computeRadarHealth } from "../radar/radar.health.js";
|
|
|
38
38
|
export type { RadarHealthInput } from "../radar/radar.health.js";
|
|
39
39
|
export { isIntroducerDiscoveryEnabled } from "../application/opportunity.introducer-feature.js";
|
|
40
40
|
export { OpportunityGraphFactory } from "../application/opportunity.graph.js";
|
|
41
|
+
export type { OpportunityGraphThresholdOverrides } from "../application/opportunity.graph.js";
|
|
41
42
|
export type { StampNewbornOpportunitiesFn, StampNewbornOpportunitiesInput, } from "../application/opportunity.newborn-stamping.js";
|
|
42
43
|
export { OpportunityEvaluator } from "../application/opportunity.evaluator.js";
|
|
43
44
|
export type { EvaluatorInput } from "../application/opportunity.evaluator.js";
|
|
@@ -22,7 +22,7 @@ export { OPPORTUNITY_PRESENTATION_CACHE_VERSION, buildRadarCardPresentationCache
|
|
|
22
22
|
export { buildDiscoverySummary, toDiscoveryNegotiation, } from "../domain/negotiation-summary.builder.js";
|
|
23
23
|
export { poolQuestionsMiningMode, poolQuestionsMode, poolQuestionsPushMode, poolQuestionsStampNewborn, POOL_DISCRIMINATOR_MIN_POOL_SIZE, POOL_DISCRIMINATOR_MAX_CANDIDATES, POOL_DISCRIMINATOR_MAX_PUBLIC_CONTEXT_CHARS, POOL_QUESTION_MIN_VOI, POOL_QUESTION_MAX_PENDING_PER_INTENT, poolQuestionsRanking, POOL_RERUN_DEBOUNCE_MS, poolQuestionsVisitTrigger, POOL_VISIT_MINING_DEBOUNCE_MS, } from "../discriminator/discriminator.env.js";
|
|
24
24
|
// discovery env accessors
|
|
25
|
-
export { discoveryAllowedTypes, discoveryIntentMatchingEnabled, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, } from "../discovery.env.js";
|
|
25
|
+
export { DISCOVERY_EVALUATOR_MIN_SCORE_DEFAULT, DISCOVERY_MIN_SIMILARITY_DEFAULT, discoveryAllowedTypes, discoveryEvaluatorMinScore, discoveryIntentMatchingEnabled, discoveryMinSimilarity, discoveryProfileMatchingEnabled, discoveryProfileSource, resetDiscoveryEnvWarningsForTests, validateDiscoveryEvaluatorMinScore, validateDiscoveryMinSimilarity, } from "../discovery.env.js";
|
|
26
26
|
export { buildPoolAdjustment, planPoolAdjustments, mergePoolAdjustment, } from "../discriminator/discriminator.adjustments.js";
|
|
27
27
|
export { synthesizePoolQuestion, selectQuestionDiscriminators, toQuestionDiscriminator, BOTH_MATTER_LABEL, } from "../discriminator/discriminator.question.js";
|
|
28
28
|
export { poolQuestionCycleKey, buildPoolQuestionPushMessage, } from "../discriminator/discriminator.push.js";
|
|
@@ -1460,6 +1460,7 @@ export interface Database {
|
|
|
1460
1460
|
networkIds: string[];
|
|
1461
1461
|
excludeUserId: string;
|
|
1462
1462
|
limit: number;
|
|
1463
|
+
minScore?: number;
|
|
1463
1464
|
}): Promise<Array<{
|
|
1464
1465
|
premiseId: string;
|
|
1465
1466
|
userId: string;
|
|
@@ -1500,6 +1501,7 @@ export interface Database {
|
|
|
1500
1501
|
networkIds: string[];
|
|
1501
1502
|
excludeUserId: string;
|
|
1502
1503
|
limitPerSource: number;
|
|
1504
|
+
minScore?: number;
|
|
1503
1505
|
}): Promise<Array<{
|
|
1504
1506
|
sourcePremiseId: string;
|
|
1505
1507
|
premiseId: string;
|