codex-workflow-v2 2.0.0-alpha.3 → 2.0.0-alpha.4

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.
@@ -92,6 +92,95 @@ handshake, doctor, status и next. Подтверди точную declared/inst
92
92
  нужно выполнить `scan/reconcile`, показать пользователю изменения классификации и получить
93
93
  approval, если он требуется.
94
94
 
95
+ ## 3.1. При необходимости включите delegated approval
96
+
97
+ Delegated approval не включается автоматически после обновления. Существующие авторизации и
98
+ terminal-сущности не меняются, а `stateSchemaVersion` остаётся `2`. Пользователь один раз
99
+ подтверждает точную policy; после этого named delegate может выполнять только перечисленные
100
+ переходы до истечения срока или revocation.
101
+
102
+ Для заместителя, который должен планировать ещё не созданные Milestones и Tasks, нужен
103
+ ограниченный по времени project scope. Более узкий Milestone/Task scope безопаснее, когда ID
104
+ уже известен. Пример policy:
105
+
106
+ ```json
107
+ {
108
+ "principal": "user:owner",
109
+ "delegate": "agent:deputy",
110
+ "scope": { "kind": "project" },
111
+ "transitions": [
112
+ "project_memory.approve",
113
+ "milestone.execution_authorize",
114
+ "milestone.final_accept",
115
+ "task.execution_authorize",
116
+ "task.final_accept"
117
+ ],
118
+ "expiresAt": "<ISO-8601 UTC>"
119
+ }
120
+ ```
121
+
122
+ Промпт для выпуска grant:
123
+
124
+ ```text
125
+ Подготовь delegated approval policy для этого проекта: principal user:owner,
126
+ delegate agent:deputy, project scope, переходы project_memory.approve,
127
+ milestone.execution_authorize,
128
+ milestone.final_accept, task.execution_authorize и task.final_accept, срок до
129
+ <ДАТА_И_ВРЕМЯ_UTC>. Создай временный JSON вне репозитория и выполни только
130
+ delegation prepare. Покажи всю policy, projectId, policyHash и DGA-код, затем
131
+ остановись. Grant в этом же ответе не выпускай.
132
+ ```
133
+
134
+ После проверки ответьте отдельным сообщением:
135
+
136
+ ```text
137
+ Одобряю выпуск delegated approval grant для policy hash <POLICY_HASH>
138
+ с кодом <DGA-CODE>. Выпусти grant и покажи DGR-ID, scope, transitions,
139
+ expiresAt и revision.
140
+ ```
141
+
142
+ `delegation list` и `status` показывают grants. Для досрочной остановки автономности агент
143
+ выполняет `delegation revoke` от имени точного principal с текущей revision и причиной.
144
+ Revocation запрещает будущие использования, но не переписывает уже записанные события.
145
+
146
+ Важно: это локальная проверка policy и audit trail, а не криптографическая аутентификация
147
+ Codex-процесса. Любой процесс с доступом к локальному state и CLI может заявить строку
148
+ delegate. Поэтому project-wide grant должен быть короткоживущим, а секреты, платежи, реальные
149
+ торговые операции и иные необратимые действия требуют отдельных технических ограничений и не
150
+ должны полагаться только на delegated approval.
151
+
152
+ ## 3.2. Запустите delegate в новом чате
153
+
154
+ Grant сам не запускает агента и не прикрепляется к существующему чату. После получения
155
+ `DGR-ID` откройте новый Local-чат в том же Codex Project. Новый чат нужен ещё и потому, что он
156
+ загрузит актуальную gateway-инструкцию. Передайте точные `delegate` и `DGR-ID`; `DGA-код`
157
+ больше не нужен.
158
+
159
+ Перед запуском проверьте выбор scope:
160
+
161
+ - новый Milestone или новая standalone Task с `AUTO` требуют project scope;
162
+ - существующий Milestone и его linked Tasks могут использовать Milestone scope;
163
+ - одна существующая Task может использовать Task scope;
164
+ - Knowledge Map approval доступен только project-scoped grant с
165
+ `project_memory.approve`.
166
+
167
+ Полные копируемые промпты для Milestone delegate и Task delegate находятся в
168
+ `docs/delegated-approval.md` и chat-only PDF. В обоих промптах delegate обязан сначала
169
+ выполнить `delegation show`, а каждый approval применять только при exact записи в текущем
170
+ `next.delegatedApprovalOptions`. Внутренние Worker и Independent Reviewer grant не используют:
171
+ его применяет координатор после получения их evidence.
172
+
173
+ Рекомендуемые названия чатов:
174
+
175
+ ```text
176
+ NN - M2 delegated coordinator
177
+ NN - M2/T1 delegated execution
178
+ NN - Standalone delegated task
179
+ ```
180
+
181
+ После завершения автономного окна попросите отдельный контрольный чат показать
182
+ `delegation list`, использованные authorization events и отозвать ненужный широкий grant.
183
+
95
184
  ## 4. Продолжите начатый Milestone или создайте следующий
