@kici-dev/engine 0.1.21 → 0.1.23
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/approval/types.d.ts +1 -1
- package/dist/approval/types.js +1 -1
- package/dist/audit/access-log-policy.js +9 -0
- package/dist/audit/activity.d.ts +3 -1
- package/dist/audit/activity.js +8 -16
- package/dist/audit/retention-policy.js +12 -0
- package/dist/environment/host-match.d.ts +25 -0
- package/dist/environment/host-match.js +67 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/scope-resolver.d.ts +15 -4
- package/dist/environment/scope-resolver.js +55 -15
- package/dist/environment/scope-template.d.ts +18 -0
- package/dist/environment/scope-template.js +43 -0
- package/dist/environment/types.d.ts +7 -0
- package/dist/fanout/materialize.d.ts +55 -4
- package/dist/fanout/materialize.js +95 -49
- package/dist/index.d.ts +4 -2
- package/dist/index.js +14 -8
- package/dist/inputs/build.d.ts +9 -0
- package/dist/inputs/build.js +44 -0
- package/dist/inputs/coerce.d.ts +25 -0
- package/dist/inputs/coerce.js +51 -0
- package/dist/inputs/descriptor.d.ts +53 -0
- package/dist/inputs/descriptor.js +42 -0
- package/dist/inputs/extract.d.ts +15 -0
- package/dist/inputs/extract.js +117 -0
- package/dist/inputs/index.d.ts +5 -0
- package/dist/inputs/index.js +6 -0
- package/dist/inventory.d.ts +2 -2
- package/dist/labels/compile.d.ts +9 -0
- package/dist/labels/compile.js +10 -1
- package/dist/labels-match.d.ts +52 -0
- package/dist/labels-match.js +22 -1
- package/dist/labels.d.ts +29 -0
- package/dist/labels.js +32 -1
- package/dist/metrics/catalog-policy.d.ts +7 -0
- package/dist/metrics/catalog-policy.js +11 -12
- package/dist/metrics/metric-catalog.generated.d.ts +2 -2
- package/dist/metrics/metric-catalog.generated.js +10 -2
- package/dist/protocol/dashboard-write-operations.d.ts +8 -1
- package/dist/protocol/dashboard-write-operations.js +25 -4
- package/dist/protocol/messages/access-log.d.ts +40 -0
- package/dist/protocol/messages/access-log.js +9 -1
- package/dist/protocol/messages/auth.d.ts +2 -0
- package/dist/protocol/messages/capabilities.d.ts +2 -0
- package/dist/protocol/messages/dashboard.d.ts +766 -25
- package/dist/protocol/messages/dashboard.js +173 -9
- package/dist/protocol/messages/deployment-identity.d.ts +38 -0
- package/dist/protocol/messages/deployment-identity.js +28 -0
- package/dist/protocol/messages/orchestrator-agent.d.ts +64 -2
- package/dist/protocol/messages/orchestrator-agent.js +26 -7
- package/dist/protocol/messages/peer.js +1 -1
- package/dist/protocol/messages/platform-orchestrator.d.ts +197 -2
- package/dist/protocol/messages/run-events.d.ts +1 -1
- package/dist/protocol/messages/source-registration.d.ts +15 -0
- package/dist/protocol/messages/source-registration.js +17 -1
- package/dist/trigger/types.d.ts +114 -22
- package/dist/trigger/types.js +53 -12
- package/package.json +9 -1
- package/sbom.spdx.json +5 -5
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
//#region src/inputs/extract.ts
|
|
3
|
+
/** Thrown when a declared dispatch input falls outside the closed Zod subset. */
|
|
4
|
+
var UnsupportedDispatchInputError = class extends Error {
|
|
5
|
+
construct;
|
|
6
|
+
key;
|
|
7
|
+
constructor(construct, key) {
|
|
8
|
+
super(`Unsupported dispatch input${key ? ` "${key}"` : ""}: ${construct}. Allowed: z.string/number/boolean/enum/literal with .optional/.nullable/.default/.min/.max/.regex/.int.`);
|
|
9
|
+
this.construct = construct;
|
|
10
|
+
this.key = key;
|
|
11
|
+
this.name = "UnsupportedDispatchInputError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const defOf = (s) => s?._zod?.def;
|
|
15
|
+
const checkDefOf = (c) => c?._zod?.def;
|
|
16
|
+
/** Pull string/number checks (min/max/int/regex) into descriptor fields. */
|
|
17
|
+
function applyChecks(d, checks, key) {
|
|
18
|
+
for (const c of checks ?? []) {
|
|
19
|
+
const cd = checkDefOf(c);
|
|
20
|
+
switch (cd?.check) {
|
|
21
|
+
case "greater_than":
|
|
22
|
+
d.min = Number(cd.value);
|
|
23
|
+
break;
|
|
24
|
+
case "less_than":
|
|
25
|
+
d.max = Number(cd.value);
|
|
26
|
+
break;
|
|
27
|
+
case "min_length":
|
|
28
|
+
d.min = Number(cd.minimum);
|
|
29
|
+
break;
|
|
30
|
+
case "max_length":
|
|
31
|
+
d.max = Number(cd.maximum);
|
|
32
|
+
break;
|
|
33
|
+
case "string_format":
|
|
34
|
+
if (cd.format === "regex" && cd.pattern) d.pattern = String(typeof cd.pattern === "object" ? cd.pattern.source ?? cd.pattern : cd.pattern);
|
|
35
|
+
else throw new UnsupportedDispatchInputError(`string format:${cd.format ?? "unknown"}`, key);
|
|
36
|
+
break;
|
|
37
|
+
case "number_format":
|
|
38
|
+
if (cd.format === "safeint" || cd.format === "int") d.type = "integer";
|
|
39
|
+
else throw new UnsupportedDispatchInputError(`number format:${cd.format ?? "unknown"}`, key);
|
|
40
|
+
break;
|
|
41
|
+
default: throw new UnsupportedDispatchInputError(`check:${cd?.check ?? "unknown"}`, key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Walk a Zod schema's `_zod.def`, reject any construct outside the closed
|
|
47
|
+
* subset, and extract a JSON-safe `InputDescriptor`.
|
|
48
|
+
*/
|
|
49
|
+
function extractInputDescriptor(schema, key) {
|
|
50
|
+
let cur = schema;
|
|
51
|
+
let optional = false;
|
|
52
|
+
let nullable = false;
|
|
53
|
+
let hasDefault = false;
|
|
54
|
+
let defaultValue;
|
|
55
|
+
for (;;) {
|
|
56
|
+
const d = defOf(cur);
|
|
57
|
+
if (!d) throw new UnsupportedDispatchInputError("non-zod value", key);
|
|
58
|
+
if (d.type === "optional") {
|
|
59
|
+
optional = true;
|
|
60
|
+
cur = d.innerType;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (d.type === "nullable") {
|
|
64
|
+
nullable = true;
|
|
65
|
+
cur = d.innerType;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (d.type === "default") {
|
|
69
|
+
hasDefault = true;
|
|
70
|
+
defaultValue = typeof d.defaultValue === "function" ? d.defaultValue() : d.defaultValue;
|
|
71
|
+
cur = d.innerType;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const d = defOf(cur);
|
|
77
|
+
if (!d) throw new UnsupportedDispatchInputError("non-zod value", key);
|
|
78
|
+
const out = {
|
|
79
|
+
type: "string",
|
|
80
|
+
optional,
|
|
81
|
+
nullable
|
|
82
|
+
};
|
|
83
|
+
if (hasDefault) out.default = defaultValue;
|
|
84
|
+
switch (d.type) {
|
|
85
|
+
case "string":
|
|
86
|
+
out.type = "string";
|
|
87
|
+
applyChecks(out, d.checks, key);
|
|
88
|
+
break;
|
|
89
|
+
case "number":
|
|
90
|
+
out.type = "number";
|
|
91
|
+
applyChecks(out, d.checks, key);
|
|
92
|
+
break;
|
|
93
|
+
case "boolean":
|
|
94
|
+
out.type = "boolean";
|
|
95
|
+
break;
|
|
96
|
+
case "enum":
|
|
97
|
+
out.type = "enum";
|
|
98
|
+
out.values = Object.values(d.entries ?? {});
|
|
99
|
+
break;
|
|
100
|
+
case "literal":
|
|
101
|
+
out.type = "literal";
|
|
102
|
+
out.literal = d.values?.[0] ?? d.value;
|
|
103
|
+
break;
|
|
104
|
+
default: throw new UnsupportedDispatchInputError(`z.${d.type}`, key);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/** Extract a descriptor for every key in a `{ name: ZodSchema }` map. */
|
|
109
|
+
function extractInputsDescriptorMap(map) {
|
|
110
|
+
const out = {};
|
|
111
|
+
for (const [k, v] of Object.entries(map)) out[k] = extractInputDescriptor(v, k);
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { UnsupportedDispatchInputError, extractInputDescriptor, extractInputsDescriptorMap };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { DispatchInputType, InputDescriptor, InputsDescriptorMapSchema } from "./descriptor.js";
|
|
3
|
+
import { UnsupportedDispatchInputError, extractInputDescriptor, extractInputsDescriptorMap } from "./extract.js";
|
|
4
|
+
import { buildZodFromDescriptor, buildZodObjectFromMap } from "./build.js";
|
|
5
|
+
import { DispatchInputError, coerceDispatchInputs, parseInputPairs } from "./coerce.js";
|
|
6
|
+
export { DispatchInputError, DispatchInputType, InputDescriptor, InputsDescriptorMapSchema, UnsupportedDispatchInputError, buildZodFromDescriptor, buildZodObjectFromMap, coerceDispatchInputs, extractInputDescriptor, extractInputsDescriptorMap, parseInputPairs };
|
package/dist/inventory.d.ts
CHANGED
|
@@ -30,8 +30,8 @@ export type InventoryLifecycleClass = z.infer<typeof InventoryLifecycleClass>;
|
|
|
30
30
|
* awaiting reap).
|
|
31
31
|
*/
|
|
32
32
|
export declare const InventoryHostStatus: z.ZodEnum<{
|
|
33
|
-
unreachable: "unreachable";
|
|
34
33
|
ready: "ready";
|
|
34
|
+
unreachable: "unreachable";
|
|
35
35
|
stale: "stale";
|
|
36
36
|
}>;
|
|
37
37
|
export type InventoryHostStatus = z.infer<typeof InventoryHostStatus>;
|
|
@@ -48,8 +48,8 @@ export declare const HostInventoryEntry: z.ZodObject<{
|
|
|
48
48
|
ephemeral: "ephemeral";
|
|
49
49
|
}>;
|
|
50
50
|
status: z.ZodEnum<{
|
|
51
|
-
unreachable: "unreachable";
|
|
52
51
|
ready: "ready";
|
|
52
|
+
unreachable: "unreachable";
|
|
53
53
|
stale: "stale";
|
|
54
54
|
}>;
|
|
55
55
|
lastSeen: z.ZodString;
|
package/dist/labels/compile.d.ts
CHANGED
|
@@ -15,9 +15,12 @@ export declare function assertSafeRegex(source: string, flags: string, ctx: stri
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function toLabelMatcher(el: string | RegExp, ctx: string): LabelMatcher;
|
|
17
17
|
export type SelectorEl = string | RegExp;
|
|
18
|
+
/** Single-agent selection policy when multiple agents match a `runsOn` selector. */
|
|
19
|
+
export type RunsOnPickInput = 'deterministic' | 'any';
|
|
18
20
|
export type RunsOnAuthorInput = SelectorEl | readonly SelectorEl[] | {
|
|
19
21
|
labels: SelectorEl | readonly SelectorEl[];
|
|
20
22
|
exclude?: SelectorEl | readonly SelectorEl[];
|
|
23
|
+
pick?: RunsOnPickInput;
|
|
21
24
|
};
|
|
22
25
|
export type RunsOnAllAuthorInput = string | RegExp | readonly SelectorEl[] | {
|
|
23
26
|
include: readonly {
|
|
@@ -30,6 +33,12 @@ export declare function normalizeRunsOnToMatchers(runsOn: RunsOnAuthorInput, ctx
|
|
|
30
33
|
include: LabelMatcher[];
|
|
31
34
|
exclude: LabelMatcher[];
|
|
32
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a `runsOn` author value's single-agent selection policy, defaulting to
|
|
38
|
+
* `'deterministic'` for every form (string / array shorthand inherit the default
|
|
39
|
+
* after normalization; the selector object's explicit `pick` wins).
|
|
40
|
+
*/
|
|
41
|
+
export declare function runsOnPickFromInput(runsOn: RunsOnAuthorInput): RunsOnPickInput;
|
|
33
42
|
/** Normalize a `runsOnAll` author value into include groups + exclude matchers. */
|
|
34
43
|
export declare function normalizeRunsOnAllToMatchers(input: RunsOnAllAuthorInput, ctx: string): {
|
|
35
44
|
include: LabelMatcher[][];
|
package/dist/labels/compile.js
CHANGED
|
@@ -59,6 +59,15 @@ function normalizeRunsOnToMatchers(runsOn, ctx) {
|
|
|
59
59
|
exclude: sel.exclude ? asArray(sel.exclude).map((e) => toLabelMatcher(e, ctx)) : []
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve a `runsOn` author value's single-agent selection policy, defaulting to
|
|
64
|
+
* `'deterministic'` for every form (string / array shorthand inherit the default
|
|
65
|
+
* after normalization; the selector object's explicit `pick` wins).
|
|
66
|
+
*/
|
|
67
|
+
function runsOnPickFromInput(runsOn) {
|
|
68
|
+
if (typeof runsOn === "string" || runsOn instanceof RegExp || Array.isArray(runsOn)) return "deterministic";
|
|
69
|
+
return runsOn.pick ?? "deterministic";
|
|
70
|
+
}
|
|
62
71
|
/** Normalize a `runsOnAll` author value into include groups + exclude matchers. */
|
|
63
72
|
function normalizeRunsOnAllToMatchers(input, ctx) {
|
|
64
73
|
if (typeof input === "string" || input instanceof RegExp) return {
|
|
@@ -86,6 +95,6 @@ function assertMatchersSafe(matchers, ctx) {
|
|
|
86
95
|
for (const m of matchers) if (m.kind === "regex") assertSafeRegex(m.source, m.flags, ctx);
|
|
87
96
|
}
|
|
88
97
|
//#endregion
|
|
89
|
-
export { assertMatchersSafe, assertSafeRegex, normalizeRunsOnAllToMatchers, normalizeRunsOnToMatchers, toLabelMatcher };
|
|
98
|
+
export { assertMatchersSafe, assertSafeRegex, normalizeRunsOnAllToMatchers, normalizeRunsOnToMatchers, runsOnPickFromInput, toLabelMatcher };
|
|
90
99
|
|
|
91
100
|
//# sourceMappingURL=compile.js.map
|
package/dist/labels-match.d.ts
CHANGED
|
@@ -24,6 +24,58 @@ export declare function compileRegexMatcher(m: {
|
|
|
24
24
|
export declare function matcherMatches(m: LabelMatcher, label: string): boolean;
|
|
25
25
|
/** Whether some label in the set satisfies the matcher. */
|
|
26
26
|
export declare function matcherSatisfiedBy(m: LabelMatcher, labels: ReadonlySet<string>): boolean;
|
|
27
|
+
export declare const HostTargetValue: z.ZodObject<{
|
|
28
|
+
include: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
|
+
kind: z.ZodLiteral<"exact">;
|
|
30
|
+
value: z.ZodString;
|
|
31
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"regex">;
|
|
33
|
+
source: z.ZodString;
|
|
34
|
+
flags: z.ZodString;
|
|
35
|
+
}, z.core.$strip>], "kind">>;
|
|
36
|
+
exclude: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
37
|
+
kind: z.ZodLiteral<"exact">;
|
|
38
|
+
value: z.ZodString;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
kind: z.ZodLiteral<"regex">;
|
|
41
|
+
source: z.ZodString;
|
|
42
|
+
flags: z.ZodString;
|
|
43
|
+
}, z.core.$strip>], "kind">>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type HostTargetValue = z.infer<typeof HostTargetValue>;
|
|
46
|
+
/**
|
|
47
|
+
* A runtime host narrowing (`kici run --target`): each repeated value is an AND
|
|
48
|
+
* set; values AND-combine. Narrow-only — applied as a post-filter over the
|
|
49
|
+
* runsOnAll-matched roster. `allowEmpty` selects the zero-host outcome: skip
|
|
50
|
+
* (true) vs fail (false).
|
|
51
|
+
*/
|
|
52
|
+
export declare const HostTargetSelector: z.ZodObject<{
|
|
53
|
+
values: z.ZodArray<z.ZodObject<{
|
|
54
|
+
include: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
55
|
+
kind: z.ZodLiteral<"exact">;
|
|
56
|
+
value: z.ZodString;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"regex">;
|
|
59
|
+
source: z.ZodString;
|
|
60
|
+
flags: z.ZodString;
|
|
61
|
+
}, z.core.$strip>], "kind">>;
|
|
62
|
+
exclude: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
|
+
kind: z.ZodLiteral<"exact">;
|
|
64
|
+
value: z.ZodString;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
kind: z.ZodLiteral<"regex">;
|
|
67
|
+
source: z.ZodString;
|
|
68
|
+
flags: z.ZodString;
|
|
69
|
+
}, z.core.$strip>], "kind">>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
allowEmpty: z.ZodBoolean;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type HostTargetSelector = z.infer<typeof HostTargetSelector>;
|
|
74
|
+
/**
|
|
75
|
+
* True iff the host's labels satisfy EVERY target value: all of a value's
|
|
76
|
+
* include matchers match and none of its exclude matchers match.
|
|
77
|
+
*/
|
|
78
|
+
export declare function hostSatisfiesTarget(labels: ReadonlySet<string>, target: HostTargetSelector): boolean;
|
|
27
79
|
/** Split a matcher list into exact label strings and the remaining regex matchers. */
|
|
28
80
|
export declare function partitionMatchers(ms: readonly LabelMatcher[]): {
|
|
29
81
|
exact: string[];
|
package/dist/labels-match.js
CHANGED
|
@@ -38,6 +38,27 @@ function matcherSatisfiedBy(m, labels) {
|
|
|
38
38
|
for (const label of labels) if (re.test(label)) return true;
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
41
|
+
const HostTargetValue = z.object({
|
|
42
|
+
include: z.array(LabelMatcher),
|
|
43
|
+
exclude: z.array(LabelMatcher)
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* A runtime host narrowing (`kici run --target`): each repeated value is an AND
|
|
47
|
+
* set; values AND-combine. Narrow-only — applied as a post-filter over the
|
|
48
|
+
* runsOnAll-matched roster. `allowEmpty` selects the zero-host outcome: skip
|
|
49
|
+
* (true) vs fail (false).
|
|
50
|
+
*/
|
|
51
|
+
const HostTargetSelector = z.object({
|
|
52
|
+
values: z.array(HostTargetValue).min(1),
|
|
53
|
+
allowEmpty: z.boolean()
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* True iff the host's labels satisfy EVERY target value: all of a value's
|
|
57
|
+
* include matchers match and none of its exclude matchers match.
|
|
58
|
+
*/
|
|
59
|
+
function hostSatisfiesTarget(labels, target) {
|
|
60
|
+
return target.values.every((v) => v.include.every((m) => matcherSatisfiedBy(m, labels)) && !v.exclude.some((m) => matcherSatisfiedBy(m, labels)));
|
|
61
|
+
}
|
|
41
62
|
/** Split a matcher list into exact label strings and the remaining regex matchers. */
|
|
42
63
|
function partitionMatchers(ms) {
|
|
43
64
|
const exact = [];
|
|
@@ -51,6 +72,6 @@ function partitionMatchers(ms) {
|
|
|
51
72
|
};
|
|
52
73
|
}
|
|
53
74
|
//#endregion
|
|
54
|
-
export { LabelMatcher, compileRegexMatcher, matcherMatches, matcherSatisfiedBy, partitionMatchers };
|
|
75
|
+
export { HostTargetSelector, HostTargetValue, LabelMatcher, compileRegexMatcher, hostSatisfiesTarget, matcherMatches, matcherSatisfiedBy, partitionMatchers };
|
|
55
76
|
|
|
56
77
|
//# sourceMappingURL=labels-match.js.map
|
package/dist/labels.d.ts
CHANGED
|
@@ -79,6 +79,35 @@ export declare const KNOWN_ROLES: readonly ["builder", "init-runner"];
|
|
|
79
79
|
export type AgentRole = (typeof KNOWN_ROLES)[number];
|
|
80
80
|
/** Reserved label prefix — labels starting with this are system-managed. */
|
|
81
81
|
export declare const RESERVED_LABEL_PREFIX = "kici:";
|
|
82
|
+
/**
|
|
83
|
+
* Capability label prefix — `kici:capability:<name>` grants an agent a
|
|
84
|
+
* privileged capability beyond plain execution. Distinct from `kici:role:`
|
|
85
|
+
* (which gates which internal job kinds an agent runs).
|
|
86
|
+
*/
|
|
87
|
+
export declare const CAPABILITY_LABEL_PREFIX = "kici:capability:";
|
|
88
|
+
/** Build a `kici:capability:<name>` label. */
|
|
89
|
+
export declare function capabilityLabel(name: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* The `ssh-transport` capability: an agent holding this may run the bootstrap
|
|
92
|
+
* bring-up (`ctx.kici.bootstrap.ensureInitRunner` / `preBootSend`) — i.e. SSH
|
|
93
|
+
* to a declared-but-un-agented host. The orchestrator refuses to run a
|
|
94
|
+
* bring-up on an agent that lacks it. Prod-critical: such an agent custodies
|
|
95
|
+
* the bootstrap SSH key.
|
|
96
|
+
*/
|
|
97
|
+
export declare const SSH_TRANSPORT_CAPABILITY = "kici:capability:ssh-transport";
|
|
98
|
+
/**
|
|
99
|
+
* The `kici:init` lifecycle label carried by a temporary init-runner agent
|
|
100
|
+
* brought up on a fresh box for bootstrap. Marks it as ephemeral + privileged;
|
|
101
|
+
* it dies on reboot and is reaped. Distinct from `kici:role:init-runner`
|
|
102
|
+
* (which is the per-job `__init__` workspace-init capability — a different
|
|
103
|
+
* concept entirely).
|
|
104
|
+
*/
|
|
105
|
+
export declare const INIT_LABEL = "kici:init";
|
|
106
|
+
/**
|
|
107
|
+
* The `kici:privileged:root` label a bootstrap init-runner carries — it runs
|
|
108
|
+
* as root in the target's rescue env to partition / format / install.
|
|
109
|
+
*/
|
|
110
|
+
export declare const PRIVILEGED_ROOT_LABEL = "kici:privileged:root";
|
|
82
111
|
/** Role label prefix — used to generate role-specific labels. */
|
|
83
112
|
export declare const ROLE_LABEL_PREFIX = "kici:role:";
|
|
84
113
|
/**
|
package/dist/labels.js
CHANGED
|
@@ -116,6 +116,37 @@ function normalizeRunsOn(runsOn) {
|
|
|
116
116
|
const KNOWN_ROLES = ["builder", "init-runner"];
|
|
117
117
|
/** Reserved label prefix — labels starting with this are system-managed. */
|
|
118
118
|
const RESERVED_LABEL_PREFIX = "kici:";
|
|
119
|
+
/**
|
|
120
|
+
* Capability label prefix — `kici:capability:<name>` grants an agent a
|
|
121
|
+
* privileged capability beyond plain execution. Distinct from `kici:role:`
|
|
122
|
+
* (which gates which internal job kinds an agent runs).
|
|
123
|
+
*/
|
|
124
|
+
const CAPABILITY_LABEL_PREFIX = "kici:capability:";
|
|
125
|
+
/** Build a `kici:capability:<name>` label. */
|
|
126
|
+
function capabilityLabel(name) {
|
|
127
|
+
return `${CAPABILITY_LABEL_PREFIX}${name}`;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The `ssh-transport` capability: an agent holding this may run the bootstrap
|
|
131
|
+
* bring-up (`ctx.kici.bootstrap.ensureInitRunner` / `preBootSend`) — i.e. SSH
|
|
132
|
+
* to a declared-but-un-agented host. The orchestrator refuses to run a
|
|
133
|
+
* bring-up on an agent that lacks it. Prod-critical: such an agent custodies
|
|
134
|
+
* the bootstrap SSH key.
|
|
135
|
+
*/
|
|
136
|
+
const SSH_TRANSPORT_CAPABILITY = "kici:capability:ssh-transport";
|
|
137
|
+
/**
|
|
138
|
+
* The `kici:init` lifecycle label carried by a temporary init-runner agent
|
|
139
|
+
* brought up on a fresh box for bootstrap. Marks it as ephemeral + privileged;
|
|
140
|
+
* it dies on reboot and is reaped. Distinct from `kici:role:init-runner`
|
|
141
|
+
* (which is the per-job `__init__` workspace-init capability — a different
|
|
142
|
+
* concept entirely).
|
|
143
|
+
*/
|
|
144
|
+
const INIT_LABEL = "kici:init";
|
|
145
|
+
/**
|
|
146
|
+
* The `kici:privileged:root` label a bootstrap init-runner carries — it runs
|
|
147
|
+
* as root in the target's rescue env to partition / format / install.
|
|
148
|
+
*/
|
|
149
|
+
const PRIVILEGED_ROOT_LABEL = "kici:privileged:root";
|
|
119
150
|
/** Role label prefix — used to generate role-specific labels. */
|
|
120
151
|
const ROLE_LABEL_PREFIX = "kici:role:";
|
|
121
152
|
/**
|
|
@@ -203,6 +234,6 @@ function separateLabels(labels) {
|
|
|
203
234
|
};
|
|
204
235
|
}
|
|
205
236
|
//#endregion
|
|
206
|
-
export { HOST_LABEL_PREFIX, KNOWN_ROLES, RESERVED_LABEL_PREFIX, ROLE_LABEL_PREFIX, SELF_REPORTED_LABEL_PREFIXES, agentTypeLabel, deriveOsArchLabels, hostLabel, isAutoLabel, isSelfReportedLabel, mergeAutoLabels, normalizeRunsOn, parseHostLabel, resolveRoleLabels, roleToLabel, scalerAgentLabels, scalerLabel, separateLabels, validateNoReservedLabels };
|
|
237
|
+
export { CAPABILITY_LABEL_PREFIX, HOST_LABEL_PREFIX, INIT_LABEL, KNOWN_ROLES, PRIVILEGED_ROOT_LABEL, RESERVED_LABEL_PREFIX, ROLE_LABEL_PREFIX, SELF_REPORTED_LABEL_PREFIXES, SSH_TRANSPORT_CAPABILITY, agentTypeLabel, capabilityLabel, deriveOsArchLabels, hostLabel, isAutoLabel, isSelfReportedLabel, mergeAutoLabels, normalizeRunsOn, parseHostLabel, resolveRoleLabels, roleToLabel, scalerAgentLabels, scalerLabel, separateLabels, validateNoReservedLabels };
|
|
207
238
|
|
|
208
239
|
//# sourceMappingURL=labels.js.map
|
|
@@ -52,6 +52,13 @@ export declare const OVERFLOW_LABEL_VALUE = "__overflow__";
|
|
|
52
52
|
* so they are valid push payloads alongside `kici_orch_*`.
|
|
53
53
|
*/
|
|
54
54
|
export declare const ORCH_PUSHED_METRIC_NAMES: ReadonlySet<MetricName>;
|
|
55
|
+
/**
|
|
56
|
+
* Closed enum of scaler-backend TYPE values the orchestrator's own
|
|
57
|
+
* resource-usage gauges carry on their `scalerType` rollup label.
|
|
58
|
+
* `__global__` is the orchestrator-wide rollup row; the other four match
|
|
59
|
+
* `AGENT_SCALER_VALUES`. Exported so the policy tests can assert against it.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ORCH_SCALER_VALUES: readonly ["__global__", "stateful", "container", "firecracker", "bare-metal"];
|
|
55
62
|
/**
|
|
56
63
|
* Per-metric, per-label value policy. Missing entries (or missing label
|
|
57
64
|
* keys within an entry) mean "no value-level constraint" — the label key
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../chunk-BTugEXQM.js";
|
|
2
|
+
import { ExecutionRunStatus } from "../protocol/messages/execution-status.js";
|
|
2
3
|
import { MetricNames, MetricService } from "./metric-catalog.generated.js";
|
|
3
4
|
//#region src/metrics/catalog-policy.ts
|
|
4
5
|
/**
|
|
@@ -48,9 +49,10 @@ const AGENT_SCALER_VALUES = [
|
|
|
48
49
|
"bare-metal"
|
|
49
50
|
];
|
|
50
51
|
/**
|
|
51
|
-
* Closed enum of scaler values the orchestrator's own
|
|
52
|
-
* gauges
|
|
53
|
-
* other four match
|
|
52
|
+
* Closed enum of scaler-backend TYPE values the orchestrator's own
|
|
53
|
+
* resource-usage gauges carry on their `scalerType` rollup label.
|
|
54
|
+
* `__global__` is the orchestrator-wide rollup row; the other four match
|
|
55
|
+
* `AGENT_SCALER_VALUES`. Exported so the policy tests can assert against it.
|
|
54
56
|
*/
|
|
55
57
|
const ORCH_SCALER_VALUES = ["__global__", ...AGENT_SCALER_VALUES];
|
|
56
58
|
/** Closed enum of the five scheduled jobs the orchestrator runs (mirrors `OrchestratorScheduledJobName`). */
|
|
@@ -94,12 +96,7 @@ const METRIC_LABEL_POLICY = {
|
|
|
94
96
|
"handled",
|
|
95
97
|
"dispatched"
|
|
96
98
|
] } },
|
|
97
|
-
kici_orch_executions_total: { status: { values:
|
|
98
|
-
"running",
|
|
99
|
-
"success",
|
|
100
|
-
"failed",
|
|
101
|
-
"cancelled"
|
|
102
|
-
] } },
|
|
99
|
+
kici_orch_executions_total: { status: { values: ExecutionRunStatus.options } },
|
|
103
100
|
kici_orch_steps_total: { status: { values: [
|
|
104
101
|
"running",
|
|
105
102
|
"success",
|
|
@@ -130,11 +127,13 @@ const METRIC_LABEL_POLICY = {
|
|
|
130
127
|
] }
|
|
131
128
|
},
|
|
132
129
|
kici_orch_scaler_cpus_used: {
|
|
133
|
-
scaler: {
|
|
130
|
+
scaler: { maxUniqueValues: 50 },
|
|
131
|
+
scalerType: { values: ORCH_SCALER_VALUES },
|
|
134
132
|
machinePool: { maxUniqueValues: 50 }
|
|
135
133
|
},
|
|
136
134
|
kici_orch_scaler_memory_bytes_used: {
|
|
137
|
-
scaler: {
|
|
135
|
+
scaler: { maxUniqueValues: 50 },
|
|
136
|
+
scalerType: { values: ORCH_SCALER_VALUES },
|
|
138
137
|
machinePool: { maxUniqueValues: 50 }
|
|
139
138
|
},
|
|
140
139
|
kici_orch_install_secrets_decisions_total: {
|
|
@@ -278,6 +277,6 @@ const METRIC_LABEL_POLICY = {
|
|
|
278
277
|
}
|
|
279
278
|
};
|
|
280
279
|
//#endregion
|
|
281
|
-
export { METRIC_LABEL_POLICY, ORCH_PUSHED_METRIC_NAMES, OVERFLOW_LABEL_VALUE };
|
|
280
|
+
export { METRIC_LABEL_POLICY, ORCH_PUSHED_METRIC_NAMES, ORCH_SCALER_VALUES, OVERFLOW_LABEL_VALUE };
|
|
282
281
|
|
|
283
282
|
//# sourceMappingURL=catalog-policy.js.map
|
|
@@ -183,8 +183,8 @@ export declare const MetricLabels: {
|
|
|
183
183
|
readonly KICI_ORCH_LOG_CHUNKS_RECEIVED_TOTAL: readonly [];
|
|
184
184
|
readonly KICI_ORCH_PG_POOL_CLIENT_ERRORS_TOTAL: readonly ["source"];
|
|
185
185
|
readonly KICI_ORCH_SCALER_CONFIG_RELOADS_TOTAL: readonly ["result"];
|
|
186
|
-
readonly KICI_ORCH_SCALER_CPUS_USED: readonly ["scaler", "machinePool"];
|
|
187
|
-
readonly KICI_ORCH_SCALER_MEMORY_BYTES_USED: readonly ["scaler", "machinePool"];
|
|
186
|
+
readonly KICI_ORCH_SCALER_CPUS_USED: readonly ["scaler", "scalerType", "machinePool"];
|
|
187
|
+
readonly KICI_ORCH_SCALER_MEMORY_BYTES_USED: readonly ["scaler", "scalerType", "machinePool"];
|
|
188
188
|
readonly KICI_ORCH_SCALER_SPAWN_FAILURES_TOTAL: readonly ["backend", "bound"];
|
|
189
189
|
readonly KICI_ORCH_SCALER_SPAWN_REFUSALS_TOTAL: readonly [];
|
|
190
190
|
readonly KICI_ORCH_SOURCE_CACHE_HITS_TOTAL: readonly [];
|
|
@@ -188,8 +188,16 @@ const MetricLabels = {
|
|
|
188
188
|
KICI_ORCH_LOG_CHUNKS_RECEIVED_TOTAL: [],
|
|
189
189
|
KICI_ORCH_PG_POOL_CLIENT_ERRORS_TOTAL: ["source"],
|
|
190
190
|
KICI_ORCH_SCALER_CONFIG_RELOADS_TOTAL: ["result"],
|
|
191
|
-
KICI_ORCH_SCALER_CPUS_USED: [
|
|
192
|
-
|
|
191
|
+
KICI_ORCH_SCALER_CPUS_USED: [
|
|
192
|
+
"scaler",
|
|
193
|
+
"scalerType",
|
|
194
|
+
"machinePool"
|
|
195
|
+
],
|
|
196
|
+
KICI_ORCH_SCALER_MEMORY_BYTES_USED: [
|
|
197
|
+
"scaler",
|
|
198
|
+
"scalerType",
|
|
199
|
+
"machinePool"
|
|
200
|
+
],
|
|
193
201
|
KICI_ORCH_SCALER_SPAWN_FAILURES_TOTAL: ["backend", "bound"],
|
|
194
202
|
KICI_ORCH_SCALER_SPAWN_REFUSALS_TOTAL: [],
|
|
195
203
|
KICI_ORCH_SOURCE_CACHE_HITS_TOTAL: [],
|
|
@@ -44,6 +44,8 @@ export declare const DashboardWriteOperation: z.ZodEnum<{
|
|
|
44
44
|
"backends.sync": "backends.sync";
|
|
45
45
|
"backends.sync_one": "backends.sync_one";
|
|
46
46
|
"backends.test": "backends.test";
|
|
47
|
+
"fleet.host.declare": "fleet.host.declare";
|
|
48
|
+
"fleet.host.remove": "fleet.host.remove";
|
|
47
49
|
}>;
|
|
48
50
|
export type DashboardWriteOperation = z.infer<typeof DashboardWriteOperation>;
|
|
49
51
|
/** Stable list of every operation in enum-declaration order. */
|
|
@@ -57,6 +59,7 @@ export declare const DashboardWriteCategory: z.ZodEnum<{
|
|
|
57
59
|
DLQ: "DLQ";
|
|
58
60
|
Registrations: "Registrations";
|
|
59
61
|
Topology: "Topology";
|
|
62
|
+
Fleet: "Fleet";
|
|
60
63
|
}>;
|
|
61
64
|
export type DashboardWriteCategory = z.infer<typeof DashboardWriteCategory>;
|
|
62
65
|
export declare const DashboardWriteSensitivity: z.ZodEnum<{
|
|
@@ -130,6 +133,8 @@ export declare const dashboardWritePolicyMap: z.ZodRecord<z.ZodEnum<{
|
|
|
130
133
|
"backends.sync": "backends.sync";
|
|
131
134
|
"backends.sync_one": "backends.sync_one";
|
|
132
135
|
"backends.test": "backends.test";
|
|
136
|
+
"fleet.host.declare": "fleet.host.declare";
|
|
137
|
+
"fleet.host.remove": "fleet.host.remove";
|
|
133
138
|
}> & z.core.$partial, z.ZodBoolean>;
|
|
134
139
|
export declare const dashboardWritePolicyMapSchema: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
135
140
|
"secrets.set": "secrets.set";
|
|
@@ -156,6 +161,8 @@ export declare const dashboardWritePolicyMapSchema: z.ZodDefault<z.ZodRecord<z.Z
|
|
|
156
161
|
"backends.sync": "backends.sync";
|
|
157
162
|
"backends.sync_one": "backends.sync_one";
|
|
158
163
|
"backends.test": "backends.test";
|
|
164
|
+
"fleet.host.declare": "fleet.host.declare";
|
|
165
|
+
"fleet.host.remove": "fleet.host.remove";
|
|
159
166
|
}> & z.core.$partial, z.ZodBoolean>>;
|
|
160
167
|
/**
|
|
161
168
|
* Resolve the effective state of an operation given a (possibly sparse)
|
|
@@ -164,7 +171,7 @@ export declare const dashboardWritePolicyMapSchema: z.ZodDefault<z.ZodRecord<z.Z
|
|
|
164
171
|
export declare function isDashboardWriteOperationEnabled(policy: DashboardWritePolicyMap | null | undefined, op: DashboardWriteOperation): boolean;
|
|
165
172
|
/**
|
|
166
173
|
* Expand a (possibly sparse) policy map into the full effective state
|
|
167
|
-
* for all
|
|
174
|
+
* for all 26 operations. Operations the policy doesn't mention come
|
|
168
175
|
* back as `true` (permissive). Used by the orch HTTP admin response,
|
|
169
176
|
* the WS `orch.capabilities` broadcast, and the dashboard's policy
|
|
170
177
|
* page so consumers see the full picture, not the sparse storage shape.
|
|
@@ -45,7 +45,9 @@ const DashboardWriteOperation = z.enum([
|
|
|
45
45
|
"global_workflows.update",
|
|
46
46
|
"backends.sync",
|
|
47
47
|
"backends.sync_one",
|
|
48
|
-
"backends.test"
|
|
48
|
+
"backends.test",
|
|
49
|
+
"fleet.host.declare",
|
|
50
|
+
"fleet.host.remove"
|
|
49
51
|
]);
|
|
50
52
|
/** Stable list of every operation in enum-declaration order. */
|
|
51
53
|
const DASHBOARD_WRITE_OPERATION_VALUES = Object.freeze([
|
|
@@ -72,7 +74,9 @@ const DASHBOARD_WRITE_OPERATION_VALUES = Object.freeze([
|
|
|
72
74
|
"global_workflows.update",
|
|
73
75
|
"backends.sync",
|
|
74
76
|
"backends.sync_one",
|
|
75
|
-
"backends.test"
|
|
77
|
+
"backends.test",
|
|
78
|
+
"fleet.host.declare",
|
|
79
|
+
"fleet.host.remove"
|
|
76
80
|
]);
|
|
77
81
|
const DashboardWriteCategory = z.enum([
|
|
78
82
|
"Secrets",
|
|
@@ -82,7 +86,8 @@ const DashboardWriteCategory = z.enum([
|
|
|
82
86
|
"Held runs",
|
|
83
87
|
"DLQ",
|
|
84
88
|
"Registrations",
|
|
85
|
-
"Topology"
|
|
89
|
+
"Topology",
|
|
90
|
+
"Fleet"
|
|
86
91
|
]);
|
|
87
92
|
const DashboardWriteSensitivity = z.enum([
|
|
88
93
|
"plaintext",
|
|
@@ -281,6 +286,22 @@ const DASHBOARD_WRITE_OPERATIONS = Object.freeze([
|
|
|
281
286
|
label: "Test scaler backend",
|
|
282
287
|
sensitivity: "dispatch",
|
|
283
288
|
cliEquivalent: "kici-admin backend test"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: "fleet.host.declare",
|
|
292
|
+
wireMessageType: "dashboard.fleet.host.declare",
|
|
293
|
+
category: "Fleet",
|
|
294
|
+
label: "Declare a static host",
|
|
295
|
+
sensitivity: "dispatch",
|
|
296
|
+
cliEquivalent: "kici-admin host declare"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "fleet.host.remove",
|
|
300
|
+
wireMessageType: "dashboard.fleet.host.remove",
|
|
301
|
+
category: "Fleet",
|
|
302
|
+
label: "Remove a host from the roster",
|
|
303
|
+
sensitivity: "dispatch",
|
|
304
|
+
cliEquivalent: "kici-admin host remove"
|
|
284
305
|
}
|
|
285
306
|
]);
|
|
286
307
|
/** O(1) lookup of a descriptor by operation name. */
|
|
@@ -318,7 +339,7 @@ function isDashboardWriteOperationEnabled(policy, op) {
|
|
|
318
339
|
}
|
|
319
340
|
/**
|
|
320
341
|
* Expand a (possibly sparse) policy map into the full effective state
|
|
321
|
-
* for all
|
|
342
|
+
* for all 26 operations. Operations the policy doesn't mention come
|
|
322
343
|
* back as `true` (permissive). Used by the orch HTTP admin response,
|
|
323
344
|
* the WS `orch.capabilities` broadcast, and the dashboard's policy
|
|
324
345
|
* page so consumers see the full picture, not the sparse storage shape.
|