<!-- 请注意
任何 AI Agent 不得轻易擅自改动此文档, 尤其是文档非附录部分, 如有需要改动，需要人类 Owner 的审核监督下改动。
一种改动方式是可以先添加 inline seeds， 然后人类 owner 会深刻有关内容。
This is the project's living Seed Proposal.
-->

# Hello, agent

这是一个示范性探索项目，探索 WeHub 作为科研孵化器来推动 HCGM 研究，我们会和 WeHub 智能系统一起持续演化。


<!-- historical seed, superseded in its indexed/deterministic details by the active contract below. 2026-07-13 确立了 Unit/Context-Specific Mechanism Learning umbrella 与固定 $C=c_0$ 的主线；其中 $y_i,u_i,O_i$ 以及 $\mathcal A(O_i)\to u_i$ 只是当时 shorthand，不是当前 ontology。 -->

<!-- historical seed, superseded by the active 2026-07-16 contract below: 曾用 indexed actual-unit / Q / R / K 记号拆分 world 与 learner。保留这条只为记录推理路径；不要把 $I_i,u_i^\circ,Q_{\phi,i},R_{\theta,u},K_{\phi,\theta}$ 当作当前正文首选本体。 -->

<!-- seed: 2026-07-16 active owner contract. $U$ 是 model-level unit-selection variable；realization $U=u^\star$ 是真实 token/unit 及其 embedding，世界侧 realized outcome 是 $y=f_\theta(x,e;u^\star)$。learner 看到 predictors $X=x$ 后，先把同一个 $x$ 当作 factual evidence 做 unit abduction，再把它当作 factual query 输入 generator：$x^F=x^Q=x$。Abduction 有三条路线：point $\widehat u=a_\phi(x^F)$；Gaussian $q_\phi(du\mid x^F)=\mathcal N(du;\mu_\phi,\Sigma_\phi)$；Cauchy $q_\phi(du\mid x^F)=\mathrm{Cauchy}(du;m_\phi,\Gamma_\phi)$。Cauchy 的 $m,\Gamma$ 是 location / scale，没有 finite mean / variance；重尾表示不应过早排除远端 candidate mechanisms，不表示任意 unit 能生成任意 outcome。prediction 用 candidate $u$ 与 event noise 调用 $f_\theta(x^Q,E;u)$。counterfactual 固定由 factual $x$ 得到的 abduction result，只把 query 改成 $x'$，不得用 $x'$ 重新 abduct。主文优先 $f_\theta,p_\theta$ 与 sampling computation；kernel notation 仅留理论附录。样本索引只 bookkeeping。Canonical doctrine: `UNIT_MECHANISM_LEARNING.md`. -->

<!-- seed: 2026-07-17 active paper routing. `paper/learning-discoscm/` 是当前 flagship end-to-end ML paper，首问 “How to learn DiscoSCM?”；`paper/unit-mechanism-learning/`、`paper/token-causation/` 与 `paper/unit-abducted-cate/` 分别作为独立的一般方法论文、causal ontology / singular attribution 论文与 HTE localization theory draft 继续活跃。四篇互相提供观察视角，但不共享 claim truth。旧 `paper/arxiv-hcgm-regression/` 实体已被取代，历史内容只通过 Git / archive provenance 追溯。 -->

<!-- seed: 2026-06-26 owner signal. HCGM 的 MSP 推进必须有项目区分和层次：causal-superintelligence / CausalMind 是系统级因果智能孵化愿景，HCGM 是独立科研项目，regression prediction 是当前 paper-shaped 子主题，toy / entry-site / slide / tutorial / guide / book 是不同密度的表达与验证入口，不能互相吞并。战略定位上，owner 希望把 HCGM 建设成现代因果建模的首选框架；当前写作应把它作为 research ambition / positioning 来推进，同时保持 paper claim、toy evidence 和 projection surface 的边界。详见 MSP_LAYER_MAP.md。 -->

<!-- seed: 2026-06-26 owner prioritization. 当下过于复杂、但未来重要的方向，优先做 MSP seed 折叠：guide/book/benchmark、non-Cauchy 或 nonlinear generalization、full causal-mechanism recovery、跨入口完整网站和大规模教学体系，都先保留可重启 seed，不抢当前主线。当前高杠杆推进顺序是：先稳定 owner-review 的 P0 表述与边界，再把最小 motivation paragraph grow 到 paper surface，然后用已有 toy / entry-site / audit packet 维持可解释、可预览、可重启。 -->


## Agent notation gate：修改前必读