96
185
 
97
186
  Terminal Milestone со статусом `accepted` остаётся закрытым. Для следующего результата нужно
@@ -1,26 +1,36 @@
1
1
  # V2 Alpha Validation Report
2
2
 
3
- Release candidate `2.0.0-alpha.3` was validated on 2026-08-12 with Node.js 24.17.0.
3
+ Release candidate `2.0.0-alpha.4` was validated on 2026-08-12 with Node.js 24.17.0.
4
4
 
5
5
  - TypeScript typecheck and build passed.
6
- - All 41 unit and integration tests passed. Coverage includes the complete Task lifecycle,
6
+ - All 47 unit and integration tests passed. Coverage includes the complete Task lifecycle,
7
7
  a Project Knowledge Map change between Steps, preservation of completed Step evidence,
8
8
  mandatory reauthorization, the public `task knowledge-rebind` CLI route, no-op and active
9
9
  Worker rejection, current gateway capability negotiation, and rejection of deprecated
10
10
  state schema instead of migration.
11
+ - Delegated approval coverage includes DGA-bound grant issuance, project/Milestone/Task
12
+ scopes, Knowledge Map approval, all Task/Milestone execution and final transitions,
13
+ `next.delegatedApprovalOptions`, explicit principal/delegate audit metadata, actor,
14
+ transition and scope rejection, expiry, revocation, duplicate issuance, and policy-hash
15
+ tamper rejection.
11
16
  - Milestone scheduling now ignores unstarted Tasks with cancelled/waived or terminal
12
17
  membership paths. Final Milestone acceptance exposes a revision/hash/HEAD-bound human gate,
13
18
  rejects a wrong code, and regenerates its code after base advancement and revalidation.
14
19
  - Milestone amendments, graph binding, deterministic V1 snapshot, symlink rejection, writer
15
20
  leases, and strict reviewer fail-closed behavior also passed.
16
- - npm dry-run packaging produced `codex-workflow-v2-2.0.0-alpha.3.tgz` with runtime, schemas,
21
+ - npm dry-run packaging produced `codex-workflow-v2-2.0.0-alpha.4.tgz` with runtime, schemas,
17
22
  roles, references, docs, and plugin source.
18
23
  - Downstream installation from that tarball and the packaged CLI handshake passed; the
19
24
  installation created none of the forbidden repository workflow directories.
20
- - Plugin validation and the repository release check passed for `2.0.0-alpha.3`.
21
- - The alpha.3 CLI read the existing Signal project state created by alpha.2 without migration:
22
- project ID and accepted Milestone 1 were preserved, while repository-level `next` returned
23
- `idle` instead of the historical cancelled Task.
25
+ - Plugin validation and the repository release check passed for `2.0.0-alpha.4`.
26
+ - The alpha.4 CLI read the existing Signal schema 2 project state without migration:
27
+ project ID `b06d0f18f790f4521a23c770`, accepted Milestone 1 revision 10, historical
28
+ authorization events, and all entity IDs were preserved; `delegations` was an empty
29
+ additive collection and repository-level `next` remained `idle`.
30
+ - The three Russian PDFs were regenerated and all 40 pages were rendered to PNG for visual
31
+ inspection; delegated approval, compatibility, grant issuance, audit, revocation, and
32
+ chat-only grant issuance and Milestone/Task delegate launch prompts are present without
33
+ layout defects.
24
34
 
