feat: 研究规则 rules 模块(任务书 02)

rules 是纯计算,src/rules 共 1761 行:方法.md 第六部分的全部公式、第七部分的余额与扣次、4.2 的入口分配,以及种子与规则登记表。

预期值有三个来源:方法.md 的手算例;tests/fixtures/rules/ 下不看实现写的 Python 脚本;参考项目 calc15、calc14b 里与现行方法一致的部分。审阅做了两轮,每轮都换一个全新上下文的子 Agent,提出的问题都已修复或写明不修的理由。

用户确认的约定(原话"1–8 都同意"):入池、采纳、消融中发现都用严格不等号;成本用 max(0, ĝ₀);没测的格附"含它的最好组合"的净值;战绩在分数原值上判。三个数改为严格递增后,删掉了尖峰的全部专门处理(bfb96ba)。vocab 里 Range 的说明同步改为严格递增。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 01:50:21 -04:00
parent bfb96ba7d7
commit 60c21ae346
37 changed files with 14067 additions and 3 deletions
+117
View File
@@ -0,0 +1,117 @@
// rules:方法.md 第六部分的全部公式和常数、第七部分的余额、4.2 的入口分配(docs/结构.md 第二部分)。
// 纯计算:输入数字,输出数字,不碰文件、数据库、模型,也不用全局随机数。
export {
combinations,
compareIds,
epsilonFloor,
GRID_COMBINATION_CAP,
GRID_SUBDIVISIONS,
improvement,
INDISPENSABLE_SUPPORT,
INTERACTION_CUT,
NET_TOLERANCE,
} from "./basics.ts";
export {
ablationCellMixture,
authorShares,
below,
breakpoints,
density,
forwardMergedRange,
forwardMixtures,
integrateUpperTail,
knotsMean,
mapKnots,
mapMixture,
mixtureBelow,
mixtureQuantile,
mixtureRange,
personKnots,
reserveKnots,
toImprovement,
type Component,
type Knots,
type Mixture,
type Point,
} from "./distribution.ts";
export {
adopt,
adoptionLine,
batchValue,
lossProbability,
selectBestExpected,
selectUniformRandom,
type AdoptionLineInput,
type BatchDecision,
type BatchInput,
} from "./forward.ts";
export {
ablationFinding,
inseparableGroups,
judgeExplanations,
listCells,
settleAblation,
sharedSettings,
supportOf,
synergyLabel,
totalGain,
type AblationCell,
type AblationExplanation,
type CellOutcome,
type SettleInput,
type SynergyLabel,
type ExplanationVerdict,
} from "./ablation.ts";
export {
ablationModel,
cellGrid,
evaluateCombos,
gridSize,
informationValue,
informationValueExact,
informationValueGrid,
measuredGrid,
OPEN_RESERVE,
remainingSpace,
type AblationModel,
type AblationModelInput,
type ComboParams,
type ComboValue,
} from "./value.ts";
export {
chooseBet,
pickByNet,
selectAll,
selectByValue,
selectNone,
selectRandomSameCount,
topCombo,
type BetResult,
type CellDecision,
type CellRuleInput,
type UntestedReason,
} from "./cells.ts";
export {
bitWidth,
cellIndex,
coverage,
covers,
disagreement,
entropyBits,
placement,
surprise,
worldBits,
type Placement,
} from "./bits.ts";
export { ablationCellLimit, forwardBatchSize, runBalance, type RunState } from "./budget.ts";
export { authorVsMerged, trackRecord, type Phase, type Tally } from "./record.ts";
export { assignEntries, type EntryAssignment } from "./entries.ts";
export { decisionSeed, seededRandom, seededSample } from "./random.ts";
export {
BATCH_RULES,
CELL_RULES,
runBatchRule,
runCellRule,
type BatchRuleName,
type CellRuleName,
} from "./registry.ts";