@kici-dev/orchestrator 0.1.26 → 0.1.27

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 (83) hide show
  1. package/dist/app.d.ts +13 -4
  2. package/dist/approvals/apply-decision.d.ts +1 -1
  3. package/dist/approvals/step-approval-bridge.d.ts +1 -1
  4. package/dist/cache/pending-inits.d.ts +4 -4
  5. package/dist/cli/api-client.d.ts +29 -4
  6. package/dist/cli/commands/context.d.ts +25 -0
  7. package/dist/cli/commands/debug-bundle.d.ts +1 -1
  8. package/dist/cli/commands/variable.d.ts +6 -6
  9. package/dist/cli/service/windows.d.ts +6 -0
  10. package/dist/cli.js +526 -340
  11. package/dist/config.d.ts +16 -0
  12. package/dist/contexts/binding-store.d.ts +36 -0
  13. package/dist/contexts/context-store.d.ts +87 -0
  14. package/dist/{environments → contexts}/held-runs.d.ts +15 -15
  15. package/dist/{environments → contexts}/index.d.ts +1 -1
  16. package/dist/contexts/protection/aggregate.d.ts +43 -0
  17. package/dist/contexts/protection/branch-gate.d.ts +5 -0
  18. package/dist/contexts/protection/concurrency-gate.d.ts +7 -0
  19. package/dist/{environments → contexts}/protection/pipeline.d.ts +3 -3
  20. package/dist/contexts/protection/reviewer-gate.d.ts +7 -0
  21. package/dist/{environments → contexts}/protection/satisfiability.d.ts +21 -21
  22. package/dist/contexts/protection/trust-gate.d.ts +7 -0
  23. package/dist/contexts/protection/wait-timer-gate.d.ts +7 -0
  24. package/dist/contexts/variable-store.d.ts +39 -0
  25. package/dist/dashboard/attestation-filters.d.ts +10 -8
  26. package/dist/dashboard/handler.d.ts +28 -2
  27. package/dist/db/migrations/067_environments_to_contexts.d.ts +36 -0
  28. package/dist/db/migrations/068_request_idempotency.d.ts +17 -0
  29. package/dist/db/types.d.ts +78 -59
  30. package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +1 -1
  31. package/dist/index.js +21 -6
  32. package/dist/metrics/prometheus.d.ts +2 -0
  33. package/dist/oidc/id-token-claims.d.ts +63 -0
  34. package/dist/oidc/jwt.d.ts +15 -0
  35. package/dist/oidc/local-dev-signer.d.ts +31 -0
  36. package/dist/oidc/local-mint.d.ts +77 -0
  37. package/dist/oidc/oidc-mint-registration.d.ts +49 -0
  38. package/dist/pipeline/decorating-secret-resolver.d.ts +4 -4
  39. package/dist/pipeline/dispatch-matched-workflow.d.ts +3 -3
  40. package/dist/pipeline/inline-eval.d.ts +2 -2
  41. package/dist/pipeline/install-secrets-resolver.d.ts +13 -13
  42. package/dist/pipeline/{job-environments.d.ts → job-contexts.d.ts} +23 -23
  43. package/dist/pipeline/manual-schedule.d.ts +8 -1
  44. package/dist/pipeline/processor.d.ts +6 -6
  45. package/dist/pipeline/request-idempotency.d.ts +28 -0
  46. package/dist/pipeline/rerun.d.ts +8 -0
  47. package/dist/pipeline/resume-workflow.d.ts +1 -1
  48. package/dist/pipeline/test-pipeline.d.ts +2 -2
  49. package/dist/provenance/trust-root.d.ts +7 -0
  50. package/dist/provider-registry.d.ts +8 -0
  51. package/dist/providers/local/index.d.ts +1 -0
  52. package/dist/providers/local/local-source-config.d.ts +1 -0
  53. package/dist/reporting/execution-tracker.d.ts +17 -7
  54. package/dist/reporting/run-aggregator.d.ts +5 -5
  55. package/dist/routes/admin-contexts.d.ts +47 -0
  56. package/dist/routes/admin-registrations.d.ts +2 -2
  57. package/dist/routes/github-webhook.d.ts +2 -2
  58. package/dist/secrets/context-secret-resolver.d.ts +30 -0
  59. package/dist/secrets/index.d.ts +1 -1
  60. package/dist/secrets/pg-secret-store.d.ts +3 -3
  61. package/dist/secrets/rbac.d.ts +1 -1
  62. package/dist/secrets/secret-resolver.d.ts +19 -19
  63. package/dist/security/comment-handler.d.ts +1 -1
  64. package/dist/server.js +1770 -1196
  65. package/dist/stale-detector/stale-run-detector.d.ts +1 -1
  66. package/dist/standalone.js +1649 -747
  67. package/dist/storage/blob-routes.d.ts +16 -0
  68. package/dist/ws/{dashboard-env-handler.d.ts → dashboard-context-handler.d.ts} +15 -15
  69. package/dist/ws/oidc-token-relay.d.ts +6 -0
  70. package/installer-image-digests.json +3 -3
  71. package/package.json +4 -4
  72. package/sbom.spdx.json +50 -50
  73. package/dist/cli/commands/environment.d.ts +0 -25
  74. package/dist/environments/binding-store.d.ts +0 -36
  75. package/dist/environments/environment-store.d.ts +0 -87
  76. package/dist/environments/protection/aggregate.d.ts +0 -43
  77. package/dist/environments/protection/branch-gate.d.ts +0 -5
  78. package/dist/environments/protection/concurrency-gate.d.ts +0 -7
  79. package/dist/environments/protection/reviewer-gate.d.ts +0 -7
  80. package/dist/environments/protection/trust-gate.d.ts +0 -7
  81. package/dist/environments/protection/wait-timer-gate.d.ts +0 -7
  82. package/dist/environments/variable-store.d.ts +0 -39
  83. package/dist/routes/admin-environments.d.ts +0 -47