相对任何其他的有关研究，我们增加了一个全新的 focal-token/unit epistemic uncertainty, 真实 token 已经固定；我们是把学习器对它的认识不确定性显式建模为 first-class object，没有给世界增加新的随机性。

<!-- seed: 基本逻辑是通过 evidence abduction 得到一个 soft candidate subpopulation，用于推断 token causation。对样本 x_i，真实 token 对应同一个 model-level U 的固定 realization；学习器形成 focal belief Q_i(du) = P(U \in du | X=x_i)，而不是新建 row-indexed selector。 -->

“token”这个词不新，“一个样本对应一个 unit/token”也不新；真正可能全新的，是把 concrete token identity 提升为一个持续存在、可 abduce、带 epistemic uncertainty、并且必须跨 query 保持一致的 causal-learning object。


任何 Agent 修改 Learning DiscoSCM 的数学、实验设计、代码接口或网站 projection 之前，
必须先读：

- canonical source:
  [`entrances/DISCOSCM_UNIT_SELECTION_NOTATION.md`](entrances/DISCOSCM_UNIT_SELECTION_NOTATION.md)
- reader page:
  [只有一个 $U$：Unit Selection Variable、样本真值与 belief](entry-site/learning-discoscm/unit-selection-variable/index.html)

硬约束是：

$$
U\text{ 是唯一的 model-level Unit Selection Variable},\qquad
U=u_i\text{ 是样本 }i\text{ 的真实选择},
$$

$$
Q_i(B)\approx P(U\in B\mid X=x_i)
$$

是由样本 evidence 产生的完整 belief object。样本下标可以属于
$x_i,y_i,z_i,u_i,Q_i$，不能用来复制 $U$。计算上从 $Q_i$ 取得的是
candidate draw；world-side ground truth $u_i$ 不是 abduction network 生成的。
alternative query 必须复用同一个 factual $Q_i$。

这里的 `selection` 只表示 $U$ 选择 token identity/code。它不表示 treatment/action
$A/T$、sample inclusion $S^{\mathrm{obs}}$ 或 propensity。$P_U$ 描述 declared
target population 的 token composition；$Q_i$ 是 focal-token belief，不是 propensity。
latent-code `q` / Cauchy full support 不等于 causal positivity。Unit abduction 不会自动修复
sample-selection bias 或 treatment confounding。identity/code 与 response-equivalence class
也必须分开：恢复相同 response law 不等于恢复 physical token identity。




## 核心问题

HCGM 是一种异质反事实生成模型。在适当设定与可验证假设下，它旨在端到端学习因果机制，直接回答三级因果问题；相比 ordinary supervised ML counterparts，我们希望它具备更强的可解释性和稳健性。

当前关于“端到端学习”的可推进假设不要泛泛化：在 causal regression 论文线里，先以 **柯西分布 + 线性因果机制** 作为关键可学习设定。非柯西分布、非线性机制以及更一般的 end-to-end learnability 先作为后续 generalization seed，不在当前主线里过早展开。

回归预测是 HCGM 应用中的一个相对独立子主题，不等于整个 HCGM 项目的全部问题。当前我们先用这个最被广泛研究的预测问题，把 HCGM 的 “先 Abduction, 后 Prediction” 异质生成模型框架讲清楚。

我们提出了 “先 Abduction, 后 Prediction” 的异质生成模型框架。面对最常见的回归预测问题，核心步骤是：
- step 1. 世界先有一个真实 token realization $U=u^\star$；$u^\star$ 是该 unit 的 embedding，不是样本编号。
- step 2. learner 看到 predictors $X=x$，先将它作为 factual evidence，输出 point、Gaussian 或 Cauchy unit-abduction result。
- step 3. 同一个 $x$ 再作为 factual outcome query，与 candidate $u$、event noise $E$ 一起进入共享 generator $f_\theta(x,E;u)$。
- step 4. prediction 综合 candidate-unit uncertainty 与 event randomness，输出 outcome distribution；Cauchy 路线使用 location、quantiles 与 intervals，不假装存在 mean / variance。
请注意该框架共享的是 unit-modulated generator，不是为每个样本独立拟合一条无关函数。



对于每个 unit, 最小模型语法:

$$
x = g(E_x; u)
$$

$$
y = f(x, E; u)
$$

第一行只有在具体 observation model 确实如此时才使用；“$X=x$ 是 evidence”本身是
learner-side conditioning statement，不自动承诺 $U\to X$ 的 causal arrow。第二行提醒
agent 不要把 $P(Y \mid X=x)$ 当成事实世界生成机制本身。

