@cleocode/contracts 2026.9.21 → 2026.9.23

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 (60) hide show
  1. package/dist/__tests__/evidence-atom-schema.test.js +20 -2
  2. package/dist/__tests__/evidence-atom-schema.test.js.map +1 -1
  3. package/dist/acceptance-gate-schema.d.ts.map +1 -1
  4. package/dist/acceptance-gate-schema.js +4 -1
  5. package/dist/acceptance-gate-schema.js.map +1 -1
  6. package/dist/data-accessor.d.ts +4 -0
  7. package/dist/data-accessor.d.ts.map +1 -1
  8. package/dist/data-accessor.js.map +1 -1
  9. package/dist/decide-sites.d.ts +157 -0
  10. package/dist/decide-sites.d.ts.map +1 -0
  11. package/dist/decide-sites.js +28 -0
  12. package/dist/decide-sites.js.map +1 -0
  13. package/dist/decide.d.ts +105 -0
  14. package/dist/decide.d.ts.map +1 -1
  15. package/dist/decide.js +31 -0
  16. package/dist/decide.js.map +1 -1
  17. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  18. package/dist/dispatch/operations-registry.js +38 -2
  19. package/dist/dispatch/operations-registry.js.map +1 -1
  20. package/dist/done-plan.d.ts +19 -0
  21. package/dist/done-plan.d.ts.map +1 -1
  22. package/dist/evidence-atom-schema.d.ts +12 -44
  23. package/dist/evidence-atom-schema.d.ts.map +1 -1
  24. package/dist/evidence-atom-schema.js +32 -14
  25. package/dist/evidence-atom-schema.js.map +1 -1
  26. package/dist/index.d.ts +6 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/operations/admin.d.ts +5 -0
  31. package/dist/operations/admin.d.ts.map +1 -1
  32. package/dist/operations/docs.d.ts +5 -2
  33. package/dist/operations/docs.d.ts.map +1 -1
  34. package/dist/operations/docs.js.map +1 -1
  35. package/dist/operations/tasks.d.ts +24 -0
  36. package/dist/operations/tasks.d.ts.map +1 -1
  37. package/dist/operations/tasks.js.map +1 -1
  38. package/dist/task.d.ts +32 -1
  39. package/dist/task.d.ts.map +1 -1
  40. package/dist/tools/index.d.ts +1 -1
  41. package/dist/tools/index.d.ts.map +1 -1
  42. package/dist/tools/score-task-priority.d.ts +28 -3
  43. package/dist/tools/score-task-priority.d.ts.map +1 -1
  44. package/package.json +2 -2
  45. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  46. package/src/__tests__/evidence-atom-schema.test.ts +25 -2
  47. package/src/acceptance-gate-schema.ts +4 -1
  48. package/src/data-accessor.ts +4 -0
  49. package/src/decide-sites.ts +179 -0
  50. package/src/decide.ts +109 -0
  51. package/src/dispatch/operations-registry.ts +40 -2
  52. package/src/done-plan.ts +20 -0
  53. package/src/evidence-atom-schema.ts +34 -18
  54. package/src/index.ts +25 -0
  55. package/src/operations/admin.ts +5 -0
  56. package/src/operations/docs.ts +5 -2
  57. package/src/operations/tasks.ts +26 -0
  58. package/src/task.ts +32 -1
  59. package/src/tools/index.ts +1 -0
  60. package/src/tools/score-task-priority.ts +29 -3
@@ -1648,6 +1648,11 @@ export interface AdminBackupMutateParams {
1648
1648
  file?: string;
1649
1649
  /** Preview the restore without writing (restore.file only). */
1650
1650
  dryRun?: boolean;
1651
+ /**
1652
+ * Allow a restore run from inside a git worktree to overwrite the owning
1653
+ * project's live store (T12680). Without it such a restore is refused.
1654
+ */
1655
+ confirmOwnerStore?: boolean;
1651
1656
  }
1652
1657
 
1653
1658
  /** Result of `admin.backup` mutate (create action). */
@@ -715,7 +715,9 @@ export type DocsLifecycleStatus = (typeof DOCS_LIFECYCLE_STATUSES)[number];
715
715
  * {@link DocsSupersedeParams}-style flows, NO supersession edge is created
716
716
  * (callers wanting an explicit lineage edge should use `cleo docs supersede`).
717
717
  *
718
- * Exactly one of `file` or `content` MUST be provided.
718
+ * At most one of `file` or `content` may be provided. With neither, `status`
719
+ * is required and the update changes only the lifecycle status, keeping the
720
+ * stored bytes (T12654).
719
721
  *
720
722
  * @task T10161 (Epic T10157 / Saga T9855 — E12.C4)
721
723
  */
