@cleocode/contracts 2026.9.8 → 2026.9.9

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 (151) hide show
  1. package/dist/__tests__/acceptance-gate.test.js +242 -1
  2. package/dist/__tests__/acceptance-gate.test.js.map +1 -1
  3. package/dist/__tests__/evidence-atom-schema.test.js +17 -14
  4. package/dist/__tests__/evidence-atom-schema.test.js.map +1 -1
  5. package/dist/__tests__/memory-wire-shapes.test.js.map +1 -1
  6. package/dist/__tests__/operations-registry.test.js +18 -0
  7. package/dist/__tests__/operations-registry.test.js.map +1 -1
  8. package/dist/acceptance-gate-schema.d.ts +60 -2
  9. package/dist/acceptance-gate-schema.d.ts.map +1 -1
  10. package/dist/acceptance-gate-schema.js +273 -1
  11. package/dist/acceptance-gate-schema.js.map +1 -1
  12. package/dist/acceptance-gate.d.ts +122 -11
  13. package/dist/acceptance-gate.d.ts.map +1 -1
  14. package/dist/acceptance-gate.js +3 -3
  15. package/dist/audit.d.ts +71 -2
  16. package/dist/audit.d.ts.map +1 -1
  17. package/dist/backup-manifest.d.ts +80 -0
  18. package/dist/backup-manifest.d.ts.map +1 -1
  19. package/dist/caamp-markers.d.ts +20 -0
  20. package/dist/caamp-markers.d.ts.map +1 -1
  21. package/dist/capabilities.d.ts +282 -0
  22. package/dist/capabilities.d.ts.map +1 -1
  23. package/dist/changesets.d.ts +4 -4
  24. package/dist/code-symbol.d.ts +33 -0
  25. package/dist/code-symbol.d.ts.map +1 -1
  26. package/dist/daemon/health.d.ts +3 -3
  27. package/dist/data-accessor.d.ts +15 -0
  28. package/dist/data-accessor.d.ts.map +1 -1
  29. package/dist/data-accessor.js.map +1 -1
  30. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +19 -1
  31. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -1
  32. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  33. package/dist/dispatch/operations-registry.js +684 -3
  34. package/dist/dispatch/operations-registry.js.map +1 -1
  35. package/dist/docs-taxonomy.d.ts +25 -0
  36. package/dist/docs-taxonomy.d.ts.map +1 -1
  37. package/dist/docs-taxonomy.js.map +1 -1
  38. package/dist/evidence-atom-schema.d.ts +7 -6
  39. package/dist/evidence-atom-schema.d.ts.map +1 -1
  40. package/dist/evidence-atom-schema.js +10 -9
  41. package/dist/evidence-atom-schema.js.map +1 -1
  42. package/dist/graph.d.ts +283 -2
  43. package/dist/graph.d.ts.map +1 -1
  44. package/dist/index.d.ts +6 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/invariants/adr-070-orchestration.d.ts.map +1 -1
  48. package/dist/invariants/adr-070-orchestration.js +1 -1
  49. package/dist/invariants/adr-070-orchestration.js.map +1 -1
  50. package/dist/invariants/adr-073-saga.js +2 -2
  51. package/dist/invariants/adr-073-saga.js.map +1 -1
  52. package/dist/jobs.d.ts +329 -3
  53. package/dist/jobs.d.ts.map +1 -1
  54. package/dist/knowledge-health.d.ts +695 -0
  55. package/dist/knowledge-health.d.ts.map +1 -0
  56. package/dist/knowledge-health.js +8 -0
  57. package/dist/knowledge-health.js.map +1 -0
  58. package/dist/llm/catalog-schema.d.ts +4 -4
  59. package/dist/memory/observe.d.ts +4 -2
  60. package/dist/memory/observe.d.ts.map +1 -1
  61. package/dist/memory/search.d.ts +4 -0
  62. package/dist/memory/search.d.ts.map +1 -1
  63. package/dist/nexus-living-brain-ops.d.ts +28 -3
  64. package/dist/nexus-living-brain-ops.d.ts.map +1 -1
  65. package/dist/nexus-tasks-bridge-ops.d.ts +11 -0
  66. package/dist/nexus-tasks-bridge-ops.d.ts.map +1 -1
  67. package/dist/operations/admin.d.ts +10 -4
  68. package/dist/operations/admin.d.ts.map +1 -1
  69. package/dist/operations/docs.d.ts +138 -0
  70. package/dist/operations/docs.d.ts.map +1 -1
  71. package/dist/operations/docs.js +47 -0
  72. package/dist/operations/docs.js.map +1 -1
  73. package/dist/operations/focus.d.ts +7 -0
  74. package/dist/operations/focus.d.ts.map +1 -1
  75. package/dist/operations/nexus.d.ts +7 -2
  76. package/dist/operations/nexus.d.ts.map +1 -1
  77. package/dist/operations/output-contracts-data.d.ts.map +1 -1
  78. package/dist/operations/output-contracts-data.js +31 -3
  79. package/dist/operations/output-contracts-data.js.map +1 -1
  80. package/dist/operations/research.d.ts +33 -0
  81. package/dist/operations/research.d.ts.map +1 -1
  82. package/dist/operations/tasks.d.ts +107 -4
  83. package/dist/operations/tasks.d.ts.map +1 -1
  84. package/dist/operations/tasks.js +5 -0
  85. package/dist/operations/tasks.js.map +1 -1
  86. package/dist/package-artifact.d.ts +112 -0
  87. package/dist/package-artifact.d.ts.map +1 -0
  88. package/dist/package-artifact.js +8 -0
  89. package/dist/package-artifact.js.map +1 -0
  90. package/dist/release/evidence-atoms.d.ts +10 -0
  91. package/dist/release/evidence-atoms.d.ts.map +1 -1
  92. package/dist/release/evidence-atoms.js +6 -0
  93. package/dist/release/evidence-atoms.js.map +1 -1
  94. package/dist/release/plan.d.ts +6 -6
  95. package/dist/resource-governor.d.ts +114 -0
  96. package/dist/resource-governor.d.ts.map +1 -1
  97. package/dist/resource-governor.js.map +1 -1
  98. package/dist/supervisor-ipc/messages.d.ts +6 -6
  99. package/dist/task-record.d.ts +25 -4
  100. package/dist/task-record.d.ts.map +1 -1
  101. package/dist/task.d.ts +55 -36
  102. package/dist/task.d.ts.map +1 -1
  103. package/dist/task.js.map +1 -1
  104. package/dist/tasks/archive.d.ts +3 -3
  105. package/dist/templates/manifest.d.ts +1 -1
  106. package/dist/workgraph.d.ts +5 -3
  107. package/dist/workgraph.d.ts.map +1 -1
  108. package/dist/workgraph.js +19 -0
  109. package/dist/workgraph.js.map +1 -1
  110. package/package.json +2 -2
  111. package/schemas/gate-result.schema.json +350 -1
  112. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  113. package/src/__tests__/acceptance-gate.test.ts +282 -1
  114. package/src/__tests__/evidence-atom-schema.test.ts +17 -14
  115. package/src/__tests__/memory-wire-shapes.test.ts +2 -0
  116. package/src/__tests__/operations-registry.test.ts +26 -0
  117. package/src/acceptance-gate-schema.ts +320 -14
  118. package/src/acceptance-gate.ts +133 -11
  119. package/src/audit.ts +72 -2
  120. package/src/backup-manifest.ts +88 -0
  121. package/src/caamp-markers.ts +22 -0
  122. package/src/capabilities.ts +311 -0
  123. package/src/code-symbol.ts +37 -0
  124. package/src/data-accessor.ts +16 -0
  125. package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +31 -1
  126. package/src/dispatch/operations-registry.ts +689 -3
  127. package/src/docs-taxonomy.ts +26 -0
  128. package/src/evidence-atom-schema.ts +10 -9
  129. package/src/graph.ts +326 -2
  130. package/src/index.ts +43 -1
  131. package/src/invariants/adr-070-orchestration.ts +2 -1
  132. package/src/invariants/adr-073-saga.ts +2 -2
  133. package/src/jobs.ts +382 -3
  134. package/src/knowledge-health.ts +748 -0
  135. package/src/memory/observe.ts +4 -2
  136. package/src/memory/search.ts +4 -0
  137. package/src/nexus-living-brain-ops.ts +34 -3
  138. package/src/nexus-tasks-bridge-ops.ts +12 -0
  139. package/src/operations/admin.ts +11 -4
  140. package/src/operations/docs.ts +153 -0
  141. package/src/operations/focus.ts +11 -0
  142. package/src/operations/nexus.ts +7 -1
  143. package/src/operations/output-contracts-data.ts +33 -3
  144. package/src/operations/research.ts +36 -0
  145. package/src/operations/tasks.ts +116 -4
  146. package/src/package-artifact.ts +127 -0
  147. package/src/release/evidence-atoms.ts +6 -0
  148. package/src/resource-governor.ts +132 -0
  149. package/src/task-record.ts +27 -4
  150. package/src/task.ts +58 -36
  151. package/src/workgraph.ts +19 -0
