Skip to content

A written quantity is a value, not a node - #586

Merged
WaylandYang merged 2 commits into
devfrom
fix/a-quantity-is-a-value-not-a-node
Sep 10, 2026
Merged

A written quantity is a value, not a node#586
WaylandYang merged 2 commits into
devfrom
fix/a-quantity-is-a-value-not-a-node

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

面板上点开 $5 billion 这个「实体」,底下挂着两件毫不相干的事:

$5 billion  ← valuation  SSI Inc.   2024-09-01 ~ 2025-03-01
$5 billion  ← invested   Nvidia     2026-07-27 ~ now

它们唯一的共同点是字符串一样。图上 SSI Inc. 与 Nvidia 因此隔着这个点两跳可达——一条没有含义的路径。同一个库里 $1 billion$30 billion 也这样。

病灶:一道太窄的闸

「谓词未知 + 字面值宾语」那条路早就铺好了insert_value_fact,值进 object_value、原词进 proposed_predicate,采纳时只换谓词、形状不动)。提示词也写着(规则 8a,例子正是 "$11.9 billion")。缺的是把守那条路的判据:

fn looks_literal(s: &str) -> bool {
    if s.parse::<f64>().is_ok() { return true; }   // 只认裸数字
    utopia_extract::parse_time(s).is_some()        // 和日期
}

"$5 billion" 两条都不满足,于是掉进关系那条路,凭空造出一个节点;同名的再并成一个点。

改动

parse_quantity(新,utopia-extract):一个整体就是一个量的字符串 → (数值, 单位)。可选货币符号 + 数字 + 可选量级词 + 可选百分号,此外一个词都不许有

不收
$5 billion → (5e9, $) 900 million weekly active users
52% → (52, %) 2025 Atlantic hurricane season
3.5 million35,000 $10 billion investment8GW data center
3M(那是一家公司)、5k

量级词只认全写,不认单字母后缀——把 3M、K2、B1 读成数字,代价是一个真实体被读没了,而那一头不可逆。单位照抄符号不猜币种:$ 可能是美元也可能是澳元,猜出来的 USD 是一条没人负责的断言。

  • looks_literal 改用它(裸数字那一档它已包含)。
  • 值照原文落笔(8a 要的就是 "units and all"),单位另记一格——采纳时换算成 5e9 只看得懂数,符号丢在原文里就再取不出来。
  • normalize_attr_value("number", …) 也认量,否则采纳属性时 $5 billion 一路「换不动」,事实永远拿不到谓词。
  • 面板把大数收成 $5BIntl.NumberFormat 紧凑写法):存的是乘开的数才能比大小,可念出来「5000000000 $」比原文难读。

顺带修掉一个把整批打翻的坑

value_facts_for_formss.type_id 解成裸 Uuid,可这列本来就可空(0009:「抽到了东西但本体里没有对应的类」是正常状态)。批里只要有一条主语没类型,采纳就在解码那一步整个退出:

error occurred while decoding column 1: unexpected null; try decoding as an `Option`

实测一个库里攒着 2454 条等谓词的值事实,其中 58 条主语无类型——够把好几个说法卡死。改成 Option:没类型的不参与 domain(属性得声明挂在哪些类下),但照样跟着改写,否则一条有名有姓的事实会继续没有谓词。

RED → GREEN 都跑过:改之前那条探针拿到上面那行解码错,改之后 an_untyped_subject_does_not_stall_the_batch 在真库上通过。

不做回迁

RC 阶段,语料重抽一遍就干净了,不值得为几十条记录去动双时态账本。已有的库不会自己变,要看效果得重抽。

验证

  • cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warnings 干净。
  • cargo test --workspace(CI 那条不带库的口径)86 个 test result 全绿。
  • cargo test -p utopia-store 在手工迁好的库上除 rss_ledger_contract 外全绿;那一条自己跑迁移,撞上我用 psql 铺的表(relation "organizations" already exists),是本地记账问题不是行为问题——CI 先 sqlx migrate run,以它为准。
  • pnpm test 18 passed、pnpm build(style-guard + tsc + vite)干净。

🤖 Generated with Claude Code

WaylandYang and others added 2 commits September 10, 2026 14:12
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: WaylandYang <wayland0916@gmail.com>
@WaylandYang
WaylandYang merged commit 9aaf8ca into dev Sep 10, 2026
4 checks passed
@WaylandYang
WaylandYang deleted the fix/a-quantity-is-a-value-not-a-node branch September 10, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant