@cleocode/contracts 2026.9.23 → 2026.9.24

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 (80) hide show
  1. package/dist/branch-lock.d.ts +9 -0
  2. package/dist/branch-lock.d.ts.map +1 -1
  3. package/dist/branch-lock.js +25 -3
  4. package/dist/branch-lock.js.map +1 -1
  5. package/dist/cloud/api.d.ts +1 -1
  6. package/dist/data-accessor.d.ts +205 -16
  7. package/dist/data-accessor.d.ts.map +1 -1
  8. package/dist/data-accessor.js.map +1 -1
  9. package/dist/decide.d.ts +110 -1
  10. package/dist/decide.d.ts.map +1 -1
  11. package/dist/decide.js +23 -0
  12. package/dist/decide.js.map +1 -1
  13. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  14. package/dist/dispatch/operations-registry.js +137 -6
  15. package/dist/dispatch/operations-registry.js.map +1 -1
  16. package/dist/doctor.d.ts +9 -0
  17. package/dist/doctor.d.ts.map +1 -1
  18. package/dist/exit-codes.d.ts +7 -0
  19. package/dist/exit-codes.d.ts.map +1 -1
  20. package/dist/exit-codes.js +7 -0
  21. package/dist/exit-codes.js.map +1 -1
  22. package/dist/index.d.ts +9 -6
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/knowledge-health.d.ts +21 -0
  27. package/dist/knowledge-health.d.ts.map +1 -1
  28. package/dist/nexus-account.d.ts +160 -0
  29. package/dist/nexus-account.d.ts.map +1 -0
  30. package/dist/nexus-account.js +68 -0
  31. package/dist/nexus-account.js.map +1 -0
  32. package/dist/operations/focus.d.ts +7 -3
  33. package/dist/operations/focus.d.ts.map +1 -1
  34. package/dist/operations/nexus-scope-map.d.ts +8 -0
  35. package/dist/operations/nexus-scope-map.d.ts.map +1 -1
  36. package/dist/operations/nexus-scope-map.js +8 -0
  37. package/dist/operations/nexus-scope-map.js.map +1 -1
  38. package/dist/operations/nexus.d.ts +265 -0
  39. package/dist/operations/nexus.d.ts.map +1 -1
  40. package/dist/operations/nexus.js +9 -1
  41. package/dist/operations/nexus.js.map +1 -1
  42. package/dist/operations/orchestrate.d.ts +6 -1
  43. package/dist/operations/orchestrate.d.ts.map +1 -1
  44. package/dist/operations/output-contracts-data.d.ts.map +1 -1
  45. package/dist/operations/output-contracts-data.js +115 -1
  46. package/dist/operations/output-contracts-data.js.map +1 -1
  47. package/dist/operations/tasks.d.ts +73 -9
  48. package/dist/operations/tasks.d.ts.map +1 -1
  49. package/dist/operations/tasks.js.map +1 -1
  50. package/dist/project-lifecycle.d.ts +6 -2
  51. package/dist/project-lifecycle.d.ts.map +1 -1
  52. package/dist/session.d.ts +19 -1
  53. package/dist/session.d.ts.map +1 -1
  54. package/dist/session.js +9 -2
  55. package/dist/session.js.map +1 -1
  56. package/dist/task.d.ts +35 -1
  57. package/dist/task.d.ts.map +1 -1
  58. package/dist/tools/score-task-priority.d.ts +1 -1
  59. package/dist/tools/score-task-priority.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  62. package/src/branch-lock.ts +38 -3
  63. package/src/data-accessor.ts +211 -16
  64. package/src/decide.ts +127 -1
  65. package/src/dispatch/operations-registry.ts +144 -6
  66. package/src/doctor.ts +9 -0
  67. package/src/exit-codes.ts +7 -0
  68. package/src/index.ts +48 -0
  69. package/src/knowledge-health.ts +22 -0
  70. package/src/nexus-account.ts +181 -0
  71. package/src/operations/focus.ts +7 -3
  72. package/src/operations/nexus-scope-map.ts +9 -0
  73. package/src/operations/nexus.ts +281 -0
  74. package/src/operations/orchestrate.ts +6 -2
  75. package/src/operations/output-contracts-data.ts +125 -1
  76. package/src/operations/tasks.ts +78 -12
  77. package/src/project-lifecycle.ts +6 -2
  78. package/src/session.ts +20 -2
  79. package/src/task.ts +37 -1
  80. package/src/tools/score-task-priority.ts +1 -1
