fn has_task_definition_in_run(
        loader: &TurboJsonLoader,
        workspace: &PackageName,
        task_name: &TaskName<'static>,
        task_id: &TaskId,
    ) -> Result<bool, Error> {
        let turbo_json = loader.load(workspace).map_or_else(
            |err| {
                if matches!(err, config::Error::NoTurboJSON)
                    && !matches!(workspace, PackageName::Root)
                {
                    Ok(None)
                } else {
                    Err(err)
                }
            },
            |turbo_json| Ok(Some(turbo_json)),
        )?;

        let Some(turbo_json) = turbo_json else {
            // If there was no turbo.json in the workspace, fallback to the root turbo.json
            return Self::has_task_definition_in_run(
                loader,
                &PackageName::Root,
                task_name,
                task_id,
            );
        };

        let task_id_as_name = task_id.as_task_name();
        if
        // See if pkg#task is defined e.g. `docs#build`. This can only happen in root turbo.json
        turbo_json.tasks.contains_key(&task_id_as_name)
            // See if task is defined e.g. `build`. This can happen in root or workspace turbo.json
            // This will fail if the user provided a task id e.g. turbo `docs#build`
            || turbo_json.tasks.contains_key(task_name)
            // If user provided a task id, then we see if the task is defined
            // e.g. `docs#build` should resolve if there's a `build` in root turbo.json or docs workspace level turbo.json
            || (matches!(workspace, PackageName::Root) && turbo_json.tasks.contains_key(&TaskName::from(task_name.task())))
            || (workspace == &PackageName::from(task_id.package()) && turbo_json.tasks.contains_key(&TaskName::from(task_name.task())))
        {
            Ok(true)
        } else if !matches!(workspace, PackageName::Root) {
            Self::has_task_definition_in_run(loader, &PackageName::Root, task_name, task_id)
        } else {
            Ok(false)
        }
    }
Checks if there's a task definition in the current run
crates/turborepo-lib/src/engine/builder.rs