25
35
  The strict reviewer implementation did not change in this release candidate. Its original
26
36
  2026-07-16 real Codex CLI isolation probe denied a repository write and returned
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-workflow-v2",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "Requirements-first Codex development workflow with local state and explicit Git ownership.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,6 +12,7 @@ Require package name `codex-workflow-v2`, protocol version `1`, state
12
12
  schema version `2`, and the capabilities needed for the requested operation. Task execution
13
13
  that may cross a Project Knowledge Map revision requires `task-knowledge-rebind-v1`.
14
14
  Milestone final acceptance requires `milestone-human-final-gate-v1`.
15
+ Autonomous approval requires `delegated-approval-v1`.
15
16
 
16
17
  ## Milestone Human Gate
17
18
 
@@ -29,6 +30,18 @@ codex-workflow milestone accept --repo <git-root> --id <MS-ID> \
29
30
  Do not infer approval from the request that initiated validation. A changed revision, hash,
30
31
  or HEAD requires a new gate.
31
32
 
33
+ ## Delegated Approval
34
+
35
+ `delegation prepare --file <policy.json>` returns a `delegation_grant_issuance` gate with a
36
+ project-bound policy hash and `DGA-*` confirmation code. Display it and end the turn. A later
37
+ explicit user message containing the exact code permits `delegation grant`.
38
+
39
+ Active eligible grants appear in `next.delegatedApprovalOptions`. Use only the option whose
40
+ transition matches the requested command, with the named delegate as actor and the grant ID
41
+ as `--delegation-grant`. The resulting authorization event records the grant and both actors.
42
+ For `milestone.final_accept`, also pass the current `MSA-*` code; the existing grant replaces
43
+ the later-message requirement, not the state binding.
44
+
32
45
  ## Graph Refresh Request
33
46
 
34
47
  The package returns:
@@ -64,7 +64,9 @@ independently blocks the workflow.
64
64
 
65
65
  ## Human Gates
66
66
 
67
- Treat `requiredHumanGate` from the project-local package as a mandatory turn boundary.
67
+ Treat `requiredHumanGate` from the project-local package as a mandatory turn boundary unless
68
+ the same `next` response contains a currently eligible `delegatedApprovalOptions` entry for
69
+ the exact transition and the agent is the entry's named delegate.
68
70
  For `milestone_final_acceptance`, show the user the Milestone ID, revision, Plan hash,
69
71
  Result hash, evidence hash, validated HEAD, and confirmation code. Ask whether the user
70
72
  accepts that exact result, then stop without invoking `milestone accept`.
@@ -75,6 +77,24 @@ A generic instruction such as “continue”, “finish”, or “bring it to fi
75
77
  final acceptance. If `next` returns a different code or binding, discard the old response
76
78
  and ask again.
77
79
 
80
+ ## Delegated Approval
81
+
82
+ Delegation issuance is itself a mandatory human turn boundary. Run `delegation prepare` with
83
+ the proposed policy, show the complete principal, delegate, scope, transitions, expiry,
84
+ policy hash, and `DGA-*` confirmation code, then stop. Only after a later user message
85
+ explicitly approves that exact code may `delegation grant` be invoked.
86
+
87
+ Never create, broaden, renew, or replace a grant from an agent's own judgment. Never record
88
+ the delegate as the user. When `next` exposes an eligible option, pass its grant ID through
89
+ `--delegation-grant` and use the exact delegate string as `--actor`. The core remains the
90
+ authority for status, expiry, scope, transition, and revocation checks.
91
+
92
+ For delegated Milestone final acceptance, the current `MSA-*` code is still required, but a
93
+ new user turn is not: the previously issued grant is the controlling decision. If no eligible
94
+ option is returned, follow the ordinary human-gate rule above. Knowledge Map approval is
95
+ delegable only through an explicit project-scoped `project_memory.approve` permission. Scope
96
+ changes, grant issuance, and grant expansion are never delegated by `delegated-approval-v1`.
97
+
78
98
  ## Stop Conditions
