@cleocode/core 2026.4.5 → 2026.4.6

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 (144) hide show
  1. package/dist/discovery.d.ts +69 -0
  2. package/dist/discovery.d.ts.map +1 -0
  3. package/dist/index.d.ts +3 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1643 -2349
  6. package/dist/index.js.map +4 -4
  7. package/dist/init.d.ts +51 -0
  8. package/dist/init.d.ts.map +1 -1
  9. package/dist/internal.d.ts +9 -1
  10. package/dist/internal.d.ts.map +1 -1
  11. package/dist/lifecycle/default-chain.d.ts +8 -2
  12. package/dist/lifecycle/default-chain.d.ts.map +1 -1
  13. package/dist/lifecycle/index.d.ts +1 -0
  14. package/dist/lifecycle/index.d.ts.map +1 -1
  15. package/dist/lifecycle/stage-guidance.d.ts +140 -0
  16. package/dist/lifecycle/stage-guidance.d.ts.map +1 -0
  17. package/dist/orchestration/protocol-validators.d.ts +122 -3
  18. package/dist/orchestration/protocol-validators.d.ts.map +1 -1
  19. package/dist/paths.d.ts +91 -0
  20. package/dist/paths.d.ts.map +1 -1
  21. package/dist/scaffold.d.ts +31 -1
  22. package/dist/scaffold.d.ts.map +1 -1
  23. package/dist/skills/dispatch.d.ts +1 -1
  24. package/dist/skills/skill-paths.d.ts +9 -6
  25. package/dist/skills/skill-paths.d.ts.map +1 -1
  26. package/dist/validation/protocols/_shared.d.ts +40 -0
  27. package/dist/validation/protocols/_shared.d.ts.map +1 -0
  28. package/dist/validation/protocols/architecture-decision.d.ts +23 -0
  29. package/dist/validation/protocols/architecture-decision.d.ts.map +1 -0
  30. package/dist/validation/protocols/artifact-publish.d.ts +22 -0
  31. package/dist/validation/protocols/artifact-publish.d.ts.map +1 -0
  32. package/dist/validation/protocols/consensus.d.ts +11 -17
  33. package/dist/validation/protocols/consensus.d.ts.map +1 -1
  34. package/dist/validation/protocols/contribution.d.ts +12 -17
  35. package/dist/validation/protocols/contribution.d.ts.map +1 -1
  36. package/dist/validation/protocols/decomposition.d.ts +18 -21
  37. package/dist/validation/protocols/decomposition.d.ts.map +1 -1
  38. package/dist/validation/protocols/implementation.d.ts +9 -17
  39. package/dist/validation/protocols/implementation.d.ts.map +1 -1
  40. package/dist/validation/protocols/provenance.d.ts +23 -0
  41. package/dist/validation/protocols/provenance.d.ts.map +1 -0
  42. package/dist/validation/protocols/release.d.ts +25 -0
  43. package/dist/validation/protocols/release.d.ts.map +1 -0
  44. package/dist/validation/protocols/research.d.ts +9 -17
  45. package/dist/validation/protocols/research.d.ts.map +1 -1
  46. package/dist/validation/protocols/specification.d.ts +7 -17
  47. package/dist/validation/protocols/specification.d.ts.map +1 -1
  48. package/dist/validation/protocols/testing.d.ts +22 -0
  49. package/dist/validation/protocols/testing.d.ts.map +1 -0
  50. package/dist/validation/protocols/validation.d.ts +22 -0
  51. package/dist/validation/protocols/validation.d.ts.map +1 -0
  52. package/package.json +7 -7
  53. package/src/__tests__/injection-mvi-tiers.test.js +54 -90
  54. package/src/__tests__/injection-mvi-tiers.test.js.map +1 -1
  55. package/src/discovery.ts +235 -0
  56. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js +3 -1
  57. package/src/hooks/handlers/__tests__/hook-automation-e2e.test.js.map +1 -1
  58. package/src/index.ts +16 -0
  59. package/src/init.ts +196 -0
  60. package/src/internal.ts +31 -1
  61. package/src/lifecycle/default-chain.ts +11 -2
  62. package/src/lifecycle/index.ts +10 -0
  63. package/src/lifecycle/stage-guidance.ts +282 -0
  64. package/src/metrics/__tests__/provider-detection.test.js +19 -7
  65. package/src/metrics/__tests__/provider-detection.test.js.map +1 -1
  66. package/src/orchestration/__tests__/protocol-validators.test.js +228 -8
  67. package/src/orchestration/__tests__/protocol-validators.test.js.map +1 -1
  68. package/src/orchestration/__tests__/protocol-validators.test.ts +259 -7
  69. package/src/orchestration/protocol-validators.ts +419 -4
  70. package/src/paths.ts +110 -0
  71. package/src/scaffold.ts +240 -4
  72. package/src/skills/dispatch.ts +6 -6
  73. package/src/skills/skill-paths.ts +27 -23
  74. package/src/validation/protocols/_shared.ts +88 -0
  75. package/src/validation/protocols/architecture-decision.ts +52 -0
  76. package/src/validation/protocols/artifact-publish.ts +49 -0
  77. package/src/validation/protocols/consensus.ts +44 -74
  78. package/src/validation/protocols/contribution.ts +28 -65
  79. package/src/validation/protocols/decomposition.ts +37 -64
  80. package/src/validation/protocols/implementation.ts +25 -65
  81. package/src/validation/protocols/protocols-markdown/architecture-decision.md +303 -0
  82. package/src/validation/protocols/protocols-markdown/artifact-publish.md +600 -0
  83. package/src/validation/protocols/protocols-markdown/consensus.md +322 -0
  84. package/src/validation/protocols/protocols-markdown/contribution.md +388 -0
  85. package/src/validation/protocols/protocols-markdown/decomposition.md +421 -0
  86. package/src/validation/protocols/protocols-markdown/implementation.md +357 -0
  87. package/src/validation/protocols/protocols-markdown/provenance.md +613 -0
  88. package/src/validation/protocols/protocols-markdown/release.md +783 -0
  89. package/src/validation/protocols/protocols-markdown/research.md +261 -0
  90. package/src/validation/protocols/protocols-markdown/specification.md +300 -0
  91. package/src/validation/protocols/protocols-markdown/testing.md +287 -0
  92. package/src/validation/protocols/protocols-markdown/validation.md +242 -0
  93. package/src/validation/protocols/provenance.ts +50 -0
  94. package/src/validation/protocols/release.ts +44 -0
  95. package/src/validation/protocols/research.ts +25 -87
  96. package/src/validation/protocols/specification.ts +27 -89
  97. package/src/validation/protocols/testing.ts +46 -0
  98. package/src/validation/protocols/validation.ts +46 -0
  99. package/dist/validation/protocols/release-protocol.d.ts +0 -27
  100. package/dist/validation/protocols/release-protocol.d.ts.map +0 -1
  101. package/dist/validation/protocols/testing-protocol.d.ts +0 -27
  102. package/dist/validation/protocols/testing-protocol.d.ts.map +0 -1
  103. package/dist/validation/protocols/validation-protocol.d.ts +0 -27
  104. package/dist/validation/protocols/validation-protocol.d.ts.map +0 -1
  105. package/schemas/agent-configs.schema.json +0 -120
  106. package/schemas/agent-registry.schema.json +0 -132
  107. package/schemas/archive.schema.json +0 -450
  108. package/schemas/brain-decision.schema.json +0 -69
  109. package/schemas/brain-learning.schema.json +0 -57
  110. package/schemas/brain-pattern.schema.json +0 -72
  111. package/schemas/critical-path.schema.json +0 -246
  112. package/schemas/deps-cache.schema.json +0 -97
  113. package/schemas/doctor-output.schema.json +0 -283
  114. package/schemas/error.schema.json +0 -161
  115. package/schemas/global-config.schema.json +0 -219
  116. package/schemas/grade.schema.json +0 -49
  117. package/schemas/log.schema.json +0 -250
  118. package/schemas/metrics.schema.json +0 -328
  119. package/schemas/migrations.schema.json +0 -150
  120. package/schemas/nexus-registry.schema.json +0 -90
  121. package/schemas/operation-constitution.schema.json +0 -438
  122. package/schemas/output.schema.json +0 -164
  123. package/schemas/projects-registry.schema.json +0 -107
  124. package/schemas/protocol-frontmatter.schema.json +0 -72
  125. package/schemas/rcasd-consensus-report.schema.json +0 -10
  126. package/schemas/rcasd-evidence.schema.json +0 -42
  127. package/schemas/rcasd-gate-result.schema.json +0 -46
  128. package/schemas/rcasd-hitl-resolution.schema.json +0 -10
  129. package/schemas/rcasd-index.schema.json +0 -10
  130. package/schemas/rcasd-manifest.schema.json +0 -10
  131. package/schemas/rcasd-research-output.schema.json +0 -10
  132. package/schemas/rcasd-spec-frontmatter.schema.json +0 -10
  133. package/schemas/rcasd-stage-transition.schema.json +0 -38
  134. package/schemas/releases.schema.json +0 -267
  135. package/schemas/skills-manifest.schema.json +0 -91
  136. package/schemas/spec-index.schema.json +0 -196
  137. package/schemas/system-flow-atlas.schema.json +0 -125
  138. package/src/conduit/__tests__/dual-api-e2e.test.d.ts.map +0 -1
  139. package/src/conduit/__tests__/dual-api-e2e.test.js +0 -178
  140. package/src/conduit/__tests__/dual-api-e2e.test.js.map +0 -1
  141. package/src/conduit/__tests__/dual-api-e2e.test.ts +0 -212
  142. package/src/validation/protocols/release-protocol.ts +0 -80
  143. package/src/validation/protocols/testing-protocol.ts +0 -93
  144. package/src/validation/protocols/validation-protocol.ts +0 -93
