nccgs 2.0.0-rc.3 → 2.0.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 (69) hide show
  1. package/.claude/nccgs/MEMORY.md +3 -2
  2. package/.claude/nccgs/VERSION +1 -1
  3. package/.claude/nccgs/packages/ponytail/README.md +2 -2
  4. package/.claude/nccgs/protocols/agent-contract.md +15 -2
  5. package/.claude/nccgs/protocols/bounded-repair.md +135 -7
  6. package/.claude/nccgs/protocols/editor-session-evidence.md +52 -0
  7. package/.claude/nccgs/protocols/orchestration.md +7 -5
  8. package/.claude/nccgs/protocols/review-handoff.md +17 -1
  9. package/.claude/nccgs/protocols/standalone-gates.md +64 -8
  10. package/.claude/nccgs/protocols/standalone.md +33 -13
  11. package/.claude/nccgs/protocols/task-gates.md +13 -1
  12. package/.claude/nccgs/protocols/task-slices.md +106 -0
  13. package/.claude/nccgs/routing.generated.md +20 -0
  14. package/.claude/nccgs/tools/command-process.mjs +10 -4
  15. package/.claude/nccgs/tools/compile-policy.mjs +4 -0
  16. package/.claude/nccgs/tools/editor-session-evidence.mjs +66 -0
  17. package/.claude/nccgs/tools/gates.mjs +7 -4
  18. package/.claude/nccgs/tools/handoff.mjs +51 -0
  19. package/.claude/nccgs/tools/inputs.mjs +36 -1
  20. package/.claude/nccgs/tools/lifecycle.mjs +21 -0
  21. package/.claude/nccgs/tools/orchestration.mjs +264 -14
  22. package/.claude/nccgs/tools/repair-packet.mjs +29 -10
  23. package/.claude/nccgs/tools/returned-handoff.mjs +38 -0
  24. package/.claude/nccgs/tools/review-budget.mjs +171 -0
  25. package/.claude/nccgs/tools/review-handoff.mjs +42 -8
  26. package/.claude/nccgs/tools/runtime.mjs +7 -2
  27. package/.claude/nccgs/tools/session-budget.mjs +67 -0
  28. package/.claude/nccgs/tools/task-slices.mjs +147 -0
  29. package/.claude/nccgs/tools/task.mjs +39 -2
  30. package/.claude/nccgs/tools/tool-guard.mjs +19 -5
  31. package/.claude/nccgs/tools/unity-repair.mjs +128 -0
  32. package/.claude/nccgs/tools/verification-jobs.mjs +13 -3
  33. package/.claude/nccgs/tools/windows-compiler-server.cs +163 -0
  34. package/.claude/nccgs/tools/windows-job.cs +8 -1
  35. package/CHANGELOG.md +107 -0
  36. package/MEMORY.md +3 -2
  37. package/README.md +34 -27
  38. package/UPGRADING.md +21 -18
  39. package/VERSION +1 -1
  40. package/docs/ARCHITECTURE.md +45 -18
  41. package/docs/BOUNDED-REPAIR.md +76 -7
  42. package/docs/EDITOR-SESSION-EVIDENCE.md +52 -0
  43. package/docs/HANDOFF-AUTOMATION.md +144 -0
  44. package/docs/HUONG-DAN-MIGRATE-VA-SU-DUNG.md +38 -10
  45. package/docs/PHASE-1-OPERATIONS.md +142 -1
  46. package/docs/PHASE-2-OPERATIONS.md +1 -1
  47. package/docs/RELEASE-STATUS.md +85 -4
  48. package/docs/TASK-SLICING.md +57 -0
  49. package/docs/UPGRADE-QUALIFICATION.md +1 -1
  50. package/docs/WORKFLOWS.md +1 -1
  51. package/package.json +2 -2
  52. package/scaffold/.nccgs/templates/repair-unity-code.json +18 -0
  53. package/scaffold/.nccgs/templates/repair-unity-editor.json +21 -0
  54. package/scaffold/.nccgs/templates/task-slices.json +28 -0
  55. package/scripts/cli.mjs +4 -0
  56. package/scripts/run.mjs +4 -3
  57. package/scripts/supervise.mjs +30 -6
  58. package/scripts/validate.mjs +4 -0
  59. package/scripts/work-handoff.mjs +38 -0
  60. package/tests/editor-session-evidence.test.mjs +45 -0
  61. package/tests/fixtures/compiler-shutdown.cs +64 -0
  62. package/tests/orchestration-v15.test.mjs +52 -1
  63. package/tests/phase1.test.mjs +92 -0
  64. package/tests/policy-v15.test.mjs +14 -0
  65. package/tests/review-budget.test.mjs +177 -0
  66. package/tests/runtime-v15.test.mjs +572 -4
  67. package/tests/session-budget.test.mjs +34 -0
  68. package/tests/task-slices.test.mjs +285 -0
  69. package/tests/unity-generated.test.mjs +140 -0
@@ -1,9 +1,12 @@
1
- # Hướng dẫn cài đặt và sử dụng NCCGS 2.0 RC
1
+ # Hướng dẫn cài đặt và sử dụng NCCGS 2.0.0
2
2
 
3
- Bản hiện tại: **2.0.0-rc.3**, kênh npm **next**. `latest` là kênh stable riêng.
4
- Đây là ứng viên phát hành. Nâng cấp từ npm 1.3.0 đã được kiểm chứng trong phạm vi
3
+ Gói stable đang chuẩn bị: **2.0.0**, chưa phát hành npm.
4
+ Dùng gói cục bộ cùng mã SHA-256 đi kèm; việc chuẩn bị không đổi các kênh npm.
5
+ Biên bản operator dừng Editor phải được đưa vào hồ sơ reviewer bằng
6
+ [hướng dẫn bằng chứng Editor](EDITOR-SESSION-EVIDENCE.md).
7
+ Đây là gói stable đang chuẩn bị. Nâng cấp từ npm 1.3.0 đã được kiểm chứng trong phạm vi
5
8
  [các tình huống thử](UPGRADE-QUALIFICATION.md); chạy trọn một đầu việc mới bằng
6
- chính RC này vẫn là bước riêng chưa hoàn tất. Xem [trạng thái phát hành](RELEASE-STATUS.md).
9
+ chính gói stable này vẫn là bước riêng chưa hoàn tất. Xem [trạng thái phát hành](RELEASE-STATUS.md).
7
10
 
8
11
  ## Cài mới vào bản sao dự án
9
12
 
@@ -12,14 +15,15 @@ Chức năng điều khiển Unity cần thêm Editor/CLI phù hợp. Thay đư
12
15
  dự án của bạn; đọc kết quả xem trước rồi mới áp dụng:
13
16
 