79
99
 
80
100
  - Dependency version is missing, ranged, or differs from the installed package.
@@ -84,4 +104,4 @@ and ask again.
84
104
  - An action would make MCP or the local map authoritative project memory.
85
105
  - A requested mutation is not authorized by the package CLI state.
86
106
  - A human gate was emitted but the user has not approved its exact confirmation code in a
87
- later message.
107
+ later message and no exact eligible delegated approval option exists.
@@ -6,6 +6,14 @@ to the task commit and Brief, Plan, and evidence hashes. Final acceptance is a s
6
6
  human event bound to Result, evidence, and commit. Locks expire only diagnostically;
7
7
  removing a stale lock is always an explicit repair operation.
8
8
 
9
+ Human approval remains the default. A user may instead issue a time-bound delegation grant
10
+ after confirming a deterministic `DGA-*` code bound to the project and exact policy hash.
11
+ The policy names a distinct principal and delegate, a project/Milestone/Task scope, and an
12
+ allow-list of approval transitions. Delegated transitions fail closed on actor, scope,
13
+ transition, expiry, revocation, or project mismatch. Their authorization events record
14
+ `authorizationMode: delegated` plus the grant ID, policy hash, principal, delegate, and exact
15
+ transition; the delegate is never recorded as the user.
16
+
9
17
  When an approved Project Knowledge Map changes between Task Steps, the coordinator first
10
18
  reconciles and obtains approval for the new map, then uses `task knowledge-rebind`. This
11
19
  mechanical transition preserves Step definitions, runtime status, and evidence, records both
@@ -21,6 +29,10 @@ valid only after a later explicit user response repeats that code; the CLI requi
21
29
  explicit actor and the exact code. Cancellation records intent but performs no Git reversal.
22
30
  If the base HEAD or final artifacts change before acceptance, `next` withholds the gate and
23
31
  requires Milestone validation again; revalidation supersedes the previous candidate binding.
32
+ An already issued grant containing `milestone.final_accept` may cross that gate autonomously,
33
+ but the acceptance command still requires the current `MSA-*` code so the use remains bound
34
+ to the validated revision, hashes, and HEAD. Grant issuance itself always remains a prior
35
+ human turn boundary.
24
36
 
25
37
  Repository-level scheduling respects current Milestone membership. An unstarted linked Task
26
38
  is eligible only for an `active` Milestone with `required` disposition. Historical unstarted