@@ -0,0 +1,600 @@
1
+ ---
2
+ id: ART
3
+ title: Artifact Publish Protocol
4
+ version: 1.0.0
5
+ status: active
6
+ type: cross-cutting
7
+ audience: [llm-agent, orchestrator]
8
+ tags: [artifact, publish, distribution]
9
+ skillRef: ct-artifact-publisher
10
+ lastUpdated: 2026-04-07
11
+ enforcement: advisory
12
+ ---
13
+
14
+ # Artifact Publish Protocol
15
+
16
+ **Version**: 1.0.0
17
+ **Type**: Conditional Protocol
18
+ **Max Active**: 3 protocols (including base)
19
+
20
+ ---
21
+
22
+ ## Trigger Conditions
23
+
24
+ This protocol activates when the task involves:
25
+
26
+ | Trigger | Keywords | Context |
27
+ |---------|----------|---------|
28
+ | Package Publish | "publish", "package", "distribute" | Registry distribution |
29
+ | Artifact Build | "artifact", "build artifact", "bundle" | Build output |
30
+ | Container Push | "docker push", "container registry", "image publish" | Container distribution |
31
+ | Language Package | "crate", "gem", "wheel", "sdist" | Language-specific publishing |
32
+ | Multi-Artifact | "publish all", "release artifacts", "multi-package" | Coordinated publish |
33
+
34
+ **Explicit Override**: `--protocol artifact-publish` flag on task creation.
35
+
36
+ **Relationship to Release Protocol**: This protocol orchestrates artifact building and publishing. The release protocol orchestrates version bumping, tagging, and changelog. They compose: release triggers artifact-publish for the distribution phase.
37
+
38
+ ---
39
+
40
+ ## Requirements (RFC 2119)
41
+
42
+ ### MUST
43
+
44
+ | Requirement | Description |
45
+ |-------------|-------------|
46
+ | ARTP-001 | MUST validate artifact configuration before build |
47
+ | ARTP-002 | MUST execute dry-run before any real publish |
48
+ | ARTP-003 | MUST follow handler interface contract: `validate -> build -> publish` |
49
+ | ARTP-004 | MUST generate SHA-256 checksums for all built artifacts |
50
+ | ARTP-005 | MUST record provenance metadata via `record_release()` |
51
+ | ARTP-006 | MUST use sequential execution for multi-artifact publish |
52
+ | ARTP-007 | MUST set `agent_type: "artifact-publish"` in manifest |
53
+ | ARTP-008 | MUST NOT store credentials in config, output, or manifest |
54
+ | ARTP-009 | MUST halt pipeline and attempt rollback on first publish failure |
55
+
56
+ ### SHOULD
57
+
58
+ | Requirement | Description |
59
+ |-------------|-------------|
60
+ | ARTP-010 | SHOULD verify registry reachability before publish |
61
+ | ARTP-011 | SHOULD validate version consistency between config and artifact metadata |
62
+ | ARTP-012 | SHOULD log all publish operations to audit trail |
63
+ | ARTP-013 | SHOULD verify build output exists and is non-empty before publish |
64
+
65
+ ### MAY
66
+
67
+ | Requirement | Description |
68
+ |-------------|-------------|
69
+ | ARTP-020 | MAY batch validation across all artifacts before starting builds |
70
+ | ARTP-021 | MAY generate SBOM alongside artifacts (delegate to provenance protocol) |
71
+ | ARTP-022 | MAY sign artifacts using configured signing method (delegate to provenance protocol) |
72
+
73
+ ---
74
+
75
+ ## Artifact Lifecycle
76
+
77
+ ### State Machine
78
+
79
+ ```
80
+ configured -> validated -> built -> published
81
+ | | |
82
+ failed failed failed -> rollback
83
+ ```
84
+
85
+ ### State Transitions
86
+
87
+ | From | To | Trigger | Condition |
88
+ |------|----|---------|-----------|
89
+ | configured | validated | `validate_artifact()` returns 0 | Config present, handler exists |
90
+ | configured | failed | `validate_artifact()` returns non-0 | Missing config, bad handler |
91
+ | validated | built | `build_artifact()` returns 0 | Validate passed |
92
+ | validated | failed | `build_artifact()` returns non-0 | Build error |
93
+ | built | published | `publish_artifact()` returns 0 | Build output exists |
94
+ | built | failed | `publish_artifact()` returns non-0 | Registry error, auth error |
95
+ | failed | rollback | Automatic on publish failure | Prior artifacts already published |
96
+
97
+ ### Per-Artifact State Tracking
98
+
99
+ ```json
100
+ {
101
+ "type": "npm-package",
102
+ "state": "published",
103
+ "checksum": "sha256:abc123...",
104
+ "buildOutput": "dist/",
105
+ "publishedAt": "2026-01-26T14:00:00Z",
106
+ "dryRun": false
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Handler Interface
113
+
114
+ ### Contract
115
+
116
+ Every artifact type implements three functions following `lib/release-artifacts.sh`:
117
+
118
+ ```bash
119
+ {prefix}_validate(artifact_config_json) -> exit 0|1
120
+ {prefix}_build(artifact_config_json, dry_run) -> exit 0|1
121
+ {prefix}_publish(artifact_config_json, dry_run) -> exit 0|1
122
+ ```
123
+
124
+ ### Registered Handlers (9 types)
125
+
126
+ | Artifact Type | Handler Prefix | Default Build | Default Publish |
127
+ |---------------|----------------|---------------|-----------------|
128
+ | `npm-package` | `npm_package` | (none) | `npm publish` |
129
+ | `python-wheel` | `python_wheel` | `python -m build` | `twine upload dist/*` |
130
+ | `python-sdist` | `python_sdist` | `python -m build --sdist` | `twine upload dist/*` |
131
+ | `go-module` | `go_module` | `go mod tidy` | Git tag push |
132
+ | `cargo-crate` | `cargo_crate` | `cargo build --release` | `cargo publish` |
133
+ | `ruby-gem` | `ruby_gem` | `gem build *.gemspec` | `gem push *.gem` |
134
+ | `docker-image` | `docker_image` | `docker build -t <registry>:latest .` | `docker push <registry>:latest` |
135
+ | `github-release` | `github_release` | (none) | `gh release create` |
136
+ | `generic-tarball` | `generic_tarball` | `tar czf` | (custom) |
137
+
138
+ ### Execution Decision Tree
139
+
140
+ ```
141
+ Is artifact type in config?
142
+ +-- NO -> Exit 85 (E_ARTIFACT_TYPE_UNKNOWN)
143
+ +-- YES
144
+ +-- has_artifact_handler(type)?
145
+ | +-- NO -> Exit 85 (E_ARTIFACT_TYPE_UNKNOWN)
146
+ | +-- YES -> Proceed
147
+ +-- Is artifact enabled? (.enabled != false)
148
+ +-- NO -> Skip (log: "Artifact disabled")
149
+ +-- YES -> Execute pipeline: validate -> build -> publish
150
+ ```
151
+
152
+ ### Custom Handlers
153
+
154
+ ```bash
155
+ source lib/release-artifacts.sh
156
+
157
+ my_custom_validate() { ... }
158
+ my_custom_build() { ... }
159
+ my_custom_publish() { ... }
160
+
161
+ register_artifact_handler "my-custom-type" "my_custom"
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Configuration Schema Reference
167
+
168
+ Artifacts configured in `.cleo/config.json` under `release.artifacts[]`:
169
+
170
+ ```json
171
+ {
172
+ "release": {
173
+ "artifacts": [
174
+ {
175
+ "type": "npm-package",
176
+ "enabled": true,
177
+ "package": "package.json",
178
+ "buildCommand": "npm run build",
179
+ "publishCommand": "npm publish",
180
+ "registry": "https://registry.npmjs.org",
181
+ "options": {
182
+ "access": "public",
183
+ "provenance": true,
184
+ "tag": "latest"
185
+ },
186
+ "credentials": {
187
+ "envVar": "NPM_TOKEN",
188
+ "ciSecret": "NPM_TOKEN",
189
+ "required": true
190
+ }
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ ```
196
+
197
+ ### Config Fields
198
+
199
+ | Field | Type | Required | Description |
200
+ |-------|------|----------|-------------|
201
+ | `type` | string | MUST | One of 9 registered handler types |
202
+ | `enabled` | boolean | MAY | Default: `true`. Set `false` to skip |
203
+ | `package` | string | MAY | Path to package manifest |
204
+ | `buildCommand` | string | MAY | Override default build command |
205
+ | `publishCommand` | string | MAY | Override default publish command |
206
+ | `registry` | string | MAY | Registry URL |
207
+ | `options` | object | MAY | Handler-specific publish options |
208
+ | `credentials` | object | SHOULD | Credential reference (not the credential itself) |
209
+
210
+ ---
211
+
212
+ ## Multi-Artifact Orchestration
213
+
214
+ ### Pipeline Phases
215
+
216
+ | Phase | Scope | On Failure |
217
+ |-------|-------|------------|
218
+ | 1. Pre-validate | All artifacts | Halt before any build |
219
+ | 2. Build | Sequential per artifact | Halt pipeline |
220
+ | 3. Publish | Sequential per artifact | Rollback published artifacts |
221
+
222
+ Artifacts MUST be processed sequentially in config array order.
223
+
224
+ ### Phase 1: Pre-Validate All
225
+
226
+ ```bash
227
+ for artifact in $(echo "$config" | jq -c '.release.artifacts[]'); do
228
+ type=$(echo "$artifact" | jq -r '.type')
229
+ validate_artifact "$type" "$artifact" || exit 86
230
+ done
231
+ ```
232
+
233
+ ### Phase 2: Build Sequential
234
+
235
+ ```bash
236
+ built_artifacts=()
237
+ for artifact in $(echo "$config" | jq -c '.release.artifacts[]'); do
238
+ type=$(echo "$artifact" | jq -r '.type')
239
+ build_artifact "$type" "$artifact" "$dry_run" || exit 87
240
+ built_artifacts+=("$type")
241
+ done
242
+ ```
243
+
244
+ ### Phase 3: Publish with Rollback
245
+
246
+ ```bash
247
+ published_artifacts=()
248
+ for artifact in $(echo "$config" | jq -c '.release.artifacts[]'); do
249
+ type=$(echo "$artifact" | jq -r '.type')
250
+ if ! publish_artifact "$type" "$artifact" "$dry_run"; then
251
+ rollback_published "${published_artifacts[@]}"
252
+ exit 88
253
+ fi
254
+ published_artifacts+=("$type")
255
+ done
256
+ ```
257
+
258
+ ---
259
+
260
+ ## Rollback Semantics
261
+
262
+ ### Per-Registry Feasibility
263
+
264
+ | Artifact Type | Rollback Method | Feasibility |
265
+ |---------------|----------------|-------------|
266
+ | `npm-package` | `npm unpublish <pkg>@<version>` (within 72h) | Partial |
267
+ | `python-wheel` | No API unpublish; yank via PyPI admin | Manual |
268
+ | `docker-image` | Registry API delete | Full |
269
+ | `github-release` | `gh release delete <tag>` | Full |
270
+ | `cargo-crate` | `cargo yank --version <ver>` | Partial (yank only) |
271
+ | `ruby-gem` | `gem yank <gem> -v <version>` | Full |
272
+ | `go-module` | Retract directive in go.mod | Partial |
273
+ | `generic-tarball` | Delete uploaded file | Depends on target |
274
+
275
+ ### Rollback Decision Tree
276
+
277
+ ```
278
+ Publish failed at artifact[i]?
279
+ +-- i == 0 -> No rollback needed (nothing published)
280
+ +-- i > 0
281
+ +-- --no-rollback flag set?
282
+ | +-- YES -> Log warning, exit 88
283
+ | +-- NO -> Attempt rollback of artifacts[0..i-1]
284
+ +-- Rollback succeeded?
285
+ +-- YES -> Exit 88 (clean failure)
286
+ +-- NO -> Exit 89 (dirty failure, manual intervention)
287
+ ```
288
+
289
+ ---
290
+
291
+ ## Registry Abstraction
292
+
293
+ ### Universal Interface
294
+
295
+ | Operation | Description | Implementation |
296
+ |-----------|-------------|----------------|
297
+ | `validate` | Check handler exists, config valid | `validate_artifact(type, config)` |
298
+ | `build` | Produce artifact from source | `build_artifact(type, config, dry_run)` |
299
+ | `publish` | Push artifact to registry | `publish_artifact(type, config, dry_run)` |
300
+ | `check_reachability` | Verify registry accessible | Handler-specific (SHOULD) |
301
+
302
+ ### Per-Registry Auth and Behavior
303
+
304
+ | Registry | Auth Mechanism | Version Source | Publish Idempotency |
305
+ |----------|----------------|----------------|---------------------|
306
+ | npm | `NPM_TOKEN` env var | `package.json:version` | Error on duplicate |
307
+ | PyPI | `TWINE_PASSWORD` env var | `pyproject.toml:version` | Error on duplicate |
308
+ | crates.io | `CARGO_REGISTRY_TOKEN` env var | `Cargo.toml:version` | Error on duplicate |
309
+ | RubyGems | `GEM_HOST_API_KEY` env var | `*.gemspec:version` | Error on duplicate |
310
+ | Docker | `docker login` session | Tag string | Overwrites silently |
311
+ | GitHub | `GITHUB_TOKEN` env var | Git tag | Error on duplicate |
312
+ | Go Proxy | No auth (tag-based) | `go.mod:module` + Git tag | Immutable |
313
+
314
+ ---
315
+
316
+ ## Credential Handling
317
+
318
+ ### Declarative Model
319
+
320
+ Agents MUST NOT store, log, or embed credentials. Agents declare credential requirements; the environment provides them.
321
+
322
+ ### Credential Resolution Order
323
+
324
+ | Priority | Source | Context |
325
+ |----------|--------|---------|
326
+ | 1 | Environment variable (`credentials.envVar`) | Local and CI |
327
+ | 2 | CI secret injection (`credentials.ciSecret`) | CI only |
328
+ | 3 | Credential manager (keychain/vault) | Future |
329
+
330
+ ### Validation Decision Tree
331
+
332
+ ```
333
+ Is credentials.required == true?
334
+ +-- NO -> Proceed without credential check
335
+ +-- YES
336
+ +-- Is $envVar set in environment?
337
+ | +-- YES -> Credential available, proceed
338
+ | +-- NO
339
+ | +-- Is --dry-run set?
340
+ | | +-- YES -> Warn, proceed (skip publish)
341
+ | | +-- NO -> Exit 90 (credential missing)
342
+ +-- Is credential value non-empty?
343
+ +-- YES -> Proceed
344
+ +-- NO -> Exit 90 (credential missing)
345
+ ```
346
+
347
+ ### Agent Prohibitions
348
+
349
+ | MUST NOT | Rationale |
350
+ |----------|-----------|
351
+ | Echo/log credential values | Exposure in audit trail |
352
+ | Store credentials in config.json | Committed to version control |
353
+ | Include credentials in manifest entry | Visible to orchestrator |
354
+ | Pass credentials as CLI arguments | Visible in `ps` output |
355
+ | Store credentials in output files | Readable by other agents |
356
+
357
+ ---
358
+
359
+ ## Error Codes (85-89)
360
+
361
+ | Code | Constant | Meaning | Recovery |
362
+ |------|----------|---------|----------|
363
+ | 85 | `E_ARTIFACT_TYPE_UNKNOWN` | Artifact type not registered | Check config type field, verify handler exists |
364
+ | 86 | `E_ARTIFACT_VALIDATION_FAILED` | Pre-build validation failed | Fix package manifest, check tool availability |
365
+ | 87 | `E_ARTIFACT_BUILD_FAILED` | Build command returned non-zero | Check build output, verify dependencies |
366
+ | 88 | `E_ARTIFACT_PUBLISH_FAILED` | Publish failed (rollback attempted) | Check registry auth, network, version conflicts |
367
+ | 89 | `E_ARTIFACT_ROLLBACK_FAILED` | Rollback failed | Manual intervention required |
368
+
369
+ ### Recoverability
370
+
371
+ | Code | Recoverable | Agent Action |
372
+ |------|:-----------:|--------------|
373
+ | 85 | No | Fix config, re-run |
374
+ | 86 | Yes | Fix manifest, retry |
375
+ | 87 | Yes | Fix build, retry |
376
+ | 88 | Yes | Fix auth/network, retry |
377
+ | 89 | No | Manual intervention |
378
+
379
+ ---
380
+
381
+ ## Validation Gates
382
+
383
+ ### Pre-Publish Checklist
384
+
385
+ | Gate | Check | Required | Command |
386
+ |------|-------|----------|---------|
387
+ | Config Valid | `validate_release_config()` returns 0 | MUST | `source lib/release-config.sh` |
388
+ | Handler Exists | `has_artifact_handler(type)` returns 0 | MUST | `source lib/release-artifacts.sh` |
389
+ | Artifact Valid | `validate_artifact(type, config)` returns 0 | MUST | Per handler |
390
+ | Version Consistent | Package manifest version matches release | SHOULD | Handler-specific |
391
+ | Credential Available | `$envVar` is set and non-empty | MUST (if required) | `[[ -n "${!envVar}" ]]` |
392
+ | Dry-Run Success | Full pipeline succeeds with `dry_run=true` | MUST | Per ARTP-002 |
393
+ | Build Output Exists | Build produced expected files | SHOULD | Handler-specific |
394
+ | Checksum Generated | SHA-256 computed for all artifacts | MUST | `sha256sum <artifact>` |
395
+ | Registry Reachable | Network check to registry | SHOULD | Handler-specific |
396
+ | Provenance Recorded | `record_release()` called | MUST | Post-publish |
397
+
398
+ ### Gate Execution Order
399
+
400
+ ```
401
+ 1. Config Valid (blocks all)
402
+ 2. Handler Exists (blocks validate)
403
+ 3. Credential Available (blocks publish)
404
+ 4. Artifact Valid (blocks build)
405
+ 5. Dry-Run Success (blocks real publish)
406
+ 6. Build + Checksum (blocks publish)
407
+ 7. Registry Reachable (blocks publish)
408
+ 8. Publish
409
+ 9. Provenance Recorded (post-publish)
410
+ ```
411
+
412
+ ---
413
+
414
+ ## Output Format
415
+
416
+ ### File Output
417
+
418
+ ```markdown
419
+ # Artifact Publish: {Description}
420
+
421
+ **Task**: T####
422
+ **Date**: YYYY-MM-DD
423
+ **Status**: complete|partial|blocked
424
+ **Agent Type**: artifact-publish
425
+
426
+ ---
427
+
428
+ ## Summary
429
+
430
+ {2-3 sentence summary of artifacts published}
431
+
432
+ ## Pipeline Results
433
+
434
+ | # | Artifact Type | State | Checksum | Registry |
435
+ |---|---------------|-------|----------|----------|
436
+ | 1 | npm-package | published | sha256:abc1... | npmjs.org |
437
+ | 2 | docker-image | published | sha256:def2... | ghcr.io |
438
+
439
+ ## Validation Results
440
+
441
+ | Gate | Status | Notes |
442
+ |------|--------|-------|
443
+ | Config Valid | PASS | 2 artifacts configured |
444
+ | Handlers Exist | PASS | npm-package, docker-image |
445
+ | Credentials | PASS | NPM_TOKEN, GITHUB_TOKEN set |
446
+ | Dry-Run | PASS | All pipelines succeeded |
447
+ | Checksums | PASS | SHA-256 generated |
448
+ | Provenance | PASS | Recorded to releases.json |
449
+ ```
450
+
451
+ ### Manifest Entry
452
+
453
+ ```bash
454
+ cleo research add \
455
+ --title "Artifact Publish: vX.Y.Z" \
456
+ --file "YYYY-MM-DD_artifact-publish-vXYZ.md" \
457
+ --topics "artifact-publish,npm-package,docker-image,release" \
458
+ --findings "2 artifacts published,All checksums verified,Provenance recorded" \
459
+ --status complete \
460
+ --task T#### \
461
+ --not-actionable \
462
+ --agent-type artifact-publish
463
+ ```
464
+
465
+ ---
466
+
467
+ ## Integration Points
468
+
469
+ ### Base Protocol
470
+
471
+ - Inherits task lifecycle (start, execute, complete)
472
+ - Inherits manifest append requirement
473
+ - Inherits error handling patterns
474
+
475
+ ### Protocol Interactions
476
+
477
+ | Combined With | Behavior |
478
+ |---------------|----------|
479
+ | release | Release protocol triggers artifact-publish for distribution phase |
480
+ | provenance | Artifact-publish calls provenance for signing and attestation |
481
+ | implementation | Implementation builds are inputs to artifact builds |
482
+ | contribution | Contribution records feed artifact provenance chain |
483
+
484
+ ### Composition with Release Protocol
485
+
486
+ ```
487
+ Release Protocol Artifact Publish Protocol
488
+ --- ---
489
+ 1. Version bump
490
+ 2. Changelog generation
491
+ 3. Validation gates
492
+ 4. Git commit + tag
493
+ 5. ---- HANDOFF ----------------------> 6. Load artifact config
494
+ 7. Pre-validate all artifacts
495
+ 8. Build all artifacts
496
+ 9. Publish all artifacts
497
+ 10. Record provenance
498
+ 11. <--- RETURN ---------------------- 11. Return pipeline results
499
+ 12. Push to remote
500
+ 13. Update release status
501
+ ```
502
+
503
+ ### CI/CD Integration
504
+
505
+ | Event | Workflow | Artifact Action |
506
+ |-------|----------|-----------------|
507
+ | Tag push `v*.*.*` | `release.yml` | Build tarball, checksums, GitHub Release |
508
+ | Manual dispatch | `artifact-publish.yml` | Full pipeline from config |
509
+ | PR merge to main | `build-check.yml` | Dry-run only (validation) |
510
+
511
+ ---
512
+
513
+ ## Workflow Sequence
514
+
515
+ ```
516
+ 1. Read task requirements (cleo show T####)
517
+ 2. Set focus (cleo start T####)
518
+ 3. Load release config (source lib/release-config.sh)
519
+ 4. Enumerate enabled artifacts (get_artifact_type)
520
+ 5. Pre-validate all artifacts (validate_artifact loop)
521
+ 6. Check credentials for all artifacts
522
+ 7. Execute dry-run for all artifacts
523
+ 8. Build all artifacts sequentially
524
+ 9. Generate checksums for all built artifacts
525
+ 10. Publish all artifacts sequentially (rollback on failure)
526
+ 11. Record provenance (record_release)
527
+ 12. Write output file
528
+ 13. Append manifest entry
529
+ 14. Complete task (cleo complete T####)
530
+ 15. Return: "Artifact publish complete. See MANIFEST.jsonl for summary."
531
+ ```
532
+
533
+ ---
534
+
535
+ ## Example
536
+
537
+ **Task**: Publish CLEO v0.85.0 artifacts
538
+
539
+ **Config** (`.cleo/config.json` excerpt):
540
+ ```json
541
+ {
542
+ "release": {
543
+ "artifacts": [
544
+ {
545
+ "type": "npm-package",
546
+ "enabled": true,
547
+ "package": "package.json",
548
+ "buildCommand": "npm run build",
549
+ "options": { "access": "public" },
550
+ "credentials": { "envVar": "NPM_TOKEN", "required": true }
551
+ },
552
+ {
553
+ "type": "generic-tarball",
554
+ "enabled": true,
555
+ "buildCommand": "tar czf my-project-0.85.0.tar.gz --exclude=.git ."
556
+ }
557
+ ]
558
+ }
559
+ }
560
+ ```
561
+
562
+ **Manifest Entry Command**:
563
+ ```bash
564
+ cleo research add \
565
+ --title "Artifact Publish: v0.85.0" \
566
+ --file "2026-02-09_artifact-publish-v0850.md" \
567
+ --topics "artifact-publish,npm-package,generic-tarball,v0.85.0" \
568
+ --findings "npm-package published to npmjs,tarball built,Checksums verified,Provenance recorded" \
569
+ --status complete \
570
+ --task T3200 \
571
+ --epic T3147 \
572
+ --not-actionable \
573
+ --agent-type artifact-publish
574
+ ```
575
+
576
+ **Return Message**:
577
+ ```
578
+ Artifact publish complete. See MANIFEST.jsonl for summary.
579
+ ```
580
+
581
+ ---
582
+
583
+ ## Anti-Patterns
584
+
585
+ | Pattern | Why Avoid |
586
+ |---------|-----------|
587
+ | Publishing without dry-run first | Irreversible registry state |
588
+ | Storing credentials in config.json | Committed to VCS, visible to agents |
589
+ | Parallel multi-artifact publish | Race conditions, partial state on failure |
590
+ | Skipping checksum generation | Cannot verify artifact integrity |
591
+ | Publishing without version check | Duplicate version errors |
592
+ | Ignoring publish failures | Inconsistent state across registries |
593
+ | Logging credential values | Exposure in audit trail and context |
594
+ | Building without validation | Wastes time on invalid config |
595
+ | Manual rollback without recording | Lost provenance chain |
596
+ | Hardcoding registry URLs | Breaks across environments |
597
+
598
+ ---
599
+
600
+ *Protocol Version 1.0.0 - Artifact Publish Protocol*