project-tiny-context-harness 0.7.4 → 0.7.5

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 (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +355 -343
  3. package/assets/README.md +539 -527
  4. package/assets/README.zh-CN.md +300 -284
  5. package/assets/agents/.gitkeep +1 -1
  6. package/assets/agents/AGENTS_CORE.md +55 -53
  7. package/assets/context_templates/architecture.md +33 -33
  8. package/assets/context_templates/area.md +39 -39
  9. package/assets/context_templates/context.toml +30 -30
  10. package/assets/context_templates/deployment.md +35 -35
  11. package/assets/context_templates/global.md +51 -51
  12. package/assets/context_templates/product-surface-contract.md +64 -57
  13. package/assets/context_templates/screen-contract.md +180 -0
  14. package/assets/context_templates/verification.md +32 -32
  15. package/assets/github/.gitkeep +1 -1
  16. package/assets/github/harness.yml +41 -41
  17. package/assets/make/.gitkeep +1 -1
  18. package/assets/make/ty-context.mk +48 -48
  19. package/assets/skills/context_development_engineer/SKILL.md +92 -90
  20. package/assets/skills/context_full_project_export/SKILL.md +70 -70
  21. package/assets/skills/context_harness_upgrade/SKILL.md +60 -60
  22. package/assets/skills/context_product_plan/SKILL.md +77 -76
  23. package/assets/skills/context_surface_contract/SKILL.md +177 -162
  24. package/assets/skills/context_uiux_design/SKILL.md +108 -91
  25. package/assets/skills/long-task-workflow/SKILL.md +83 -83
  26. package/assets/skills/long-task-workflow/agents/openai.yaml +4 -4
  27. package/assets/skills/long-task-workflow/references/authority-lifecycle.md +57 -55
  28. package/assets/skills/long-task-workflow/references/contract-authoring.md +95 -91
  29. package/assets/skills/long-task-workflow/references/evidence-design.md +71 -69
  30. package/assets/skills/normal-long-task/SKILL.md +12 -12
  31. package/assets/skills/source-plan-authoring/SKILL.md +293 -290
  32. package/dist/lib/design-md.d.ts +7 -0
  33. package/dist/lib/design-md.js +47 -6
  34. package/dist/lib/doctor.js +19 -4
  35. package/dist/lib/long-task-authority-material-diff.js +28 -0
  36. package/dist/lib/long-task-authority-materials.js +14 -0
  37. package/dist/lib/long-task-authority-policy.d.ts +14 -0
  38. package/dist/lib/long-task-authority-policy.js +14 -0
  39. package/dist/lib/long-task-authority-types.d.ts +14 -0
  40. package/dist/lib/long-task-claim-definitions.js +14 -0
  41. package/dist/lib/long-task-contract-types.d.ts +14 -0
  42. package/dist/lib/long-task-product-shape.js +28 -0
  43. package/dist/lib/long-task-source-target-index.js +14 -0
  44. package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +1 -1
  45. package/migrations/README.md +15 -15
  46. package/package.json +1 -1
  47. package/source-mappings.yaml +25 -25
@@ -1,297 +1,313 @@
1
- # Project Tiny Context Harness
2
-
3
- Project Tiny Context Harness 是给 AI coding agents 用的轻量项目记忆层,也是一套由 npm 包管理的上下文与交付 Harness。它为仓库提供耐久项目记忆、轻量默认工作流,以及显式启用的 Single-Goal Rolling Delivery(单目标滚动交付)长程工作流;它不是 Agent 调度器,也不接管 Git 编排。
4
-
5
- [English](README.md)
6
-
7
- 产品原则是:**保留项目记忆,丢掉流程仪式感**。公开推广与 README 以英文主入口为准,中文文档作为二级入口。
8
-
9
- ## 为什么存在
10
-
11
- 编码 Agent 同时需要两类能力:跨会话仍然可靠的少量项目事实,以及长任务经历多轮修改或上下文压缩后仍可信的完成检查。
12
-
13
- Tiny Context 将这些能力保持为窄边界:
14
-
15
- 1. **Minimal Context**:`project_context/**` 保存产品归属、架构、契约和可重复验证等耐久事实。
16
- 2. **Workflow Contract**:普通任务使用 Context-first 的轻量默认循环和平台内部计划,不要求计划文件。
17
- 3. **Long-Task Workflow**:显式使用 `long-task-delivery-v2`、编译期 Claim Coverage、一次 Authority Lock 后的模型选择、滚动修复验证与 Live Final Gate。
18
-
19
- 它不会启动或切换模型,不会创建 Agent、分支或 worktree,不会 merge、push、创建 PR 或部署,也不会取代项目测试和人工产品验收。
20
-
21
- ## 快速开始
22
-
23
- ```powershell
24
- npx --yes project-tiny-context-harness ty-context init
25
- # 已有项目文件的仓库:
26
- npx --yes project-tiny-context-harness ty-context init --adopt
27
-
28
- npx --yes project-tiny-context-harness ty-context validate-context
29
- npx --yes project-tiny-context-harness ty-context doctor
30
- ```
31
-
32
- 更新 package-managed 表面:
33
-
34
- ```powershell
35
- npx --yes project-tiny-context-harness ty-context upgrade
36
- npx --yes project-tiny-context-harness ty-context sync
37
- ```
38
-
39
- `upgrade` 先执行安全迁移再同步;资产刷新不会推断或覆盖用户编写的 Context、Source、Delivery Contract 或历史文件。
40
-
1
+ # Project Tiny Context Harness
2
+
3
+ Project Tiny Context Harness 是给 AI coding agents 用的轻量项目记忆层,也是一套由 npm 包管理的上下文与交付 Harness。它为仓库提供耐久项目记忆、轻量默认工作流,以及显式启用的 Single-Goal Rolling Delivery(单目标滚动交付)长程工作流;它不是 Agent 调度器,也不接管 Git 编排。
4
+
5
+ [English](README.md)
6
+
7
+ 产品原则是:**保留项目记忆,丢掉流程仪式感**。公开推广与 README 以英文主入口为准,中文文档作为二级入口。
8
+
9
+ ## 为什么存在
10
+
11
+ 编码 Agent 同时需要两类能力:跨会话仍然可靠的少量项目事实,以及长任务经历多轮修改或上下文压缩后仍可信的完成检查。
12
+
13
+ Tiny Context 将这些能力保持为窄边界:
14
+
15
+ 1. **Minimal Context**:`project_context/**` 保存产品归属、架构、契约和可重复验证等耐久事实。
16
+ 2. **Workflow Contract**:普通任务使用 Context-first 的轻量默认循环和平台内部计划,不要求计划文件。
17
+ 3. **Long-Task Workflow**:显式使用 `long-task-delivery-v2`、编译期 Claim Coverage、一次 Authority Lock 后的模型选择、滚动修复验证与 Live Final Gate。
18
+
19
+ 它不会启动或切换模型,不会创建 Agent、分支或 worktree,不会 merge、push、创建 PR 或部署,也不会取代项目测试和人工产品验收。
20
+
21
+ ## 快速开始
22
+
23
+ ```powershell
24
+ npx --yes project-tiny-context-harness ty-context init
25
+ # 已有项目文件的仓库:
26
+ npx --yes project-tiny-context-harness ty-context init --adopt
27
+
28
+ npx --yes project-tiny-context-harness ty-context validate-context
29
+ npx --yes project-tiny-context-harness ty-context doctor
30
+ ```
31
+
32
+ 更新 package-managed 表面:
33
+
34
+ ```powershell
35
+ npx --yes project-tiny-context-harness ty-context upgrade
36
+ npx --yes project-tiny-context-harness ty-context sync
37
+ ```
38
+
39
+ `upgrade` 先执行安全迁移再同步;资产刷新不会推断或覆盖用户编写的 Context、Source、Delivery Contract 或历史文件。
40
+
41
41
  默认 Profile 是 `core-portable` 与 `workflow-default`。显式启用长程能力:
42
-
43
- ```powershell
44
- ty-context enable long-task
45
- ```
46
-
47
- 它会安装 `/source-plan-authoring`、`/long-task-workflow` 与完成 Hook,不安装模型 Worker、Agent runtime、调度器或 Git 编排资产。
48
-
49
- ## Minimal Context 与默认工作流
50
-
51
- 默认读取顺序是:
52
-
53
- ```text
54
- project_context/global.md
55
- project_context/architecture.md
56
- project_context/context.toml
57
- default area root
58
- manifest/trigger 命中的少量 area/role Context
59
- ```
60
-
61
- 只有近乎所有任务都需要的恢复事实才使用 `read_policy = "default"`;专业架构、契约、部署和历史细节应由任务触发按需读取。
62
-
63
- ### 双路由 Context 发现
64
-
65
- 在判断 `Context Delta` 前,Agent 不再只依赖 `triggers`、`read_when` 与 `read_policy`:
66
-
67
- 1. 先根据 `context.toml` 的 area、role、trigger 和 graph 收集候选;
68
- 2. 再从任务中提取少量高信号词,例如明确的 area/module 名、API、Schema、state、security、verification、deployment 词,对 `project_context/**` 做一次 bounded text search;
69
- 3. 合并两路候选,只读取真正相关的 Context;
70
- 4. 再判断 `Context Delta: none|required`。
71
-
72
- 这次搜索只补充语义判断,不会把所有关键词命中都当成 Authority,也不会创建向量/持久索引、缓存、Registry、search state 或第二权威。它仍可能漏掉完全不同的同义词或间接依赖,因此高风险任务还需要 Architecture Context Hit 与收尾 Conformance。
73
-
74
- `ty-context doctor` 会报告确定性的默认 Context 文件/字节规模、单文件与总量软预算超限、字节完全相同的默认文件,以及 `DESIGN.md` 权威状态。这些只是维护提示,不是新验证 Gate 或运行时状态。
75
-
76
- Context 负责耐久的意图和边界,代码负责当前实现,测试/CI/浏览器或运行时证据/人工负责行为与产品验收。
77
-
78
- 普通任务:
79
-
80
- 1. 读取 core/default Context,收集 manifest 候选;
81
- 2. 在 `project_context/**` 做一次 bounded Context search;
82
- 3. 决定 `Context Delta: none|required`;
83
- 4. 耐久语义改变时先更新 owner Context;
84
- 5. 使用平台内部计划;
85
- 6. 实现并运行项目验证;
86
- 7. 执行 Contract Conformance 与 Context drift 检查。
87
-
88
- 默认工作流不要求 `plan.md`、matrix、verdict、evidence ledger、持久检索索引或第二份执行计划。任务时长、文件数和复杂度不会自动激活长程状态。
89
-
90
- 每次交接只报告一个 Context 结果:
91
-
92
- ```text
93
- Context: updated <文件/原因>
94
- # 或
95
- Context: no durable fact change
96
- ```
97
-
98
- ### 架构与模块质量
99
-
100
- 技术架构能力属于 Minimal Context。高风险工作在平台内部计划中使用 `Architecture Context Hit`、`Decision Rationale Hit: existing|required|none` 和 `Modularity Check: none|required|exception`,不创建 Task Contract 或固定 `plan.md`。
101
-
102
- 只有新长期模块/能力、公共 API/Schema/data/persistence、source of truth/state ownership、dependency direction、跨 area、migration/security/recovery 或可复用抽象才触发架构 Gate;小修复不支付这项成本。Gate 要明确 owner、唯一事实源、依赖方向、接口/状态生命周期、失败/恢复/兼容、禁止绕过路径和项目自己的可执行架构检查。
103
-
42
+
43
+ ```powershell
44
+ ty-context enable long-task
45
+ ```
46
+
47
+ 启用长程能力会安装 `/source-plan-authoring`、`/long-task-workflow` 与完成 Hook。它不安装模型 Worker、Agent runtime、调度器、Git 编排资产或设计生成系统。
48
+
49
+ ## Minimal Context 与默认工作流
50
+
51
+ 默认读取顺序是:
52
+
53
+ ```text
54
+ project_context/global.md
55
+ project_context/architecture.md
56
+ project_context/context.toml
57
+ default area root
58
+ manifest/trigger 命中的少量 area/role Context
59
+ ```
60
+
61
+ 只有近乎所有任务都需要的恢复事实才使用 `read_policy = "default"`;专业架构、契约、部署和历史细节应由任务触发按需读取。
62
+
63
+ ### 双路由 Context 发现
64
+
65
+ 在判断 `Context Delta` 前,Agent 不再只依赖 `triggers`、`read_when` 与 `read_policy`:
66
+
67
+ 1. 先根据 `context.toml` 的 area、role、trigger 和 graph 收集候选;
68
+ 2. 再从任务中提取少量高信号词,例如明确的 area/module 名、API、Schema、state、security、verification、deployment 词,对 `project_context/**` 做一次 bounded text search;
69
+ 3. 合并两路候选,只读取真正相关的 Context;
70
+ 4. 再判断 `Context Delta: none|required`。
71
+
72
+ 这次搜索只补充语义判断,不会把所有关键词命中都当成 Authority,也不会创建向量/持久索引、缓存、Registry、search state 或第二权威。它仍可能漏掉完全不同的同义词或间接依赖,因此高风险任务还需要 Architecture Context Hit 与收尾 Conformance。
73
+
74
+ `ty-context doctor` 会报告确定性的默认 Context 文件/字节规模、单文件与总量软预算超限、字节完全相同的默认文件,以及 `DESIGN.md` 权威状态。这些只是维护提示,不是新验证 Gate 或运行时状态。
75
+
76
+ Context 负责耐久的意图和边界,代码负责当前实现,测试/CI/浏览器或运行时证据/人工负责行为与产品验收。
77
+
78
+ 普通任务:
79
+
80
+ 1. 读取 core/default Context,收集 manifest 候选;
81
+ 2. 在 `project_context/**` 做一次 bounded Context search;
82
+ 3. 决定 `Context Delta: none|required`;
83
+ 4. 耐久语义改变时先更新 owner Context;
84
+ 5. 使用平台内部计划;
85
+ 6. 实现并运行项目验证;
86
+ 7. 执行 Contract Conformance 与 Context drift 检查。
87
+
88
+ 默认工作流不要求 `plan.md`、matrix、verdict、evidence ledger、持久检索索引或第二份执行计划。任务时长、文件数和复杂度不会自动激活长程状态。
89
+
90
+ 每次交接只报告一个 Context 结果:
91
+
92
+ ```text
93
+ Context: updated <文件/原因>
94
+ # 或
95
+ Context: no durable fact change
96
+ ```
97
+
98
+ ### 架构与模块质量
99
+
100
+ 技术架构能力属于 Minimal Context。高风险工作在平台内部计划中使用 `Architecture Context Hit`、`Decision Rationale Hit: existing|required|none` 和 `Modularity Check: none|required|exception`,不创建 Task Contract 或固定 `plan.md`。
101
+
102
+ 只有新长期模块/能力、公共 API/Schema/data/persistence、source of truth/state ownership、dependency direction、跨 area、migration/security/recovery 或可复用抽象才触发架构 Gate;小修复不支付这项成本。Gate 要明确 owner、唯一事实源、依赖方向、接口/状态生命周期、失败/恢复/兼容、禁止绕过路径和项目自己的可执行架构检查。
103
+
104
104
  Harness 只路由仓库原生 lint/AST/dependency/contract check,不实现跨语言通用架构分析器。`check-modularity` 的语句数/分支风险会定位到最高风险函数和行号。
105
105
 
106
- ### 视觉交付指导
107
-
108
- 默认 Workflow 现在会在 material production UI 前执行条件式 Design Authority Check,包括新建/重做页面、主要布局/导航/主题/组件体系、高保真实现和大幅 visual polish。它读取 owning surface Context、`DESIGN.md`、唯一 authored token source/generation direction 和选定设计引用。引用分为 `exact-target`、`constraint`、`inspiration`;未配置 starter、只有风格文字或灵感图都不能授权 agent 自行发明生产布局。明确的设计任务路由到 `context_uiux_design`;已有充分权威的普通实现、局部样式修复和 throwaway prototype 仍保持轻量。
109
-
110
- 对 material 工作,`context_uiux_design` 在任务内部维护风险比例化的 Visual Coverage Set;耐久 surface/interaction 事实属于 `project_context/**`,耐久视觉语义和设计引用 registry 属于 `DESIGN.md`,versioned target 保留在项目原生路径。`context_development_engineer` 把这些意图绑定到生产组件/真实 route,只报告真正渲染和检查过的组合;实现截图不能成为它自己的目标。
111
-
112
- 显式 Long-Task 会在 Compile 前解决缺失/冲突的视觉权威,再复用现有 Requirement、Control、Assertion、proof surface、verification input 与 `external_confirmation`。浏览器视觉 AC 使用 `ui_browser`;浏览器代理不能证明可独立失败的原生目标,因此原生 proof 只能使用项目自己的 current-execution target Check,无法真实表达时保留为外部确认。冻结截图 baseline 是 verifier input,生成截图/diff 是 review artifact,主观批准保持外部。这不新增视觉 Schema、risk level、lifecycle state、Gate、必需设计目录或通用像素阈值。
113
-
114
- ### 可选 Source Plan Authoring
115
-
116
- 用户明确要求初版方案、源方案、方案源稿、Source Plan,或要求综合、细化、审计后续实现与 Contract Authoring 的 Source 时,使用 `/source-plan-authoring`。输入既可以是一份接近完成的方案,也可以只是目标,加上零散笔记、产品/技术文档、截图、图表等混合附件。用户只需说明附件角色、产品目标、参考资料是精确目标还是灵感,以及希望 Skill 细化即可;不需要先填固定问卷或整理统一大纲。
117
-
118
- 它输出一份自包含 Markdown Source Plan:
119
-
120
- - 为每份附件建立 Input Inventory,完整检查有实质含义的页面、画面与屏幕,未读内容或覆盖缺口必须显式报告,不能静默抽样;
121
- - 保留直接要求及其限定条件;
122
- - 必要推导必须标记并写明 `Derived From`;
123
- - 在对比调研或实质性的产品、技术、架构、供应商选型前,先判断哪些用户取舍会改变调研范围、候选集或推荐;如果质量与性价比、交付速度、可靠性、隐私、供应商锁定、运维成本等关键偏好不明确,就先用简短、有针对性的问题询问用户,不重复询问已有偏好,也不打断推荐不会改变的局部可逆选择;
124
- - 偏好边界明确后,再决定是否以及如何调研;外部能力、价格、额度、许可、兼容性、区域、安全与支持等时效性事实使用当前权威或一手来源。用户要求综合、细化、补全或自行判断时,默认委托方案层决策:形成有依据的合理推荐后,直接标记为 `delegated` 并记录委托语句、偏好/证据依据和准确含义,高影响方案语义本身不再触发批准;真实付款/签约、生产发布、生产数据破坏性修改、实际授权、敏感数据外发及必要法务/安全/人工审批仍保留为 `EXT`,只有输入冲突、用户明确保留、关键偏好仍缺失或无法形成可靠推荐时才进入 `DEC`/`decision_required`;
125
- - Outcome 只按可独立判断的可观察结果拆分;
126
- - 重要 Source 项使用稳定语义 Key 与显式 Anchor;
127
- - 强制技术义务使用 `OBL`,非强制实现建议使用 `HINT`;
128
- - 对交互产品,先穷举范围内的 surface,再细化到每个实质控件,分别记录页面/区域/类型/文案、位置、任务、可见与可用条件、触发/输入/校验/默认值、交互/跳转,以及 Loading、Empty、Success、Failure、Recovery、Permission、Feedback 和 Accessibility;
129
- - 明确“不算完成”的 Source 含义使用 `NCOMP`;
130
- - 每个 `RISK` 明确 Fact、单个 Affected Outcome、Basis 与 Consequence,无法确定时进入 `DEC`;Fact 精确使用 Runtime 的十个名称:`public_api_or_schema_change`、`persistent_data_change`、`data_migration`、`security_boundary_change`、`permission_boundary_change`、`irreversible_external_effect`、`critical_user_path`、`full_population_operation`、`multi_repository_change`、`weak_observability`;
131
- - 每个 AC 只代表一个 Given/When/Then 可观察场景,显式列出对应 `REQ`/`CTRL`/`OBL`/`NCOMP` Key,不能首次偷渡新需求,并在文末报告是否已可交给 Contract Authoring。
132
-
133
- 它不更新项目 Context,不绑定真实仓库 owner/path/runner,不生成 Delivery Contract YAML,不执行实现,不创建工作流状态,也不声明完成。`HINT` 不是 Material Source Item;Source Plan Skill 不输出 `ty-source-item` Marker,Marker 由后续 repository-aware Long-Task Authoring 插入。Source Plan 是 Source,不是 Contract Draft。推荐结构只是 Authoring Fast Path;普通 prose/Source Plan 或普通文本方案仍可直接作为 Long-Task Source。
134
-
135
- ## Single-Goal Rolling Delivery
136
-
137
- 只有用户显式调用 `/long-task-workflow`,或当前 worktree 已有 active long task 时才使用。它固定为:
138
-
139
- - 一个平台原生、持续的 Goal;
140
- - 一个用户选定的仓库/worktree;
141
- - 一次完整选定交付、一个 Contract、一个 Final Gate;
142
- - Outcome 依赖只表示验收就绪关系,不表示 Worker 调度;
143
- - 第一次 Authority Lock 后、正式实现前有一次用户模型选择;
144
- - 当前 Goal 内部滚动展开实现 Frontier;
145
- - targeted verify 只用于修复,永远不能 accepted;
146
- - scope-only revision 可先做无状态候选诊断,再只发起一次精确审批;
147
- - Final Gate 在一个当前快照上重跑全部 Check;
148
- - Stop Hook 在结果 stale 时阻止完成。
149
-
150
- Long-Task Contract Authoring 会尽量保留 Source 中已有的稳定 Key 与 Anchor。若未知偏好会实质改变对比调研或选型,必须先询问用户;决策标准明确后,有依据的推荐方案再把委托、偏好/证据依据和准确含义写入真实 Source,然后映射到 Contract,不能只藏在 YAML 中。这份方案委托不授权任何真实高危外部动作,高危动作继续作为显式 external confirmation。保持产品含义的结构分解和有真实证据的仓库绑定可以继续;输入冲突、用户明确保留、关键偏好缺失或没有可靠推荐的新产品语义仍进入 `decision_required`。缺少推荐 Source Plan 结构不构成阻塞,但激活前必须完成只插入标记、不改写原文的 Material Source Item 枚举。
151
-
152
- 第一次正式 Compile 成功前,`delivery-contract.yaml` 是同一份非权威 Contract Draft。`/long-task-workflow` 可以跨多轮仓库/Context 读取和 Preflight 修复持续修改它,不要求一次响应生成完整 Contract。不存在单独 Contract Draft Skill、Draft Receipt 或 Authoring State。
153
-
154
- 第一次成功 Compile 创建 Authority Lock,并返回:
155
-
156
- ```json
157
- {
158
- "execution_model_checkpoint": {
159
- "required": true,
160
- "phase": "post_authority_lock_pre_implementation",
161
- "options": ["continue_current_model", "switch_model_then_resume"]
162
- }
163
- }
164
- ```
165
-
166
- Agent 此时在实现前只暂停一次,请用户选择:继续当前模型,或切换模型后恢复同一 active Long-Task。如果用户已明确给出本任务的模型策略,则视为已完成选择。后续 `compile --revise` 返回 `required: false`,不会重复暂停。Harness 不会自动切换模型,也不持久化 acknowledgement、model route 或 checkpoint state;模型选择不是验收证据。
167
-
168
- 锁定后的修订分三类:机器可证明的单调证据增强和机械安全变化自动采用;如果唯一的受保护原因只是扩大 owner、expected-change 或 allowed-support path(可以同时带有安全的单调增强),就能用 `diagnose-revision` 在不切换 Authority 的前提下运行原 Active Authority 已有且未更换的 Check;产品/Source/Acceptance 语义变化、证明弱化、verifier 内容或 runner 变化、风险上升只给摘要,不运行候选,风险降级则直接拒绝。滚动实现遇阻本身不是 External Confirmation,也不允许删除机器可验证范围;真正的范围变化必须先成为 marked Source。诊断结果不是 Progress 或 acceptance,也不会写 pending/approval、cache、Receipt 或 marker。相关修改只在同一份 `delivery-contract.yaml` 中累计,最终由一次 `compile --revise` 生成精确 hash 与包含语义字段、Source/Product Claim 缩减、proof 缩减和 external-confirmation key 的短摘要;`status`/`resume` 投影同一个待批决策。批准并原子采用后返回 `delivery_completed_by_this_event: false`,旧证据失效并回到滚动实现或修复,完整 Final Gate 仍必须重跑。
169
-
170
- Long-Task Skill 采用渐进读取:主 `SKILL.md` 只保留目标、硬边界和阶段路由,Contract Authoring、Evidence Design 与 Authority Lifecycle 细节只在对应阶段读取一层 reference。这只是指令组织,不产生第二权威。
171
-
172
- Draft Outcome 只是 Authority Lock 前的 Outcome。Outcome 按可独立观察、判断、纵向闭环和定向验证的结果拆分,使当前 Goal 能缩小 dependency-ready 工作集、定向验证、定位失败、恢复 finding 并精确失效旧局部结果。`depends_on` 只表示 acceptance readiness。每个 Outcome 属于一个有序 Stage;Stage gate 传递依赖同 Stage 其余 Outcome,后续 Stage 依赖前置 gate。Rolling Frontier 和 Stage 状态都由普通 Outcome Progress 临时派生;Outcome 不是 Worker、scheduler task、queue 或并行单元,Stage 也没有 Receipt 或第二个 Gate。Outcome 拆分执行和诊断,不拆分完成权威,因此最终仍必须在当前最终快照运行一次完整 Final Gate。
173
-
174
- Contract 声明一个有界 target profile、非空 required product target refs,以及每个 target 的 runtime family/root entrypoint。Web/process 代理不能代替单独要求的 Native/desktop 目标;browser 目标由 Playwright 证明,Native/desktop 目标由 project binary 证明。每个 `critical_user_path` Outcome 和 Stage gate 都必须从每个 required target 的 root 证明 `target_runtime`;多 Outcome Stage gate 还必须证明至少两个不同 surface 对应同一运行时状态。
175
-
176
- 如果一个声明结果可能在代理表面通过、却在目标运行时独立失败,最早拥有可运行边界的 Outcome 必须声明项目自有的真实运行 Check,并在当前 Check 执行中启动或触达目标、从同一会话产生结构化 Observation。仓库内状态报告、截图、二进制、日志或历史运行不能单独证明目标运行时。Check 显式声明带 Key 的 Given/When 场景与 journey role;Assertion 声明 all-of Evidence Capability,并由类型化的当前执行记录证明。静态 `presence` 不能证明行为,降级路径不能替代要求的成功路径,固定输入不能证明输入变化,产生 side effect 的组件也不能自行证明其边界效果。当前 Goal 在第一个可运行切片后执行一次;后续相关修改先合并,在声明输入使 Progress stale 后、扩大依赖工作前再运行。它复用 targeted verify 与 Final Gate,不增加开放式 `platform_impact` 字段、逐平台 Progress 或替代 Gate,不要求每个 Outcome/每次编辑完整重建,也不提前取得接受权;Final Gate 仍会重跑。
177
-
178
- 只有 `weak_observability` 同时遇到多 Stage 或多个 required product runtime family 时,才额外要求一个只读 Global Product Conformance Check。它从 required root product target 启动,使用独立 Raw Execution,并在既有 Final Gate 内运行。单 Stage、单 family 继续使用原有 same-Check sensitivity,不支付额外 conformance 执行成本。
179
-
180
- 平台负责物理 Goal/会话生命周期。新会话通过 `resume` 恢复语义状态;Tiny Context 不会重建此前的物理 Turn。机器接受只覆盖 `declared_machine_authority`,并报告 `native_goal_effect: none`。完成平台原生 Goal 前,Agent 只做一次否决型核对:当前 Goal/用户语义是否全部进入 accepted marked Source,且没有 pending revision、未解 blocker 或遗漏;它只能阻止并触发修复,不能增加验收证据。
181
-
182
- ### CLI
183
-
184
- ```text
185
- ty-context long-task init <workdir>
186
- ty-context long-task preflight <workdir>
187
- ty-context long-task compile <workdir>
188
- ty-context long-task compile <workdir> --revise
189
- ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]
190
- ty-context long-task approve-authority-revision <workdir> --revision <sha>
191
- ty-context long-task explain <workdir>
192
- ty-context long-task verify <workdir> [--outcome <key>] [--check <key>]
193
- ty-context long-task status <workdir>
194
- ty-context long-task resume <workdir>
195
- ty-context long-task doctor <workdir>
196
- ty-context long-task final-gate <workdir>
197
- ty-context long-task stop-check <workdir> [--message <text>]
198
- ty-context long-task close <workdir>
199
- ty-context long-task abandon <workdir> [--force-corrupt-state]
200
- ```
106
+ ### Product Surface 与 Screen Contract
201
107
 
202
- - `init` 创建单文件 inline Outcome Compact Contract 模板。
203
- - `preflight` 应用 Compact 默认值并一次输出 Source/REQ/CTRL/OBL/AC、Stage closure、required-target/root/runner、scenario/journey、capability、external impact、Product Conformance、Context、风险、路径/Binding、Runner/Input 与 Proof 诊断;它完全只读,不创建 Authority Lock、marker、cache、progress、Receipt、pending revision、状态锁,也不运行项目 Check。
204
- - `compile` 生成 Global 与 Outcome Result/Requirement/Control-field/Non-completing/Technical Claim,拒绝未覆盖 Claim,并让第一次正式成功 Compile 成为 Authority Lock。每次结果都包含 lifecycle event、`delivery_completed_by_this_event: false`、`native_goal_effect: none` 和 next action。第一次结果附带 `execution_model_checkpoint.required: true`,后续 Compile 返回 `false`;这些字段不进入 Authority state。
205
- - `diagnose-revision` 只做无副作用候选 Compile;仅 scope-only 候选能运行 Active Authority 已有且未更换的 Check,输出固定为非验收、非 Progress、非 pending。
206
- - `compile --revise` 自动采用可证明安全的修订;受保护修订在 stdout 返回 `authority_revision_pending`、精确 decision id 与确定性 material 摘要,并继续 fail closed,直到用户批准完全相同的 id。候选内容再变会生成新 id,并使旧批准失效。采用后输出 `authority_revision_adopted` 并回到滚动执行,不表示交付完成。
207
- - `verify` 在重查 active task/revision/compiled/worktree identity 后写 scoped Progress;targeted verify 始终只是修复证据。
208
- - `status` 输出 `unverified`、`progress_passing`、`progress_failing`、`progress_stale` 或 `blocked_external`,由当前 Progress 派生 `stages`、`ready_stages` 和受 Stage 约束的 Outcome frontier,不持久化 Stage 完成。它同时报告 fresh `final_workflow_status`、target profile/state、完整 `external_confirmations` 与唯一的 `pending_authority_revision`。`progress_passing` 只能表述为定向修复证据,不能简称“Outcome 完成”;`progress_stale` 不是当前通过,`final_workflow_status: null` 表示 Goal 尚未完成。
209
- - `resume` 完全只读,恢复 task/contract identity、风险、相关 Context、Git 状态、相同的 Final/target/Stage/external/pending surface、ready Outcome、findings 和 next safe action。
210
- - `final-gate` 在完整 Check 后再次验证 active identity;并发 revision 不能产生 accepted。Receipt 把每个 Stage 派生为 `passed`、`failed`、`blocked_external` 或 `blocked_dependency`,把 `target_state` 派生为 `not_accepted`、`blocked_external` 或 Contract 精确声明的 `implementation_complete`、`target_profile_usable`、`production_release_ready`。
211
- - `stop-check` 与 `close` 自己运行 Live Final Gate,并只用 accepted identity 做 CAS clear。每次机器接受的 Stop 都给一个非阻塞 terminal-scope `systemMessage`;外部待确认时同时列出全部确认项。Final/Stop/close 输出 `acceptance_scope: declared_machine_authority` 与 `native_goal_effect: none`,close 另输出 `closed_scope: machine_authority`。`status: closed` 只表示机器 Authority 已清理,不表示原生 Goal 或完整外部交付完成。
212
- - `abandon --force-corrupt-state` 仅用于损坏/mismatch/legacy-unrecoverable 状态或遗留锁,只删除确定性 active state 与 `<workdir>/.ty-context/**`。
108
+ `context_surface_contract` 继续使用现有 `contract`、area/subdomain 和 verification 角色。`product-surface-contract.md` 负责跨页面、主层/下钻与共享职责;可选且按需读取的 `screen-contract.md` 负责单屏 entry/exit/shared state、信息层级、语义区域、导航/变体、material controls target/verification 引用。它们不新增 `design`、`screen` 或 product-surface Context role,局部样式修复也不要求补建 Screen Contract
213
109
 
214
- ### Delivery Contract
110
+ material UI 在实现前执行 **UI Authority Closure**:每个稳定 surface/control/target key 必须归类为现有 Context 已覆盖、需要 Context 更新、task-local、显式 out-of-scope 或真正 decision-required。Surface Context 负责跨页面职责,Screen/interaction Context 负责稳定层级和行为,`DESIGN.md` 负责视觉系统与引用解释,authored target 负责具体构图,Delivery Contract 只绑定并证明本次交付。出现冲突时 fail closed;当前代码、时间戳、YAML 或实现截图不能静默胜出。
215
111
 
216
- `long-task-delivery-v2` 在同一个文件中保持 Product Authority、Technical Boundary Authority 与 Acceptance Authority。Compact YAML 只省略确定性默认值,规范化后的 Contract、Authority Hash 与 Compiled Identity 和完整展开形式一致。
217
-
218
- Contract 顶层包含:
219
-
220
- - `task`:完整目标、target profile、required target refs、execution target/runtime family/root entrypoint、Source 路径、相关 Context 与 snapshot 模式;
221
- - `stages`:有序 Stage DAG 与每个 Stage 的 gate Outcome;
222
- - `risk`:`auto | standard | strict` 与明确 risk facts;
223
- - `global`:非目标、owner boundary、技术约束、禁止路径/捷径和全局 Check;
224
- - `outcomes`:可独立判断并可定向验证的纵向结果、所属 Stage、依赖、明确 success/degradation 要求、REQ、产品/控件状态与位置、稳定技术义务和命名 AC。
225
-
226
- Runner 支持 `package_script`、`project_binary`、`node_oracle`、`playwright_test`。Proof surface 支持 `ui_browser`、`runtime_behavior`、`api_contract`、`data_state`、`security_boundary`、`population_coverage`、`implementation_structure`。Execution target family 是有界的 `browser`、`native`、`desktop`、`service`、`process`、`external`,role 是 `product`、`support`、`observer`;required ref 只能指向 product target。Browser target 只能由 `playwright_test` 证明,Native/desktop target 只能由 `project_binary` 证明。
227
-
228
- ### 一个 Contract 与 Source Claim
229
-
230
- 用户选定的一次完整交付始终只有一个 Contract 和一个 Final Gate。Outcome 只按“可独立判断、可定向验证”的结果拆分;模型输出长度、YAML/文件长度、前后端层、模块数量、并行偏好或 Agent 容量都不是拆分依据。
231
-
232
- V2 强制至少一个真实 `source_path` 与一个 `source_claim`,且每个声明的 Source 文件至少包含一个 Material Item。Authoring 阶段必须在原始 Markdown 中仅插入不渲染的 `ty-source-item:start/end` 标记,不得改写 Item 原文。Marker key 与 Source Claim key 必须集合完全相等且全局唯一。
233
-
234
- 类型化 disposition 分开整体结果、Requirement/Control/Obligation/Non-completing Claim、单一命名 Acceptance Assertion、Global Constraint/Non-goal、Risk Fact/Affected Outcome、External Confirmation 与真实决策。Outcome Source Acceptance 必须原样对应一个 `<outcome>.<check>.<assertion>` criterion,并证明至少一个被独立 Source Item 支撑的非 Result Claim。`out_of_scope` 已退休:排除原本在范围内的要求只能进入 `decision_required`。
235
-
236
- `context.toml` 中仅用于未来读取的 `triggers`、`read_when`、`read_policy`、default selection 与未选节点不再进入当前 delivery Authority;当前已选 area ownership、role/dependency 与 Context 内容仍受保护。最终 Git tree 变化后仍必须重新运行 Live Final Gate。
237
-
238
- ## 确定性风险分级
239
-
240
- - **L0**:局部、可逆、可直接测试的任务走默认工作流。
241
- - **L1 standard**:多个可观察 Outcome 或需要跨会话恢复,且有可靠可执行验证。
242
- - **L2 strict**:使用同一套 Long-Task 和 Outcome 结构,但对公共 API/schema、持久数据、迁移、安全/权限边界、不可逆外部影响、全量 population,或可观察性弱的关键主路径增加更严格的 proof;不支持多仓库交付。
243
-
244
- 用户可以主动升级为 strict。显式 `standard` 低于计算出的最低级别会以 `risk_level_below_required` 失败。Strict 所需 negative、counterfactual、population、security、environment、rollback/recovery proof 由 Compiler 按风险强制。
245
-
246
- ## Evidence 与完成权威
247
-
248
- 最终接受来自当前可执行证据,不来自 Agent 文本。Evidence Adapter 由 Runner 派生:只有 `playwright_test → playwright_json_v1` 可以证明 `ui_browser`,其余 Runner 使用 `structured_json_v2` Adapter 证明非浏览器 Surface,并在需要 capability record 时输出增量 `long-task-check-result-v3` payload。V2 payload 只保留解码兼容,不能满足非 `presence` 能力。
249
-
250
- 每个 Check 声明非空、带 Key 的 `scenario.given`/`scenario.when`,并使用 `success`、`degradation`、`recovery`、`stage_gate`、`conformance` journey role。每个 Assertion 声明 `presence`、`interaction_trace`、`state_delta`、`cross_surface_consistency`、`durable_readback`、`boundary_invocation`、`external_side_effect`、`failure_injection`、`visual_render`、`target_runtime`、`input_variation` 中所需的 all-of 集合。除了静态 `presence`,每种能力恰好需要一条绑定该 Assertion 的当前执行记录;缺失、重复、未知或未声明记录全部 fail closed。Result 只能由 success Check 证明;success 与 degradation 不能共用一个 Check;外部边界从 observer target 观察;input variation 至少证明两个不同输入、两个输出 hash 和一个失败样例。
251
-
252
- 每个 Outcome 至少有一个非 Result 原子 Claim,且 `required_proof_surfaces` 必须 all-of 全覆盖。Claim-bearing Assertion 使用显式 Expected 比较;`truthy/falsy` 禁止,`exists` 仅允许证明 `implementation_structure` Obligation。
253
-
254
- Targeted verify、Progress、status、Receipt 与 compiled cache 都不是完成权威。Final Gate 要求 clean candidate commit,从 Source 重新 Compile,在同一 Git-tree snapshot 上运行全部 Global/Outcome Check,并在结束时再次校验 active identity。只有它可以生成 `machine_accepted` 或 `machine_accepted_external_pending`;后者仍必须明确列出外部确认项。
255
-
256
- ## 兼容与迁移
257
-
258
- 0.7.2 在同一个 `long-task-delivery-v2` 权威中增加 ordered Stage、required target/root entrypoint、显式 success/degradation journey 与 scenario、类型化 Evidence Capability、类型化 external impact、按风险触发的 Product Conformance,以及 terminal target/Stage projection。缺少这些字段的旧 V2 Contract 会报告可索引的人工迁移 `long-task-v2-semantic-drift-authority`;必须依据 Source 重新表达缺失语义。Upgrade 不会猜测这些含义,也不会把旧 Progress/Receipt 当作通过证据。
259
-
260
- ## 开发与验证
112
+ ### 视觉交付指导
261
113
 
262
- ```powershell
263
- npm install
264
- npm run format:check
265
- npm run typecheck --workspace project-tiny-context-harness
266
- npm run build --workspace project-tiny-context-harness
267
- npm run test:affected:list
268
- npm run test:affected
269
- npm run test:long-task:trust
270
- npm run test:long-task-performance --workspace project-tiny-context-harness
271
- npm test
272
- npm run smoke:quickstart
273
- npm run preview:pack
274
- npm run launch:check
275
- node packages/ty-context/dist/cli.js package check-source
276
- make validate-harness
277
- ```
114
+ 默认 Workflow 现在会在 material production UI 前执行 UI Authority Closure 和条件式 Design Authority Check,包括新建/重做页面、主要布局/导航/主题/组件体系、高保真实现和大幅 visual polish。它读取 owning Surface/Screen/Control Context、`DESIGN.md`、唯一 authored token source/generation direction 和选定设计引用。引用分为 `exact-target`、`constraint`、`inspiration`;未配置 starter、候选稿、只有风格文字或灵感图都不能授权 agent 自行发明生产布局;全局视觉系统 configured 也不等于每个页面 implementation-ready。独立设计资源生成由外部专用 Product Design、Figma 或原型系统负责;进入开发流程后的耐久权威采纳/修复路由到 `context_uiux_design`。已有充分权威的普通实现、局部样式修复和 throwaway prototype 仍保持轻量。
115
+
116
+ material 工作,`context_uiux_design` 在任务内部维护风险比例化的 Visual Coverage Set;耐久 surface/interaction 事实属于 `project_context/**`,耐久视觉语义和设计引用 registry 属于 `DESIGN.md`,versioned target 保留在项目原生路径。`context_development_engineer` 把这些意图绑定到生产组件/真实 route,只报告真正渲染和检查过的组合;实现截图不能成为它自己的目标。
117
+
118
+ 显式 Long-Task 会在 Compile 前解决缺失/冲突的 UI 权威,并把每个 applicable Control 的 surface、region/location、type/label、user task、visibility/availability、trigger/input/validation/default、interaction/navigation、loading/empty/success/failure/recovery/permission/feedback/accessibility 完整投影为独立 Source-backed Control Claim 和受保护产品语义;空字段不生成 Claim。仍只复用现有 Requirement、Control、Assertion、Stage、Binding、proof surface、verification input、revision 与 `external_confirmation`。
278
119
 
279
- `test:affected` 用于日常修改和修复循环;`test:long-task:trust` 是冻结候选版本后的高风险边界门,也是 PR CI 使用的层级;`npm test` 是 `main` 和发布保留的完整发布回归,不应在每次小修复后重跑。Delivery Contract 和完整 Long-Task 门仍可通过 package workspace scripts 显式执行。
120
+ combined design-and-implementation 可以先用普通 Outcome/Stage 生成候选,但 candidate/planned target 不能解锁 fidelity implementation;选定结果必须先进入真实 marked Source 与 owning registry/target,并在 Authority Lock 后通过现有 protected revision 采用。浏览器视觉 AC 使用 `ui_browser`;浏览器代理不能证明可独立失败的原生目标,因此原生 proof 只能使用项目自己的 current-execution target Check,无法真实表达时保留为外部确认。冻结截图 baseline verifier input,生成截图/diff review artifact,主观批准保持外部。这不新增 `uiux_delivery`、视觉 Claim type、risk level、lifecycle state、Gate、必需设计目录或通用像素阈值。
280
121
 
281
- 模块化门禁是 `ty-context check-modularity`;例外必须包含 `owner`、`introduced_at`、`reason`、`tracking_issue` `expiry_condition`。
122
+ `ty-context doctor` 保留兼容的项目级 `missing | unconfigured | configured` 状态,并增加 Design Authority Index、token source 和已分类 reference 的 advisory 信号。它明确不推断页面实现就绪;material surface 仍需 owning Screen/Control meaning、selected target/constraints 与项目自己的验证路径。
282
123
 
283
- ## 诚实限制
124
+ ### 外部设计资源
284
125
 
285
- - Harness 不创建或恢复平台物理 Goal/会话。
286
- - 它不能证明用户从未遗漏未声明需求。
287
- - bounded Context keyword search 仍可能漏掉同义词或间接依赖,只能补充语义判断。
288
- - Harness 不能切换 host 选择的模型,只能在第一次 Authority Lock 后要求一次用户选择。
289
- - 核心长程执行不提供并行 mutation runtime。
290
- - 它不观测平台 token 或模型调用数。
291
- - Network policy 会约束传给 runner 的代理环境,但不是操作系统 sandbox。
292
- - 同用户/管理员文件篡改、系统级 Hook 绕过不在安全边界内。
293
- - Git/PR/CI、部署与人工产品确认仍由外部系统负责。
126
+ 独立 flow、线框图、视觉候选、高保真目标、token、素材与原型由专用 Product Design、Figma、图片生成、原型工具或人工设计流程生成。Tiny Context 不复制这些成熟能力,也不要求专有插件、统一 pack schema、固定目录或固定产物数量。
294
127
 
295
- ## License
128
+ 这些输出以普通 external Source 进入默认 Workflow 或 Long-Task。candidate 与 inspiration 不授权 fidelity;selected exact target 只控制其声明的 surface/viewport/mode/state/content 条件,并且需要稳定不可变身份后才能成为影响验收的 `verification_input`。`context_uiux_design` 在下游执行 UI Authority Closure,只把耐久事实采纳到 Context/`DESIGN.md`;实现截图与 diff 仍是证据 artifact,不能自我授权为目标。
296
129
 
297
- MIT
130
+ ### 可选 Source Plan Authoring
131
+
132
+ 用户明确要求初版方案、源方案、方案源稿、Source Plan,或要求综合、细化、审计后续实现与 Contract Authoring 的 Source 时,使用 `/source-plan-authoring`。输入既可以是一份接近完成的方案,也可以只是目标,加上零散笔记、产品/技术文档、截图、图表等混合附件。用户只需说明附件角色、产品目标、参考资料是精确目标还是灵感,以及希望 Skill 细化即可;不需要先填固定问卷或整理统一大纲。
133
+
134
+ 它输出一份自包含 Markdown Source Plan:
135
+
136
+ - 为每份附件建立 Input Inventory,完整检查有实质含义的页面、画面与屏幕,未读内容或覆盖缺口必须显式报告,不能静默抽样;
137
+ - 保留直接要求及其限定条件;
138
+ - 必要推导必须标记并写明 `Derived From`;
139
+ - 在对比调研或实质性的产品、技术、架构、供应商选型前,先判断哪些用户取舍会改变调研范围、候选集或推荐;如果质量与性价比、交付速度、可靠性、隐私、供应商锁定、运维成本等关键偏好不明确,就先用简短、有针对性的问题询问用户,不重复询问已有偏好,也不打断推荐不会改变的局部可逆选择;
140
+ - 偏好边界明确后,再决定是否以及如何调研;外部能力、价格、额度、许可、兼容性、区域、安全与支持等时效性事实使用当前权威或一手来源。用户要求综合、细化、补全或自行判断时,默认委托方案层决策:形成有依据的合理推荐后,直接标记为 `delegated` 并记录委托语句、偏好/证据依据和准确含义,高影响方案语义本身不再触发批准;真实付款/签约、生产发布、生产数据破坏性修改、实际授权、敏感数据外发及必要法务/安全/人工审批仍保留为 `EXT`,只有输入冲突、用户明确保留、关键偏好仍缺失或无法形成可靠推荐时才进入 `DEC`/`decision_required`;
141
+ - Outcome 只按可独立判断的可观察结果拆分;
142
+ - 重要 Source 项使用稳定语义 Key 与显式 Anchor;
143
+ - 强制技术义务使用 `OBL`,非强制实现建议使用 `HINT`;
144
+ - 对交互产品,先穷举范围内的 surface,再细化到每个实质控件,分别记录页面/区域/类型/文案、位置、任务、可见与可用条件、触发/输入/校验/默认值、交互/跳转,以及 Loading、Empty、Success、Failure、Recovery、Permission、Feedback 和 Accessibility;
145
+ - 明确“不算完成”的 Source 含义使用 `NCOMP`;
146
+ - 每个 `RISK` 明确 Fact、单个 Affected Outcome、Basis 与 Consequence,无法确定时进入 `DEC`;Fact 精确使用 Runtime 的十个名称:`public_api_or_schema_change`、`persistent_data_change`、`data_migration`、`security_boundary_change`、`permission_boundary_change`、`irreversible_external_effect`、`critical_user_path`、`full_population_operation`、`multi_repository_change`、`weak_observability`;
147
+ - 每个 AC 只代表一个 Given/When/Then 可观察场景,显式列出对应 `REQ`/`CTRL`/`OBL`/`NCOMP` Key,不能首次偷渡新需求,并在文末报告是否已可交给 Contract Authoring。
148
+
149
+ 它不更新项目 Context,不绑定真实仓库 owner/path/runner,不生成 Delivery Contract YAML,不执行实现,不创建工作流状态,也不声明完成。`HINT` 不是 Material Source Item;Source Plan Skill 不输出 `ty-source-item` Marker,Marker 由后续 repository-aware Long-Task Authoring 插入。Source Plan 是 Source,不是 Contract Draft。推荐结构只是 Authoring Fast Path;普通 prose/Source Plan 或普通文本方案仍可直接作为 Long-Task Source。
150
+
151
+ ## Single-Goal Rolling Delivery
152
+
153
+ 只有用户显式调用 `/long-task-workflow`,或当前 worktree 已有 active long task 时才使用。它固定为:
154
+
155
+ - 一个平台原生、持续的 Goal;
156
+ - 一个用户选定的仓库/worktree;
157
+ - 一次完整选定交付、一个 Contract、一个 Final Gate;
158
+ - Outcome 依赖只表示验收就绪关系,不表示 Worker 调度;
159
+ - 第一次 Authority Lock 后、正式实现前有一次用户模型选择;
160
+ - 当前 Goal 内部滚动展开实现 Frontier;
161
+ - targeted verify 只用于修复,永远不能 accepted;
162
+ - scope-only revision 可先做无状态候选诊断,再只发起一次精确审批;
163
+ - Final Gate 在一个当前快照上重跑全部 Check;
164
+ - Stop Hook 在结果 stale 时阻止完成。
165
+
166
+ Long-Task Contract Authoring 会尽量保留 Source 中已有的稳定 Key 与 Anchor。若未知偏好会实质改变对比调研或选型,必须先询问用户;决策标准明确后,有依据的推荐方案再把委托、偏好/证据依据和准确含义写入真实 Source,然后映射到 Contract,不能只藏在 YAML 中。这份方案委托不授权任何真实高危外部动作,高危动作继续作为显式 external confirmation。保持产品含义的结构分解和有真实证据的仓库绑定可以继续;输入冲突、用户明确保留、关键偏好缺失或没有可靠推荐的新产品语义仍进入 `decision_required`。缺少推荐 Source Plan 结构不构成阻塞,但激活前必须完成只插入标记、不改写原文的 Material Source Item 枚举。
167
+
168
+ 第一次正式 Compile 成功前,`delivery-contract.yaml` 是同一份非权威 Contract Draft。`/long-task-workflow` 可以跨多轮仓库/Context 读取和 Preflight 修复持续修改它,不要求一次响应生成完整 Contract。不存在单独 Contract Draft Skill、Draft Receipt 或 Authoring State。
169
+
170
+ 第一次成功 Compile 创建 Authority Lock,并返回:
171
+
172
+ ```json
173
+ {
174
+ "execution_model_checkpoint": {
175
+ "required": true,
176
+ "phase": "post_authority_lock_pre_implementation",
177
+ "options": ["continue_current_model", "switch_model_then_resume"]
178
+ }
179
+ }
180
+ ```
181
+
182
+ Agent 此时在实现前只暂停一次,请用户选择:继续当前模型,或切换模型后恢复同一 active Long-Task。如果用户已明确给出本任务的模型策略,则视为已完成选择。后续 `compile --revise` 返回 `required: false`,不会重复暂停。Harness 不会自动切换模型,也不持久化 acknowledgement、model route 或 checkpoint state;模型选择不是验收证据。
183
+
184
+ 锁定后的修订分三类:机器可证明的单调证据增强和机械安全变化自动采用;如果唯一的受保护原因只是扩大 owner、expected-change 或 allowed-support path(可以同时带有安全的单调增强),就能用 `diagnose-revision` 在不切换 Authority 的前提下运行原 Active Authority 已有且未更换的 Check;产品/Source/Acceptance 语义变化、证明弱化、verifier 内容或 runner 变化、风险上升只给摘要,不运行候选,风险降级则直接拒绝。滚动实现遇阻本身不是 External Confirmation,也不允许删除机器可验证范围;真正的范围变化必须先成为 marked Source。诊断结果不是 Progress 或 acceptance,也不会写 pending/approval、cache、Receipt 或 marker。相关修改只在同一份 `delivery-contract.yaml` 中累计,最终由一次 `compile --revise` 生成精确 hash 与包含语义字段、Source/Product Claim 缩减、proof 缩减和 external-confirmation key 的短摘要;`status`/`resume` 投影同一个待批决策。批准并原子采用后返回 `delivery_completed_by_this_event: false`,旧证据失效并回到滚动实现或修复,完整 Final Gate 仍必须重跑。
185
+
186
+ Long-Task Skill 采用渐进读取:主 `SKILL.md` 只保留目标、硬边界和阶段路由,Contract Authoring、Evidence Design 与 Authority Lifecycle 细节只在对应阶段读取一层 reference。这只是指令组织,不产生第二权威。
187
+
188
+ Draft Outcome 只是 Authority Lock 前的 Outcome。Outcome 按可独立观察、判断、纵向闭环和定向验证的结果拆分,使当前 Goal 能缩小 dependency-ready 工作集、定向验证、定位失败、恢复 finding 并精确失效旧局部结果。`depends_on` 只表示 acceptance readiness。每个 Outcome 属于一个有序 Stage;Stage gate 传递依赖同 Stage 其余 Outcome,后续 Stage 依赖前置 gate。Rolling Frontier 和 Stage 状态都由普通 Outcome Progress 临时派生;Outcome 不是 Worker、scheduler task、queue 或并行单元,Stage 也没有 Receipt 或第二个 Gate。Outcome 拆分执行和诊断,不拆分完成权威,因此最终仍必须在当前最终快照运行一次完整 Final Gate。
189
+
190
+ Contract 声明一个有界 target profile、非空 required product target refs,以及每个 target 的 runtime family/root entrypoint。Web/process 代理不能代替单独要求的 Native/desktop 目标;browser 目标由 Playwright 证明,Native/desktop 目标由 project binary 证明。每个 `critical_user_path` Outcome 和 Stage gate 都必须从每个 required target 的 root 证明 `target_runtime`;多 Outcome Stage gate 还必须证明至少两个不同 surface 对应同一运行时状态。
191
+
192
+ 如果一个声明结果可能在代理表面通过、却在目标运行时独立失败,最早拥有可运行边界的 Outcome 必须声明项目自有的真实运行 Check,并在当前 Check 执行中启动或触达目标、从同一会话产生结构化 Observation。仓库内状态报告、截图、二进制、日志或历史运行不能单独证明目标运行时。Check 显式声明带 Key 的 Given/When 场景与 journey role;Assertion 声明 all-of Evidence Capability,并由类型化的当前执行记录证明。静态 `presence` 不能证明行为,降级路径不能替代要求的成功路径,固定输入不能证明输入变化,产生 side effect 的组件也不能自行证明其边界效果。当前 Goal 在第一个可运行切片后执行一次;后续相关修改先合并,在声明输入使 Progress stale 后、扩大依赖工作前再运行。它复用 targeted verify 与 Final Gate,不增加开放式 `platform_impact` 字段、逐平台 Progress 或替代 Gate,不要求每个 Outcome/每次编辑完整重建,也不提前取得接受权;Final Gate 仍会重跑。
193
+
194
+ 只有 `weak_observability` 同时遇到多 Stage 或多个 required product runtime family 时,才额外要求一个只读 Global Product Conformance Check。它从 required root product target 启动,使用独立 Raw Execution,并在既有 Final Gate 内运行。单 Stage、单 family 继续使用原有 same-Check sensitivity,不支付额外 conformance 执行成本。
195
+
196
+ 平台负责物理 Goal/会话生命周期。新会话通过 `resume` 恢复语义状态;Tiny Context 不会重建此前的物理 Turn。机器接受只覆盖 `declared_machine_authority`,并报告 `native_goal_effect: none`。完成平台原生 Goal 前,Agent 只做一次否决型核对:当前 Goal/用户语义是否全部进入 accepted marked Source,且没有 pending revision、未解 blocker 或遗漏;它只能阻止并触发修复,不能增加验收证据。
197
+
198
+ ### CLI
199
+
200
+ ```text
201
+ ty-context long-task init <workdir>
202
+ ty-context long-task preflight <workdir>
203
+ ty-context long-task compile <workdir>
204
+ ty-context long-task compile <workdir> --revise
205
+ ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]
206
+ ty-context long-task approve-authority-revision <workdir> --revision <sha>
207
+ ty-context long-task explain <workdir>
208
+ ty-context long-task verify <workdir> [--outcome <key>] [--check <key>]
209
+ ty-context long-task status <workdir>
210
+ ty-context long-task resume <workdir>
211
+ ty-context long-task doctor <workdir>
212
+ ty-context long-task final-gate <workdir>
213
+ ty-context long-task stop-check <workdir> [--message <text>]
214
+ ty-context long-task close <workdir>
215
+ ty-context long-task abandon <workdir> [--force-corrupt-state]
216
+ ```
217
+
218
+ - `init` 创建单文件 inline Outcome 的 Compact Contract 模板。
219
+ - `preflight` 应用 Compact 默认值并一次输出 Source/REQ/CTRL/OBL/AC、Stage closure、required-target/root/runner、scenario/journey、capability、external impact、Product Conformance、Context、风险、路径/Binding、Runner/Input 与 Proof 诊断;它完全只读,不创建 Authority Lock、marker、cache、progress、Receipt、pending revision、状态锁,也不运行项目 Check。
220
+ - `compile` 生成 Global 与 Outcome Result/Requirement/Control-field/Non-completing/Technical Claim,拒绝未覆盖 Claim,并让第一次正式成功 Compile 成为 Authority Lock。每次结果都包含 lifecycle event、`delivery_completed_by_this_event: false`、`native_goal_effect: none` 和 next action。第一次结果附带 `execution_model_checkpoint.required: true`,后续 Compile 返回 `false`;这些字段不进入 Authority state。
221
+ - `diagnose-revision` 只做无副作用候选 Compile;仅 scope-only 候选能运行 Active Authority 已有且未更换的 Check,输出固定为非验收、非 Progress、非 pending。
222
+ - `compile --revise` 自动采用可证明安全的修订;受保护修订在 stdout 返回 `authority_revision_pending`、精确 decision id 与确定性 material 摘要,并继续 fail closed,直到用户批准完全相同的 id。候选内容再变会生成新 id,并使旧批准失效。采用后输出 `authority_revision_adopted` 并回到滚动执行,不表示交付完成。
223
+ - `verify` 在重查 active task/revision/compiled/worktree identity 后写 scoped Progress;targeted verify 始终只是修复证据。
224
+ - `status` 输出 `unverified`、`progress_passing`、`progress_failing`、`progress_stale` 或 `blocked_external`,由当前 Progress 派生 `stages`、`ready_stages` 和受 Stage 约束的 Outcome frontier,不持久化 Stage 完成。它同时报告 fresh `final_workflow_status`、target profile/state、完整 `external_confirmations` 与唯一的 `pending_authority_revision`。`progress_passing` 只能表述为定向修复证据,不能简称“Outcome 完成”;`progress_stale` 不是当前通过,`final_workflow_status: null` 表示 Goal 尚未完成。
225
+ - `resume` 完全只读,恢复 task/contract identity、风险、相关 Context、Git 状态、相同的 Final/target/Stage/external/pending surface、ready Outcome、findings 和 next safe action。
226
+ - `final-gate` 在完整 Check 后再次验证 active identity;并发 revision 不能产生 accepted。Receipt 把每个 Stage 派生为 `passed`、`failed`、`blocked_external` 或 `blocked_dependency`,把 `target_state` 派生为 `not_accepted`、`blocked_external` 或 Contract 精确声明的 `implementation_complete`、`target_profile_usable`、`production_release_ready`。
227
+ - `stop-check` 与 `close` 自己运行 Live Final Gate,并只用 accepted identity 做 CAS clear。每次机器接受的 Stop 都给一个非阻塞 terminal-scope `systemMessage`;外部待确认时同时列出全部确认项。Final/Stop/close 输出 `acceptance_scope: declared_machine_authority` 与 `native_goal_effect: none`,close 另输出 `closed_scope: machine_authority`。`status: closed` 只表示机器 Authority 已清理,不表示原生 Goal 或完整外部交付完成。
228
+ - `abandon --force-corrupt-state` 仅用于损坏/mismatch/legacy-unrecoverable 状态或遗留锁,只删除确定性 active state 与 `<workdir>/.ty-context/**`。
229
+
230
+ ### Delivery Contract
231
+
232
+ `long-task-delivery-v2` 在同一个文件中保持 Product Authority、Technical Boundary Authority 与 Acceptance Authority。Compact YAML 只省略确定性默认值,规范化后的 Contract、Authority Hash 与 Compiled Identity 和完整展开形式一致。
233
+
234
+ Contract 顶层包含:
235
+
236
+ - `task`:完整目标、target profile、required target refs、execution target/runtime family/root entrypoint、Source 路径、相关 Context 与 snapshot 模式;
237
+ - `stages`:有序 Stage DAG 与每个 Stage 的 gate Outcome;
238
+ - `risk`:`auto | standard | strict` 与明确 risk facts;
239
+ - `global`:非目标、owner boundary、技术约束、禁止路径/捷径和全局 Check;
240
+ - `outcomes`:可独立判断并可定向验证的纵向结果、所属 Stage、依赖、明确 success/degradation 要求、REQ、产品/控件状态与位置、稳定技术义务和命名 AC。
241
+
242
+ Runner 支持 `package_script`、`project_binary`、`node_oracle`、`playwright_test`。Proof surface 支持 `ui_browser`、`runtime_behavior`、`api_contract`、`data_state`、`security_boundary`、`population_coverage`、`implementation_structure`。Execution target family 是有界的 `browser`、`native`、`desktop`、`service`、`process`、`external`,role 是 `product`、`support`、`observer`;required ref 只能指向 product target。Browser target 只能由 `playwright_test` 证明,Native/desktop target 只能由 `project_binary` 证明。
243
+
244
+ ### 一个 Contract 与 Source Claim
245
+
246
+ 用户选定的一次完整交付始终只有一个 Contract 和一个 Final Gate。Outcome 只按“可独立判断、可定向验证”的结果拆分;模型输出长度、YAML/文件长度、前后端层、模块数量、并行偏好或 Agent 容量都不是拆分依据。
247
+
248
+ V2 强制至少一个真实 `source_path` 与一个 `source_claim`,且每个声明的 Source 文件至少包含一个 Material Item。Authoring 阶段必须在原始 Markdown 中仅插入不渲染的 `ty-source-item:start/end` 标记,不得改写 Item 原文。Marker key 与 Source Claim key 必须集合完全相等且全局唯一。
249
+
250
+ 类型化 disposition 分开整体结果、Requirement/Control/Obligation/Non-completing Claim、单一命名 Acceptance Assertion、Global Constraint/Non-goal、Risk Fact/Affected Outcome、External Confirmation 与真实决策。Outcome Source Acceptance 必须原样对应一个 `<outcome>.<check>.<assertion>` criterion,并证明至少一个被独立 Source Item 支撑的非 Result Claim。`out_of_scope` 已退休:排除原本在范围内的要求只能进入 `decision_required`。
251
+
252
+ `context.toml` 中仅用于未来读取的 `triggers`、`read_when`、`read_policy`、default selection 与未选节点不再进入当前 delivery Authority;当前已选 area ownership、role/dependency 与 Context 内容仍受保护。最终 Git tree 变化后仍必须重新运行 Live Final Gate。
253
+
254
+ ## 确定性风险分级
255
+
256
+ - **L0**:局部、可逆、可直接测试的任务走默认工作流。
257
+ - **L1 standard**:多个可观察 Outcome 或需要跨会话恢复,且有可靠可执行验证。
258
+ - **L2 strict**:使用同一套 Long-Task 和 Outcome 结构,但对公共 API/schema、持久数据、迁移、安全/权限边界、不可逆外部影响、全量 population,或可观察性弱的关键主路径增加更严格的 proof;不支持多仓库交付。
259
+
260
+ 用户可以主动升级为 strict。显式 `standard` 低于计算出的最低级别会以 `risk_level_below_required` 失败。Strict 所需 negative、counterfactual、population、security、environment、rollback/recovery proof 由 Compiler 按风险强制。
261
+
262
+ ## Evidence 与完成权威
263
+
264
+ 最终接受来自当前可执行证据,不来自 Agent 文本。Evidence Adapter 由 Runner 派生:只有 `playwright_test → playwright_json_v1` 可以证明 `ui_browser`,其余 Runner 使用 `structured_json_v2` Adapter 证明非浏览器 Surface,并在需要 capability record 时输出增量 `long-task-check-result-v3` payload。V2 payload 只保留解码兼容,不能满足非 `presence` 能力。
265
+
266
+ 每个 Check 声明非空、带 Key 的 `scenario.given`/`scenario.when`,并使用 `success`、`degradation`、`recovery`、`stage_gate`、`conformance` journey role。每个 Assertion 声明 `presence`、`interaction_trace`、`state_delta`、`cross_surface_consistency`、`durable_readback`、`boundary_invocation`、`external_side_effect`、`failure_injection`、`visual_render`、`target_runtime`、`input_variation` 中所需的 all-of 集合。除了静态 `presence`,每种能力恰好需要一条绑定该 Assertion 的当前执行记录;缺失、重复、未知或未声明记录全部 fail closed。Result 只能由 success Check 证明;success 与 degradation 不能共用一个 Check;外部边界从 observer target 观察;input variation 至少证明两个不同输入、两个输出 hash 和一个失败样例。
267
+
268
+ 每个 Outcome 至少有一个非 Result 原子 Claim,且 `required_proof_surfaces` 必须 all-of 全覆盖。Claim-bearing Assertion 使用显式 Expected 比较;`truthy/falsy` 禁止,`exists` 仅允许证明 `implementation_structure` Obligation。
269
+
270
+ Targeted verify、Progress、status、Receipt 与 compiled cache 都不是完成权威。Final Gate 要求 clean candidate commit,从 Source 重新 Compile,在同一 Git-tree snapshot 上运行全部 Global/Outcome Check,并在结束时再次校验 active identity。只有它可以生成 `machine_accepted` 或 `machine_accepted_external_pending`;后者仍必须明确列出外部确认项。
271
+
272
+ ## 兼容与迁移
273
+
274
+ 0.7.2 在同一个 `long-task-delivery-v2` 权威中增加 ordered Stage、required target/root entrypoint、显式 success/degradation journey 与 scenario、类型化 Evidence Capability、类型化 external impact、按风险触发的 Product Conformance,以及 terminal target/Stage projection。缺少这些字段的旧 V2 Contract 会报告可索引的人工迁移 `long-task-v2-semantic-drift-authority`;必须依据 Source 重新表达缺失语义。Upgrade 不会猜测这些含义,也不会把旧 Progress/Receipt 当作通过证据。
275
+
276
+ ## 开发与验证
277
+
278
+ ```powershell
279
+ npm install
280
+ npm run format:check
281
+ npm run typecheck --workspace project-tiny-context-harness
282
+ npm run build --workspace project-tiny-context-harness
283
+ npm run test:affected:list
284
+ npm run test:affected
285
+ npm run test:long-task:trust
286
+ npm run test:long-task-performance --workspace project-tiny-context-harness
287
+ npm test
288
+ npm run smoke:quickstart
289
+ npm run preview:pack
290
+ npm run launch:check
291
+ node packages/ty-context/dist/cli.js package check-source
292
+ make validate-harness
293
+ ```
294
+
295
+ `test:affected` 用于日常修改和修复循环;`test:long-task:trust` 是冻结候选版本后的高风险边界门,也是 PR CI 使用的层级;`npm test` 是 `main` 和发布保留的完整发布回归,不应在每次小修复后重跑。Delivery Contract 和完整 Long-Task 门仍可通过 package workspace scripts 显式执行。
296
+
297
+ 模块化门禁是 `ty-context check-modularity`;例外必须包含 `owner`、`introduced_at`、`reason`、`tracking_issue` 和 `expiry_condition`。
298
+
299
+ ## 诚实限制
300
+
301
+ - Harness 不创建或恢复平台物理 Goal/会话。
302
+ - 它不能证明用户从未遗漏未声明需求。
303
+ - bounded Context keyword search 仍可能漏掉同义词或间接依赖,只能补充语义判断。
304
+ - Harness 不能切换 host 选择的模型,只能在第一次 Authority Lock 后要求一次用户选择。
305
+ - 核心长程执行不提供并行 mutation runtime。
306
+ - 它不观测平台 token 或模型调用数。
307
+ - Network policy 会约束传给 runner 的代理环境,但不是操作系统 sandbox。
308
+ - 同用户/管理员文件篡改、系统级 Hook 绕过不在安全边界内。
309
+ - Git/PR/CI、部署与人工产品确认仍由外部系统负责。
310
+
311
+ ## License
312
+
313
+ MIT