@indigoai-us/hq-cli 5.345.215-beta.0 → 5.345.215
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.
- package/CHANGELOG.md +65 -1
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/dist/command-catalog.generated.d.ts +46 -6
- package/dist/command-catalog.generated.js +53 -6
- package/dist/commands/bot.js +64 -6
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/core-delegate-w1b.js +15 -1
- package/dist/commands/core-policy.js +67 -8
- package/dist/commands/daemon.js +5 -0
- package/dist/commands/files-browse.d.ts +11 -4
- package/dist/commands/files-browse.js +21 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.js +25 -11
- package/dist/commands/integrations-auth-rules.d.ts +27 -0
- package/dist/commands/integrations-auth-rules.js +79 -0
- package/dist/commands/integrations-import.js +124 -12
- package/dist/commands/lanes.js +2 -2
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sync-held.js +5 -2
- package/dist/lazy-commands.js +3 -5
- package/dist/lib/bot/fleet-cron.d.ts +8 -0
- package/dist/lib/bot/fleet-cron.js +35 -3
- package/dist/lib/bot/fleet-daemon.d.ts +46 -0
- package/dist/lib/bot/fleet-daemon.js +99 -1
- package/dist/lib/bot/probe.js +7 -1
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
- package/dist/lib/bot/runtime/grok-acp.js +6 -3
- package/dist/lib/bot/runtime/index.js +19 -9
- package/dist/lib/bot/runtime/messages-stream.js +2 -2
- package/dist/lib/bot/runtime/types.d.ts +15 -0
- package/dist/lib/bot/runtime/types.js +9 -0
- package/dist/lib/bot/runtime-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/resolver.d.ts +2 -0
- package/dist/lib/daemon/resolver.js +3 -0
- package/dist/lib/daemon/run.d.ts +9 -0
- package/dist/lib/daemon/run.js +54 -1
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +10 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
- package/dist/lib/daemon/tcc-eperm.js +310 -0
- package/dist/lib/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +7 -1
- package/dist/lib/delivery/artifacts.js +29 -10
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +21 -17
- package/dist/lib/delivery/enrollment.js +83 -5
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +120 -4
- package/dist/lib/delivery/migrations.js +215 -15
- package/dist/lib/delivery/mqtt.d.ts +2 -0
- package/dist/lib/delivery/mqtt.js +7 -0
- package/dist/lib/delivery/reconciler.d.ts +65 -1
- package/dist/lib/delivery/reconciler.js +224 -13
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +2 -0
- package/dist/lib/delivery/store.js +4 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos.d.ts +16 -1
- package/dist/lib/delivery/workers/macos.js +54 -12
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +32 -22
- package/dist/lib/delivery/workers/windows.js +50 -64
- package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
- package/dist/lib/hot-channels/adapters/meetings.js +36 -3
- package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
- package/dist/lib/hot-channels/signals-pass.js +71 -2
- package/dist/lib/hot-channels/signals-redo.js +10 -2
- package/dist/lib/lanes/watcher.js +35 -0
- package/dist/lib/signals/steps/extract.js +40 -4
- package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
- package/dist/utils/catalog-runtime-paths.d.ts +34 -0
- package/dist/utils/catalog-runtime-paths.js +53 -0
- package/dist/utils/files-browse-acl.js +1 -1
- package/package.json +7 -7
- package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
- package/dist/lib/delivery/workers/windows-boundary.js +0 -693
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fenced deployment effects (US-009).
|
|
3
|
+
*
|
|
4
|
+
* Flow: request() admits (admission.ts) and, in one fenced store commit,
|
|
5
|
+
* either records a blocked decision or records an in-flight deployment with
|
|
6
|
+
* the next fence for its tenant/environment. perform() sends the effect to
|
|
7
|
+
* the target with that fence. publish() records the outcome, but only for a
|
|
8
|
+
* current publisher. deploy() is the three in order.
|
|
9
|
+
*
|
|
10
|
+
* Guarantees, and their limits:
|
|
11
|
+
* - One effect in flight per tenant/environment. A second request while one
|
|
12
|
+
* is in flight is refused ENV_BUSY; while one is unknown it is refused
|
|
13
|
+
* DEPLOY_OUTCOME_UNKNOWN until reconcile() resolves it. A deployment is in
|
|
14
|
+
* flight only while its worker holds the deploy attempt in the epoch that
|
|
15
|
+
* issued the fence; after a lost lease it counts as unknown even if the
|
|
16
|
+
* worker never tries to publish.
|
|
17
|
+
* - The in-flight guard has a max hold (maxHoldMs, measured from requestedAt
|
|
18
|
+
* on the store clock). A worker that dies or hangs without returning its
|
|
19
|
+
* attempt holds the environment no longer than that: past the hold the
|
|
20
|
+
* deployment is lease-lost. That only makes it unknown. It issues no fence
|
|
21
|
+
* and frees nothing; reconcile() must still seal the fence at the target
|
|
22
|
+
* before a retry, and the old worker's publication is refused.
|
|
23
|
+
* - The deploy attempt's claim lease (US-011 slice 4) works the same way: once
|
|
24
|
+
* it expires on the store clock the attempt is abandoned, the deployment is
|
|
25
|
+
* lease-lost (unknown) and goes to reconcile(). request(), publish() and
|
|
26
|
+
* reconcile() first sweep expired leases, and the in-commit checks treat a
|
|
27
|
+
* lease that has run out as lost even before a sweep.
|
|
28
|
+
* - Stale publication is refused (STALE_PUBLICATION): the publisher must be
|
|
29
|
+
* the worker that requested it, its deploy attempt must still be open and
|
|
30
|
+
* claimed by it in the controller epoch that issued the fence, and the
|
|
31
|
+
* ticket must match the record. A refused publication leaves the
|
|
32
|
+
* deployment unknown, never applied on the stale worker's word.
|
|
33
|
+
* - The target refuses fences at or below the highest it has seen for the
|
|
34
|
+
* environment, so a stale worker's late effect cannot overwrite a newer one.
|
|
35
|
+
* - A lost answer (timeout, dropped connection, crash of either side) leaves
|
|
36
|
+
* the outcome unknown. reconcile() queries the target, which first raises
|
|
37
|
+
* its fence floor to the deployment's fence so an effect still in transit
|
|
38
|
+
* cannot land afterwards, and records applied or not-applied. Only then can
|
|
39
|
+
* a retry run, with a new fence.
|
|
40
|
+
* - Not exactly-once. An effect is applied at most once per fence by a target
|
|
41
|
+
* that honours fences; whether it was applied is learned from the target,
|
|
42
|
+
* not assumed. A target that cannot be queried keeps the outcome unknown.
|
|
43
|
+
*
|
|
44
|
+
* The artifact bytes deployed are the ones ArtifactStore.read() verified at
|
|
45
|
+
* admission, never a path.
|
|
46
|
+
*/
|
|
47
|
+
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
48
|
+
import { admit, checkRequest, deployPolicyProblem } from "./admission.js";
|
|
49
|
+
import { authenticate } from "./identity.js";
|
|
50
|
+
import { DeliveryStoreError, WORKER_TRUSTS, } from "./migrations.js";
|
|
51
|
+
import { canonicalJson, sha256Hex } from "./provenance.js";
|
|
52
|
+
import { leaseExpired } from "./reconciler.js";
|
|
53
|
+
/** Default max hold of an in-flight deployment: 15 minutes, well above the request-perform-publish time of a live worker. */
|
|
54
|
+
export const DEFAULT_DEPLOY_MAX_HOLD_MS = 15 * 60 * 1000;
|
|
55
|
+
/** Environment variable that overrides the default max hold, in whole ms. */
|
|
56
|
+
export const DEPLOY_MAX_HOLD_ENV = "HQ_DELIVERY_DEPLOY_MAX_HOLD_MS";
|
|
57
|
+
function resolveMaxHoldMs(option, timeoutMs) {
|
|
58
|
+
const raw = process.env[DEPLOY_MAX_HOLD_ENV];
|
|
59
|
+
const fromEnv = option === undefined && raw !== undefined;
|
|
60
|
+
const value = option ?? (raw === undefined ? DEFAULT_DEPLOY_MAX_HOLD_MS : /^\d+$/.test(raw) ? Number(raw) : Number.NaN);
|
|
61
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value <= timeoutMs) {
|
|
62
|
+
throw new DeliveryStoreError("INVALID_RECORD", {
|
|
63
|
+
found: `deployment max hold ${fromEnv ? `${DEPLOY_MAX_HOLD_ENV}=${JSON.stringify(raw)}` : String(value)}`,
|
|
64
|
+
expected: `a whole number of ms above the target call timeout of ${timeoutMs} ms`,
|
|
65
|
+
action: `Set maxHoldMs or ${DEPLOY_MAX_HOLD_ENV} to such a value, or leave both unset for the default of ${DEFAULT_DEPLOY_MAX_HOLD_MS} ms. Nothing was opened.`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
export function openDeploymentManager(opts) {
|
|
71
|
+
return new DeploymentManager(opts);
|
|
72
|
+
}
|
|
73
|
+
const OPEN = ["in-flight", "unknown"];
|
|
74
|
+
function denied(found, expected) {
|
|
75
|
+
return new DeliveryStoreError("ACCESS_DENIED", { found, expected, action: "Use a scope of the company that owns the deployment. Nothing was read or written." });
|
|
76
|
+
}
|
|
77
|
+
function checkScope(scope) {
|
|
78
|
+
const s = scope;
|
|
79
|
+
const ok = typeof scope === "object" &&
|
|
80
|
+
scope !== null &&
|
|
81
|
+
Array.isArray(s.tenantIds) &&
|
|
82
|
+
s.tenantIds.length > 0 &&
|
|
83
|
+
s.tenantIds.every((t) => typeof t === "string" && t !== "") &&
|
|
84
|
+
WORKER_TRUSTS.includes(s.maxTrust);
|
|
85
|
+
if (!ok)
|
|
86
|
+
throw denied("a missing or malformed admin scope", "tenantIds as a non-empty list and a known maxTrust");
|
|
87
|
+
return s;
|
|
88
|
+
}
|
|
89
|
+
export class DeploymentManager {
|
|
90
|
+
access;
|
|
91
|
+
artifacts;
|
|
92
|
+
target;
|
|
93
|
+
timeoutMs;
|
|
94
|
+
/** Longest an in-flight deployment holds its environment, in ms from requestedAt. */
|
|
95
|
+
maxHoldMs;
|
|
96
|
+
ids;
|
|
97
|
+
signing;
|
|
98
|
+
policyAdmin;
|
|
99
|
+
constructor(opts) {
|
|
100
|
+
this.access = opts.access;
|
|
101
|
+
this.artifacts = opts.artifacts;
|
|
102
|
+
this.target = opts.target;
|
|
103
|
+
this.timeoutMs = opts.timeoutMs ?? 5000;
|
|
104
|
+
this.maxHoldMs = resolveMaxHoldMs(opts.maxHoldMs, this.timeoutMs);
|
|
105
|
+
this.ids = opts.ids ?? (() => `deploy-${randomUUID()}`);
|
|
106
|
+
this.signing = opts.signing;
|
|
107
|
+
this.policyAdmin = opts.policyAdmin;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Admit a deployment and issue its fence. Throws DEPLOY_BLOCKED after
|
|
111
|
+
* recording the decision, ENV_BUSY or DEPLOY_OUTCOME_UNKNOWN when the
|
|
112
|
+
* environment has an open deployment, INVALID_RECORD for a malformed request.
|
|
113
|
+
*/
|
|
114
|
+
request(identity, raw) {
|
|
115
|
+
const req = checkRequest(raw);
|
|
116
|
+
const controller = this.access.controller;
|
|
117
|
+
controller.assertOwner();
|
|
118
|
+
controller.expireLeases();
|
|
119
|
+
const worker = authenticate(controller.workerRecords(), identity, { capability: "claim" });
|
|
120
|
+
const attempt = controller.attempts().find((a) => a.attempt.attemptId === req.attemptId);
|
|
121
|
+
// The policy comes from the store only, keyed by the authenticated worker's company.
|
|
122
|
+
const policyRec = controller.deployPolicyRecords().find((p) => p.tenantId === worker.tenantId);
|
|
123
|
+
const adm = admit({
|
|
124
|
+
identity,
|
|
125
|
+
worker,
|
|
126
|
+
attempt,
|
|
127
|
+
controllerEpoch: controller.epoch,
|
|
128
|
+
now: "",
|
|
129
|
+
targetId: this.target.targetId,
|
|
130
|
+
artifacts: this.artifacts,
|
|
131
|
+
request: req,
|
|
132
|
+
storedPolicy: policyRec ?? null,
|
|
133
|
+
policyVerified: policyRec ? this.policyVerifies(policyRec) : false,
|
|
134
|
+
});
|
|
135
|
+
const deploymentId = this.ids();
|
|
136
|
+
let fence = 0;
|
|
137
|
+
controller.commitDeployments((draft, at) => {
|
|
138
|
+
const current = draft.deployPolicies.find((p) => p.tenantId === worker.tenantId);
|
|
139
|
+
if ((current?.signature.value ?? null) !== (policyRec?.signature.value ?? null)) {
|
|
140
|
+
throw new DeliveryStoreError("DEPLOY_OUTCOME_UNKNOWN", {
|
|
141
|
+
found: `the deploy policy of ${worker.tenantId} changed during admission`,
|
|
142
|
+
expected: "the policy admission evaluated",
|
|
143
|
+
action: "Request again. Nothing was recorded or deployed.",
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const snapshot = structuredClone(adm.snapshot);
|
|
147
|
+
snapshot.context.requestedAt = at.now;
|
|
148
|
+
const snapshotDigest = sha256Hex(canonicalJson(snapshot));
|
|
149
|
+
const base = {
|
|
150
|
+
deploymentId,
|
|
151
|
+
tenantId: worker.tenantId,
|
|
152
|
+
environment: req.environment,
|
|
153
|
+
artifactId: req.artifactId,
|
|
154
|
+
digest: req.digest,
|
|
155
|
+
workerId: worker.workerId,
|
|
156
|
+
attemptId: req.attemptId,
|
|
157
|
+
targetId: snapshot.context.targetId,
|
|
158
|
+
snapshot,
|
|
159
|
+
snapshotDigest,
|
|
160
|
+
snapshotSignature: this.sign({ kind: "deployment-snapshot", deploymentId, snapshotDigest }),
|
|
161
|
+
requestedAt: at.now,
|
|
162
|
+
requestedEpoch: at.epoch,
|
|
163
|
+
resolvedAt: null,
|
|
164
|
+
resolvedEpoch: null,
|
|
165
|
+
observation: null,
|
|
166
|
+
};
|
|
167
|
+
if (!adm.ok) {
|
|
168
|
+
draft.deployments.push({
|
|
169
|
+
...base,
|
|
170
|
+
fence: null,
|
|
171
|
+
status: "blocked",
|
|
172
|
+
decision: { code: adm.code, found: adm.found, scope: { tenantId: worker.tenantId, environment: req.environment }, escalateTo: `company-admin:${worker.tenantId}`, resolution: "pending" },
|
|
173
|
+
});
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const same = draft.deployments.filter((d) => d.tenantId === worker.tenantId && d.environment === req.environment);
|
|
177
|
+
const open = same.find((d) => OPEN.includes(d.status));
|
|
178
|
+
if (open)
|
|
179
|
+
throw open.status === "in-flight" && open.requestedEpoch === at.epoch && leaseHeld(draft.attempts.find((x) => x.record.attemptId === open.attemptId), open, at.epoch, Date.parse(at.now), this.maxHoldMs) ? busy(open) : unknownOutcome(open);
|
|
180
|
+
const a = draft.attempts.find((x) => x.record.attemptId === req.attemptId);
|
|
181
|
+
if (!a || a.resolution !== "open" || a.claimedBy !== worker.workerId || a.claimedEpoch !== at.epoch || leaseExpired(a, Date.parse(at.now))) {
|
|
182
|
+
throw stale(`deploy attempt ${req.attemptId} stopped being current during admission`);
|
|
183
|
+
}
|
|
184
|
+
fence = same.reduce((m, d) => Math.max(m, d.fence ?? 0), 0) + 1;
|
|
185
|
+
draft.deployments.push({ ...base, fence, status: "in-flight", decision: null });
|
|
186
|
+
});
|
|
187
|
+
if (!adm.ok) {
|
|
188
|
+
throw new DeliveryStoreError("DEPLOY_BLOCKED", {
|
|
189
|
+
found: `${adm.code}: ${adm.found}`,
|
|
190
|
+
expected: "an approved environment in the requester's company policy and an exact, verified, promoted release artifact",
|
|
191
|
+
action: `Recorded as deployment ${deploymentId}, escalated to company-admin:${worker.tenantId}. Nothing was deployed; there is no bypass.`,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
deploymentId,
|
|
196
|
+
tenantId: worker.tenantId,
|
|
197
|
+
environment: req.environment,
|
|
198
|
+
fence,
|
|
199
|
+
digest: req.digest,
|
|
200
|
+
attemptId: req.attemptId,
|
|
201
|
+
workerId: worker.workerId,
|
|
202
|
+
epoch: controller.epoch,
|
|
203
|
+
targetId: this.target.targetId,
|
|
204
|
+
bytes: adm.bytes,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/** Send the fenced effect to the target. Worker side: writes nothing to the store. */
|
|
208
|
+
perform(ticket) {
|
|
209
|
+
return this.target.apply({ deploymentId: ticket.deploymentId, tenantId: ticket.tenantId, environment: ticket.environment, fence: ticket.fence, digest: ticket.digest, bytes: ticket.bytes }, this.timeoutMs);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Record the outcome of a performed effect. Refuses a stale publisher
|
|
213
|
+
* (STALE_PUBLICATION) and then leaves the deployment unknown.
|
|
214
|
+
*/
|
|
215
|
+
publish(identity, ticket, outcome) {
|
|
216
|
+
const controller = this.access.controller;
|
|
217
|
+
controller.assertOwner();
|
|
218
|
+
controller.expireLeases();
|
|
219
|
+
const worker = authenticate(controller.workerRecords(), identity, { capability: "report" });
|
|
220
|
+
let refused = null;
|
|
221
|
+
controller.commitDeployments((draft, at) => {
|
|
222
|
+
const rec = this.record(draft, ticket.deploymentId);
|
|
223
|
+
if (rec.tenantId !== worker.tenantId)
|
|
224
|
+
throw denied(`deployment ${rec.deploymentId} of another company`, `a deployment of ${worker.tenantId}`);
|
|
225
|
+
const reasons = staleReasons(draft, rec, ticket, worker.workerId, at.epoch, outcome, Date.parse(at.now), this.maxHoldMs);
|
|
226
|
+
if (reasons.length > 0) {
|
|
227
|
+
refused = reasons.join("; ");
|
|
228
|
+
if (rec.status === "in-flight") {
|
|
229
|
+
rec.status = "unknown";
|
|
230
|
+
rec.observation = { source: "stale-publication", detail: `publication refused: ${refused}`, fence: null, digest: null };
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (outcome.kind === "applied") {
|
|
235
|
+
resolve(rec, "applied", at, { source: "apply-response", detail: "target answered applied", fence: outcome.fence, digest: outcome.digest });
|
|
236
|
+
}
|
|
237
|
+
else if (outcome.kind === "rejected") {
|
|
238
|
+
resolve(rec, "rejected", at, { source: "apply-rejected", detail: outcome.detail, fence: null, digest: null });
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
rec.status = "unknown";
|
|
242
|
+
rec.observation = { source: "transport-error", detail: outcome.detail, fence: null, digest: null };
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
if (refused !== null)
|
|
246
|
+
throw stale(refused);
|
|
247
|
+
return this.view(ticket.deploymentId);
|
|
248
|
+
}
|
|
249
|
+
/** request, perform and publish. Returns the recorded outcome; unknown means reconcile next. */
|
|
250
|
+
async deploy(identity, req) {
|
|
251
|
+
const ticket = this.request(identity, req);
|
|
252
|
+
const outcome = await this.perform(ticket);
|
|
253
|
+
return this.publish(identity, ticket, outcome);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Resolve an unknown deployment from the target's actual state. The target
|
|
257
|
+
* raises its fence floor to this deployment's fence before answering.
|
|
258
|
+
* Throws TARGET_UNREACHABLE (the outcome stays unknown) if it cannot ask.
|
|
259
|
+
*/
|
|
260
|
+
async reconcile(scope, deploymentId) {
|
|
261
|
+
const s = checkScope(scope);
|
|
262
|
+
const controller = this.access.controller;
|
|
263
|
+
controller.assertOwner();
|
|
264
|
+
controller.expireLeases();
|
|
265
|
+
const rec = controller.deploymentRecords().find((d) => d.deploymentId === deploymentId);
|
|
266
|
+
if (!rec)
|
|
267
|
+
throw unknownDeployment(deploymentId);
|
|
268
|
+
if (!s.tenantIds.includes(rec.tenantId))
|
|
269
|
+
throw denied(`deployment ${deploymentId} of a company outside the admin scope`, `a deployment of ${s.tenantIds.join(", ")}`);
|
|
270
|
+
// Still in flight only while the requesting worker holds its attempt in this epoch and within the
|
|
271
|
+
// max hold. Once that lease is gone the worker can no longer publish, so the outcome is unknown and
|
|
272
|
+
// is reconciled here.
|
|
273
|
+
if (rec.status === "in-flight" && rec.requestedEpoch === controller.epoch && this.held(rec))
|
|
274
|
+
throw busy(rec);
|
|
275
|
+
if (!OPEN.includes(rec.status))
|
|
276
|
+
return this.view(deploymentId);
|
|
277
|
+
if (rec.targetId !== this.target.targetId || rec.fence === null) {
|
|
278
|
+
throw new DeliveryStoreError("INVALID_RECORD", {
|
|
279
|
+
found: `deployment ${deploymentId} went to target ${String(rec.targetId)}`,
|
|
280
|
+
expected: `a deployment of target ${this.target.targetId}`,
|
|
281
|
+
action: "Reconcile with a manager for that deployment's target. Nothing was written.",
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const fence = rec.fence;
|
|
285
|
+
let observed;
|
|
286
|
+
try {
|
|
287
|
+
observed = await this.target.observe({ deploymentId, tenantId: rec.tenantId, environment: rec.environment, fence }, this.timeoutMs);
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
if (err instanceof DeliveryStoreError && err.code === "TARGET_UNREACHABLE") {
|
|
291
|
+
controller.commitDeployments((draft) => {
|
|
292
|
+
const r = this.record(draft, deploymentId);
|
|
293
|
+
if (!OPEN.includes(r.status) || r.fence !== fence)
|
|
294
|
+
return;
|
|
295
|
+
r.status = "unknown";
|
|
296
|
+
r.observation = { source: "transport-error", detail: err.found, fence: null, digest: null };
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
throw err;
|
|
300
|
+
}
|
|
301
|
+
let mismatch = null;
|
|
302
|
+
controller.commitDeployments((draft, at) => {
|
|
303
|
+
const r = this.record(draft, deploymentId);
|
|
304
|
+
if (!OPEN.includes(r.status) || r.fence !== fence)
|
|
305
|
+
return;
|
|
306
|
+
if (observed.kind === "absent") {
|
|
307
|
+
resolve(r, "not-applied", at, { source: "target-query", detail: `target has no such deployment; fence floor now ${observed.floor}`, fence: null, digest: null });
|
|
308
|
+
}
|
|
309
|
+
else if (observed.fence === fence && observed.digest === r.digest) {
|
|
310
|
+
resolve(r, "applied", at, { source: "target-query", detail: "target reports the deployment applied", fence: observed.fence, digest: observed.digest });
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
mismatch = `target reports fence ${observed.fence} digest ${observed.digest}, the record has fence ${fence} digest ${r.digest}`;
|
|
314
|
+
r.status = "unknown";
|
|
315
|
+
r.observation = { source: "target-query", detail: mismatch, fence: observed.fence, digest: observed.digest };
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
if (mismatch !== null) {
|
|
319
|
+
throw new DeliveryStoreError("DEPLOY_OUTCOME_UNKNOWN", { found: mismatch, expected: "the target's record to match the deployment", action: "Investigate the target. No retry is allowed." });
|
|
320
|
+
}
|
|
321
|
+
return this.view(deploymentId);
|
|
322
|
+
}
|
|
323
|
+
/** Deployments and decisions of the companies in scope, oldest first. */
|
|
324
|
+
deployments(scope) {
|
|
325
|
+
const s = checkScope(scope);
|
|
326
|
+
const controller = this.access.controller;
|
|
327
|
+
controller.assertOwner();
|
|
328
|
+
return controller
|
|
329
|
+
.deploymentRecords()
|
|
330
|
+
.filter((d) => s.tenantIds.includes(d.tenantId))
|
|
331
|
+
.map((d) => this.toView(d, controller.epoch));
|
|
332
|
+
}
|
|
333
|
+
record(draft, deploymentId) {
|
|
334
|
+
const rec = draft.deployments.find((d) => d.deploymentId === deploymentId);
|
|
335
|
+
if (!rec)
|
|
336
|
+
throw unknownDeployment(deploymentId);
|
|
337
|
+
return rec;
|
|
338
|
+
}
|
|
339
|
+
view(deploymentId) {
|
|
340
|
+
const controller = this.access.controller;
|
|
341
|
+
const rec = controller.deploymentRecords().find((d) => d.deploymentId === deploymentId);
|
|
342
|
+
if (!rec)
|
|
343
|
+
throw unknownDeployment(deploymentId);
|
|
344
|
+
return this.toView(rec, controller.epoch);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Set a company's deploy policy. The caller must present that company's
|
|
348
|
+
* admin credential (the value at policyAdmin.refPrefix/<tenantId> in the
|
|
349
|
+
* credential source); the scope alone is not trusted. The version must
|
|
350
|
+
* increase. The stored record is signed with the provenance signing key.
|
|
351
|
+
*/
|
|
352
|
+
setPolicy(admin, policy) {
|
|
353
|
+
const s = checkScope(admin?.scope);
|
|
354
|
+
const problem = deployPolicyProblem(policy);
|
|
355
|
+
if (problem !== null) {
|
|
356
|
+
throw new DeliveryStoreError("INVALID_RECORD", { found: problem, expected: "a deploy policy { policyId, tenantId, version, environments }", action: "Fix the policy. Nothing was written." });
|
|
357
|
+
}
|
|
358
|
+
const tenantId = policy.tenantId;
|
|
359
|
+
if (!s.tenantIds.includes(tenantId))
|
|
360
|
+
throw denied(`a policy for ${tenantId} from an admin scope that does not cover it`, `an admin of ${tenantId}`);
|
|
361
|
+
const ref = `${this.policyAdmin.refPrefix}/${tenantId}`;
|
|
362
|
+
let expected;
|
|
363
|
+
try {
|
|
364
|
+
expected = this.policyAdmin.source.resolve(ref);
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
throw denied(`no admin credential is provisioned for ${tenantId}`, `an admin credential at ${ref}`);
|
|
368
|
+
}
|
|
369
|
+
// A blank or non-string credential is an unprovisioned one: it authenticates nobody.
|
|
370
|
+
if (typeof expected !== "string" || expected.trim() === "")
|
|
371
|
+
throw denied(`no admin credential is provisioned for ${tenantId}`, `a non-empty admin credential at ${ref}`);
|
|
372
|
+
if (typeof admin.token !== "string" || admin.token.trim() === "")
|
|
373
|
+
throw denied(`no admin credential was presented for ${tenantId}`, `the admin credential at ${ref}`);
|
|
374
|
+
const want = Buffer.from(sha256Hex(expected), "hex");
|
|
375
|
+
const have = Buffer.from(sha256Hex(admin.token), "hex");
|
|
376
|
+
if (!timingSafeEqual(want, have))
|
|
377
|
+
throw denied(`an admin credential that does not authenticate for ${tenantId}`, `the admin credential at ${ref}`);
|
|
378
|
+
const controller = this.access.controller;
|
|
379
|
+
controller.assertOwner();
|
|
380
|
+
controller.commitDeployments((draft, at) => {
|
|
381
|
+
const prior = draft.deployPolicies.find((p) => p.tenantId === tenantId);
|
|
382
|
+
const priorVersion = prior ? prior.policy.version : 0;
|
|
383
|
+
if (policy.version <= priorVersion) {
|
|
384
|
+
throw new DeliveryStoreError("INVALID_RECORD", {
|
|
385
|
+
found: `policy version ${policy.version} for ${tenantId}`,
|
|
386
|
+
expected: `a version above the stored ${priorVersion}`,
|
|
387
|
+
action: "Increase the version. Nothing was written.",
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
const body = { tenantId, policy: structuredClone(policy), setBy: ref, setAt: at.now, setEpoch: at.epoch };
|
|
391
|
+
const rec = { ...body, signature: this.sign({ kind: "deploy-policy", ...body }) };
|
|
392
|
+
draft.deployPolicies = [...draft.deployPolicies.filter((p) => p.tenantId !== tenantId), rec];
|
|
393
|
+
});
|
|
394
|
+
return this.policy(s, tenantId);
|
|
395
|
+
}
|
|
396
|
+
/** The stored policy of a company in scope (the first in scope by default), or null. */
|
|
397
|
+
policy(scope, tenantId) {
|
|
398
|
+
const s = checkScope(scope);
|
|
399
|
+
const t = tenantId ?? s.tenantIds[0];
|
|
400
|
+
if (!s.tenantIds.includes(t))
|
|
401
|
+
throw denied(`a policy of ${t} outside the admin scope`, `a company in ${s.tenantIds.join(", ")}`);
|
|
402
|
+
const rec = this.access.controller.deployPolicyRecords().find((p) => p.tenantId === t);
|
|
403
|
+
return rec ? { ...rec, policy: rec.policy, verified: this.policyVerifies(rec) } : null;
|
|
404
|
+
}
|
|
405
|
+
key() {
|
|
406
|
+
try {
|
|
407
|
+
const value = this.signing.source.resolve(this.signing.ref);
|
|
408
|
+
// A blank key is an unprovisioned one: it signs nothing.
|
|
409
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
410
|
+
return value;
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// fall through
|
|
414
|
+
}
|
|
415
|
+
throw new DeliveryStoreError("SIGNING_KEY_UNCONFIGURED", {
|
|
416
|
+
found: `no signing key at ${this.signing.ref}`,
|
|
417
|
+
expected: "the provenance signing key",
|
|
418
|
+
action: "Provision the key with HQ secrets. Nothing was signed or written.",
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
sign(body) {
|
|
422
|
+
return { algorithm: "hmac-sha256", keyRef: this.signing.ref, value: createHmac("sha256", this.key()).update(canonicalJson(body)).digest("hex") };
|
|
423
|
+
}
|
|
424
|
+
verifies(body, sig) {
|
|
425
|
+
if (sig.algorithm !== "hmac-sha256" || sig.keyRef !== this.signing.ref)
|
|
426
|
+
return false;
|
|
427
|
+
const want = createHmac("sha256", this.key()).update(canonicalJson(body)).digest();
|
|
428
|
+
const have = Buffer.from(sig.value, "hex");
|
|
429
|
+
return have.length === want.length && timingSafeEqual(have, want);
|
|
430
|
+
}
|
|
431
|
+
policyVerifies(p) {
|
|
432
|
+
const { signature, ...body } = p;
|
|
433
|
+
return this.verifies({ kind: "deploy-policy", ...body }, signature);
|
|
434
|
+
}
|
|
435
|
+
toView(d, epoch) {
|
|
436
|
+
const snapshotVerified = d.snapshotDigest === sha256Hex(canonicalJson(d.snapshot)) && this.verifies({ kind: "deployment-snapshot", deploymentId: d.deploymentId, snapshotDigest: d.snapshotDigest }, d.snapshotSignature);
|
|
437
|
+
return toView(d, epoch, snapshotVerified, this.held(d));
|
|
438
|
+
}
|
|
439
|
+
/** True while the worker that requested `d` still holds its deploy attempt in the current epoch. */
|
|
440
|
+
held(d) {
|
|
441
|
+
const controller = this.access.controller;
|
|
442
|
+
const view = controller.attempts().find((x) => x.attempt.attemptId === d.attemptId);
|
|
443
|
+
// AttemptView does not carry the claim lease, so read it from the controller.
|
|
444
|
+
const a = view && { ...view, leaseExpiresAt: controller.leaseExpiresAt(d.attemptId) };
|
|
445
|
+
return leaseHeld(a, d, controller.epoch, Date.parse(controller.now()), this.maxHoldMs);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The lease of a deployment: its attempt is open and claimed by the requesting worker in `epoch`,
|
|
450
|
+
* its claim lease has not run out, and the deployment has not been in flight longer than the max hold.
|
|
451
|
+
* `leaseExpiresAt` is required so that no caller can drop the claim lease by passing a view without it.
|
|
452
|
+
*/
|
|
453
|
+
function leaseHeld(a, d, epoch, nowMs, maxHoldMs) {
|
|
454
|
+
const claimExpired = a !== undefined && a.leaseExpiresAt !== null && nowMs >= Date.parse(a.leaseExpiresAt);
|
|
455
|
+
return a !== undefined && a.resolution === "open" && a.claimedBy === d.workerId && a.claimedEpoch === epoch && !claimExpired && !holdExpired(d, nowMs, maxHoldMs);
|
|
456
|
+
}
|
|
457
|
+
/** True once `d` has been in flight for maxHoldMs since requestedAt. A time that cannot be read counts as expired. */
|
|
458
|
+
function holdExpired(d, nowMs, maxHoldMs) {
|
|
459
|
+
return !(nowMs - Date.parse(d.requestedAt) < maxHoldMs);
|
|
460
|
+
}
|
|
461
|
+
function toView(d, epoch, snapshotVerified, held) {
|
|
462
|
+
const status = d.status === "in-flight" && (d.requestedEpoch < epoch || !held) ? "unknown" : d.status;
|
|
463
|
+
return {
|
|
464
|
+
snapshotVerified,
|
|
465
|
+
deploymentId: d.deploymentId,
|
|
466
|
+
tenantId: d.tenantId,
|
|
467
|
+
environment: d.environment,
|
|
468
|
+
artifactId: d.artifactId,
|
|
469
|
+
digest: d.digest,
|
|
470
|
+
workerId: d.workerId,
|
|
471
|
+
attemptId: d.attemptId,
|
|
472
|
+
targetId: d.targetId,
|
|
473
|
+
fence: d.fence,
|
|
474
|
+
status,
|
|
475
|
+
snapshot: d.snapshot,
|
|
476
|
+
snapshotDigest: d.snapshotDigest,
|
|
477
|
+
decision: d.decision,
|
|
478
|
+
observation: d.observation,
|
|
479
|
+
requestedAt: d.requestedAt,
|
|
480
|
+
requestedEpoch: d.requestedEpoch,
|
|
481
|
+
resolvedAt: d.resolvedAt,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function resolve(rec, status, at, observation) {
|
|
485
|
+
rec.status = status;
|
|
486
|
+
rec.resolvedAt = at.now;
|
|
487
|
+
rec.resolvedEpoch = at.epoch;
|
|
488
|
+
rec.observation = observation;
|
|
489
|
+
}
|
|
490
|
+
function staleReasons(draft, rec, ticket, workerId, epoch, outcome, nowMs, maxHoldMs) {
|
|
491
|
+
const reasons = [];
|
|
492
|
+
if (rec.status !== "in-flight")
|
|
493
|
+
reasons.push(`deployment ${rec.deploymentId} is ${rec.status}, not in flight`);
|
|
494
|
+
if (rec.fence !== ticket.fence)
|
|
495
|
+
reasons.push(`ticket fence ${ticket.fence} is not the issued fence ${String(rec.fence)}`);
|
|
496
|
+
if (rec.digest !== ticket.digest || rec.attemptId !== ticket.attemptId)
|
|
497
|
+
reasons.push("ticket does not match the recorded artifact and attempt");
|
|
498
|
+
if (rec.workerId !== workerId)
|
|
499
|
+
reasons.push(`worker ${workerId} did not request this deployment`);
|
|
500
|
+
if (rec.requestedEpoch !== epoch || ticket.epoch !== epoch)
|
|
501
|
+
reasons.push(`the fence was issued at controller epoch ${rec.requestedEpoch}; the current epoch is ${epoch} (lease lost)`);
|
|
502
|
+
const a = draft.attempts.find((x) => x.record.attemptId === rec.attemptId);
|
|
503
|
+
if (!a || a.resolution !== "open" || a.claimedBy !== workerId || a.claimedEpoch !== epoch || leaseExpired(a, nowMs)) {
|
|
504
|
+
reasons.push(`deploy attempt ${rec.attemptId} is ${a ? a.resolution : "missing"}, no longer held by ${workerId} (lease lost)`);
|
|
505
|
+
}
|
|
506
|
+
if (rec.status === "in-flight" && holdExpired(rec, nowMs, maxHoldMs)) {
|
|
507
|
+
reasons.push(`deployment ${rec.deploymentId} was in flight longer than the max hold of ${maxHoldMs} ms since ${rec.requestedAt} (lease lost)`);
|
|
508
|
+
}
|
|
509
|
+
if (outcome.kind === "applied" && (outcome.fence !== ticket.fence || outcome.digest !== ticket.digest))
|
|
510
|
+
reasons.push("the reported effect is not the ticket's fence and digest");
|
|
511
|
+
return reasons;
|
|
512
|
+
}
|
|
513
|
+
function stale(found) {
|
|
514
|
+
return new DeliveryStoreError("STALE_PUBLICATION", {
|
|
515
|
+
found,
|
|
516
|
+
expected: "a publication by the requesting worker, holding its open deploy attempt, in the epoch that issued the fence",
|
|
517
|
+
action: "The deployment is left unknown. Reconcile it against the target before any retry.",
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function busy(d) {
|
|
521
|
+
return new DeliveryStoreError("ENV_BUSY", {
|
|
522
|
+
found: `deployment ${d.deploymentId} (fence ${String(d.fence)}) is in flight for ${d.tenantId}/${d.environment}`,
|
|
523
|
+
expected: "no other effect in flight for this environment",
|
|
524
|
+
action: "Wait for it to publish, then request again. If its worker is gone, it becomes unknown after the max hold and can then be reconciled. Nothing was written.",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function unknownOutcome(d) {
|
|
528
|
+
return new DeliveryStoreError("DEPLOY_OUTCOME_UNKNOWN", {
|
|
529
|
+
found: `deployment ${d.deploymentId} (fence ${String(d.fence)}) for ${d.tenantId}/${d.environment} has an unknown outcome`,
|
|
530
|
+
expected: "the previous effect reconciled against the target",
|
|
531
|
+
action: `Run reconcile for ${d.deploymentId} first. Nothing was written or deployed.`,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function unknownDeployment(deploymentId) {
|
|
535
|
+
return new DeliveryStoreError("UNKNOWN_DEPLOYMENT", {
|
|
536
|
+
found: `no deployment ${String(deploymentId)}`,
|
|
537
|
+
expected: "a deploymentId returned by request",
|
|
538
|
+
action: "Check the id. Nothing was written.",
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
//# sourceMappingURL=effects.js.map
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worker enrollment and the authenticated access layer (US-004).
|
|
3
|
-
*
|
|
4
|
-
* An admin with a company scope issues a one-time enrollment ticket for a
|
|
5
|
-
* worker of one tenant, with fixed capabilities and trust. The worker redeems
|
|
6
|
-
* the ticket for a token. Every worker operation then authenticates against
|
|
7
|
-
* the stored worker records: company scope, capability and status.
|
|
8
|
-
*
|
|
9
|
-
* Revocation is a fenced store commit. Each worker write re-authenticates
|
|
10
|
-
* inside the same commit, against the state about to be written, so a
|
|
11
|
-
* revocation that lands while an operation is in flight refuses that
|
|
12
|
-
* operation instead of racing it. Requests beyond the ticket, the admin's
|
|
13
|
-
* scope or the worker's trust are rejected, never downgraded.
|
|
14
|
-
*/
|
|
15
1
|
import type { Run } from "./contracts.js";
|
|
16
2
|
import { type CredentialPolicy, type CredentialSource, type InjectedCredentials, type JobClass } from "./credentials.js";
|
|
17
3
|
import { type WorkerIdentity } from "./identity.js";
|
|
18
4
|
import { type WorkerCapability, type WorkerStatus, type WorkerTrust } from "./migrations.js";
|
|
19
5
|
import { type LedgerEvent } from "./outbox.js";
|
|
20
|
-
import { type AttemptView, type ClaimResult, type ControllerOptions, type DeliveryController, type JobView } from "./reconciler.js";
|
|
6
|
+
import { type AttemptView, type ClaimResult, type ControllerOptions, type DeliveryController, type JobView, type LeaseView } from "./reconciler.js";
|
|
21
7
|
export type AccessOptions = ControllerOptions & {
|
|
22
8
|
credentialPolicy?: CredentialPolicy;
|
|
23
9
|
credentialSource?: CredentialSource;
|
|
@@ -79,6 +65,13 @@ export declare class DeliveryAccess {
|
|
|
79
65
|
}): WorkerIdentity;
|
|
80
66
|
/** Revoke a worker. It can no longer claim, read or report. Revoking twice is a no-op. */
|
|
81
67
|
revoke(scope: AdminScope, workerId: string): WorkerView;
|
|
68
|
+
/**
|
|
69
|
+
* US-011 slice 4: extend the lease of the worker's own open attempt. Needs
|
|
70
|
+
* "report". The claimant, the open attempt, the lease and that the worker is
|
|
71
|
+
* not revoked are checked again inside the commit. Refused with
|
|
72
|
+
* ATTEMPT_ABANDONED once the lease has expired.
|
|
73
|
+
*/
|
|
74
|
+
renewLease(identity: WorkerIdentity, attemptId: string): LeaseView;
|
|
82
75
|
/** Workers in the admin's scope, without secret digests. */
|
|
83
76
|
workers(scope: AdminScope): WorkerView[];
|
|
84
77
|
/** Read a run of the worker's own company and its jobs. Needs "read". */
|
|
@@ -86,8 +79,16 @@ export declare class DeliveryAccess {
|
|
|
86
79
|
run: Run;
|
|
87
80
|
jobs: JobView[];
|
|
88
81
|
};
|
|
89
|
-
/**
|
|
90
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Claim a ready job of the worker's own company. Needs "claim". A worker may
|
|
84
|
+
* choose the attemptId (US-011 slice 4 B): claiming again with the same id
|
|
85
|
+
* replays the stored claim instead of opening a second attempt, so a retry
|
|
86
|
+
* after a lost answer is safe. The id must be a safe name (it becomes a
|
|
87
|
+
* directory name on the worker).
|
|
88
|
+
*/
|
|
89
|
+
claim(identity: WorkerIdentity, jobId: string, opts?: {
|
|
90
|
+
attemptId?: string;
|
|
91
|
+
}): ClaimResult;
|
|
91
92
|
/** Report the outcome of an attempt of the worker's own company. Needs "report". */
|
|
92
93
|
recordOutcome(identity: WorkerIdentity, attemptId: string, outcome: "passed" | "failed"): AttemptView;
|
|
93
94
|
/** US-007: return an open attempt of the worker's own company unfinished, so its job can be claimed again. Needs "report". */
|
|
@@ -99,7 +100,10 @@ export declare class DeliveryAccess {
|
|
|
99
100
|
*/
|
|
100
101
|
dispatch(identity: WorkerIdentity, jobId: string, request: {
|
|
101
102
|
credentials: string[];
|
|
103
|
+
attemptId?: string;
|
|
102
104
|
}): Dispatch;
|
|
105
|
+
/** The trust an authenticated worker was enrolled with. Needs "claim". */
|
|
106
|
+
workerTrust(identity: WorkerIdentity): WorkerTrust;
|
|
103
107
|
/** The company of an authenticated worker. Needs "claim". */
|
|
104
108
|
workerTenant(identity: WorkerIdentity): string;
|
|
105
109
|
/**
|