frontend-project-context 1.2.0 → 1.3.0

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.
@@ -0,0 +1,348 @@
1
+ # 18 — `1.3.0` Branch-aware Staged Context & Handoff 设计
2
+
3
+ > 权威说明:本文定义 AI Exchange Boundary 之上的可选附带能力,用于帮助现有 Coding Agent 以更小、更准确、可分阶段恢复的上下文完成目标功能;如与 [00-PRODUCT-CONSTITUTION.md](./00-PRODUCT-CONSTITUTION.md) 冲突,以产品宪法为准。
4
+ >
5
+ > 状态:`implemented-locally; A-64-through-A-73-passed; release-not-authorized`
6
+ >
7
+ > 基线:`frontend-project-context@1.2.0` 已公开发布并独立验证;Project Contract 身份、七项内核、人工权限和永久边界保持不变。
8
+
9
+ ## 1. 用户问题
10
+
11
+ 团队采用“一个需求一个分支”的开发方式。一个需求通常不能一步完成,需要经历理解、实现、局部验证、修正和合并审查等多个阶段。当前 Coding Agent 容易在长对话中反复读取完整项目说明、历史讨论、代码和验证日志,导致:
12
+
13
+ - 上下文超过宿主窗口后被压缩;
14
+ - 无关叙述稀释当前目标、项目约束和验收条件;
15
+ - 换窗口、换模型或换同事后重复解释任务现场;
16
+ - AI 只看见代码差异,却不知道修改原因、已确认决定和未完成项;
17
+ - 分支合入主分支前,代码冲突、Contract 基线变化和语义重叠没有统一的上下文审查入口;
18
+ - 每个任务的临时描述如果长期累积,会反向污染 Project Contract 和后续会话。
19
+
20
+ 该问题的目标不是“保存更多上下文”,而是让现有 Coding Agent 在每个阶段只获得完成当前功能所需的最小、准确、可追溯上下文。
21
+
22
+ ## 2. 产品定位与分类
23
+
24
+ 本能力分类为 **可选适配器协议**,不是第八项内核,也不改变 Project Contract 的唯一真源地位。
25
+
26
+ ```text
27
+ 人工批准的 Project Contract
28
+ + 宿主提供的 Task Context Plan
29
+ + 宿主提供的 changed paths / revision labels
30
+ + 前序 Stage Receipts
31
+ → 当前 Stage Context Bundle
32
+ → 现有 Coding Agent 执行开发任务
33
+ → 宿主提交新的 Stage Receipt
34
+ → Integration Review Bundle
35
+ → 人工决定是否合并或把长期事实提案到 Project Contract
36
+ ```
37
+
38
+ Frontend Project Context 只验证机器合同、核对 baseline、复用 Scope Compiler 选择合同项、生成最小派生 Bundle 和报告冲突。任务拆分、代码修改、命令执行、测试结论、Git 操作和最终功能判断仍由外部 Coding Agent、现有工具和人负责。
39
+
40
+ ## 3. 成功定义
41
+
42
+ 本能力成功时:
43
+
44
+ 1. 一个需求可以由一个模型无关 Task Context Plan 表达为多个有依赖的 Stage;
45
+ 2. 每次只编译当前 Stage,前序过程只以结构化 receipt 进入上下文;
46
+ 3. Project Contract、任务目标、当前路径、验收条件和必要证据不会在压缩或换窗口后丢失;
47
+ 4. 输出有调用方显式提供的确定性字节预算,不存在隐式无限全文模式;
48
+ 5. 分支路径只是宿主提供的候选范围信号,不被自动提升为来源或长期规则;
49
+ 6. 合并前可以只读比较任务基线、主分支变化、分支变化和阶段完成证据;
50
+ 7. 合并后任务工件不会自动进入 Contract,只有人工明确选择的长期事实继续复用既有 `propose`/`approve`;
51
+ 8. 同一输入产生同一 Bundle,过期 baseline、缺失依赖和冲突均失败封闭。
52
+
53
+ ## 4. 非目标与永久边界
54
+
55
+ 本阶段不实现:
56
+
57
+ - Provider、Agent Runtime、planner、任务执行器或自动循环;
58
+ - 自动把自然语言需求拆成 Stage;
59
+ - 修改、生成、验证或修复业务代码;
60
+ - 执行测试、构建、lint、shell 或项目脚本;
61
+ - 读取 Git diff、branch、commit、merge-base、PR 或远端平台;
62
+ - checkout、rebase、merge、commit、push 或 Git hook;
63
+ - scheduler、daemon、watcher、任务队列或多人锁;
64
+ - 自动接受 source、批准 Contract、解决冲突或晋升长期事实;
65
+ - 新的持久 store、聊天记录、AI 推理库、向量库或第二真源;
66
+ - 精确模拟不同模型的 tokenizer。
67
+
68
+ 宿主可以只读调用 Git 或平台 API,再把规范化后的相对路径和不透明 revision label 显式传入;该行为属于宿主适配器,不属于产品内核。
69
+
70
+ ## 5. 机器合同
71
+
72
+ `1.3.0` 公开四份 schema version 1:
73
+
74
+ 1. `task-context-plan.schema.json`
75
+ 2. `stage-receipt.schema.json`
76
+ 3. `stage-context-bundle.schema.json`
77
+ 4. `integration-review-bundle.schema.json`
78
+
79
+ 它们都是短生命周期交换合同,不是 store、Project Contract、approval、Git 事实或持久执行权限。`capabilities` 必须公开版本、命令、预算单位和永久边界。
80
+
81
+ ## 6. Task Context Plan schema 1
82
+
83
+ Task Context Plan 由外部 Coding Agent、人或其他宿主生成,Frontend Project Context 只负责严格验证和稳定规范化。
84
+
85
+ 最小结构:
86
+
87
+ ```json
88
+ {
89
+ "schemaVersion": 1,
90
+ "kind": "task-context-plan",
91
+ "projectId": "example-project",
92
+ "task": {
93
+ "id": "task-multi-segment-dialog",
94
+ "title": "非协议价弹窗支持多航段",
95
+ "goal": "在保持单航段行为不变的前提下展示多个航段",
96
+ "acceptance": [
97
+ { "id": "acceptance-single-segment", "text": "单航段行为保持不变" },
98
+ { "id": "acceptance-multi-segment", "text": "多航段按顺序完整展示" }
99
+ ]
100
+ },
101
+ "workspace": {
102
+ "branchLabel": "feature/multi-segment-dialog",
103
+ "baseRevision": "opaque-host-provided-value"
104
+ },
105
+ "snapshots": {
106
+ "contract": "sha256:...",
107
+ "sourcesLock": "sha256:...",
108
+ "projectionsLock": "sha256:..."
109
+ },
110
+ "budget": {
111
+ "maxUtf8Bytes": 12000,
112
+ "maxReadTargets": 12
113
+ },
114
+ "stages": [
115
+ {
116
+ "id": "stage-understand",
117
+ "title": "理解与定位",
118
+ "objective": "确认数据结构、渲染入口和回归范围",
119
+ "dependsOn": [],
120
+ "paths": ["src/components"],
121
+ "acceptanceIds": ["acceptance-single-segment"]
122
+ },
123
+ {
124
+ "id": "stage-render",
125
+ "title": "实现多航段渲染",
126
+ "objective": "完成最小渲染闭环",
127
+ "dependsOn": ["stage-understand"],
128
+ "paths": ["src/components/protocol-price-dialog.vue"],
129
+ "acceptanceIds": ["acceptance-single-segment", "acceptance-multi-segment"]
130
+ }
131
+ ]
132
+ }
133
+ ```
134
+
135
+ 冻结规则:
136
+
137
+ - 顶层和所有嵌套对象拒绝未知字段;
138
+ - task、acceptance、stage ID 稳定且唯一;
139
+ - `dependsOn` 必须引用存在的 stage,不允许循环;
140
+ - 每个 stage 必须有单一 objective、至少一个项目内相对 path 和 acceptance ID;
141
+ - path 拒绝绝对路径、`..`、项目外 realpath 和重复规范化结果;
142
+ - 同一 plan 内没有依赖关系但 path 相同或祖先/后代重叠的 stages 报告并发范围冲突;
143
+ - workspace 字段是不透明宿主标签,不证明 Git 状态;
144
+ - snapshots 必须来自当前项目公开摘要;
145
+ - budget 必须显式提供,`maxUtf8Bytes` 和 `maxReadTargets` 均为正整数;
146
+ - 拒绝 `write`、`approve`、`by`、token、secret、shell、command、provider、autoRun 或其他权限/执行字段。
147
+
148
+ ## 7. Stage Receipt schema 1
149
+
150
+ Stage Receipt 是宿主对外部执行结果的结构化陈述,不是产品自己运行测试后产生的证明,也不授予下一步权限。
151
+
152
+ ```json
153
+ {
154
+ "schemaVersion": 1,
155
+ "kind": "stage-receipt",
156
+ "projectId": "example-project",
157
+ "taskId": "task-multi-segment-dialog",
158
+ "stageId": "stage-understand",
159
+ "planDigest": "sha256:...",
160
+ "inputBundleDigest": "sha256:...",
161
+ "status": "completed",
162
+ "changedPaths": [],
163
+ "acceptanceResults": [
164
+ {
165
+ "id": "acceptance-single-segment",
166
+ "status": "observed",
167
+ "evidence": ["src/components/protocol-price-dialog.vue"]
168
+ }
169
+ ],
170
+ "verificationResults": [],
171
+ "decisions": ["保留单航段渲染分支"],
172
+ "openIssues": [],
173
+ "nextStageId": "stage-render"
174
+ }
175
+ ```
176
+
177
+ 冻结规则:
178
+
179
+ - status 只允许 `completed` 或 `blocked`;
180
+ - receipt 必须绑定 project、task、stage、plan digest 和输入 Bundle digest;
181
+ - changed/evidence path 使用与 plan 相同的项目内路径规则;
182
+ - acceptance result 只能引用 plan 中当前 stage 的 acceptance ID;
183
+ - verification result 只记录宿主提供的 ID、状态、摘要和证据引用,不含可执行 shell;
184
+ - completed 必须覆盖当前 stage 的全部 acceptance ID,blocked 必须有至少一个 open issue;
185
+ - receipt 不代表人类接受功能、不代表 Contract approval,也不能自动触发下一 Stage;
186
+ - 产品不写、覆盖、归档或删除 receipt。
187
+
188
+ ## 8. `stage-context` 命令
189
+
190
+ ```text
191
+ project-context stage-context --project PATH --plan FILE --stage STAGE_ID
192
+ [--receipt FILE...] [--changed-path RELATIVE_PATH...] [--json]
193
+ ```
194
+
195
+ 命令永远只读,并按以下顺序执行:
196
+
197
+ 1. 读取并验证当前 Project Contract 与三个 store snapshot;
198
+ 2. 验证并稳定规范化 Task Context Plan;
199
+ 3. 验证 plan project ID、三个 snapshot 和所有 receipt baseline;
200
+ 4. 解析目标 stage,检查依赖 receipt 是否完整;
201
+ 5. 验证显式 changed path,只把它作为候选范围信号;
202
+ 6. 使用 stage paths、changed paths 与现有 Scope Compiler 选择已批准 Contract items;
203
+ 7. 汇总 task goal、当前 objective、acceptance、依赖 receipt 摘要、冲突和精确 read targets;
204
+ 8. 按预算优先级生成 Stage Context Bundle;
205
+ 9. 输出稳定 digest、预算使用和 `ready | blocked` 状态。
206
+
207
+ 产品不得读取 path 对应源码正文或 Git diff。AI 按 `readTargets` 渐进读取真正需要的代码片段。
208
+
209
+ ## 9. Stage Context Bundle schema 1
210
+
211
+ Bundle 必须包含:
212
+
213
+ - project/task/stage identity;
214
+ - plan digest 和三个 project snapshots;
215
+ - task goal、当前 stage objective、acceptance;
216
+ - 完整的依赖 stage receipt 摘要;
217
+ - 当前 stage paths 和调用方 changed paths;
218
+ - 适用的 approved Contract item ID、kind、scope、value/statement 和 source ID;
219
+ - readTargets、findings、明确排除项;
220
+ - budget limit、used bytes、read target count;
221
+ - `ready | blocked` 状态和稳定 bundle digest。
222
+
223
+ 预算优先级固定为:
224
+
225
+ 1. identity、goal、objective、acceptance、snapshot 和 blocker;
226
+ 2. 适用的人工批准 Contract items;
227
+ 3. 前序 receipt 的完成状态、决定、未解决问题和证据引用;
228
+ 4. readTargets 和 changed paths;
229
+ 5. 可省略的辅助说明。
230
+
231
+ 必需内容不得截断、改写或摘要。若前四类必要内容无法放入 `maxUtf8Bytes` 或 readTargets 超过限制,Bundle 必须 blocked,并报告 `context-budget-insufficient` 或 `read-target-budget-insufficient`;调用方只能进一步收窄 stage/path 或显式提高预算。不得静默丢失 Contract item、acceptance 或 blocker。
232
+
233
+ 核心只计算规范 UTF-8 字节,不声称等于任一模型 token。宿主适配器可以在此基础上实施模型特定 token 上限,但不能改变 Bundle 语义。
234
+
235
+ ## 10. 分阶段恢复规则
236
+
237
+ - 没有依赖的 stage 可被显式选择;产品不自动选择“下一步”;
238
+ - 有依赖的 stage 只有在全部依赖 receipt 为 completed、baseline 匹配且 acceptance 覆盖完整时才 ready;
239
+ - blocked receipt 保留阻塞事实,但不能解锁后续 stage;
240
+ - plan digest、Contract snapshot 或依赖 Bundle digest 变化时,旧 receipt 立即 stale;
241
+ - 换窗口、换模型或换同事只需重新提供 plan、当前 stage、有效 receipts 和 changed paths,不携带聊天历史;
242
+ - 前序 stage 的源码正文、完整 diff、完整验证日志和对话不得进入 Bundle;
243
+ - replan 由宿主产生一份新 plan,旧 receipt 只作为外部历史证据,不自动迁移。
244
+
245
+ ## 11. `integration-review` 命令
246
+
247
+ ```text
248
+ project-context integration-review --project PATH --plan FILE
249
+ [--receipt FILE...]
250
+ [--main-changed-path RELATIVE_PATH...]
251
+ [--branch-changed-path RELATIVE_PATH...]
252
+ [--json]
253
+ ```
254
+
255
+ 所有 revision 和 changed path 都由宿主显式提供;产品不调用 Git。命令永远只读,并输出 Integration Review Bundle:
256
+
257
+ - 当前 Project Contract 与 plan snapshot 是否一致;
258
+ - 全部 stage 是否具有有效 completed receipt;
259
+ - main/branch exact path 和祖先/后代范围重叠;
260
+ - 两组路径经 Scope Compiler 映射后的 Contract item 重叠;
261
+ - source drift、pending item、Contract conflict 和 projection finding;
262
+ - receipt 声明的 out-of-stage changed path;
263
+ - 需要渐进读取的冲突路径和来源;
264
+ - 可以由人考虑晋升为长期事实的 decision candidates;
265
+ - `reviewable | blocked` 状态。
266
+
267
+ ## 12. 合并冲突分类
268
+
269
+ | 类别 | 判定 | 结果 |
270
+ | --- | --- | --- |
271
+ | `path-overlap` | main/branch path 相同或祖先/后代重叠 | 报告精确路径,要求外部审查 |
272
+ | `contract-overlap` | 两组路径命中同一 approved Contract item | 报告语义风险,不自动判定代码冲突 |
273
+ | `contract-baseline-stale` | 当前 Contract digest 与 plan 不同 | blocked,重编 plan/context |
274
+ | `source-drift` | 当前 checker 报告 changed/missing/unreadable | blocked,先走既有来源维护 |
275
+ | `stage-incomplete` | 缺少 completed receipt 或 acceptance | blocked |
276
+ | `stage-scope-escaped` | receipt changed path 不在 stage path 范围 | blocked,人工判断 replan |
277
+ | `projection-stale` | 受管 projection 过期 | 报告,合并后由人决定显式 republish |
278
+ | `decision-candidate` | receipt 中可能成为长期规则的决定 | 仅列候选,不自动 propose/approve |
279
+
280
+ Git 自身的文本冲突、测试失败和最终业务语义正确性仍由 Git、项目工具、Coding Agent 和人判断。本产品只报告上下文层的可验证事实和不确定性。
281
+
282
+ ## 13. 合并后的生命周期
283
+
284
+ Integration Review Bundle 不执行 merge。人或外部工具完成合并后:
285
+
286
+ 1. 重新运行既有 `sync` 与 `check`;
287
+ 2. 如 source 变化,继续使用 `review-source → accept-source-change → revise/deprecate → approve`;
288
+ 3. 如受管 projection stale,由人对精确输出路径执行既有 publish;
289
+ 4. receipt decision 只有在确属长期项目事实时,才通过既有 `propose → approve` 进入 Contract;
290
+ 5. plan、receipt、Stage/Integration Bundle 默认停止参与后续上下文;
291
+ 6. 产品不保存、提交、删除或归档这些工件,宿主决定放在临时目录、任务系统或分支文件中。
292
+
293
+ 合并关闭后不得把完整任务历史、聊天、diff、测试日志或所有 receipts 写入 Project Contract。长期合同只保留经过人工批准、对未来任务仍有效的项目事实和规则。
294
+
295
+ ## 14. 与 1.2.0 的复用和兼容
296
+
297
+ 直接复用:
298
+
299
+ - Project Contract、source/projection lock 与三个 snapshot;
300
+ - Scope Compiler 的 project/path-prefix/file 语义和 sibling 隔离;
301
+ - `sync --changed-path` 的显式调用方路径信号;
302
+ - checker、source drift、pending、conflict 与 projection findings;
303
+ - Assist Bundle 的 readTargets/workUnits、无 source body 和稳定排序原则;
304
+ - Action Plan/Review Bundle 的严格 schema、baseline、authority-free 和失败封闭原则。
305
+
306
+ 明确不复用:
307
+
308
+ - 1.2.0 Action Plan 只描述治理 action,不扩展为业务 Task Plan;
309
+ - Review Bundle 不承担 Stage 或 Git merge 语义;
310
+ - 不修改 Contract、proposal、source lock、projection lock、renderer、Dashboard View Model、Assist Bundle、Action Plan 或 Review Bundle schema。
311
+
312
+ `1.2.0 → 1.3.0` 不需要 store migration。未采用本适配器的项目行为完全不变。
313
+
314
+ ## 15. 实现文件图
315
+
316
+ | 文件 | 责任 |
317
+ | --- | --- |
318
+ | `src/project-context/task-context-schema.mjs` | 严格验证/规范化 Task Context Plan 与 Stage Receipt |
319
+ | `src/project-context/task-context.mjs` | Stage Bundle、预算、依赖、路径映射和 integration review 纯逻辑 |
320
+ | `src/project-context/capabilities.mjs` | 公开新命令、schema 和预算单位 |
321
+ | `src/project-context/cli.mjs` | 新增 `stage-context` 与 `integration-review` 只读入口 |
322
+ | `schemas/task-context-plan.schema.json` | Task Context Plan schema 1 |
323
+ | `schemas/stage-receipt.schema.json` | Stage Receipt schema 1 |
324
+ | `schemas/stage-context-bundle.schema.json` | Stage Context Bundle schema 1 |
325
+ | `schemas/integration-review-bundle.schema.json` | Integration Review Bundle schema 1 |
326
+ | `test/project-context/task-context.test.mjs` | A-64 至 A-73 |
327
+ | `test/release/acceptance.test.mjs` | npm 白名单、schema 和永久边界回归 |
328
+
329
+ 不得新增 child process、Git client、Provider client、tokenizer dependency、任务 store、scheduler、daemon 或业务代码执行模块。
330
+
331
+ ## 16. 冻结验收 A-64 至 A-73
332
+
333
+ - **A-64 capability 与公开 schema**:capabilities 稳定公开两个命令、四份 schema、UTF-8 byte 预算和永久边界;发布白名单包含 schema。
334
+ - **A-65 Task Context Plan**:合法 plan 稳定规范化;未知/权限/执行字段、重复 ID、循环依赖、非法路径、缺失预算和无依赖重叠 stage 失败封闭。
335
+ - **A-66 Stage 选择与依赖**:只编译显式 stage;依赖缺失/blocked/stale 时 blocked,完整 completed receipts 才 ready,不自动前进。
336
+ - **A-67 Scope 与 changed paths**:复用现有 compiler 精确选择 Contract items,保持 sibling 隔离;changed paths 只作信号,不读 Git、不成为来源。
337
+ - **A-68 确定性预算**:相同输入字节等价;默认无 source/code/diff/chat body;必要内容超限显式 blocked,不静默截断。
338
+ - **A-69 Stage Receipt**:严格绑定 plan/bundle/stage/acceptance;completed/blocked 语义完整;不含 shell、权限或伪造 approval。
339
+ - **A-70 跨窗口恢复**:只用 plan、当前 stage、有效 receipts 和 paths 可重建同一 Bundle,不依赖聊天历史或新 store。
340
+ - **A-71 Integration Review**:精确报告 main/branch path overlap、Contract item overlap、stage scope escape、incomplete receipt 和 decision candidate。
341
+ - **A-72 baseline 与恢复**:Contract/source/projection snapshot、plan 或 receipt baseline 失效立即 blocked;刷新显式输入后可确定性恢复。
342
+ - **A-73 生命周期、兼容与边界**:合并审查不执行 Git/测试/业务代码,不自动晋升决定或保存任务;A-01 至 A-63 和全部旧 CLI/发布验收继续通过,总计预期 79 项。
343
+
344
+ ## 17. 实现结果、停止条件与下一步
345
+
346
+ 用户于 2026-09-10 以 `authorize-1.3.0-branch-aware-staged-context-implementation` 明确授权冻结范围的本地实现。产品代码、四份机器 schema、两个只读 CLI 入口、capabilities、使用文档与 A-64 至 A-73 已完成,连同全部旧回归为 79/79 通过。
347
+
348
+ 实现授权已消耗,本阶段在状态同步后停止。未执行真实业务项目访问、Provider、依赖安装、产品内 Git 读取/写入、任务执行、团队试用、npm pack、registry、commit、push 或发布。79 项测试通过不等于发布授权;唯一下一步是等待用户另行授权 `1.3.0` 发布候选工件与公共 npm 发布。
package/docs/README.md CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  10. [14-FORMAL-RELEASE-READINESS.md](./14-FORMAL-RELEASE-READINESS.md)
50
50
 
