@kici-dev/orchestrator 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/agent/dispatcher.d.ts +18 -1
  2. package/dist/app.d.ts +25 -0
  3. package/dist/approvals/apply-decision.d.ts +70 -0
  4. package/dist/approvals/approval-resolver.d.ts +66 -0
  5. package/dist/approvals/step-approval-bridge.d.ts +72 -0
  6. package/dist/approvals/team-membership-lookup.d.ts +13 -0
  7. package/dist/cache/pending-inits.d.ts +5 -0
  8. package/dist/cache/user-cache.d.ts +1 -1
  9. package/dist/cli/api-client.d.ts +35 -0
  10. package/dist/cli/commands/firecracker/index.d.ts +11 -0
  11. package/dist/cli/commands/firecracker/provision.d.ts +13 -0
  12. package/dist/cli/commands/firecracker/teardown.d.ts +3 -0
  13. package/dist/cli/commands/firecracker/verify.d.ts +3 -0
  14. package/dist/cli/commands/local-hook.d.ts +15 -0
  15. package/dist/cli/commands/local-trigger.d.ts +24 -0
  16. package/dist/cli/commands/remote-source.d.ts +17 -0
  17. package/dist/cli/commands/scaler.d.ts +18 -0
  18. package/dist/cli/commands/shared/versioned-upgrade.d.ts +14 -0
  19. package/dist/cli/kici-admin.d.ts +23 -1
  20. package/dist/cli/service/image-digests.d.ts +21 -0
  21. package/dist/cli.js +4320 -490
  22. package/dist/cluster/peer-client.d.ts +23 -1
  23. package/dist/cluster/peer-handler.d.ts +9 -1
  24. package/dist/config.d.ts +0 -4
  25. package/dist/dashboard/handler.d.ts +26 -2
  26. package/dist/dashboard/needs-edges.d.ts +13 -0
  27. package/dist/db/migrations/033_org_settings_approval.d.ts +19 -0
  28. package/dist/db/migrations/034_held_runs_generalize.d.ts +24 -0
  29. package/dist/db/migrations/035_pending_workflow_contexts.d.ts +11 -0
  30. package/dist/db/migrations/036_attestations.d.ts +15 -0
  31. package/dist/db/migrations/037_generic_sources_provider_type_local.d.ts +19 -0
  32. package/dist/db/migrations/038_remote_sources.d.ts +14 -0
  33. package/dist/db/types.d.ts +135 -11
  34. package/dist/diagnostics/bundle-writer.d.ts +1 -17
  35. package/dist/diagnostics/checks/firecracker-network.d.ts +13 -0
  36. package/dist/diagnostics/checks/index.d.ts +2 -1
  37. package/dist/diagnostics/fleet-collector.d.ts +52 -0
  38. package/dist/diagnostics/fleet-constants.d.ts +8 -0
  39. package/dist/diagnostics/fleet-selection.d.ts +15 -0
  40. package/dist/diagnostics/fleet-topology.d.ts +47 -0
  41. package/dist/diagnostics/fleet-wiring.d.ts +60 -0
  42. package/dist/entry-helpers.d.ts +7 -29
  43. package/dist/environments/held-runs.d.ts +93 -1
  44. package/dist/firecracker/host-network.d.ts +83 -0
  45. package/dist/firecracker/persist.d.ts +14 -0
  46. package/dist/index.js +25 -6
  47. package/dist/metrics/prometheus.d.ts +4 -2
  48. package/dist/orchestrator-core.d.ts +57 -1
  49. package/dist/pipeline/dispatch-matched-workflow.d.ts +18 -1
  50. package/dist/pipeline/install-secrets-resolver.d.ts +32 -5
  51. package/dist/pipeline/needs-scheduler.d.ts +12 -10
  52. package/dist/pipeline/pending-workflow-context.d.ts +44 -0
  53. package/dist/pipeline/processor.d.ts +28 -4
  54. package/dist/pipeline/remote-source-store.d.ts +21 -0
  55. package/dist/pipeline/resume-workflow.d.ts +26 -0
  56. package/dist/providers/local/index.d.ts +33 -0
  57. package/dist/providers/local/local-source-config.d.ts +17 -0
  58. package/dist/providers/{internal → local}/lock-file-fetcher.d.ts +6 -6
  59. package/dist/providers/{internal → local}/normalizer.d.ts +28 -28
  60. package/dist/providers/{internal → local}/repo-url-builder.d.ts +6 -6
  61. package/dist/reporting/execution-tracker.d.ts +33 -0
  62. package/dist/routes/admin-events.d.ts +3 -4
  63. package/dist/routes/fleet.d.ts +20 -0
  64. package/dist/routes/uploads.d.ts +36 -26
  65. package/dist/scaler/config.d.ts +4 -2
  66. package/dist/scaler/disk-guard.d.ts +27 -0
  67. package/dist/scaler/firecracker-backend.d.ts +18 -0
  68. package/dist/scaler/manager.d.ts +6 -0
  69. package/dist/scaler/nftables.d.ts +4 -0
  70. package/dist/scaler/reap-orphans.d.ts +27 -0
  71. package/dist/scaler/types.d.ts +2 -0
  72. package/dist/server.js +26929 -23511
  73. package/dist/sources/build-platform-sources.d.ts +4 -2
  74. package/dist/stale-detector/stale-run-detector.d.ts +32 -1
  75. package/dist/standalone.js +16941 -15329
  76. package/dist/storage/filesystem.d.ts +2 -1
  77. package/dist/storage/s3.d.ts +2 -1
  78. package/dist/storage/types.d.ts +7 -0
  79. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  80. package/dist/webhook/generic-sources.d.ts +37 -11
  81. package/dist/webhook/register-source-bundle.d.ts +14 -4
  82. package/dist/ws/agent-handler.d.ts +49 -0
  83. package/dist/ws/dashboard-dispatch-guard.d.ts +21 -0
  84. package/dist/ws/dashboard-env-handler.d.ts +47 -0
  85. package/dist/ws/fleet-agent-collector.d.ts +23 -0
  86. package/dist/ws/oidc-token-relay.d.ts +59 -0
  87. package/dist/ws/platform-client.d.ts +30 -1
  88. package/dist/ws/test-relay-handlers.d.ts +112 -0
  89. package/installer-image-digests.json +7 -0
  90. package/package.json +6 -5
  91. package/sbom.spdx.json +112 -57
  92. package/dist/providers/internal/index.d.ts +0 -32
  93. package/dist/routes/test-trigger.d.ts +0 -41
  94. package/dist/ws/observer-handler.d.ts +0 -42