package/src/task.ts CHANGED
@@ -21,7 +21,8 @@
21
21
  * @task T4456
22
22
  */
23
23
 
24
- import type { AcceptanceGate } from './acceptance-gate.js';
24
+ import type { AcceptanceGate, AcceptanceGateResult } from './acceptance-gate.js';
25
+ import type { AcRow } from './data-accessor.js';
25
26
  import type { TaskStatus } from './status-registry.js';
26
27
 
27
28
  export type { TaskStatus };
@@ -159,6 +160,29 @@ export type VerificationGate =
159
160
  */
160
161
  | 'nexusImpact';
161
162
 
163
+ /** Task and criterion scope used while validating evidence, independent of PR metadata. */
164
+ export interface EvidenceValidationContext {
165
+ /** Canonical current task intent; prose is never interpreted as a file declaration. */
166
+ task: Pick<Task, 'id' | 'kind' | 'labels' | 'files' | 'acceptance' | 'verification'>;
167
+ /** Gates requested by this verification operation. */
168
+ gates: readonly VerificationGate[];
169
+ /** Canonical criteria read for this verification operation. */
170
+ criteria: ReadonlyArray<Pick<AcRow, 'id' | 'text' | 'updatedAt'>>;
171
+ /** Verified PR merge whose immutable artifact bytes must be inspected. */
172
+ artifactCommitSha?: string;
173
+ }
174
+
175
+ /** Explicit criterion link to inspected artifacts and validated results in one gate receipt. */
176
+ export interface CriterionEvidenceLink {
177
+ /** Canonical criterion identity and exact text hash at verification time. */
178
+ criterionId: string;
179
+ criterionHash: string;
180
+ /** Inspected changed artifacts; correspondence is asserted by the foreground caller. */
181
+ artifactPaths: string[];
182
+ /** Indices of actual validated result atoms in the containing gate's atoms array. */
183
+ resultAtomIndices: number[];
184
+ }
185
+
162
186
  /** Verification failure log entry. */