51
- 记录 `1.0.0` 正式发布与 `1.0.1` README/metadata patch:包边界、项目接入、CI、迁移、A-39、registry 完整性和不伪造公共仓库链接的决定。
51
+ 记录 `1.0.0` 正式发布、`1.0.1` README/metadata patch 与 `1.2.0` AI Exchange Boundary 发布:包边界、项目接入、CI、迁移、验收、registry 完整性和不伪造公共仓库链接的决定。
52
52
 
53
53
  11. [15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md](./15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md)
54
54
 
@@ -60,22 +60,26 @@
60
60
 
61
61
  13. [17-AI-EXCHANGE-BOUNDARY-DESIGN.md](./17-AI-EXCHANGE-BOUNDARY-DESIGN.md)
62
62
 
63
- 记录 `1.2.0` 双向 AI 交换内核的冻结设计与本地实现结果:机器可发现 capability、Action Plan、只读 preflight/Review Bundle、结构化 invocation 和人工精确授权边界;A-56 至 A-63 已通过,发布仍未授权。
63
+ 记录 `1.2.0` 双向 AI 交换内核的冻结设计、实现与公共发布结果:机器可发现 capability、Action Plan、只读 preflight/Review Bundle、结构化 invocation 和人工精确授权边界;A-56 至 A-63、完整 69 项验收及 registry 工件独立验证均已通过。
64
+
65
+ 14. [18-BRANCH-AWARE-STAGED-CONTEXT-DESIGN.md](./18-BRANCH-AWARE-STAGED-CONTEXT-DESIGN.md)
66
+
67
+ 记录 `1.3.0` 可选附带协议的冻结设计与本地实现:由宿主提供任务、分支路径信号和阶段 receipt,产品只读编译当前 Stage 的预算 Context Bundle,并在合并前报告 baseline、path、Contract item 和生命周期冲突;A-64 至 A-73 及完整 79 项回归已通过,发布未授权。
64
68
 