@@ -1,38 +1,48 @@
1
1
  /**
2
- * REST endpoints for test run upload management.
2
+ * Test-run upload provisioning.
3
3
  *
4
- * POST /api/v1/uploads/init - Initialize an upload (returns signed URL + public key)
5
- * GET /api/v1/uploads/:uploadId/status - Check upload status
6
- *
7
- * Uploads support the repo state transfer mechanism: CLI uploads an encrypted
8
- * tarball of changed files to S3 via a pre-signed URL, then references the
9
- * upload ID in the test trigger request.
4
+ * Mints an upload record and a presigned PUT URL + ephemeral X25519 public key
5
+ * for the overlay tarball. The developer encrypts the tarball with the returned
6
+ * public key and PUTs it directly to the object store; a test trigger then
7
+ * references the upload id. This is invoked by the Platform-first
8
+ * `test.relay.uploads.init` relay handler the developer never reaches the
9
+ * orchestrator's HTTP API directly.
10
10
  */
11
- import { Hono } from 'hono';
12
- import type { AppConfig } from '../config.js';
13
- import type { TokenManager } from '../secrets/token-manager.js';
14
11
  import type { Kysely } from 'kysely';
15
12
  import type { Database } from '../db/types.js';
16
13
  import type { CacheStorage } from '../storage/types.js';