package/src/session.ts CHANGED
@@ -132,6 +132,17 @@ export interface Session {
132
132
  * @defaultValue undefined
133
133
  */
134
134
  parentSessionId?: string | null;
135
+ /**
136
+ * ID of the orchestrator session that SPAWNED this one, recorded by the
137
+ * spawn itself (T12502). Unlike {@link Session.parentSessionId}, which a
138
+ * process declares for itself at `session start`, only the spawn writes
139
+ * this edge, so the task-claim chokepoint trusts it to let a spawn family
140
+ * pass a live lease between its members. Read-only on the session record:
141
+ * the whole-row session upsert never writes it.
142
+ *
143
+ * @defaultValue undefined
144
+ */
145
+ spawnedBySessionId?: string | null;
135
146
  /** Provider-specific agent identifier string. @defaultValue undefined */
136
147
  agentIdentifier?: string | null;
137
148
  /** ISO 8601 timestamp of when the handoff was consumed. @defaultValue undefined */
@@ -233,9 +244,16 @@ export class SessionView {
233
244
  return this._sessions.length;
234
245
  }
235
246
 
236
- /** Find the currently active session (if any). */
247
+ /**
248
+ * First `active` session in THIS collection — a scan over the rows the
249
+ * caller loaded, NOT the caller's own session (T12500). With several agents
250
+ * active it names an arbitrary one of them.
251
+ *
252
+ * @deprecated For "my session" use `resolveBoundSession` (mutations) or
253
+ * `resolveSessionForRead` (reads, labels an unbound guess).
254
+ */
237
255
  findActive(): Session | undefined {
238
- return this._sessions.find((s) => s.status === 'active');
256
+ return this._sessions.find((s) => s.status === 'active'); // get-active-session-allowed: collection scan over caller-supplied rows, not identity (T12500)
239
257
  }
240
258
 
241
259
  /** Find a session by ID. */
package/src/task.ts CHANGED
@@ -723,9 +723,22 @@ export interface Task {
723
723
  */
724
724
  pipelineStage?: string | null;
725
725
 
726
- /** Agent ID that has claimed/is assigned to this task. Null when unclaimed. @defaultValue undefined */
726
+ /**
727
+ * First-class human / owner assignee (`cleo assignee`, Studio boards).
728
+ * Separate from the agent work lease in {@link Task.claim}: `cleo start`,
729
+ * `cleo claim` and spawn never write it (T12502). @defaultValue undefined
730
+ */
727
731
  assignee?: string | null;
728
732
 
733
+ /**
734
+ * The agent work lease held on this task, when one is recorded (T12502).
735
+ * Absent when the task is unclaimed. Distinct from the human
736
+ * {@link Task.assignee}. Read-only on the task object: full-row writes
737
+ * never carry it, only the claim chokepoint changes it.
738
+ * @defaultValue undefined
739
+ */
740
+ claim?: TaskClaim;
741
+
729
742
  /**
730
743
  * Abort reason when a worker was stopped due to runaway detection (T1658).
731
744
  *
@@ -1020,3 +1033,26 @@ export interface TaskWorkState {
1020
1033
  /** ID of the primary session managing this work state. @defaultValue undefined */
1021
1034
  primarySession?: string | null;
1022
1035
  }
1036
+
1037
+ /**
1038
+ * A leased agent claim on a task (T12502 · epic T12497).
1039
+ *
1040
+ * Taken by `cleo start`, `cleo claim` and spawn with a compare-and-set in the
1041
+ * same write transaction; renewed by the holder session's activity or
1042
+ * `cleo claim <id> --renew`; released by `cleo stop`, completion,
1043
+ * cancellation, archive and the holder session ending. A claim whose
1044
+ * `leaseExpiresAt` has passed stays recorded until another session takes it
1045
+ * over explicitly (`--take-over`, audited).
1046
+ *
1047
+ * @task T12502
1048
+ */
1049
+ export interface TaskClaim {
1050
+ /** Session holding the lease. */
1051
+ sessionId: string;
1052
+ /** Agent identity of the holder (`CLEO_AGENT_ID` / spawn handle), or `null`. */
1053
+ agentId: string | null;
1054
+ /** ISO-8601 UTC instant the lease was taken. */
1055
+ claimedAt: string;
1056
+ /** ISO-8601 UTC instant the lease lapses unless renewed. */
1057
+ leaseExpiresAt: string;
1058
+ }
@@ -26,7 +26,7 @@ export interface ScoreTaskInput {
26
26
  labels?: string[];
27
27
  /** Severity axis (orthogonal to priority); unset for most tasks. */
28
28
  severity?: TaskSeverity | null;
29
- /** Kind axis; a `bug` with no severity is scored at the default bug severity (T12661). */
29
+ /** Kind axis; not part of the order — an unset severity is unknown, never imputed from `kind` (D11161). */
30
30
  kind?: TaskKind | null;
31
31
  }
32
32