65
69
  ## 历史证据
66
70
 
67
- 14. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
68
- 15. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
71
+ 15. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
72
+ 16. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
69
73
 
70
74
  历史文档只解释为什么不再建设任务执行 Harness。它们不是程序需求、工作流或授权来源。
71
75
 
72
76
  ## Beta 证据
73
77
 
74
- 16. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
78
+ 17. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
75
79
 
76
80
  记录首次真实项目只读接入、通用修补和同项目回归。报告中的历史“下一步”不再产生新需求。
77
81
 
78
- 17. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
82
+ 18. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
79
83
 
80
84
  记录第二个真实项目只读接入和跨项目对比:核心链路与首轮通用修补再次通过。产品宪法已经停止继续寻找项目和扩充技术发现白名单。
81
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-project-context",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Govern, compile, and verify project-local context for AI coding tools.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "scripts": {
28
28
  "check": "node --check bin/project-context.mjs && npm test",
29
- "test": "node --test test/project-context/acceptance.test.mjs test/project-context/assist.test.mjs test/project-context/cli.test.mjs test/project-context/dashboard.test.mjs test/project-context/exchange.test.mjs test/project-context/maintenance.test.mjs test/project-context/source-lifecycle.test.mjs test/release/acceptance.test.mjs",
29
+ "test": "node --test test/project-context/acceptance.test.mjs test/project-context/assist.test.mjs test/project-context/cli.test.mjs test/project-context/dashboard.test.mjs test/project-context/exchange.test.mjs test/project-context/maintenance.test.mjs test/project-context/source-lifecycle.test.mjs test/project-context/task-context.test.mjs test/release/acceptance.test.mjs",
30
30
  "prepack": "npm run check"