163
187
  export interface VerificationFailure {
164
188
  /** Verification round number when the failure occurred. */
@@ -288,35 +312,9 @@ export type EvidenceAtom =
288
312
  }
289
313
  | {
290
314
  /**
291
- * Pull-request atom — proves that a referenced GitHub PR shipped to
292
- * the project's primary branch with CI green.
293
- *
294
- * Closes the release-verb dogfood gap (T9764): tasks that ship via the
295
- * standard PR + admin-merge flow lacked a zero-friction way to record
296
- * `implemented` / `testsPassed` / `qaPassed` evidence after the fact.
297
- * Re-running `tool:test` against the entire monorepo is overkill for
298
- * one-line tasks, and `note:` is rejected for hard gates on critical
299
- * verifications.
300
- *
301
- * A `pr:<number>` atom satisfies `implemented`, `testsPassed`, and
302
- * `qaPassed` simultaneously (T9838) when:
303
- * 1. `state === 'MERGED'` (PR was actually shipped to main)
304
- * 2. `mergedAt` is non-null (defends against API races)
305
- * 3. The status-check rollup contains ≥1 SUCCESS check and zero
306
- * FAILURE checks in the required workflows
307
- * (`CI`, `Lockfile Check`, `Contracts Dep Lint`)
308
- *
309
- * Format: `pr:<positive integer>` (e.g. `pr:357`)
310
- *
311
- * Validation: CLEO calls `gh pr view <num> --json
312
- * statusCheckRollup,mergeable,state,mergedAt,headRefOid` and parses
313
- * the rollup. Results are cached under
314
- * `.cleo/cache/evidence/pr-<num>.json` keyed on `(prNumber, mergedAt)`
315
- * so re-verifies skip the network round trip.
316
- *
317
- * @task T9764
318
- * @epic T9762
319
- * @saga T9758
315
+ * Merged-PR provenance. Implementation additionally requires inspected
316
+ * changed artifacts and task/criterion linkage. Test and review gates
317
+ * require their own result atoms; merge status cannot satisfy them.
320
318
  */
321
319
  kind: 'pr';
322
320
  /** PR number (positive integer). */
@@ -329,6 +327,10 @@ export type EvidenceAtom =
329
327
  successCount: number;
330
328
  /** Total number of checks evaluated in the rollup. */
331
329
  totalChecks: number;
330
+ /** Complete PR changed-file inventory retained for task-scope checks and display. */
331
+ changedPaths?: string[];
332
+ /** Explicit task relationship established when this atom was accepted. */
333
+ taskId?: string;
332
334
  }
333
335
  | {
334
336
  /**
@@ -379,6 +381,13 @@ export type EvidenceAtom =
379
381
  export interface GateEvidence {
380
382
  /** One or more evidence atoms supporting this gate. */
381
383
  atoms: EvidenceAtom[];
384
+ /** Task and gate scope captured alongside explicitly linked criterion evidence. */
385
+ scope?: {
386
+ taskId: string;
387
+ gate: VerificationGate;
388
+ classification: 'code' | 'documentation' | 'research';
389
+ criteria: CriterionEvidenceLink[];
390
+ };
382
391
  /** ISO 8601 timestamp of when evidence was captured. */
383
392
  capturedAt: string;
384
393
  /** Agent identifier that captured the evidence. */
@@ -395,6 +404,8 @@ export interface GateEvidence {
395
404
 
396
405
  /** Task verification state. */
397
406
  export interface TaskVerification {
407
+ /** Explicitly verified acceptance results; only current authenticated bindings support completion. */
408
+ gateResults?: AcceptanceGateResult[];
398
409
  /** Whether all required verification gates have passed. */
399
410
  passed: boolean;
400
411
  /** Current verification round number (starts at 1). */
@@ -732,13 +743,13 @@ export type CancelledTask = Task & {
732
743
  };
733
744
 
734
745
  /**
735
- * Shape of a signed severity attestation line appended to the audit log.
746
+ * Severity assertion signed with the project identity.
736
747
  *
737
- * The attestation is produced whenever a task's `--severity` flag is
738
- * explicitly set. It is signed with the project's CLEO Ed25519 identity and
739
- * appended to `.cleo/audit/severity-attestation.jsonl` as a single JSON line
740
- * (stable / sorted-key serialisation so verifiers can reconstruct the signed
741
- * payload).
748
+ * Explicit severity changes through CLI, params, or SDK receive signed
749
+ * assertions bound to the actual task ID in the same transaction as the task
750
+ * audit. Standalone legacy JSONL assertions remain historical evidence and
751
+ * do not establish that a task mutation committed. Sorted-key serialization
752
+ * lets verifiers reconstruct the signed payload.
742
753
  *
743
754
  * Renamed from the earlier `BugSeverityAttestation` (which was scoped only to
744
755
  * `cleo bug`). The new name reflects that severity attestation is a
@@ -763,6 +774,17 @@ export interface SeverityAttestation {
763
774
  signerPub: string;
764
775
  }
765
776
 
777
+ /** Signed severity assertion; task audit persistence establishes commit provenance. */
778
+ export interface SignedSeverityAttestation extends SeverityAttestation {
779
+ /** Ed25519 signature of the canonical assertion, excluding this signature field. */
780
+ _sig: {
781
+ /** Hex-encoded signature. */
782
+ sig: string;
783
+ /** Hex-encoded signing public key, matching signerPub. */
784
+ pub: string;
785
+ };
786
+ }
787
+
766
788
  /** Phase status. */
767
789
  export type PhaseStatus = 'pending' | 'active' | 'completed';
768
790
 
package/src/workgraph.ts CHANGED
@@ -1058,6 +1058,23 @@ export interface WorkGraphHierarchyValidationOptions {
1058
1058
  readonly throwOnViolation?: boolean;
1059
1059
  }
1060
1060
 
1061
+ /**
1062
+ * Tiers that may sit at the root of a containment tree.
1063
+ *
1064
+ * Deliberately WIDER than the `cleo add` write path, which enforces strict-spine
1065
+ * containment (T11811) and hard-rejects a net-new parentless `epic`. The two are
1066
+ * not in conflict — they answer different questions. This set describes which
1067
+ * shapes are structurally VALID (the WorkGraph scaffold subsystem builds and
1068
+ * applies epic-rooted graphs, and the fleet still carries legacy root epics);
1069
+ * T11811 governs what a net-new agent-authored `cleo add` may CREATE.
1070
+ *
1071
+ * Narrowing this to `['saga']` to match the add path was attempted and reverted:
1072
+ * `validateWorkGraphHierarchy` never throws without `throwOnViolation`, but
1073
+ * `scaffold-validate.ts` consumes the returned violations and fails the
1074
+ * scaffold, so the change silently broke epic-rooted scaffolding. Tightening it
1075
+ * is a behaviour change to that subsystem, not a set edit — it needs its own
1076
+ * task, with the scaffold's root handling decided first.
1077
+ */
1061
1078
  const ROOT_TASK_TYPES: ReadonlySet<TaskType> = new Set(['saga', 'epic']);
1062
1079
 
1063
1080
  const PARENT_TYPE_MATRIX: Readonly<Record<TaskType, readonly TaskType[]>> = {
@@ -1143,6 +1160,8 @@ function makeViolation(
1143
1160
  * contain subtasks, and subtasks are leaves. Saga membership uses `parentId`
1144
1161
  * containment, never `task_relations.groups`.
1145
1162
  *
1163
+ * Note that `cleo add` is STRICTER — see {@link ROOT_TASK_TYPES}.
1164
+ *
1146
1165
  * @param nodes - Task-like hierarchy rows to validate.
1147
1166
  * @param options - Optional fail-fast behavior for enforcement call sites.
1148
1167
  * @returns Structured validation result with all violations in input order.