project-tiny-context-harness 0.6.2 → 0.7.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.
Files changed (30) hide show
  1. package/README.md +27 -20
  2. package/assets/README.md +29 -21
  3. package/assets/README.zh-CN.md +27 -19
  4. package/assets/skills/long-task-workflow/SKILL.md +3 -1
  5. package/assets/skills/long-task-workflow/references/authority-lifecycle.md +9 -1
  6. package/dist/commands/check-modularity.js +10 -10
  7. package/dist/commands/long-task-authoring.js +65 -65
  8. package/dist/commands/long-task-command-args.d.ts +3 -0
  9. package/dist/commands/long-task-command-args.js +20 -0
  10. package/dist/commands/long-task-revision.d.ts +1 -0
  11. package/dist/commands/long-task-revision.js +137 -0
  12. package/dist/commands/long-task.js +20 -120
  13. package/dist/lib/long-task-authority-revision-details.d.ts +2 -0
  14. package/dist/lib/long-task-authority-revision-details.js +10 -0
  15. package/dist/lib/long-task-authority-revision-diagnosis.d.ts +24 -0
  16. package/dist/lib/long-task-authority-revision-diagnosis.js +141 -0
  17. package/dist/lib/long-task-authority-revision-enforcement.d.ts +3 -1
  18. package/dist/lib/long-task-authority-revision-enforcement.js +17 -9
  19. package/dist/lib/long-task-authority-revision-summary.d.ts +11 -0
  20. package/dist/lib/long-task-authority-revision-summary.js +99 -0
  21. package/dist/lib/long-task-authority-revision-types.d.ts +44 -1
  22. package/dist/lib/long-task-authority-revision.js +9 -1
  23. package/dist/lib/long-task-delivery-compiler.d.ts +3 -0
  24. package/dist/lib/long-task-delivery-compiler.js +5 -2
  25. package/dist/lib/long-task-state.d.ts +3 -15
  26. package/dist/lib/long-task-status-v2.d.ts +2 -0
  27. package/dist/lib/long-task-status-v2.js +12 -2
  28. package/dist/lib/long-task-verifier-v2.d.ts +4 -0
  29. package/dist/lib/long-task-verifier-v2.js +1 -1
  30. package/package.json +5 -1
package/README.md CHANGED
@@ -137,7 +137,7 @@ npm ci
137
137
  npm run smoke:quickstart
138
138
  npm run preview:pack
139
139
  cd /path/to/your/test-repo
140
- npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.6.2.tgz
140
+ npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.7.0.tgz
141
141
  npx --no-install ty-context init --adopt
142
142
  make validate-context
143
143
  ```
@@ -229,16 +229,19 @@ The first successful Compile creates Authority Lock and returns:
229
229
  }
230
230
  ```
231
231
 
232
- Before product implementation, the Agent asks the user to continue with the current model or switch models and then resume the active Long-Task. A task-specific model choice already stated explicitly satisfies the checkpoint. Later Compile revisions return `{ "required": false }` and do not repeat it.
233
-
234
- Harness cannot switch the host-selected model. It creates no checkpoint file, acknowledgement state, model route, model-tier scheduler or automatic model switch. The choice is a one-time execution-cost affordance enabled by locked Authority and Final Gate protection; it is not acceptance evidence.
232
+ Before product implementation, the Agent asks the user to continue with the current model or switch models and then resume the active Long-Task. A task-specific model choice already stated explicitly satisfies the checkpoint. Later Compile revisions return `{ "required": false }` and do not repeat it.
233
+
234
+ Harness cannot switch the host-selected model. It creates no checkpoint file, acknowledgement state, model route, model-tier scheduler or automatic model switch. The choice is a one-time execution-cost affordance enabled by locked Authority and Final Gate protection; it is not acceptance evidence.
235
+
236
+ Post-lock revisions use three fail-closed paths. Proven monotonic/mechanical strengthening auto-adopts. A candidate whose only protected reasons are owner/change/support expansion may run existing active Check identities with unchanged runner/verifier authority through stateless `diagnose-revision`; safe monotonic strengthening may coexist, but those transient results write no authority, pending decision, Progress, cache or Receipt and cannot accept. Semantic changes, proof weakening, runner or verifier-content changes, and risk increases are preview-only; risk downgrade is rejected. Related edits remain in the same `delivery-contract.yaml` until one ordinary `compile --revise` emits an exact hash-bound approval summary; `status` and `resume` project that same pending decision. Exact adoption invalidates derived evidence and never replaces the complete current-snapshot Final Gate.
235
237
 
236
238
  ```text
237
239
  ty-context long-task init <workdir>
238
240
  ty-context long-task preflight <workdir>
239
- ty-context long-task compile <workdir>
240
- ty-context long-task compile <workdir> --revise
241
- ty-context long-task approve-authority-revision <workdir> --revision <sha>
241
+ ty-context long-task compile <workdir>
242
+ ty-context long-task compile <workdir> --revise
243
+ ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]
244
+ ty-context long-task approve-authority-revision <workdir> --revision <sha>
242
245
  ty-context long-task explain <workdir>
243
246
  ty-context long-task verify <workdir> [--outcome <key>] [--check <key>]
244
247
  ty-context long-task status <workdir>
@@ -250,7 +253,9 @@ ty-context long-task close <workdir>
250
253
  ty-context long-task abandon <workdir> [--force-corrupt-state]
251
254
  ```
252
255
 
