@indigoai-us/hq-cli 5.345.214 → 5.345.215-beta.0

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 (103) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/command-catalog.generated.d.ts +134 -7
  3. package/dist/command-catalog.generated.js +168 -7
  4. package/dist/commands/agents.d.ts +51 -1
  5. package/dist/commands/agents.js +154 -2
  6. package/dist/commands/bot-jobs.d.ts +2 -15
  7. package/dist/commands/bot-jobs.js +2 -94
  8. package/dist/commands/bot-runtime.d.ts +46 -5
  9. package/dist/commands/bot-runtime.js +228 -18
  10. package/dist/commands/bot.d.ts +16 -9
  11. package/dist/commands/bot.js +169 -51
  12. package/dist/commands/cloud.d.ts +66 -13
  13. package/dist/commands/cloud.js +120 -39
  14. package/dist/commands/company-restore.d.ts +23 -0
  15. package/dist/commands/company-restore.js +128 -0
  16. package/dist/commands/company.js +2 -0
  17. package/dist/commands/integrations-connect.d.ts +10 -3
  18. package/dist/commands/integrations-connect.js +87 -13
  19. package/dist/commands/lanes.js +26 -9
  20. package/dist/commands/sources.js +6 -0
  21. package/dist/commands/storage-offload.d.ts +12 -0
  22. package/dist/commands/storage-offload.js +41 -3
  23. package/dist/commands/sync-mode.js +5 -0
  24. package/dist/commands/whoami.js +4 -0
  25. package/dist/lib/bot/config.d.ts +1 -0
  26. package/dist/lib/bot/config.js +10 -0
  27. package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
  28. package/dist/lib/bot/eventbridge-cron.js +104 -0
  29. package/dist/lib/bot/fleet-local.d.ts +33 -1
  30. package/dist/lib/bot/fleet-local.js +215 -31
  31. package/dist/lib/bot/fleet-python.d.ts +3 -0
  32. package/dist/lib/bot/fleet-python.js +34 -4
  33. package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
  34. package/dist/lib/bot/fleet-runtime-sources.js +30 -0
  35. package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
  36. package/dist/lib/bot/legacy-provider-login.js +19 -2
  37. package/dist/lib/bot/prompt.js +1 -1
  38. package/dist/lib/bot/readiness.d.ts +8 -0
  39. package/dist/lib/bot/readiness.js +17 -3
  40. package/dist/lib/bot/runtime-auth.d.ts +30 -0
  41. package/dist/lib/bot/runtime-auth.js +94 -3
  42. package/dist/lib/bot/status.d.ts +2 -0
  43. package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
  44. package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
  45. package/dist/lib/capacity/collectors/grok.d.ts +5 -0
  46. package/dist/lib/capacity/collectors/grok.js +56 -5
  47. package/dist/lib/daemon/catalog.js +11 -1
  48. package/dist/lib/db/sqlite-binding.d.ts +1 -0
  49. package/dist/lib/db/sqlite-binding.js +1 -1
  50. package/dist/lib/delivery/artifacts.d.ts +99 -0
  51. package/dist/lib/delivery/artifacts.js +548 -0
  52. package/dist/lib/delivery/backup.d.ts +78 -0
  53. package/dist/lib/delivery/backup.js +343 -0
  54. package/dist/lib/delivery/cache.d.ts +29 -0
  55. package/dist/lib/delivery/cache.js +33 -0
  56. package/dist/lib/delivery/contracts.d.ts +142 -0
  57. package/dist/lib/delivery/contracts.js +289 -0
  58. package/dist/lib/delivery/credentials.d.ts +54 -0
  59. package/dist/lib/delivery/credentials.js +119 -0
  60. package/dist/lib/delivery/enrollment.d.ts +142 -0
  61. package/dist/lib/delivery/enrollment.js +382 -0
  62. package/dist/lib/delivery/identity.d.ts +25 -0
  63. package/dist/lib/delivery/identity.js +82 -0
  64. package/dist/lib/delivery/inbox.d.ts +116 -0
  65. package/dist/lib/delivery/inbox.js +260 -0
  66. package/dist/lib/delivery/migrations.d.ts +139 -0
  67. package/dist/lib/delivery/migrations.js +623 -0
  68. package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
  69. package/dist/lib/delivery/mqtt-adapter.js +242 -0
  70. package/dist/lib/delivery/mqtt.d.ts +61 -0
  71. package/dist/lib/delivery/mqtt.js +112 -0
  72. package/dist/lib/delivery/outbox.d.ts +95 -0
  73. package/dist/lib/delivery/outbox.js +187 -0
  74. package/dist/lib/delivery/provenance.d.ts +129 -0
  75. package/dist/lib/delivery/provenance.js +93 -0
  76. package/dist/lib/delivery/reconciler.d.ts +151 -0
  77. package/dist/lib/delivery/reconciler.js +492 -0
  78. package/dist/lib/delivery/restore.d.ts +35 -0
  79. package/dist/lib/delivery/restore.js +134 -0
  80. package/dist/lib/delivery/store.d.ts +161 -0
  81. package/dist/lib/delivery/store.js +940 -0
  82. package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
  83. package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
  84. package/dist/lib/delivery/workers/macos.d.ts +176 -0
  85. package/dist/lib/delivery/workers/macos.js +901 -0
  86. package/dist/lib/delivery/workers/windows-boundary.d.ts +453 -0
  87. package/dist/lib/delivery/workers/windows-boundary.js +693 -0
  88. package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
  89. package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
  90. package/dist/lib/delivery/workers/windows.d.ts +241 -0
  91. package/dist/lib/delivery/workers/windows.js +608 -0
  92. package/dist/lib/install/provider-wrappers.d.ts +2 -0
  93. package/dist/lib/install/provider-wrappers.js +68 -3
  94. package/dist/utils/cognito-callback-port.d.ts +14 -0
  95. package/dist/utils/cognito-callback-port.js +24 -0
  96. package/dist/utils/cognito-session.js +3 -3
  97. package/dist/utils/deleted-company-notice.d.ts +59 -0
  98. package/dist/utils/deleted-company-notice.js +156 -0
  99. package/dist/utils/login-browser.d.ts +1 -1
  100. package/dist/utils/login-browser.js +7 -5
  101. package/dist/utils/resident-package-preload.js +30 -15
  102. package/dist/utils/vault-api.js +7 -0
  103. package/package.json +7 -7
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Idempotent notification inbox and bounded reconciliation (US-005).
3
+ *
4
+ * A consumer belongs to one enrolled worker. It treats every notification as
5
+ * a hint: the payload is parsed strictly, then checked against the committed
6
+ * ledger through the US-004 access layer (tenant, capability, owner epoch)
7
+ * before any claim, and claims go through `dispatch`, which applies the same
8
+ * checks inside the store commit. A notification therefore cannot authorize,
9
+ * create or claim a job the ledger does not already hold as ready.
10
+ *
11
+ * The inbox is a sqlite file of handled keys. A verified event is recorded
12
+ * under its stable event id, so a redelivery or a republish is a duplicate and
13
+ * each durable transition is applied once. A payload that fails parsing or
14
+ * verification is recorded under its sha256 only, so a forgery cannot occupy
15
+ * a genuine event's id. A handle that is fenced or closed records nothing and
16
+ * reports "deferred", which leaves the message unacked.
17
+ *
18
+ * Reconciliation finds ready work from the ledger without the broker. Each
19
+ * call reads at most one batch after a durable cursor and wraps to the start
20
+ * when the scan reaches the end, so every ready job is reached within a
21
+ * bounded number of calls. A job this worker may not run is backed off
22
+ * exponentially and skipped until its retry time; it is never deleted.
23
+ */
24
+ import { createHash } from "node:crypto";
25
+ import { DeliveryStoreError } from "./migrations.js";
26
+ import { notificationTopic } from "./mqtt.js";
27
+ import { DEFAULT_BACKOFF, backoffDelay, checkBatch, openTransportDb, parseNotification, } from "./outbox.js";
28
+ /** The handle can no longer act for the store; the caller must stop or reopen. */
29
+ const OWNERSHIP_LOST = new Set(["FENCED", "STORE_CLOSED"]);
30
+ /** Verification failures: the payload is recorded and acked, never retried. */
31
+ const NOT_GENUINE = new Set(["ACCESS_DENIED", "NOTIFICATION_UNVERIFIED", "WORKER_REVOKED"]);
32
+ /** A reconcile time budget: absent, or a finite number of milliseconds above zero. */
33
+ function checkBudget(maxMs) {
34
+ if (maxMs === undefined)
35
+ return undefined;
36
+ if (typeof maxMs !== "number" || !Number.isFinite(maxMs) || maxMs <= 0) {
37
+ throw new RangeError("maxMs must be a finite number of milliseconds above zero");
38
+ }
39
+ return maxMs;
40
+ }
41
+ function codeOf(err) {
42
+ return err instanceof DeliveryStoreError ? err.code : "INTERNAL";
43
+ }
44
+ export class NotificationConsumer {
45
+ access;
46
+ identity;
47
+ db;
48
+ credentials;
49
+ clock;
50
+ backoff;
51
+ testBarrier;
52
+ results = [];
53
+ detach = null;
54
+ statements = new Map();
55
+ constructor(access, identity, db, credentials, clock, backoff, testBarrier) {
56
+ this.access = access;
57
+ this.identity = identity;
58
+ this.db = db;
59
+ this.credentials = credentials;
60
+ this.clock = clock;
61
+ this.backoff = backoff;
62
+ this.testBarrier = testBarrier;
63
+ }
64
+ static open(opts) {
65
+ const db = openTransportDb(opts.path);
66
+ db.exec(`
67
+ CREATE TABLE IF NOT EXISTS inbox (key TEXT PRIMARY KEY, outcome TEXT NOT NULL, reason TEXT, at INTEGER NOT NULL);
68
+ CREATE TABLE IF NOT EXISTS claims (attempt_id TEXT PRIMARY KEY, job_id TEXT NOT NULL, at INTEGER NOT NULL);
69
+ CREATE TABLE IF NOT EXISTS cursor (id INTEGER PRIMARY KEY CHECK (id = 1), after TEXT);
70
+ CREATE TABLE IF NOT EXISTS retry (job_id TEXT PRIMARY KEY, failures INTEGER NOT NULL, next_at INTEGER NOT NULL);
71
+ `);
72
+ return new NotificationConsumer(opts.access, opts.identity, db, [...(opts.credentials ?? [])], opts.clock ?? Date.now, opts.backoff ?? DEFAULT_BACKOFF, opts.testBarrier);
73
+ }
74
+ /**
75
+ * Handle one notification payload. Never throws: every outcome is returned.
76
+ * Only "deferred" leaves nothing recorded.
77
+ */
78
+ handle(payload) {
79
+ const result = this.handleOnce(payload);
80
+ this.results.push(result);
81
+ return result;
82
+ }
83
+ handleOnce(payload) {
84
+ const hashKey = `payload:${createHash("sha256").update(String(payload)).digest("hex")}`;
85
+ if (this.recorded(hashKey))
86
+ return { eventId: null, outcome: "duplicate", reason: null, claims: [] };
87
+ const event = parseNotification(payload);
88
+ if (!event) {
89
+ this.record(hashKey, "rejected", "NOTIFICATION_MALFORMED");
90
+ return { eventId: null, outcome: "rejected", reason: "NOTIFICATION_MALFORMED", claims: [] };
91
+ }
92
+ const eventKey = `event:${event.eventId}`;
93
+ if (this.recorded(eventKey))
94
+ return { eventId: event.eventId, outcome: "duplicate", reason: null, claims: [] };
95
+ let candidates;
96
+ try {
97
+ candidates = this.access.verifyNotification(this.identity, event);
98
+ }
99
+ catch (err) {
100
+ const code = codeOf(err);
101
+ if (NOT_GENUINE.has(code)) {
102
+ this.record(hashKey, "rejected", code);
103
+ return { eventId: event.eventId, outcome: "rejected", reason: code, claims: [] };
104
+ }
105
+ return { eventId: event.eventId, outcome: "deferred", reason: code, claims: [] };
106
+ }
107
+ const claims = [];
108
+ for (const jobId of candidates) {
109
+ try {
110
+ if (this.tryClaim(jobId))
111
+ claims.push(jobId);
112
+ }
113
+ catch (err) {
114
+ return { eventId: event.eventId, outcome: "deferred", reason: codeOf(err), claims };
115
+ }
116
+ }
117
+ const outcome = claims.length > 0 ? "claimed" : "ignored";
118
+ this.record(eventKey, outcome, null);
119
+ return { eventId: event.eventId, outcome, reason: null, claims };
120
+ }
121
+ /**
122
+ * Claim one job through the access layer. False when the ledger says it is
123
+ * not claimable now or this worker may not run it (left for reconciliation
124
+ * and its backoff). Throws on anything that means the handle cannot act.
125
+ */
126
+ tryClaim(jobId) {
127
+ try {
128
+ const d = this.access.dispatch(this.identity, jobId, { credentials: this.credentials });
129
+ this.testBarrier?.("claimed", jobId, d.claim.attempt.attemptId);
130
+ this.saveClaim(d.claim.attempt.attemptId, jobId);
131
+ return true;
132
+ }
133
+ catch (err) {
134
+ const code = codeOf(err);
135
+ if (code === "NOT_CLAIMABLE" || code === "PRIVILEGE_REJECTED" || code === "CREDENTIAL_UNAVAILABLE")
136
+ return false;
137
+ throw err;
138
+ }
139
+ }
140
+ /**
141
+ * Claim up to `batchSize` ready jobs of this worker's company from the
142
+ * ledger, continuing after the saved cursor and wrapping to the start.
143
+ * With `maxMs`, the clock is read after each scanned job; once that much
144
+ * time has passed the call stops, saving that job as the cursor. FENCED and STORE_CLOSED are thrown; nothing is
145
+ * claimed then.
146
+ */
147
+ reconcile(opts) {
148
+ const batchSize = checkBatch(opts?.batchSize);
149
+ const maxMs = checkBudget(opts?.maxMs);
150
+ const after = this.cursor();
151
+ const first = this.access.readyWork(this.identity, { after, limit: batchSize });
152
+ const scan = [...first.jobs];
153
+ let cursor = first.cursor;
154
+ if (after !== null && first.cursor === null && scan.length < batchSize) {
155
+ const wrapped = this.access.readyWork(this.identity, { after: null, limit: batchSize });
156
+ for (const id of wrapped.jobs) {
157
+ if (scan.length === batchSize)
158
+ break;
159
+ if (!scan.includes(id))
160
+ scan.push(id);
161
+ }
162
+ cursor = scan.length === batchSize ? scan[scan.length - 1] : null;
163
+ }
164
+ const report = { claimed: [], deferred: [], skipped: [], cursor };
165
+ const now = this.clock();
166
+ for (const jobId of scan) {
167
+ this.reconcileOne(jobId, now, report);
168
+ if (maxMs !== undefined && this.clock() - now >= maxMs) {
169
+ // Budget spent: stop after this job and resume after it next call.
170
+ report.cursor = jobId;
171
+ break;
172
+ }
173
+ }
174
+ this.stmt("INSERT INTO cursor (id, after) VALUES (1, ?) ON CONFLICT(id) DO UPDATE SET after = excluded.after").run(report.cursor);
175
+ return report;
176
+ }
177
+ /** Scan one ready job: skip it while its retry delay runs, else claim it or defer it. */
178
+ reconcileOne(jobId, now, report) {
179
+ const retry = this.stmt("SELECT failures, next_at FROM retry WHERE job_id = ?").get(jobId);
180
+ if (retry && retry.next_at > now) {
181
+ report.skipped.push(jobId);
182
+ return;
183
+ }
184
+ try {
185
+ const d = this.access.dispatch(this.identity, jobId, { credentials: this.credentials });
186
+ this.saveClaim(d.claim.attempt.attemptId, jobId);
187
+ }
188
+ catch (err) {
189
+ const code = codeOf(err);
190
+ if (OWNERSHIP_LOST.has(code))
191
+ throw err;
192
+ if (code === "NOT_CLAIMABLE")
193
+ return;
194
+ const failures = (retry?.failures ?? 0) + 1;
195
+ this
196
+ .stmt("INSERT INTO retry (job_id, failures, next_at) VALUES (?, ?, ?) ON CONFLICT(job_id) DO UPDATE SET failures = excluded.failures, next_at = excluded.next_at")
197
+ .run(jobId, failures, now + backoffDelay(this.backoff, failures));
198
+ report.deferred.push(jobId);
199
+ return;
200
+ }
201
+ this.stmt("DELETE FROM retry WHERE job_id = ?").run(jobId);
202
+ report.claimed.push(jobId);
203
+ }
204
+ /**
205
+ * Subscribe to this worker's company topic. A deferred result throws so the
206
+ * broker keeps the message; every other outcome acks it.
207
+ */
208
+ attach(broker) {
209
+ this.detach?.();
210
+ const topic = notificationTopic(this.access.workerTenant(this.identity));
211
+ this.detach = broker.subscribe(topic, (message) => {
212
+ const result = this.handle(message.payload);
213
+ if (result.outcome === "deferred")
214
+ throw new Error("notification deferred");
215
+ });
216
+ }
217
+ /** Attempts this consumer claimed, in claim order. */
218
+ claims() {
219
+ return this.db.prepare("SELECT attempt_id, job_id, at FROM claims ORDER BY rowid").all().map((r) => ({ attemptId: r.attempt_id, jobId: r.job_id, at: r.at }));
220
+ }
221
+ /** True when a verified event with this id has been handled. */
222
+ seen(eventId) {
223
+ return this.recorded(`event:${eventId}`);
224
+ }
225
+ records() {
226
+ return this.db.prepare("SELECT key, outcome, reason, at FROM inbox ORDER BY rowid").all();
227
+ }
228
+ /** Results of handle() since the last call, oldest first. */
229
+ lastResults() {
230
+ return this.results.splice(0);
231
+ }
232
+ close() {
233
+ this.detach?.();
234
+ this.detach = null;
235
+ this.db.close();
236
+ }
237
+ cursor() {
238
+ const row = this.db.prepare("SELECT after FROM cursor WHERE id = 1").get();
239
+ return row?.after ?? null;
240
+ }
241
+ recorded(key) {
242
+ return this.db.prepare("SELECT 1 FROM inbox WHERE key = ?").get(key) !== undefined;
243
+ }
244
+ record(key, outcome, reason) {
245
+ this.db.prepare("INSERT OR IGNORE INTO inbox (key, outcome, reason, at) VALUES (?, ?, ?, ?)").run(key, outcome, reason, this.clock());
246
+ }
247
+ /** A prepared statement, prepared once per consumer. */
248
+ stmt(sql) {
249
+ let st = this.statements.get(sql);
250
+ if (!st) {
251
+ st = this.db.prepare(sql);
252
+ this.statements.set(sql, st);
253
+ }
254
+ return st;
255
+ }
256
+ saveClaim(attemptId, jobId) {
257
+ this.stmt("INSERT OR IGNORE INTO claims (attempt_id, job_id, at) VALUES (?, ?, ?)").run(attemptId, jobId, this.clock());
258
+ }
259
+ }
260
+ //# sourceMappingURL=inbox.js.map
@@ -0,0 +1,139 @@
1
+ import { type Attempt, type Job, type Run } from "./contracts.js";
2
+ import { type StoredArtifact, type StoredCacheEntry } from "./provenance.js";
3
+ export declare const STORE_SCHEMA_V1 = "hq-delivery.store.v1";
4
+ export declare const STORE_SCHEMA_V2 = "hq-delivery.store.v2";
5
+ /** v3 (US-004) adds the worker list. */
6
+ export declare const STORE_SCHEMA_V3 = "hq-delivery.store.v3";
7
+ /** v4 binds each attempt to the worker that claimed it (claimedBy). */
8
+ export declare const STORE_SCHEMA_V4 = "hq-delivery.store.v4";
9
+ /** v5 (US-008) adds artifact provenance records and cache entries. */
10
+ export declare const STORE_SCHEMA_V5 = "hq-delivery.store.v5";
11
+ /** The store schema version this code writes. */
12
+ export declare const STORE_SCHEMA_VERSION = "hq-delivery.store.v5";
13
+ /** Every version this code can open, oldest first. Older ones migrate forward on open. */
14
+ export declare const KNOWN_STORE_SCHEMA_VERSIONS: readonly string[];
15
+ export type DeliveryStoreErrorCode = "STORE_CORRUPT" | "STORE_SCHEMA_NEWER" | "STORE_SCHEMA_UNKNOWN" | "STORE_INVALID_RECORD" | "CONTROLLER_OWNED" | "CONTROLLER_AMBIGUOUS" | "FENCED" | "STORE_CLOSED" | "STORE_IO" | "INVALID_RECORD" | "DUPLICATE_CONFLICT" | "UNKNOWN_RUN" | "UNKNOWN_JOB" | "UNKNOWN_DEPENDENCY" | "DEPENDENCY_CYCLE" | "NOT_CLAIMABLE" | "UNKNOWN_ATTEMPT" | "ATTEMPT_CONFLICT" | "ATTEMPT_ABANDONED" | "ACCESS_DENIED" | "WORKER_REVOKED" | "PRIVILEGE_REJECTED" | "CREDENTIAL_UNAVAILABLE" | "NOTIFICATION_UNVERIFIED" | "ARTIFACT_UNKNOWN" | "ARTIFACT_TAMPERED" | "ARTIFACT_NOT_PROMOTABLE" | "SIGNING_KEY_UNCONFIGURED" | "BACKUP_INVALID" | "RESTORE_PENDING" | "STORE_RETIRED";
16
+ export interface ErrorDetail {
17
+ /** What the store saw. */
18
+ found: string;
19
+ /** What it needed instead. */
20
+ expected: string;
21
+ /** What the operator or caller should do next. */
22
+ action: string;
23
+ }
24
+ /** Every refusal from the delivery store. The message reads "CODE: found ...; expected .... action". */
25
+ export declare class DeliveryStoreError extends Error {
26
+ readonly code: DeliveryStoreErrorCode;
27
+ readonly found: string;
28
+ readonly expected: string;
29
+ readonly action: string;
30
+ constructor(code: DeliveryStoreErrorCode, detail: ErrorDetail);
31
+ }
32
+ export type AttemptResolution = "open" | "reported" | "abandoned";
33
+ export type TakeoverReason = "stale-pid" | "operator-override";
34
+ /** One entry per controller that has owned the store, in epoch order. */
35
+ export interface ControllerEntry {
36
+ epoch: number;
37
+ controllerId: string;
38
+ host: string;
39
+ pid: number;
40
+ acquiredAt: string;
41
+ /** Set when this controller replaced an earlier lock holder. previousOwner is the old lock text. */
42
+ takeover: {
43
+ reason: TakeoverReason;
44
+ previousOwner: string;
45
+ note: string | null;
46
+ } | null;
47
+ }
48
+ export interface StoredRun {
49
+ record: Run;
50
+ /** null for runs migrated from v1, which did not record accept times. */
51
+ acceptedAt: string | null;
52
+ acceptedEpoch: number;
53
+ }
54
+ export interface StoredJob {
55
+ record: Job;
56
+ /** jobIds in the same run that must pass before this job is claimable. */
57
+ dependsOn: string[];
58
+ acceptedAt: string | null;
59
+ acceptedEpoch: number;
60
+ }
61
+ export interface StoredAttempt {
62
+ record: Attempt;
63
+ claimedAt: string | null;
64
+ claimedEpoch: number;
65
+ /**
66
+ * workerId of the enrolled worker that claimed the attempt. Only that worker
67
+ * may report or return it. null for a claim made without a worker (direct
68
+ * controller use) and for attempts migrated from v3 or older.
69
+ */
70
+ claimedBy: string | null;
71
+ /**
72
+ * open: outcome pending, owned by the controller of claimedEpoch.
73
+ * reported: outcome passed or failed, reported by a controller.
74
+ * abandoned: was open when its controller stopped; outcome is "failed".
75
+ */
76
+ resolution: AttemptResolution;
77
+ resolvedAt: string | null;
78
+ resolvedEpoch: number | null;
79
+ }
80
+ /** What an enrolled worker may do. Checked on every operation. */
81
+ export type WorkerCapability = "claim" | "read" | "report";
82
+ /** standard workers run untrusted build and test jobs; only release workers run release jobs. */
83
+ export type WorkerTrust = "standard" | "release";
84
+ export type WorkerStatus = "pending" | "active" | "revoked";
85
+ export declare const WORKER_CAPABILITIES: readonly WorkerCapability[];
86
+ export declare const WORKER_TRUSTS: readonly WorkerTrust[];
87
+ /** One worker of one tenant (US-004). Only a SHA-256 digest of its secret is stored. */
88
+ export interface StoredWorker {
89
+ workerId: string;
90
+ tenantId: string;
91
+ capabilities: WorkerCapability[];
92
+ trust: WorkerTrust;
93
+ /** pending: enrollment ticket issued, not redeemed. active: enrolled. revoked: final. */
94
+ status: WorkerStatus;
95
+ /** Digest of the enrollment ticket while pending, of the worker token once enrolled. */
96
+ secretSha256: string;
97
+ issuedAt: string;
98
+ issuedEpoch: number;
99
+ enrolledAt: string | null;
100
+ enrolledEpoch: number | null;
101
+ revokedAt: string | null;
102
+ revokedEpoch: number | null;
103
+ }
104
+ export interface StoreState {
105
+ /** Fencing epoch of the current owner. Bumped on every acquisition. */
106
+ epoch: number;
107
+ controllers: ControllerEntry[];
108
+ runs: StoredRun[];
109
+ jobs: StoredJob[];
110
+ attempts: StoredAttempt[];
111
+ workers: StoredWorker[];
112
+ /** US-008: one provenance record per stored artifact. */
113
+ artifacts: StoredArtifact[];
114
+ /** US-008: cache entries, partitioned by tenant and trust. */
115
+ cache: StoredCacheEntry[];
116
+ }
117
+ export declare function emptyState(): StoreState;
118
+ export declare function stateChecksum(state: StoreState): string;
119
+ /** The exact bytes of a current-version store file for `state`. */
120
+ export declare function serializeState(state: StoreState): string;
121
+ export interface ParsedStore {
122
+ state: StoreState;
123
+ /** The version the file was migrated from, or null when it was already current. */
124
+ fromVersion: string | null;
125
+ }
126
+ /**
127
+ * Parse and validate a store file. A known older version is migrated forward
128
+ * in memory. Throws DeliveryStoreError for anything that cannot be opened
129
+ * exactly as written.
130
+ */
131
+ export declare function parseStoreText(text: string, source: string): ParsedStore;
132
+ /**
133
+ * Return one dependency cycle as a path (a -> b -> a, where a depends on b),
134
+ * or null. Edges to nodes not in the graph are ignored.
135
+ */
136
+ export declare function findCycle(graph: ReadonlyMap<string, readonly string[]>): string[] | null;
137
+ /** All problems with a store state, or [] when it is valid. Never throws. */
138
+ export declare function validateState(input: unknown): string[];
139
+ //# sourceMappingURL=migrations.d.ts.map