dp-worker 0.1.30 → 0.1.34

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 (66) hide show
  1. package/builtin-skills/bilibili.md +57 -0
  2. package/builtin-skills/douyin.md +54 -0
  3. package/builtin-skills/linkedin.md +52 -0
  4. package/builtin-skills/weibo.md +61 -0
  5. package/builtin-skills/xiaohongshu.md +55 -0
  6. package/builtin-skills/zhihu.md +55 -0
  7. package/dist/agent/skill-generator.js +63 -0
  8. package/dist/agent/skill-generator.js.map +1 -1
  9. package/dist/browser/account-health.d.ts +16 -0
  10. package/dist/browser/account-health.js +33 -4
  11. package/dist/browser/account-health.js.map +1 -1
  12. package/dist/browser/workspace-lock.js +64 -3
  13. package/dist/browser/workspace-lock.js.map +1 -1
  14. package/dist/center/center-frontend.d.ts +10 -0
  15. package/dist/center/center-frontend.js +13 -3
  16. package/dist/center/center-frontend.js.map +1 -1
  17. package/dist/chrome-extension/omni-flow/manifest.json +1 -1
  18. package/node_modules/dp-shared/dist/bird-contracts.d.ts +8 -0
  19. package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -1
  20. package/node_modules/dp-shared/dist/bird-contracts.js +19 -0
  21. package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -1
  22. package/node_modules/dp-shared/dist/desk-contracts.d.ts +478 -0
  23. package/node_modules/dp-shared/dist/desk-contracts.d.ts.map +1 -0
  24. package/node_modules/dp-shared/dist/desk-contracts.js +397 -0
  25. package/node_modules/dp-shared/dist/desk-contracts.js.map +1 -0
  26. package/node_modules/dp-shared/dist/identities.d.ts +2 -1
  27. package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
  28. package/node_modules/dp-shared/dist/identities.js +13 -1
  29. package/node_modules/dp-shared/dist/identities.js.map +1 -1
  30. package/node_modules/dp-shared/dist/index.d.ts +2 -0
  31. package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
  32. package/node_modules/dp-shared/dist/index.js +2 -0
  33. package/node_modules/dp-shared/dist/index.js.map +1 -1
  34. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts +223 -6
  35. package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts.map +1 -1
  36. package/node_modules/dp-shared/dist/post-drafts-contracts.js +133 -0
  37. package/node_modules/dp-shared/dist/post-drafts-contracts.js.map +1 -1
  38. package/node_modules/dp-shared/dist/promo-contracts.d.ts +183 -23
  39. package/node_modules/dp-shared/dist/promo-contracts.d.ts.map +1 -1
  40. package/node_modules/dp-shared/dist/promo-contracts.js +368 -16
  41. package/node_modules/dp-shared/dist/promo-contracts.js.map +1 -1
  42. package/node_modules/dp-shared/dist/relay-contracts.d.ts +439 -0
  43. package/node_modules/dp-shared/dist/relay-contracts.d.ts.map +1 -0
  44. package/node_modules/dp-shared/dist/relay-contracts.js +362 -0
  45. package/node_modules/dp-shared/dist/relay-contracts.js.map +1 -0
  46. package/node_modules/dp-shared/dist/signal/draft-rules.d.ts +169 -0
  47. package/node_modules/dp-shared/dist/signal/draft-rules.d.ts.map +1 -0
  48. package/node_modules/dp-shared/dist/signal/draft-rules.js +261 -0
  49. package/node_modules/dp-shared/dist/signal/draft-rules.js.map +1 -0
  50. package/node_modules/dp-shared/dist/signal/normalize-metric.d.ts +121 -0
  51. package/node_modules/dp-shared/dist/signal/normalize-metric.d.ts.map +1 -0
  52. package/node_modules/dp-shared/dist/signal/normalize-metric.js +373 -0
  53. package/node_modules/dp-shared/dist/signal/normalize-metric.js.map +1 -0
  54. package/node_modules/dp-shared/dist/signal/signal-score.d.ts +445 -0
  55. package/node_modules/dp-shared/dist/signal/signal-score.d.ts.map +1 -0
  56. package/node_modules/dp-shared/dist/signal/signal-score.js +1922 -0
  57. package/node_modules/dp-shared/dist/signal/signal-score.js.map +1 -0
  58. package/node_modules/dp-shared/dist/signal/validate-draft.d.ts +718 -0
  59. package/node_modules/dp-shared/dist/signal/validate-draft.d.ts.map +1 -0
  60. package/node_modules/dp-shared/dist/signal/validate-draft.js +433 -0
  61. package/node_modules/dp-shared/dist/signal/validate-draft.js.map +1 -0
  62. package/node_modules/dp-shared/dist/signal/weighted-length.d.ts +87 -0
  63. package/node_modules/dp-shared/dist/signal/weighted-length.d.ts.map +1 -0
  64. package/node_modules/dp-shared/dist/signal/weighted-length.js +195 -0
  65. package/node_modules/dp-shared/dist/signal/weighted-length.js.map +1 -0
  66. package/package.json +1 -1