@@ -0,0 +1,55 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codex-workflow.local/schemas/authorization-event.schema.json",
4
+ "title": "Codex Workflow V2 Authorization Event",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "kind", "decision", "actor", "recordedAt", "briefHash", "planHash", "resultHash",
9
+ "evidenceHash", "headCommit", "reason"
10
+ ],
11
+ "properties": {
12
+ "kind": { "enum": ["execution", "final_acceptance", "exception"] },
13
+ "decision": { "enum": ["approved", "rejected", "waived", "superseded"] },
14
+ "actor": { "type": "string", "minLength": 1 },
15
+ "recordedAt": { "type": "string", "format": "date-time" },
16
+ "briefHash": { "$ref": "#/$defs/nullableHash" },
17
+ "planHash": { "$ref": "#/$defs/nullableHash" },
18
+ "resultHash": { "$ref": "#/$defs/nullableHash" },
19
+ "evidenceHash": { "$ref": "#/$defs/nullableHash" },
20
+ "headCommit": { "$ref": "#/$defs/nullableHash" },
21
+ "reason": { "type": "string" },
22
+ "authorizationMode": { "enum": ["human", "delegated"] },
23
+ "delegation": { "$ref": "#/$defs/delegation" }
24
+ },
25
+ "allOf": [
26
+ {
27
+ "if": {
28
+ "properties": { "authorizationMode": { "const": "delegated" } },
29
+ "required": ["authorizationMode"]
30
+ },
31
+ "then": { "required": ["delegation"] }
32
+ }
33
+ ],
34
+ "$defs": {
35
+ "nullableHash": { "type": ["string", "null"], "pattern": "^[a-f0-9]{40,64}$" },
36
+ "delegation": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "required": ["grantId", "policyHash", "principal", "delegate", "transition"],
40
+ "properties": {
41
+ "grantId": { "type": "string", "pattern": "^DGR-[0-9A-HJKMNP-TV-Z]{26}$" },
42
+ "policyHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
43
+ "principal": { "type": "string", "minLength": 1 },
44
+ "delegate": { "type": "string", "minLength": 1 },
45
+ "transition": {
46
+ "enum": [
47
+ "project_memory.approve",
48
+ "task.execution_authorize", "task.final_accept",
49
+ "milestone.execution_authorize", "milestone.final_accept"
50
+ ]
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codex-workflow.local/schemas/delegation-grant.schema.json",
4
+ "title": "Codex Workflow V2 Delegation Grant",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion", "revision", "id", "projectId", "createdAt", "updatedAt", "kind",
9
+ "status", "principal", "delegate", "scope", "transitions", "expiresAt", "policyHash",
10
+ "revokedAt", "revokedBy", "revokeReason"
11
+ ],
12
+ "properties": {
13
+ "schemaVersion": { "const": 2 },
14
+ "revision": { "type": "integer", "minimum": 1 },
15
+ "id": { "type": "string", "pattern": "^DGR-[0-9A-HJKMNP-TV-Z]{26}$" },
16
+ "projectId": { "type": "string", "pattern": "^[a-f0-9]{24}$" },
17
+ "createdAt": { "type": "string", "format": "date-time" },
18
+ "updatedAt": { "type": "string", "format": "date-time" },
19
+ "kind": { "const": "delegation-grant" },
20
+ "status": { "enum": ["active", "revoked"] },
21
+ "principal": { "type": "string", "minLength": 1 },
22
+ "delegate": { "type": "string", "minLength": 1 },
23
+ "scope": {
24
+ "oneOf": [
25
+ {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["kind"],
29
+ "properties": { "kind": { "const": "project" } }
30
+ },
31
+ {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "required": ["kind", "id"],
35
+ "properties": {
36
+ "kind": { "const": "milestone" },
37
+ "id": { "type": "string", "pattern": "^MS-[0-9A-HJKMNP-TV-Z]{26}$" }
38
+ }
39
+ },
40
+ {
41
+ "type": "object",
42
+ "additionalProperties": false,
43
+ "required": ["kind", "id"],
44
+ "properties": {
45
+ "kind": { "const": "task" },
46
+ "id": { "type": "string", "pattern": "^TASK-[0-9A-HJKMNP-TV-Z]{26}$" }
47
+ }
48
+ }
49
+ ]
50
+ },
51
+ "transitions": {
52
+ "type": "array",
53
+ "minItems": 1,
54
+ "uniqueItems": true,
55
+ "items": {
56
+ "enum": [
57
+ "project_memory.approve",
58
+ "task.execution_authorize", "task.final_accept",
59
+ "milestone.execution_authorize", "milestone.final_accept"
60
+ ]
61
+ }
62
+ },
63
+ "expiresAt": { "type": "string", "format": "date-time" },
64
+ "policyHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
65
+ "revokedAt": { "type": ["string", "null"], "format": "date-time" },
66
+ "revokedBy": { "type": ["string", "null"] },
67
+ "revokeReason": { "type": ["string", "null"] }
68
+ }
69
+ }