---
phase: 54-dashboard-workflow-closure
plan: 003
type: execute
wave: 2
depends_on: ["54-002"]
files_modified:
  - .github/workflows/ci-chaos.yml
autonomous: true
requirements: [CI-05]

must_haves:
  truths:
    - "ci-chaos.yml runs chaos tests on a weekly schedule (Sunday 06:00 UTC)"
    - "ci-chaos.yml can be triggered manually via workflow_dispatch"
    - "Chaos tests run on ubuntu-latest with Python 3.11"
    - "Chaos tests are explicitly excluded from the regular CI gate (ci.yml unchanged)"
    - "CI chaos workflow is independent — does not block PRs or merge-to-main"
  artifacts:
    - path: ".github/workflows/ci-chaos.yml"
      provides: "Scheduled + manual chaos test workflow"
      contains: "schedule"
    - path: ".github/workflows/ci-chaos.yml"
      provides: "workflow_dispatch trigger for manual execution"
      contains: "workflow_dispatch"
    - path: ".github/workflows/ci-chaos.yml"
      provides: "pytest tests/chaos/ -m chaos invocation"
      contains: "pytest tests/chaos"
  key_links:
    - from: ".github/workflows/ci-chaos.yml"
      to: "tests/chaos/"
      via: "pytest tests/chaos/ -m chaos runs all chaos tests"
      pattern: "tests/chaos"
    - from: ".github/workflows/ci-chaos.yml"
      to: ".github/workflows/ci.yml"
      via: "ci-chaos.yml is a separate file from ci.yml — chaos tests explicitly excluded from regular CI"
      pattern: "NOT present in ci.yml"
---

<objective>
**Objective:** Create the scheduled chaos CI workflow (`ci-chaos.yml`) that runs Level 6 destructive tests weekly and on manual trigger.

**Purpose:** Chaos tests are destructive by nature (corrupt inputs, network failures, filesystem errors). They must run in isolation, on a controlled schedule, separately from the main CI gate that blocks PRs. A weekly cadence catches regressions in abnormal path handling without blocking day-to-day development.

**Output:** `.github/workflows/ci-chaos.yml` — standalone workflow, one file, one job.
</objective>

<execution_context>
@C:/Users/Lin/.opencode/get-shit-done/workflows/execute-plan.md
@C:/Users/Lin/.opencode/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/REQUIREMENTS.md
@.planning/ROADMAP.md
@.github/workflows/ci.yml

<interfaces>
Existing CI pattern from .github/workflows/ci.yml:
```yaml
name: CI
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  plugin-tests:
    name: Plugin Tests (L3)
    runs-on: ubuntu-latest
    # ... path-filtered, only runs on plugin changes
```
</interfaces>
</context>

<tasks>

<task type="auto" tdd="false">
  <name>Task 1: Create ci-chaos.yml Workflow</name>
  <files>
    - .github/workflows/ci-chaos.yml
  </files>
  <action>
    Create `.github/workflows/ci-chaos.yml` — a standalone GitHub Actions workflow for chaos/destructive tests only.

    ```yaml
    name: Chaos Tests (L6)

    on:
      schedule:
        # Weekly: Sunday 06:00 UTC
        - cron: "0 6 * * 0"
      workflow_dispatch:
        # Manual trigger from GitHub UI — no parameters needed

    jobs:
      chaos-tests:
        name: Chaos / Destructive Tests
        runs-on: ubuntu-latest

        steps:
          - uses: actions/checkout@v4

          - uses: actions/setup-python@v5
            with:
              python-version: "3.11"

          - name: Install package with test dependencies
            run: |
              pip install -e ".[test]"
              pip install pytest pytest-timeout responses

          - name: Run chaos tests
            run: |
              python -m pytest tests/chaos/ -m chaos -v --tb=long --timeout=120 \
                --junit-xml=chaos-results.xml

          - name: Upload test results
            if: always()
            uses: actions/upload-artifact@v4
            with:
              name: chaos-test-results
              path: chaos-results.xml
    ```

    Key design decisions:
    1. **Schedule**: `0 6 * * 0` = Sunday 06:00 UTC (users' least active time)
    2. **Manual trigger**: `workflow_dispatch` — can be triggered from GitHub Actions UI
    3. **Single OS**: ubuntu-latest only — chaos tests don't need the OS/Python plasma matrix
    4. **Single Python**: 3.11 — latest stable; chaos tests test error handling, not platform compatibility
    5. **No path filtering**: Always run on schedule/manual — chaos tests are small/fast
    6. **junit-xml artifact**: Upload even on failure (`if: always()`) so failure details are preserved
    7. **Timeout**: 120 seconds per test — chaos tests involve subprocess calls which can hang on error paths
    8. **Verbose + long traceback**: `--tb=long` so failure details are visible in CI logs

    Do NOT modify `ci.yml` or any other workflow files. The chaos workflow must be entirely separate — chaos tests are excluded from the regular CI gate by design. The `pytest.mark.chaos` marker (already configured in pyproject.toml) ensures they never run in the default `pytest` invocation used by ci.yml.
  </action>
  <verify>
    <automated>python -c "import yaml; w=yaml.safe_load(open('.github/workflows/ci-chaos.yml')); assert 'schedule' in str(w['on']), 'Missing schedule trigger'; assert 'workflow_dispatch' in str(w['on']), 'Missing manual trigger'; assert 'tests/chaos' in str(w), 'Missing chaos test path'; assert 'chaos' in str(w['jobs']), 'Missing chaos job'; print('CI chaos workflow valid')"</automated>
  </verify>
  <done>
    ci-chaos.yml created with weekly schedule (Sunday 06:00 UTC), manual trigger (workflow_dispatch), runs chaos tests on ubuntu-latest with Python 3.11. Completely independent from ci.yml.
  </done>
</task>

</tasks>

<verification>
1. `ci-chaos.yml` has `schedule` trigger with weekly cron
2. `ci-chaos.yml` has `workflow_dispatch` for manual trigger
3. `ci-chaos.yml` runs `pytest tests/chaos/ -m chaos` (only chaos tests)
4. `ci.yml` is NOT modified — chaos tests excluded from regular CI gate
5. Workflow file parses as valid YAML
</verification>

<success_criteria>
- [ ] ci-chaos.yml exists with weekly schedule (cron: "0 6 * * 0")
- [ ] ci-chaos.yml supports manual trigger (workflow_dispatch)
- [ ] ci-chaos.yml runs pytest tests/chaos/ -m chaos
- [ ] ci.yml untouched — chaos tests excluded from PR/merge gate
</success_criteria>

<output>
After completion, create `.planning/phases/54-dashboard-workflow-closure/54-003-SUMMARY.md`
</output>