31
31
  },
32
32
  "engines": {
@@ -11,6 +11,7 @@
11
11
  "schemas",
12
12
  "commands",
13
13
  "actionKinds",
14
+ "contextBudget",
14
15
  "initialization",
15
16
  "initialized",
16
17
  "project",
@@ -37,11 +38,15 @@
37
38
  "capabilities",
38
39
  "contract",
39
40
  "dashboardViewModel",
41
+ "integrationReviewBundle",
40
42
  "projectionLock",
41
43
  "projectionRenderer",
42
44
  "proposal",
43
45
  "reviewBundle",
44
- "sourceLock"
46
+ "sourceLock",
47
+ "stageContextBundle",
48
+ "stageReceipt",
49
+ "taskContextPlan"
45
50
  ],
46
51
  "properties": {
47
52
  "actionPlan": { "const": 1 },
@@ -49,11 +54,15 @@
49
54
  "capabilities": { "const": 1 },
50
55
  "contract": { "type": "integer" },
51
56
  "dashboardViewModel": { "type": "integer" },
57
+ "integrationReviewBundle": { "const": 1 },
52
58
  "projectionLock": { "type": "integer" },
53
59
  "projectionRenderer": { "type": "integer" },
54
60
  "proposal": { "type": "integer" },
55
61
  "reviewBundle": { "const": 1 },
56
- "sourceLock": { "type": "integer" }
62
+ "sourceLock": { "type": "integer" },
63
+ "stageContextBundle": { "const": 1 },
64
+ "stageReceipt": { "const": 1 },
65
+ "taskContextPlan": { "const": 1 }
57
66
  }