14
17
  ```powershell
15
- npx --yes nccgs@2.0.0-rc.3 install --project "D:\path\to\UnityProject" --dry-run
16
- npx --yes nccgs@2.0.0-rc.3 install --project "D:\path\to\UnityProject"
17
- npx --yes nccgs@2.0.0-rc.3 doctor --project "D:\path\to\UnityProject"
18
+ $NccgsArchive = "D:\path\to\nccgs-2.0.0.tgz"
19
+ npx --yes --package "$NccgsArchive" nccgs install --project "D:\path\to\UnityProject" --dry-run
20
+ npx --yes --package "$NccgsArchive" nccgs install --project "D:\path\to\UnityProject"
21
+ npx --yes --package "$NccgsArchive" nccgs doctor --project "D:\path\to\UnityProject"
18
22
  ```
19
23
 
20
- Có thể dùng `nccgs@next` để theo RC mới nhất; dùng số phiên bản cụ thể để tái lập.
24
+ Dùng đúng gói cục bộ và SHA-256 đã ghi; các kênh npm không chọn gói chưa phát hành này.
21
25
  Cài mới mặc định dùng Claude Code standalone, không yêu cầu Astra/Fable. Dự án cũ
22
- vẫn giữ nghĩa vụ đã cấu hình; không tự bỏ một bước duyệt chỉ vì cài RC.
26
+ vẫn giữ nghĩa vụ đã cấu hình; không tự bỏ một bước duyệt chỉ vì cài gói mới.
23
27
 
24
28
  ## Dự án đã cài NCCGS
25
29
 
@@ -36,7 +40,7 @@ mở lại phiên Claude Code.
36
40
  ## Bắt đầu một đầu việc rõ ràng
37
41
 
38
42
  ```powershell
39
- npx --yes nccgs@2.0.0-rc.3 run --project "D:\path\to\UnityProject"
43
+ npx --yes --package "$NccgsArchive" nccgs run --project "D:\path\to\UnityProject"
40
44
  ```
41
45
 
42
46
  Trong Claude Code, cung cấp mục tiêu, phạm vi, yêu cầu cố định, phần được phép sửa
@@ -57,3 +61,27 @@ mong muốn, không phải bằng chứng model thực chạy. Chỉ gọi chuy
57
61
  review hợp lệ và mọi gate áp dụng đều đạt. Nghiệm thu kỹ thuật và quyết định nghiệm
58
62
  thu của người dùng được ghi riêng. Một lượt thất bại phải được giữ cùng chi phí,
59
63
  nguyên nhân và kết quả sửa lại.
64
+
65
+ ## Hỗ trợ handoff, Unity repair và chia nhỏ task trong NCCGS 2.0.0
66
+
67
+ Source hiện có thêm các hỗ trợ chưa phát hành lên npm. Coordinator dùng
68
+ `task dispatch-prompt` để lấy prompt và khung bàn giao PARTIAL cho lượt đã đăng ký.
69
+ Worker có thể dùng `task handoff-validate` để phát hiện lỗi cấu trúc trước khi kết
70
+ thúc; repair worker theo giới hạn riêng của gói repair. Sau khi reviewer hoàn thành,
71
+ coordinator dùng `task record-review` để ghi đúng kết luận từ handoff đã ghim,
72
+ qua đầy đủ cổng kiểm tra hiện có. Các lệnh này không tự chấp thuận hay đóng task.
73
+ Xem [cú pháp và giới hạn](HANDOFF-AUTOMATION.md). Dùng source/package mới theo quy
74
+ trình nâng cấp; các lệnh ở trên dùng chính gói 2.0.0 cục bộ chưa phát hành.
75
+
76
+ Repair cũ giữ nguyên. Gói mới `unity-code` cho sửa/tạo tối đa 8 tệp mã; `unity-editor`
77
+ cho sửa scene/prefab/asset bằng thao tác Editor đã chốt trước. Tệp mới phải được
78
+ Unity import và tạo metadata trước khi worker kết thúc. Không sửa tay GUID hay
79
+ dùng kết quả thao tác Editor thay bằng chứng kiểm thử. Khi thao tác Editor chưa rõ
80
+ đã dừng hay chưa, giữ lượt repair và quyền sở hữu cho tới khi được đối soát; không
81
+ tự chạy lại hoặc hoàn ngân sách. Xem [luồng repair và mẫu gói](BOUNDED-REPAIR.md).
82
+
83
+ Với task quá lớn cho một lượt, dùng `task slice-preview`, `task slice-plan` và
84
+ `task slice-status` để chia thành các phần có mục tiêu, tệp và phụ thuộc rõ ràng
85
+ trong cùng task. Phần cuối tích hợp toàn bộ điều kiện gốc trước review độc lập.
86
+ Các phần dùng chung ngân sách hiện có; lịch sử, lượt thất bại và các cổng nghiệm
87
+ thu vẫn được giữ. Xem [hướng dẫn chia nhỏ task](TASK-SLICING.md).
@@ -1,7 +1,7 @@
1
1
  # Phase 1: durable verification and bounded continuation
2
2
 
3
3
  These verification and continuation mechanisms originated in the 1.5 preview
4
- and are included in 2.0 RC. Historical test descriptions below retain their original
4
+ and are included in 2.0.0. Historical test descriptions below retain their original
5
5
  scope. See [current release status](RELEASE-STATUS.md) for completed and pending checks.
6
6
 
7
7
  ## Run a verification once
@@ -50,6 +50,47 @@ Framework options end at `--`. A helper's later `--project` is passed to that he
50
50
  it is not interpreted as the framework root. The framework's own `--project` must
51
51
  still resolve to the bound root. Shell composition and expansion remain blocked.
52
52
 