253
- Compact authoring omits only deterministic defaults and normalizes identically to the expanded form. `preflight` is a read-only aggregated Source/REQ/CTRL/OBL/AC and repository check that creates no authority, state, Receipt or runner execution. Compile generates Global plus Outcome Result/Requirement/Control-field/Non-completing/Technical Claims, rejects uncovered Claims and makes the first successful formal Compile the Authority Lock. The first Compile result emits `execution_model_checkpoint.required: true`; later Compile revisions emit `required: false`. Every later authority change still compares with active authority regardless of progress, Receipt/cache deletion or implementation restoration. Source/Context/Product/Acceptance/Global/verifier content, resolved runners and verification inputs are frozen in the common-dir Active Authority V3 record.
256
+ Compact authoring omits only deterministic defaults and normalizes identically to the expanded form. `preflight` is a read-only aggregated Source/REQ/CTRL/OBL/AC and repository check that creates no authority, state, Receipt or runner execution. Compile generates Global plus Outcome Result/Requirement/Control-field/Non-completing/Technical Claims, rejects uncovered Claims and makes the first successful formal Compile the Authority Lock. The first Compile result emits `execution_model_checkpoint.required: true`; later Compile revisions emit `required: false`. Every later authority change still compares with active authority regardless of progress, Receipt/cache deletion or implementation restoration. Source/Context/Product/Acceptance/Global/verifier content, resolved runners and verification inputs are frozen in the common-dir Active Authority V3 record.
257
+
258
+ `diagnose-revision` performs a side-effect-free candidate Compile and only exercises existing active Check identities whose runner/verifier authority is unchanged. Its output explicitly denies acceptance, Progress and pending-state writes. Protected `compile --revise` emits `authority_revision_pending`, the exact decision id and a deterministic concise summary before failing closed; approving a different or stale id is rejected.
254
259
 
255
260
  Targeted verify rechecks active task/revision/compiled/worktree identity before writing scoped Progress. Counterfactual Findings first enter the owning Check Result, invalidate an otherwise passed Check, clear Claim Proofs and remain visible in status/resume; Global Checks reuse the same Progress type without a Global Outcome state. Final Gate repeats the identity check after all Checks; Stop/close clear only the accepted identity through CAS. Commit, migration, clear and abandon share one active-state lock. `abandon --force-corrupt-state` is reserved for corrupt continuity or stale lock cleanup and preserves Contract, Source, Context and Git content.
256
261
 
@@ -290,24 +295,26 @@ Release metadata declares one update mode: `sync-only`, `upgrade-required` or `m
290
295
  ## Verification
291
296
 
292
297
  ```powershell
293
- npm run format:check
294
- npm run typecheck --workspace project-tiny-context-harness
295
- npm run build --workspace project-tiny-context-harness
296
- node --test --test-concurrency=1 tests/ty-context/source-plan-authoring-skill.test.mjs tests/ty-context/sync-init-doctor.test.mjs tests/ty-context/workflow-contract-routing.test.mjs tests/ty-context/long-task-model-choice-checkpoint.test.mjs
297
- npm run test:delivery-contract --workspace project-tiny-context-harness
298
- npm run test:long-task-workflow --workspace project-tiny-context-harness
299
- npm run test:long-task-performance --workspace project-tiny-context-harness
300
- npm test
298
+ npm run format:check
299
+ npm run typecheck --workspace project-tiny-context-harness
300
+ npm run build --workspace project-tiny-context-harness
301
+ npm run test:affected:list
302
+ npm run test:affected
303
+ npm run test:long-task:trust
304
+ npm run test:long-task-performance --workspace project-tiny-context-harness
305
+ npm test
301
306
  npm run smoke:quickstart
302
307
  npm run preview:pack
303
308
  npm run launch:check
304
309
  node packages/ty-context/dist/cli.js package check-source
305
310
  make validate-harness
306
- ```
307
-
308
- The modularity gate is `ty-context check-modularity`. Scoped waivers require `owner`, `introduced_at`, `reason`, `tracking_issue` and `expiry_condition`.
311
+ ```
312
+
313
+ `test:affected` is the edit/fix loop. `test:long-task:trust` is the frozen-candidate high-impact boundary gate used by pull-request CI. `npm test` is the complete release regression retained on `main` and publish; do not rerun it after every small repair. Explicit delivery-contract and complete Long-Task gates remain available as package workspace scripts.
314
+
315
+ The modularity gate is `ty-context check-modularity`. Scoped waivers require `owner`, `introduced_at`, `reason`, `tracking_issue` and `expiry_condition`.
309
316
 
310
- The synchronized local preview tarball is named `project-tiny-context-harness-0.6.2.tgz`.
317
+ The synchronized local preview tarball is named `project-tiny-context-harness-0.7.0.tgz`.
311
318
 
312
319
  ## Community And Further Reading
313
320
 
package/assets/README.md CHANGED
@@ -137,7 +137,7 @@ The smoke packs the local workspace, installs it into a disposable repo and vali
137
137
 
138
138
  ```sh
139
139
  cd /path/to/your/test-repo
140
- npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.6.2.tgz
140
+ npm install -D /path/to/project-tiny-context-harness/tmp/ty-context/source-preview/package/project-tiny-context-harness-0.7.0.tgz
141
141
  npx --no-install ty-context init --adopt
142
142
  make validate-context
143
143
  ```
@@ -247,7 +247,8 @@ Use `/long-task-workflow` only when explicitly requested or when the current wor
247
247
  - Outcome dependencies as acceptance readiness, not worker scheduling;