package/dist/app.d.ts CHANGED
@@ -38,6 +38,7 @@ import type { PendingInitTracker } from './cache/index.js';
38
38
  import type { PendingDynamicTracker } from './cache/index.js';
39
39
  import type { CacheStorage } from './storage/types.js';
40
40
  import type { ProvenanceTrustRoot } from './provenance/trust-root.js';
41
+ import type { LocalSigner } from './oidc/local-dev-signer.js';
41
42
  import { type CheckRunReporter } from './reporting/check-run-reporter.js';
42
43
  import type { ExecutionTracker } from './reporting/execution-tracker.js';
43
44
  import type { LogWriter } from './reporting/log-writer.js';
@@ -71,9 +72,9 @@ import type { EventLogWriter } from './webhook/event-log.js';
71
72
  import type { AccessLogWriter } from './audit/access-log.js';
72
73
  import type { GenericSourceManager } from './webhook/generic-sources.js';
73
74
  import type { TrustStore } from './events/trust-store.js';
74
- import type { EnvironmentStore } from './environments/environment-store.js';
75
- import type { VariableStore } from './environments/variable-store.js';
76
- import type { HeldRunStore } from './environments/held-runs.js';
75
+ import type { ContextStore } from './contexts/context-store.js';
76
+ import type { VariableStore } from './contexts/variable-store.js';
77
+ import type { HeldRunStore } from './contexts/held-runs.js';
77
78
  import type { StepApprovalBridge } from './approvals/step-approval-bridge.js';
78
79
  import type { ContributorCache } from './security/contributor-cache.js';
79
80
  import { AgentMetricsAggregator } from './metrics/agent-metrics-aggregator.js';