53
+ ## Unity-generated IDE files on first import
54
+
55
+ Before `task init` for a new Unity project, declare its known derived files in
56
+ `.nccgs/inputs.json`. Preserve existing canonical inputs, build outputs and check
57
+ timeouts. For example, add this optional field to the existing manifest, replacing
58
+ the project/assembly names with the actual outputs:
59
+
60
+ ```json
61
+ "unityGeneratedFiles": [
62
+ "Assembly-CSharp.csproj",
63
+ "MyGame.slnx",
64
+ ".vscode/extensions.json",
65
+ ".vscode/launch.json",
66
+ ".vscode/settings.json",
67
+ "UserSettings/EditorUserSettings.asset",
68
+ "UserSettings/Search.settings"
69
+ ]
70
+ ```
71
+
72
+ This is an explicit declaration of derived output, not automatic recognition of
73
+ file contents or proof that Unity was the writer. Inspect existing files first;
74
+ do not list user-owned IDE settings, custom project files or any file consumed as
75
+ a build/test input. Such files remain tracked and may also be canonical inputs.
76
+ If another tool builds from a root `.csproj`, that file is an input, not an output.
77
+
78
+ Only exact root `.csproj`/`.sln`/`.slnx` paths and the five IDE/user-setting paths
79
+ shown above are allowed, at most 256 entries in an actual Unity project. Whole
80
+ directories, globs, traversal, links, duplicates and overlap with canonical inputs
81
+ are rejected. All other files, including nested project files, `.vscode/tasks.json`,
82
+ source/tests, assets and their `.meta` files, packages and ProjectSettings remain
83
+ covered by the existing source snapshot. No Git ignore file is consulted.
84
+
85
+ The manifest itself remains a canonical input pinned at task initialization.
86
+ Managed requests capture each declared file's original hash or absence; receipts
87
+ retain the before/after hashes and changed paths. This metadata change record is
88
+ separate from source integrity and never overrides a failed command, timeout,
89
+ source change, criterion or review. Missing/null output hashes mean absence, not
90
+ an unverified source exemption. Empty/omitted declarations retain the previous
91
+ strict behavior. Changing the list changes the canonical fingerprint; it cannot
92
+ retroactively repair a FAIL, reuse a stale approval or reset a task's allowance.
93
+
53
94
  ## Supervise headless Claude Code
54
95
 
55
96
  Initialize an implementation task first. Start from an external terminal:
@@ -76,6 +117,61 @@ invocation receives only the remaining allowance. Missing/decreasing usage block
76
117
  another invocation and remains unknown, not zero. Client list-cost is not billing,
77
118
  and in-flight provider requests can exceed a stop threshold.
78
119
 
