Skip to content
Myr

run.ts

This file

Path

apps/sandbox/src/lander/run.ts

870 lines · 23.2 KiB · TypeScript

Last changed by

Merge observability into mainoscabrielbefore adoption1985111

History of this file

Take it

1// A remote's token reaches git as an `http.extraHeader` through `GIT_CONFIG_*`2// env, never in a URL or on a command line. git's stderr is logged with every3// token taken out, never put in the refusal.4import { Brand } from "@repo/brand";5import { notesRef } from "@repo/git/notes";6import { authorLine, committerLine, parseTrailers } from "@repo/git/trailers";7import type { GitIdentity } from "@repo/git/trailers";8import { Rebuild } from "@repo/project/lander/wire";9import type {10  BundleWire,11  ComposeWire,12  Landed,13  LandWire,14  MergeWire,15} from "@repo/project/lander/wire";16import { Verdict } from "@repo/protocol/domain/answer";17import { CommitSha, LandedSha, TreeSha } from "@repo/protocol/ids";18import type { RepoName } from "@repo/protocol/ids";19import { RepoBusy, StaleBase, VerifierBlocked } from "@repo/protocol/refusal";20import {21  Array,22  Clock,23  Context,24  Effect,25  Option,26  Redacted,27  Schema,28} from "effect";2930import { Box } from "../box.ts";31import type { Executed } from "../box.ts";32import {33  bundle,34  bundledAs,35  bundleEntries,36  catBlob,37  checkoutIndex,38  commitTree,39  composeCopy,40  configEntry,41  fetchCommit,42  fetchFork,43  fetchMain,44  fetchRef,45  filesUnder,46  folders,47  firstParents,48  hashObject,49  initCopy,50  isScript,51  landScript,52  listFiles,53  lsRemote,54  lsTree,55  mainCopy,56  mainRef,57  mergeRef,58  mergeScript,59  mergeTree,60  notesCopy,61  objectType,62  pushRef,63  readChanges,64  readEntries,65  readFile,66  readFiles,67  readLog,68  readMerge,69  readPush,70  readRemoteRef,71  readTree,72  removeFolder,73  resolution,74  revParse,75  symlink,76  updateIndex,77  writeTree,78} from "./script.ts";79import type { GitStep, RemoteName, Signature } from "./script.ts";8081export interface LanderLayout {82  readonly work: string;83  readonly sdk: {84    readonly entry: string;85    readonly modules: string;86    readonly version: string;87  };88  readonly path: string;89}9091export const Layout = Context.Reference<LanderLayout>("sandbox/lander/Layout", {92  defaultValue: () => ({93    path: "/usr/local/bin:/usr/bin:/bin",94    sdk: {95      entry: "/opt/sdk/node_modules/@repo/sdk/src/index.ts",96      modules: "/opt/sdk/node_modules",97      version: "/opt/sdk/version",98    },99    work: "/workspace",100  }),101});102103type Tokens = Partial<Record<RemoteName, Redacted.Redacted>>;104105// The modes git stores a file's bytes under, plain or executable: a file a106// composed file may replace, and a file a bundle may read.107const FILE_MODES = new Set(["100644", "100755"]);108109// How much of git's stderr a log keeps: its end, where git says what broke.110const STDERR_KEPT = 2000;111112// A step that reaches a remote may take a while; a local one should not.113const REMOTE_MS = 120_000;114115const LOCAL_MS = 30_000;116117const scrubbed = (text: string, tokens: Tokens) => {118  let kept = text;119120  for (const token of Object.values(tokens)) {121    const secret = Redacted.value(token);122123    if (secret !== "") {124      kept = kept.replaceAll(secret, "[token]");125    }126  }127128  return kept.trim().slice(-STDERR_KEPT);129};130131const subcommandOf = (step: GitStep) =>132  step.argv.find(133    (argument, index) =>134      index > 0 && !argument.startsWith("-") && step.argv[index - 1] !== "-c"135  ) ?? "git";136137const blockedBy = (step: string, why: string, tokens: Tokens) =>138  Effect.logWarning("a Lander step failed").pipe(139    Effect.annotateLogs({ step, why: scrubbed(why, tokens) }),140    Effect.andThen(Effect.fail(new VerifierBlocked({})))141  );142143const printed = (ran: Executed) =>144  `exit ${ran.exitCode}: ${ran.stdout}\n${ran.stderr}`;145146const baseEnv = (layout: LanderLayout) => ({147  GIT_CONFIG_GLOBAL: "/dev/null",148  GIT_CONFIG_NOSYSTEM: "1",149  GIT_TERMINAL_PROMPT: "0",150  HOME: layout.work,151  LC_ALL: "C",152  PATH: layout.path,153});154155const header = (token: Redacted.Redacted) => ({156  GIT_CONFIG_COUNT: "1",157  GIT_CONFIG_KEY_0: "http.extraHeader",158  GIT_CONFIG_VALUE_0: `Authorization: Bearer ${Redacted.value(token)}`,159});160161interface Steps {162  /** A step expected to succeed that does not blocks the job. */163  readonly run: (step: GitStep) => Effect.Effect<Executed, VerifierBlocked>;164  readonly blocked: (165    step: GitStep,166    why: string167  ) => Effect.Effect<never, VerifierBlocked>;168}169170const runner = (tokens: Tokens) => {171  const blocked = (step: GitStep, why: string) =>172    blockedBy(subcommandOf(step), why, tokens);173174  return Effect.gen(function* () {175    const box = yield* Box;176    const layout = yield* Layout;177178    const run = (step: GitStep): Effect.Effect<Executed, VerifierBlocked> =>179      Effect.gen(function* () {180        const token =181          step.remote === undefined ? undefined : tokens[step.remote];182183        if (step.remote !== undefined && token === undefined) {184          return yield* blocked(185            step,186            `the job carries no token for ${step.remote}`187          );188        }189190        const env =191          token === undefined192            ? { ...baseEnv(layout), ...step.env }193            : { ...baseEnv(layout), ...step.env, ...header(token) };194195        const ran = yield* box196          .exec(step.argv, {197            cwd: layout.work,198            env,199            timeoutMs: step.remote === undefined ? LOCAL_MS : REMOTE_MS,200          })201          .pipe(202            // By its subcommand alone: an argument may be a remote's URL.203            Effect.withSpan("Lander.git", {204              attributes: { step: subcommandOf(step) },205            }),206            Effect.catchTag("BoxFailed", ({ reason }) => blocked(step, reason))207          );208209        const expected =210          step.expect === "ok"211            ? ran.exitCode === 0212            : step.expect !== "merge" || ran.exitCode <= 1;213214        return expected ? ran : yield* blocked(step, printed(ran));215      });216217    return { blocked, run } satisfies Steps;218  });219};220221/** Clock time, in the whole seconds a git signature holds. */222const seconds = Effect.map(Clock.currentTimeMillis, (millis) =>223  Math.floor(millis / 1000)224);225226const signed = (who: GitIdentity, at: number): Signature => ({ ...who, at });227228const scratch = (name: string) =>229  Effect.map(Layout, ({ work }) => `${work}/scratch/${name}`);230231const prepared = (job: Job) =>232  Effect.gen(function* () {233    const { work } = yield* Layout;234235    yield* job.run(folders([`${work}/scratch/compose`]));236    yield* job.run(initCopy(job.repo));237  });238239const writtenAt = (file: string, text: string) =>240  Box.use((box) => box.writeFile(file, new TextEncoder().encode(text))).pipe(241    Effect.catchTag("BoxFailed", ({ reason }) =>242      blockedBy("writeFile", reason, {})243    )244  );245246const written = (name: string, text: string) =>247  Effect.gen(function* () {248    const file = yield* scratch(name);249250    yield* writtenAt(file, text);251252    return file;253  });254255interface Job extends Steps {256  readonly repo: RepoName;257  readonly url: string;258}259260const resolved = ({ repo, run }: Job, rev: string) =>261  Effect.map(run(revParse(repo, rev)), ({ exitCode, stdout }) =>262    exitCode === 0 ? Option.some(stdout.trim()) : Option.none()263  );264265const idOf = (job: Job, rev: string) =>266  resolved(job, rev).pipe(267    Effect.flatMap(268      Option.match({269        onNone: () =>270          job.blocked(revParse(job.repo, rev), `the copy has no ${rev}`),271        onSome: Effect.succeed,272      })273    )274  );275276const committed = (277  job: Job,278  commit: {279    readonly tree: string;280    readonly parents: readonly string[];281    readonly message: string;282    readonly author: GitIdentity;283    readonly at: number;284  }285) =>286  Effect.gen(function* () {287    const messageFile = yield* written("message", commit.message);288289    const ran = yield* job.run(290      commitTree(job.repo, {291        author: signed(commit.author, commit.at),292        committer: signed(committerLine, commit.at),293        messageFile,294        parents: commit.parents,295        tree: commit.tree,296      })297    );298299    return CommitSha.make(ran.stdout.trim());300  });301302/** Dated at the epoch, so merging the same sides again makes the same commit. */303const keptForChecks = (304  job: Job,305  sides: {306    readonly head: CommitSha;307    readonly main: LandedSha;308    readonly tree: TreeSha;309  }310) =>311  Effect.gen(function* () {312    yield* prepared(job);313314    const commit = yield* committed(job, {315      at: 0,316      author: committerLine,317      message: `Merge ${sides.head} onto ${sides.main}, for its checks\n`,318      parents: [sides.main, sides.head],319      tree: sides.tree,320    });321322    const ref = mergeRef(sides.tree);323324    const push = pushRef(job.repo, job.url, {325      ref,326      remote: "fork",327      to: commit,328    });329330    const ran = yield* job.run(push);331332    return readPush(ran, ref) === "moved"333      ? commit334      : yield* job.blocked(push, printed(ran));335  });336337export const merge = (wire: typeof MergeWire.Type) =>338  Effect.gen(function* () {339    const { job } = wire;340341    const steps = yield* runner({342      fork: wire.fork.token,343      main: wire.main.token,344    });345346    const { run } = steps;347348    const script = mergeScript(job, {349      fork: wire.fork.url,350      main: wire.main.url,351    });352353    yield* Effect.forEach(script.fetch, run, { discard: true });354355    const merged = readMerge((yield* run(script.merge)).stdout);356357    if (merged.conflicts.length > 0) {358      return yield* new StaleBase({359        base: job.base,360        conflicts: merged.conflicts,361        main: job.main,362      });363    }364365    const changes = readChanges((yield* run(script.changes)).stdout);366367    yield* keptForChecks(368      { ...steps, repo: job.repo, url: wire.fork.url },369      {370        head: job.head,371        main: job.main,372        tree: merged.tree,373      }374    );375376    return { changes, tree: merged.tree };377  });378379const placed = ({ path }: { readonly path: string }) =>380  path.split("/").every((segment) => !["", ".", "..", ".git"].includes(segment))381    ? Effect.void382    : Effect.die(`${path} cannot name a file in a repo`);383384/** A file keeps the mode of the file it replaces. */385const composed = (386  job: Job,387  main: string,388  files: readonly { readonly path: string; readonly content: string }[]389) =>390  Effect.gen(function* () {391    yield* Effect.forEach(files, placed, { discard: true });392393    const blobs = yield* Effect.forEach(files, ({ content }, index) =>394      Effect.flatMap(written(`compose/${index}`, content), (file) =>395        Effect.map(job.run(hashObject(job.repo, file)), ({ stdout }) =>396          stdout.trim()397        )398      )399    );400401    const paths = files.map(({ path }) => path);402403    const existing = readEntries(404      (yield* job.run(lsTree(job.repo, main, paths))).stdout405    );406407    const modes = paths.map((path) => existing.get(path)?.mode ?? "100644");408409    if (!modes.every((mode) => FILE_MODES.has(mode))) {410      return yield* job.blocked(411        lsTree(job.repo, main, paths),412        "a composed file's path is a folder, a symlink or a submodule on main"413      );414    }415416    const index = yield* scratch("compose.index");417418    yield* job.run(readTree(job.repo, index, main));419    yield* job.run(420      updateIndex(421        job.repo,422        index,423        paths.map((path, at) => ({424          blob: blobs[at] ?? "",425          mode: modes[at] ?? "100644",426          path,427        }))428      )429    );430431    return TreeSha.make(432      (yield* job.run(writeTree(job.repo, index))).stdout.trim()433    );434  });435436const rebuilt = (437  job: Job,438  wire: typeof LandWire.Type439): Effect.Effect<TreeSha, StaleBase | VerifierBlocked, Box> =>440  Rebuild.match<Effect.Effect<TreeSha, StaleBase | VerifierBlocked, Box>>(441    wire.job.rebuild,442    {443      Compose: ({ files }) => composed(job, wire.job.main, files),444      Existing: ({ commit }) =>445        Effect.map(idOf(job, `${commit}^{tree}`), (tree) => TreeSha.make(tree)),446      Merge: ({ base, fork, head }) =>447        Effect.gen(function* () {448          if (wire.fork === undefined) {449            return yield* job.blocked(450              mergeTree(job.repo, { base, head, main: wire.job.main }),451              "a merge rebuild needs the fork's remote"452            );453          }454455          yield* job.run(fetchFork(job.repo, fork, wire.fork.url));456457          const merged = readMerge(458            (yield* job.run(459              mergeTree(job.repo, { base, head, main: wire.job.main })460            )).stdout461          );462463          return merged.conflicts.length > 0464            ? yield* new StaleBase({465                base,466                conflicts: merged.conflicts,467                main: wire.job.main,468              })469            : merged.tree;470        }),471    }472  );473474const landedRef = `${Brand.refsPrefix}landed`;475476const notesCopyOf = notesRef.replace("refs/notes/", `${notesCopy}/`);477478const encodeNote = Schema.encodeEffect(Schema.fromJsonString(Verdict));479480const holdsNote = (job: Job, notes: string, landing: CommitSha) =>481  Effect.map(482    job.run(objectType(job.repo, `${notes}:${landing}`)),483    ({ exitCode }) => exitCode === 0484  );485486const note = (job: Job, landing: CommitSha, verdict: Verdict, at: number) =>487  Effect.gen(function* () {488    const parent = yield* resolved(job, notesCopyOf);489490    if (491      Option.isSome(parent) &&492      (yield* holdsNote(job, parent.value, landing))493    ) {494      return parent.value;495    }496497    const json = yield* Effect.orDie(encodeNote(verdict));498    const file = yield* written("note", `${json}\n`);499    const blob = (yield* job.run(hashObject(job.repo, file))).stdout.trim();500    const index = yield* scratch("notes.index");501502    yield* job.run(503      readTree(504        job.repo,505        index,506        Option.getOrUndefined(Option.map(parent, (sha) => `${sha}^{tree}`))507      )508    );509    yield* job.run(510      updateIndex(job.repo, index, [{ blob, mode: "100644", path: landing }])511    );512513    const tree = (yield* job.run(writeTree(job.repo, index))).stdout.trim();514515    const commit = yield* committed(job, {516      at,517      author: committerLine,518      message: `Verdict on ${landing}\n`,519      parents: Option.toArray(parent),520      tree,521    });522523    const step = pushRef(job.repo, job.url, { ref: notesRef, to: commit });524    const ran = yield* job.run(step);525526    return readPush(ran, notesRef) === "moved"527      ? commit528      : yield* job.blocked(step, printed(ran));529  });530531type Bookkeeping = (typeof Landed.Type)["pending"][number];532533const attempt = <A, E, R>(item: Bookkeeping, write: Effect.Effect<A, E, R>) =>534  write.pipe(535    Effect.as(Option.none<Bookkeeping>()),536    Effect.catchCause((cause) =>537      Effect.as(538        Effect.logWarning(`a landing's ${item} was not written`, cause),539        Option.some(item)540      )541    )542  );543544/** Neither fails the landing: what was not written comes back pending, and landing again writes it. */545const settle = (546  job: Job,547  wire: typeof LandWire.Type,548  landing: CommitSha,549  tip: string550) =>551  Effect.gen(function* () {552    const at = yield* seconds;553    const script = landScript(wire.job, job.url, landing, landedRef);554555    const mirrored = yield* attempt(556      "mirror",557      tip === landing558        ? Effect.flatMap(job.run(script.mirror), (ran) =>559            readPush(ran, landedRef) === "moved"560              ? Effect.void561              : job.blocked(script.mirror, printed(ran))562          )563        : Effect.void564    );565566    const noted = yield* Option.match(wire.job.verdict, {567      onNone: () => Effect.succeedNone,568      onSome: (verdict) => attempt("notes", note(job, landing, verdict, at)),569    });570571    return {572      pending: [...Option.toArray(mirrored), ...Option.toArray(noted)],573      sha: LandedSha.make(landing),574    };575  });576577// How far back from main's tip a second land looks for the first one's commit.578const LOOKBACK = 16;579580const requestIdOf = (text: string) =>581  parseTrailers(text).find(({ key }) => key.toLowerCase() === "request-id")582    ?.value;583584const baseOf = (wire: typeof LandWire.Type) =>585  Rebuild.match(wire.job.rebuild, {586    Compose: () => wire.job.main,587    Existing: () => wire.job.main,588    Merge: ({ base }) => base,589  });590591/** An earlier land of the same `Request-Id` gets its missing bookkeeping written; anything else is `StaleBase`. */592const moved = (job: Job, wire: typeof LandWire.Type, tip: string) =>593  Effect.gen(function* () {594    const history = readLog(595      (yield* job.run(firstParents(job.repo, tip, LOOKBACK))).stdout596    );597598    const mine = Array.takeWhile(599      history,600      ({ sha }) => sha !== wire.job.main601    ).find(602      ({ message, parents }) =>603        parents[0] === wire.job.main &&604        requestIdOf(message) === wire.job.requestId605    );606607    if (mine !== undefined) {608      return yield* settle(job, wire, mine.sha, tip);609    }610611    return yield* new StaleBase({612      base: baseOf(wire),613      conflicts: [],614      main: CommitSha.make(tip),615    });616  });617618/** Pushed without force, so a `main` that moved refuses it. */619export const land = (wire: typeof LandWire.Type) =>620  Effect.gen(function* () {621    const { job: landing } = wire;622623    if (requestIdOf(landing.message) !== landing.requestId) {624      return yield* Effect.die(625        `a landing's message must carry Request-Id: ${landing.requestId}`626      );627    }628629    const job: Job = {630      ...(yield* runner(631        wire.fork === undefined632          ? { main: wire.main.token }633          : { fork: wire.fork.token, main: wire.main.token }634      )),635      repo: landing.repo,636      url: wire.main.url,637    };638639    yield* prepared(job);640    yield* job.run(fetchMain(job.repo, job.url, { notes: true }));641642    const tip = yield* idOf(job, mainCopy);643644    if (tip !== landing.main) {645      return yield* moved(job, wire, tip);646    }647648    const tree = yield* rebuilt(job, wire);649650    if (tree !== landing.tree) {651      return yield* Effect.logWarning(652        "a land rebuilt another tree than it was asked to land"653      ).pipe(654        Effect.annotateLogs({ asked: landing.tree, rebuilt: tree }),655        Effect.andThen(Effect.fail(new VerifierBlocked({})))656      );657    }658659    const commit = yield* committed(job, {660      at: yield* seconds,661      author: authorLine(landing.author),662      message: landing.message,663      parents: [landing.main],664      tree,665    });666667    const script = landScript(landing, job.url, commit, landedRef);668    const ran = yield* job.run(script.main);669    const pushed = readPush(ran, mainRef);670671    if (pushed === "moved") {672      return yield* settle(job, wire, commit, commit);673    }674675    if (pushed === "busy") {676      return yield* new RepoBusy({});677    }678679    if (pushed === "stale") {680      yield* job.run(fetchMain(job.repo, job.url, { notes: true }));681682      return yield* moved(job, wire, yield* idOf(job, mainCopy));683    }684685    return yield* job.blocked(script.main, printed(ran));686  });687688const COMPOSE_MESSAGE = "Compose files onto main for a check\n";689690export const compose = (wire: typeof ComposeWire.Type) =>691  Effect.gen(function* () {692    const job: Job = {693      ...(yield* runner({ main: wire.main.token })),694      repo: wire.job.repo,695      url: wire.main.url,696    };697698    yield* prepared(job);699    yield* job.run(fetchMain(job.repo, job.url));700701    const tree = yield* composed(job, wire.job.main, wire.job.files);702    const ref = `${Brand.refsPrefix}compose/${tree}`;703704    const existing = readRemoteRef(705      (yield* job.run(lsRemote(job.repo, job.url, ref))).stdout706    );707708    if (existing !== undefined) {709      yield* job.run(fetchRef(job.repo, job.url, ref, composeCopy));710711      const [before] = readLog(712        (yield* job.run(firstParents(job.repo, existing, 1))).stdout713      );714715      const kept = yield* idOf(job, `${existing}^{tree}`);716717      if (kept === tree && before?.parents[0] === wire.job.main) {718        return { commit: existing, tree };719      }720    }721722    const commit = yield* committed(job, {723      at: yield* seconds,724      author: committerLine,725      message: COMPOSE_MESSAGE,726      parents: [wire.job.main],727      tree,728    });729730    const step = pushRef(731      job.repo,732      job.url,733      existing === undefined734        ? { ref, to: commit }735        : { lease: existing, ref, to: commit }736    );737738    const ran = yield* job.run(step);739740    if (readPush(ran, ref) !== "moved") {741      return yield* job.blocked(step, printed(ran));742    }743744    return { commit, tree };745  });746747const hasCommit = (job: Job, rev: string) =>748  Effect.map(749    job.run(objectType(job.repo, `${rev}^{commit}`)),750    ({ exitCode }) => exitCode === 0751  );752753const present = (job: Job, commit: string) =>754  Effect.gen(function* () {755    if (!(yield* hasCommit(job, commit))) {756      yield* job.run(fetchCommit(job.repo, job.url, commit));757    }758759    return (yield* hasCommit(job, commit))760      ? commit761      : yield* job.blocked(762          objectType(job.repo, commit),763          `canonical has no commit ${commit}`764        );765  });766767/** Files only, never a symlink, and no repo config or hooks. */768const built = (769  job: Job,770  files: readonly {771    readonly path: string;772    readonly mode: string;773    readonly sha: string;774  }[],775  entries: Array.NonEmptyReadonlyArray<string>776) =>777  Effect.gen(function* () {778    const { sdk, work } = yield* Layout;779    const root = `${work}/bundle`;780    const out = `${work}/bundle-out`;781    const index = yield* scratch("bundle.index");782783    yield* job.run(removeFolder(root));784    yield* job.run(removeFolder(out));785    yield* job.run(folders([root]));786    yield* job.run(readTree(job.repo, index));787    yield* job.run(788      updateIndex(789        job.repo,790        index,791        files.map(({ mode, path, sha }) => ({ blob: sha, mode, path }))792      )793    );794    yield* job.run(checkoutIndex(job.repo, index, root));795796    const tsconfig = `${root}/tsconfig.json`;797798    yield* writtenAt(tsconfig, resolution(sdk.entry));799    yield* job.run(symlink(sdk.modules, `${root}/node_modules`));800    yield* job.run(bundle({ entries, out, root, tsconfig }));801802    const outputs = readFiles((yield* job.run(listFiles(out))).stdout);803    const owners = new Map(entries.map((entry) => [bundledAs(entry), entry]));804805    if (!entries.every((entry) => outputs.includes(bundledAs(entry)))) {806      return yield* job.blocked(807        listFiles(out),808        "bun wrote no bundle for an entry"809      );810    }811812    return yield* Effect.forEach(outputs, (output) =>813      Effect.map(814        job.run(readFile(`${out}/${output}`)),815        ({ stdout }) => [owners.get(output) ?? output, stdout] as const816      )817    );818  });819820/** Nothing in the folder runs here. A missing folder gives no modules: the defaults apply. */821export const bundleRules = (wire: typeof BundleWire.Type) =>822  Effect.gen(function* () {823    const { sdk } = yield* Layout;824825    const job: Job = {826      ...(yield* runner({ main: wire.main.token })),827      repo: wire.job.repo,828      url: wire.main.url,829    };830831    yield* prepared(job);832    yield* job.run(fetchMain(job.repo, job.url));833    yield* present(job, wire.job.at);834835    const listed = readEntries(836      (yield* job.run(filesUnder(job.repo, wire.job.at, Brand.configDir)))837        .stdout838    );839840    const files = [...listed].flatMap(([path, { mode, sha }]) =>841      FILE_MODES.has(mode) ? [{ mode, path, sha }] : []842    );843844    const sdkVersion = (yield* job.run(readFile(sdk.version))).stdout.trim();845846    if (sdkVersion === "") {847      return yield* job.blocked(readFile(sdk.version), "no sdk version");848    }849850    const data = yield* Effect.forEach(851      files.filter(({ path }) => !isScript(path)),852      ({ path, sha }) =>853        Effect.map(854          job.run(catBlob(job.repo, sha)),855          ({ stdout }) => [path, stdout] as const856        )857    );858859    const entries = bundleEntries(files.map(({ path }) => path));860861    const code = Array.isReadonlyArrayNonEmpty(entries)862      ? yield* built(job, files, entries)863      : [];864865    return {866      entry: configEntry,867      modules: Object.fromEntries([...data, ...code]),868      sdkVersion,869    };870  });