@@ -132,6 +133,13 @@ export interface AppDependencies {
132
133
  cacheStorage?: CacheStorage;
133
134
  /** Provenance trust root used to verify build-provenance bundles at ingest. */
134
135
  provenanceTrustRoot?: ProvenanceTrustRoot;
136
+ /**
137
+ * In-process dev-signed identity signer for the offline local dev plane.
138
+ * Present ONLY in independent mode with KICI_INDEPENDENT_IDENTITY=1. When set
139
+ * (and NOT Platform-connected), the local mint path for `OIDC_TOKEN_REQUEST_METHOD`
140
+ * is registered so `ctx.kici.oidc.token()` mints a `kici-local` dev token.
141
+ */
142
+ localOidcSigner?: LocalSigner;
135
143
  /**
136
144
  * Filesystem cache backend handle. Only set when KICI_STORAGE_TYPE is
137
145
  * `filesystem`. Drives the /api/v1/cache/blob/* HTTP route that serves and
@@ -141,6 +149,7 @@ export interface AppDependencies {
141
149
  basePath: string;
142
150
  signingSecret: string;
143
151
  ttlMs: number;
152
+ maxUploadBytes: number;
144
153
  };
145
154
  /** Pending build tracker for build-then-execute coordination. Optional — requires bundle cache. */
146
155
  pendingBuilds?: PendingBuildTracker;
@@ -208,7 +217,7 @@ export interface AppDependencies {
208
217
  /** Registration index for admin registration routes. Optional -- mounted when registration system is initialized. */
209
218
  registrationIndex?: RegistrationIndex;
210
219
  /** Environment store for resolving environment configs. Optional -- if not set, environment resolution is inactive. */
211
- environmentStore?: EnvironmentStore;
220
+ contextStore?: ContextStore;
212
221
  /** Variable store for resolving environment variables. Optional -- if not set, environment vars are not merged. */
213
222
  variableStore?: VariableStore;
214
223
  /** Held run store for persisting protection rule holds. Optional -- if not set, holds are not persisted. */
@@ -15,7 +15,7 @@
15
15
  * A reject records the decision and `reject()`s the hold (failing the element).
16
16
  */
17
17
  import { ApprovalDecision } from '@kici-dev/engine';
18
- import type { HeldRunStore, ReleaseSignal } from '../environments/held-runs.js';
18
+ import type { HeldRunStore, ReleaseSignal } from '../contexts/held-runs.js';
19
19
  import { type TeamMembershipLookup } from './approval-resolver.js';
20
20
  /** Outcome of applying a decision. */
21
21
  export interface ApplyDecisionResult {
@@ -1,4 +1,4 @@
1
- import type { HeldRunStore } from '../environments/held-runs.js';
1
+ import type { HeldRunStore } from '../contexts/held-runs.js';
2
2
  import type { AccessLogWriter } from '../audit/access-log.js';
3
3
  /** Outcome relayed back to the waiting agent. */
4
4
  export type StepApprovalOutcome = 'approved' | 'rejected' | 'expired';
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Pending init tracker for coordinating init-then-execute pipeline.
3
3
  *
4
- * The orchestrator dispatches an init job for dynamic environment resolution
4
+ * The orchestrator dispatches an init job for dynamic context resolution
5
5
  * and waits for the agent to return the resolved field values
6
- * (environmentNames, env, concurrencyGroup). The underlying tracker logic lives
6
+ * (contextNames, env, concurrencyGroup). The underlying tracker logic lives
7
7
  * in `PendingTracker<InitResult>`; this subclass wires the init-specific
8
8
  * logger prefix and disconnect error.
9
9
  */
10
10
  import { PendingTracker } from './pending-tracker.js';
11
11
  export interface InitResult {
12
- /** Resolved bound-environment names, in merge order (one per `environments` element). */
13
- environmentNames?: string[];
12
+ /** Resolved bound-context names, in merge order (one per `contexts` element). */
13
+ contextNames?: string[];
14
14
  env?: Record<string, string>;
15
15
  concurrencyGroup?: string;
16
16
  /**
@@ -26,12 +26,15 @@ export interface FleetTopologyResponse {
26
26
  */
27
27
  export type GenericSourceGitConfigPayload = Record<string, unknown>;
28
28
  /**
29
- * Wire shape for a local filesystem source's config (`{ repoBasePath, cloneUrlBase? }`).
29
+ * Wire shape for a local filesystem source's config
30
+ * (`{ repoBasePath, cloneUrlBase?, inPlace? }`).
30
31
  * Matches `LocalSourceConfigSchema` in `providers/local/local-source-config.ts`.
31
32
  */
32
33
  export interface GenericSourceLocalConfigPayload {
33
34
  repoBasePath: string;
34
35
  cloneUrlBase?: string;
36
+ /** In-place profile: the repoBasePath is the operator's real working tree. */
37
+ inPlace?: boolean;
35
38
  }
36
39
  /**
37
40
  * Response shape for generic webhook sources from the admin API.
@@ -111,7 +114,29 @@ export declare class AdminApiClient {
111
114
  }>;
112
115
  setSecret(orgId: string, scope: string, key: string, value: string): Promise<void>;
113
116
  deleteSecret(orgId: string, scope: string, key: string): Promise<void>;
114
- listVariables(orgId: string, environment: string): Promise<{
117
+ /**
118
+ * Create (or upsert) a deployment context. `allowLocalExecution` lets
119
+ * CLI-initiated / local runs resolve secrets through this context.
120
+ */
121
+ createContext(data: {
122
+ orgId: string;
123
+ name: string;
124
+ allowLocalExecution?: boolean;
125
+ }): Promise<{
126
+ envId: string;
127
+ created: boolean;
128
+ }>;
129
+ /**
130
+ * Bind a scope pattern to a context so its scoped secrets resolve at dispatch.
131
+ * `hostPattern` defaults to `**` (every host) server-side.
132
+ */
133
+ bindContext(data: {
134
+ orgId: string;
135
+ name: string;
136
+ scopePattern: string;
137
+ hostPattern?: string;
138
+ }): Promise<unknown>;
139
+ listVariables(orgId: string, context: string): Promise<{
115
140
  variables: Array<{
116
141
  key: string;
117
142
  value: string;
@@ -119,8 +144,8 @@ export declare class AdminApiClient {
119
144
  updated_at: string;
120
145
  }>;
121
146
  }>;
122
- setVariable(orgId: string, environment: string, key: string, value: string, locked?: boolean): Promise<void>;
123
- deleteVariable(orgId: string, environment: string, key: string): Promise<void>;
147
+ setVariable(orgId: string, context: string, key: string, value: string, locked?: boolean): Promise<void>;
148
+ deleteVariable(orgId: string, context: string, key: string): Promise<void>;
124
149
  rotateKey(): Promise<{
125
150
  reEncrypted: number;
126
151
  reEncryptedConfigs: number;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Context management CLI commands for kici-admin.
3
+ *
4
+ * context create — upsert a context
5
+ * context bind — bind a scope pattern to a context
6
+ * context set-policy — update policy fields (branch, reviewers, timers, trust)
7
+ * context list — list contexts for an org
8
+ * context show — show a single context with variables + bindings
9
+ * context delete — delete a context (cascades bindings, variables, overrides; held-run history survives; pending held runs block with a clear error, resolved holds do not)
10
+ * context create-template — create/update a context template + its seed variables
11
+ *
12
+ * Each command supports two modes (stage-4 pattern from `maintenance.ts`):
13
+ *
14
+ * HTTP mode (default): requires `--url` + `--token`, routes through the
15
+ * orchestrator admin HTTP API at /api/v1/admin/contexts.
16
+ *
17
+ * Direct-DB mode: activated when `--database-url` is passed (or
18
+ * KICI_DATABASE_URL / DATABASE_URL is set). Opens its own pool and runs the
19
+ * SQL directly via *Direct helpers in @kici-dev/shared. Used by E2E
20
+ * `globalSetup` helpers that need to seed envs before the orchestrator is up.
21
+ */
22
+ import type { Command } from 'commander';
23
+ import type { AdminApiClient } from '../api-client.js';
24
+ export declare function registerContextCommands(program: Command, getClient: () => AdminApiClient): void;
25
+ //# sourceMappingURL=context.d.ts.map
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Usage: kici-admin debug-bundle [--output <path>]
9
9
  */
10
- import type { Command } from 'commander';
10
+ import { type Command } from 'commander';
11
11
  import type { AdminApiClient } from '../api-client.js';
12
12
  /**
13
13
  * Register the debug-bundle command on the CLI program.
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Environment variable management commands for kici-admin.
2
+ * Context variable management commands for kici-admin.
3
3
  *
4
- * kici-admin variable list <orgId> <environment>
5
- * kici-admin variable get <orgId> <environment> <key>
6
- * kici-admin variable set <orgId> <environment> <key> [--value | --from-stdin | --from-file | --from-env | --prompt]
7
- * kici-admin variable delete <orgId> <environment> <key>
4
+ * kici-admin variable list <orgId> <context>
5
+ * kici-admin variable get <orgId> <context> <key>
6
+ * kici-admin variable set <orgId> <context> <key> [--value | --from-stdin | --from-file | --from-env | --prompt]
7
+ * kici-admin variable delete <orgId> <context> <key>
8
8
  *
9
- * Org-level environment variables are plaintext-at-rest in the
9
+ * Org-level context variables are plaintext-at-rest in the
10
10
  * orchestrator's DB; the dashboard write path is gated by the
11
11
  * `variables.set` / `variables.delete` switches in the dashboard-write
12
12
  * policy. This CLI is the always-available authority path when the
@@ -8,6 +8,12 @@
8
8
  */
9
9
  import type { ServiceManager, ServiceConfig, ServiceStatus, LogOptions, DiscoveredInstance, LaunchSpec } from './types.js';
10
10
  export declare class WindowsServiceManager implements ServiceManager {
11
+ /**
12
+ * Check whether a Windows service is currently registered.
13
+ * `sc.exe query` exits non-zero (execSync throws) when the service does
14
+ * not exist; exit 0 means it exists (possibly pending-delete).
15
+ */
16
+ private serviceExists;
11
17
  install(config: ServiceConfig): Promise<void>;
12
18
  uninstall(config: ServiceConfig): Promise<void>;
13
19
  start(config: ServiceConfig): Promise<void>;