@naxodev/apnea 0.2.0 → 0.2.2

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 (44) hide show
  1. package/README.md +18 -1
  2. package/SECURITY.md +36 -0
  3. package/briefs/orchestrator.md +4 -3
  4. package/dist/cli.js +8375 -15093
  5. package/docs/protocol/artifacts.md +18 -2
  6. package/docs/protocol/config.md +15 -3
  7. package/docs/protocol/manual-gate.md +8 -8
  8. package/docs/protocol/overview.md +17 -4
  9. package/extension/adapters/commit.ts +5 -1
  10. package/extension/adapters/dispatch.ts +9 -1
  11. package/extension/adapters/setup.ts +15 -1
  12. package/extension/adapters/start.ts +5 -1
  13. package/extension/adapters/status.ts +17 -2
  14. package/extension/adapters/wait.ts +6 -1
  15. package/extension/api.ts +7 -1
  16. package/extension/cli/main.ts +67 -7
  17. package/extension/cli/parse.ts +172 -5
  18. package/extension/domain/paths.ts +2 -11
  19. package/extension/domain/timeouts.ts +4 -0
  20. package/extension/domain/types.ts +65 -3
  21. package/extension/errors.ts +51 -16
  22. package/extension/operation-hooks.ts +6 -0
  23. package/extension/registry.ts +29 -15
  24. package/extension/run-tool.ts +19 -2
  25. package/extension/schema/config.ts +58 -16
  26. package/extension/schema/frontmatter.ts +57 -0
  27. package/extension/schema/state.ts +210 -13
  28. package/extension/services/app-live.ts +2 -1
  29. package/extension/services/config.ts +6 -4
  30. package/extension/services/file-system.ts +346 -75
  31. package/extension/services/herdr.ts +466 -260
  32. package/extension/services/operation-lock.ts +452 -0
  33. package/extension/services/process.ts +477 -0
  34. package/extension/services/run-store.ts +38 -16
  35. package/extension/services/vcs.ts +1258 -328
  36. package/extension/workflows/commit.ts +214 -13
  37. package/extension/workflows/dispatch.ts +305 -67
  38. package/extension/workflows/setup.ts +59 -32
  39. package/extension/workflows/start.ts +6 -4
  40. package/extension/workflows/status.ts +2 -2
  41. package/extension/workflows/wait.ts +62 -77
  42. package/package.json +2 -2
  43. package/schemas/config.schema.json +5 -1
  44. package/schemas/state.schema.json +165 -11
@@ -5,8 +5,21 @@
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "required": ["version", "slug", "step", "phase_index", "rounds", "vcs"],
8
+ "allOf": [
9
+ {
10
+ "if": {
11
+ "properties": { "version": { "const": 2 } },
12
+ "required": ["version"]
13
+ },
14
+ "then": { "required": ["pending_commit"] },
15
+ "description": "Runtime enforcement is authoritative: decodeRunState applies the same rule plus consistency checks the JSON Schema cannot express."
16
+ }
17
+ ],
8
18
  "properties": {
9
- "version": { "const": 1 },
19
+ "version": {
20
+ "enum": [1, 2],
21
+ "description": "Version 1 is accepted INPUT for migration (decodes with pending_commit=null); version 2 is the OUTPUT every save writes and must carry pending_commit explicitly."
22
+ },
10
23
  "slug": { "type": "string", "minLength": 1 },
11
24
  "step": {
12
25
  "type": "string",
@@ -21,19 +34,39 @@
21
34
  "done"
22
35
  ]
23
36
  },
24
- "phase_index": { "type": "integer", "minimum": 0 },
25
- "phase_count_hint": { "type": ["integer", "null"], "minimum": 0 },
37
+ "phase_index": {
38
+ "type": "integer",
39
+ "minimum": 1,
40
+ "maximum": 9007199254740991
41
+ },
42
+ "phase_count_hint": {
43
+ "type": ["integer", "null"],
44
+ "minimum": 0,
45
+ "maximum": 9007199254740991
46
+ },
26
47
  "rounds": {
27
48
  "type": "object",
28
49
  "description": "Keys like phase-01/plan_review or phase-01/code_review",
29
- "additionalProperties": { "type": "integer", "minimum": 1 }
50
+ "additionalProperties": {
51
+ "type": "integer",
52
+ "minimum": 1,
53
+ "maximum": 9007199254740991
54
+ }
30
55
  },
31
56
  "vcs": { "type": "string", "enum": ["jj", "git"] },
32
57
  "allow_dirty": { "type": "boolean" },
33
58
  "goal": { "type": "string" },
34
59
  "last_error": { "type": ["string", "null"] },
35
- "pending_artifact": { "type": ["string", "null"] },
60
+ "pending_artifact": {
61
+ "type": ["string", "null"],
62
+ "pattern": "^\\.apnea\\/(?!.*\\u0000)(?!\\.(?:/|$)|\\.\\.(?:/|$))(?!.*\\/\\.(?:\\/|$))(?!.*\\/\\.\\.(?:\\/|$))(?!.*\\\\)[^/]+(?:/[^/]+)*$"
63
+ },
36
64
  "pending_role": { "type": ["string", "null"] },
65
+ "pending_delivery": {
66
+ "type": ["string", "null"],
67
+ "enum": ["manual", "interactive", null],
68
+ "description": "Known delivery boundary for pending ownership; null is idle or legacy-ambiguous"
69
+ },
37
70
  "pending_floating_exit": {
38
71
  "type": "null",
39
72
  "deprecated": true,
@@ -41,9 +74,21 @@
41
74
  },
42
75
  "pending_pane_id": { "type": ["string", "null"] },
43
76
  "pending_pane_label": { "type": ["string", "null"] },
