feat: 任务书 09,materials 模块与提示词

- src/materials:每种提交一个材料函数,生成给模型看的材料、第一条消息、对号清单、能读的代码版本;查询只在材料内按编号找;读提示词并算原始字节哈希;信念本按方法.md 6.10 现算。
- 账本里只存成 Json 的冻结协议、位置表、决定、结算的形状和编号规则由 materials 定义并导出。
- vocab 加 Checklist(对号清单)。
- prompts/:参考项目 3 份角色提示词、16 份任务说明,只做必要改动。
- TASK.md 补一句 unversionedNames 不存进代码版本。
- 方法.md 4.3 ① 改为"研究者任务"放信念本;结构.md vocab 上限 1150、补 materials 对外内容。

用户 2026-10-03 开工前的四个决定(选的都是推荐项):"甲:上限改 1150,只放对号清单";"甲:materials 定义并导出";"不放,改方法.md ① 的措辞";"按原提案挑"。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 04:08:46 -04:00
parent cba1678eaf
commit 446e26224e
41 changed files with 3665 additions and 10 deletions
+69
View File
@@ -0,0 +1,69 @@
import type { Ledger } from "../ledger/index.ts";
import type { Direction, MetricDefinition, Role, SubmissionKind } from "../vocab/index.ts";
// flow 交给 materials 的东西:账本里没有、只有 flow 拿得到的(任务书 09 第六部分第 1 条)。
/**
* 一份研究的事实:来自冻结的研究配置和任务。账本里的配置记录只存 Json,materials 不能引用 config、tasks,
* 所以由 flow 取好传进来。
*/
export type StudyFacts = {
finalMetric: string;
direction: Direction;
epsilon: number;
/** 已知最好,没有为 null。 */
knownBest: number | null;
/** 开放预留 λ。 */
lambda: number;
/** 正式运行总次数。 */
totalRuns: number;
/** 每人每轮提案上限 M。 */
proposalLimit: number;
factorLimit: number;
/** 最终指标和常规辅助指标的定义(tasks 的 metricDefinitions)。 */
metrics: MetricDefinition[];
/** 任务说明全文(TASK.md)。 */
taskText: string;
/** 单次正式运行的墙钟时限(秒),资源用量写"占时限几成"用。 */
wallSeconds: number;
};
/**
* 两个代码版本的比较结果。与 workspace 的 compareVersions 交回的形状相同(jev 的 codeHunks 是同样的先例),
* materials 不引用 workspace。块可以为空:空文件增删、只改可执行位都没有块,按整个文件改了算。
*/
export type LineRange = { start: number; end: number } | { after: number };
export type CodeChanges = {
files: Array<
{ path: string; change: "added" | "deleted" | "modified"; modeOnly: boolean } & (
| { binary: true }
| { binary: false; hunks: Array<{ from: LineRange; to: LineRange }> }
)
>;
diff: string;
};
/** 一份提示词文件:文字和原始字节的 sha256。 */
export type PromptFile = { text: string; hash: string };
/** 提示词目录读出来的全部文件(readPrompts)。 */
export type Prompts = { roles: Record<Role, PromptFile>; tasks: Record<SubmissionKind, PromptFile> };
/**
* 生成一份任务材料要的全部输入。全部必填,用不到的写 null:
* - changes:核验是起点到候选代码,修复是起点到上一次提交的代码,消融核验是完整代码到这一格的代码;其余为 null;
* - artifacts:解释任务要的本轮各次运行的产物(运行编号 → 文件名 → 文字);其余为 null;
* - codeRoot:能读的代码版本取出到 `<codeRoot>/<版本号>`,flow 照材料里的目录取出。
*/
export type TaskRequest = {
kind: SubmissionKind;
actor: string;
stageId: string;
/** 一个任务一个对象:候选、原提案(挑刺)或消融格;入口、讨论、志愿、提案、解释、收尾为 null。 */
object: string | null;
ledger: Ledger;
study: StudyFacts;
prompts: Prompts;
codeRoot: string;
changes: CodeChanges | null;
artifacts: Record<string, Record<string, string>> | null;
};