120
+ For pinned dispatch cost limits, supervised admission can cover missing worker
121
+ cost using the whole-session allowance plus verified prior session totals. It
122
+ retains unknown worker telemetry and records the separate budget basis. One
123
+ project-wide supervision lock prevents concurrent allowance reuse; unexplained
124
+ worker sessions or missing prior cost fail closed. A fresh authorized run must
125
+ fit the remainder of every ancestor cap; it cannot erase spent attempts or cost.
126
+
127
+ ### Protect the final independent review before starting work
128
+
129
+ Before the first session, the external operator registers an allocation on the
130
+ root task (children inherit it):
131
+
132
+ ```text
133
+ node .claude/nccgs/tools/task.mjs budget-plan --id ROOT --file .nccgs/evidence/budget-plan.json
134
+ ```
135
+
136
+ The JSON has `schemaVersion: 1`, a human-readable `authority`, `totalUsd`,
137
+ `finalReviewUsd`, `totalDurationMs`, and `finalReviewDurationMs`. For a USD 12,
138
+ 75-minute case, reserving USD 4 and 15 minutes leaves at most USD 8 and 60 minutes
139
+ for design, design review, implementation, verification and repair together.
140
+ This is an explicit allocation, not a prediction that every reviewer will finish.
141
+ Provider requests in flight can exceed a stop threshold; actual terminal usage is
142
+ always retained and subtracted, never inferred for individual workers.
143
+
144
+ Use `nccgs run ... --budget-phase work` (the default) for those work sessions.
145
+ The supervisor clamps the requested session allowance and deadline to the
146
+ remaining shared work allocation. A fresh session or child task cannot take the
147
+ protected amount. Finish the implementation record and invoke
148
+ `node .claude/nccgs/tools/task.mjs report --id TASK --outcome partial --summary "Awaiting protected independent review"`.
149
+ A prose PARTIAL response is not itself a task record. NCCGS 2.0.0 can settle it without
150
+ another model invocation only when the protected work phase has current recorded
151
+ implementation, all latest checks and automatic criteria pass, no active work,
152
+ and complete session cost. It writes an attributed PARTIAL report through the
153
+ normal lifecycle. Otherwise the bounded continuation/blocked path remains.
154
+ See [deterministic handoff](HANDOFF-AUTOMATION.md#deterministic-protected-work-handoff).
155
+ Then start `nccgs run ... --budget-phase final-review` on that same
156
+ implementation task with a fresh native coordinator/reviewer session. The latter
157
+ may use unused work funds as well as its protected remainder; all previous spend
158
+ stays charged. Design review cannot use the final delivery reserve.
159
+
160
+ The final-review phase admits only independent delivery reviewer dispatches and
161
+ settlement of existing evidence. Source workers, repairs and new verification
162
+ jobs are rejected; all normal review/acceptance gates still apply. A negative
163
+ review can return to work only if its original work time/cost remain. A retry,
164
+ replacement session or recovered launcher never restores spent review funds.
165
+ `task budget-status --id TASK` shows settled totals, protected remainder and the
166
+ current allocation, explicitly leaving in-flight actual cost unknown.
167
+
168
+ Plan terms are pinned once; native sessions cannot register or replace them.
169
+ Missing allocation/run history or a started worker without correlated supervised
170
+ session coverage fails closed, even if the old task omitted optional `maxCostUsd`.
171
+ An existing case cannot reserve
172
+ money already spent or receive a later deadline. A separately authorized new
173
+ case has its own budget and must retain/report the earlier case's cost and result.
174
+
79
175
  Run records and native streams live in `.nccgs/runs/RUN_ID/`. Resume a recoverable
80
176
  external launcher interruption with:
81
177
 
@@ -89,6 +185,19 @@ usage and ambiguous launch windows block recovery. This is not an unlimited retr
89
185
  service. Keep local job/run ownership records in their original project; move only
90
186
  archived evidence when collecting a report.
91
187
 
188
+ An installed framework update changes the source fingerprint of an open plan or
189
+ audit. Do not reuse its old analysis/review or silently edit its baseline. An
190
+ external operator can run `task.mjs migrate-framework --id TASK --decision FILE`
191
+ with a JSON decision containing `reason`, `authority`, and `beforeFiles` (the exact
192
+ sorted `[path, sha256]` inventory from the original snapshot). The command proves
193
+ that inventory against the locked baseline and permits changes only under
194
+ `.claude/`, with unchanged canonical inputs and execution/pipeline policy. It
195
+ archives all old stages and the exact delta, retains task identity and budgets,
196
+ and requires fresh native analysis plus independent review. Missing original
197
+ inventory, game/source changes, live workers or pending checks block migration.
198
+ This is an external maintenance operation, never automatic acceptance or a
199
+ budget extension.
200
+
92
201
  ## Process ownership and locks
93
202
 
94
203
  On Windows 10+, the bundled inspectable C# helper uses a named Windows Job Object,
@@ -101,6 +210,38 @@ change PowerShell/system policy, install a runtime, or require WMI access.
101
210
  On POSIX, foreground commands use an owned process group; commands must not detach
102
211
  or daemonize out of that group. Windows is the locally tested platform for this change.
103
212
 
213
+ In the prepared 2.0.0 package, managed verification commands and their
214
+ wrappers inherit `UNITY_NO_AUTH_BROKER=1`.
215
+ Unity CLI then uses its supported direct OS-keyring authentication path instead
216
+ of starting a resident auth broker that waits two idle minutes after a short test.
217
+ The flag is scoped to the command tree: the caller's environment, stored account
218
+ settings, peer-signature policy, credentials and other environment entries are
219
+ not changed. No environment values are added to the saved command specification.
220
+ All actual descendants remain owned; root exit, test XML or a wrapper's PASS
221
+ alone cannot release the group or publish the verification receipt. Surviving
222
+ children still hold the slot until exit or the original timeout; an interrupted
223
+ or timed-out command still fails. These source fixes do not rewrite old jobs,
224
+ reviews, acceptance definitions or budgets.
225
+
226
+ For cold Unity compilation on Windows, the helper can request graceful shutdown
227
+ of a qualified Roslyn server after the command root has exited. It first verifies
228
+ that only recognized Unity compiler servers and system console hosts remain in
229
+ the Job Object. The exact open named-pipe connection must belong to that live,
230
+ owned compiler PID before any shutdown bytes are sent. Connection and I/O waits
231
+ are bounded; an acknowledgement never counts as process completion. The normal
232
+ empty-group check, original root exit code and original deadline still apply.
233
+ No compiler outside the job is stopped, and no global compiler setting is changed.
234
+
235
+ Qualification currently covers the Roslyn 4.3.1 / .NET host binary pair measured
236
+ with Editor 6000.3.17f1 and Unity CLI 1.0.0-beta.14 on Windows. The compiler and host
237
+ SHA-256 hashes and exact protocol revision are pinned in
238
+ `windows-compiler-server.cs`; matching a process name or version string is not
239
+ sufficient. Unknown binaries, ambiguous process data or another remaining worker
240
+ do not authorize shutdown. They retain normal ownership and may still time out.
241
+ The helper cache includes both C# source hashes, so updating this logic rebuilds
242
+ the executable. Adding another binary pair requires protocol and real cold-run
243
+ qualification, not widening detection to every `dotnet` or `VBCSCompiler` process.
244
+
104
245
  Local task/orchestration locks can recover a verifiably dead owner. Engine locks
105
246
  also require all managed descendants to be gone. Recovery writes an audit entry;
106
247
  it never refunds a dispatch, fabricates completion or resets a ledger. Live owners,
@@ -1,7 +1,7 @@
1
1
  # Phase 2: measured acceptance and a protected repair cycle
2
2
 
3
3
  These acceptance and dispatch mechanisms originated in the 1.5 preview and are
4
- included in 2.0 RC. They do not tune a game or rewrite frozen evaluations. See
4
+ included in 2.0.0. They do not tune a game or rewrite frozen evaluations. See
5
5
  [current release status](RELEASE-STATUS.md) for validation scope.
6
6
 
7
7
  The owner revised the evaluation scope on 2026-10-04: NCCGS must support delivery
@@ -1,20 +1,101 @@
1
- # NCCGS 2.0 RC release status
1
+ # NCCGS 2.0.0 stable preparation
2
2
 
3
- Current candidate: **2.0.0-rc.3**. Release channel: **next**. Latest/stable is not
4
- promoted by this candidate. Pin the exact version for reproducible evaluation.
3
+ Prepared stable package: **2.0.0**, unpublished. No npm publication or tag mutation
4
+ has occurred. The release directory contains the exact local archive, SHA-256,
5
+ regression/install/upgrade results and a separate maintenance review.
6
+
7
+ ## Current evidence boundary
8
+
9
+ - Exact RC4 archive SHA-256: a1db9783f3f4077c742cbc346d0fa935c438fdd783e13c058e13b0bd0521bbf6.
10
+ The 2026-10-28 native Claude Code case qualified dirty-scene refusal, subsequent
11
+ scene repair and deterministic PARTIAL handoff without a continuation. All five
12
+ checks, 28 unchanged criteria/385 assertions, 19 EditMode and 8 PlayMode tests
13
+ passed; independent review was PASS with no mandatory conditions, then normal
14
+ closure. It spent USD7.8510068/12 in 16 min 12 s, retaining the failed attempt.
15
+ - The reviewer retained one LOW evidence-location finding: operator stop receipts
16
+ existed outside its project tree. Version 2.0.0 adds a publisher and protocol to
17
+ expose those existing bytes to reviewers. Old verdicts and frozen files remain
18
+ unchanged. See [Editor lifecycle evidence](EDITOR-SESSION-EVIDENCE.md).
19
+ - Existing acceptance, independent review, source, process and budget gates remain
20
+ mandatory. The Editor helper only validates and copies operator evidence; it
21
+ does not stop an Editor, query a live process or approve a task. An explicit
22
+ read-only `native-result` handoff transport also captures exact correlated
23
+ worker output when the client requires returned text; it never rewrites a
24
+ historical failed attempt, a verdict or a pending condition.
25
+ - Stable archive framework tests and maintenance review are separate from a full
26
+ native Unity run through the stable archive. That broader new run is not claimed.
27
+ Publication, human acceptance and broad productivity remain separate decisions.
28
+
29
+ ## Historical release notes
30
+
31
+ The following notes preserve their earlier preparation-time status. Statements
32
+ about pending RC4 execution below were superseded by the exact-RC4 case above.
33
+
34
+ ### Earlier RC preparation record
35
+
36
+ Prepared candidate: **2.0.0-rc.4**, unpublished. No npm tag is changed and stable
37
+ is not promoted. Use the local archive and its SHA-256 manifest for evaluation.
38
+
39
+ RC4 collects handoff automation, bounded task slices, typed Unity repair, process
40
+ settlement, first-import output declarations and protected review budgets. It
41
+ adds deterministic PARTIAL work handoff and an atomic dirty-scene precondition.
42
+ The historical RC3 archive and all frozen native cases remain unchanged. Their
43
+ execution evidence does not qualify these last additions or the exact RC4 archive.
44
+ See [handoff operations](HANDOFF-AUTOMATION.md), [bounded repair](BOUNDED-REPAIR.md)
45
+ and [task slicing](TASK-SLICING.md).
5
46
 
6
47
  ## What the evidence supports
7
48
 
8
49
  | Check | Status and scope |
9
50
  |---|---|
51
+ | RC4 deterministic work handoff and dirty-scene precondition (2026-10-28 Asia/Saigon) | Framework fixtures exercise prose-only PARTIAL settlement, stale/failed/missing evidence, current negative checks, idempotent recovery, unchanged final-review reserve and legacy reservations. An operator probe with Unity 6000.3.17f1 / CLI 1.0.0-beta.14 blocked named dirty and non-active additive untitled scenes without source loss, then allowed the saved-scene operation with existing GUIDs retained. The owned Editor exited normally and its process group was verified dead. These additions have no new Claude Code execution credit. |
52
+ | RC4 release preparation | Local archive only. Accompanying release receipts record full regression, source/archive hashes, fresh install and disposable upgrade results. Exact-RC native workflow qualification and publication remain separate pending steps. |
10
53
  | Framework functional regression | Previous maintained source: 183 PASS, 0 FAIL, 6 Windows symlink skips across 189 tests. RC3 changes installer recognition of previously generated agents and adds a focused regression. Installer/policy suites and exact-archive upgrade qualification are rerun for this change. |
11
54
  | Scoped native delivery V2 case | 24/24 criteria,137 EditMode,52 PlayMode and independent unconditional Claude Code PASS. Operator-assisted; used a frozen framework with a session-only reviewer capacity override. |
55
+ | Unreleased source: slices and Unity code repair (2026-10-27) | Actual Claude Code workers delivered two dependent slices in one task, then repaired a disclosed post-review fault through a typed `unity-code` packet. The real PlayMode failure remains recorded. Fresh final checks passed 24/24 original criteria (349 assertions), 16/16 EditMode and 7/7 PlayMode; both independent reviews were unconditional PASS. Original tests, installed framework, role limits, task history and total budgets were retained. No capacity override. |
56
+ | Managed Unity test settlement fix (2026-10-27) | On Windows with Unity CLI 1.0.0-beta.14 and Editor 6000.3.17f1, observed the idle auth broker remaining inside the owned process group. The process-local direct-keyring setting reduced warm EditMode total time from 121.37 s to 7.46 s; final PlayMode took 26.75 s. Post-wrapper settlement was 0.373/0.383 s. All 24 unchanged criteria passed (16/16 EditMode, 7/7 PlayMode). Framework regression: 207 PASS, 0 FAIL, 6 Windows symlink skips across 213 tests. Operator-run maintenance; no new Claude session or modification of the prior native evidence. |
57
+ | Cold Unity compiler settlement fix (2026-10-27) | Qualified compiler/host binary pair: Windows, Editor 6000.3.17f1, Roslyn 4.3.1, CLI 1.0.0-beta.14. Graceful shutdown of the exact owned compiler pipe settled a fresh-project run in 28.55 s; its source-change guard correctly retained FAIL when Unity generated IDE files. With those initialization files present and Library removed, a fresh full compilation passed 16/16 EditMode in 31.28 s. PlayMode passed 7/7 in 28.89 s; all 24 unchanged criteria (349 assertions) passed. Framework regression: 208 PASS, 0 FAIL, 6 Windows symlink skips across 214 tests. The original 360 s deadline and process ownership remain. Operator-run maintenance, not a new Claude game run; previous failures, reviews and spent budgets remain immutable. |
58
+ | First-import source classification (2026-10-27) | With nine exact generated IDE/local metadata files declared before init, a project with no Library or IDE files passed its first real EditMode attempt: 16/16 in 31.53 s. Their absence and resulting hashes are retained in the receipt; source stayed unchanged. Fresh PlayMode passed 7/7 in 30.82 s. All 24 original criteria (349 assertions) passed. Framework regression: 215 PASS, 0 FAIL, 6 Windows symlink skips across 221 tests, including seven focused source/output guard tests. Opt-in declarations are canonical inputs; undeclared source/configuration remains tracked. Windows, Editor 6000.3.17f1 and CLI 1.0.0-beta.14; operator-run maintenance, not new Claude execution. Previous source-change FAIL, reviews and budgets are retained. |
59
+ | Fresh-project full native component workflow (2026-10-27) | Actual Claude Code completed native design and independent design review, two dependent implementation slices from API scaffolds, whole-task review, a disclosed post-review fault, typed existing-code repair and fresh independent re-review. First cold EditMode passed 16/16 in 35.17 s with all nine generated outputs audited; no timeout or source drift. The fault produced a retained real 6 PASS/1 FAIL PlayMode run. Final EditMode passed 16/16 in 9.45 s and PlayMode 7/7 in 26.71 s; all 24 unchanged criteria (349 assertions) passed. All three independent reviews were unconditional PASS. The design/implementation parent-child lifecycle shared 7/12 dispatches, USD 10.214066/12 and 25 min 28 s/75 min, with no continuation or extension. Installed framework, checks, source controls, process ownership, history and earlier evidence remained intact; both owned process groups settled. |
12
60
  | RC package integrity | Release procedure verifies version consistency, public contents, documentation links, and install/doctor on a fresh disposable fixture using the packed archive. This is not an upgrade or provider task test. |
61
+ | Native new-script and scene/prefab repair attempt (2026-10-27) | NOT QUALIFIED. A native designer completed an extension contract preserving all original 24 criteria and adding four fixed criteria (385 assertions total); structural validation passed. The coordinator pinned optional per-worker `maxCostUsd: 12`, but the worker's native cost was null, so the next reservation correctly failed closed before independent design review. Actual whole-session cost was USD 2.3247276/12; 1/12 dispatches and no review invocation. No native script creation, asset repair or Unity acceptance checks occurred. Pinned controls, unknown telemetry, partial report, source and earlier evaluations remain unchanged; all owned process groups stopped. |
13
62
  | Upgrade from published npm 1.3.0 | Qualified within the disposable fixture matrix; RC2 exposed a generated-agent issue corrected in RC3. See [scope and limits](UPGRADE-QUALIFICATION.md). |
63
+ | Supervised cost coverage and continued asset repair (2026-10-27 UTC) | PARTIAL, not delivery-qualified. Missing worker cost now uses a separately recorded supervised-session ceiling plus verified historical native spend; worker cost stays unknown. A framework-only baseline migration archived stale analysis and required fresh native validation and independent design PASS. Actual Claude workers then created/imported the new script and repaired the existing prefab and connected scene via pinned Unity operations. Initial 16/19 and intermediate 17/19 EditMode results remain as failures; final 19/19 EditMode, 8/8 PlayMode and all 28 criteria/385 assertions passed. Aggregate spend including both earlier blocked phases is USD 11.589259/12, with 5/12 dispatches and 1/3 reviews in 58 min/75. The coordinator stopped before implementation recording and final independent review; task remains PARTIAL/unclosed. No verdict, review allowance, source exemption or total cap was manufactured. Framework regression: 218 PASS, 0 FAIL, 6 Windows symlink skips across 224 tests. |
14
64
  | Fresh task through this exact RC | PENDING — separate qualification step. Earlier delivery evidence is not attributed to a new run. |
65
+ | Protected final-review allocation and new-script/asset repair (2026-10-28 Asia/Saigon) | QUALIFIED within the disclosed fixture. A separately authorized new USD12/75-minute case pinned USD4/15 minutes for final independent review. Native design/design review spent USD2.9107512; a requested USD9.0892488 work session was clamped to USD5.0892488, and actual repair/verification spending was USD3.6935616. Two native workers created/imported the script and repaired the prefab/connected scene through three pinned Editor operations. Initial 16/19 and intermediate 17/19 EditMode failures remain; final 19/19 EditMode, 8/8 PlayMode and all 28 unchanged criteria/385 assertions passed. The protected review session received USD5.3956872, spent USD3.2125752, imported the fresh independent unconditional PASS unchanged, and normally closed the same implementation task. Total USD9.816888/12, 22 min 35 s/75, 5/12 dispatches, 2/3 reviewers and 1/1 automatic continuation. The work coordinator returned prose PARTIAL without recording the task report, so its continuation-limit stop remains recorded; the separately planned review phase completed delivery. All 32 final audit checks passed; frozen source controls, process ownership, prior evidence and the old USD11.589259 PARTIAL remain intact. Combined prior plus new cost is USD21.406147. |
15
66
  | Human third-party acceptance | Separate decision; not supplied by installation, tests or this release status. |
16
67
  | Broad game quality/productivity | Not established. No universal quality, balance, cost or efficiency claim. |
17
68
 
69
+ The 2026-10-27 cases use a known component, unchanged tests and deliberate
70
+ regressions. The fresh-project case starts with API scaffolds and existing metadata;
71
+ native workers author the implementation, but its fixed brief and tests are reused.
72
+ It qualifies the exercised workflow, not independent game creation, large-project
73
+ productivity, new-file import or scene/prefab repair. Design and implementation use
74
+ separate required lifecycle sessions under one cumulative budget, not replacement
75
+ attempts. The native workers and Unity tests ran locally; detailed task, provider
76
+ and measurement evidence is retained outside the public package. This source
77
+ qualification does not qualify the exact published RC archive or promote a release.
78
+
79
+ The 2026-10-28 reserve case qualifies the exact new-script/import and existing
80
+ prefab/scene repair path exercised against Editor 6000.3.17f1 and Unity CLI
81
+ 1.0.0-beta.14. It used a warmed, disclosed fixture and copied dependency code,
82
+ not a cold start or blind game creation. The final reviewer retained one LOW
83
+ non-blocking process finding about a missing dirty-scene precondition; no source
84
+ loss or acceptance impact was observed. The frozen native installation remains
85
+ unchanged. Subsequent source hardening adds coverage checks for legacy worker
86
+ sessions even without optional per-worker cost limits, and explicitly prompts
87
+ the lifecycle `report` command; those additions receive framework tests, not
88
+ new native-execution credit.
89
+ Pre-RC4 maintained-source regression: 230 PASS, 0 FAIL and 6 Windows symlink skips
90
+ across 236 tests; the focused reserve/supervisor suites passed all 30 tests.
91
+
92
+ The settlement fixes do not bypass live descendants. The original cold-project
93
+ compiler-server timeout remains a failed historical attempt. The subsequent
94
+ compiler fix requests graceful shutdown only for the qualified binary pair;
95
+ unknown compilers retain the normal wait and may still time out. Neither change
96
+ removes every possible engine startup, compilation or shutdown delay. See
97
+ [managed process ownership](PHASE-1-OPERATIONS.md#process-ownership-and-locks).
98
+
18
99
  ## Public package boundary
19
100
 
20
101
  The package contains the CLI, framework roles/protocols/hooks, project scaffold,
@@ -29,7 +110,7 @@ change current defaults or add new delivery gates. Current installation guidance
29
110
  is in [UPGRADING.md](../UPGRADING.md) and the
30
111
  [Vietnamese quick start](HUONG-DAN-MIGRATE-VA-SU-DUNG.md).
31
112
 
32
- ## RC3 change scope
113
+ ## Historical RC3 change scope
33
114
 
34
115
  RC1 already standardized package metadata and removed private memory. RC2 finishes
35
116
  public documentation: current standalone defaults, exact-version npm commands,
@@ -0,0 +1,57 @@
1
+ # Chia nhỏ task lớn trong NCCGS
2
+
3
+ Tính năng này được đóng gói trong bản chuẩn bị `2.0.0`, chưa phát hành npm.
4
+ NCCGS vẫn dùng Claude Code để điều phối và thực thi.
5
+
6
+ Task lớn được chia thành các phần việc có mục tiêu, tệp được sửa và quan hệ phụ
7
+ thuộc rõ ràng **trong cùng task**. Mỗi phần nhận đúng các điều kiện nghiệm thu gốc
8
+ liên quan. Phần tích hợp cuối nhận toàn bộ điều kiện. Chia nhỏ không tự tạo task
9
+ con, thêm lượt review hay tăng ngân sách.
10
+
11
+ 1. Coordinator đọc task và thiết kế đã review, chọn ít phần nhất đủ để mỗi lượt
12
+ làm việc có phạm vi rõ ràng. Mỗi phần có 1–8 tệp cụ thể; cả kế hoạch có 2–12 phần.
13
+ Tính cả test và metadata Unity cần tạo. Phần cuối có thể vừa làm hành vi cuối
14
+ vừa tích hợp, tránh thêm một bước bàn giao hình thức.
15
+ 2. Dùng mẫu `.nccgs/templates/task-slices.json`, điền task ID, contract hash,
16
+ snapshot hiện tại, agent, tệp, phụ thuộc và ID điều kiện gốc. Lưu bản nháp vào
17
+ `.nccgs/evidence/slice-plans/`. Mỗi điều kiện gốc, kể cả điều kiện thủ công,
18
+ phải có một phần chịu trách nhiệm chính. Các cổng nghiệm thu vẫn thuộc task.
19
+ 3. Chạy preview để kiểm tra cấu trúc và phần ngân sách còn lại, rồi đăng ký:
20
+
21
+ ```text
22
+ node .claude/nccgs/tools/task.mjs slice-preview --id TASK --file .nccgs/evidence/slice-plans/TASK.json
23
+ node .claude/nccgs/tools/task.mjs slice-plan --id TASK --file .nccgs/evidence/slice-plans/TASK.json
24
+ node .claude/nccgs/tools/task.mjs slice-status --id TASK
25
+ ```
26
+
27
+ 4. Lưu đối tượng `next` từ status vào tệp request và dùng luồng `reserve` →
28
+ `dispatch-prompt` → Agent foreground → handoff hiện có. Các lệnh mới không tự
29
+ khởi chạy agent. Hoàn tất từng phần trước khi làm phần tiếp theo. Checkpoint
30
+ sớm của task vẫn phải được đo trước khi mở rộng.
31
+ 5. Khi mọi phần có trạng thái `DELIVERED`, chạy kiểm tra trên kết quả tích hợp
32
+ hiện tại, ghi implementation bằng lượt tích hợp cuối, rồi review độc lập và
33
+ nghiệm thu theo task gốc. `DELIVERED` chỉ xác nhận bàn giao đầy đủ, không phải
34
+ PASS. Reviewer phải độc lập với tất cả người đã triển khai các phần.
35
+
36
+ Ngân sách đã ghim, ngân sách cha, chi phí/thời gian đo được và ngân sách phiên
37
+ `nccgs run` tiếp tục áp dụng. Nếu chưa có giới hạn dispatch được ghim, đăng ký kế
38
+ hoạch dùng mức mặc định hiện có của task. Kế hoạch phải đủ chỗ cho các phần còn
39
+ lại, review độc lập và phần dự phòng repair/QA/review gốc. Đây là mức tối thiểu về
40
+ số lượt, không bảo đảm đủ tiền hoặc thời gian cho mọi lần thử lại. Không tự tăng
41
+ giới hạn để hoàn tất kế hoạch.
42
+
43
+ Khi cần điều chỉnh, giữ các lượt cũ, tạo plan ID mới với lý do và `supersedes`
44
+ trỏ đến kế hoạch hiện tại. Giữ ID các phần đã thử. Thay đổi phạm vi một phần hoặc
45
+ chạy lại phần nền tảng sẽ làm các kết quả phụ thuộc hết hiệu lực; chúng cần lượt
46
+ bàn giao mới. Phần không thay đổi có thể tái sử dụng khi lần thử mới nhất và các
47
+ phụ thuộc vẫn hợp lệ. Lịch sử, kết luận review âm tính và ngân sách đã tiêu không
48
+ bị xóa. Repair sau tích hợp dùng đúng luồng repair đã có.
49
+
50
+ Xem [giao thức đầy đủ](../.claude/nccgs/protocols/task-slices.md),
51
+ [handoff](HANDOFF-AUTOMATION.md) và [Unity repair](BOUNDED-REPAIR.md).
52
+ Ngày 2026-10-27, một lượt Claude Code/Unity thực đã kiểm chứng hai phần phụ thuộc
53
+ trong cùng task, tích hợp, review độc lập, lỗi PlayMode được ghi nhận, repair và
54
+ review độc lập lần nữa. Cả 24 điều kiện gốc đạt lại; test, lịch sử và ngân sách
55
+ tổng được giữ nguyên. Đây là ca hồi quy có kiểm soát trên component đã có lời
56
+ giải, gồm lỗi được chủ động cài để kiểm chứng repair; chưa chứng minh hiệu quả
57
+ trên task lớn hoặc game mới. Xem [phạm vi bằng chứng](RELEASE-STATUS.md).
@@ -1,6 +1,6 @@
1
1
  # Published 1.3.0 upgrade qualification
2
2
 
3
- Target: **2.0.0-rc.3**. This is installation/configuration qualification on Windows
3
+ Historical target: **2.0.0-rc.3**. This is installation/configuration qualification on Windows
4
4
  with Node.js 24.12.0 using the published npm 1.3.0 archive and the exact RC3 archive.
5
5
  It does not establish Node 18, macOS/Linux, provider execution or gameplay results.
6
6
 
package/docs/WORKFLOWS.md CHANGED
@@ -1,4 +1,4 @@
1
- # NCCGS workflows — 2.0 RC
1
+ # NCCGS workflows — 2.0.0
2
2
 
3
3
  New installations use standalone Claude Code execution with the claude-standalone
4
4
  model profile. The coordinator owns intake, planning, dispatch, verification and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nccgs",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0",
4
4
  "description": "Unity-first game-studio operating system for Claude Code",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public",
31
- "tag": "next",
31
+ "tag": "latest",
32
32
  "registry": "https://registry.npmjs.org/"
33
33
  },
34
34
  "scripts": {
@@ -0,0 +1,18 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "repairType": "unity-code",
4
+ "taskId": "REPLACE_WITH_TASK_ID",
5
+ "contractHash": "REPLACE_WITH_CURRENT_CONTRACT_HASH",
6
+ "sourceSnapshot": "REPLACE_WITH_CURRENT_SOURCE_SNAPSHOT",
7
+ "problem": "Describe the recorded failure and its evidence.",
8
+ "solution": "State the chosen correction, relevant callers and regression coverage.",
9
+ "changes": [
10
+ { "path": "Assets/REPLACE_WITH_SOURCE.cs", "operation": "edit", "instruction": "Apply the exact chosen correction; preserve the full acceptance contract." }
11
+ ],
12
+ "context": [],
13
+ "verification": ["REPLACE_WITH_REQUIRED_CHECK_NAME"],
14
+ "unity": {
15
+ "steps": []
16
+ },
17
+ "budget": { "workCalls": 24, "readCalls": 12, "handoffCalls": 3, "durationMs": 900000 }
18
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "repairType": "unity-editor",
4
+ "taskId": "REPLACE_WITH_TASK_ID",
5
+ "contractHash": "REPLACE_WITH_CURRENT_CONTRACT_HASH",
6
+ "sourceSnapshot": "REPLACE_WITH_CURRENT_SOURCE_SNAPSHOT",
7
+ "problem": "Describe the recorded scene, prefab or asset failure.",
8
+ "solution": "State the chosen Editor operation and how it saves only the exact affected files.",
9
+ "changes": [
10
+ { "path": "Assets/REPLACE_WITH_PREFAB.prefab", "operation": "edit", "instruction": "Apply and save the chosen correction through Unity Editor APIs." }
11
+ ],
12
+ "context": [],
13
+ "verification": ["REPLACE_WITH_REQUIRED_CHECK_NAME"],
14
+ "unity": {
15
+ "capabilities": { "path": ".nccgs/evidence/REPLACE_WITH_UNITY_DISCOVERY.json", "sha256": "REPLACE_WITH_CAPTURED_HASH" },
16
+ "steps": [
17
+ { "id": "apply-and-save", "command": "eval", "arguments": ["REPLACE_WITH_CHOSEN_CSHARP_BODY_USING_FULLY_QUALIFIED_TYPES"], "timeoutMs": 30000 }
18
+ ]
19
+ },
20
+ "budget": { "workCalls": 20, "readCalls": 8, "handoffCalls": 3, "durationMs": 900000 }
21
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "taskId": "REPLACE_WITH_EXISTING_TASK_ID",
4
+ "contractHash": "REPLACE_WITH_CURRENT_CONTRACT_HASH",
5
+ "sourceSnapshot": "REPLACE_WITH_CURRENT_SOURCE_SNAPSHOT",
6
+ "planId": "delivery-one",
7
+ "supersedes": null,
8
+ "reason": "Split the existing contract into bounded assignments within its remaining budget.",
9
+ "integration": "integrate",
10
+ "slices": [
11
+ {
12
+ "id": "foundation",
13
+ "objective": "Implement the first coherent behavior and its targeted test.",
14
+ "agent": "nccgs-gameplay-programmer",
15
+ "dependsOn": [],
16
+ "writePaths": ["Assets/REPLACE_WITH_FIRST_SOURCE.cs", "Assets/Tests/REPLACE_WITH_FIRST_TEST.cs"],
17
+ "criteria": ["REPLACE_WITH_ORIGINAL_CRITERION_ID"]
18
+ },
19
+ {
20
+ "id": "integrate",
21
+ "objective": "Implement the remaining behavior and integrate the full original contract.",
22
+ "agent": "nccgs-gameplay-programmer",
23
+ "dependsOn": ["foundation"],
24
+ "writePaths": ["Assets/REPLACE_WITH_SECOND_SOURCE.cs", "Assets/Tests/REPLACE_WITH_INTEGRATION_TEST.cs"],
25
+ "criteria": ["REPLACE_WITH_REMAINING_ORIGINAL_CRITERION_ID"]
26
+ }
27
+ ]
28
+ }
package/scripts/cli.mjs CHANGED
@@ -171,6 +171,10 @@ Usage:
171
171
  nccgs run --supervise --task ID --prompt-file FILE --session-budget-usd N [--max-resumes 2] [--timeout-ms 3600000] -- [provider options]
172
172
  nccgs run --recover-run RUN_ID [--project DIR] [--claude EXECUTABLE]
173
173
  nccgs task init|snapshot|ref|observe|verify|acceptance-status|record|check|close|bind|extend-review|refresh-inputs|migrate-evidence [options]
174
+ nccgs task dispatch-prompt|handoff-validate|record-review --id TASK --dispatch ID [--file HANDOFF]
175
+ nccgs task repair-editor --id TASK --dispatch ID --step STEP (admitted Unity repair worker only)
176
+ nccgs task slice-preview|slice-plan --id TASK --file PLAN (same task and budget)
177
+ nccgs task slice-status --id TASK
174
178
  nccgs agents --enable <role> | --disable <role> [--project <directory>]
175
179
  nccgs policy [--write] Check/regenerate package routing
176
180
  nccgs migrate-execution --to standalone [--external-review off|advisory|required] [--model-profile <profile>] [--dry-run]
package/scripts/run.mjs CHANGED
@@ -16,13 +16,14 @@ export function launchPlan(argv, env = process.env) {
16
16
  const option = options[i];
17
17
  if (option === "--dry-run") { dryRun = true; continue; }
18
18
  if (option === "--supervise") { supervised = true; continue; }
19
- if (!["--project", "--claude", "--task", "--prompt-file", "--max-resumes", "--timeout-ms", "--session-budget-usd", "--recover-run"].includes(option) || !options[i + 1] || options[i + 1].startsWith("--")) throw new Error(`Invalid run option: ${option}; put Claude arguments after --`);
19
+ if (!["--project", "--claude", "--task", "--prompt-file", "--max-resumes", "--timeout-ms", "--session-budget-usd", "--recover-run", "--budget-phase"].includes(option) || !options[i + 1] || options[i + 1].startsWith("--")) throw new Error(`Invalid run option: ${option}; put Claude arguments after --`);
20
20
  const value = options[++i];
21
21
  if (option === "--project") project = path.resolve(value);
22
22
  else if (option === "--claude") binary = value;
23
23
  else if (option === "--task") supervision.taskId = value;
24
24
  else if (option === "--prompt-file") supervision.promptFile = path.resolve(value);
25
25
  else if (option === "--recover-run") { supervision.recoverRun = value; supervised = true; }
26
+ else if (option === "--budget-phase") { if (!["work", "final-review"].includes(value)) throw new Error("Budget phase must be work or final-review"); supervision.budgetPhase = value; }
26
27
  else if (option === "--max-resumes") supervision.maxResumes = Number(value);
27
28
  else if (option === "--timeout-ms") supervision.timeoutMs = Number(value);
28
29
  else supervision.budgetUsd = Number(value);
@@ -35,14 +36,14 @@ export function launchPlan(argv, env = process.env) {
35
36
  for (const argument of forwarded) if (conflicting.test(argument)) throw new Error(`NCCGS owns session permission/root settings; conflicting option: ${argument}`);
36
37
  if (supervised) {
37
38
  if (supervision.recoverRun) {
38
- if (forwarded.length || supervision.taskId || supervision.promptFile || supervision.budgetUsd !== undefined || options.includes("--max-resumes") || options.includes("--timeout-ms")) throw new Error("Recovery preserves the original prompt, limits and provider arguments");
39
+ if (forwarded.length || supervision.taskId || supervision.promptFile || supervision.budgetUsd !== undefined || supervision.budgetPhase || options.includes("--max-resumes") || options.includes("--timeout-ms")) throw new Error("Recovery preserves the original prompt, limits and provider arguments");
39
40
  } else {
40
41
  if (!supervision.taskId || !supervision.promptFile || !Number.isFinite(supervision.budgetUsd) || supervision.budgetUsd <= 0) throw new Error("Supervision needs --task, --prompt-file and --session-budget-usd");
41
42
  if (!Number.isSafeInteger(supervision.maxResumes) || supervision.maxResumes < 0 || supervision.maxResumes > 5 || !Number.isSafeInteger(supervision.timeoutMs) || supervision.timeoutMs < 1000 || supervision.timeoutMs > 86400000) throw new Error("Invalid supervision continuation/time limits");
42
43
  const owned = /^(?:-p|--print|--output-format|--input-format|--session-id|--resume|-r|--continue|-c|--fork-session|--no-session-persistence|--max-budget-usd|--verbose|--bg|--background|--remote|--cloud)(?:=|$)/;
43
44
  for (const argument of forwarded) if (owned.test(argument)) throw new Error(`Supervisor owns native lifecycle option: ${argument}`);
44
45
  }
45
- } else if (options.some(option => ["--task", "--prompt-file", "--max-resumes", "--timeout-ms", "--session-budget-usd"].includes(option))) throw new Error("Lifecycle options require --supervise");
46
+ } else if (options.some(option => ["--task", "--prompt-file", "--max-resumes", "--timeout-ms", "--session-budget-usd", "--budget-phase"].includes(option))) throw new Error("Lifecycle options require --supervise");
46
47
  return { project, binary, dryRun, mode, args: ["--permission-mode", mode === "full" ? "bypassPermissions" : "default", ...forwarded],
47
48
  supervision: supervised ? supervision : null, env: { ...env, NCCGS_PROJECT_ROOT: project, NCCGS_TASK_AUTONOMY: mode,
48
49
  // Native auto-backgrounding can otherwise turn a claimed foreground worker