---
id: TASK-10.8
title: >-
  Cover remaining configurator parsing branches (skip_string/skip_ws
  comments/fallback order)
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 12:43'
updated_date: '2026-02-04 12:44'
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 specs to exercise the remaining untested parsing branches in `lua/zync/api/configurator.lua` seen in the latest luacov report (skip_string, skip_ws_and_comments comment handling, find_profiles_block comment/string paths, extract_profile_order no-profiles path, and profile_order_from_config table-iteration fallback).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests hit skip_string via a zconf.lua that has quoted strings before the profiles block (ensure parsing still finds profiles).
- [x] #2 Tests hit skip_ws_and_comments comment branches by including both line and block comments in and around the profiles block (ensure order extracted correctly).
- [x] #3 Tests cover extract_profile_order returning empty when no profiles block exists and profile_order_from_config falls back to table iteration (assert order contains all profiles).
- [x] #4 Tests cover apply_profile error when profiles is not a table (assert error in non-build context).
- [x] #5 Tests are meaningful and assert behavior, not just line hits.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add a configurator spec with a zconf.lua that contains quoted strings before the `profiles` block (to exercise `skip_string` and `find_profiles_block`), and assert `profile_order` is extracted correctly.
2. Add a configurator spec that includes both line comments and block comments inside/around the `profiles` block, ensuring `skip_ws_and_comments` paths are exercised and order is correct.
3. Add a configurator spec where the zconf source has no `profiles` block but `profiles` table exists (force `extract_profile_order` empty and `profile_order_from_config` fallback to table iteration).
4. Add a configurator spec to assert `apply_profile` errors when `profiles` is not a table (non-build context).
5. Keep assertions behavior-focused (profile_order contents, selected profile, errors).
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added configurator specs to cover skip_string/quoted preface, line+block comment parsing, profiles-block-in-string fallback to table iteration, and profiles-not-table error handling.

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