17
- /**
18
- * Dependencies for upload routes.
19
- */
20
- export interface UploadRouteDeps {
21
- config: AppConfig;
14
+ /** Parameters for {@link initTestUpload}. */
15
+ export interface InitTestUploadParams {
16
+ routingKey: string;
17
+ sha?: string;
18
+ fileCount?: number;
19
+ compressedSize?: number;
20
+ /** PAT/actor identity that owns this upload, written to `test_uploads.created_by`. */
21
+ createdBy?: string | null;
22
+ /**
23
+ * When true, presign with the host-facing internal endpoint. When false (the
24
+ * Platform-relayed path), presign with the external/dev-reachable endpoint so
25
+ * a developer on a different network can PUT directly to the object store.
26
+ */
27
+ internal?: boolean;
28
+ }
29
+ /** Result of {@link initTestUpload}. */
30
+ export interface InitTestUploadResult {
31
+ uploadId: string;
32
+ signedUrl: string;
33
+ publicKey: string;
34
+ expiresIn: number;
35
+ }
36
+ /** Dependencies for {@link initTestUpload}. */
37
+ export interface InitTestUploadDeps {
22
38
  db: Kysely<Database>;
23
- tokenManager?: TokenManager;
24
39
  cacheStorage?: CacheStorage;
25
40
  }
26
- /** Hono env type for upload routes with context variables. */
27
- type UploadEnv = {
28
- Variables: {
29
- userId: string;
30
- routingKey: string | null;
31
- };
32
- };
33
41
  /**
34
- * Create Hono routes for upload management endpoints.
42
+ * Mint an upload record and return a presigned PUT URL + ephemeral X25519
43
+ * public key. The encryption keypair is generated per upload; the private key
44
+ * is stored orchestrator-side for post-PUT decryption. The `internal` flag
45
+ * selects the host-facing vs the external/dev-reachable presign endpoint.
35
46
  */
36
- export declare function createUploadRoutes(deps: UploadRouteDeps): Hono<UploadEnv>;
37
- export {};
47
+ export declare function initTestUpload(deps: InitTestUploadDeps, params: InitTestUploadParams): Promise<InitTestUploadResult>;
38
48
  //# sourceMappingURL=uploads.d.ts.map
@@ -89,6 +89,7 @@ export declare const firecrackerNetworkSchema: z.ZodObject<{
89
89
  bridgeName: z.ZodDefault<z.ZodString>;
90
90
  gateway: z.ZodDefault<z.ZodString>;
91
91
  netmask: z.ZodDefault<z.ZodString>;
92
+ table: z.ZodDefault<z.ZodString>;
92
93
  }, z.core.$strip>;
93
94
  /**
94
95
  * Zod schema for the complete scaler configuration file.
@@ -241,10 +242,10 @@ export declare const scalerFileSchema: z.ZodObject<{
241
242
  }, z.core.$strip>>;
242
243
  mandatoryLabels: z.ZodDefault<z.ZodArray<z.ZodString>>;
243
244
  roles: z.ZodPipe<z.ZodOptional<z.ZodArray<z.ZodEnum<{
245
+ all: "all";
244
246
  builder: "builder";
245
247
  "init-runner": "init-runner";
246
- all: "all";
247
- }>>>, z.ZodTransform<string[] | undefined, ("builder" | "init-runner" | "all")[] | undefined>>;
248
+ }>>>, z.ZodTransform<string[] | undefined, ("all" | "builder" | "init-runner")[] | undefined>>;
248
249
  resourceCap: z.ZodOptional<z.ZodPipe<z.ZodObject<{
249
250
  maxCpu: z.ZodOptional<z.ZodNumber>;
250
251
  maxMemory: z.ZodOptional<z.ZodString>;
@@ -272,6 +273,7 @@ export declare const scalerFileSchema: z.ZodObject<{
272
273
  bridgeName: z.ZodDefault<z.ZodString>;
273
274
  gateway: z.ZodDefault<z.ZodString>;
274
275
  netmask: z.ZodDefault<z.ZodString>;
276
+ table: z.ZodDefault<z.ZodString>;
275
277
  }, z.core.$strip>>;
276
278
  }, z.core.$strip>;
277
279
  /**
@@ -0,0 +1,27 @@
1
+ import { type ReapCounts } from './reap-orphans.js';
2
+ import type { ScalerConfig } from './index.js';
3
+ /** Default minimum free space before startup is allowed to proceed: 1 GiB. */
4
+ export declare const DEFAULT_DISK_GUARD_THRESHOLD_BYTES: number;
5
+ export interface DiskGuardResult {
6
+ reaped: boolean;
7
+ recovered: boolean;
8
+ freeBytesAfter: number;
9
+ }
10
+ interface DiskGuardOpts {
11
+ scalerConfig: ScalerConfig;
12
+ thresholdBytes?: number;
13
+ /** Injectable for tests. */
14
+ statfsFn?: (path: string) => Promise<{
15
+ bavail: bigint;
16
+ bsize: number;
17
+ }>;
18
+ reapFn?: (cfg: ScalerConfig) => Promise<ReapCounts>;
19
+ }
20
+ /**
21
+ * Run the disk guard. Returns reaped/recovered status; the caller decides
22
+ * whether to proceed or exit with backoff. No-ops (recovered=true) when there
23
+ * is no FC scaler or free space is already above threshold.
24
+ */
25
+ export declare function runDiskGuard(opts: DiskGuardOpts): Promise<DiskGuardResult>;
26
+ export {};
27
+ //# sourceMappingURL=disk-guard.d.ts.map
@@ -61,10 +61,14 @@ export interface FirecrackerScalerBackendOptions {
61
61
  memSizeMib?: number;
62
62
  /** Bridge interface name for TAP attachment */
63
63
  bridgeName: string;
64
+ /** Network CIDR (e.g. '10.0.0.0/24'); supplies the prefix for the bridge gateway CIDR. */
65
+ cidr?: string;
64
66
  /** Gateway IP for guest networking */
65
67
  gateway: string;
66
68
  /** Netmask for guest networking */
67
69
  netmask: string;
70
+ /** nft table name for host-network diagnostics. @default 'kici' */
71
+ table?: string;
68
72
  /** Token store for creating ephemeral agent auth tokens. Optional -- when undefined, no token is injected. */
69
73
  tokenStore?: AgentTokenStore;
70
74
  /** TTL for ephemeral agent tokens in ms. Default: 1 hour. */
@@ -99,8 +103,10 @@ export declare class FirecrackerScalerBackend implements ScalerBackend {
99
103
  private readonly vcpuCount;
100
104
  private readonly memSizeMib;
101
105
  private readonly bridgeName;
106
+ private readonly cidr;
102
107
  private readonly gateway;
103
108
  private readonly netmask;
109
+ private readonly table;
104
110
  private readonly tokenStore?;
105
111
  private readonly tokenTtlMs;
106
112
  private readonly roles;
@@ -120,6 +126,18 @@ export declare class FirecrackerScalerBackend implements ScalerBackend {
120
126
  getActiveCount(): number;
121
127
  spawn(labelSet: string[], agentId: string, orchestratorUrl: string, onEvent?: ScalerEventCallback, effectiveLimits?: EffectiveLimits): Promise<ManagedAgent>;
122
128
  getScalerContext(agentId: string): Record<string, unknown> | undefined;
129
+ /**
130
+ * Bridge config for host-network diagnostics (read-only snapshot).
131
+ * `bridgeCidr` is the gateway IP with the network prefix (e.g. '10.0.0.1/24'),
132
+ * which is exactly what `provisionBridge`/`verifyBridge` consume. The prefix
133
+ * comes from the configured network `cidr`; if absent, it is derived from the
134
+ * dotted `netmask`.
135
+ */
136
+ getBridgeConfig(): {
137
+ bridgeName: string;
138
+ bridgeCidr: string;
139
+ table: string;
140
+ };
123
141
  destroy(managedId: string): Promise<void>;
124
142
  shutdownAll(): Promise<void>;
125
143
  /**
@@ -336,6 +336,12 @@ export declare class ScalerManager {
336
336
  * Returns null if the agent is not scaler-managed (standalone).
337
337
  */
338
338
  getBackendForAgent(agentId: string): string | null;
339
+ /**
340
+ * Get a backend instance by scaler name. Returns undefined for an unknown
341
+ * name. Used by diagnostics to reach backend-specific accessors (e.g. the
342
+ * Firecracker backend's `getBridgeConfig()`).
343
+ */
344
+ getBackend(name: string): ScalerBackend | undefined;
339
345
  /**
340
346
  * Get scaler-specific configuration metadata for a managed agent.
341
347
  * Returns undefined for non-scaler-managed (static) agents.
@@ -17,6 +17,10 @@ import type { NetworkPolicy } from './types.js';
17
17
  * - 'saddr': Match on source IP address (container backends)
18
18
  */
19
19
  export type NftMatchMode = 'iifname' | 'saddr';
20
+ /** RFC1918 private address ranges. */
21
+ export declare const RFC1918_RANGES: string[];
22
+ /** Cloud metadata service range (AWS/GCP/Azure link-local). */
23
+ export declare const METADATA_RANGE = "169.254.0.0/16";
20
24
  /**
21
25
  * Options for nft command execution.
22
26
  */
@@ -0,0 +1,27 @@
1
+ import type { ScalerConfig } from './index.js';
2
+ /** Per-scaler orphan counts, keyed by scaler name. */
3
+ export type ReapCounts = Record<string, number>;
4
+ /**
5
+ * Reap orphan Firecracker resources (dead-VM chroots + TAPs) for every
6
+ * `firecracker` scaler in the config. Safe to run alongside a live
7
+ * orchestrator: the reap is liveness-driven and only touches dead VMs.
8
+ */
9
+ export declare function reapFirecrackerOrphans(scalerConfig: ScalerConfig): Promise<ReapCounts>;
10
+ /**
11
+ * Reap orphan container resources for every `container` scaler. Unlike the FC
12
+ * reap, container cleanup is unconditional (it removes every kici-managed
13
+ * container), so callers MUST ensure the orchestrator is NOT running before
14
+ * invoking this — otherwise live agents are killed. The CLI command enforces
15
+ * this via the /health gate.
16
+ */
17
+ export declare function reapContainerOrphans(scalerConfig: ScalerConfig): Promise<ReapCounts>;
18
+ /**
19
+ * Reap orphans for all supported backends. Firecracker is always reaped
20
+ * (liveness-driven, safe). Containers are reaped only when includeContainers
21
+ * is set (caller has confirmed the orchestrator is down).
22
+ */
23
+ export declare function reapAllOrphans(opts: {
24
+ scalerConfig: ScalerConfig;
25
+ includeContainers: boolean;
26
+ }): Promise<ReapCounts>;
27
+ //# sourceMappingURL=reap-orphans.d.ts.map
@@ -248,6 +248,8 @@ export interface FirecrackerNetworkConfig {
248
248
  gateway?: string;
249
249
  /** Subnet mask for guest networking @default '255.255.255.0' */
250
250
  netmask?: string;
251
+ /** nft table name for this coordinator's host bridge @default 'kici' */
252
+ table?: string;
251
253
  }
252
254
  /**
253
255
  * Parsed and validated scaler configuration from YAML.