248
248
  - one user model-choice checkpoint after first Authority Lock and before implementation;
249
249
  - a rolling internal implementation Frontier;
250
- - targeted repair checks that never accept;
250
+ - targeted repair checks that never accept;
251
+ - stateless scope-only revision diagnosis before one exact approval;
251
252
  - a complete Final Gate on one current snapshot;
252
253
  - a Stop Hook that rejects stale completion.
253
254
 
@@ -255,7 +256,9 @@ Long-Task Contract authoring preserves stable Source keys and anchors where prac
255
256
 
256
257
  Before the first successful formal Compile, `delivery-contract.yaml` is one non-authoritative Contract Draft. `/long-task-workflow` keeps revising that same Draft across repository/Context reads and Preflight repair rounds; it does not require one response to produce a complete Contract. Draft authoring is integrated because repository bindings and verification inputs need real evidence, Preflight findings must feed back into the same object, and a separate handoff would risk lost meaning or a second plan/authority. No standalone Contract Draft Skill, Draft Receipt or Authoring State exists.
257
258
 
258
- The first successful Compile creates Authority Lock and returns `execution_model_checkpoint.required: true`. Before implementation, the Agent asks the user to `continue_current_model` or switch models and then resume the active Long-Task. A task-specific model strategy already stated explicitly satisfies the checkpoint. Later Compile revisions return `required: false`; Harness does not switch models, persist acknowledgement/model-route state or repeat the pause.
259
+ The first successful Compile creates Authority Lock and returns `execution_model_checkpoint.required: true`. Before implementation, the Agent asks the user to `continue_current_model` or switch models and then resume the active Long-Task. A task-specific model strategy already stated explicitly satisfies the checkpoint. Later Compile revisions return `required: false`; Harness does not switch models, persist acknowledgement/model-route state or repeat the pause.
260
+
261
+ Later revisions are classified into three paths. Formally monotonic evidence strengthening and other proven mechanical-safe changes auto-adopt. A candidate whose only protected reasons are owner, expected-change or allowed-support expansion may be exercised through `diagnose-revision` using existing active Check identities whose runner and verifier are unchanged; safe monotonic strengthening may coexist, and the results remain transient repair diagnostics rather than Progress or acceptance. Product/Source/Acceptance semantic changes, proof weakening, verifier-content or runner changes, and risk increases are preview-only and require the exact revision identity; risk downgrade remains rejected outright. Diagnosis never changes the active Authority or writes pending/approval state, cache, Progress or Receipt, so related edits can accumulate in the same `delivery-contract.yaml` before one `compile --revise` approval request. The pending decision contains a concise hash-bound summary and is projected by `status`/`resume`; adoption invalidates derived evidence and the complete Final Gate remains mandatory.
259
262
 
260
263
  The package-managed Long-Task Skill uses progressive disclosure: its main `SKILL.md` keeps the objective, boundaries and phase routing; one-level references are read only for Contract authoring, evidence design or authority lifecycle. This reduces routine instruction load without moving any rule into a second authority. When Source or controlling Context declares an architecture invariant, the Contract uses existing technical obligations/global constraints/forbidden shortcuts, owner/path/Binding boundaries and a project-owned executable Check. Functional acceptance cannot substitute when the architecture invariant can fail independently.
261
264
 
