@stigmer/server 3.15.3-dev.20260916211208 → 3.16.1-dev.20260917224426
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/dist/authorization/lane-admission.d.ts +50 -0
- package/dist/authorization/lane-admission.d.ts.map +1 -0
- package/dist/authorization/lane-admission.js +13 -0
- package/dist/authorization/lane-admission.js.map +1 -0
- package/dist/authorization/schedule-fire-caller.d.ts +2 -2
- package/dist/authorization/schedule-fire-caller.d.ts.map +1 -1
- package/dist/authorization/schedule-fire-caller.js +8 -8
- package/dist/authorization/schedule-fire-caller.js.map +1 -1
- package/dist/boot/compose.d.ts +12 -0
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +68 -14
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/inprocess.d.ts.map +1 -1
- package/dist/boot/inprocess.js +6 -1
- package/dist/boot/inprocess.js.map +1 -1
- package/dist/domain/executioncontext/resolve-values-for-caller.d.ts +33 -14
- package/dist/domain/executioncontext/resolve-values-for-caller.d.ts.map +1 -1
- package/dist/domain/executioncontext/resolve-values-for-caller.js +32 -8
- package/dist/domain/executioncontext/resolve-values-for-caller.js.map +1 -1
- package/dist/domain/identityaccount/actor.d.ts +33 -18
- package/dist/domain/identityaccount/actor.d.ts.map +1 -1
- package/dist/domain/identityaccount/actor.js +20 -3
- package/dist/domain/identityaccount/actor.js.map +1 -1
- package/dist/domain/identityaccount/resolve.d.ts +19 -0
- package/dist/domain/identityaccount/resolve.d.ts.map +1 -1
- package/dist/domain/identityaccount/resolve.js +12 -0
- package/dist/domain/identityaccount/resolve.js.map +1 -1
- package/dist/domain/mcpserver/connect-execution-id.d.ts +5 -0
- package/dist/domain/mcpserver/connect-execution-id.d.ts.map +1 -0
- package/dist/domain/mcpserver/connect-execution-id.js +32 -0
- package/dist/domain/mcpserver/connect-execution-id.js.map +1 -0
- package/dist/domain/mcpserver/connect.d.ts +28 -2
- package/dist/domain/mcpserver/connect.d.ts.map +1 -1
- package/dist/domain/mcpserver/connect.js +27 -7
- package/dist/domain/mcpserver/connect.js.map +1 -1
- package/dist/domain/mcpserver/engine.d.ts +9 -3
- package/dist/domain/mcpserver/engine.d.ts.map +1 -1
- package/dist/domain/mcpserver/engine.js.map +1 -1
- package/dist/domain/mcpserver/start-connect.js +1 -1
- package/dist/domain/mcpserver/start-connect.js.map +1 -1
- package/dist/domain/platform/controller.d.ts +31 -11
- package/dist/domain/platform/controller.d.ts.map +1 -1
- package/dist/domain/platform/controller.js +2 -3
- package/dist/domain/platform/controller.js.map +1 -1
- package/dist/domain/plugin/materialize/agent.d.ts +10 -1
- package/dist/domain/plugin/materialize/agent.d.ts.map +1 -1
- package/dist/domain/plugin/materialize/agent.js +35 -1
- package/dist/domain/plugin/materialize/agent.js.map +1 -1
- package/dist/domain/plugin/materialize/plan.d.ts.map +1 -1
- package/dist/domain/plugin/materialize/plan.js +1 -1
- package/dist/domain/plugin/materialize/plan.js.map +1 -1
- package/dist/domain/plugin/overlay/sanitize.d.ts.map +1 -1
- package/dist/domain/plugin/overlay/sanitize.js +4 -2
- package/dist/domain/plugin/overlay/sanitize.js.map +1 -1
- package/dist/domain/project/reconcile.d.ts.map +1 -1
- package/dist/domain/project/reconcile.js +14 -10
- package/dist/domain/project/reconcile.js.map +1 -1
- package/dist/domain/workflowexecution/phases.d.ts +21 -0
- package/dist/domain/workflowexecution/phases.d.ts.map +1 -0
- package/dist/domain/workflowexecution/phases.js +31 -0
- package/dist/domain/workflowexecution/phases.js.map +1 -0
- package/dist/identity/oidc-verifier.js +8 -1
- package/dist/identity/oidc-verifier.js.map +1 -1
- package/dist/pipeline/apiresource-meta.d.ts +15 -0
- package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
- package/dist/pipeline/apiresource-meta.js +34 -0
- package/dist/pipeline/apiresource-meta.js.map +1 -1
- package/dist/pipeline/steps/guard-memory-capture.d.ts.map +1 -1
- package/dist/pipeline/steps/guard-memory-capture.js +5 -3
- package/dist/pipeline/steps/guard-memory-capture.js.map +1 -1
- package/dist/runnerauth/bound-execution.d.ts +27 -0
- package/dist/runnerauth/bound-execution.d.ts.map +1 -0
- package/dist/runnerauth/bound-execution.js +137 -0
- package/dist/runnerauth/bound-execution.js.map +1 -0
- package/dist/runnerauth/built-in-runner-credential-provider.d.ts +28 -0
- package/dist/runnerauth/built-in-runner-credential-provider.d.ts.map +1 -0
- package/dist/runnerauth/built-in-runner-credential-provider.js +217 -0
- package/dist/runnerauth/built-in-runner-credential-provider.js.map +1 -0
- package/dist/runnerauth/constants.d.ts +63 -0
- package/dist/runnerauth/constants.d.ts.map +1 -0
- package/dist/runnerauth/constants.js +63 -0
- package/dist/runnerauth/constants.js.map +1 -0
- package/dist/runnerauth/dispatch-credential.d.ts +38 -0
- package/dist/runnerauth/dispatch-credential.d.ts.map +1 -0
- package/dist/runnerauth/dispatch-credential.js +17 -0
- package/dist/runnerauth/dispatch-credential.js.map +1 -0
- package/dist/runnerauth/runner-credential-provider.d.ts +49 -11
- package/dist/runnerauth/runner-credential-provider.d.ts.map +1 -1
- package/dist/runnerauth/runner-credential-provider.js +16 -4
- package/dist/runnerauth/runner-credential-provider.js.map +1 -1
- package/dist/runnerauth/runner-subject-verifier.d.ts +14 -0
- package/dist/runnerauth/runner-subject-verifier.d.ts.map +1 -0
- package/dist/runnerauth/runner-subject-verifier.js +115 -0
- package/dist/runnerauth/runner-subject-verifier.js.map +1 -0
- package/dist/runnerauth/runnerauth.d.ts +33 -4
- package/dist/runnerauth/runnerauth.d.ts.map +1 -1
- package/dist/runnerauth/runnerauth.js +131 -35
- package/dist/runnerauth/runnerauth.js.map +1 -1
- package/dist/temporal/agentexecution/engine-client.d.ts +13 -0
- package/dist/temporal/agentexecution/engine-client.d.ts.map +1 -1
- package/dist/temporal/agentexecution/engine-client.js +10 -2
- package/dist/temporal/agentexecution/engine-client.js.map +1 -1
- package/dist/temporal/agentexecution/workflow-input.d.ts +13 -0
- package/dist/temporal/agentexecution/workflow-input.d.ts.map +1 -1
- package/dist/temporal/agentexecution/workflows/invoke-agent-execution.d.ts.map +1 -1
- package/dist/temporal/agentexecution/workflows/invoke-agent-execution.js +35 -31
- package/dist/temporal/agentexecution/workflows/invoke-agent-execution.js.map +1 -1
- package/dist/temporal/workflowexecution/engine-client.d.ts +24 -0
- package/dist/temporal/workflowexecution/engine-client.d.ts.map +1 -1
- package/dist/temporal/workflowexecution/engine-client.js +26 -19
- package/dist/temporal/workflowexecution/engine-client.js.map +1 -1
- package/dist/temporal/workflowexecution/workflow-input.d.ts +14 -0
- package/dist/temporal/workflowexecution/workflow-input.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/authorization/__tests__/lane-admission.test.ts +115 -0
- package/src/authorization/lane-admission.ts +73 -0
- package/src/authorization/schedule-fire-caller.ts +10 -14
- package/src/boot/compose.ts +93 -22
- package/src/boot/inprocess.ts +7 -1
- package/src/domain/executioncontext/__tests__/executioncontext.test.ts +104 -0
- package/src/domain/executioncontext/__tests__/resolve-values-capability.test.ts +33 -4
- package/src/domain/executioncontext/resolve-values-for-caller.ts +79 -22
- package/src/domain/identityaccount/__tests__/account-for-stamp.test.ts +111 -0
- package/src/domain/identityaccount/actor.ts +61 -21
- package/src/domain/identityaccount/resolve.ts +31 -0
- package/src/domain/mcpserver/__tests__/connect.test.ts +17 -2
- package/src/domain/mcpserver/connect-execution-id.ts +34 -0
- package/src/domain/mcpserver/connect.ts +38 -3
- package/src/domain/mcpserver/engine.ts +9 -3
- package/src/domain/mcpserver/start-connect.ts +1 -1
- package/src/domain/platform/__tests__/platform.test.ts +47 -1
- package/src/domain/platform/controller.ts +33 -14
- package/src/domain/plugin/__tests__/materialize.test.ts +60 -1
- package/src/domain/plugin/__tests__/plugin.test.ts +122 -1
- package/src/domain/plugin/__tests__/sanitize.test.ts +2 -2
- package/src/domain/plugin/materialize/agent.ts +38 -0
- package/src/domain/plugin/materialize/plan.ts +7 -1
- package/src/domain/plugin/overlay/sanitize.ts +4 -2
- package/src/domain/project/__tests__/reconcile.test.ts +51 -5
- package/src/domain/project/reconcile.ts +20 -15
- package/src/domain/workflowexecution/__tests__/phases.test.ts +58 -0
- package/src/domain/workflowexecution/phases.ts +33 -0
- package/src/extensions/__tests__/extension-composition.test.ts +7 -1
- package/src/identity/__tests__/oidc-verifier.test.ts +22 -0
- package/src/identity/oidc-verifier.ts +8 -1
- package/src/pipeline/__tests__/kind-by-id-prefix.test.ts +75 -0
- package/src/pipeline/apiresource-meta.ts +41 -0
- package/src/pipeline/steps/__tests__/guard-memory-capture.test.ts +55 -35
- package/src/pipeline/steps/guard-memory-capture.ts +5 -3
- package/src/runnerauth/__tests__/bound-execution.test.ts +334 -0
- package/src/runnerauth/__tests__/built-in-runner-credential-provider.test.ts +516 -0
- package/src/runnerauth/__tests__/dispatch-credential.test.ts +94 -0
- package/src/runnerauth/__tests__/runner-credential-provider.test.ts +27 -0
- package/src/runnerauth/__tests__/runner-subject-composed.test.ts +497 -0
- package/src/runnerauth/__tests__/runner-subject-verifier.test.ts +541 -0
- package/src/runnerauth/bound-execution.ts +270 -0
- package/src/runnerauth/built-in-runner-credential-provider.ts +300 -0
- package/src/runnerauth/constants.ts +74 -0
- package/src/runnerauth/dispatch-credential.ts +63 -0
- package/src/runnerauth/runner-credential-provider.ts +60 -11
- package/src/runnerauth/runner-subject-verifier.ts +152 -0
- package/src/runnerauth/runnerauth.ts +148 -38
- package/src/temporal/agentexecution/__tests__/engine-client.test.ts +107 -38
- package/src/temporal/agentexecution/__tests__/invoke-workflow.test.ts +105 -2
- package/src/temporal/agentexecution/engine-client.ts +27 -2
- package/src/temporal/agentexecution/workflow-input.ts +13 -0
- package/src/temporal/agentexecution/workflows/invoke-agent-execution.ts +90 -44
- package/src/temporal/workflowexecution/__tests__/engine-client.test.ts +139 -33
- package/src/temporal/workflowexecution/engine-client.ts +48 -21
- package/src/temporal/workflowexecution/workflow-input.ts +14 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The execution a runner credential is bound to — the ONE reader every
|
|
3
|
+
* consumer of the binding goes through, so the verifier (who is this
|
|
4
|
+
* runner acting as?), the memory-capture capability (which session is
|
|
5
|
+
* this run's?) and the ExecutionContext decrypt lane (may a run
|
|
6
|
+
* credential still decrypt?) cannot answer "is this run live" three ways.
|
|
7
|
+
*
|
|
8
|
+
* A credential binds exactly THREE things, and the lane's vocabulary
|
|
9
|
+
* names them (`BoundExecutionKind`):
|
|
10
|
+
*
|
|
11
|
+
* - an agent execution or a workflow execution — a RUN, whose row is
|
|
12
|
+
* the person's run and whose liveness is its phase;
|
|
13
|
+
* - an MCP connect (`mcp-connect`) — not an execution at all, but the
|
|
14
|
+
* ephemeral ExecutionContext the connect lane creates for one
|
|
15
|
+
* discovery (domain/mcpserver/connect.ts), named by the synthetic id
|
|
16
|
+
* that module and this one recognize through one predicate
|
|
17
|
+
* (domain/mcpserver/connect-execution-id.ts). The row is created AS
|
|
18
|
+
* THE PERSON who asked for the connect, so its creator stamp is who
|
|
19
|
+
* the runner acts as when it reads that connect's secrets; the lane
|
|
20
|
+
* deletes the row when the connect settles, so the row's existence IS
|
|
21
|
+
* the binding's liveness, and the token's own clock (every connect
|
|
22
|
+
* token carries `exp`) bounds a row a crash left behind.
|
|
23
|
+
*
|
|
24
|
+
* Two questions, two functions, because the callers pay differently:
|
|
25
|
+
*
|
|
26
|
+
* - `boundExecutionKindOf(id)`: which kind the binding names, read off
|
|
27
|
+
* the id alone — the contract's own `kind_meta` prefix table
|
|
28
|
+
* (pipeline/apiresource-meta.ts `kindByIdPrefix`) for the two runs,
|
|
29
|
+
* the connect predicate for the third — with no store read. A
|
|
30
|
+
* session's or an agent's id, a foreign prefix, or garbage is
|
|
31
|
+
* `undefined`, and the caller refuses with its own sentence. The
|
|
32
|
+
* lane-admission decorator asks only this, per run-gate check, so it
|
|
33
|
+
* must stay free of I/O.
|
|
34
|
+
* - `loadBoundExecution(store, id)`: the row's facts the lane needs and
|
|
35
|
+
* nothing else — the creator stamp the verifier resolves a person
|
|
36
|
+
* from, the org and session the capture capability scopes with, and
|
|
37
|
+
* LIVENESS. One read (a primary key for a run; the EC's indexed
|
|
38
|
+
* `spec.execution_id` for a connect, the read `getByExecutionId`
|
|
39
|
+
* already makes); a missing row is `undefined` (the credential is
|
|
40
|
+
* invalid — the run is not the caller's to learn about); any other
|
|
41
|
+
* store failure propagates as the fault it is (the ratified
|
|
42
|
+
* store-fault mapping), so an outage never reads as a bad credential.
|
|
43
|
+
*
|
|
44
|
+
* Liveness is the row's, not a clock's, and it is the same rule on both
|
|
45
|
+
* lanes that accept a run credential: a run is live while its phase is
|
|
46
|
+
* not terminal — a run waits on humans with no timeout, so no clock could
|
|
47
|
+
* bound it — and for RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS after the
|
|
48
|
+
* moment the row says it finished (`status.completed_at`), because two
|
|
49
|
+
* legitimate runner writes trail the terminal stamp (constants.ts). A
|
|
50
|
+
* terminal row that does not say when it finished gets no grace: fail
|
|
51
|
+
* closed. Each kind's terminal set is its own domain's predicate
|
|
52
|
+
* (agentexecution/phases.ts, workflowexecution/phases.ts), never restated
|
|
53
|
+
* here. A RECOVERED execution is live again, and so is its credential —
|
|
54
|
+
* the same principal set as the token in Temporal history (the operator
|
|
55
|
+
* who runs the engine and holds the signing key).
|
|
56
|
+
*
|
|
57
|
+
* One more rule both no-`exp` lanes share, `bindsARun(kind)`: a RUN
|
|
58
|
+
* credential — the no-`exp` token the dispatch mints (runnerauth.ts) —
|
|
59
|
+
* may bind only a run. No mint produces a clockless token for a connect,
|
|
60
|
+
* so a token shaped that way is refused by the verifier and falls closed
|
|
61
|
+
* to redaction on the decrypt lane, through this one predicate rather
|
|
62
|
+
* than two restatements of it.
|
|
63
|
+
*/
|
|
64
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
65
|
+
|
|
66
|
+
import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
|
|
67
|
+
import { ExecutionContextSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/api_pb";
|
|
68
|
+
import { WorkflowExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
|
|
69
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
70
|
+
|
|
71
|
+
import { isTerminalExecutionPhase } from "../domain/agentexecution/phases.js";
|
|
72
|
+
import { isConnectExecutionId } from "../domain/mcpserver/connect-execution-id.js";
|
|
73
|
+
import { isTerminalWorkflowExecutionPhase } from "../domain/workflowexecution/phases.js";
|
|
74
|
+
import { kindByIdPrefix } from "../pipeline/apiresource-meta.js";
|
|
75
|
+
import { auditOf } from "../pipeline/steps/defaults.js";
|
|
76
|
+
import type { Store } from "../store/interface.js";
|
|
77
|
+
import { ResourceNotFoundError } from "../store/interface.js";
|
|
78
|
+
import { RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS } from "./constants.js";
|
|
79
|
+
|
|
80
|
+
/** The three things a runner credential can bind — the lane's own vocabulary, not the enum's. */
|
|
81
|
+
export type BoundExecutionKind =
|
|
82
|
+
| "agent-execution"
|
|
83
|
+
| "workflow-execution"
|
|
84
|
+
| "mcp-connect";
|
|
85
|
+
|
|
86
|
+
/** The facts the lane reads off a bound execution's row. */
|
|
87
|
+
export interface BoundExecution {
|
|
88
|
+
readonly kind: BoundExecutionKind;
|
|
89
|
+
readonly executionId: string;
|
|
90
|
+
/** `metadata.org` — the capture capability scopes a memory to it. */
|
|
91
|
+
readonly org: string;
|
|
92
|
+
/** The creator stamp as written: an account id since 3.15.0, a raw issuer subject before. */
|
|
93
|
+
readonly createdBy: string;
|
|
94
|
+
/** The agent execution's session; empty for a workflow execution or a connect, which have none. */
|
|
95
|
+
readonly sessionId: string;
|
|
96
|
+
/** Not terminal, or terminal within the grace (see the header); a connect's row exists. */
|
|
97
|
+
readonly live: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type BoundExecutionStore = Pick<Store, "getResource" | "findByField">;
|
|
101
|
+
|
|
102
|
+
export function boundExecutionKindOf(
|
|
103
|
+
executionId: string,
|
|
104
|
+
): BoundExecutionKind | undefined {
|
|
105
|
+
switch (kindByIdPrefix(executionId)) {
|
|
106
|
+
case ApiResourceKind.agent_execution:
|
|
107
|
+
return "agent-execution";
|
|
108
|
+
case ApiResourceKind.workflow_execution:
|
|
109
|
+
return "workflow-execution";
|
|
110
|
+
default:
|
|
111
|
+
return isConnectExecutionId(executionId) ? "mcp-connect" : undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Whether a binding of this kind is a RUN — the only thing a no-`exp` credential may name (see the header). */
|
|
116
|
+
export function bindsARun(kind: BoundExecutionKind): boolean {
|
|
117
|
+
switch (kind) {
|
|
118
|
+
case "agent-execution":
|
|
119
|
+
case "workflow-execution":
|
|
120
|
+
return true;
|
|
121
|
+
case "mcp-connect":
|
|
122
|
+
return false;
|
|
123
|
+
default: {
|
|
124
|
+
const exhaustive: never = kind;
|
|
125
|
+
throw new Error(`unknown bound execution kind ${String(exhaustive)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Loads the bound execution's facts; `undefined` when the id names no
|
|
132
|
+
* binding kind or no row. `now` is injectable for the grace arms and
|
|
133
|
+
* defaults to the wall clock.
|
|
134
|
+
*/
|
|
135
|
+
export async function loadBoundExecution(
|
|
136
|
+
store: BoundExecutionStore,
|
|
137
|
+
executionId: string,
|
|
138
|
+
now: number = Date.now(),
|
|
139
|
+
): Promise<BoundExecution | undefined> {
|
|
140
|
+
const kind = boundExecutionKindOf(executionId);
|
|
141
|
+
if (kind === undefined) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
switch (kind) {
|
|
145
|
+
case "agent-execution": {
|
|
146
|
+
const row = await getRow(
|
|
147
|
+
store,
|
|
148
|
+
ApiResourceKind.agent_execution,
|
|
149
|
+
executionId,
|
|
150
|
+
AgentExecutionSchema,
|
|
151
|
+
);
|
|
152
|
+
if (row === undefined) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
kind,
|
|
157
|
+
executionId,
|
|
158
|
+
org: row.metadata?.org ?? "",
|
|
159
|
+
createdBy: creatorStampOf(AgentExecutionSchema, row),
|
|
160
|
+
sessionId: row.spec?.sessionId ?? "",
|
|
161
|
+
live: isLive(
|
|
162
|
+
row.status !== undefined &&
|
|
163
|
+
isTerminalExecutionPhase(row.status.phase),
|
|
164
|
+
row.status?.completedAt ?? "",
|
|
165
|
+
now,
|
|
166
|
+
),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
case "workflow-execution": {
|
|
170
|
+
const row = await getRow(
|
|
171
|
+
store,
|
|
172
|
+
ApiResourceKind.workflow_execution,
|
|
173
|
+
executionId,
|
|
174
|
+
WorkflowExecutionSchema,
|
|
175
|
+
);
|
|
176
|
+
if (row === undefined) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
kind,
|
|
181
|
+
executionId,
|
|
182
|
+
org: row.metadata?.org ?? "",
|
|
183
|
+
createdBy: creatorStampOf(WorkflowExecutionSchema, row),
|
|
184
|
+
sessionId: "",
|
|
185
|
+
live: isLive(
|
|
186
|
+
row.status !== undefined &&
|
|
187
|
+
isTerminalWorkflowExecutionPhase(row.status.phase),
|
|
188
|
+
row.status?.completedAt ?? "",
|
|
189
|
+
now,
|
|
190
|
+
),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "mcp-connect": {
|
|
194
|
+
// The connect's ExecutionContext, by the execution id it was
|
|
195
|
+
// created for — the same indexed read getByExecutionId makes. The
|
|
196
|
+
// row is deleted when the connect settles, so its presence is the
|
|
197
|
+
// liveness; the token's clock is enforced by `verify` before this.
|
|
198
|
+
const row = await getExecutionContextRow(store, executionId);
|
|
199
|
+
if (row === undefined) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
kind,
|
|
204
|
+
executionId,
|
|
205
|
+
org: row.metadata?.org ?? "",
|
|
206
|
+
createdBy: creatorStampOf(ExecutionContextSchema, row),
|
|
207
|
+
sessionId: "",
|
|
208
|
+
live: true,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
default: {
|
|
212
|
+
const exhaustive: never = kind;
|
|
213
|
+
throw new Error(`unknown bound execution kind ${String(exhaustive)}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** A row with no status has not started, which is live. */
|
|
219
|
+
function isLive(terminal: boolean, completedAt: string, now: number): boolean {
|
|
220
|
+
if (!terminal) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
const finishedAt = Date.parse(completedAt);
|
|
224
|
+
if (Number.isNaN(finishedAt)) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
return now - finishedAt < RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The schemas whose rows a binding can resolve to. */
|
|
231
|
+
type BoundRowSchema =
|
|
232
|
+
| typeof AgentExecutionSchema
|
|
233
|
+
| typeof WorkflowExecutionSchema
|
|
234
|
+
| typeof ExecutionContextSchema;
|
|
235
|
+
|
|
236
|
+
function creatorStampOf(schema: BoundRowSchema, row: Message): string {
|
|
237
|
+
return auditOf(schema, row)?.specAudit?.createdBy?.id ?? "";
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async function getRow<
|
|
241
|
+
Desc extends typeof AgentExecutionSchema | typeof WorkflowExecutionSchema,
|
|
242
|
+
>(store: BoundExecutionStore, kind: ApiResourceKind, id: string, schema: Desc) {
|
|
243
|
+
try {
|
|
244
|
+
return await store.getResource(kind, id, schema);
|
|
245
|
+
} catch (error) {
|
|
246
|
+
if (error instanceof ResourceNotFoundError) {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
async function getExecutionContextRow(
|
|
254
|
+
store: BoundExecutionStore,
|
|
255
|
+
executionId: string,
|
|
256
|
+
) {
|
|
257
|
+
try {
|
|
258
|
+
return await store.findByField(
|
|
259
|
+
ApiResourceKind.execution_context,
|
|
260
|
+
"spec.executionId",
|
|
261
|
+
executionId,
|
|
262
|
+
ExecutionContextSchema,
|
|
263
|
+
);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (error instanceof ResourceNotFoundError) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in RunnerCredentialProvider — the open-source execution-scoped
|
|
3
|
+
* default (runner-credential-provider.ts) plus the three capabilities an
|
|
4
|
+
* ENFORCING self-host needs, composed under the built-in authorization
|
|
5
|
+
* posture beside the runner-subject verifier (boot/compose.ts). The
|
|
6
|
+
* cloud's shape, kept on purpose: one provider object carries the
|
|
7
|
+
* edition's whole credential story, so the composition root binds one
|
|
8
|
+
* thing and every OSS touchpoint that consults the seam sees the same
|
|
9
|
+
* policy. Mint, verify, isEnabled and the dispatch's `mintRunCredential`
|
|
10
|
+
* are the default provider's, byte for byte; under trusted-local the
|
|
11
|
+
* default alone is composed and none of what follows exists.
|
|
12
|
+
*
|
|
13
|
+
* ONE reading of "what is this runner bound to" — `runnerBindingOf` —
|
|
14
|
+
* feeds everything here and the Authorizer's lane admission
|
|
15
|
+
* (authorization/lane-admission.ts). It re-verifies the caller's own
|
|
16
|
+
* `rawToken` (the cloud's `verifiedClaims(caller.rawToken)` pattern: one
|
|
17
|
+
* HMAC, no store read) and reads the kind off the bound id's prefix
|
|
18
|
+
* through the contract's table (bound-execution.ts). It checks the
|
|
19
|
+
* caller CLASS first: the lane admission runs on every run-gate check
|
|
20
|
+
* for every caller, and only the runner-subject verifier mints `runner`,
|
|
21
|
+
* so a person costs nothing here. It never throws: a person, a runner
|
|
22
|
+
* holding no token, a token this server did not sign, or a binding that
|
|
23
|
+
* names no kind is simply "not a runner binding", and each caller
|
|
24
|
+
* answers its own default for that. A CONNECT binding (`mcp-connect`, a
|
|
25
|
+
* runner reading one discovery's secrets as the person who asked) IS a
|
|
26
|
+
* runner binding, and every capability below answers it by name: it is
|
|
27
|
+
* admitted on no run gate, vouches no lineage, captures no memory, and
|
|
28
|
+
* the exchange mints nothing for it.
|
|
29
|
+
*
|
|
30
|
+
* The capabilities, and where they follow or narrow the cloud:
|
|
31
|
+
*
|
|
32
|
+
* - `vouchRunnerLineageLabels`: a WORKFLOW-bound runner vouches the two
|
|
33
|
+
* lineage keys for its own workflow execution and REFUSES a stamp
|
|
34
|
+
* naming another (the cloud's byte-pinned copy, constants.ts). Without
|
|
35
|
+
* this, a self-host with sign-in on cannot run any workflow that
|
|
36
|
+
* calls an agent: the child create's GuardReservedLabels asks the
|
|
37
|
+
* Authorizer for `can_write_reserved_labels` on the platform object,
|
|
38
|
+
* which the built-in Authorizer denies for everyone. NARROWER than the
|
|
39
|
+
* cloud on purpose: the cloud vouches for every runner-class
|
|
40
|
+
* credential and binds only its workflow lane; here an agent-bound
|
|
41
|
+
* runner vouches nothing, because the workflow's `agent_call` activity
|
|
42
|
+
* is the only producer of the lineage labels and it runs under the
|
|
43
|
+
* workflow's credential (runner: activities/call-agent.ts). Nothing
|
|
44
|
+
* observable diverges; do not widen this toward the cloud without a
|
|
45
|
+
* producer that needs it.
|
|
46
|
+
* - `authorizeMemoryCapture`: an AGENT-bound runner is ADMITTED with the
|
|
47
|
+
* human the verifier resolved as the memory's subject — the row's one
|
|
48
|
+
* principal under the model; without it every memory an enforcing
|
|
49
|
+
* self-host writes belongs to nobody — and the run's session as the
|
|
50
|
+
* proved provenance. The cloud reads both off its session-scoped
|
|
51
|
+
* token; our token names only the execution, so this reads the row
|
|
52
|
+
* (one primary-key read per `remember` call) and the seam allows the
|
|
53
|
+
* promise. The cloud's org arm is kept: a capture addressed to an org
|
|
54
|
+
* that is not the run's is "a forged address, not a routing choice"
|
|
55
|
+
* (its byte-pinned copy). A workflow-bound runner is refused (the
|
|
56
|
+
* cloud refuses every non-session lane); a person, or a runner whose
|
|
57
|
+
* token does not verify, is no-opinion and the gate's own logic
|
|
58
|
+
* applies. A run that has vanished between the verifier's read and
|
|
59
|
+
* this one is refused: a memory the server cannot attribute to a run
|
|
60
|
+
* must not be written as nobody's (fail closed).
|
|
61
|
+
* - `exchangeScopedToken`: the platform exchange (getRunnerScopedToken)
|
|
62
|
+
* becomes a MINT GATE. Under trusted-local the controller's own arms
|
|
63
|
+
* mint a clocked decrypt-lane token for any caller naming an
|
|
64
|
+
* execution, and that is harmless — the token unlocks a decrypt lane
|
|
65
|
+
* and nothing more. Under this posture the same token IS an identity
|
|
66
|
+
* (the verifier admits its bearer as the run's human), so minting
|
|
67
|
+
* one for another person's run would be impersonation. The execution
|
|
68
|
+
* arms therefore mint only for the run's own person — the account
|
|
69
|
+
* the row's creator stamp resolves to, the same reading the verifier
|
|
70
|
+
* makes — and mint the RUN credential (no `exp`; `expires_in_seconds`
|
|
71
|
+
* 0, the proto default), so under the posture there is one credential
|
|
72
|
+
* shape and the exchange is the runner's true fallback for a dispatch
|
|
73
|
+
* that carried none. The ladder is the platform's own: a row that
|
|
74
|
+
* does not exist → NOT_FOUND with the load-first copy (what a `get`
|
|
75
|
+
* on that id answers), a caller who is not the run's person, or a run
|
|
76
|
+
* whose stamp names nobody → PERMISSION_DENIED with one sentence
|
|
77
|
+
* (constants.ts). The id decides which execution kind is read (the
|
|
78
|
+
* lane's rule everywhere); the request's arm only chooses the
|
|
79
|
+
* not-found copy; an id that resolves to a CONNECT binding is
|
|
80
|
+
* NOT_FOUND too, because the exchange mints run credentials and a
|
|
81
|
+
* connect is not a run. Liveness is NOT judged at mint — both lanes that
|
|
82
|
+
* accept the token judge it, by one rule (bound-execution.ts), and a
|
|
83
|
+
* third judge here would be a divergence waiting to happen. The
|
|
84
|
+
* pool-claim, renewal and unset arms answer not-minted, the
|
|
85
|
+
* controller's arms verbatim; keyless answers not-minted too.
|
|
86
|
+
*
|
|
87
|
+
* Deliberately UNDEFINED here: `bootstrapCredentials`,
|
|
88
|
+
* `mintSandboxCredential`, `authorizeExecutionContextRead`,
|
|
89
|
+
* `resolvePayloadKey`. Their open-source arms stay where they are (the
|
|
90
|
+
* sandbox lane's mint, the decrypt lane's binding-equality decision);
|
|
91
|
+
* this provider adds policy an enforcing server lacks and takes over
|
|
92
|
+
* nothing that already works.
|
|
93
|
+
*/
|
|
94
|
+
import { Code, ConnectError } from "@connectrpc/connect";
|
|
95
|
+
|
|
96
|
+
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
97
|
+
|
|
98
|
+
import { accountForStamp } from "../domain/identityaccount/resolve.js";
|
|
99
|
+
import type { AccountsByCaller } from "../domain/identityaccount/resolve.js";
|
|
100
|
+
import type { CallerIdentity } from "../extensions/identity.js";
|
|
101
|
+
import { getKindName } from "../pipeline/apiresource-meta.js";
|
|
102
|
+
import { notFoundError } from "../pipeline/errors.js";
|
|
103
|
+
import {
|
|
104
|
+
bindsARun,
|
|
105
|
+
boundExecutionKindOf,
|
|
106
|
+
loadBoundExecution,
|
|
107
|
+
} from "./bound-execution.js";
|
|
108
|
+
import type {
|
|
109
|
+
BoundExecutionKind,
|
|
110
|
+
BoundExecutionStore,
|
|
111
|
+
} from "./bound-execution.js";
|
|
112
|
+
import {
|
|
113
|
+
MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE,
|
|
114
|
+
RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE,
|
|
115
|
+
WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE,
|
|
116
|
+
} from "./constants.js";
|
|
117
|
+
import type {
|
|
118
|
+
MemoryCaptureDecision,
|
|
119
|
+
RunnerCredentialProvider,
|
|
120
|
+
RunnerScopedTokenExchange,
|
|
121
|
+
RunnerScopedTokenRequest,
|
|
122
|
+
} from "./runner-credential-provider.js";
|
|
123
|
+
import { newExecutionScopedRunnerCredentialProvider } from "./runner-credential-provider.js";
|
|
124
|
+
import type { RunnerAuthService } from "./runnerauth.js";
|
|
125
|
+
|
|
126
|
+
/** What a runner-class caller's credential is bound to. */
|
|
127
|
+
export interface RunnerBinding {
|
|
128
|
+
readonly kind: BoundExecutionKind;
|
|
129
|
+
readonly executionId: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface BuiltInRunnerCredentialProviderDeps {
|
|
133
|
+
/** The service that signed every token this provider reads. */
|
|
134
|
+
readonly service: RunnerAuthService;
|
|
135
|
+
/** Where the bound executions live — the capture and exchange capabilities' one read each. */
|
|
136
|
+
readonly store: BoundExecutionStore;
|
|
137
|
+
/** Resolves a run's creator stamp to its person — the exchange's owner check, the verifier's reading. */
|
|
138
|
+
readonly accounts: AccountsByCaller;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The one reading of a runner's binding. `undefined` for anything that
|
|
143
|
+
* is not a runner-class caller holding a token this service signed whose
|
|
144
|
+
* binding names an execution kind; never a throw.
|
|
145
|
+
*/
|
|
146
|
+
export function runnerBindingOf(
|
|
147
|
+
service: RunnerAuthService,
|
|
148
|
+
caller: CallerIdentity,
|
|
149
|
+
): RunnerBinding | undefined {
|
|
150
|
+
if (caller.callerClass !== "runner" || caller.rawToken === "") {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
let executionId: string;
|
|
154
|
+
try {
|
|
155
|
+
executionId = service.verify(caller.rawToken);
|
|
156
|
+
} catch {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
const kind = boundExecutionKindOf(executionId);
|
|
160
|
+
return kind === undefined ? undefined : { kind, executionId };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The lane-admission predicate: a runner acting for a WORKFLOW execution (the cloud's `workflow_sandbox`). */
|
|
164
|
+
export function isWorkflowBoundRunner(
|
|
165
|
+
service: RunnerAuthService,
|
|
166
|
+
caller: CallerIdentity,
|
|
167
|
+
): boolean {
|
|
168
|
+
return runnerBindingOf(service, caller)?.kind === "workflow-execution";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The kind name the not-found copy carries, by the request's arm (what a `get` on that kind would say). */
|
|
172
|
+
function requestedKindName(
|
|
173
|
+
arm: "agent-execution" | "workflow-execution",
|
|
174
|
+
): string {
|
|
175
|
+
switch (arm) {
|
|
176
|
+
case "agent-execution":
|
|
177
|
+
return getKindName(ApiResourceKind.agent_execution);
|
|
178
|
+
case "workflow-execution":
|
|
179
|
+
return getKindName(ApiResourceKind.workflow_execution);
|
|
180
|
+
default: {
|
|
181
|
+
const exhaustive: never = arm;
|
|
182
|
+
throw new Error(`unhandled exchange arm: ${JSON.stringify(exhaustive)}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function newBuiltInRunnerCredentialProvider(
|
|
188
|
+
deps: BuiltInRunnerCredentialProviderDeps,
|
|
189
|
+
): RunnerCredentialProvider {
|
|
190
|
+
const { service, store, accounts } = deps;
|
|
191
|
+
const lane = newExecutionScopedRunnerCredentialProvider(service);
|
|
192
|
+
const mintRunCredential = lane.mintRunCredential!.bind(lane);
|
|
193
|
+
return {
|
|
194
|
+
isEnabled: lane.isEnabled,
|
|
195
|
+
mint: lane.mint,
|
|
196
|
+
verify: lane.verify,
|
|
197
|
+
mintRunCredential,
|
|
198
|
+
|
|
199
|
+
async exchangeScopedToken(
|
|
200
|
+
request: RunnerScopedTokenRequest,
|
|
201
|
+
caller: CallerIdentity,
|
|
202
|
+
): Promise<RunnerScopedTokenExchange> {
|
|
203
|
+
switch (request.arm) {
|
|
204
|
+
case "agent-execution":
|
|
205
|
+
case "workflow-execution": {
|
|
206
|
+
if (request.executionId === "" || !service.isEnabled()) {
|
|
207
|
+
return { minted: false };
|
|
208
|
+
}
|
|
209
|
+
const execution = await loadBoundExecution(
|
|
210
|
+
store,
|
|
211
|
+
request.executionId,
|
|
212
|
+
);
|
|
213
|
+
// A connect binding is not a run: the exchange mints RUN
|
|
214
|
+
// credentials, and the requested kind's row does not exist.
|
|
215
|
+
if (execution === undefined || !bindsARun(execution.kind)) {
|
|
216
|
+
throw notFoundError(
|
|
217
|
+
requestedKindName(request.arm),
|
|
218
|
+
request.executionId,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
const person = await accountForStamp(accounts, execution.createdBy);
|
|
222
|
+
if (
|
|
223
|
+
person === undefined ||
|
|
224
|
+
person.metadata?.id !== caller.identityId
|
|
225
|
+
) {
|
|
226
|
+
throw new ConnectError(
|
|
227
|
+
RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE,
|
|
228
|
+
Code.PermissionDenied,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
minted: true,
|
|
233
|
+
token: mintRunCredential(execution.executionId),
|
|
234
|
+
// No `exp` on a run credential; 0 is the proto default and
|
|
235
|
+
// the runner's acquire sites read no expiry from it.
|
|
236
|
+
expiresInSeconds: 0,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
case "pool-claim":
|
|
240
|
+
case "renewal":
|
|
241
|
+
case "unset":
|
|
242
|
+
return { minted: false };
|
|
243
|
+
default: {
|
|
244
|
+
const exhaustive: never = request;
|
|
245
|
+
throw new Error(
|
|
246
|
+
`unhandled exchange arm: ${JSON.stringify(exhaustive)}`,
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
vouchRunnerLineageLabels(
|
|
253
|
+
caller: CallerIdentity,
|
|
254
|
+
stampedWorkflowExecutionId: string,
|
|
255
|
+
): boolean {
|
|
256
|
+
const binding = runnerBindingOf(service, caller);
|
|
257
|
+
if (binding?.kind !== "workflow-execution") {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
if (
|
|
261
|
+
stampedWorkflowExecutionId !== "" &&
|
|
262
|
+
stampedWorkflowExecutionId !== binding.executionId
|
|
263
|
+
) {
|
|
264
|
+
throw new ConnectError(
|
|
265
|
+
WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE,
|
|
266
|
+
Code.InvalidArgument,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
async authorizeMemoryCapture(
|
|
273
|
+
caller: CallerIdentity,
|
|
274
|
+
captureOrg: string,
|
|
275
|
+
): Promise<MemoryCaptureDecision> {
|
|
276
|
+
const binding = runnerBindingOf(service, caller);
|
|
277
|
+
if (binding === undefined) {
|
|
278
|
+
return { verdict: "no-opinion" };
|
|
279
|
+
}
|
|
280
|
+
if (binding.kind !== "agent-execution") {
|
|
281
|
+
return { verdict: "refuse" };
|
|
282
|
+
}
|
|
283
|
+
const execution = await loadBoundExecution(store, binding.executionId);
|
|
284
|
+
if (execution === undefined) {
|
|
285
|
+
return { verdict: "refuse" };
|
|
286
|
+
}
|
|
287
|
+
if (captureOrg !== "" && captureOrg !== execution.org) {
|
|
288
|
+
throw new ConnectError(
|
|
289
|
+
MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE,
|
|
290
|
+
Code.PermissionDenied,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
verdict: "admit",
|
|
295
|
+
subjectIdentityAccountId: caller.identityId,
|
|
296
|
+
provedSessionId: execution.sessionId,
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runner-subject lane's pinned names and copy — the one constants
|
|
3
|
+
* module for the runner-credential domain (the ts-server guideline:
|
|
4
|
+
* byte-pinned copy lives in one constants module per domain, never
|
|
5
|
+
* inline at the refusal site).
|
|
6
|
+
*
|
|
7
|
+
* Two refusal sentences for a PRESENTED credential, deliberately not
|
|
8
|
+
* more (the InvalidTokenError doctrine of runnerauth.ts: a finer reason
|
|
9
|
+
* invites branching on it). The runner is the only caller that ever
|
|
10
|
+
* presents a run credential, and the person reading these is its
|
|
11
|
+
* operator, in the runner's log:
|
|
12
|
+
*
|
|
13
|
+
* - the TOKEN sentence: the credential itself is not one this server
|
|
14
|
+
* will honor — forged, the wrong shape, bound to an execution or a
|
|
15
|
+
* connect this server does not have (a connect's row is gone once
|
|
16
|
+
* the connect settles), a clockless token bound to a connect (a shape
|
|
17
|
+
* no mint produces), a present `exp` in the past, or minted by a key
|
|
18
|
+
* this server does not hold. A missing row is this sentence and not
|
|
19
|
+
* NOT_FOUND on purpose: the credential is invalid, and the run is
|
|
20
|
+
* not the caller's to learn about.
|
|
21
|
+
* - the LIVENESS sentence: the credential is genuine but its run is
|
|
22
|
+
* over, or its run or connect was created by nobody this server
|
|
23
|
+
* recognizes as a person (the schedule fire caller's
|
|
24
|
+
* deterministic-refusal shape: no retry will make that run anyone's).
|
|
25
|
+
*
|
|
26
|
+
* And one for a REQUESTED credential — the platform exchange under the
|
|
27
|
+
* built-in posture (built-in-runner-credential-provider.ts), where the
|
|
28
|
+
* caller is a signed-in person asking for a run's credential and the
|
|
29
|
+
* answer is a permission, not a token verdict: only the person whose run
|
|
30
|
+
* it is may hold its credential. A run whose creator stamp names nobody
|
|
31
|
+
* gets the same sentence — no one is its person.
|
|
32
|
+
*
|
|
33
|
+
* The lineage mismatch copy is the cloud edition's, transcribed byte for
|
|
34
|
+
* byte (credentials/provider.ts in the composition; the Java
|
|
35
|
+
* RecordRunnerLineageLabelsStep before it) so the two editions refuse a
|
|
36
|
+
* mis-stamped lineage label with one sentence.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** The verifier's name in the boot log and in auth failures (the `oidc` / `apikey` precedent). */
|
|
40
|
+
export const RUNNER_VERIFIER_NAME = "runner";
|
|
41
|
+
|
|
42
|
+
/** The token arms: forged, wrong shape, unknown execution, past `exp`, keyless. */
|
|
43
|
+
export const RUNNER_CREDENTIAL_INVALID_MESSAGE =
|
|
44
|
+
"runner credential is not valid on this server";
|
|
45
|
+
|
|
46
|
+
/** The resolution arms: a terminal execution; a run stamped by nobody the server recognizes. */
|
|
47
|
+
export const RUNNER_CREDENTIAL_NOT_LIVE_MESSAGE =
|
|
48
|
+
"runner credential names a run that is over or belongs to nobody this server recognizes";
|
|
49
|
+
|
|
50
|
+
/** The exchange's refusal under the built-in posture: the caller is not the run's person (PERMISSION_DENIED). */
|
|
51
|
+
export const RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE =
|
|
52
|
+
"a run credential is minted only for the person whose run it is";
|
|
53
|
+
|
|
54
|
+
/** The cloud's byte-pinned lineage refusal (the Java step's copy). */
|
|
55
|
+
export const WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE =
|
|
56
|
+
"workflow lineage label names a workflow execution this runner credential is not bound to";
|
|
57
|
+
|
|
58
|
+
/** The cloud's byte-pinned org-mismatch refusal (MemoryPolicy.MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE). */
|
|
59
|
+
export const MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE =
|
|
60
|
+
"memory capture is scoped to the session's organization";
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* How long a run credential outlives its run, measured from the row's
|
|
64
|
+
* `status.completed_at`. A run's credential is valid while the run is
|
|
65
|
+
* not terminal — runs wait on humans with no timeout, so no clock can
|
|
66
|
+
* bound them — and for this long after, because two legitimate runner
|
|
67
|
+
* writes land after the terminal stamp: the session-subject generation
|
|
68
|
+
* the workflow fires and does not await (issue #665), and a Temporal
|
|
69
|
+
* activity retried after its completion failed to reach the engine.
|
|
70
|
+
* Ten minutes covers one model call and one retry backoff; today's
|
|
71
|
+
* exchange-lane token outlives a run by up to an hour. A terminal row
|
|
72
|
+
* with no `completed_at` gets no grace: fail closed.
|
|
73
|
+
*/
|
|
74
|
+
export const RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS = 10 * 60 * 1000;
|