44
- "pending_started_at": { "type": ["integer", "null"] },
45
- "pending_deadline_ms": { "type": ["integer", "null"] },
46
- "pending_nudged_at": { "type": ["integer", "null"] },
77
+ "pending_started_at": {
78
+ "type": ["integer", "null"],
79
+ "minimum": 0,
80
+ "maximum": 9007199254740991
81
+ },
82
+ "pending_deadline_ms": {
83
+ "type": ["integer", "null"],
84
+ "minimum": 0,
85
+ "maximum": 9007199254740991
86
+ },
87
+ "pending_nudged_at": {
88
+ "type": ["integer", "null"],
89
+ "minimum": 0,
90
+ "maximum": 9007199254740991
91
+ },
47
92
  "pending_final_grace": { "type": "boolean" },
48
93
  "pending_extended": { "type": "boolean" },
49
94
  "role_panes": {
@@ -60,8 +105,117 @@
60
105
  },
61
106
  "package_root": { "type": "string" },
62
107
  "reviewer_tree_fingerprint": { "type": ["string", "null"] },
63
- "current_phase_package": { "type": ["string", "null"] },
64
- "current_code_review": { "type": ["string", "null"] },
65
- "phase_package_rework": { "type": "boolean" }
108
+ "current_phase_package": {
109
+ "type": ["string", "null"],
110
+ "pattern": "^\\.apnea\\/(?!.*\\u0000)(?!\\.(?:/|$)|\\.\\.(?:/|$))(?!.*\\/\\.(?:\\/|$))(?!.*\\/\\.\\.(?:\\/|$))(?!.*\\\\)[^/]+(?:/[^/]+)*$"
111
+ },
112
+ "current_code_review": {
113
+ "type": ["string", "null"],
114
+ "pattern": "^\\.apnea\\/(?!.*\\u0000)(?!\\.(?:/|$)|\\.\\.(?:/|$))(?!.*\\/\\.(?:\\/|$))(?!.*\\/\\.\\.(?:\\/|$))(?!.*\\\\)[^/]+(?:/[^/]+)*$"
115
+ },
116
+ "required_rework": {
117
+ "type": ["string", "null"],
118
+ "enum": ["plan", "code", "phase_package", null],
119
+ "description": "Exact dispatch target that owns the next review round"
120
+ },
121
+ "pending_commit": {
122
+ "description": "Durable record of an in-flight commit transaction (crash-recoverable commit completion). Requires step=committing and phase_index equal to the run's phase_index; non-committing states must carry null. Version-1 files must not contain this key.",
123
+ "oneOf": [
124
+ {
125
+ "type": "null"
126
+ },
127
+ {
128
+ "type": "object",
129
+ "additionalProperties": false,
130
+ "required": [
131
+ "backend",
132
+ "id",
133
+ "phase_index",
134
+ "message",
135
+ "no_remaining_phases",
136
+ "verify_log",
137
+ "branch",
138
+ "parent_commit",
139
+ "tree_id"
140
+ ],
141
+ "properties": {
142
+ "backend": { "const": "git" },
143
+ "id": {
144
+ "type": "string",
145
+ "minLength": 1,
146
+ "description": "Transaction uuid; appears in the commit message as Apnea-Transaction: <id>"
147
+ },
148
+ "phase_index": { "type": "integer", "minimum": 1 },
149
+ "message": {
150
+ "type": "string",
151
+ "minLength": 1,
152
+ "description": "Full commit message including the Apnea-Transaction trailer line"
153
+ },
154
+ "no_remaining_phases": { "type": "boolean" },
155
+ "verify_log": { "type": "string", "minLength": 1 },
156
+ "branch": {
157
+ "type": "string",
158
+ "minLength": 1,
159
+ "description": "Full ref the commit must land on, e.g. refs/heads/apnea/<slug>"
160
+ },
161
+ "parent_commit": {
162
+ "type": "string",
163
+ "minLength": 1,
164
+ "description": "Expected HEAD at completion; also the created commit's parent"
165
+ },
166
+ "tree_id": {
167
+ "type": "string",
168
+ "minLength": 1,
169
+ "description": "Prepared tree id staged with .apnea excluded"
170
+ }
171
+ }
172
+ },
173
+ {
174
+ "type": "object",
175
+ "additionalProperties": false,
176
+ "required": [
177
+ "backend",
178
+ "id",
179
+ "phase_index",
180
+ "message",
181
+ "no_remaining_phases",
182
+ "verify_log",
183
+ "change_id",
184
+ "content_fingerprint"
185
+ ],
186
+ "properties": {
187
+ "backend": { "const": "jj" },
188
+ "id": {
189
+ "type": "string",
190
+ "minLength": 1,
191
+ "description": "Transaction uuid; appears in the change description as Apnea-Transaction: <id>"
192
+ },
193
+ "phase_index": { "type": "integer", "minimum": 1 },
194
+ "message": {
195
+ "type": "string",
196
+ "minLength": 1,
197
+ "description": "Full description including the Apnea-Transaction trailer line"
198
+ },
199
+ "no_remaining_phases": { "type": "boolean" },
200
+ "verify_log": { "type": "string", "minLength": 1 },
201
+ "change_id": {
202
+ "type": "string",
203
+ "minLength": 1,
204
+ "description": "Change id of the described working-copy change"
205
+ },
206
+ "content_fingerprint": {
207
+ "type": "string",
208
+ "minLength": 1,
209
+ "description": "Fingerprint of the change's non-.apnea diff at preparation time"
210
+ }
211
+ }
212
+ }
213
+ ]
214
+ },
215
+ "phase_package_rework": {
216
+ "type": "boolean",
217
+ "deprecated": true,
218
+ "description": "Deprecated migration-only field. True migrates to required_rework=phase_package."
219
+ }
66
220
  }
67
221
  }