@@ -268,9 +271,10 @@ The platform owns physical Goal/session lifecycle. A later session runs `resume`
268
271
  ```text
269
272
  ty-context long-task init <workdir>
270
273
  ty-context long-task preflight <workdir>
271
- ty-context long-task compile <workdir>
272
- ty-context long-task compile <workdir> --revise
273
- ty-context long-task approve-authority-revision <workdir> --revision <sha>
274
+ ty-context long-task compile <workdir>
275
+ ty-context long-task compile <workdir> --revise
276
+ ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]
277
+ ty-context long-task approve-authority-revision <workdir> --revision <sha>
274
278
  ty-context long-task explain <workdir>
275
279
  ty-context long-task verify <workdir> [--outcome <key>] [--check <key>]
276
280
  ty-context long-task status <workdir>
@@ -284,10 +288,12 @@ ty-context long-task abandon <workdir> [--force-corrupt-state]
284
288
 
285
289
  - `init` creates one Compact inline-Outcome Contract template.
286
290
  - `preflight` applies Compact defaults and reports all discoverable Source/REQ/CTRL/OBL/AC, Context, risk, path/binding, runner/input and proof diagnostics. Exact duplicate diagnostics are merged with `occurrences`; known problems may include stable `refs` and a safe `repair_hint` that never weakens authority or invents product semantics. It is read-only: no Authority Lock, marker, cache, progress, Receipt, pending revision, state lock or project Check.
287
- - `compile` generates Global plus Outcome Result/Requirement/Control-field/Non-completing/Technical Claims, rejects uncovered Claims, preserves an immutable first baseline and makes the first successful formal Compile the Authority Lock. The first result also includes `execution_model_checkpoint.required: true`; later Compile results return `required: false`. Every revision compares against active authority regardless of progress, Receipt/cache deletion or implementation restoration. Source/Context/Product/Acceptance/Global/verifier materials, owner/binding authority, resolved runners and verification inputs are frozen in the common-dir Active Authority V3 snapshot; the model-choice result is not stored as Authority state.
291
+ - `compile` generates Global plus Outcome Result/Requirement/Control-field/Non-completing/Technical Claims, rejects uncovered Claims, preserves an immutable first baseline and makes the first successful formal Compile the Authority Lock. The first result also includes `execution_model_checkpoint.required: true`; later Compile results return `required: false`. Every revision compares against active authority regardless of progress, Receipt/cache deletion or implementation restoration. Source/Context/Product/Acceptance/Global/verifier materials, owner/binding authority, resolved runners and verification inputs are frozen in the common-dir Active Authority V3 snapshot; the model-choice result is not stored as Authority state.
292
+ - `diagnose-revision` performs a side-effect-free candidate Compile. Only a scope-only candidate may run existing active Check identities with unchanged runner/verifier authority; semantic changes, proof weakening, runner or verifier-content changes, and risk increases are summarized without runner execution, while risk downgrade is rejected. Output always has `acceptance_authorized: false`, `progress_written: false` and `pending_revision_written: false`.
293
+ - `compile --revise` auto-adopts proven-safe revisions. Protected revisions return `authority_revision_pending` on stdout plus the exact decision id and deterministic approval summary, then fail closed until `approve-authority-revision` approves that exact id. Candidate edits produce a new id and invalidate the old approval.
288
294
  - `verify` writes scoped per-Check Progress Records only after rechecking active task/revision/compiled/worktree identity. A concurrent revision returns `active_authority_changed_during_verify` and writes no stale progress.
289
- - `status` reports each Outcome as `unverified`, `progress_passing`, `progress_failing`, `progress_stale` or `blocked_external`. It also reports the fresh Final Receipt as `final_workflow_status` (or `null` after drift) and the active Contract's complete `external_confirmations`. It reads the common-dir authority snapshot and reports a missing or mismatched workdir cache as a repairable diagnostic.
290
- - `resume` is read-only and reports task identity, risk, relevant Context, Git state, the same `final_workflow_status` and external confirmations, ready Outcomes, findings and the next safe action from the common-dir authority snapshot.
295
+ - `status` reports each Outcome as `unverified`, `progress_passing`, `progress_failing`, `progress_stale` or `blocked_external`. It also reports the fresh Final Receipt as `final_workflow_status` (or `null` after drift), the active Contract's complete `external_confirmations` and the single `pending_authority_revision` decision when present. It reads the common-dir authority snapshot and reports a missing or mismatched workdir cache as a repairable diagnostic.
296
+ - `resume` is read-only and reports task identity, risk, relevant Context, Git state, the same Final/external/pending decision surfaces, ready Outcomes, findings and the next safe action from the common-dir authority snapshot.
291
297
  - `final-gate` requires a clean candidate commit, recompiles source authority, reruns every required Check on one Git-tree snapshot and rechecks active identity before acceptance.
292
298
  - `stop-check` and `close` run that Live Final Gate themselves. They never trust status, progress, a Receipt or compiled cache for acceptance; success clears only the accepted identity through CAS. When machine scope passes with external work pending, the Stop Hook allows stopping but shows a non-blocking `systemMessage`; `close` returns `workflow_status` plus all `external_confirmations`. `status: closed` means only that machine Authority was cleared, not that complete external delivery finished.
293
299
  - `abandon` is explicit non-success cleanup. `--force-corrupt-state` is reserved for invalid/mismatched/legacy-unrecoverable state or a stale active lock and removes only deterministic local active state plus `<workdir>/.ty-context/**`; Contract, Source, Context and Git content are preserved.
@@ -436,24 +442,26 @@ Release metadata declares one update mode: `sync-only`, `upgrade-required` or `m
436
442
 
437
443
  ```powershell
438
444
  npm install
439
- npm run format:check
440
- npm run typecheck --workspace project-tiny-context-harness
441
- npm run build --workspace project-tiny-context-harness
442
- node --test --test-concurrency=1 tests/ty-context/source-plan-authoring-skill.test.mjs tests/ty-context/sync-init-doctor.test.mjs tests/ty-context/workflow-contract-routing.test.mjs tests/ty-context/long-task-model-choice-checkpoint.test.mjs
443
- npm run test:delivery-contract --workspace project-tiny-context-harness
444
- npm run test:long-task-workflow --workspace project-tiny-context-harness
445
- npm run test:long-task-performance --workspace project-tiny-context-harness
446
- npm test
445
+ npm run format:check
446
+ npm run typecheck --workspace project-tiny-context-harness
447
+ npm run build --workspace project-tiny-context-harness
448
+ npm run test:affected:list
449
+ npm run test:affected
450
+ npm run test:long-task:trust
451
+ npm run test:long-task-performance --workspace project-tiny-context-harness
452
+ npm test
447
453
  npm run smoke:quickstart
448
454
  npm run preview:pack
449
455
  npm run launch:check
450
456
  node packages/ty-context/dist/cli.js package check-source
451
457
  make validate-harness
452
- ```
453
-
454
- The modularity gate is `ty-context check-modularity`. Scoped waivers require `owner`, `introduced_at`, `reason`, `tracking_issue` and `expiry_condition`.
458
+ ```
459
+
460
+ `test:affected` is the edit/fix loop. `test:long-task:trust` is the frozen-candidate high-impact boundary gate used by pull-request CI. `npm test` is the complete release regression retained on `main` and publish; do not rerun it after every small repair. Explicit delivery-contract and complete Long-Task gates remain available as package workspace scripts.
461
+
462
+ The modularity gate is `ty-context check-modularity`. Scoped waivers require `owner`, `introduced_at`, `reason`, `tracking_issue` and `expiry_condition`.
455
463
 
456
- `npm run preview:pack` produces a local preview named `project-tiny-context-harness-0.6.2.tgz` under the preview output directory.
464
+ `npm run preview:pack` produces a local preview named `project-tiny-context-harness-0.7.0.tgz` under the preview output directory.
457
465
 
458
466
  ## Community And Further Reading
459
467
 
@@ -140,7 +140,8 @@ Harness 只路由仓库原生 lint/AST/dependency/contract check,不实现跨
140
140
  - Outcome 依赖只表示验收就绪关系,不表示 Worker 调度;
141
141
  - 第一次 Authority Lock 后、正式实现前有一次用户模型选择;
142
142
  - 当前 Goal 内部滚动展开实现 Frontier;
143
- - targeted verify 只用于修复,永远不能 accepted;
143
+ - targeted verify 只用于修复,永远不能 accepted;
144
+ - scope-only revision 可先做无状态候选诊断,再只发起一次精确审批;
144
145
  - Final Gate 在一个当前快照上重跑全部 Check;
145
146
  - Stop Hook 在结果 stale 时阻止完成。
146
147
 
@@ -160,7 +161,9 @@ Long-Task Contract Authoring 会尽量保留 Source 中已有的稳定 Key 与 A
160
161
  }
161
162
  ```
162
163
 
163
- Agent 此时在实现前只暂停一次,请用户选择:继续当前模型,或切换模型后恢复同一 active Long-Task。如果用户已明确给出本任务的模型策略,则视为已完成选择。后续 `compile --revise` 返回 `required: false`,不会重复暂停。Harness 不会自动切换模型,也不持久化 acknowledgement、model route 或 checkpoint state;模型选择不是验收证据。
164
+ Agent 此时在实现前只暂停一次,请用户选择:继续当前模型,或切换模型后恢复同一 active Long-Task。如果用户已明确给出本任务的模型策略,则视为已完成选择。后续 `compile --revise` 返回 `required: false`,不会重复暂停。Harness 不会自动切换模型,也不持久化 acknowledgement、model route 或 checkpoint state;模型选择不是验收证据。
165
+
166
+ 锁定后的修订分三类:机器可证明的单调证据增强和机械安全变化自动采用;如果唯一的受保护原因只是扩大 owner、expected-change 或 allowed-support path(可以同时带有安全的单调增强),就能用 `diagnose-revision` 在不切换 Authority 的前提下运行原 Active Authority 已有且未更换的 Check;产品/Source/Acceptance 语义变化、证明弱化、verifier 内容或 runner 变化、风险上升只给摘要,不运行候选,风险降级则直接拒绝。诊断结果不是 Progress 或 acceptance,也不会写 pending/approval、cache、Receipt 或 marker。相关修改只在同一份 `delivery-contract.yaml` 中累计,最终由一次 `compile --revise` 生成带短摘要的精确 hash;`status`/`resume` 投影同一个待批决策。批准并原子采用后旧证据失效,完整 Final Gate 仍必须重跑。
164
167
 
165
168
  Long-Task Skill 采用渐进读取:主 `SKILL.md` 只保留目标、硬边界和阶段路由,Contract Authoring、Evidence Design 与 Authority Lifecycle 细节只在对应阶段读取一层 reference。这只是指令组织,不产生第二权威。
166
169
 
@@ -173,9 +176,10 @@ Draft Outcome 只是 Authority Lock 前的 Outcome。Outcome 按可独立观察
173
176
  ```text
174
177
  ty-context long-task init <workdir>
175
178
  ty-context long-task preflight <workdir>
176
- ty-context long-task compile <workdir>
177
- ty-context long-task compile <workdir> --revise
178
- ty-context long-task approve-authority-revision <workdir> --revision <sha>
179
+ ty-context long-task compile <workdir>
180
+ ty-context long-task compile <workdir> --revise
181
+ ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]
182
+ ty-context long-task approve-authority-revision <workdir> --revision <sha>
179
183
  ty-context long-task explain <workdir>
180
184
  ty-context long-task verify <workdir> [--outcome <key>] [--check <key>]
181
185
  ty-context long-task status <workdir>
@@ -189,10 +193,12 @@ ty-context long-task abandon <workdir> [--force-corrupt-state]
189
193
 
190
194
  - `init` 创建单文件 inline Outcome 的 Compact Contract 模板。
191
195
  - `preflight` 应用 Compact 默认值并一次输出 Source/REQ/CTRL/OBL/AC、Context、风险、路径/Binding、Runner/Input 与 Proof 诊断;它完全只读,不创建 Authority Lock、marker、cache、progress、Receipt、pending revision、状态锁,也不运行项目 Check。
192
- - `compile` 生成 Global 与 Outcome Result/Requirement/Control-field/Non-completing/Technical Claim,拒绝未覆盖 Claim,并让第一次正式成功 Compile 成为 Authority Lock。第一次结果附带 `execution_model_checkpoint.required: true`,后续 Compile 返回 `false`;该字段不进入 Authority state。
196
+ - `compile` 生成 Global 与 Outcome Result/Requirement/Control-field/Non-completing/Technical Claim,拒绝未覆盖 Claim,并让第一次正式成功 Compile 成为 Authority Lock。第一次结果附带 `execution_model_checkpoint.required: true`,后续 Compile 返回 `false`;该字段不进入 Authority state。
197
+ - `diagnose-revision` 只做无副作用候选 Compile;仅 scope-only 候选能运行 Active Authority 已有且未更换的 Check,输出固定为非验收、非 Progress、非 pending。
198
+ - `compile --revise` 自动采用可证明安全的修订;受保护修订在 stdout 返回 `authority_revision_pending`、精确 decision id 与确定性短摘要,并继续 fail closed,直到用户批准完全相同的 id。候选内容再变会生成新 id,并使旧批准失效。
193
199
  - `verify` 在重查 active task/revision/compiled/worktree identity 后写 scoped Progress;targeted verify 始终只是修复证据。
194
- - `status` 输出 `unverified`、`progress_passing`、`progress_failing`、`progress_stale` 或 `blocked_external`,并报告 fresh `final_workflow_status` 与完整 `external_confirmations`。
195
- - `resume` 完全只读,恢复 task/contract identity、风险、相关 Context、Git 状态、ready Outcome、findings 和 next safe action。
200
+ - `status` 输出 `unverified`、`progress_passing`、`progress_failing`、`progress_stale` 或 `blocked_external`,并报告 fresh `final_workflow_status`、完整 `external_confirmations` 与唯一的 `pending_authority_revision`。
201
+ - `resume` 完全只读,恢复 task/contract identity、风险、相关 Context、Git 状态、同一待批决策、ready Outcome、findings 和 next safe action。
196
202
  - `final-gate` 在完整 Check 后再次验证 active identity;并发 revision 不能产生 accepted。
197
203
  - `stop-check` 与 `close` 自己运行 Live Final Gate,并只用 accepted identity 做 CAS clear。`status: closed` 只表示机器 Authority 已清理,不表示完整外部交付完成。
198
204
  - `abandon --force-corrupt-state` 仅用于损坏/mismatch/legacy-unrecoverable 状态或遗留锁,只删除确定性 active state 与 `<workdir>/.ty-context/**`。
@@ -240,22 +246,24 @@ Targeted verify、Progress、status、Receipt 与 compiled cache 都不是完成
240
246
 
241
247
  ```powershell
242
248
  npm install
243
- npm run format:check
244
- npm run typecheck --workspace project-tiny-context-harness
245
- npm run build --workspace project-tiny-context-harness
246
- node --test --test-concurrency=1 tests/ty-context/source-plan-authoring-skill.test.mjs tests/ty-context/sync-init-doctor.test.mjs tests/ty-context/workflow-contract-routing.test.mjs tests/ty-context/long-task-model-choice-checkpoint.test.mjs
247
- npm run test:delivery-contract --workspace project-tiny-context-harness
248
- npm run test:long-task-workflow --workspace project-tiny-context-harness
249
- npm run test:long-task-performance --workspace project-tiny-context-harness
250
- npm test
249
+ npm run format:check
250
+ npm run typecheck --workspace project-tiny-context-harness
251
+ npm run build --workspace project-tiny-context-harness
252
+ npm run test:affected:list
253
+ npm run test:affected
254
+ npm run test:long-task:trust
255
+ npm run test:long-task-performance --workspace project-tiny-context-harness
256
+ npm test
251
257
  npm run smoke:quickstart
252
258
  npm run preview:pack
253
259
  npm run launch:check
254
260
  node packages/ty-context/dist/cli.js package check-source
255
261
  make validate-harness
256
- ```
257
-
258
- 模块化门禁是 `ty-context check-modularity`;例外必须包含 `owner`、`introduced_at`、`reason`、`tracking_issue` `expiry_condition`。
262
+ ```
263
+
264
+ `test:affected` 用于日常修改和修复循环;`test:long-task:trust` 是冻结候选版本后的高风险边界门,也是 PR CI 使用的层级;`npm test``main` 和发布保留的完整发布回归,不应在每次小修复后重跑。Delivery Contract 和完整 Long-Task 门仍可通过 package workspace scripts 显式执行。
265
+
266
+ 模块化门禁是 `ty-context check-modularity`;例外必须包含 `owner`、`introduced_at`、`reason`、`tracking_issue` 和 `expiry_condition`。
259
267
 
260
268
  ## 诚实限制
261
269
 
@@ -62,7 +62,9 @@ After Authority Lock and the one-time execution-model checkpoint are satisfied,
62
62
 
63
63
  Re-evaluate `Context Delta` whenever implementation or repair discovers a durable fact. Controlling Context changes use protected revision; graph-derived, non-explicit `implementation-index` and `archive` are Supporting Context in referenced mode and may auto-revise when only navigation/background changed. Full snapshot mode treats every selected Context file as controlling.
64
64
 
65
- Use targeted `verify --outcome/--check` only to drive repair. Progress is repair evidence only and never acceptance authority. Keep precise findings attached to the owning Source item, Claim, Assertion, Check, Binding and owner path. Do not add another model-switch pause or coordinate parallel subagents.
65
+ Use targeted `verify --outcome/--check` only to drive repair. Progress is repair evidence only and never acceptance authority. Keep precise findings attached to the owning Source item, Claim, Assertion, Check, Binding and owner path. Do not add another model-switch pause or coordinate parallel subagents.
66
+
67
+ When implementation discovers missing Contract paths, first classify the revision. Proven monotonic evidence strengthening may use ordinary `compile --revise` directly. If every protected reason is only owner/expected-change/allowed-support expansion, continue editing the same `delivery-contract.yaml` and use `ty-context long-task diagnose-revision <workdir> [--outcome <key>] [--check <key>]` to exercise only existing active Check identities with unchanged runner/verifier authority; safe monotonic strengthening may coexist. Candidate diagnostics are transient: they authorize no acceptance and write no pending/approval state, Active Authority, cache, Progress or Receipt. Semantic changes, proof weakening, runner or verifier-content changes, and risk-increase candidates are preview-only and must not run; risk downgrade is rejected. When the candidate is complete, run ordinary `compile --revise` once, present its exact concise decision summary to the user, and never approve it yourself. Keep the previous Authority active until exact approval and atomic adoption; after adoption, discard historical/candidate evidence and require the complete Final Gate.
66
68
 
67
69
  ## Live Final Authority
68
70
 
@@ -16,7 +16,15 @@ Its JSON result includes `execution_model_checkpoint.required: true`. Before pro
16
16
 
17
17
  ## Protected Revision
18
18
 
19
- After Authority Lock, Source/Product/Global semantics, Controlling Context, verifier content, runner/verification input replacement, proof reduction, scope expansion or unprovable containment must compare against active authority. Pure verifier relocation and proven proof/scope tightening may auto-revise; content weakening requires exact user approval. The executing Agent never approves its own pending revision.
19
+ After Authority Lock, every revision compares against active authority and follows one of three paths:
20
+
21
+ 1. proven monotonic evidence strengthening, pure verifier relocation, proven tightening and supporting-only Context revision may auto-revise;
22
+ 2. a candidate whose only protected reasons are owner, expected-change or allowed-support expansion remains inactive but may be exercised with `diagnose-revision` through existing active Check identities whose runner/verifier authority is unchanged; safe monotonic strengthening may coexist; or
23
+ 3. every semantic change, proof weakening, runner or verifier-content change, risk change or other protected reason requires the exact revision identity and is never candidate-executed.
24
+
25
+ `diagnose-revision` recompiles the same `delivery-contract.yaml` in memory, creates only a disposable workspace snapshot when class 2 is proven, and returns transient repair results with `acceptance_authorized: false`. It writes no pending/approval state, authority/marker, cache, Progress or Receipt. Repeated edits therefore accumulate only in the one existing Contract authoring file, not a pending Draft authority or candidate state plane.
26
+
27
+ Ordinary `compile --revise` is the only operation that may create the one pending decision. It binds a deterministic concise change summary into the revision identity. `status` and `resume` expose that same decision so the host can deduplicate the user prompt without a Harness-owned waiting state. The executing Agent never approves its own pending revision; earlier blanket authorization cannot approve a later exact identity. If the candidate changes, the identity changes and old approval is rejected. The previous Authority remains active until approved compare-and-swap adoption, which invalidates derived evidence and leaves the complete source-recompiled Final Gate mandatory.
20
28
 
21
29
  Every path-bearing field uses canonical grammar. Internal `.`/`..`, control characters, empty segments, absolute/drive/UNC paths and unsupported glob syntax fail closed.
22
30
 
@@ -154,15 +154,15 @@ function parseLimit(value) {
154
154
  return limit;
155
155
  }
156
156
  function helpText() {
157
- return `ty-context check-modularity:
158
- check-modularity --touched [--limit 300] [--fail-on-warning]
159
- check-modularity --file <path> [--file <path> ...] [--limit 300] [--fail-on-warning]
160
- check-modularity --base <ref> [--limit 300] [--fail-on-warning]
161
- check-modularity --config-only
162
-
163
- Audits physical lines, per-function statements and branch complexity, exports, state transitions and module responsibilities.
164
- For --touched and --base, existing findings are reported but only new or worsened non-line complexity is a warning; physical lines remain a risk signal and new files are audited in full.
165
- The default is warning-only; --fail-on-warning lets projects opt into CI enforcement.
166
- Generated configs default to modularity.policy: strict_except_generated; omitted policy is treated as scoped_waivers for compatibility.
157
+ return `ty-context check-modularity:
158
+ check-modularity --touched [--limit 300] [--fail-on-warning]
159
+ check-modularity --file <path> [--file <path> ...] [--limit 300] [--fail-on-warning]
160
+ check-modularity --base <ref> [--limit 300] [--fail-on-warning]
161
+ check-modularity --config-only
162
+
163
+ Audits physical lines, per-function statements and branch complexity, exports, state transitions and module responsibilities.
164
+ For --touched and --base, existing findings are reported but only new or worsened non-line complexity is a warning; physical lines remain a risk signal and new files are audited in full.
165
+ The default is warning-only; --fail-on-warning lets projects opt into CI enforcement.
166
+ Generated configs default to modularity.policy: strict_except_generated; omitted policy is treated as scoped_waivers for compatibility.
167
167
  Risks can be waived only through lifecycle-complete <harnessRoot>/config.yaml modularity.waivers when policy is scoped_waivers.`;
168
168
  }
@@ -23,70 +23,70 @@ export function compactLongTaskTemplate() {
23
23
  return template();
24
24
  }
25
25
  function template() {
26
- return `schema_version: long-task-delivery-v2
27
- task:
28
- id: replace-me
29
- title: Replace me
30
- goal: Describe the complete observable delivery goal.
31
- source_paths: [plans/replace-me.md]
32
- context_refs: [project_context/areas/replace-me.md]
33
- source_claims:
34
- - key: replace-requirement
35
- source_ref: plans/replace-me.md#replace-requirement
36
- statement: Preserve one atomic source requirement.
37
- disposition:
38
- type: claim
39
- refs: [replace-outcome.requirement.replace-requirement]
40
- risk:
41
- facts: {}
42
- global: {}
43
- outcomes:
44
- - key: replace-outcome
45
- title: Replace outcome
46
- product:
47
- observable_result: Describe what a user or system can observe.
48
- owner:
49
- label: replace-owner
50
- context_refs: [project_context/areas/replace-me.md]
51
- path_globs: ["src/**", "tests/**"]
52
- requirements:
53
- - key: replace-requirement
54
- statement: Preserve one atomic source requirement.
55
- required_proof_surfaces: [runtime_behavior]
56
- technical:
57
- expected_change_paths: ["src/**"]
58
- bindings:
59
- - key: replace-carrier
60
- kind: file
61
- target: src/replace-me.ts
62
- carrier_paths: [src/replace-me.ts]
63
- existence: planned
64
- acceptance:
65
- checks:
66
- - key: replace-check
67
- proof_surface: runtime_behavior
68
- runner:
69
- type: node_oracle
70
- target: tests/replace-oracle.mjs
71
- effect: read_only
72
- verification_inputs: ["tests/replace-oracle.mjs"]
73
- input_paths: [src/replace-me.ts]
74
- expected_output_paths: [src/replace-me.ts]
75
- positive_assertions:
76
- - key: replace-success
77
- criterion: The declared outcome and requirement are observable.
78
- claims: [result, requirement.replace-requirement]
79
- observation: result
80
- operator: equals
81
- expected: true
82
- counterfactual_controls:
83
- - key: remove-replace-carrier
84
- binding_key: replace-carrier
85
- claims: [result, requirement.replace-requirement]
86
- check_key: replace-check
87
- mutation:
88
- type: remove_paths
89
- paths: [src/replace-me.ts]
90
- expected_assertion_failures: [replace-success]
26
+ return `schema_version: long-task-delivery-v2
27
+ task:
28
+ id: replace-me
29
+ title: Replace me
30
+ goal: Describe the complete observable delivery goal.
31
+ source_paths: [plans/replace-me.md]
32
+ context_refs: [project_context/areas/replace-me.md]
33
+ source_claims:
34
+ - key: replace-requirement
35
+ source_ref: plans/replace-me.md#replace-requirement
36
+ statement: Preserve one atomic source requirement.
37
+ disposition:
38
+ type: claim
39
+ refs: [replace-outcome.requirement.replace-requirement]
40
+ risk:
41
+ facts: {}
42
+ global: {}
43
+ outcomes:
44
+ - key: replace-outcome
45
+ title: Replace outcome
46
+ product:
47
+ observable_result: Describe what a user or system can observe.
48
+ owner:
49
+ label: replace-owner
50
+ context_refs: [project_context/areas/replace-me.md]
51
+ path_globs: ["src/**", "tests/**"]
52
+ requirements:
53
+ - key: replace-requirement
54
+ statement: Preserve one atomic source requirement.
55
+ required_proof_surfaces: [runtime_behavior]
56
+ technical:
57
+ expected_change_paths: ["src/**"]
58
+ bindings:
59
+ - key: replace-carrier
60
+ kind: file
61
+ target: src/replace-me.ts
62
+ carrier_paths: [src/replace-me.ts]
63
+ existence: planned
64
+ acceptance:
65
+ checks:
66
+ - key: replace-check
67
+ proof_surface: runtime_behavior
68
+ runner:
69
+ type: node_oracle
70
+ target: tests/replace-oracle.mjs
71
+ effect: read_only
72
+ verification_inputs: ["tests/replace-oracle.mjs"]
73
+ input_paths: [src/replace-me.ts]
74
+ expected_output_paths: [src/replace-me.ts]
75
+ positive_assertions:
76
+ - key: replace-success
77
+ criterion: The declared outcome and requirement are observable.
78
+ claims: [result, requirement.replace-requirement]
79
+ observation: result
80
+ operator: equals
81
+ expected: true
82
+ counterfactual_controls:
83
+ - key: remove-replace-carrier
84
+ binding_key: replace-carrier
85
+ claims: [result, requirement.replace-requirement]
86
+ check_key: replace-check
87
+ mutation:
88
+ type: remove_paths
89
+ paths: [src/replace-me.ts]
90
+ expected_assertion_failures: [replace-success]
91
91
  `;
92
92
  }
@@ -0,0 +1,3 @@
1
+ export declare function option(args: string[], name: string): string | undefined;
2
+ export declare function rejectOptions(args: string[], allowed: string[]): void;
3
+ export declare function rejectUnknown(actual: string[], allowed: string[]): void;
@@ -0,0 +1,20 @@
1
+ export function option(args, name) {
2
+ const indexes = args.flatMap((value, index) => value === name ? [index] : []);
3
+ if (indexes.length > 1)
4
+ throw new Error(`duplicate option: ${name}`);
5
+ if (!indexes.length)
6
+ return undefined;
7
+ const value = args[indexes[0] + 1];
8
+ if (!value || value.startsWith("--"))
9
+ throw new Error(`${name} requires a value`);
10
+ return value;
11
+ }
12
+ export function rejectOptions(args, allowed) {
13
+ for (let index = 0; index < args.length; index += 2)
14
+ if (!allowed.includes(args[index]) || !args[index + 1])
15
+ throw new Error(`Unknown or injected arguments: ${args.join(" ")}`);
16
+ }
17
+ export function rejectUnknown(actual, allowed) {
18
+ if (actual.join("\0") !== allowed.join("\0"))
19
+ throw new Error(`Unknown or injected arguments: ${actual.join(" ")}`);
20
+ }
@@ -0,0 +1 @@
1
+ export declare function handleLongTaskRevisionCommand(subcommand: string, workdir: string, args: string[]): Promise<boolean>;