buildModuleRecordsForSource(
    specifier,
    { parser, record, sourceLocation, bytes }
  ) {
    if (!sourceLocation) {
      // XXX: under what circumstances does this occur?
      return []
    }

    if (!record) {
      // XXX: under what circumstances does this occur?
      throw new GenerationError(
        `Source descriptor "${specifier}" in compartment "${this.canonicalName}" missing prop: record`
      )
    }

    // `record` can be several different types, but for our purposes,
    // we can use `imports` as the discriminator
    if (!hasOwn(record, 'imports')) {
      // XXX: under what circumstances does this occur?
      throw new GenerationError(
        `StaticModuleType for source descriptor "${specifier}" in compartment "${this.canonicalName} missing prop: imports`
      )
    }

    const content = PolicyGeneratorContext.#decoder.decode(bytes)

    /**
     * The {@link LavamoatModuleRecord.file} prop
     *
     * @type {LavamoatModuleRecord['file']}
     */
    const file = this.#readPowers.fileURLToPath(new URL(sourceLocation))

    // TODO: add a "trace" loglevel
    // this.#log.debug(`Building module record for "${specifier}" (${file})`)

    /**
     * The {@link LavamoatModuleRecord.importMap} prop
     */
    const importMap = this.buildImportMap(
      /** @type {VirtualModuleSource} */ (record).imports
    )

    // careful with the distinction between the root MODULE and the root COMPARTMENT
    const isRoot = file === this.#rootModule

    /** @type {SimpleLavamoatModuleRecordOptions} */
    const lmrOptions = {
      specifier: file,
      file,
      packageName: this.canonicalName,
      importMap,
      content,
      type: parser === NATIVE_PARSER_NAME ? LMR_TYPE_NATIVE : LMR_TYPE_SOURCE,
      isRoot,
    }

    if (isRoot) {
      this.#log.debug(`Found root module: ${hrPath(file)}`)
    }

    if (!this.#lmrCache.has(lmrOptions)) {
      this.#lmrCache.add(lmrOptions)
    }

    // because builtins do not have their own compartments, we need to
    // look into the `importMap` and create LMRs for each builtin.
    // we will add the source LMR to this array as the last step
    return [
      ...this.buildModuleRecordsFromImportedBuiltins(importMap),
      /** @type {LavamoatModuleRecord} */ (this.#lmrCache.get(lmrOptions)),
    ]
  }
Creates one or more {@link LavamoatModuleRecord LavamoatModuleRecords} from
a single `ModuleSource`.

The resulting array will contain--at minimum--a LMR of the source itself.
It will also contain zero (0) or more LMRs for any builtins the module
references.

@param {string} specifier
@param {ModuleSource} source
@returns {LavamoatModuleRecord[]}