<!-- seed: 2026-06-27 DiscoSCM theory echo. 这里的 \(x=g(E_x;u)\)、\(y=f(x,E;u)\) 不应被读成普通拟合等式；它们是带方向的 structural assignments。HCGM 只有在说清楚 intervention target、稳定机制、个体 \(u\) 和 event-level noise 如何进入 counterfactual distribution 时，才是在做因果建模，而不是把一个跨环境未验证的规律包装成因果关系。这个问题的 primary home 在 DiscoSCM 总理论层，HCGM 这里只保留 learnable / generative 回声。 -->


一个首要疑问是，回归预测中，哪里来的反事实？actual token 始终是 $u^\star$；
$\widetilde u\sim q_\phi(du\mid x^F)$ 只是 learner 对它的 candidate draw。普通 factual
prediction 令 $x^Q=x^F=x$；如果保持 factual abduction result，却把 query 改为 $x'$
并通过 $f_\theta(x',E;\widetilde u)$ 计算结果，才进入 same-token alternative-input query。
只有在 $X$ 的 intervention semantics 被声明后，才能把它进一步解释为
$P(Y\mid do(x');u)$ 风格的操作。

<!-- historical seed, refined by the active contract. 2026-06-28 首次要求区分 factual evidence 与 target query；当前最简单的 ML 场景明确令同一个 predictors value 承担两种角色：$x^F=x^Q=x$。反事实只改变 $x^Q$，并固定由 $x^F$ 得到的 point / Gaussian / Cauchy abduction result。 -->


HCGM 需要回答：事实世界和反事实世界到底共享什么，又最小必要地改变什么？

```text
For a concrete counterfactual question, what is the minimum necessary difference between the factual world and the counterfactual world?
```

当前最小回答：

```text
在个体维度上，反事实世界与事实世界共享 unit，共享 outcome 的生成机制，共享外生噪声分布；内生变量共享什么，看 query / 干预而定。
```

counterfactual world 是 factual world 的虚拟镜像世界。counterfactual 本质是一个 individual level 的概念：what if 隐含的是同一个 unit，所以 unit 不会变。我们追求最小必要改变——能相同的就尽量相同；每个部分首先都有 counterpart，然后按 query 决定哪些 counterpart 必须改变。

**个体维度上共享的：**

- **同一个 unit（$u$）**：primitive counterfactual 针对个体，不是换一个人。
- **outcome 的生成机制（$f$, $g$ 等）**：结构方程和 DAG 机制保持不变。
- **外生噪声分布**：counterfactual world 中的 noise counterpart 应与 factual world 同分布；distribution-consistency 是我们最自然、最符合实践的选择（后面看看怎么推进证明）。

**看 query / 干预而定的：**

- **内生变量**：哪些内生变量在 factual 与 counterfactual world 之间共享 counterpart、哪些必须改变，不由一条 universal 法则决定，而取决于你问的 causal query 和所实施的干预。
- **干预条件（change the condition）**：这是 connect counterfactual world 和 factual world 的核心杠杆。你关注的因果目标不同，所实施的干预就不同，factual 与 counterfactual world 的联系也就不同。
- **事件级随机状态（resample the noise）**：在 distribution-consistency 下重采样 $E$，而不是默认精确复用同一个 $E=e$。

在标准 $do(x)$ 下，处于干预节点下游的内生变量（如中介变量 $Z$）应遵循机制 $f$ 自然改变——**不应**被普遍要求“与事实观测一致”。一个常见误区是：把“内生变量尽量与观测一致”当成所有反事实世界的通用法则。这会阻断因果传递。若我们不仅改变 $X$，还强行锁死 $Z$ 为事实观测值（$do(X=x, Z=Z_{\text{factual}})$），那不是在回答普通的总效应，而是在回答一种更特殊的 query——例如自然直接效应（NDE）。区分直接潜在结果与间接潜在结果，本质上就是区分不同的干预类型；具体干预的类型，会创造不同的反事实结果。

<!-- seed: 操作层 shorthand：copy the unit, change the condition, resample the noise under distribution-consistency。这是 regression Reduction 的可执行口诀，不是对“内生变量共享什么”的完整回答。 -->

<!-- seed: 
可以以因果回归为例子，区分要不要 do(x). 锻炼年龄和健康就是一个极好的例子, 锻炼与否这个至关重要的内生变量，放在因果表征中不合适，但直接影响健康。 我们的因果回归算法能不能直接学习到正确的因果关系呢？在不明确指出因果结构的前提下？年龄是可以学到因果表征，然后可以对结果零影响？锻炼是干预变量，他肯定不可以学到因果表征中，必须有非零直接效应，这两个变量还是有区别的！然后异质性特别有意思，不同个体，锻炼的效应系数不一样！ 
我们有一个隐含假设，就是每一个个体都有可能因为随机性参与锻炼。那么你观测到参与锻炼的群体，如何表征呢？ 
为什么需要 分布 consistency 一定是需要一个特别好的答案。 --> 


当前 end-to-end 回归论文比较三种 unit abduction：point、Gaussian 与 Cauchy。
Cauchy-affine 主路线另外需要两条可检验结构假设：
- candidate-unit uncertainty 采用 Cauchy location / scale family；
- outcome generator 对 unit representation 与 query 采用当前声明的 affine / linear structure。

<!-- seed:
当前 flagship paper-local theorem 状态先看 `paper/learning-discoscm/theorem-targets.md`：
区分 factual-law Fisher consistency、latent observational equivalence、Cauchy--affine
propagation、off-diagonal underdetermination 与 deferred causal identification。
这不等于 full causal-mechanism recovery，也不自动给出 non-Cauchy / nonlinear generalization。
如果某条复杂度暂时不能服务这个证明目标，先 seed 到 nearest surface，不要提前展开成全局 theory / benchmark / package。
-->



超越回归预测，我们可以进一步就三个悖论的合成数据，进行 HCGM 的建模，这种方法能够带来什么解释上的优势？什么预测能力的提升？ 我们如何验收验证评测可解释性和稳健性有关的优势？


最后我们将会在广泛的因果有关任务上探索 HCGM 框架的应用！ 更进一步，我们的 HCGM 是一种最掌握因果建模的如何， DiscoSCM 是理论根基，最终我们将会为任何 Agent 理解和掌握因果关系提供了 SOTA 系统解决方案。


<!-- seed: 2026-07-16 owner-directed Portfolio bridge. HCGM `paper/` is the upstream scientific source; Portfolio owns RQ/P allocation, package status, venue pressure and public routing. Current mapping is causal-effect -> RQ23/P23 preflight, learning-discoscm -> RQ16/P16 active flagship science source but Portfolio seed/not an active submission package, continuous-treatment -> independent second-wave candidate, causal-regression -> RQ25 provenance. Do not move paper sources into Portfolio. -->

## 最底层思考

经典监督学习用 $n$ 个样本直接估计一条 $x\mapsto y$ predictive law；这里把同一数据重新
理解为共享 generator $f_\theta(x,E;U)$ 的 $n$ 次 token realizations，每个 token-level slice
只暴露一次 factual evaluation。不是创建 $n$ 个互不相关的自由函数。

我们研究的是学习 token-level response function。给定最经典的 $n$ 个样本
$(x^{(n)},y^{(n)})$，每一行是一次 token realization $u^{(n)}$ 的 factual evaluation。
第一种模型把所有 rows 直接压成同一条 response function；第二种模型则把每个 token
看成共享 generator $f_\theta(x,E;U)$ 的一个 slice。接下来的问题不是独立拟合 $n$ 条
自由函数，而是如何从 $X=x$ abduct token，并学习 slices 之间可共享的生成结构。

在没有任何跨 Unit 结构约束时，单点数据无法恢复一条函数。经典监督学习本质上是在做高级的归纳法——它假设所有样本都在遵从同一个“共享规律”，认为只要数据量 $n$ 足够大，就能大力出奇迹拟合出那条曲线。我们

$$
\boxed{
\text{不再共享 response function；共享的是 response functions 的生成规律。}
}
$$

前者寻找最大公约数，后者追求有共享结构约束的极端 Personalization。

# 附录

## 顶层架构：一个研究纲领，多条独立证据线

> 2026-07-11 owner-authorized routing update：本节只更新项目架构与入口，
> 不改写上面的 living scientific seed。

HCGM 现在按 research program 理解，不等同于某一篇 regression paper。多个
论文项目放在 `hcgm/paper/` 下，是因为它们共享同一个建模语法：

```text
factual predictors / admissible evidence x^F
  -> point / Gaussian / Cauchy unit abduction about the same actual token
  -> 在稳定的共享 generator f_theta(x^Q,E;u) 中设置 factual 或 alternative query
  -> 综合 candidate-unit uncertainty 与 event-level noise
  -> 得到 predictive outcome distribution；causal contrast 需另加 intervention assumptions
```

这里的共同点是 heterogeneous unit、factual evidence、intervention-indexed
mechanism 与 reduction 的角色分离；不同论文负责检验不同 query。它们不能自动
共享 estimand、identification、support、cross-world coupling、实验结果或强 claim。
当前多篇论文使用的 Cauchy + affine/linear family 是 tractable family，不是
HCGM 的定义本身。

## 为什么独立成项目

`causal-mind/` 是更大的因果心智孵化空间。HCGM 现在需要变成一个标准科研项目，因为它要接受更硬的约束：

- claim 要能进入 paper；
- example 要能进入 toy；
- notation 要能被反驳和修正；
- assumption 要显性化；
- projection 不能替代 source。

## 当前 grow 面与 paper family

- `paper/`：多个共享 HCGM 语法、但独立维护 claim 与 evidence 的论文 / 研究线。
- `toy/`：当例子能区分不同 query/context/target commitment 时再 grow。当前已有五个可复用 toy：`toy/hcgm-regression-worked-example/`、`toy/cauchy-affine-response-kernel/`、`toy/simpson-paradox/`、`toy/berkson-paradox/` 和 `toy/surrogate-marker-paradox/`。
- `entry-site/`：统一入口网站子模块。先读 `entry-site/seed.md`，它推动网站入口的 grow；`index.html` 和部署脚本只是当前 projection，不替代 paper/toy/source。
- `entrances/`：保存 positioning、teaching 与历史四入口传播材料；它不是 active manuscript truth。

当前 paper family 路由：

```text
paper/learning-discoscm/        # active flagship: How to learn DiscoSCM?
paper/unit-mechanism-learning/  # independent general method paper
paper/token-causation/          # independent causal ontology paper
paper/unit-abducted-cate/       # DiscoCATE: HTE localization theory draft
paper/causal-regression/        # corrected precursor + prior work/code/provenance
paper/causal-effect/            # binary-treatment sibling paper
paper/continuous-treatment/     # continuous-dose sibling paper
```

`causal-regression/` 是 corrected factual-prediction precursor 与历史证据入口；
`learning-discoscm/` 从 DiscoSCM ontology 推导第一个可学习 outcome-mechanism slice，
二者不能互相替代或共享证据。
`unit-abducted-cate/` 消费一个 frozen / honestly cross-fitted abductor 作为 localization
interface，但不继承 Learning DiscoSCM 的 theorem 或 experiment truth；其 public reader 在
`entry-site/learning-discoscm/unit-abducted-cate/`。
`causal-effect/` 与 `continuous-treatment/` 分别把同一 HCGM 语法专门化到 binary
treatment 与 continuous dose；它们是 sibling papers，不是 regression 稿的附录。

2026-06-26 的 F1 reader request、feedback 与 next-grow decision 是当时四入口阶段的
review / branch-selection 记录，不再作为整个 HCGM research program 的全局 gate。
只有任务明确涉及该阶段反馈或 provenance 时，才回读这些文件。

最新 owner 表述对齐审计：

```text
_archive/phase-2026-06-26/HCGM_LATEST_EXPRESSION_ALIGNMENT_AUDIT_2026-06-24.md
```

它的边界是：基本说清楚 HCGM 如何进行 regression prediction。论文正文可以是英文，但 inline seeds 应保持中文，方便 owner review 和后续重启。

<!-- seed: 未来可能需要 references、outputs、src、experiments、benchmark、paper TeX；当前虽已有第一个 paper source 和多个 runnable toy，但还没有跨 paper/toy 反复复用的共享 substrate 需求。先把复杂度折叠在这里，不让空目录污染项目起点。 -->

## 边界

- 这不是完整 Causal Mind 项目。
- 这不是旧 DiscoSCM LaTeX 的搬家目录。
- 这还不是 codebase。
- 网站入口可以在 `entry-site/` grow，但 projection 不能替代 source。

## Canonical Paths

Project body:

```text
/Users/cms/.openclaw-causaclaw/workspace/projects/hcgm/
```

Owner-facing shared entry:

```text
/Users/cms/wehub-system-msp/causal-superintelligence/hcgm
```

Shared entry:

```text
/Users/cms/.openclaw/workspace/projects/causal-superintelligence/hcgm
```

Incubation source:

```text
/Users/cms/.openclaw/workspace/projects/causal-superintelligence/causal-mind/hcgm/
```

Phase handoff:

```text
/Users/cms/.openclaw/workspace/projects/causal-superintelligence/causal-mind/PHASE_HANDOFF_2026-06-24.md
```
