function inspectForEnvironment(ast, moduleRecord, includeDebugInfo) {
    const { packageName } = moduleRecord
    // @ts-expect-error `ParseResult` / `AST` mismatch
    const compatWarnings = inspectSesCompat(ast)

    const { primordialMutations, strictModeViolations, dynamicRequires } =
      // @ts-expect-error `SesCompat` / `InspectSesCompatResult` mismatch
      /** @type {import('./schema').SesCompat} */ (compatWarnings)
    const hasResults =
      primordialMutations.length > 0 ||
      strictModeViolations.length > 0 ||
      dynamicRequires.length > 0
    if (!hasResults) {
      return
    }
    if (includeDebugInfo) {
      const moduleDebug = debugInfo[moduleRecord.specifier]
      moduleDebug.sesCompat = {
        // FIXME: I don't think this is needed, since it appears we overwrite all properties
        ...compatWarnings,
        // fix serialization
        primordialMutations: primordialMutations.map(({ node: { loc } }) => ({
          node: { loc },
        })),
        strictModeViolations: strictModeViolations.map(({ node: { loc } }) => ({
          node: { loc },
        })),
        dynamicRequires: dynamicRequires.map(({ node: { loc } }) => ({
          node: { loc },
        })),
      }
    } else {
      // warn if non-compatible code found
      if (inspector.listenerCount('compat-warning') > 0) {
        inspector.emit('compat-warning', { moduleRecord, compatWarnings })
      } else {
        const samples = jsonStringify({
          primordialMutations: primordialMutations.map(({ node }) =>
            // @ts-expect-error `SesCompatNode` / `Node.loc` mismatch
            codeSampleFromAstNode(node, moduleRecord)
          ),
          strictModeViolations: strictModeViolations.map(({ node }) =>
            // @ts-expect-error `SesCompatNode` / `Node.loc` mismatch
            codeSampleFromAstNode(node, moduleRecord)
          ),
          dynamicRequires: dynamicRequires.map(({ node }) =>
            // @ts-expect-error `SesCompatNode` / `Node.loc` mismatch
            codeSampleFromAstNode(node, moduleRecord)
          ),
        })
        const errMsg = `Incompatible code detected in package "${packageName}" file "${moduleRecord.file}". Violations:\n${samples}`
        console.warn(errMsg)
      }
    }
  }
@param {AST} ast
@param {import('./moduleRecord').LavamoatModuleRecord} moduleRecord
@param {boolean} includeDebugInfo
@returns