---
id: TASK-10.6
title: Cover remaining configurator parsing and workspace branches
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 12:05'
updated_date: '2026-02-04 12:39'
labels: []
dependencies: []
references:
  - luacov.report.out
  - spec/api_spec/configurator_spec.lua
  - lua/zync/api/configurator.lua
parent_task_id: TASK-10
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add configurator tests to cover untested parsing helpers (comments, escapes, missing profiles block) and workspace-derived Zephyr base/workspace logic.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover extract_profile_order behavior with block comments, escaped strings, and when no profiles block exists (returns empty).
- [x] #2 Tests cover profile_order_from_config fallback to table iteration when the source does not contain profiles block (assert order present).
- [x] #3 Tests cover apply_profile error when profile is specified but profiles are not configured (assert error in non-build context).
- [x] #4 Tests cover zephyr workspace/base derivation from ZEPHYR_BASE and ZEPHYR_WORKSPACE environment variables (both directions).
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add configurator specs for profile-order parsing edge cases:
   - zconf.lua with block comments and quoted keys with escapes to exercise `skip_block_comment`, `skip_string`, and `scan_string` escape handling.
   - zconf.lua without any `profiles` block to ensure `extract_profile_order` returns empty and `profile_order_from_config` falls back to table iteration.
2. Add configurator spec to assert `apply_profile` errors when `profile` is specified but `profiles` are not configured (non-build context).
3. Add configurator specs for Zephyr base/workspace derivation:
   - ZEPHYR_BASE set (ending in `/zephyr`) and ZEPHYR_WORKSPACE empty → workspace inferred.
   - ZEPHYR_WORKSPACE set and ZEPHYR_BASE empty → base inferred.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added configurator specs for block comments and escaped-string profile keys, missing profiles block fallback, profile specified without profiles error, and zephyr base/workspace derivation from env vars.

Ran `busted spec/api_spec/configurator_spec.lua` (14/0/0/0).
<!-- SECTION:NOTES:END -->