@@ -738,7 +740,8 @@ export interface DocsUpdateParams {
738
740
  /**
739
741
  * Override the new lifecycle status. Defaults to `'draft'` on every update
740
742
  * so an explicit `accepted` doc gets back-pressured to draft on edit. Pass
741
- * `--status accepted` (or any other valid status) to override.
743
+ * `--status accepted` (or any other valid status) to override. Passed alone
744
+ * (no `file`/`content`), it changes only the lifecycle status.
742
745
  */
743
746
  status?: DocsLifecycleStatus;
744
747
  /** Validate/preflight only; do not mutate attachment rows, blob storage, or audit logs. */
@@ -921,6 +921,31 @@ export interface TasksComplexityEstimateResult {
921
921
  export interface TasksHistoryParams {
922
922
  taskId?: string;
923
923
  limit?: number;
924
+ /**
925
+ * With `taskId`: only ranking-input changes (priority, severity, kind,
926
+ * depends) — who, which session, why, before/after (T12693, D11161).
927
+ */
928
+ ranking?: boolean;
929
+ }
930
+
931
+ // tasks.ranking.revert
932
+ /** Parameters for `tasks.ranking.revert` (T12693, D11161). */
933
+ export interface TasksRankingRevertParams {
934
+ /** The `ranking_changed` audit row id to undo (from `cleo history ranking`). */
935
+ entryId: string;
936
+ /** Why it is reverted; recorded on the new audit row. */
937
+ reason?: string;
938
+ /** Revert even though a field changed again since. */
939
+ force?: boolean;
940
+ }
941
+ /** Result of `tasks.ranking.revert`. */
942
+ export interface TasksRankingRevertResult {
943
+ /** Task whose ranking inputs were restored. */
944
+ taskId: string;
945
+ /** Fields set back. */
946
+ fields: string[];
947
+ /** The values they were set back to. */
948
+ revertedTo: Record<string, unknown>;
924
949
  }
925
950
  /**
926
951
  * Result of `tasks.history` — audit log entries for a task.
@@ -2277,6 +2302,7 @@ export type TasksOps = {
2277
2302
  readonly 'relates.add': readonly [TasksRelatesAddParams, TasksRelatesAddResult];
2278
2303
  readonly 'relates.add-batch': readonly [TasksRelatesAddBatchParams, TasksRelatesAddBatchResult];
2279
2304
  readonly 'relates.remove': readonly [TasksRelatesRemoveParams, TasksRelatesRemoveResult];
2305
+ readonly 'ranking.revert': readonly [TasksRankingRevertParams, TasksRankingRevertResult];
2280
2306
  readonly start: readonly [TasksStartQueryParams, TasksStartQueryResult];
2281
2307
  readonly stop: readonly [TasksStopQueryParams, TasksStopQueryResult];
2282
2308
  readonly 'sync.reconcile': readonly [TasksSyncReconcileParams, TasksSyncReconcileResult];
package/src/task.ts CHANGED
@@ -170,6 +170,12 @@ export interface EvidenceValidationContext {
170
170
  criteria: ReadonlyArray<Pick<AcRow, 'id' | 'text' | 'updatedAt'>>;
171
171
  /** Verified PR merge whose immutable artifact bytes must be inspected. */
172
172
  artifactCommitSha?: string;
173
+ /**
174
+ * Validate without persisting anything: `pr:`/`ci:` lookups write neither
175
+ * the PR-result cache nor the branch-protection cache (T12671 review — the
176
+ * `cleo done --plan` preview must leave `.cleo/` untouched).
177
+ */
178
+ readOnly?: boolean;
173
179
  }
174
180
 
175
181
  /** Explicit criterion link to inspected artifacts and validated results in one gate receipt. */
@@ -181,6 +187,14 @@ export interface CriterionEvidenceLink {
181
187
  artifactPaths: string[];
182
188
  /** Indices of actual validated result atoms in the containing gate's atoms array. */
183
189
  resultAtomIndices: number[];
190
+ /**
191
+ * How the `implemented` link is supported (T12689): `files` when a path the
192
+ * criterion names is among the inspected artifacts; `self-attested` when the
193
+ * criterion names no path in them, so the link rests on the agent's claim.
194
+ * Paths parsed from criterion text are advisory (T12118), so this flags
195
+ * rather than refuses. Absent on other gates and on older receipts.
196
+ */
197
+ basis?: 'files' | 'self-attested';
184
198
  }
185
199
 
186
200
  /** Verification failure log entry. */
@@ -371,10 +385,25 @@ export type EvidenceAtom =
371
385
  successCount: number;
372
386
  /** Total number of checks evaluated in the rollup. */
373
387
  totalChecks: number;
374
- /** Complete PR changed-file inventory retained for task-scope checks and display. */
388
+ /**
389
+ * Changed-file inventory retained for task-scope checks and display. With
390
+ * `componentPrNumber`, the component PR's files that survive in this
391
+ * PR's merge commit — never the whole integration PR.
392
+ */
375
393
  changedPaths?: string[];
376
394
  /** Explicit task relationship established when this atom was accepted. */
377
395
  taskId?: string;
396
+ /**
397
+ * Component PR this (integration) PR landed on the default branch
398
+ * (T12671): the task is linked through it and its files are the change.
399
+ */
400
+ componentPrNumber?: number;
401
+ /**
402
+ * Paths the (component) PR deleted that stay deleted in the landing
403
+ * commit (T12689). A deletion has no bytes to hash, so a PR whose every
404
+ * change is a deletion implements with `pr:` + `note:` instead of `files:`.
405
+ */
406
+ deletedPaths?: string[];
378
407
  }