58
67
  },
59
68
  "commands": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string" } },
@@ -75,6 +84,16 @@
75
84
  ]
76
85
  }
77
86
  },
87
+ "contextBudget": {
88
+ "type": "object",
89
+ "additionalProperties": false,
90
+ "required": ["unit", "modelTokens", "callerMustProvideLimit"],
91
+ "properties": {
92
+ "unit": { "const": "canonical-utf8-bytes" },
93
+ "modelTokens": { "const": false },
94
+ "callerMustProvideLimit": { "const": true }
95
+ }
96
+ },
78
97
  "initialization": { "enum": ["uninitialized", "partial", "initialized"] },
79
98
  "initialized": { "type": "boolean" },
80
99
  "project": {
@@ -102,6 +121,8 @@
102
121
  "dependencyInstallation",
103
122
  "automaticApproval",
104
123
  "businessCodeWrites",
124
+ "taskExecution",
125
+ "stagePathBodyReads",
105
126
  "applyPlan",
106
127
  "scheduler",
107
128
  "daemon"
@@ -114,6 +135,8 @@
114
135
  "dependencyInstallation": { "const": false },
115
136
  "automaticApproval": { "const": false },
116
137
  "businessCodeWrites": { "const": false },
138
+ "taskExecution": { "const": false },
139
+ "stagePathBodyReads": { "const": false },
117
140
  "applyPlan": { "const": false },
118
141
  "scheduler": { "const": false },
119
142
  "daemon": { "const": false }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:frontend-project-context:schema:integration-review-bundle:1",
4
+ "title": "Frontend Project Context Integration Review Bundle",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "kind", "project", "task", "workspace", "planDigest", "planSnapshots", "currentSnapshots", "mainChangedPaths", "branchChangedPaths", "receipts", "contractOverlapItemIds", "decisionCandidates", "readTargets", "findings", "excluded", "status", "bundleDigest"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "kind": { "const": "integration-review-bundle" },
11
+ "project": { "$ref": "#/$defs/identity" },
12
+ "task": { "$ref": "#/$defs/task" },
13
+ "workspace": { "$ref": "#/$defs/workspace" },
14
+ "planDigest": { "$ref": "#/$defs/digest" },
15
+ "planSnapshots": { "$ref": "#/$defs/snapshots" },
16
+ "currentSnapshots": { "$ref": "#/$defs/snapshots" },
17
+ "mainChangedPaths": { "$ref": "#/$defs/paths" },
18
+ "branchChangedPaths": { "$ref": "#/$defs/paths" },
19
+ "receipts": { "type": "array", "items": { "$ref": "#/$defs/receiptSummary" } },
20
+ "contractOverlapItemIds": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/id" } },
21
+ "decisionCandidates": { "type": "array", "items": { "$ref": "#/$defs/decisionCandidate" } },
22
+ "readTargets": { "type": "array", "items": { "$ref": "#/$defs/readTarget" } },
23
+ "findings": { "type": "array", "items": { "type": "object" } },
24
+ "excluded": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
25
+ "status": { "enum": ["reviewable", "blocked"] },
26
+ "bundleDigest": { "$ref": "#/$defs/digest" }
27
+ },
28
+ "$defs": {
29
+ "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
30
+ "id": { "type": "string", "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$" },
31
+ "text": { "type": "string", "minLength": 1 },
32
+ "paths": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
33
+ "snapshots": { "type": "object", "additionalProperties": false, "required": ["contract", "sourcesLock", "projectionsLock"], "properties": { "contract": { "$ref": "#/$defs/digest" }, "sourcesLock": { "$ref": "#/$defs/digest" }, "projectionsLock": { "$ref": "#/$defs/digest" } } },
34
+ "identity": { "type": "object", "additionalProperties": false, "required": ["id", "name"], "properties": { "id": { "$ref": "#/$defs/id" }, "name": { "$ref": "#/$defs/text" } } },
35
+ "task": { "type": "object", "additionalProperties": false, "required": ["id", "title", "goal"], "properties": { "id": { "$ref": "#/$defs/id" }, "title": { "$ref": "#/$defs/text" }, "goal": { "$ref": "#/$defs/text" } } },
36
+ "workspace": { "type": "object", "additionalProperties": false, "required": ["branchLabel", "baseRevision"], "properties": { "branchLabel": { "$ref": "#/$defs/text" }, "baseRevision": { "$ref": "#/$defs/text" } } },
37
+ "acceptanceResult": { "type": "object", "additionalProperties": false, "required": ["id", "status", "evidence"], "properties": { "id": { "$ref": "#/$defs/id" }, "status": { "enum": ["observed", "not-observed"] }, "evidence": { "$ref": "#/$defs/paths" } } },
38
+ "verificationResult": { "type": "object", "additionalProperties": false, "required": ["id", "status", "summary", "evidence"], "properties": { "id": { "$ref": "#/$defs/id" }, "status": { "enum": ["passed", "failed", "observed", "skipped"] }, "summary": { "$ref": "#/$defs/text" }, "evidence": { "$ref": "#/$defs/paths" } } },
39
+ "receiptSummary": { "type": "object", "additionalProperties": false, "required": ["stageId", "status", "inputBundleDigest", "changedPaths", "acceptanceResults", "verificationResults", "decisions", "openIssues"], "properties": { "stageId": { "$ref": "#/$defs/id" }, "status": { "enum": ["completed", "blocked"] }, "inputBundleDigest": { "$ref": "#/$defs/digest" }, "changedPaths": { "$ref": "#/$defs/paths" }, "acceptanceResults": { "type": "array", "items": { "$ref": "#/$defs/acceptanceResult" } }, "verificationResults": { "type": "array", "items": { "$ref": "#/$defs/verificationResult" } }, "decisions": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/text" } }, "openIssues": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/text" } } } },
40
+ "decisionCandidate": { "type": "object", "additionalProperties": false, "required": ["stageId", "decision"], "properties": { "stageId": { "$ref": "#/$defs/id" }, "decision": { "$ref": "#/$defs/text" } } },
41
+ "readTarget": { "type": "object", "additionalProperties": false, "required": ["path", "reason"], "properties": { "path": { "type": "string", "minLength": 1 }, "reason": { "enum": ["integration-conflict", "contract-source"] }, "sourceId": { "$ref": "#/$defs/id" } } }
42
+ }
43
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:frontend-project-context:schema:stage-context-bundle:1",
4
+ "title": "Frontend Project Context Stage Context Bundle",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "kind", "project", "task", "stage", "workspace", "planDigest", "snapshots", "dependencyReceipts", "changedPaths", "contractItems", "readTargets", "findings", "excluded", "budget", "status", "bundleDigest"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "kind": { "const": "stage-context-bundle" },
11
+ "project": { "$ref": "#/$defs/identity" },
12
+ "task": { "$ref": "#/$defs/task" },
13
+ "stage": { "$ref": "#/$defs/stage" },
14
+ "workspace": { "$ref": "#/$defs/workspace" },
15
+ "planDigest": { "$ref": "#/$defs/digest" },
16
+ "snapshots": { "$ref": "#/$defs/snapshots" },
17
+ "dependencyReceipts": { "type": "array", "items": { "$ref": "#/$defs/receiptSummary" } },
18
+ "changedPaths": { "$ref": "#/$defs/paths" },
19
+ "contractItems": { "type": "array", "items": { "$ref": "#/$defs/contractItem" } },
20
+ "readTargets": { "type": "array", "items": { "$ref": "#/$defs/readTarget" } },
21
+ "findings": { "type": "array", "items": { "type": "object" } },
22
+ "excluded": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
23
+ "budget": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["unit", "maxUtf8Bytes", "maxReadTargets", "usedUtf8Bytes", "readTargetCount"],
27
+ "properties": {
28
+ "unit": { "const": "canonical-utf8-bytes" },
29
+ "maxUtf8Bytes": { "type": "integer", "minimum": 1 },
30
+ "maxReadTargets": { "type": "integer", "minimum": 1 },
31
+ "usedUtf8Bytes": { "type": "integer", "minimum": 0 },
32
+ "readTargetCount": { "type": "integer", "minimum": 0 }
33
+ }
34
+ },
35
+ "status": { "enum": ["ready", "blocked"] },
36
+ "bundleDigest": { "$ref": "#/$defs/digest" }
37
+ },
38
+ "$defs": {
39
+ "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
40
+ "identity": { "type": "object", "additionalProperties": false, "required": ["id", "name"], "properties": { "id": { "$ref": "#/$defs/id" }, "name": { "$ref": "#/$defs/text" } } },
41
+ "id": { "type": "string", "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$" },
42
+ "text": { "type": "string", "minLength": 1 },
43
+ "paths": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
44
+ "snapshots": { "type": "object", "additionalProperties": false, "required": ["contract", "sourcesLock", "projectionsLock"], "properties": { "contract": { "$ref": "#/$defs/digest" }, "sourcesLock": { "$ref": "#/$defs/digest" }, "projectionsLock": { "$ref": "#/$defs/digest" } } },
45
+ "task": { "type": "object", "additionalProperties": false, "required": ["id", "title", "goal"], "properties": { "id": { "$ref": "#/$defs/id" }, "title": { "$ref": "#/$defs/text" }, "goal": { "$ref": "#/$defs/text" } } },
46
+ "acceptance": { "type": "object", "additionalProperties": false, "required": ["id", "text"], "properties": { "id": { "$ref": "#/$defs/id" }, "text": { "$ref": "#/$defs/text" } } },
47
+ "stage": { "type": "object", "additionalProperties": false, "required": ["id", "title", "objective", "acceptance", "paths"], "properties": { "id": { "$ref": "#/$defs/id" }, "title": { "$ref": "#/$defs/text" }, "objective": { "$ref": "#/$defs/text" }, "acceptance": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/acceptance" } }, "paths": { "$ref": "#/$defs/paths" } } },
48
+ "workspace": { "type": "object", "additionalProperties": false, "required": ["branchLabel", "baseRevision"], "properties": { "branchLabel": { "$ref": "#/$defs/text" }, "baseRevision": { "$ref": "#/$defs/text" } } },
49
+ "acceptanceResult": { "type": "object", "additionalProperties": false, "required": ["id", "status", "evidence"], "properties": { "id": { "$ref": "#/$defs/id" }, "status": { "enum": ["observed", "not-observed"] }, "evidence": { "$ref": "#/$defs/paths" } } },
50
+ "verificationResult": { "type": "object", "additionalProperties": false, "required": ["id", "status", "summary", "evidence"], "properties": { "id": { "$ref": "#/$defs/id" }, "status": { "enum": ["passed", "failed", "observed", "skipped"] }, "summary": { "$ref": "#/$defs/text" }, "evidence": { "$ref": "#/$defs/paths" } } },
51
+ "receiptSummary": { "type": "object", "additionalProperties": false, "required": ["stageId", "status", "inputBundleDigest", "changedPaths", "acceptanceResults", "verificationResults", "decisions", "openIssues"], "properties": { "stageId": { "$ref": "#/$defs/id" }, "status": { "enum": ["completed", "blocked"] }, "inputBundleDigest": { "$ref": "#/$defs/digest" }, "changedPaths": { "$ref": "#/$defs/paths" }, "acceptanceResults": { "type": "array", "items": { "$ref": "#/$defs/acceptanceResult" } }, "verificationResults": { "type": "array", "items": { "$ref": "#/$defs/verificationResult" } }, "decisions": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/text" } }, "openIssues": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/text" } } } },
52
+ "scope": { "type": "object", "additionalProperties": false, "required": ["kind"], "properties": { "kind": { "enum": ["project", "path-prefix", "file"] }, "path": { "type": "string", "minLength": 1 } } },
53
+ "contractItem": { "type": "object", "additionalProperties": false, "required": ["id", "kind", "subject", "value", "statement", "scope", "sourceIds"], "properties": { "id": { "$ref": "#/$defs/id" }, "kind": { "enum": ["fact", "policy", "reference", "validation-description"] }, "subject": { "$ref": "#/$defs/id" }, "value": {}, "statement": { "$ref": "#/$defs/text" }, "scope": { "$ref": "#/$defs/scope" }, "sourceIds": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/id" } } } },
54
+ "readTarget": { "type": "object", "additionalProperties": false, "required": ["path", "reason"], "properties": { "path": { "type": "string", "minLength": 1 }, "reason": { "enum": ["stage-scope", "host-changed-path-signal", "contract-source"] }, "sourceId": { "$ref": "#/$defs/id" } } }
55
+ }
56
+ }