@evident-ai/runner-cdk 3.4.1-dev.2f1b44b → 3.4.1-dev.51df4de

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.
@@ -312,14 +312,21 @@ fetch_runner_secret() {
312
312
  log "runner secret is not configured; continuing without GitHub and MCP credentials"
313
313
  return 0
314
314
  fi
315
+ # From here, RUNNER_SECRET_ARN IS configured: every failure branch below
316
+ # returns 1, not 0. Process env is fixed at spawn — nothing later in this
317
+ # VM's life can retry a fetch that fails here — so a VM that was promised
318
+ # these credentials and never got them is contrary evidence it can do the
319
+ # job it was launched for, exactly the class check_runner_key already treats
320
+ # as fatal (#1997): fail /run now and let the lifecycle machinery replace
321
+ # this VM, rather than run the whole session silently degraded.
315
322
  remaining="$(remaining_credential_budget "${step_started_s}")"
316
323
  if [ "${remaining}" -lt 1 ]; then
317
324
  warn "CREDENTIAL-RESTORE-SKIPPED: runner-secret skipped; the ${CREDENTIAL_RESTORE_DEADLINE_SECONDS}s credential-restore budget is exhausted"
318
- return 0
325
+ return 1
319
326
  fi
320
327
  if ! stderr_file="$(mktemp /dev/shm/runner-secret-stderr.XXXXXX)"; then
321
328
  warn "RUNNER-SECRET-STDERR-UNAVAILABLE: could not allocate diagnostic storage; continuing without runner credentials"
322
- return 0
329
+ return 1
323
330
  fi
324
331
  started_ms="$(now_ms)"
325
332
  payload="$(timeout -k "${CREDENTIAL_RESTORE_KILL_GRACE_SECONDS}" "${remaining}" aws secretsmanager get-secret-value --secret-id "${RUNNER_SECRET_ARN}" --query SecretString --output text 2>"${stderr_file}")" || rc=$?
@@ -327,12 +334,12 @@ fetch_runner_secret() {
327
334
  if [ "${rc}" -eq 124 ] || [ "${rc}" -eq 137 ]; then
328
335
  warn "CREDENTIAL-RESTORE-TIMEOUT: runner-secret did not finish within its ${remaining}s share of the ${CREDENTIAL_RESTORE_DEADLINE_SECONDS}s credential-restore deadline; continuing without it"
329
336
  rm -f "${stderr_file}"
330
- return 0
337
+ return 1
331
338
  fi
332
339
  if [ "${rc}" -ne 0 ]; then
333
340
  warn "RUNNER-SECRET-UNREADABLE: $(<"${stderr_file}")"
334
341
  rm -f "${stderr_file}"
335
- return 0
342
+ return 1
336
343
  fi
337
344
  rm -f "${stderr_file}"
338
345
  if ! jq -e 'type == "object"' >/dev/null 2>&1 <<<"${payload}"; then
@@ -363,7 +370,10 @@ restore_credentials() {
363
370
 
364
371
  load_state_config || return 1
365
372
  # This shares the existing bounded window so /run's worst-case duration does not grow.
366
- fetch_runner_secret "${step_started_s}"
373
+ # Fatal when RUNNER_SECRET_ARN is configured (see fetch_runner_secret's own
374
+ # comment); a no-ARN self-hosted runner already returned 0 above and never
375
+ # reaches this `||`.
376
+ fetch_runner_secret "${step_started_s}" || return 1
367
377
  bounded_restore_call restore-claude "${step_started_s}" restore claude || return 1
368
378
  bounded_restore_call restore-opencode "${step_started_s}" restore opencode || return 1
369
379
 
@@ -517,6 +527,35 @@ prewarm_litestream() {
517
527
  log "pre-warming ${binary} in the background"
518
528
  }
519
529
 
530
+ # Reads the aws CLI v2 install tree into the page cache, in the background, so
531
+ # fetch_runner_secret's first `aws secretsmanager get-secret-value` does not
532
+ # pay first-touch I/O on the critical path.
533
+ #
534
+ # A single `cat` of the `aws` entrypoint (litestream's pattern above) is NOT
535
+ # enough here: v2 ships as a real Python distribution (~7,500 files under the
536
+ # resolved binary's own directory), and a cold invocation demand-pages a
537
+ # scattered set of them (botocore's endpoints.json/partitions.json, service
538
+ # model JSON, shared libs) — one boot measured #1997's fetch at 7,243ms cold
539
+ # vs ~400ms warm, an ~18x gap the litestream read-ahead trick alone cannot
540
+ # close. `find -exec cat` walks that whole tree instead of one file.
541
+ prewarm_aws_cli() {
542
+ local binary tree
543
+ binary="$(command -v aws 2>/dev/null || true)"
544
+ if [ -z "${binary}" ]; then
545
+ warn "aws CLI is not on PATH; skipping the boot pre-warm"
546
+ return 0
547
+ fi
548
+ tree="$(dirname "$(readlink -f "${binary}")")"
549
+
550
+ (
551
+ local started_ms rc=0
552
+ started_ms="$(now_ms)"
553
+ find "${tree}" -type f -exec cat {} + >/dev/null 2>&1 || rc=$?
554
+ log_elapsed_since aws-cli-prewarm "${started_ms}" "${rc}"
555
+ ) &
556
+ log "pre-warming ${tree} in the background"
557
+ }
558
+
520
559
  # Generates ${LITESTREAM_CONFIG_FILE} from runner-synchroniser's own renderer
521
560
  # — the SAME config module the credential restore/sync already goes through,
522
561
  # so there is no second copy of the bucket/prefix/path logic to drift
@@ -54,8 +54,12 @@ printf '%s\n' "${state_prefix}" >"${STATE_PREFIX_FILE}"
54
54
 
55
55
  # 3 — start reading the litestream binary NOW so that read overlaps step 4,
56
56
  # which needs a different binary (node), instead of landing inside step 5, which
57
- # start_opencode has to wait for. Backgrounded and never waited on.
57
+ # start_opencode has to wait for. Backgrounded and never waited on. Same for the
58
+ # aws CLI: step 4's runner-secret fetch is its first-ever invocation in this
59
+ # VM's life, and #1997 measured that cold first touch alone blowing the whole
60
+ # credential-restore deadline.
58
61
  prewarm_litestream
62
+ prewarm_aws_cli
59
63
 
60
64
  # 4 — credential stores, restored before anything that reads them starts. Fatal
61
65
  # only if persistence itself is unavailable (an unset bucket/prefix, or a broken
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evident-ai/runner-cdk",
3
- "version": "3.4.1-dev.2f1b44b",
3
+ "version": "3.4.1-dev.51df4de",
4
4
  "description": "Reusable CDK constructs for an Evident agent runner: a single scale-to-zero Fargate runner (task + service + per-agent self-stop role + waker Lambda), or a per-session AWS Lambda MicroVM that boots on demand and suspends between messages. Instantiate once per agent from your own stack.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",