@h-rig/contracts 0.0.6-alpha.164 → 0.0.6-alpha.166

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.
@@ -0,0 +1,33 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { TaskArtifactReadResult } from "./task-data";
3
+ export type TaskArtifactRef = {
4
+ readonly projectRoot: string;
5
+ readonly taskId?: string;
6
+ };
7
+ export type TaskArtifactListEntry = {
8
+ readonly path: string;
9
+ readonly sizeBytes: number;
10
+ readonly kind: "file" | "directory" | "other";
11
+ readonly modifiedAt?: string | null;
12
+ };
13
+ export type TaskArtifactWriteInput = TaskArtifactRef & {
14
+ readonly filename: string;
15
+ readonly content: string;
16
+ };
17
+ export type TaskArtifactReadInput = TaskArtifactRef & {
18
+ readonly filename: string;
19
+ readonly maxBytes?: number;
20
+ };
21
+ export type TaskArtifactWriteResult = {
22
+ readonly path: string;
23
+ readonly sizeBytes: number;
24
+ };
25
+ /** Task artifact directory/list/read/write vocabulary. */
26
+ export interface TaskArtifactsService {
27
+ artifactDir(input: TaskArtifactRef): string;
28
+ listArtifacts(input: TaskArtifactRef): Promise<readonly TaskArtifactListEntry[]>;
29
+ readArtifact(input: TaskArtifactReadInput): Promise<TaskArtifactReadResult>;
30
+ writeArtifact(input: TaskArtifactWriteInput): Promise<TaskArtifactWriteResult>;
31
+ }
32
+ export declare const TASK_ARTIFACTS_CAPABILITY_ID = "task-state.artifacts";
33
+ export declare const TASK_ARTIFACTS: CapabilityId<TaskArtifactsService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-artifacts.ts
8
+ var TASK_ARTIFACTS_CAPABILITY_ID = "task-state.artifacts";
9
+ var TASK_ARTIFACTS = makeCapabilityId(TASK_ARTIFACTS_CAPABILITY_ID);
10
+ export {
11
+ TASK_ARTIFACTS_CAPABILITY_ID,
12
+ TASK_ARTIFACTS
13
+ };
@@ -0,0 +1,29 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { RuntimeInstructionProvider } from "./provider-instructions";
3
+ import type { RigTask, TaskRecord } from "./task-source";
4
+ export type TaskContextRenderInput = {
5
+ readonly projectRoot: string;
6
+ readonly taskId?: string;
7
+ readonly task?: RigTask | TaskRecord | null;
8
+ readonly provider?: RuntimeInstructionProvider;
9
+ };
10
+ export type TaskScopeRenderInput = TaskContextRenderInput & {
11
+ readonly expandFiles?: boolean;
12
+ };
13
+ export type TaskPromptContextSection = {
14
+ readonly title: string;
15
+ readonly content: string;
16
+ };
17
+ export type TaskPromptContext = {
18
+ readonly taskId: string | null;
19
+ readonly sections: readonly TaskPromptContextSection[];
20
+ };
21
+ /** Provider/prompt-owned task info, scope, and dependency rendering vocabulary. */
22
+ export interface TaskContextRendererService {
23
+ renderTaskInfo(input: TaskContextRenderInput): Promise<TaskPromptContextSection>;
24
+ renderTaskScope(input: TaskScopeRenderInput): Promise<TaskPromptContextSection>;
25
+ renderTaskDependencies(input: TaskContextRenderInput): Promise<TaskPromptContextSection>;
26
+ renderPromptContext(input: TaskContextRenderInput): Promise<TaskPromptContext>;
27
+ }
28
+ export declare const TASK_CONTEXT_RENDERER_CAPABILITY_ID = "provider.task-context-renderer";
29
+ export declare const TASK_CONTEXT_RENDERER: CapabilityId<TaskContextRendererService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-context-renderer.ts
8
+ var TASK_CONTEXT_RENDERER_CAPABILITY_ID = "provider.task-context-renderer";
9
+ var TASK_CONTEXT_RENDERER = makeCapabilityId(TASK_CONTEXT_RENDERER_CAPABILITY_ID);
10
+ export {
11
+ TASK_CONTEXT_RENDERER_CAPABILITY_ID,
12
+ TASK_CONTEXT_RENDERER
13
+ };
@@ -1,23 +1,33 @@
1
1
  /**
2
- * The TASK-DATA capability seam.
2
+ * The TASK_DATA compatibility-facade seam.
3
3
  *
4
- * Floor-neutral vocab + a single `CapabilityId<TaskDataService>` describing the
5
- * task-DATA reads and task-command behaviours the lifecycle, scheduler,
6
- * isolation provisioning, repos, workspace, and CLI surfaces consume. The
7
- * READ/normalize/validate POLICY behind each method (synchronize task-config,
8
- * strip metadata, tracker projection, validator dispatch, artifact IO) is owned
9
- * by `@rig/task-sources-plugin`, which `defineCapability(TASK_DATA_SERVICE_CAPABILITY).provide`s
10
- * the impl. Consumers `resolve`/`require` it off a built plugin host (or read the
11
- * boot-installed singleton) WITHOUT importing the provider plugin — this is the
12
- * seam that replaces the cross-plugin `import("@rig/task-sources-plugin/...")`
13
- * impl imports (SEAM-ONLY §6.4).
4
+ * Floor-neutral vocab + a single `CapabilityId<TaskDataService>` for legacy
5
+ * task-data reads and task-command behaviours consumed by lifecycle, scheduler,
6
+ * isolation provisioning, repos, workspace, and CLI surfaces. Source adapters
7
+ * own real source IO through their dedicated seams; local task state, metadata,
8
+ * artifact IO, and tracker reads own their semantic capabilities in
9
+ * `@rig/task-state-plugin`.
14
10
  *
15
- * Pure: types + one branded id, no behaviour.
11
+ * Ownership intent: `@rig/task-io-plugin` is the target owner for this legacy
12
+ * facade because it aggregates task/source IO for old consumers. The temporary
13
+ * provider shim remains in `@rig/task-state-plugin` only because capability
14
+ * provider factories run as `FeatureCapability.run(undefined)` with no
15
+ * `PluginHost`/resolver context; the narrower task-state/artifact/tracker
16
+ * capabilities are not boot-installed, and this facade still includes
17
+ * synchronous methods. Without a host-aware provider seam, task-io cannot compose
18
+ * `TASK_STATE_STORE`, `TASK_ARTIFACTS`, and `TASK_TRACKER_STATE` without a
19
+ * forbidden plugin-to-plugin implementation import.
20
+ *
21
+ * Consumers `resolve`/`require` task data off a built plugin host (or read the
22
+ * boot-installed singleton) WITHOUT importing the provider plugin. When provider
23
+ * execution becomes host-aware, move only the facade provider to task-io and keep
24
+ * the semantic state/artifact/tracker services in task-state.
25
+ *
26
+ * Pure: types + one branded legacy id, no behaviour.
16
27
  */
