---
id: TASK-39.2
title: Discover sysbuild images early and link correct compile_commands.json
status: Done
assignee:
  - mrbya
created_date: '2026-03-05 16:41'
updated_date: '2026-03-05 16:43'
labels: []
dependencies: []
parent_task_id: TASK-39
priority: medium
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Identify sysbuild images early (before command-specific image resolution), then select the project app image matching the project_root directory name for compile_commands.json linkage without relying on per-command resolution.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Sysbuild images are discovered early enough to support compile_commands.json linking on commands that don’t resolve images.
- [ ] #2 The selected compile_commands.json always comes from the project app image whose name matches the project_root directory name.
- [ ] #3 External app images are never chosen for the link.
- [ ] #4 Failure to identify the project app image is handled without linking the file.
- [ ] #5 Tests cover early discovery plus correct app-image selection and non-selection cases.
<!-- AC:END -->
