@ship.zone/runner 0.2.4 → 1.0.0

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_npm/mod.d.ts CHANGED
@@ -83,19 +83,26 @@ export declare class LeaseLostError extends CoordinatorError { constructor(messa
83
83
  }
84
84
  export declare class ProtocolError extends CoordinatorError { constructor(message: string, options?: ErrorOptions);
85
85
  }
86
+ /**
87
+ * An archive prepared for publication contains a member of the attempt's redaction set in an entry
88
+ * path, a link target, or file content. The archive is never published.
89
+ */
90
+ export declare class SecretDisclosureError extends RunnerError { constructor(message?: string);
91
+ }
86
92
  export declare const runnerVersion: string;
87
- export declare const runnerProtocolIdentifier: 'foss-ci-runner/2.0-draft.2';
88
- export type TRunnerProtocolIdentifier = typeof runnerProtocolIdentifier;
89
- export type TExecutionProfile = 'oci.v1';
90
- export type TRunnerFeature = 'source.tar-gz' | 'artifacts.v1' | 'caches.v1';
91
- export type TJobNetwork = 'none' | 'bridge';
93
+ export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
94
+ export type TIsolation = 'container' | 'microvm';
95
+ export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
96
+ export type TNetworkMode = 'none' | 'egress';
92
97
  export type TSourceFormat = 'tar.gz';
93
98
  export type TOciRuntime = 'docker' | 'podman';
94
99
  export type TArtifactPermission = 'none' | 'write';
95
100
  export type TCachePermission = 'none' | 'read' | 'read-write';
101
+ export type TImagePermission = 'none' | 'push';
96
102
  export type TCacheAccess = 'read' | 'read-write';
97
103
  export type TArtifactWhen = 'always' | 'success' | 'failure';
98
104
  export type TLogStream = 'stdout' | 'stderr' | 'runner';
105
+ export type TImageGrantAccess = 'pull' | 'push';
99
106
  export type TJobCompletionStatus = 'succeeded' | 'failed' | 'canceled' | 'timed_out' | 'system_error';
100
107
  export type TCancellationReason = 'user_requested' | 'superseded' | 'policy' | 'coordinator_shutdown';
101
108
  export type TAbandonReason = 'runner_shutdown' | 'runner_error';
@@ -110,8 +117,8 @@ export interface IProtocolLimits { maximumJsonBytes: number;
110
117
  minimumLeaseSeconds: number;
111
118
  maximumLeaseSeconds: number;
112
119
  }
113
- export interface IDiscoveryResponse { protocol: TRunnerProtocolIdentifier;
114
- basePath: '/api/runner/v2';
120
+ export interface IDiscoveryResponse { spec: string;
121
+ basePath: '/api/runner';
115
122
  status: 'draft';
116
123
  serverTime: string;
117
124
  limits: IProtocolLimits;
@@ -138,32 +145,40 @@ export interface ITransferLimits { maximumSourceArchiveBytes: number;
138
145
  maximumWorkspaceBytes: number;
139
146
  maximumWorkspaceEntries: number;
140
147
  }
148
+ export interface IResourceLimits { maximumMemoryBytes: number;
149
+ maximumCpus: number;
150
+ maximumPids: number;
151
+ maximumSharedMemoryBytes: number;
152
+ }
141
153
  export interface IRunnerCapabilities { executionProfiles: TExecutionProfile[];
154
+ isolation: TIsolation[];
155
+ platforms: string[];
142
156
  labels: string[];
143
157
  features: TRunnerFeature[];
144
- networks: TJobNetwork[];
158
+ networks: TNetworkMode[];
145
159
  sourceFormats: TSourceFormat[];
146
160
  limits: ITransferLimits;
161
+ resources?: IResourceLimits;
147
162
  }
148
163
  export interface IRegisterRunnerRequest { registrationRequestId: string;
149
- protocol: TRunnerProtocolIdentifier;
164
+ spec: string;
150
165
  runnerVersion: string;
151
166
  name: string;
152
167
  capabilities: IRunnerCapabilities;
153
168
  }
154
- export interface IRegisterRunnerResponse { protocol: TRunnerProtocolIdentifier;
169
+ export interface IRegisterRunnerResponse { spec: string;
155
170
  serverTime: string;
156
171
  registrationReplayUntil: string;
157
172
  credential: IRunnerCredential;
158
173
  }
159
174
  export interface IStartSessionRequest { sessionRequestId: string;
160
175
  runnerId: string;
161
- protocol: TRunnerProtocolIdentifier;
176
+ spec: string;
162
177
  runnerVersion: string;
163
178
  capabilities: IRunnerCapabilities;
164
179
  }
165
180
  export interface IStartSessionResponse { sessionId: string;
166
- protocol: TRunnerProtocolIdentifier;
181
+ spec: string;
167
182
  serverTime: string;
168
183
  credential?: IRunnerCredential;
169
184
  }
@@ -183,12 +198,44 @@ export interface IClaimJobResponse { serverTime: string;
183
198
  retryAfterMs?: number;
184
199
  lease: unknown | null;
185
200
  }
201
+ /** Attempt-scoped registry credential for one registry, repository, and access mode. */
202
+ export interface IImageGrant { grantId: string;
203
+ access: TImageGrantAccess;
204
+ registry: string;
205
+ repository: string;
206
+ username: string;
207
+ secret: string;
208
+ expiresAt: string;
209
+ }
210
+ /** Resolution of one candidate reference of the job to a digest-pinned image. */
211
+ export interface IImageBinding { candidate: string;
212
+ image: string;
213
+ }
214
+ /** Attempt-scoped read-only npm registry token for one `npmRead` entry of the job. */
215
+ export interface INpmGrant { grantId: string;
216
+ registry: string;
217
+ scopes: string[];
218
+ secret: string;
219
+ expiresAt: string;
220
+ }
221
+ /** A lease exactly as the protocol defines it, for every execution profile. */
186
222
  export interface IJobLease { jobId: string;
187
223
  attemptId: string;
188
224
  leaseId: string;
189
225
  fencingToken: string;
190
226
  leaseExpiresAt: string;
191
- job: ICompiledRunnerJob;
227
+ job: TCompiledRunnerJob;
228
+ grants: IImageGrant[];
229
+ bindings: IImageBinding[];
230
+ npmGrants?: INpmGrant[];
231
+ }
232
+ /**
233
+ * A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
234
+ * no image grants or bindings, and no npm grants.
235
+ */
236
+ export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> { job: IOciRunnerJob;
237
+ grants: [];
238
+ bindings: [];
192
239
  }
193
240
  export interface IJobIdentity { runnerId: string;
194
241
  sessionId: string;
@@ -258,6 +305,8 @@ export interface IErrorResponse { error: { code: string;
258
305
  };
259
306
  }
260
307
  export interface IJobRequirements { executionProfile: TExecutionProfile;
308
+ isolation: TIsolation;
309
+ platform?: string;
261
310
  labels: string[];
262
311
  features: TRunnerFeature[];
263
312
  limits: ITransferLimits;
@@ -265,13 +314,42 @@ export interface IJobRequirements { executionProfile: TExecutionProfile;
265
314
  export interface IJobPermissions { source: 'read';
266
315
  artifacts: TArtifactPermission;
267
316
  caches: TCachePermission;
268
- packages: 'none';
317
+ images: TImagePermission;
269
318
  }
270
- export interface IOciExecution { profile: 'oci.v1';
271
- image: string;
272
- network: TJobNetwork;
319
+ export interface IEgressRule { host: string;
320
+ ports: number[];
321
+ }
322
+ export interface INoNetwork { mode: 'none';
323
+ }
324
+ export interface IEgressNetwork { mode: 'egress';
325
+ allow: IEgressRule[];
326
+ }
327
+ export type TJobNetwork = INoNetwork | IEgressNetwork;
328
+ export interface ICandidateReference { candidate: string;
329
+ }
330
+ export type TImageReference = string | ICandidateReference;
331
+ export interface IOciExecution { profile: 'oci';
332
+ image: TImageReference;
273
333
  workingDirectory?: string;
274
334
  }
335
+ export interface IVmExecution { profile: 'vm';
336
+ image: TImageReference;
337
+ workingDirectory?: string;
338
+ }
339
+ export interface IBuildSecret { id: string;
340
+ environment: string;
341
+ }
342
+ export interface IBaseImage { name: string;
343
+ image: TImageReference;
344
+ }
345
+ export interface IImageBuild { context: string;
346
+ dockerfile: string;
347
+ target?: string;
348
+ buildArgs: Record<string, string>;
349
+ secrets: IBuildSecret[];
350
+ labels: Record<string, string>;
351
+ baseImages: IBaseImage[];
352
+ }
275
353
  export interface ICompiledStep { name?: string;
276
354
  command: string[];
277
355
  environment: Record<string, string>;
@@ -285,6 +363,10 @@ export interface IJobSource { format: 'tar.gz';
285
363
  export interface IJobResources { memoryBytes?: number;
286
364
  cpus?: number;
287
365
  pids?: number;
366
+ sharedMemoryBytes?: number;
367
+ }
368
+ export interface INpmReadEntry { registry: string;
369
+ scopes: string[];
288
370
  }
289
371
  export interface IArtifactDeclaration { name: string;
290
372
  path: string;
@@ -296,30 +378,56 @@ export interface IArtifactDeclaration { name: string;
296
378
  maximumEntries: number;
297
379
  retentionDays?: number;
298
380
  }
299
- export interface ICacheDeclaration { name: string;
381
+ export interface IBuildCacheDeclaration { name: string;
300
382
  key: string;
301
- paths: string[];
302
383
  access: TCacheAccess;
303
384
  maximumBytes: number;
304
385
  maximumExtractedBytes: number;
305
386
  maximumEntries: number;
306
387
  retentionDays?: number;
307
388
  }
308
- export interface ICompiledRunnerJob { specVersion: '2.0-draft.2';
389
+ export interface ICacheDeclaration extends IBuildCacheDeclaration { paths: string[];
390
+ }
391
+ interface ICompiledRunnerJobBase {
392
+ spec: string;
309
393
  sourceObjectId: string;
310
394
  workflowDigest: string;
311
395
  compiledPlanDigest: string;
312
396
  requirements: IJobRequirements;
313
397
  permissions: IJobPermissions;
314
- execution: IOciExecution;
315
- steps: ICompiledStep[];
398
+ network: TJobNetwork;
316
399
  source: IJobSource;
317
400
  secrets: Record<string, string>;
318
401
  timeoutMs: number;
319
402
  resources?: IJobResources;
403
+ npmRead?: INpmReadEntry[];
320
404
  artifacts: IArtifactDeclaration[];
405
+ }
406
+ /** A compiled `oci` job: ordered argument-array steps in fresh containers. */
407
+ export interface IContainerRunnerJob extends ICompiledRunnerJobBase { execution: IOciExecution;
408
+ steps: ICompiledStep[];
321
409
  caches: ICacheDeclaration[];
322
410
  }
411
+ /** A compiled `vm` job: ordered steps as root in one microVM guest per attempt. */
412
+ export interface IVmRunnerJob extends ICompiledRunnerJobBase { execution: IVmExecution;
413
+ steps: ICompiledStep[];
414
+ caches: ICacheDeclaration[];
415
+ }
416
+ /** A compiled `oci-image` job: one single-platform image build in a microVM guest. */
417
+ export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase { build: IImageBuild;
418
+ caches: IBuildCacheDeclaration[];
419
+ }
420
+ /** Every compiled job shape the published runner job schema admits. */
421
+ export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
422
+ /** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
423
+ export interface IOciRunnerJob extends IContainerRunnerJob { requirements: IJobRequirements & { executionProfile: 'oci';
424
+ isolation: 'container';
425
+ };
426
+ network: INoNetwork;
427
+ execution: IOciExecution & {
428
+ image: string;
429
+ };
430
+ }
323
431
  export interface ITransferMetadata { sha256: string;
324
432
  sizeBytes: number;
325
433
  extractedSizeBytes: number;
@@ -357,7 +465,7 @@ export interface IOciExecutorConfig { runtime: TOciRuntime;
357
465
  runtimePath: string;
358
466
  workspaceHelperPath?: string;
359
467
  requireRootless: boolean;
360
- allowedNetworks: TJobNetwork[];
468
+ allowedNetworks: TNetworkMode[];
361
469
  containerUser: string;
362
470
  defaultTimeoutMs: number;
363
471
  maximumTimeoutMs: number;
@@ -367,6 +475,8 @@ export interface IOciExecutorConfig { runtime: TOciRuntime;
367
475
  maximumCpus: number;
368
476
  defaultPids: number;
369
477
  maximumPids: number;
478
+ defaultSharedMemoryBytes: number;
479
+ maximumSharedMemoryBytes: number;
370
480
  workspaceSizeBytes: number;
371
481
  temporarySizeBytes: number;
372
482
  stopTimeoutSeconds: number;
@@ -398,9 +508,14 @@ export interface IRunnerConfig extends ITransferManagerConfig { controlPlaneUrl:
398
508
  }
399
509
  export interface IExecutionContext { runnerId: string;
400
510
  sessionId: string;
401
- lease: IJobLease;
511
+ lease: IOciJobLease;
402
512
  preparedLease: IPreparedOciLease;
403
513
  workspacePath: string;
514
+ /**
515
+ * Milliseconds left until the attempt deadline when execution starts: the job `timeoutMs`
516
+ * counted from the acceptance 204, less the time source extraction and cache restoration took.
517
+ */
518
+ timeoutMs: number;
404
519
  signal: AbortSignal;
405
520
  terminationDeadline?: () => number | undefined;
406
521
  onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
@@ -417,7 +532,7 @@ export interface IOciRuntimeFacts { readonly runtime: TOciRuntime;
417
532
  }
418
533
  export interface IPrepareOciLeaseContext { runnerId: string;
419
534
  sessionId: string;
420
- lease: IJobLease;
535
+ lease: IOciJobLease;
421
536
  signal: AbortSignal;
422
537
  }
423
538
  export interface IPreparedOciLease { readonly preparationId: string;
@@ -456,15 +571,24 @@ export interface IPreparedWorkspace { path: string;
456
571
  cleanup(): Promise<void>;
457
572
  }
458
573
  export interface ISourcePrepareContext { identity: IJobIdentity;
459
- job: Pick<ICompiledRunnerJob, 'source' | 'permissions' | 'requirements'>;
574
+ job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
460
575
  signal: AbortSignal;
461
576
  }
462
577
  export interface IRunnerRunResult { claimed: boolean;
463
578
  status?: TJobCompletionStatus;
464
579
  }
580
+ /** A streaming check of bytes against the attempt's redaction set. */
581
+ export interface ISecretContentMatcher { /** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */ push(bytes: Uint8Array): boolean;
582
+ }
583
+ /** The attempt's redaction set as the archive publication check consumes it. */
584
+ export interface ISecretRedactionSet { readonly empty: boolean;
585
+ occursIn(text: string): boolean;
586
+ createContentMatcher(): ISecretContentMatcher;
587
+ }
465
588
  export interface IArtifactUploadContext { workspace: IRuntimeWorkspaceExporter;
466
- job: Pick<ICompiledRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
589
+ job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
467
590
  status: TJobCompletionStatus;
591
+ redactionSet: ISecretRedactionSet;
468
592
  identity: IJobIdentity;
469
593
  signal: AbortSignal;
470
594
  }
@@ -472,19 +596,21 @@ export interface IArtifactManager { upload(context: IArtifactUploadContext): Pro
472
596
  }
473
597
  export interface ICacheRestoreContext { workspacePath: string;
474
598
  workspaceEntryCount: number;
475
- job: Pick<ICompiledRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
599
+ job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
476
600
  identity: IJobIdentity;
477
601
  signal: AbortSignal;
478
602
  }
479
603
  export interface ICacheSaveContext { workspace: IRuntimeWorkspaceExporter;
480
- job: Pick<ICompiledRunnerJob, 'caches' | 'permissions' | 'requirements'>;
604
+ job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
481
605
  status: TJobCompletionStatus;
606
+ redactionSet: ISecretRedactionSet;
482
607
  identity: IJobIdentity;
483
608
  signal: AbortSignal;
484
609
  }
485
610
  export interface ICacheManager { restore(context: ICacheRestoreContext): Promise<void>;
486
611
  save(context: ICacheSaveContext): Promise<void>;
487
612
  }
613
+ export {};
488
614
  export interface ILogApi { appendLog(chunk: ILogChunk, signal?: AbortSignal): Promise<ILogAcknowledgement>;
489
615
  }
490
616
  export declare class LogSender { private readonly api;
@@ -493,13 +619,14 @@ export declare class LogSender { private readonly api;
493
619
  private readonly maximumChunkBytes;
494
620
  private readonly signal?;
495
621
  private readonly redactors;
622
+ private readonly sequenceRedactor;
496
623
  private sequence;
497
624
  private sentBytes;
498
625
  private operationQueue;
499
626
  private terminalError;
500
627
  private observationSequence;
501
628
  private readonly lastObservation;
502
- constructor(api: ILogApi, identity: IJobIdentity, secrets: Iterable<string>, maximumBytes: number, maximumChunkBytes: number, signal?: AbortSignal | undefined);
629
+ constructor(api: ILogApi, identity: IJobIdentity, redactionSet: SecretRedactionSet, maximumBytes: number, maximumChunkBytes: number, signal?: AbortSignal | undefined);
503
630
  write(stream: 'stdout' | 'stderr', rawData: string): Promise<void>;
504
631
  writeRunnerMessage(data: string): Promise<void>;
505
632
  flush(): Promise<void>;
@@ -568,7 +695,7 @@ export interface IOciRunCommand { args: string[];
568
695
  }
569
696
  export interface IOciStepCommandInput { runnerId: string;
570
697
  sessionId: string;
571
- lease: IJobLease;
698
+ lease: IOciJobLease;
572
699
  step: ICompiledStep;
573
700
  containerName: string;
574
701
  volumeName: string;
@@ -645,22 +772,105 @@ export declare const copyOciConfig: (config: IOciExecutorConfig) => IOciExecutor
645
772
  export declare const canonicalizeJson: (value: unknown) => string;
646
773
  export declare const projectCompiledPlan: (job: unknown) => TJsonObject;
647
774
  export declare const computeCompiledPlanDigest: (job: unknown) => Promise<string>;
775
+ /** A leased job this runner does not execute; it is refused as `runner_error` before acceptance. */
776
+ export declare class UnsupportedJobError extends ProtocolError { constructor(message: string);
777
+ }
778
+ /**
779
+ * Validates capabilities against the published `RunnerCapabilities` schema and returns an
780
+ * immutable copy, the snapshot every lease is checked against.
781
+ */
648
782
  export declare const createRunnerCapabilitySnapshot: (capabilities: IRunnerCapabilities) => IRunnerCapabilities;
649
- export declare const validateCapabilityFit: (job: ICompiledRunnerJob, capabilities: IRunnerCapabilities) => void;
650
- export declare class RunnerProtocolValidator { private readonly capabilities;
651
- constructor(capabilities: IRunnerCapabilities);
652
- validateJob(jobUnknown: unknown): Promise<ICompiledRunnerJob>;
783
+ /**
784
+ * Narrows a coherent lease to the one shape this runner executes and refuses every other shape:
785
+ * the `vm` and `oci-image` profiles, `microvm` isolation, egress networking, candidate images and
786
+ * image grants, and npm read grants.
787
+ */
788
+ export declare const requireExecutableLease: (lease: IJobLease) => IOciJobLease;
789
+ export declare const validateCapabilityFit: (job: TCompiledRunnerJob, capabilities: IRunnerCapabilities) => void;
790
+ export declare class RunnerProtocolValidator { private readonly implementedSpec;
791
+ private readonly capabilities;
792
+ constructor(capabilities: IRunnerCapabilities, implementedSpec?: string);
793
+ /**
794
+ * Validates a compiled job: the published schema, the specification version acceptance rule,
795
+ * the compiled plan digest, internal coherence, and fit against the capability snapshot.
796
+ */
797
+ validateJob(jobUnknown: unknown): Promise<TCompiledRunnerJob>;
798
+ /** Validates a lease against the published `JobLease` schema, its job, and lease coherence. */
653
799
  validateJobLease(leaseUnknown: unknown): Promise<IJobLease>;
800
+ /** Validates a lease and narrows it to the `oci` shape this runner executes. */
801
+ validateExecutableLease(leaseUnknown: unknown): Promise<IOciJobLease>;
654
802
  }
655
803
  export declare const validateJobLease: (leaseUnknown: unknown, capabilities: IRunnerCapabilities) => Promise<IJobLease>;
656
- export declare class StreamingSecretRedactor { private readonly secrets;
657
- private readonly maximumSecretLength;
804
+ /** Redaction set members shorter than this many UTF-8 bytes are left out by the protocol. */
805
+ export declare const minimumRedactionMemberBytes = 8;
806
+ /** The secret-bearing values of one lease: job secret values and npm grant tokens. */
807
+ export interface IRedactionSource { job: { secrets: Readonly<Record<string, string>>;
808
+ };
809
+ npmGrants?: readonly {
810
+ secret: string;
811
+ }[];
812
+ }
813
+ /**
814
+ * The redaction set of an attempt: every secret value, every npm grant token, and each line of a
815
+ * multi-line value, leaving out members shorter than eight UTF-8 bytes.
816
+ */
817
+ export declare class SecretRedactionSet implements ISecretRedactionSet { readonly members: readonly string[];
818
+ private readonly membersByFirstCodeUnit;
819
+ private readonly memberBytes;
820
+ constructor(values: Iterable<string>);
821
+ static forLease(source: IRedactionSource): SecretRedactionSet;
822
+ get empty(): boolean;
823
+ /** The longest member in UTF-16 code units, the look-ahead a streaming redactor retains. */
824
+ get maximumMemberLength(): number;
825
+ /** The longest member at `index` of `text`, when one starts there. */
826
+ memberAt(text: string, index: number): string | undefined;
827
+ /** Whether any member occurs in `text`. */
828
+ occursIn(text: string): boolean;
829
+ /** A streaming matcher over bytes that reports whether any member occurs in them. */
830
+ createContentMatcher(): SecretContentMatcher;
831
+ }
832
+ /**
833
+ * Aho-Corasick matcher over the UTF-8 bytes of the redaction set. It is fed a byte stream in
834
+ * arbitrary chunks and detects members that span chunk boundaries. Transitions live in one map
835
+ * keyed by `state * 256 + byte`, so memory stays proportional to the total member bytes.
836
+ */
837
+ export declare class SecretContentMatcher implements ISecretContentMatcher { private readonly transitions;
838
+ private readonly failure;
839
+ private readonly terminal;
840
+ private state;
841
+ private matched;
842
+ constructor(members: readonly Uint8Array[]);
843
+ /** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */
844
+ push(bytes: Uint8Array): boolean;
845
+ get found(): boolean;
846
+ }
847
+ /**
848
+ * Replaces every member occurring in one text stream with `***`, retaining just enough look-ahead
849
+ * to catch members split across writes.
850
+ */
851
+ export declare class StreamingSecretRedactor { private readonly redactionSet;
658
852
  private buffer;
659
- constructor(secrets: Iterable<string>);
853
+ constructor(redactionSet: SecretRedactionSet);
660
854
  push(chunk: string): string;
661
855
  flush(): string;
662
856
  private consume;
663
857
  }
858
+ export interface IRedactedLogSegment { stream: TLogStream;
859
+ data: string;
860
+ }
861
+ /**
862
+ * Redacts the attempt's log output in emission order across all streams, so that no log chunk and
863
+ * no concatenation of consecutive chunks contains a member. A replacement spanning streams is
864
+ * attributed to the stream in which the member started.
865
+ */
866
+ export declare class LogSequenceRedactor { private readonly redactionSet;
867
+ private text;
868
+ private streams;
869
+ constructor(redactionSet: SecretRedactionSet);
870
+ push(stream: TLogStream, data: string): IRedactedLogSegment[];
871
+ flush(): IRedactedLogSegment[];
872
+ private consume;
873
+ }
664
874
  export interface IRunnerCoordinatorClient { discover(signal?: AbortSignal): Promise<IDiscoveryResponse>;
665
875
  setRunnerToken(token: string): void;
666
876
  startSession(request: IStartSessionRequest, signal?: AbortSignal): Promise<IStartSessionResponse>;
@@ -683,15 +893,28 @@ export interface IRunnerDependencies { api: IRunnerCoordinatorClient;
683
893
  onCredential?: (credential: IRunnerCredential) => Promise<void>;
684
894
  onMessage?: (message: string) => void;
685
895
  now?: () => number;
896
+ /** Monotonic milliseconds that measure the attempt deadline; `performance.now` by default. */
897
+ monotonicNow?: () => number;
686
898
  sleep?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
687
899
  }
688
- export declare const runnerCapabilities: (config: IRunnerConfig) => IRunnerCapabilities;
900
+ /**
901
+ * The capabilities this runner advertises: the `oci` profile in `container` isolation on the
902
+ * native linux platform of its verified OCI engine, the `none` network mode, the configured
903
+ * transfer limits, and the resource ceilings it enforces per attempt.
904
+ */
905
+ export declare const runnerCapabilities: (config: IRunnerConfig, runtime: Pick<IOciRuntimeFacts, "os" | "architecture">) => IRunnerCapabilities;
906
+ /**
907
+ * Restricts capabilities to the constructs defined at the lower of the coordinator and runner
908
+ * specification versions, the version every non-job message may use.
909
+ */
910
+ export declare const capabilitiesForCoordinator: (capabilities: IRunnerCapabilities, discovery: Pick<IDiscoveryResponse, "spec">) => IRunnerCapabilities;
689
911
  export declare const reconcileProtocolLimits: (config: IRunnerConfig, discovery: IDiscoveryResponse, capabilities: IRunnerCapabilities) => void;
690
912
  export declare class ShipRunner { private readonly config;
691
913
  private readonly dependencies;
692
914
  private drainRequested;
693
915
  private sessionInvalid;
694
916
  private readonly now;
917
+ private readonly monotonicNow;
695
918
  private readonly sleep;
696
919
  constructor(config: IRunnerConfig, dependencies: IRunnerDependencies);
697
920
  run(options?: {
@@ -715,4 +938,29 @@ export declare class SourceWorkspaceManager { private readonly config;
715
938
  constructor(config: ITransferManagerConfig, api: ISourceApiClient);
716
939
  prepare(context: ISourcePrepareContext): Promise<IPreparedWorkspace>;
717
940
  }
941
+ /**
942
+ * Outcome of the specification version acceptance rule of the runner protocol: a declared
943
+ * version is accepted when it is canonical, has the implemented major version, and is not newer.
944
+ */
945
+ export type TSpecAcceptance = 'accepted' | 'malformed' | 'major-mismatch' | 'newer';
946
+ /** The specification version this runner implements: the ci-spec package it is built against. */
947
+ export declare const runnerSpecVersion: string;
948
+ /** Applies the acceptance rule of an implementation of version `implemented` to `declared`. */
949
+ export declare const acceptSpecVersion: (implemented: string, declared: unknown) => TSpecAcceptance;
950
+ /** Returns whether two canonical versions share a major version, the coordinator session rule. */
951
+ export declare const specMajorVersionsMatch: (left: string, right: string) => boolean;
952
+ /** Compares two canonical specification versions numerically. */
953
+ export declare const compareSpecVersions: (left: string, right: string) => number;
954
+ /** The lower of two canonical versions: the version whose constructs a message may use. */
955
+ export declare const lowerSpecVersion: (left: string, right: string) => string;
718
956
  export declare const scavengeRunnerStaging: (stateDirectory: string) => Promise<void>;
957
+ /** OpenAPI component schemas of the published runner protocol that this runner validates. */
958
+ export declare const wireSchemaNames: readonly ["AbandonJobRequest", "AcceptJobRequest", "ClaimJobRequest", "ClaimJobResponse", "CompleteJobRequest", "CompleteJobResponse", "DiscoveryResponse", "ErrorResponse", "ImageBinding", "ImageGrant", "ImageRecord", "JobHeartbeatRequest", "JobHeartbeatResponse", "JobLease", "LogAcknowledgement", "LogChunk", "NpmGrant", "RecordImageRequest", "RecoverAttemptRequest", "RegisterRunnerRequest", "RegisterRunnerResponse", "RunnerCapabilities", "RunnerHeartbeatRequest", "RunnerHeartbeatResponse", "StartSessionRequest", "StartSessionResponse", "TransferRecord"];
959
+ export type TWireSchemaName = (typeof wireSchemaNames)[number];
960
+ export declare const isWireSchemaName: (value: unknown) => value is TWireSchemaName;
961
+ /** Returns whether a value is valid against one published runner protocol component. */
962
+ export declare const isValidWireMessage: (name: TWireSchemaName, value: unknown) => boolean;
963
+ /** Validates a value against one published runner protocol component and returns it typed. */
964
+ export declare const validateWireMessage: <T>(name: TWireSchemaName, value: unknown) => T;
965
+ /** Validates a compiled runner job against the published runner job schema. */
966
+ export declare const validateCompiledJobSchema: <T>(value: unknown) => T;