@@ -0,0 +1,1922 @@
1
+ /**
2
+ * signal-score.ts — Signal Desk 的 5 维 100 分评分引擎。
3
+ *
4
+ * 这是 Signal-Desk 0.6.1 `lib/intelligence.ts`(262 行)的逐行移植。五个维度、
5
+ * 各自的上限(来源可信度 25 / 市场影响 35 / 市场反应 10 / 时效 15 / 受众关联 15)、
6
+ * `ScoreBreakdown` 与 `scoreReasons[]` 的可解释契约、`clampScore` 的一位小数、
7
+ * 高优 ≥75 与今日关注 60–74.9(且 24 小时内)两个分档、重点资产 72 小时不受分数
8
+ * 限制的第三档 —— 全部保留,一个都没少。
9
+ *
10
+ * 它放在 dp-shared 而不是 dp-signal,是因为 dp-center 的审批页要展示同一份拆解
11
+ * (CONTRACT-FREEZE §C-15 第 4 行)。两侧 import 同一个函数,不允许各自实现。
12
+ *
13
+ * ## 为什么改成「特征提取 + 版本化配置档 + 两段式打分」
14
+ *
15
+ * 0.6.1 的 `scoreItem()` 算完即丢:既不存输入特征,也不存那 20 多个常数是哪一版。
16
+ * 于是「0.55 这个斜率该不该是 0.55」永远无法回答 —— 没有可重放的历史。
17
+ *
18
+ * 拆成 `extractFeatures()`(贵:分词、正则、gazetteer、行情)与 `scoreFeatures()`
19
+ * (纯函数:只读特征与 profile)之后:
20
+ * - 换一套常数重算 90 天 = 一次 D1 顺序读 + 一个纯函数,零 LLM、零重抓;
21
+ * - A/B = 同一批特征多插一行分数;
22
+ * - 特征按 `extractorVersion + termsVersion` 作键,分数按 `profileVersion` 作键,
23
+ * 两者互不失效。
24
+ *
25
+ * ## 移植时必须修掉的六个已复现缺陷
26
+ *
27
+ * 1. `hasAny()` 对 CJK 是子串匹配。`(?:^|[^a-z0-9])` 边界只对 ASCII 生效,中文没有
28
+ * 空格,于是「比特幣現金 (BCH)」命中 `比特幣` 被算成 Bitcoin 故事拿 55.6 分,
29
+ * 「清算所」命中 `清算` 被算成爆仓信号。改成 **单 trie 一次扫描 + 每个起点取最长
30
+ * 匹配 + 诱饵词只遮蔽不计分 + ASCII 词条另做 `[a-z0-9]` 边界**。
31
+ * 不依赖 `Intl.Segmenter` —— workerd 的 ICU 支持未文档化,而诱饵表的失败模式
32
+ * 可枚举、可单测、加一行数据就能修。
33
+ *
34
+ * 2. `classify()` 首个命中胜出,且 security 桶排在最前、桶里有裸词 `security`。
35
+ * 于是「SEC says XRP is not a security」被判成安全風險 65.5 分。改成
36
+ * **加权 argmax + security 桶 `requireAnyOf` 多词证据 + 显式 `unclassified`**。
37
+ * 同一个修法套用到 0.6.1 的 `classifyInformationType()`(它的兜底是静默的
38
+ * 「Crypto」,同样是把「不知道」伪装成一个答案)。
39
+ *
40
+ * 3. `if (hasAny(normalized, ["tapbit"])) audienceRelevance = 15;` —— 品牌名出现在
41
+ * 任何位置即受众满分。在单机版这只是难看;搬到服务端的共享排序里,它是一条
42
+ * **可写入的提权路径**:任何人加一个在 description 里注入 Tapbit 的个人 RSS,
43
+ * 就能把自己的内容钉在全团队看板顶部。而且「Tapbit accused of wash trading」
44
+ * 也拿满分。改成 **只认 gazetteer 签发的 BrandHit + 与其它重点实体同量级 +
45
+ * 用户自填源贡献恒为 0**。
46
+ *
47
+ * 4. 「Bitcoin's share of the total crypto market cap rose to 58%」被当成 58% 的价格
48
+ * 波动。根因有两层:`market cap` 在包含表里而 `share`/`dominance` 不在排除表;
49
+ * 以及 ±80 字符共现窗口根本不表达「这个百分比的主语是谁」。改成
50
+ * **结构化行情优先 + 句法附着模板 + 扩充排除表 + 幅度上限**。
51
+ *
52
+ * 5. 加 "proposes" 反而降分(53.2 → 52.4),因为 immediacy 的无关键词兜底是 1.5,
53
+ * 高于显式最低档 1。**这是分档设计的结构性错误,不是调参问题**:常数一旦外置成
54
+ * 数据,运营下次编辑 `config_json` 时会再犯,而那时 code review 拦不住。所以
55
+ * 所有阶梯必含 `unknown` 档,且 `assertProfileInvariants()` 断言
56
+ * `unknown ≤ min(所有显式档)` 并且显式档按取值降序排列(这两条一起才让
57
+ * 「首个命中」等价于「argmax」)。
58
+ *
59
+ * 6. 数字正则吃掉后随 ticker 的首字母 —— 那条与身份/清洗侧共用,评分侧只保证
60
+ * 百分比抽取自己的 `(\d+(?:\.\d+)?)\s*%` 不越界。
61
+ *
62
+ * 顺带修掉两个时间缺陷:未来时间戳(`Math.max(0, 负数)` → 0 分钟 → 永久时效满分)、
63
+ * 不可解析日期(`interpolate(NaN)` 走完循环返回最后一个锚点 → 静默得 1 分)。
64
+ * 两者现在都得 0 分并打 flag —— 「不知道」必须看得见。
65
+ */
66
+ /* ============================================================================
67
+ * 版本号
68
+ * ========================================================================== */
69
+ /** 打分逻辑的版本。改了 `scoreFeatures` 的语义就要升。 */
70
+ export const SCORER_VERSION = "signal-score/2.0.0";
71
+ /**
72
+ * 特征提取的版本。改了 `extractFeatures` 就要升 —— 升了会让 `signal_mention_features`
73
+ * 的整个键空间失效,这正是想要的:旧特征不能拿来喂新打分器。
74
+ */
75
+ export const EXTRACTOR_VERSION = "signal-features/2.0.0";
76
+ /* ============================================================================
77
+ * 0.6.1 的显示标签 —— UI 文案是产品资产,不能在移植中蒸发
78
+ * ========================================================================== */
79
+ export const CATEGORY_LABELS = {
80
+ market: "市場行情",
81
+ regulation: "監管政策",
82
+ security: "安全風險",
83
+ exchange: "交易平台",
84
+ product: "產品技術",
85
+ funding: "公司投融資",
86
+ industry: "一般產業",
87
+ unclassified: "未分類",
88
+ };
89
+ export const INFORMATION_TYPE_LABELS = {
90
+ macro_policy: "宏觀與政策",
91
+ equities_corporate: "股票與公司",
92
+ rates_credit: "利率與信用",
93
+ fx: "外匯",
94
+ commodities: "商品",
95
+ flows_positioning: "資金流與倉位",
96
+ crypto: "Crypto",
97
+ sentiment_hot: "輿情熱點",
98
+ unclassified: "未分類",
99
+ };
100
+ export const BAND_LABELS = {
101
+ priority: "高優事件",
102
+ today: "今日關注",
103
+ standard: "全部事件",
104
+ };
105
+ const ASCII_ONLY = /^[\x20-\x7e]+$/;
106
+ const ASCII_WORD = /[a-z0-9]/i;
107
+ function escapeRegExp(value) {
108
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
109
+ }
110
+ function newNode() {
111
+ return { next: new Map(), entryIndex: -1 };
112
+ }
113
+ /**
114
+ * 把 profile 的全部词表编译成一棵 trie。
115
+ *
116
+ * 一个词条可以同时属于多个集合(`sec` 既是 regulationEvidence 也是 macroBreadth),
117
+ * 所以按 term 去重后把 set 名收进同一条 entry —— 这样 trie 里每个终结点只对应一条
118
+ * entry,最长匹配就是纯几何判定。
119
+ *
120
+ * 诱饵词最后加,且只在该 term 尚未作为真词存在时才加:把「securities and exchange
121
+ * commission」写成诱饵会连 `sec` 一起吃掉,那不是遮蔽是失明。
122
+ */
123
+ export function compileLexicon(profile) {
124
+ const byTerm = new Map();
125
+ const put = (rawTerm, set) => {
126
+ const term = rawTerm.toLowerCase();
127
+ if (!term)
128
+ return;
129
+ let entry = byTerm.get(term);
130
+ if (!entry) {
131
+ entry = { sets: [], term, ascii: ASCII_ONLY.test(term) };
132
+ byTerm.set(term, entry);
133
+ }
134
+ if (set && !entry.sets.includes(set))
135
+ entry.sets.push(set);
136
+ };
137
+ for (const [set, terms] of Object.entries(profile.lexicons)) {
138
+ for (const term of terms)
139
+ put(term, set);
140
+ }
141
+ for (const asset of profile.watchedAssets) {
142
+ for (const term of asset.terms)
143
+ put(term, watchedAssetSet(asset.name));
144
+ }
145
+ for (const decoy of profile.decoys) {
146
+ if (!byTerm.has(decoy.toLowerCase()))
147
+ put(decoy, null);
148
+ }
149
+ const entries = [...byTerm.values()];
150
+ const root = newNode();
151
+ entries.forEach((entry, index) => {
152
+ let node = root;
153
+ for (const char of entry.term) {
154
+ let next = node.next.get(char);
155
+ if (!next) {
156
+ next = newNode();
157
+ node.next.set(char, next);
158
+ }
159
+ node = next;
160
+ }
161
+ node.entryIndex = index;
162
+ });
163
+ const proximity = profile.proximity.map((rule) => ({
164
+ set: rule.set,
165
+ regex: new RegExp(`(?:${rule.left.map(escapeRegExp).join("|")})[\\s\\S]{0,${rule.maxGapChars}}?(?:${rule.right
166
+ .map(escapeRegExp)
167
+ .join("|")})`, "g"),
168
+ }));
169
+ const casePatterns = profile.casePatterns.map((pattern) => ({
170
+ set: pattern.set,
171
+ regex: new RegExp(pattern.pattern, `${pattern.flags ?? ""}g`),
172
+ }));
173
+ return { root, entries, proximity, casePatterns, profileVersion: profile.profileVersion };
174
+ }
175
+ /** 合成集合名。`watchedAsset:Bitcoin` 这种,避免和运营配置的集合名撞车。 */
176
+ export function watchedAssetSet(name) {
177
+ return `watchedAsset:${name}`;
178
+ }
179
+ /**
180
+ * 一次扫描,每个起点取最长匹配,再丢掉被更长匹配严格包含的命中。
181
+ *
182
+ * 为什么这样就够:把「比特幣現金 / 以太坊經典 / 清算所 / ripple effect / ethernet」
183
+ * 和真词放进同一棵 trie 之后,遮蔽变成纯几何判定 —— 确定性、可单测、零外部依赖、
184
+ * O(n·Lmax)。`Intl.Segmenter` 的失败模式是「workerd 某次更新换了 ICU 数据集」,
185
+ * 而这里的失败模式是「诱饵表少一行」,后者能靠加一行数据修。
186
+ *
187
+ * ASCII 词条额外做 `[a-z0-9]` 边界(0.6.1 的 `hasAny` 本来就有这一半,只是它对
188
+ * 中文完全失效)。注意:边界不通过时**不回退到更短的匹配** —— "ethers" 不该退化成
189
+ * "eth"。
190
+ */
191
+ export function matchLexicon(text, lexicon, titleLength) {
192
+ const lower = text.toLowerCase();
193
+ const raw = [];
194
+ for (let i = 0; i < lower.length; i++) {
195
+ let node = lexicon.root;
196
+ let bestEntry = -1;
197
+ let bestEnd = -1;
198
+ for (let j = i; j < lower.length && node; j++) {
199
+ node = node.next.get(lower[j]);
200
+ if (!node)
201
+ break;
202
+ if (node.entryIndex >= 0) {
203
+ bestEntry = node.entryIndex;
204
+ bestEnd = j + 1;
205
+ }
206
+ }
207
+ if (bestEntry < 0)
208
+ continue;
209
+ const entry = lexicon.entries[bestEntry];
210
+ if (entry.ascii) {
211
+ const before = i > 0 ? lower[i - 1] : "";
212
+ const after = bestEnd < lower.length ? lower[bestEnd] : "";
213
+ if ((before && ASCII_WORD.test(before)) || (after && ASCII_WORD.test(after)))
214
+ continue;
215
+ }
216
+ raw.push({ index: bestEntry, start: i, end: bestEnd });
217
+ }
218
+ const kept = raw.filter((hit) => !raw.some((other) => other !== hit &&
219
+ other.start <= hit.start &&
220
+ other.end >= hit.end &&
221
+ other.end - other.start > hit.end - hit.start));
222
+ const out = [];
223
+ for (const hit of kept) {
224
+ const entry = lexicon.entries[hit.index];
225
+ for (const set of entry.sets) {
226
+ out.push({
227
+ set,
228
+ term: entry.term,
229
+ start: hit.start,
230
+ end: hit.end,
231
+ inTitle: hit.start < titleLength,
232
+ });
233
+ }
234
+ }
235
+ // 邻近规则跑在小写文本上;大小写敏感规则跑在原文上(HYPE vs hype)。
236
+ // 两者都自带边界,不参与上面的遮蔽 —— 它们是短语级证据,不是词条。
237
+ for (const rule of lexicon.proximity) {
238
+ rule.regex.lastIndex = 0;
239
+ for (let m = rule.regex.exec(lower); m; m = rule.regex.exec(lower)) {
240
+ out.push({
241
+ set: rule.set,
242
+ term: m[0],
243
+ start: m.index,
244
+ end: m.index + m[0].length,
245
+ inTitle: m.index < titleLength,
246
+ });
247
+ if (m.index === rule.regex.lastIndex)
248
+ rule.regex.lastIndex++;
249
+ }
250
+ }
251
+ for (const rule of lexicon.casePatterns) {
252
+ rule.regex.lastIndex = 0;
253
+ for (let m = rule.regex.exec(text); m; m = rule.regex.exec(text)) {
254
+ out.push({
255
+ set: rule.set,
256
+ term: m[0],
257
+ start: m.index,
258
+ end: m.index + m[0].length,
259
+ inTitle: m.index < titleLength,
260
+ });
261
+ if (m.index === rule.regex.lastIndex)
262
+ rule.regex.lastIndex++;
263
+ }
264
+ }
265
+ return out;
266
+ }
267
+ /* ============================================================================
268
+ * 数值工具(0.6.1 逐字保留)
269
+ * ========================================================================== */
270
+ /** 一位小数 + 上下限。0.6.1 的显示契约,改了会让全部历史分数对不上。 */
271
+ export function clampScore(value, maximum) {
272
+ if (!Number.isFinite(value))
273
+ return 0;
274
+ return Math.max(0, Math.min(maximum, Math.round(value * 10) / 10));
275
+ }
276
+ /** 分段线性插值。非有限输入返回最后一个锚点(与 0.6.1 一致,但调用点已不再喂 NaN)。 */
277
+ export function interpolate(value, anchors) {
278
+ if (!Number.isFinite(value))
279
+ return anchors[anchors.length - 1][1];
280
+ if (value <= anchors[0][0])
281
+ return anchors[0][1];
282
+ for (let i = 1; i < anchors.length; i++) {
283
+ const [leftX, leftY] = anchors[i - 1];
284
+ const [rightX, rightY] = anchors[i];
285
+ if (value <= rightX)
286
+ return leftY + ((value - leftX) / (rightX - leftX)) * (rightY - leftY);
287
+ }
288
+ return anchors[anchors.length - 1][1];
289
+ }
290
+ /* ============================================================================
291
+ * 百分比 → 行情(修缺陷 4)
292
+ * ========================================================================== */
293
+ function buildAttachmentRegexes(profile) {
294
+ const cfg = profile.marketReaction;
295
+ const verbs = cfg.priceVerbs.map(escapeRegExp).join("|");
296
+ const nouns = cfg.priceNouns.map(escapeRegExp).join("|");
297
+ const pct = "\\d+(?:\\.\\d+)?\\s*%";
298
+ const gap = `[^。.;;\\n]{0,${cfg.attachmentWindowChars}}`;
299
+ return [
300
+ new RegExp(`(?:${verbs})${gap}${pct}`, "i"),
301
+ new RegExp(`${pct}[^。.;;\\n]{0,12}(?:${nouns})`, "i"),
302
+ new RegExp(`${pct}[^。.;;\\n]{0,12}(?:${verbs})`, "i"),
303
+ ];
304
+ }
305
+ const ASSET_SETS = ["coreAssets", "watchedCrypto", "watchedEquity", "majorMarket"];
306
+ /**
307
+ * 从正文里抽「这是一次价格波动」的百分比。
308
+ *
309
+ * 三道闸门,缺一不可:
310
+ * 1. **排除表**(`share of` / `dominance` / 市占率 / 占比 / 营收 / 同比 …)在窗口内
311
+ * 出现即否决。这一道用 trie 命中做,而不是 `String.includes` —— 否则排除表自己
312
+ * 就会重蹈缺陷 1 的子串匹配。
313
+ * 2. **句法附着**:百分比必须和一个价格动词/名词在同一子句里。0.6.1 的 ±80 字符
314
+ * 共现窗口只表达「附近有个行情词」,不表达「这个百分比的主语是它」。
315
+ * 3. **幅度上限**:核心资产 >40%、其它 >80% 判为解析错误。
316
+ * 「up 12000% over the past decade」是十年涨幅,不是今天的行情。
317
+ *
318
+ * 被否决的百分比仍然写进 `percentMoves` 并带 `rejectedReason` —— 「为什么这条没分」
319
+ * 必须有答案,否则调参的人只能靠猜。
320
+ */
321
+ export function extractPercentMoves(text, hits, profile) {
322
+ const cfg = profile.marketReaction;
323
+ const lower = text.toLowerCase();
324
+ const out = [];
325
+ const attachment = buildAttachmentRegexes(profile);
326
+ const assetHits = hits.filter((hit) => ASSET_SETS.includes(hit.set));
327
+ const exclusionHits = hits.filter((hit) => hit.set === cfg.exclusionSet);
328
+ const pushRejected = (value, core, start, end, reason) => out.push({ valuePct: value, isCoreAsset: core, start, end, origin: "text", rejectedReason: reason });
329
+ const re = /(\d+(?:\.\d+)?)\s*%/g;
330
+ for (let m = re.exec(lower); m; m = re.exec(lower)) {
331
+ const start = m.index;
332
+ const end = start + m[0].length;
333
+ const value = Number(m[1]);
334
+ const windowStart = Math.max(0, start - cfg.attachmentWindowChars);
335
+ const windowEnd = Math.min(lower.length, end + cfg.attachmentWindowChars);
336
+ const near = lower.slice(windowStart, windowEnd);
337
+ if (exclusionHits.some((hit) => hit.start < windowEnd && hit.end > windowStart)) {
338
+ pushRejected(value, false, start, end, "non_reaction_subject");
339
+ continue;
340
+ }
341
+ if (!attachment.some((rx) => rx.test(near))) {
342
+ pushRejected(value, false, start, end, "no_price_attachment");
343
+ continue;
344
+ }
345
+ const asset = assetHits.find((hit) => Math.abs(hit.start - start) <= cfg.attachmentWindowChars * 2);
346
+ if (!asset) {
347
+ pushRejected(value, false, start, end, "no_asset_in_window");
348
+ continue;
349
+ }
350
+ const isCore = asset.set === "coreAssets";
351
+ const ceiling = isCore ? cfg.maxPlausibleMovePctCore : cfg.maxPlausibleMovePctOther;
352
+ if (value > ceiling) {
353
+ pushRejected(value, isCore, start, end, "implausible_magnitude");
354
+ continue;
355
+ }
356
+ out.push({ valuePct: value, isCoreAsset: isCore, start, end, origin: "text" });
357
+ }
358
+ return out;
359
+ }
360
+ /* ============================================================================
361
+ * 第一段:特征提取(贵的那半)
362
+ * ========================================================================== */
363
+ export function extractFeatures(input, profile, lexicon) {
364
+ const title = input.title ?? "";
365
+ // 0.6.1 在打分前就抹掉 @handle 与 URL,保留这一步:一条推文里的 @binance
366
+ // 不是「这条新闻讲币安」,而 URL 里的 `bitcoin.org` 更不是。
367
+ const text = `${title}\n${input.body ?? ""}`
368
+ .replace(/@[a-z0-9_]+/gi, " ")
369
+ .replace(/https?:\/\/\S+/g, " ");
370
+ const hits = matchLexicon(text, lexicon, title.length + 1);
371
+ const setsPresent = {};
372
+ for (const hit of hits)
373
+ setsPresent[hit.set] = true;
374
+ const nowMs = Date.parse(input.nowAt);
375
+ const publishedMs = input.publishedAt ? Date.parse(input.publishedAt) : Number.NaN;
376
+ const invalidDate = input.publishedAt != null && !Number.isFinite(publishedMs);
377
+ const rawAgeMinutes = Number.isFinite(publishedMs) ? (nowMs - publishedMs) / 60_000 : Number.NaN;
378
+ const futureDated = Number.isFinite(rawAgeMinutes) && rawAgeMinutes < -profile.freshness.futureToleranceMinutes;
379
+ // 结构化行情优先(docB B-B-04)。文本抽取只是 fallback —— 真正重要的行情本来就
380
+ // 应该来自交易所 API 而不是新闻正文。
381
+ let percentMoves;
382
+ let moveOrigin = "none";
383
+ if (input.structuredMoves.length > 0) {
384
+ moveOrigin = "structured";
385
+ percentMoves = input.structuredMoves.map((move) => ({
386
+ valuePct: Math.abs(move.changePct),
387
+ isCoreAsset: move.isCoreAsset,
388
+ start: -1,
389
+ end: -1,
390
+ origin: "structured",
391
+ }));
392
+ }
393
+ else {
394
+ percentMoves = extractPercentMoves(text, hits, profile);
395
+ if (percentMoves.some((move) => !move.rejectedReason))
396
+ moveOrigin = "text";
397
+ }
398
+ const largest = percentMoves
399
+ .filter((move) => !move.rejectedReason)
400
+ .reduce((best, move) => (!best || move.valuePct > best.valuePct ? move : best), null);
401
+ const watchedAssets = profile.watchedAssets
402
+ .filter((asset) => setsPresent[watchedAssetSet(asset.name)])
403
+ .map((asset) => asset.name);
404
+ return {
405
+ extractorVersion: EXTRACTOR_VERSION,
406
+ termsVersion: input.termsVersion,
407
+ hits,
408
+ setsPresent,
409
+ percentMoves,
410
+ largestMovePct: largest?.valuePct ?? 0,
411
+ largestMoveIsCore: largest?.isCoreAsset ?? false,
412
+ moveOrigin,
413
+ structuredMoves: input.structuredMoves,
414
+ ageMinutes: Number.isFinite(rawAgeMinutes) ? Math.max(0, rawAgeMinutes) : null,
415
+ futureDated,
416
+ invalidDate,
417
+ distinctPublishers: Math.max(1, input.corroboration.distinctPublishers),
418
+ sourceTier: input.source.tier,
419
+ sourcePriorityWeight: input.source.priorityWeight,
420
+ sourceIsUserSupplied: input.source.isUserSupplied,
421
+ brandHits: input.brandHits,
422
+ watchedAssets,
423
+ isRumor: Boolean(setsPresent["rumor"]),
424
+ isDenied: Boolean(setsPresent["denial"]),
425
+ isRetrospective: Boolean(setsPresent["retrospective"]),
426
+ hasOfficialConfirmation: Boolean(setsPresent["official"]) && !setsPresent["rumor"] && !setsPresent["denial"],
427
+ };
428
+ }
429
+ /** 存库时的瘦身:`hits` 只留证据样本,`scoreFeatures` 根本不读它。 */
430
+ export const MAX_STORED_HITS = 64;
431
+ export function compactForStorage(features) {
432
+ return { ...features, hits: features.hits.slice(0, MAX_STORED_HITS) };
433
+ }
434
+ /* ============================================================================
435
+ * 第二段:打分(纯函数,重算 90 天就靠它)
436
+ * ========================================================================== */
437
+ /**
438
+ * 首个命中胜出 —— 之所以安全,是因为 `assertProfileInvariants()` 强制显式档按取值
439
+ * 降序排列。两条一起才让「首个命中」等价于「argmax」;只有一条的话就是缺陷 2。
440
+ */
441
+ function ladder(rungs, sets) {
442
+ for (const rung of rungs) {
443
+ if (rung.state === "unknown")
444
+ continue;
445
+ if (!rung.anySets && !rung.allSets)
446
+ continue;
447
+ const anyOk = !rung.anySets || rung.anySets.some((set) => sets[set]);
448
+ const allOk = !rung.allSets || rung.allSets.every((set) => sets[set]);
449
+ if (anyOk && allOk)
450
+ return { state: rung.state, value: rung.value };
451
+ }
452
+ const fallback = rungs.find((rung) => rung.state === "unknown");
453
+ return { state: "unknown", value: fallback ? fallback.value : 0 };
454
+ }
455
+ /** 加权 argmax + 多词证据闸门 + 显式 unclassified(修缺陷 2)。 */
456
+ function argmaxCategory(rules, sets, fallback) {
457
+ let slug = fallback;
458
+ let best = 0;
459
+ let second = 0;
460
+ for (const rule of rules) {
461
+ if (rule.requireAnyOf && !rule.requireAnyOf.some((set) => sets[set]))
462
+ continue;
463
+ let score = 0;
464
+ for (const [set, weight] of Object.entries(rule.weights))
465
+ if (sets[set])
466
+ score += weight;
467
+ if (score < rule.minScore)
468
+ continue;
469
+ if (score > best) {
470
+ second = best;
471
+ best = score;
472
+ slug = rule.slug;
473
+ }
474
+ else if (score > second) {
475
+ second = score;
476
+ }
477
+ }
478
+ return { slug, confidence: best === 0 ? 0 : Math.min(1, (best - second) / best) };
479
+ }
480
+ export function scoreFeatures(features, profile) {
481
+ const contributions = [];
482
+ const flags = [];
483
+ if (features.futureDated)
484
+ flags.push("future_dated");
485
+ if (features.invalidDate)
486
+ flags.push("invalid_published_at");
487
+ if (features.ageMinutes == null && !features.invalidDate)
488
+ flags.push("no_published_at");
489
+ if (features.moveOrigin === "text")
490
+ flags.push("reaction_from_text");
491
+ if (features.moveOrigin === "structured")
492
+ flags.push("reaction_from_structured");
493
+ for (const move of features.percentMoves) {
494
+ if (move.rejectedReason)
495
+ flags.push(`pct_rejected:${move.rejectedReason}`);
496
+ }
497
+ /* --- 1. 来源可信度 /25 ------------------------------------------------- */
498
+ const sr = profile.sourceReliability;
499
+ const baseline = sr.baselineIntercept + (features.sourcePriorityWeight - sr.baselinePivot) * sr.baselineSlope;
500
+ contributions.push({
501
+ feature: "source.baseline",
502
+ dimension: "sourceReliability",
503
+ points: baseline,
504
+ });
505
+ let corroboration = 0;
506
+ for (const [publishers, bonus] of sr.corroborationBonus) {
507
+ if (features.distinctPublishers >= publishers) {
508
+ corroboration = bonus;
509
+ break;
510
+ }
511
+ }
512
+ if (corroboration) {
513
+ contributions.push({
514
+ feature: `source.corroboration:${features.distinctPublishers}`,
515
+ dimension: "sourceReliability",
516
+ points: corroboration,
517
+ });
518
+ }
519
+ const official = features.hasOfficialConfirmation ? sr.officialBonus : 0;
520
+ if (official) {
521
+ contributions.push({
522
+ feature: "source.official",
523
+ dimension: "sourceReliability",
524
+ points: official,
525
+ });
526
+ }
527
+ const sourceReliability = clampScore(baseline + corroboration + official, profile.caps.sourceReliability);
528
+ /* --- 2. 市场影响 /35 --------------------------------------------------- */
529
+ const mi = profile.marketImpact;
530
+ const rungs = {
531
+ severity: ladder(mi.ladders.severity, features.setsPresent),
532
+ assetScale: ladder(mi.ladders.assetScale, features.setsPresent),
533
+ breadth: ladder(mi.ladders.breadth, features.setsPresent),
534
+ immediacy: ladder(mi.ladders.immediacy, features.setsPresent),
535
+ };
536
+ const claimMultiplier = features.isDenied
537
+ ? mi.claimMultiplier.denied
538
+ : features.isRumor
539
+ ? mi.claimMultiplier.rumor
540
+ : mi.claimMultiplier.normal;
541
+ const timeMultiplier = features.isRetrospective
542
+ ? mi.timeMultiplier.retrospective
543
+ : mi.timeMultiplier.normal;
544
+ // 归因必须能加回总分:先记未乘系数的各阶梯,再把两个乘数各记成一笔调整。
545
+ // 设计稿里那版把系数同时乘进阶梯**又**单独记一笔,归因和是错的。
546
+ let rawImpact = 0;
547
+ for (const key of Object.keys(rungs)) {
548
+ const points = rungs[key].value * mi.weights[key];
549
+ rawImpact += points;
550
+ contributions.push({
551
+ feature: `impact.${key}:${rungs[key].state}`,
552
+ dimension: "marketImpact",
553
+ points,
554
+ });
555
+ }
556
+ if (claimMultiplier !== 1) {
557
+ contributions.push({
558
+ feature: features.isDenied ? "impact.denied" : "impact.rumor",
559
+ dimension: "marketImpact",
560
+ points: rawImpact * (claimMultiplier - 1),
561
+ });
562
+ }
563
+ if (timeMultiplier !== 1) {
564
+ contributions.push({
565
+ feature: "impact.retrospective",
566
+ dimension: "marketImpact",
567
+ points: rawImpact * claimMultiplier * (timeMultiplier - 1),
568
+ });
569
+ }
570
+ const marketImpact = clampScore(rawImpact * claimMultiplier * timeMultiplier, profile.caps.marketImpact);
571
+ /* --- 3. 市场反应 /10 --------------------------------------------------- */
572
+ const mr = profile.marketReaction;
573
+ const reactionScale = mr.postScaleFactor * claimMultiplier * timeMultiplier;
574
+ let reactionRaw = 0;
575
+ if (features.largestMovePct > 0) {
576
+ const points = interpolate(features.largestMovePct, features.largestMoveIsCore ? mr.anchorsMajor : mr.anchorsMinor);
577
+ reactionRaw += points;
578
+ contributions.push({
579
+ feature: `reaction.move:${features.largestMovePct}%:${features.moveOrigin}`,
580
+ dimension: "marketReaction",
581
+ points: points * reactionScale,
582
+ });
583
+ }
584
+ const hasVolume = Boolean(features.setsPresent["volumeSignal"]);
585
+ const hasLiquidation = Boolean(features.setsPresent["liquidationSignal"]);
586
+ if (hasVolume) {
587
+ reactionRaw += mr.bonusVolume;
588
+ contributions.push({
589
+ feature: "reaction.volume",
590
+ dimension: "marketReaction",
591
+ points: mr.bonusVolume * reactionScale,
592
+ });
593
+ }
594
+ if (hasLiquidation) {
595
+ reactionRaw += mr.bonusLiquidation;
596
+ contributions.push({
597
+ feature: "reaction.liquidation",
598
+ dimension: "marketReaction",
599
+ points: mr.bonusLiquidation * reactionScale,
600
+ });
601
+ }
602
+ if (hasVolume && hasLiquidation && features.largestMovePct > 0) {
603
+ reactionRaw += mr.bonusBoth;
604
+ contributions.push({
605
+ feature: "reaction.both",
606
+ dimension: "marketReaction",
607
+ points: mr.bonusBoth * reactionScale,
608
+ });
609
+ }
610
+ if (features.largestMovePct === 0 && features.setsPresent["reactionDirection"]) {
611
+ reactionRaw += mr.bonusDirectionOnly;
612
+ contributions.push({
613
+ feature: "reaction.direction_only",
614
+ dimension: "marketReaction",
615
+ points: mr.bonusDirectionOnly * reactionScale,
616
+ });
617
+ }
618
+ const marketReaction = clampScore(reactionRaw * reactionScale, profile.caps.marketReaction);
619
+ /* --- 4. 时效 /15 ------------------------------------------------------- */
620
+ // 0.6.1:未来时间戳经 `Math.max(0, 负数)` 变成 0 分钟,于是永久占满分;
621
+ // 不可解析日期喂进 `interpolate(NaN)` 走完循环返回最后一个锚点,于是静默得 1 分。
622
+ // 两者现在都是 0 分 + flag。
623
+ const freshness = features.ageMinutes == null || features.futureDated || features.invalidDate
624
+ ? 0
625
+ : clampScore(interpolate(features.ageMinutes, profile.freshness.anchors), profile.caps.freshness);
626
+ contributions.push({
627
+ feature: `freshness.age:${features.ageMinutes ?? "unknown"}m`,
628
+ dimension: "freshness",
629
+ points: freshness,
630
+ });
631
+ /* --- 5. 受众关联 /15 --------------------------------------------------- */
632
+ const ar = profile.audienceRelevance;
633
+ let audience = 0;
634
+ const addAudience = (feature, points, evidence) => {
635
+ audience += points;
636
+ contributions.push({ feature, dimension: "audienceRelevance", points, evidence });
637
+ };
638
+ if (features.setsPresent["coreAssets"])
639
+ addAudience("audience.core_asset", ar.coreAsset);
640
+ else if (features.setsPresent["watchedCrypto"])
641
+ addAudience("audience.watched_crypto", ar.watchedCrypto);
642
+ else if (features.setsPresent["watchedEquity"])
643
+ addAudience("audience.watched_equity", ar.watchedEquity);
644
+ if (features.setsPresent["watchedCompanyEvent"])
645
+ addAudience("audience.company_event", ar.watchedCompanyEvent);
646
+ if (features.setsPresent["trader"])
647
+ addAudience("audience.trader", ar.trader);
648
+ if (features.setsPresent["systemic"])
649
+ addAudience("audience.systemic", ar.systemic);
650
+ if (features.setsPresent["education"])
651
+ addAudience("audience.education", ar.education);
652
+ // 修缺陷 3:品牌只能经 gazetteer 的 BrandHit 进来,贡献与其它重点实体同量级,
653
+ // 并且用户自填源乘 0 —— 关掉「往 description 注入 Tapbit 就能把自己顶上全团队看板」
654
+ // 那条提权路径。
655
+ const brandFactor = features.sourceIsUserSupplied ? ar.userSuppliedBrandContribution : 1;
656
+ for (const hit of features.brandHits) {
657
+ if (!hit.isOwnBrand)
658
+ continue;
659
+ const base = hit.inTitle
660
+ ? ar.brandTitleHit
661
+ : hit.relevancePrior === "core"
662
+ ? ar.brandCoreHit
663
+ : ar.brandPassingHit;
664
+ const points = base * brandFactor;
665
+ if (points > 0) {
666
+ addAudience(`audience.brand:${hit.brandId}:${hit.inTitle ? "title" : hit.relevancePrior}`, points, `${hit.charStart}-${hit.charEnd}`);
667
+ }
668
+ else if (features.sourceIsUserSupplied &&
669
+ !flags.includes("brand_hit_suppressed_user_source")) {
670
+ flags.push("brand_hit_suppressed_user_source");
671
+ }
672
+ }
673
+ const audienceRelevance = clampScore(audience, profile.caps.audienceRelevance);
674
+ /* --- 汇总 -------------------------------------------------------------- */
675
+ const dimensions = {
676
+ sourceReliability,
677
+ marketImpact,
678
+ marketReaction,
679
+ freshness,
680
+ audienceRelevance,
681
+ };
682
+ const total = clampScore(sourceReliability + marketImpact + marketReaction + freshness + audienceRelevance, 100);
683
+ const category = argmaxCategory(profile.categories, features.setsPresent, "unclassified");
684
+ const informationType = argmaxCategory(profile.informationTypes, features.setsPresent, "unclassified");
685
+ const band = total >= profile.bands.priority
686
+ ? "priority"
687
+ : total >= profile.bands.today &&
688
+ features.ageMinutes != null &&
689
+ features.ageMinutes <= profile.bands.todayWithinMinutes
690
+ ? "today"
691
+ : "standard";
692
+ const criticalRecallBypass = features.sourceTier <= profile.criticalRecall.maxSourceTier &&
693
+ profile.criticalRecall.sets.some((set) => features.setsPresent[set]);
694
+ // 0.6.1 的第三档:重点资产最近 72 小时的动态,不受最低分数限制。
695
+ const watchlistBypass = features.watchedAssets.length > 0 &&
696
+ features.ageMinutes != null &&
697
+ !features.futureDated &&
698
+ features.ageMinutes <= profile.bands.watchlistWithinMinutes;
699
+ return {
700
+ total,
701
+ dimensions,
702
+ scoreBreakdown: dimensions,
703
+ scoreReasons: [
704
+ `來源 ${sourceReliability}/${profile.caps.sourceReliability}`,
705
+ `影響 ${marketImpact}/${profile.caps.marketImpact}`,
706
+ `反應 ${marketReaction}/${profile.caps.marketReaction}`,
707
+ `時效 ${freshness}/${profile.caps.freshness}`,
708
+ `受眾 ${audienceRelevance}/${profile.caps.audienceRelevance}`,
709
+ ],
710
+ contributions,
711
+ reasons: [
712
+ { code: "dim.source", dimension: "sourceReliability", value: sourceReliability, max: profile.caps.sourceReliability },
713
+ { code: "dim.impact", dimension: "marketImpact", value: marketImpact, max: profile.caps.marketImpact },
714
+ { code: "dim.reaction", dimension: "marketReaction", value: marketReaction, max: profile.caps.marketReaction },
715
+ { code: "dim.freshness", dimension: "freshness", value: freshness, max: profile.caps.freshness },
716
+ { code: "dim.audience", dimension: "audienceRelevance", value: audienceRelevance, max: profile.caps.audienceRelevance },
717
+ ],
718
+ category: category.slug,
719
+ categoryConfidence: category.confidence,
720
+ informationType: informationType.slug,
721
+ informationTypeConfidence: informationType.confidence,
722
+ band,
723
+ criticalRecallBypass,
724
+ watchlistBypass,
725
+ watchedAssets: features.watchedAssets,
726
+ flags,
727
+ profileVersion: profile.profileVersion,
728
+ scorerVersion: SCORER_VERSION,
729
+ };
730
+ }
731
+ /** 两段合一。线上 ingest 走这条;重算走 `scoreFeatures` 单段。 */
732
+ export function scoreItem(input, profile, lexicon) {
733
+ return scoreFeatures(extractFeatures(input, profile, lexicon), profile);
734
+ }
735
+ /* ============================================================================
736
+ * 0.6.1 的三个独立导出(保全)
737
+ * ========================================================================== */
738
+ /** 0.6.1 `classify()` 的替身,但用加权 argmax 而不是首个命中。 */
739
+ export function classifyCategory(text, profile, lexicon) {
740
+ const hits = matchLexicon(text, lexicon, 0);
741
+ const sets = {};
742
+ for (const hit of hits)
743
+ sets[hit.set] = true;
744
+ return argmaxCategory(profile.categories, sets, "unclassified").slug;
745
+ }
746
+ /** 0.6.1 `classifyInformationType()` 的替身。兜底从静默的「Crypto」改成 unclassified。 */
747
+ export function classifyInformationType(text, profile, lexicon) {
748
+ const hits = matchLexicon(text, lexicon, 0);
749
+ const sets = {};
750
+ for (const hit of hits)
751
+ sets[hit.set] = true;
752
+ return argmaxCategory(profile.informationTypes, sets, "unclassified").slug;
753
+ }
754
+ /**
755
+ * 0.6.1 `detectWatchedAssets()` 的替身。
756
+ * 走同一棵 trie,所以「比特幣現金」不再被认成 Bitcoin,而 `HYPE` 仍然靠大小写敏感
757
+ * 的 casePattern 认出 Hyperliquid。
758
+ */
759
+ export function detectWatchedAssets(text, profile, lexicon) {
760
+ const hits = matchLexicon(text, lexicon, 0);
761
+ const sets = new Set(hits.map((hit) => hit.set));
762
+ return profile.watchedAssets
763
+ .filter((asset) => sets.has(watchedAssetSet(asset.name)))
764
+ .map((asset) => asset.name);
765
+ }
766
+ /* ============================================================================
767
+ * 配置层不变量 —— 缺陷 5 唯一能随外置常数一起交付的防线
768
+ * ========================================================================== */
769
+ /**
770
+ * 常数一旦从代码搬进 `signal_score_profiles.config_json`,「加信息反而降分」这类错误
771
+ * 就不再是代码 bug 而是数据 bug,code review 看不见。所以把单调性写成对**配置**的
772
+ * 性质测试,CI 与 profile 载入时各跑一次。运营改 config_json 也回归不了。
773
+ */
774
+ export function assertProfileInvariants(profile) {
775
+ const errors = [];
776
+ const capSum = Object.values(profile.caps).reduce((a, b) => a + b, 0);
777
+ if (Math.abs(capSum - 100) > 1e-9)
778
+ errors.push(`caps must sum to 100, got ${capSum}`);
779
+ if (!(profile.bands.priority > profile.bands.today)) {
780
+ errors.push(`bands.priority(${profile.bands.priority}) must exceed bands.today(${profile.bands.today})`);
781
+ }
782
+ for (const [key, rungs] of Object.entries(profile.marketImpact.ladders)) {
783
+ const explicit = rungs.filter((rung) => rung.state !== "unknown");
784
+ const unknown = rungs.find((rung) => rung.state === "unknown");
785
+ if (!unknown) {
786
+ errors.push(`ladder ${key} missing unknown rung`);
787
+ }
788
+ else {
789
+ const weakest = Math.min(...explicit.map((rung) => rung.value));
790
+ if (unknown.value > weakest) {
791
+ errors.push(`ladder ${key}: unknown(${unknown.value}) > weakest explicit(${weakest}) — 非单调,加信息会降分`);
792
+ }
793
+ }
794
+ for (let i = 1; i < explicit.length; i++) {
795
+ if (explicit[i].value > explicit[i - 1].value) {
796
+ errors.push(`ladder ${key}: explicit rungs must be sorted by value DESC (${explicit[i - 1].state} < ${explicit[i].state}) — 否则首个命中不等于 argmax`);
797
+ }
798
+ }
799
+ if (rungs[rungs.length - 1]?.state !== "unknown") {
800
+ errors.push(`ladder ${key}: unknown rung must be last`);
801
+ }
802
+ }
803
+ const strictlyIncreasing = (name, anchors) => {
804
+ if (anchors.length < 2)
805
+ errors.push(`${name}: needs at least two anchors`);
806
+ for (let i = 1; i < anchors.length; i++) {
807
+ if (anchors[i][0] <= anchors[i - 1][0]) {
808
+ errors.push(`${name}: anchors x must strictly increase at index ${i}`);
809
+ }
810
+ }
811
+ };
812
+ strictlyIncreasing("freshness", profile.freshness.anchors);
813
+ strictlyIncreasing("reaction.major", profile.marketReaction.anchorsMajor);
814
+ strictlyIncreasing("reaction.minor", profile.marketReaction.anchorsMinor);
815
+ for (let i = 1; i < profile.freshness.anchors.length; i++) {
816
+ if (profile.freshness.anchors[i][1] > profile.freshness.anchors[i - 1][1]) {
817
+ errors.push(`freshness must be non-increasing at index ${i} — 越旧越值钱是反的`);
818
+ }
819
+ }
820
+ const corroboration = profile.sourceReliability.corroborationBonus;
821
+ for (let i = 1; i < corroboration.length; i++) {
822
+ if (corroboration[i][0] >= corroboration[i - 1][0]) {
823
+ errors.push("corroborationBonus must be sorted by publishers DESC");
824
+ }
825
+ }
826
+ const known = new Set(Object.keys(profile.lexicons));
827
+ for (const asset of profile.watchedAssets)
828
+ known.add(watchedAssetSet(asset.name));
829
+ for (const rule of profile.proximity)
830
+ known.add(rule.set);
831
+ for (const pattern of profile.casePatterns)
832
+ known.add(pattern.set);
833
+ const referenced = new Set();
834
+ for (const rungs of Object.values(profile.marketImpact.ladders)) {
835
+ for (const rung of rungs) {
836
+ (rung.anySets ?? []).forEach((set) => referenced.add(set));
837
+ (rung.allSets ?? []).forEach((set) => referenced.add(set));
838
+ }
839
+ }
840
+ for (const rule of [...profile.categories, ...profile.informationTypes]) {
841
+ Object.keys(rule.weights).forEach((set) => referenced.add(set));
842
+ (rule.requireAnyOf ?? []).forEach((set) => referenced.add(set));
843
+ }
844
+ profile.criticalRecall.sets.forEach((set) => referenced.add(set));
845
+ referenced.add(profile.marketReaction.exclusionSet);
846
+ for (const set of referenced) {
847
+ if (!known.has(set))
848
+ errors.push(`unknown lexicon set referenced: ${set}`);
849
+ }
850
+ // 上限必须够得着,否则那个数字是装饰品。
851
+ const rawMax = Object.keys(profile.marketImpact.ladders).reduce((sum, key) => sum +
852
+ Math.max(...profile.marketImpact.ladders[key].map((rung) => rung.value)) *
853
+ profile.marketImpact.weights[key], 0);
854
+ if (rawMax + 1e-9 < profile.caps.marketImpact) {
855
+ errors.push(`marketImpact raw max ${rawMax.toFixed(2)} < cap ${profile.caps.marketImpact} — 上限不可达`);
856
+ }
857
+ for (const pattern of profile.casePatterns) {
858
+ try {
859
+ new RegExp(pattern.pattern, pattern.flags ?? "");
860
+ }
861
+ catch (error) {
862
+ errors.push(`casePattern /${pattern.pattern}/ does not compile: ${String(error)}`);
863
+ }
864
+ }
865
+ const assetNames = new Set();
866
+ for (const asset of profile.watchedAssets) {
867
+ if (assetNames.has(asset.name))
868
+ errors.push(`duplicate watched asset: ${asset.name}`);
869
+ assetNames.add(asset.name);
870
+ if (asset.terms.length === 0)
871
+ errors.push(`watched asset ${asset.name} has no terms`);
872
+ }
873
+ if (profile.audienceRelevance.userSuppliedBrandContribution !== 0) {
874
+ // 不是硬错误(业务可能某天决定给一点点),但必须显式记在 lint 里。
875
+ errors.push("audienceRelevance.userSuppliedBrandContribution must be 0 — 非 0 会重新打开「往个人 RSS 的 description 注入品牌名即可置顶」的提权路径");
876
+ }
877
+ if (errors.length > 0) {
878
+ throw new Error(`[signal-score] profile ${profile.profileVersion} invalid:\n - ${errors.join("\n - ")}`);
879
+ }
880
+ }
881
+ /* ============================================================================
882
+ * sd-compat-1 —— 0.6.1 常数的逐字外置
883
+ * ========================================================================== */
884
+ /**
885
+ * 「compat」是字面意思:这一份的取值就是 0.6.1 `intelligence.ts` 里那些魔数,
886
+ * 一个都没调。目的是让新旧两套的分数可比,**然后**再用影子档做 A/B。
887
+ * 先改常数再上线,等于把「常数零依据」这个病根原样搬到服务端。
888
+ *
889
+ * 运行时的真相在 `signal_score_profiles.config_json`;这里的常量只做两件事:
890
+ * 迁移 0004 的 seed,以及 D1 里一行 active 都没有时的兜底(兜底也会跑不变量)。
891
+ */
892
+ export const SD_COMPAT_1 = {
893
+ profileVersion: "sd-compat-1",
894
+ caps: {
895
+ sourceReliability: 25,
896
+ marketImpact: 35,
897
+ marketReaction: 10,
898
+ freshness: 15,
899
+ audienceRelevance: 15,
900
+ },
901
+ bands: {
902
+ priority: 75,
903
+ today: 60,
904
+ todayWithinMinutes: 1440,
905
+ watchlistWithinMinutes: 4320,
906
+ },
907
+ // 只遮蔽、不计分。每一条都对应一次已复现的误命中。
908
+ decoys: [
909
+ "清算所",
910
+ "結算所",
911
+ "结算所",
912
+ "清算中心",
913
+ "清算機構",
914
+ "清算机构",
915
+ "ripple effect",
916
+ "ripple effects",
917
+ "漣漪效應",
918
+ "涟漪效应",
919
+ "ethernet",
920
+ "etherscan",
921
+ "aether",
922
+ ],
923
+ lexicons: {
924
+ coreAssets: ["bitcoin", "btc", "比特币", "比特幣", "ethereum", "eth", "ether", "以太坊"],
925
+ watchedCrypto: [
926
+ "usd coin",
927
+ "usdc",
928
+ "美元币",
929
+ "美元幣",
930
+ "hyperliquid",
931
+ "$hype",
932
+ "xrp",
933
+ "ripple",
934
+ "ripple labs",
935
+ "瑞波",
936
+ "瑞波币",
937
+ "瑞波幣",
938
+ "solana",
939
+ "$sol",
940
+ ],
941
+ watchedEquity: [
942
+ "nvidia",
943
+ "nvda",
944
+ "英伟达",
945
+ "英偉達",
946
+ "辉达",
947
+ "輝達",
948
+ "sandisk",
949
+ "sndk",
950
+ "闪迪",
951
+ "閃迪",
952
+ "samsung electronics",
953
+ "005930",
954
+ "三星电子",
955
+ "三星電子",
956
+ "sk hynix",
957
+ "000660",
958
+ "海力士",
959
+ ],
960
+ majorMarket: [
961
+ "solana",
962
+ "xrp",
963
+ "stablecoin",
964
+ "binance",
965
+ "coinbase",
966
+ "okx",
967
+ "bybit",
968
+ "bitget",
969
+ "kraken",
970
+ "稳定币",
971
+ "穩定幣",
972
+ ],
973
+ sector: [
974
+ "defi",
975
+ "nft",
976
+ "memecoin",
977
+ "altcoin",
978
+ "layer 2",
979
+ "protocol",
980
+ "token",
981
+ "security token",
982
+ // 与核心资产同前缀的近亲币:放进 sector 既保住「这是个行业故事」的信号,
983
+ // 又靠最长匹配挡住「比特幣現金 → Bitcoin」。
984
+ "比特幣現金",
985
+ "比特币现金",
986
+ "bitcoin cash",
987
+ "以太坊經典",
988
+ "以太坊经典",
989
+ "ethereum classic",
990
+ ],
991
+ cryptoGeneric: ["crypto", "blockchain", "web3", "加密货币", "加密貨幣", "區塊鏈", "区块链"],
992
+ partnership: ["partnership", "合作", "分析"],
993
+ education: ["guide", "explainer", "what is", "how to", "analysis", "opinion", "report"],
994
+ urgentImpact: [
995
+ "approval",
996
+ "approved",
997
+ "rejected",
998
+ "lawsuit",
999
+ "settlement",
1000
+ "bankruptcy",
1001
+ "insolvency",
1002
+ "shutdown",
1003
+ "suspended",
1004
+ "emergency",
1005
+ ],
1006
+ reactionDirection: [
1007
+ "rally",
1008
+ "surge",
1009
+ "plunge",
1010
+ "soar",
1011
+ "slump",
1012
+ "spike",
1013
+ "sell-off",
1014
+ "上漲",
1015
+ "上涨",
1016
+ "下跌",
1017
+ "暴漲",
1018
+ "暴涨",
1019
+ "暴跌",
1020
+ ],
1021
+ trader: [
1022
+ "trader",
1023
+ "exchange",
1024
+ "listing",
1025
+ "listed",
1026
+ "delist",
1027
+ "liquidation",
1028
+ "deposit",
1029
+ "withdrawal",
1030
+ "outage",
1031
+ "交易者",
1032
+ "交易员",
1033
+ "交易員",
1034
+ "交易所",
1035
+ "上币",
1036
+ "上幣",
1037
+ "下架",
1038
+ "清算",
1039
+ "爆仓",
1040
+ "爆倉",
1041
+ "充值",
1042
+ "充币",
1043
+ "充幣",
1044
+ "提款",
1045
+ "提币",
1046
+ "提幣",
1047
+ "宕机",
1048
+ "宕機",
1049
+ ],
1050
+ systemic: [
1051
+ "regulation",
1052
+ "regulator",
1053
+ "sec",
1054
+ "cftc",
1055
+ "etf",
1056
+ "interest rate",
1057
+ "federal reserve",
1058
+ "hack",
1059
+ "hacked",
1060
+ "exploit",
1061
+ "breach",
1062
+ "exchange outage",
1063
+ "withdrawal suspended",
1064
+ "securities and exchange commission",
1065
+ "监管",
1066
+ "監管",
1067
+ "監管層",
1068
+ "监管层",
1069
+ "利率决议",
1070
+ "利率決議",
1071
+ "暂停提款",
1072
+ "暫停提款",
1073
+ ],
1074
+ official: [
1075
+ "official",
1076
+ "officially",
1077
+ "announced",
1078
+ "announcement",
1079
+ "earnings report shows",
1080
+ "financial results show",
1081
+ "according to the sec",
1082
+ "according to the cftc",
1083
+ "regulator said",
1084
+ "官方公告",
1085
+ "正式公告",
1086
+ "正式宣布",
1087
+ "财报数据显示",
1088
+ "財報數據顯示",
1089
+ "监管机构表示",
1090
+ "監管機構表示",
1091
+ "央行公布",
1092
+ "美联储公布",
1093
+ "聯準會公布",
1094
+ "证监会公布",
1095
+ "證監會公布",
1096
+ "公司公告",
1097
+ "交易所公告",
1098
+ "官方确认",
1099
+ "官方確認",
1100
+ "官方证实",
1101
+ "官方證實",
1102
+ "正式通过",
1103
+ "正式通過",
1104
+ "正式批准",
1105
+ "正式生效",
1106
+ ],
1107
+ rumor: [
1108
+ "rumor",
1109
+ "rumour",
1110
+ "reportedly",
1111
+ "allegedly",
1112
+ "sources say",
1113
+ "unconfirmed",
1114
+ "传闻",
1115
+ "傳聞",
1116
+ "据称",
1117
+ "據稱",
1118
+ "消息人士",
1119
+ "或将",
1120
+ "或將",
1121
+ "网传",
1122
+ "網傳",
1123
+ "尚未证实",
1124
+ "尚未證實",
1125
+ ],
1126
+ denial: [
1127
+ "denies",
1128
+ "denied",
1129
+ "not true",
1130
+ "false report",
1131
+ "fake news",
1132
+ "no evidence",
1133
+ "clarifies",
1134
+ "否认",
1135
+ "否認",
1136
+ "不实",
1137
+ "不實",
1138
+ "假消息",
1139
+ "没有证据",
1140
+ "沒有證據",
1141
+ "并未",
1142
+ "並未",
1143
+ "澄清",
1144
+ ],
1145
+ retrospective: [
1146
+ "recap",
1147
+ "review",
1148
+ "last week",
1149
+ "previously",
1150
+ "history",
1151
+ "回顾",
1152
+ "回顧",
1153
+ "此前",
1154
+ "上周",
1155
+ "上週",
1156
+ "盘点",
1157
+ "盤點",
1158
+ "历史上",
1159
+ "歷史上",
1160
+ ],
1161
+ criticalEvent: [
1162
+ "rate decision",
1163
+ "interest rate decision",
1164
+ "etf approval",
1165
+ "etf rejection",
1166
+ "bankruptcy",
1167
+ "insolvency",
1168
+ "withdrawal suspended",
1169
+ "withdrawals halted",
1170
+ "halts withdrawals",
1171
+ "exchange outage",
1172
+ "hacked",
1173
+ "exploit",
1174
+ "利率决议",
1175
+ "利率決議",
1176
+ "破产",
1177
+ "破產",
1178
+ "暂停提款",
1179
+ "暫停提款",
1180
+ "交易所宕机",
1181
+ "交易所宕機",
1182
+ "黑客攻击",
1183
+ "駭客攻擊",
1184
+ "遭駭",
1185
+ "遭黑",
1186
+ ],
1187
+ majorEvent: [
1188
+ "lawsuit",
1189
+ "settlement",
1190
+ "mainnet",
1191
+ "hard fork",
1192
+ "protocol upgrade",
1193
+ "acquisition",
1194
+ "merger",
1195
+ "earnings guidance",
1196
+ "withdrawals resumed",
1197
+ "service restored",
1198
+ "诉讼",
1199
+ "訴訟",
1200
+ "和解",
1201
+ "主网",
1202
+ "主網",
1203
+ "协议升级",
1204
+ "協議升級",
1205
+ "收购",
1206
+ "收購",
1207
+ "并购",
1208
+ "併購",
1209
+ "财报指引",
1210
+ "財報指引",
1211
+ "恢复提款",
1212
+ "恢復提款",
1213
+ "恢复服务",
1214
+ "恢復服務",
1215
+ ],
1216
+ materialEvent: [
1217
+ "listing",
1218
+ "listed",
1219
+ "delist",
1220
+ "token unlock",
1221
+ "governance",
1222
+ "funding",
1223
+ "product launch",
1224
+ "上币",
1225
+ "上幣",
1226
+ "下架",
1227
+ "代币解锁",
1228
+ "代幣解鎖",
1229
+ "治理",
1230
+ "融资",
1231
+ "融資",
1232
+ "产品发布",
1233
+ "產品發布",
1234
+ ],
1235
+ earnings: [
1236
+ "earnings",
1237
+ "quarterly results",
1238
+ "financial results",
1239
+ "revenue",
1240
+ "sales",
1241
+ "eps",
1242
+ "财报",
1243
+ "財報",
1244
+ "季度业绩",
1245
+ "季度業績",
1246
+ "营收",
1247
+ "營收",
1248
+ "每股收益",
1249
+ ],
1250
+ guidance: [
1251
+ "better-than-expected",
1252
+ "worse-than-expected",
1253
+ "beats estimates",
1254
+ "misses estimates",
1255
+ "raises guidance",
1256
+ "cuts guidance",
1257
+ "guidance",
1258
+ "forecast",
1259
+ "outlook",
1260
+ "超预期",
1261
+ "超預期",
1262
+ "低于预期",
1263
+ "低於預期",
1264
+ "上调指引",
1265
+ "上調指引",
1266
+ "下调指引",
1267
+ "下調指引",
1268
+ "展望",
1269
+ ],
1270
+ watchedCompanyEvent: [
1271
+ "acquisition",
1272
+ "merger",
1273
+ "investigation",
1274
+ "sanction",
1275
+ "export restriction",
1276
+ "production halt",
1277
+ "recall",
1278
+ "ceo resigns",
1279
+ "ceo departure",
1280
+ "收购",
1281
+ "收購",
1282
+ "并购",
1283
+ "併購",
1284
+ "调查",
1285
+ "調查",
1286
+ "制裁",
1287
+ "出口限制",
1288
+ "停产",
1289
+ "停產",
1290
+ "召回",
1291
+ "高管离职",
1292
+ "高管離職",
1293
+ ],
1294
+ macroBreadth: [
1295
+ "federal reserve",
1296
+ "interest rate",
1297
+ "regulation",
1298
+ "regulator",
1299
+ "sec",
1300
+ "cftc",
1301
+ "securities and exchange commission",
1302
+ "securities regulator",
1303
+ "央行",
1304
+ "美联储",
1305
+ "聯準會",
1306
+ "监管",
1307
+ "監管",
1308
+ "監管層",
1309
+ "监管层",
1310
+ ],
1311
+ immediacyNow: ["effective", "takes effect", "today", "正式生效", "今日", "现已", "現已"],
1312
+ immediacyScheduled: ["scheduled", "upcoming", "will launch", "将于", "將於", "即将", "即將"],
1313
+ immediacyProposal: ["proposal", "proposes", "considering", "提案", "拟", "擬", "考虑", "考慮"],
1314
+ volumeSignal: [
1315
+ "volume doubled",
1316
+ "volume surged",
1317
+ "volume jumped",
1318
+ "volume spiked",
1319
+ "trading volume up",
1320
+ "成交量翻倍",
1321
+ "成交量激增",
1322
+ "成交量暴增",
1323
+ "成交量大增",
1324
+ ],
1325
+ liquidationSignal: [
1326
+ "liquidation",
1327
+ "liquidations",
1328
+ "open interest",
1329
+ "清算",
1330
+ "爆倉",
1331
+ "爆仓",
1332
+ "未平倉量",
1333
+ "未平仓量",
1334
+ "强制平仓",
1335
+ "強制平倉",
1336
+ ],
1337
+ nonReactionPercent: [
1338
+ "revenue",
1339
+ "profit",
1340
+ "earnings",
1341
+ "eps",
1342
+ "expectation",
1343
+ "expected",
1344
+ "year over year",
1345
+ "quarter over quarter",
1346
+ "yoy",
1347
+ "qoq",
1348
+ "margin",
1349
+ "stake",
1350
+ "ownership",
1351
+ "supply",
1352
+ "apy",
1353
+ "interest rate",
1354
+ "yield",
1355
+ "vote",
1356
+ "share of",
1357
+ "market share",
1358
+ "dominance",
1359
+ "allocation",
1360
+ "drawdown",
1361
+ "win rate",
1362
+ "uptime",
1363
+ "fee share",
1364
+ "营收",
1365
+ "營收",
1366
+ "利润",
1367
+ "利潤",
1368
+ "每股收益",
1369
+ "预期",
1370
+ "預期",
1371
+ "同比",
1372
+ "环比",
1373
+ "環比",
1374
+ "毛利",
1375
+ "持股",
1376
+ "占比",
1377
+ "份额",
1378
+ "份額",
1379
+ "市占率",
1380
+ "市佔率",
1381
+ "主导率",
1382
+ "主導率",
1383
+ "供应量",
1384
+ "供應量",
1385
+ "年化",
1386
+ "利率",
1387
+ "收益率",
1388
+ "投票",
1389
+ ],
1390
+ securityEvidence: [
1391
+ "security breach",
1392
+ "security incident",
1393
+ "security vulnerability",
1394
+ "security flaw",
1395
+ "hacked",
1396
+ "exploit",
1397
+ "exploited",
1398
+ "stolen funds",
1399
+ "phishing",
1400
+ "rug pull",
1401
+ "被盗",
1402
+ "被盜",
1403
+ "遭駭",
1404
+ "遭黑",
1405
+ "安全漏洞",
1406
+ "安全事故",
1407
+ "资金被盗",
1408
+ "資金被盜",
1409
+ ],
1410
+ regulationEvidence: [
1411
+ "regulation",
1412
+ "regulator",
1413
+ "sec",
1414
+ "cftc",
1415
+ "esma",
1416
+ "mica",
1417
+ "court",
1418
+ "lawsuit",
1419
+ "enforcement",
1420
+ "license",
1421
+ "compliance",
1422
+ "securities law",
1423
+ "securities regulator",
1424
+ "securities and exchange commission",
1425
+ "is not a security",
1426
+ "监管",
1427
+ "監管",
1428
+ "監管層",
1429
+ "监管层",
1430
+ "诉讼",
1431
+ "訴訟",
1432
+ "执法",
1433
+ "執法",
1434
+ "牌照",
1435
+ "合规",
1436
+ "合規",
1437
+ ],
1438
+ exchangeEvidence: [
1439
+ "exchange",
1440
+ "listing",
1441
+ "listed",
1442
+ "delist",
1443
+ "binance",
1444
+ "coinbase",
1445
+ "kraken",
1446
+ "bybit",
1447
+ "okx",
1448
+ "bitget",
1449
+ "交易所",
1450
+ "上币",
1451
+ "上幣",
1452
+ "下架",
1453
+ ],
1454
+ fundingEvidence: [
1455
+ "funding round",
1456
+ "raises",
1457
+ "raised",
1458
+ "investment",
1459
+ "acquisition",
1460
+ "merger",
1461
+ "valuation",
1462
+ "series a",
1463
+ "series b",
1464
+ "融资",
1465
+ "融資",
1466
+ "估值",
1467
+ "收购",
1468
+ "收購",
1469
+ ],
1470
+ productEvidence: [
1471
+ // 字面量匹配对复数没有办法,所以常见复数要显式列出。
1472
+ // 「…for zk developers」在只写 `developer` 时会被 ASCII 词边界整条挡掉。
1473
+ "mainnet",
1474
+ "testnet",
1475
+ "upgrade",
1476
+ "upgrades",
1477
+ "launch",
1478
+ "launches",
1479
+ "wallet",
1480
+ "wallets",
1481
+ "layer 2",
1482
+ "developer",
1483
+ "developers",
1484
+ "主网",
1485
+ "主網",
1486
+ "测试网",
1487
+ "測試網",
1488
+ "升级",
1489
+ "升級",
1490
+ "钱包",
1491
+ "錢包",
1492
+ ],
1493
+ marketEvidence: ["price", "rally", "surge", "falls", "trading", "etf", "价格", "價格", "行情", "涨", "漲", "跌"],
1494
+ // --- 0.6.1 的八类情报类型,词表逐字保留 ---------------------------------
1495
+ infoSentiment: [
1496
+ "trending",
1497
+ "viral",
1498
+ "social media",
1499
+ "community",
1500
+ "influencer",
1501
+ "kol",
1502
+ "x post",
1503
+ "熱搜",
1504
+ "热搜",
1505
+ "社群",
1506
+ "輿情",
1507
+ "舆情",
1508
+ ],
1509
+ infoRates: [
1510
+ "interest rate",
1511
+ "rate cut",
1512
+ "rate hike",
1513
+ "bond",
1514
+ "treasury yield",
1515
+ "credit spread",
1516
+ "default",
1517
+ "debt",
1518
+ "降息",
1519
+ "加息",
1520
+ "升息",
1521
+ "債券",
1522
+ "债券",
1523
+ "殖利率",
1524
+ "收益率",
1525
+ "信用利差",
1526
+ ],
1527
+ infoFx: [
1528
+ "foreign exchange",
1529
+ "forex",
1530
+ "fx market",
1531
+ "dollar index",
1532
+ "usd/jpy",
1533
+ "eur/usd",
1534
+ "yen",
1535
+ "yuan",
1536
+ "匯率",
1537
+ "汇率",
1538
+ "外匯",
1539
+ "外汇",
1540
+ "美元指數",
1541
+ "美元指数",
1542
+ "日圓",
1543
+ "日元",
1544
+ ],
1545
+ infoCommodities: [
1546
+ "crude oil",
1547
+ "brent",
1548
+ "wti",
1549
+ "natural gas",
1550
+ "gold price",
1551
+ "silver price",
1552
+ "copper",
1553
+ "commodity",
1554
+ "原油",
1555
+ "天然氣",
1556
+ "天然气",
1557
+ "黃金",
1558
+ "黄金",
1559
+ "白銀",
1560
+ "白银",
1561
+ "銅價",
1562
+ "铜价",
1563
+ "大宗商品",
1564
+ ],
1565
+ infoFlows: [
1566
+ "net inflow",
1567
+ "net outflow",
1568
+ "fund flow",
1569
+ "open interest",
1570
+ "funding rate",
1571
+ "liquidation",
1572
+ "positioning",
1573
+ "on-chain flow",
1574
+ "持倉",
1575
+ "持仓",
1576
+ "資金流",
1577
+ "资金流",
1578
+ "淨流入",
1579
+ "净流入",
1580
+ "淨流出",
1581
+ "净流出",
1582
+ "未平倉量",
1583
+ "未平仓量",
1584
+ "清算",
1585
+ "爆倉",
1586
+ "爆仓",
1587
+ ],
1588
+ infoMacro: [
1589
+ "inflation",
1590
+ "cpi",
1591
+ "gdp",
1592
+ "employment",
1593
+ "unemployment",
1594
+ "central bank",
1595
+ "federal reserve",
1596
+ "tariff",
1597
+ "sanction",
1598
+ "regulation",
1599
+ "regulator",
1600
+ "policy",
1601
+ "sec",
1602
+ "cftc",
1603
+ "通膨",
1604
+ "通脹",
1605
+ "通胀",
1606
+ "央行",
1607
+ "聯準會",
1608
+ "美联储",
1609
+ "關稅",
1610
+ "关税",
1611
+ "制裁",
1612
+ "監管",
1613
+ "监管",
1614
+ "政策",
1615
+ ],
1616
+ infoEquities: [
1617
+ "stock",
1618
+ "shares",
1619
+ "earnings",
1620
+ "revenue",
1621
+ "guidance",
1622
+ "ipo",
1623
+ "acquisition",
1624
+ "merger",
1625
+ "company",
1626
+ "equity",
1627
+ "股票",
1628
+ "股價",
1629
+ "股价",
1630
+ "財報",
1631
+ "财报",
1632
+ "營收",
1633
+ "营收",
1634
+ "併購",
1635
+ "并购",
1636
+ "上市公司",
1637
+ ],
1638
+ criticalRecall: [
1639
+ "withdrawal suspended",
1640
+ "withdrawals halted",
1641
+ "halts withdrawals",
1642
+ "exchange outage",
1643
+ "security breach",
1644
+ "security incident",
1645
+ "hacked",
1646
+ "exploit",
1647
+ "insolvency",
1648
+ "bankruptcy",
1649
+ "sanction",
1650
+ "enforcement action",
1651
+ "asset freeze",
1652
+ "暂停提款",
1653
+ "暫停提款",
1654
+ "停止提币",
1655
+ "停止提幣",
1656
+ "遭駭",
1657
+ "遭黑",
1658
+ "黑客攻击",
1659
+ "駭客攻擊",
1660
+ "资金被盗",
1661
+ "資金被盜",
1662
+ "破产",
1663
+ "破產",
1664
+ "制裁",
1665
+ "冻结",
1666
+ "凍結",
1667
+ "执法行动",
1668
+ "執法行動",
1669
+ ],
1670
+ },
1671
+ // 保住 0.6.1 的 `/(?:volume|成交量).{0,45}(?:double|翻倍|激增|…)/`。
1672
+ proximity: [
1673
+ {
1674
+ set: "volumeSignal",
1675
+ left: ["volume", "成交量", "交易量"],
1676
+ right: [
1677
+ "double",
1678
+ "doubled",
1679
+ "2x",
1680
+ "two times",
1681
+ "increase",
1682
+ "jump",
1683
+ "spike",
1684
+ "surge",
1685
+ "200%",
1686
+ "兩倍",
1687
+ "两倍",
1688
+ "翻倍",
1689
+ "增加",
1690
+ "激增",
1691
+ "暴增",
1692
+ "大增",
1693
+ ],
1694
+ maxGapChars: 45,
1695
+ },
1696
+ ],
1697
+ // 大小写敏感:`HYPE` 是 Hyperliquid 的代号,`hype` 是英文单词。
1698
+ // 小写化之后这个区分在结构上就没了,所以它必须跑在原文上。
1699
+ casePatterns: [
1700
+ { set: watchedAssetSet("Hyperliquid"), pattern: "\\bHYPE\\b" },
1701
+ { set: "watchedCrypto", pattern: "\\bHYPE\\b" },
1702
+ ],
1703
+ // 0.6.1 的 `watchedAssetNames`,十个,逐字保留。
1704
+ watchedAssets: [
1705
+ { name: "Bitcoin", terms: ["bitcoin", "btc", "比特币", "比特幣"] },
1706
+ { name: "Ethereum", terms: ["ethereum", "ether", "eth", "以太坊"] },
1707
+ { name: "USD Coin", terms: ["usd coin", "usdc", "美元币", "美元幣"] },
1708
+ { name: "Hyperliquid", terms: ["hyperliquid", "$hype"] },
1709
+ { name: "XRP", terms: ["xrp", "ripple", "ripple labs", "瑞波", "瑞波币", "瑞波幣"] },
1710
+ { name: "Solana", terms: ["solana", "$sol"] },
1711
+ { name: "NVIDIA", terms: ["nvidia", "nvda", "英伟达", "英偉達", "辉达", "輝達"] },
1712
+ { name: "Sandisk", terms: ["sandisk", "sndk", "闪迪", "閃迪"] },
1713
+ { name: "Samsung Electronics", terms: ["samsung electronics", "005930", "三星电子", "三星電子"] },
1714
+ { name: "SK hynix", terms: ["sk hynix", "000660", "海力士"] },
1715
+ ],
1716
+ sourceReliability: {
1717
+ baselineIntercept: 11,
1718
+ baselinePivot: 55,
1719
+ baselineSlope: 0.55,
1720
+ corroborationBonus: [
1721
+ [4, 5],
1722
+ [3, 4],
1723
+ [2, 2],
1724
+ ],
1725
+ officialBonus: 3,
1726
+ },
1727
+ marketImpact: {
1728
+ weights: {
1729
+ severity: 1.5,
1730
+ assetScale: 8 / 7,
1731
+ breadth: 1.4,
1732
+ immediacy: 5 / 3,
1733
+ },
1734
+ claimMultiplier: { denied: 0.35, rumor: 0.6, normal: 1 },
1735
+ timeMultiplier: { retrospective: 0.6, normal: 1 },
1736
+ ladders: {
1737
+ severity: [
1738
+ { state: "critical", value: 10, anySets: ["criticalEvent"] },
1739
+ {
1740
+ state: "watched_company_guidance",
1741
+ value: 9,
1742
+ allSets: ["watchedEquity", "earnings", "guidance"],
1743
+ },
1744
+ {
1745
+ state: "watched_company_major",
1746
+ value: 8.5,
1747
+ allSets: ["watchedEquity", "watchedCompanyEvent"],
1748
+ },
1749
+ { state: "major", value: 8, anySets: ["majorEvent"] },
1750
+ { state: "watched_company_earnings", value: 7.5, allSets: ["watchedEquity", "earnings"] },
1751
+ { state: "material", value: 6, anySets: ["materialEvent"] },
1752
+ { state: "systemic_or_urgent", value: 5, anySets: ["systemic", "urgentImpact"] },
1753
+ { state: "partnership", value: 3, anySets: ["partnership"] },
1754
+ { state: "sector", value: 1.5, anySets: ["sector", "cryptoGeneric"] },
1755
+ { state: "unknown", value: 0 },
1756
+ ],
1757
+ assetScale: [
1758
+ { state: "core", value: 7, anySets: ["coreAssets"] },
1759
+ { state: "watched", value: 5.5, anySets: ["watchedCrypto", "watchedEquity"] },
1760
+ { state: "major_market", value: 4, anySets: ["majorMarket"] },
1761
+ { state: "sector", value: 2.5, anySets: ["sector"] },
1762
+ { state: "unknown", value: 0 },
1763
+ ],
1764
+ breadth: [
1765
+ { state: "macro", value: 5, anySets: ["macroBreadth"] },
1766
+ { state: "critical", value: 4.5, anySets: ["criticalEvent"] },
1767
+ { state: "core_or_trader", value: 3.5, anySets: ["coreAssets", "trader"] },
1768
+ { state: "watched", value: 2.5, anySets: ["watchedCrypto", "watchedEquity"] },
1769
+ { state: "sector", value: 1.5, anySets: ["sector"] },
1770
+ { state: "unknown", value: 0 },
1771
+ ],
1772
+ immediacy: [
1773
+ // 0.6.1 这里还有一个裸词 "now"。删掉是故意的:`right now` / `for now` 让几乎
1774
+ // 每条都拿满档,那不是即时性信号而是英语。
1775
+ { state: "effective_now", value: 3, anySets: ["immediacyNow", "official"] },
1776
+ { state: "scheduled", value: 2, anySets: ["immediacyScheduled"] },
1777
+ { state: "proposal", value: 1, anySets: ["immediacyProposal"] },
1778
+ // 0.6.1 这里是 1.5 —— 高于显式最低档,于是补一个 "proposes" 反而降 0.8 分。
1779
+ // 这一行就是缺陷 5 的现场。
1780
+ { state: "unknown", value: 1 },
1781
+ ],
1782
+ },
1783
+ },
1784
+ marketReaction: {
1785
+ anchorsMajor: [
1786
+ [0, 0],
1787
+ [1, 3],
1788
+ [3, 8],
1789
+ [5, 12],
1790
+ [10, 14],
1791
+ ],
1792
+ anchorsMinor: [
1793
+ [0, 0],
1794
+ [2, 2],
1795
+ [5, 6],
1796
+ [8, 12],
1797
+ [15, 14],
1798
+ ],
1799
+ bonusVolume: 3,
1800
+ bonusLiquidation: 3,
1801
+ bonusBoth: 2,
1802
+ bonusDirectionOnly: 1.5,
1803
+ postScaleFactor: 0.5,
1804
+ maxPlausibleMovePctCore: 40,
1805
+ maxPlausibleMovePctOther: 80,
1806
+ attachmentWindowChars: 40,
1807
+ priceVerbs: [
1808
+ "rose",
1809
+ "rises",
1810
+ "fell",
1811
+ "falls",
1812
+ "is up",
1813
+ "is down",
1814
+ "was up",
1815
+ "was down",
1816
+ "gained",
1817
+ "gains",
1818
+ "lost",
1819
+ "loses",
1820
+ "jumped",
1821
+ "jumps",
1822
+ "plunged",
1823
+ "plunges",
1824
+ "surged",
1825
+ "surges",
1826
+ "slid",
1827
+ "slides",
1828
+ "dropped",
1829
+ "drops",
1830
+ "climbed",
1831
+ "climbs",
1832
+ "涨",
1833
+ "漲",
1834
+ "上涨",
1835
+ "上漲",
1836
+ "跌",
1837
+ "下跌",
1838
+ "下滑",
1839
+ "暴涨",
1840
+ "暴漲",
1841
+ "暴跌",
1842
+ "重挫",
1843
+ "飙升",
1844
+ "飆升",
1845
+ ],
1846
+ priceNouns: [
1847
+ "rally",
1848
+ "gain",
1849
+ "gains",
1850
+ "drop",
1851
+ "decline",
1852
+ "selloff",
1853
+ "sell-off",
1854
+ "涨幅",
1855
+ "漲幅",
1856
+ "跌幅",
1857
+ "回撤",
1858
+ ],
1859
+ exclusionSet: "nonReactionPercent",
1860
+ },
1861
+ freshness: {
1862
+ anchors: [
1863
+ [0, 15],
1864
+ [60, 14],
1865
+ [180, 12.5],
1866
+ [360, 11],
1867
+ [720, 9],
1868
+ [1440, 7],
1869
+ [2880, 4],
1870
+ [4320, 1],
1871
+ ],
1872
+ futureToleranceMinutes: 5,
1873
+ },
1874
+ audienceRelevance: {
1875
+ coreAsset: 7,
1876
+ watchedCrypto: 6,
1877
+ watchedEquity: 5,
1878
+ watchedCompanyEvent: 3,
1879
+ trader: 4,
1880
+ systemic: 3,
1881
+ education: 2,
1882
+ brandTitleHit: 7,
1883
+ brandCoreHit: 5,
1884
+ brandPassingHit: 2,
1885
+ userSuppliedBrandContribution: 0,
1886
+ },
1887
+ categories: [
1888
+ {
1889
+ slug: "security",
1890
+ minScore: 3,
1891
+ // 多词证据闸门:裸词 `security` 不在 securityEvidence 里,所以
1892
+ // 「SEC says XRP is not a security」压根进不了这个桶。
1893
+ requireAnyOf: ["securityEvidence"],
1894
+ weights: { securityEvidence: 4, criticalEvent: 2, trader: 1 },
1895
+ },
1896
+ { slug: "regulation", minScore: 3, weights: { regulationEvidence: 4, macroBreadth: 2, systemic: 1 } },
1897
+ { slug: "exchange", minScore: 3, weights: { exchangeEvidence: 4, trader: 2 } },
1898
+ { slug: "funding", minScore: 3, weights: { fundingEvidence: 4 } },
1899
+ { slug: "product", minScore: 3, weights: { productEvidence: 4, sector: 1 } },
1900
+ // minScore 2(而不是 3)是为了保住 0.6.1:它的 `市場行情` 规则里就有裸的
1901
+ // bitcoin/btc/ethereum/eth,一条只提 BTC 的稿子在 0.6.1 里是行情类。
1902
+ // market 是最弱的桶,任何 4 分证据桶都能盖过它。
1903
+ { slug: "market", minScore: 2, weights: { marketEvidence: 3, coreAssets: 2, reactionDirection: 2 } },
1904
+ { slug: "industry", minScore: 1, weights: { sector: 2, cryptoGeneric: 1, education: 1, majorMarket: 1 } },
1905
+ ],
1906
+ informationTypes: [
1907
+ { slug: "sentiment_hot", minScore: 2, weights: { infoSentiment: 3 } },
1908
+ { slug: "rates_credit", minScore: 2, weights: { infoRates: 3, infoMacro: 1 } },
1909
+ { slug: "fx", minScore: 2, weights: { infoFx: 3 } },
1910
+ { slug: "commodities", minScore: 2, weights: { infoCommodities: 3 } },
1911
+ { slug: "flows_positioning", minScore: 2, weights: { infoFlows: 3 } },
1912
+ { slug: "macro_policy", minScore: 2, weights: { infoMacro: 3, macroBreadth: 1 } },
1913
+ { slug: "equities_corporate", minScore: 2, weights: { infoEquities: 3, watchedEquity: 1 } },
1914
+ {
1915
+ slug: "crypto",
1916
+ minScore: 2,
1917
+ weights: { cryptoGeneric: 2, coreAssets: 2, watchedCrypto: 2, sector: 1, exchangeEvidence: 1 },
1918
+ },
1919
+ ],
1920
+ criticalRecall: { sets: ["criticalRecall"], maxSourceTier: 3 },
1921
+ };
1922
+ //# sourceMappingURL=signal-score.js.map