17
28
  import type { CapabilityId } from "./capability-id";
18
29
  import type { TaskConfigEntry, TaskRecord, RegisteredTaskSource, TaskSourceUpdate } from "./task-source";
19
30
  import type { TaskRecordReader } from "./isolation";
20
- import type { RuntimeInstructionProvider } from "./provider-instructions";
21
31
  import type { CanonicalTaskLifecycleStatus, TaskStateMetadataEnvelope } from "./task-state-metadata";
22
32
  /** Result of a bounded artifact-file read (preview + truncation metadata). */
23
33
  export type TaskArtifactReadResult = {
@@ -75,6 +85,11 @@ export type SyncedTrackerSnapshot = {
75
85
  export type ReadSyncedTrackerOptions = {
76
86
  allowLocalFallback?: boolean;
77
87
  };
88
+ export type SourceAwareTaskConfigReadOptions = {
89
+ readonly configPath?: string;
90
+ readonly ghBinary?: string;
91
+ readonly allowLocalTaskConfigStatusFallback?: boolean;
92
+ };
78
93
  /** Result of resolving a single task through the configured task source. */
79
94
  export type TaskSourceTaskReadResult = {
80
95
  configured: boolean;
@@ -106,45 +121,6 @@ export type TaskSourceLifecycleUpdateResult = {
106
121
  status: unknown;
107
122
  projectSync?: unknown;
108
123
  };
109
- /** Input for rendering a task-run lifecycle status comment. */
110
- export type TaskRunLifecycleCommentInput = {
111
- runId: string;
112
- status: string;
113
- summary: string;
114
- runtimeWorkspace?: string | null;
115
- logsDir?: string | null;
116
- sessionDir?: string | null;
117
- errorText?: string | null;
118
- };
119
- /** Boundary subset of the source-aware task-config reader options. */
120
- export type SourceAwareTaskConfigReadOptions = {
121
- configPath?: string;
122
- allowLocalTaskConfigStatusFallback?: boolean;
123
- };
124
- /**
125
- * The lifecycle status values a run reflects to the task source.
126
- * Mirrors the type defined in @rig/task-sources-plugin/source-lifecycle —
127
- * lives here so @rig/run-exec can use it through the TaskDataService seam
128
- * without a cross-plugin impl import.
129
- */
130
- export type RunTaskSourceLifecycleStatus = "running" | "under_review" | "ci_fixing" | "merging" | "closed" | "cancelled" | "needs_attention";
131
- /**
132
- * The run identity fields passed when reflecting a run lifecycle event to the
133
- * task source.
134
- */
135
- export type RunTaskSourceLifecycleRun = {
136
- runId?: string | null;
137
- taskId?: string | null;
138
- sourceTask?: unknown;
139
- worktreePath?: string | null;
140
- logRoot?: string | null;
141
- sessionPath?: string | null;
142
- errorText?: string | null;
143
- };
144
- /** Optional overrides for a run lifecycle update. */
145
- export type RunTaskSourceLifecycleOptions = {
146
- errorText?: string | null;
147
- };
148
124
  /** Context for building a plugin-backed task-record reader. */
149
125
  export type PluginTaskRecordReaderContext = {
150
126
  taskSourceRegistry: {
@@ -160,17 +136,22 @@ export type PluginTaskRecordReaderOptions = {
160
136
  sourceKind?: string;
161
137
  };
162
138
  /**
163
- * The task-DATA service contributed by `@rig/task-sources-plugin`. Every method
164
- * is keyed by `projectRoot` (the service is stateless), so it is safe to install
165
- * as a boot singleton and read synchronously by substrate consumers.
139
+ * Legacy TASK_DATA compatibility facade.
140
+ *
141
+ * The shape intentionally remains broad while callers migrate to narrower
142
+ * semantic capabilities. Every method is keyed by `projectRoot` (the service is
143
+ * stateless), so the current provider can be installed as a boot singleton and
144
+ * read synchronously by substrate consumers.
166
145
  */
167
146
  export interface TaskDataService {
168
147
  currentTaskId(projectRoot: string): string;
169
148
  readTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
170
149
  readSourceTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
150
+ readValidationDescriptions(projectRoot: string): Record<string, string>;
171
151
  lookupTask(projectRoot: string, input: string): string;
172
152
  artifactDirForId(projectRoot: string, id: string): string;
173
- taskInfo(projectRoot: string, taskId?: string, runtimeProviderOverride?: RuntimeInstructionProvider): Promise<void>;
153
+ /** @deprecated Third argument is ignored; runtime/provider instruction ownership lives outside TASK_DATA. */
154
+ taskInfo(projectRoot: string, taskId?: string, deprecatedRuntimeProviderOverride?: unknown): Promise<void>;
174
155
  taskDeps(projectRoot: string, taskId?: string): Promise<void>;
175
156
  taskStatus(projectRoot: string): void;
176
157
  taskScope(projectRoot: string, expandFiles: boolean, taskId?: string): Promise<void>;
@@ -182,7 +163,6 @@ export interface TaskDataService {
182
163
  taskId?: string;
183
164
  dryRun?: boolean;
184
165
  }): TaskReopenSummary;
185
- taskValidate(projectRoot: string, taskId?: string, validatorRegistry?: unknown): Promise<boolean>;
186
166
  taskArtifacts(projectRoot: string, taskId?: string): void;
187
167
  taskArtifactDir(projectRoot: string, taskId?: string): string;
188
168
  taskArtifactWrite(projectRoot: string, filename: string, content: string, taskId?: string): void;
@@ -200,27 +180,6 @@ export interface TaskDataService {
200
180
  sourceTask?: SourceTaskIdentity | null;
201
181
  update: TaskSourceUpdate;
202
182
  }): Promise<TaskSourceLifecycleUpdateResult>;
203
- buildTaskRunLifecycleComment(input: TaskRunLifecycleCommentInput): string;
204
- /**
205
- * Compat fallback: push an update to a github-issues-backed task by parsing
206
- * its `owner/repo#n` source-issue id. Returns false when the id does not match
207
- * the taskId. Exposed on the seam so the kernel agent-launch executor can apply
208
- * the source-aware compatibility update without importing the provider plugin.
209
- */
210
- updateGithubIssueTaskBySourceIssueId(sourceIssueId: string | null | undefined, taskId: string, update: TaskSourceUpdate): boolean;
211
- /**
212
- * Compat fallback: push a status/comment update through the source-aware
213
- * task-config (github-issues, files, or legacy task-config). Returns false when
214
- * no writable source is configured. Seam-exposed for the kernel executor.
215
- */
216
- updateSourceAwareTaskConfigTask(projectRoot: string, taskId: string, update: TaskSourceUpdate): boolean;
217
- /**
218
- * Reflect a run lifecycle event (start/stop/closeout) to the configured task
219
- * source. Returns null when no taskId is present or no source is configured.
220
- * Exposed on the seam so @rig/run-exec can call it without importing
221
- * @rig/task-sources-plugin impl files directly (SEAM-ONLY §6.4).
222
- */
223
- updateRunTaskSourceLifecycle(projectRoot: string, run: RunTaskSourceLifecycleRun, status: RunTaskSourceLifecycleStatus, summary: string, options?: RunTaskSourceLifecycleOptions): Promise<TaskSourceLifecycleUpdateResult | null>;
224
183
  createLegacyTaskConfigRecordReader(projectRoot: string, options?: {
225
184
  configPath?: string;
226
185
  }): TaskRecordReader;
@@ -230,7 +189,7 @@ export interface TaskDataService {
230
189
  listReadyTaskIdsFromTracker(snapshot: SyncedTrackerSnapshot): string[];
231
190
  normalizeTaskLifecycleStatus(status: unknown): CanonicalTaskLifecycleStatus | null;
232
191
  }
233
- /** Stable id string for the task-data service capability. */
192
+ /** Stable legacy id string for the TASK_DATA compatibility facade. */
234
193
  export declare const TASK_DATA_SERVICE_CAPABILITY_ID = "task-sources.task-data";
235
194
  /**
236
195
  * The branded task-data capability id. `defineCapability(TASK_DATA_SERVICE_CAPABILITY)`
@@ -3,9 +3,8 @@ import type { TaskSourceRegistration } from "./plugin";
3
3
  import type { TaskBrowserConfig } from "./browser";
4
4
  /**
5
5
  * A single entry in the on-disk task-config map (`.rig/task-config.json`).
6
- * Floor-neutral DATA shape. The READ/normalize POLICY (synchronize, strip
7
- * metadata, validation-description extraction) is owned by
8
- * @rig/task-sources-plugin (`task-state`), NOT the floor.
6
+ * Floor-neutral DATA shape. Read/normalize/local-state policy is intentionally
7
+ * outside this contract and belongs to the plugin that provides that domain.
9
8
  */
10
9
  export type TaskConfigEntry = {
11
10
  title?: string;
@@ -34,10 +33,9 @@ export interface TaskRecord {
34
33
  }
35
34
  /**
36
35
  * The NORMALIZED, surface-facing task shape (the projection consumers read).
37
- * The TYPE is floor-neutral vocab and lives here in contracts; the
38
- * normalization POLICY that produces it (field-mapping a raw `TaskRecord` into
39
- * this shape — title/body/url/dependency fallback chains) is owned by
40
- * @rig/task-sources-plugin (`toRigTask`), NOT by the floor.
36
+ * The TYPE is floor-neutral vocab and lives here in contracts; the normalization
37
+ * implementation is provided by the task IO owner, not by the source-adapter
38
+ * plugin.
41
39
  */
42
40
  export type RigTask = {
43
41
  readonly id: string;
@@ -56,11 +54,23 @@ export type RigTask = {
56
54
  };
57
55
  /** Alias retained for call sites that accept any task-like projection. */
58
56
  export type TaskLike = RigTask;
57
+ export type TaskSourceLabelUpdate = {
58
+ readonly add?: readonly string[];
59
+ readonly remove?: readonly string[];
60
+ };
59
61
  /**
60
- * A registered task source adapter combines the plugin-level registration
61
- * metadata with the runtime-callable interface.
62
+ * Explicit provider-owned source update payload. Reflection code should
63
+ * project intent into these concrete source write values before calling adapters.
62
64
  */
63
- export interface TaskSourceUpdate {
65
+ export interface TaskSourceProjectedUpdate {
66
+ labels?: TaskSourceLabelUpdate;
67
+ sourceFields?: Record<string, string | null | undefined>;
68
+ close?: boolean;
69
+ assignToDefault?: boolean;
70
+ }
71
+ /** Generic provider-owned source update payload. */
72
+ export interface TaskSourceUpdate extends TaskSourceProjectedUpdate {
73
+ /** @deprecated Prefer explicit projected update fields for source writeback. */
64
74
  status?: TaskRecord["status"];
65
75
  title?: string;
66
76
  body?: string;
@@ -75,6 +85,31 @@ export interface TaskSourceCreateInput {
75
85
  metadata?: Record<string, unknown>;
76
86
  }
77
87
  export type TaskSourceCreateResult = TaskRecord;
88
+ export type TaskSourceUpdateRequest = {
89
+ readonly projectRoot: string;
90
+ readonly taskId: string;
91
+ readonly sourceId?: string | null;
92
+ readonly sourceKind?: string | null;
93
+ readonly update: TaskSourceUpdate;
94
+ };
95
+ export type TaskSourceUpdateResult = {
96
+ readonly taskId: string;
97
+ readonly updated: boolean;
98
+ readonly sourceId?: string | null;
99
+ readonly sourceKind?: string | null;
100
+ readonly result?: unknown;
101
+ };
102
+ /**
103
+ * Generic source-adapter writeback port. The legacy id string is retained, but
104
+ * implementations should only dispatch to configured source adapters; local task
105
+ * state, normalized task IO, source reflection, and validation policy are
106
+ * owned by their respective plugins.
107
+ */
108
+ export interface TaskSourceUpdateService {
109
+ updateTask(input: TaskSourceUpdateRequest): Promise<TaskSourceUpdateResult>;
110
+ }
111
+ export declare const TASK_SOURCE_UPDATE_CAPABILITY_ID = "task-sources.update";
112
+ export declare const TASK_SOURCE_UPDATE: CapabilityId<TaskSourceUpdateService>;
78
113
  export interface RegisteredTaskSource extends TaskSourceRegistration {
79
114
  list(): Promise<readonly TaskRecord[]>;
80
115
  get?(id: string): Promise<TaskRecord | undefined>;
@@ -88,10 +123,9 @@ export type TaskIoCreateResult = {
88
123
  readonly result: unknown;
89
124
  };
90
125
  /**
91
- * Source-owned task IO projection seam. Providers normalize raw task-source
92
- * records into RigTask and adapt generic task creation payloads to the
93
- * configured source; consumers resolve this instead of importing @rig/core
94
- * task-source glue.
126
+ * Normalized task IO projection seam. The historical id string is retained for
127
+ * compatibility, but this capability is owned/provided by @rig/task-io-plugin;
128
+ * source-adapter plugins should contribute adapters and source writeback only.
95
129
  */
96
130
  export interface TaskIoService {
97
131
  listTasks(projectRoot: string): Promise<readonly RigTask[]>;
@@ -5,9 +5,13 @@ function makeCapabilityId(id) {
5
5
  }
6
6
 
7
7
  // packages/contracts/src/task-source.ts
8
+ var TASK_SOURCE_UPDATE_CAPABILITY_ID = "task-sources.update";
9
+ var TASK_SOURCE_UPDATE = makeCapabilityId(TASK_SOURCE_UPDATE_CAPABILITY_ID);
8
10
  var TASK_IO_SERVICE_CAPABILITY_ID = "task-sources.task-io";
9
11
  var TASK_IO_SERVICE_CAPABILITY = makeCapabilityId(TASK_IO_SERVICE_CAPABILITY_ID);
10
12
  export {
13
+ TASK_SOURCE_UPDATE_CAPABILITY_ID,
14
+ TASK_SOURCE_UPDATE,
11
15
  TASK_IO_SERVICE_CAPABILITY_ID,
12
16
  TASK_IO_SERVICE_CAPABILITY
13
17
  };
@@ -0,0 +1,16 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { TaskConfigEntry } from "./task-source";
3
+ import type { TaskStateMetadataEnvelope } from "./task-state-metadata";
4
+ /** Local `.rig` task state/config/metadata only; no runtime/provider guidance. */
5
+ export interface TaskStateStoreService {
6
+ readCurrentTaskId(projectRoot: string): string | null;
7
+ writeCurrentTaskId(projectRoot: string, taskId: string | null): void;
8
+ readTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
9
+ writeTaskConfig(projectRoot: string, entries: Record<string, TaskConfigEntry>): void;
10
+ readSourceTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
11
+ writeSourceTaskConfig(projectRoot: string, entries: Record<string, TaskConfigEntry>): void;
12
+ readTaskStateMetadata(projectRoot: string): TaskStateMetadataEnvelope | null;
13
+ writeTaskStateMetadata(projectRoot: string, envelope: TaskStateMetadataEnvelope): void;
14
+ }
15
+ export declare const TASK_STATE_STORE_CAPABILITY_ID = "task-state.store";
16
+ export declare const TASK_STATE_STORE: CapabilityId<TaskStateStoreService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-state-store.ts
8
+ var TASK_STATE_STORE_CAPABILITY_ID = "task-state.store";
9
+ var TASK_STATE_STORE = makeCapabilityId(TASK_STATE_STORE_CAPABILITY_ID);
10
+ export {
11
+ TASK_STATE_STORE_CAPABILITY_ID,
12
+ TASK_STATE_STORE
13
+ };
@@ -0,0 +1,106 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { CanonicalTaskLifecycleStatus, TaskStateMetadata, TaskStateMetadataEnvelope } from "./task-state-metadata";
3
+ import type { SyncedTrackerSnapshot, ReadSyncedTrackerOptions } from "./task-data";
4
+ export declare const TASK_TRACKER_LIFECYCLE_STATUSES: readonly ["draft", "open", "ready", "queued", "in_progress", "under_review", "blocked", "completed", "cancelled"];
5
+ export declare const TASK_TRACKER_STALE_CLAIM_MS: number;
6
+ export type TaskTrackerPolicyDecision = {
7
+ readonly allowed: boolean;
8
+ readonly code?: "claim-conflict" | "status-conflict";
9
+ readonly reason?: string;
10
+ };
11
+ export type TrackerPullRequestEvidence = {
12
+ readonly branchName?: string | null;
13
+ readonly prNumber?: number | null;
14
+ readonly prUrl?: string | null;
15
+ readonly isOpen?: boolean;
16
+ readonly isMerged?: boolean;
17
+ readonly reviewState?: string | null;
18
+ };
19
+ export type TrackerReconcileEvidence = {
20
+ readonly now?: string;
21
+ readonly closeoutPassed?: boolean;
22
+ readonly pr?: TrackerPullRequestEvidence | null;
23
+ readonly activeOwnerIds?: readonly string[];
24
+ };
25
+ export type TaskReconciliationProjection = {
26
+ readonly valid: boolean;
27
+ readonly reasons: readonly string[];
28
+ readonly isStale: boolean;
29
+ readonly wouldReconcileTo: CanonicalTaskLifecycleStatus | null;
30
+ readonly nextMetadata: TaskStateMetadata | null;
31
+ };
32
+ export type TaskTrackerReconciliationPolicyInput = {
33
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
34
+ readonly metadata: TaskStateMetadata | null;
35
+ readonly evidence?: TrackerReconcileEvidence;
36
+ /**
37
+ * Explicit clock input keeps the lifecycle-owned projection deterministic.
38
+ */
39
+ readonly nowIso: string;
40
+ };
41
+ export type TaskTrackerClaimTransitionPolicyInput = {
42
+ readonly taskId: string;
43
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
44
+ readonly expectedStatus?: CanonicalTaskLifecycleStatus;
45
+ };
46
+ export type TaskTrackerLifecycleTransitionPolicyInput = {
47
+ readonly taskId: string;
48
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
49
+ readonly allowedFrom?: readonly CanonicalTaskLifecycleStatus[];
50
+ };
51
+ export interface TaskTrackerReconciliationPolicyService {
52
+ projectReconciliation(input: TaskTrackerReconciliationPolicyInput): TaskReconciliationProjection;
53
+ canUpdateLifecycle(input: TaskTrackerLifecycleTransitionPolicyInput): TaskTrackerPolicyDecision;
54
+ }
55
+ export declare const TASK_TRACKER_RECONCILIATION_POLICY_CAPABILITY_ID = "lifecycle.task-tracker-reconciliation-policy";
56
+ export declare const TASK_TRACKER_RECONCILIATION_POLICY: CapabilityId<TaskTrackerReconciliationPolicyService>;
57
+ export interface TaskTrackerReadinessPolicyService {
58
+ listReadyTaskIds(snapshot: SyncedTrackerSnapshot): readonly string[];
59
+ canClaimTask(input: TaskTrackerClaimTransitionPolicyInput): TaskTrackerPolicyDecision;
60
+ }
61
+ export declare const TASK_TRACKER_READINESS_POLICY_CAPABILITY_ID = "scheduler.task-tracker-readiness-policy";
62
+ export declare const TASK_TRACKER_READINESS_POLICY: CapabilityId<TaskTrackerReadinessPolicyService>;
63
+ export type TaskTrackerStateUpdateInput = {
64
+ readonly projectRoot: string;
65
+ readonly taskId: string;
66
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
67
+ readonly metadata?: TaskStateMetadata | null;
68
+ /** @deprecated OWNER-TODO: remove when callers pass reconciliation evidence only to TASK_TRACKER_RECONCILIATION_POLICY. */
69
+ readonly evidence?: TrackerReconcileEvidence;
70
+ };
71
+ export type TaskTrackerStateClaimInput = {
72
+ readonly projectRoot: string;
73
+ readonly taskId: string;
74
+ readonly ownerId: string;
75
+ readonly runId?: string | null;
76
+ readonly now?: string;
77
+ };
78
+ /**
79
+ * Tracker repository locator seam.
80
+ *
81
+ * Task-state owns tracker persistence and metadata storage only. Lifecycle and
82
+ * scheduler policy capabilities own reconciliation, stale-claim, readiness, and
83
+ * transition decisions; contracts provides the pure vocabulary/capability ids.
84
+ */
85
+ export interface TaskTrackerRepoLocatorService {
86
+ resolveTrackerRepoPath(projectRoot: string): string;
87
+ }
88
+ export declare const TASK_TRACKER_REPO_LOCATOR_CAPABILITY_ID = "task-state.tracker-repo-locator";
89
+ export declare const TASK_TRACKER_REPO_LOCATOR: CapabilityId<TaskTrackerRepoLocatorService>;
90
+ /** Tracker snapshot/persistence API. Keep this shape stable for legacy callers. */
91
+ export interface TaskTrackerStateService {
92
+ readSnapshot(projectRoot: string, options?: ReadSyncedTrackerOptions): SyncedTrackerSnapshot;
93
+ /** @deprecated Use TASK_TRACKER_READINESS_POLICY. OWNER-TODO: remove after scheduler queue consumers switch seams. */
94
+ listReadyTaskIds(snapshot: SyncedTrackerSnapshot): readonly string[];
95
+ normalizeStatus(status: unknown): CanonicalTaskLifecycleStatus | null;
96
+ /** @deprecated Use TASK_TRACKER_RECONCILIATION_POLICY. OWNER-TODO: remove after lifecycle consumers switch seams. */
97
+ projectReconciliation(input: {
98
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
99
+ readonly metadata: TaskStateMetadata | null;
100
+ readonly evidence?: TrackerReconcileEvidence;
101
+ }): TaskReconciliationProjection;
102
+ claimTask(input: TaskTrackerStateClaimInput): TaskStateMetadataEnvelope | Promise<TaskStateMetadataEnvelope>;
103
+ updateLifecycle(input: TaskTrackerStateUpdateInput): TaskStateMetadataEnvelope | Promise<TaskStateMetadataEnvelope>;
104
+ }
105
+ export declare const TASK_TRACKER_STATE_CAPABILITY_ID = "task-state.tracker-state";
106
+ export declare const TASK_TRACKER_STATE: CapabilityId<TaskTrackerStateService>;
@@ -0,0 +1,39 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-tracker-state.ts
8
+ var TASK_TRACKER_LIFECYCLE_STATUSES = [
9
+ "draft",
10
+ "open",
11
+ "ready",
12
+ "queued",
13
+ "in_progress",
14
+ "under_review",
15
+ "blocked",
16
+ "completed",
17
+ "cancelled"
18
+ ];
19
+ var TASK_TRACKER_STALE_CLAIM_MS = 24 * 60 * 60 * 1000;
20
+ var TASK_TRACKER_RECONCILIATION_POLICY_CAPABILITY_ID = "lifecycle.task-tracker-reconciliation-policy";
21
+ var TASK_TRACKER_RECONCILIATION_POLICY = makeCapabilityId(TASK_TRACKER_RECONCILIATION_POLICY_CAPABILITY_ID);
22
+ var TASK_TRACKER_READINESS_POLICY_CAPABILITY_ID = "scheduler.task-tracker-readiness-policy";
23
+ var TASK_TRACKER_READINESS_POLICY = makeCapabilityId(TASK_TRACKER_READINESS_POLICY_CAPABILITY_ID);
24
+ var TASK_TRACKER_REPO_LOCATOR_CAPABILITY_ID = "task-state.tracker-repo-locator";
25
+ var TASK_TRACKER_REPO_LOCATOR = makeCapabilityId(TASK_TRACKER_REPO_LOCATOR_CAPABILITY_ID);
26
+ var TASK_TRACKER_STATE_CAPABILITY_ID = "task-state.tracker-state";
27
+ var TASK_TRACKER_STATE = makeCapabilityId(TASK_TRACKER_STATE_CAPABILITY_ID);
28
+ export {
29
+ TASK_TRACKER_STATE_CAPABILITY_ID,
30
+ TASK_TRACKER_STATE,
31
+ TASK_TRACKER_STALE_CLAIM_MS,
32
+ TASK_TRACKER_REPO_LOCATOR_CAPABILITY_ID,
33
+ TASK_TRACKER_REPO_LOCATOR,
34
+ TASK_TRACKER_RECONCILIATION_POLICY_CAPABILITY_ID,
35
+ TASK_TRACKER_RECONCILIATION_POLICY,
36
+ TASK_TRACKER_READINESS_POLICY_CAPABILITY_ID,
37
+ TASK_TRACKER_READINESS_POLICY,
38
+ TASK_TRACKER_LIFECYCLE_STATUSES
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/contracts",
3
- "version": "0.0.6-alpha.164",
3
+ "version": "0.0.6-alpha.166",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",