379
408
  | {
380
409
  /**
@@ -410,6 +439,8 @@ export type EvidenceAtom =
410
439
  testedTree?: string;
411
440
  /** Task the PR was verified to be linked to (T12634). */
412
441
  taskId?: string;
442
+ /** Component PR the task is linked through; its CI ran as this integration PR's (T12671). */
443
+ componentPrNumber?: number;
413
444
  /** Which configured checks attest each gate (`evidence.ciChecks`). */
414
445
  gateChecks?: { testsPassed?: string[]; qaPassed?: string[] };
415
446
  /** Where the required-check list came from (env, project context, branch protection). */
@@ -63,6 +63,7 @@ export type {
63
63
  ScoreFactor,
64
64
  ScoreTaskContext,
65
65
  ScoreTaskInput,
66
+ ScoreTaskKey,
66
67
  ScoreTaskResult,
67
68
  } from './score-task-priority.js';
68
69
  // === Web + browser agent tools (T1742 / T11456) ===
@@ -6,7 +6,7 @@
6
6
  * @epic T9835
7
7
  */
8
8
 
9
- import type { TaskPriority } from '../task.js';
9
+ import type { TaskKind, TaskPriority, TaskSeverity } from '../task.js';
10
10
 
11
11
  /** Minimal task shape required by scoreTask. */
12
12
  export interface ScoreTaskInput {
@@ -24,6 +24,10 @@ export interface ScoreTaskInput {
24
24
  createdAt?: string;
25
25
  /** Labels for pattern matching. */
26
26
  labels?: string[];
27
+ /** Severity axis (orthogonal to priority); unset for most tasks. */
28
+ severity?: TaskSeverity | null;
29
+ /** Kind axis; a `bug` with no severity is scored at the default bug severity (T12661). */
30
+ kind?: TaskKind | null;
27
31
  }
28
32
 
29
33
  /** Context provided to scoreTask to enable phase-aware and dependency-aware scoring. */
@@ -38,6 +42,8 @@ export interface ScoreTaskContext {
38
42
  successPatterns?: Array<{ pattern: string }>;
39
43
  /** Matched failure patterns from BRAIN (optional penalty scoring). */
40
44
  failurePatterns?: Array<{ pattern: string }>;
45
+ /** Open tasks that depend on each task id — its leverage (bounded bonus, T12661). */
46
+ leverage?: ReadonlyMap<string, number>;
41
47
  }
42
48
 
43
49
  /** A scoring factor contributing to the final score. */
@@ -48,12 +54,32 @@ export interface ScoreFactor {
48
54
  delta: number;
49
55
  /** Human-readable explanation. */
50
56
  detail: string;
57
+ /**
58
+ * Comparator tier the factor belongs to (T12691): 1 priority band, 2 severity,
59
+ * 3 bounded tiebreak; `null` for an informational factor outside the order.
60
+ */
61
+ tier?: 1 | 2 | 3 | null;
62
+ }
63
+
64
+ /** The lexicographic sort key of a scored task (T12691); higher sorts first. */
65
+ export interface ScoreTaskKey {
66
+ /** Owner priority band: critical 4, high 3, medium 2, low 1. */
67
+ band: number;
68
+ /** Attested severity: P0 4, P1 3, P2 2, P3 1, unknown 0. */
69
+ severity: number;
70
+ /** Bounded computed tiebreak (deps, phase, leverage, age). */
71
+ tiebreak: number;
51
72
  }
52
73
 
53
74
  /** Result of scoreTask. */
54
75
  export interface ScoreTaskResult {
55
- /** Final computed score. */
76
+ /**
77
+ * The key as one number that sorts identically (band × 10000 + severity ×
78
+ * 1000 + tiebreak), for display and single-number consumers.
79
+ */
56
80
  score: number;
57
- /** Individual scoring factors. */
81
+ /** Individual scoring factors, each tagged with its comparator tier. */
58
82
  factors: ScoreFactor[];
83
+ /** The lexicographic sort key (T12691). */
84
+ key?: ScoreTaskKey;
59
85
  }