# TASK 4: Add Regression Coverage For Export Success, Failure, And Contract Shape

## Summary

Lock `curated_to_s3` behavior with regression tests covering command shaping, stage integration, and failure semantics.

## Dependencies

- [TASK 3](./TASK3.md) - Add Brink `curated_to_s3` stage and wire pipeline ordering

## Files to Modify

- `backend/tests/Kds.Ai.Integrations.Tests/Etl/*`
- `backend/tests/Kds.Ai.Integrations.Tests/BrinkPos/*`
- optionally live/integration-style test project if existing S3 + Redshift fixture already fits

## Progress Checklist

- [ ] Shared executor tests added
- [ ] `UNLOAD` Parquet command test added
- [ ] Curated S3 path usage test added
- [ ] Executor failure diagnostics test added
- [ ] Brink adapter stage-order test updated
- [ ] Brink export target-scope test added
- [ ] Brink stage success-path test added
- [ ] Brink stage failure-path test added
- [ ] Parent ETL run failure-on-export-failure test added
- [ ] Optional integration/live coverage evaluated and documented

## Required Coverage

### 1. Shared executor coverage

- verifies `UNLOAD` command generation for Parquet,
- verifies standard curated S3 path usage,
- verifies executor failure bubbles useful diagnostics.

### 2. Brink stage coverage

- verifies adapter stage order includes `curated_to_s3`,
- verifies only `pos_orders` and `pos_order_items` export,
- verifies stage success path,
- verifies stage failure path.

### 3. Pipeline contract coverage

- verifies parent ETL run is not green when export fails,
- verifies export stage is part of runtime contract rather than dormant constant only,
- verifies framework contracts can describe adapter-owned export targets.

## Acceptance Criteria

- shared executor has regression tests,
- Brink export stage has regression tests,
- pipeline success boundary test covers export failure,
- tests document first exported entity scope.

## Notes

- Prefer focused unit tests first.
- Add live/integration-style test only if current test infrastructure already supports it cheaply.
