---
id: TASK-10.7
title: Cover remaining sandbox error branches and limits
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 12:05'
updated_date: '2026-02-04 12:40'
labels: []
dependencies: []
references:
  - luacov.report.out
  - spec/api_spec/sandbox_spec.lua
  - lua/zync/api/configurator/sandbox.lua
parent_task_id: TASK-10
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Add sandbox tests to cover remaining error branches: nil/empty path, loadfile/load errors, instruction/time limits, config-too-large, and sandbox global mutation errors.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover load_zconf with empty path returning the 'Failed to load zync config' error path.
- [x] #2 Tests cover loadfile or load() error paths (e.g., invalid Lua syntax), asserting error propagation.
- [x] #3 Tests cover runtime limit errors (instruction/time limit) by executing a deliberate busy loop in zconf under sandbox and asserting error message.
- [x] #4 Tests cover size limit 'config too large' (nodes) and sandbox global access/definition errors (__index/__newindex).
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add sandbox spec for empty path (`''`) to assert “Failed to load zync config.”
2. Add sandbox spec for invalid Lua syntax to exercise loadfile/load error propagation.
3. Add sandbox spec that triggers runtime limits using a deliberate busy loop (instruction/time) and assert the error message.
4. Add sandbox spec for size limit “config too large” (many nodes) and sandbox global mutation errors (`__index`/`__newindex`).
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added sandbox specs for empty path error, invalid syntax propagation, runtime limit enforcement, config-too-large, and sandbox global definition error.

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