<!-- SPDX-License-Identifier: MIT -->
<!-- SPDX-FileCopyrightText: 2025-2026 Marcus Quinn -->

# t1364.6: Wire Bundles into Dispatch, Quality Gates, and Agent Routing

## Origin

- **Created:** 2026-02-28
- **Session:** claude-code:headless
- **Created by:** ai-interactive
- **Parent task:** t1364
- **Conversation context:** Decomposition of issue #2558 item 4. This subtask wires bundles into the existing pipeline.

## What

Integration of bundle-based project presets into dispatch, quality gates, and agent routing so project-type-appropriate defaults are used automatically.

## Why

The schema (t1364.4) and detection (t1364.5) are useless without pipeline integration. This is the "last mile" that makes bundles actually affect behaviour.

## How (Approach)

- **dispatch.sh**: Before dispatching, call `get_bundle_config()` for the target repo. Use bundle's `model_defaults` for task-type-to-model mapping, `max_concurrency` for per-repo limits, `default_timeout` for worker timeout.
- **linters-local.sh**: Source bundle-helper.sh, call `get_quality_gates()` and `should_skip_gate()`. Only run gates in the bundle's quality_gates list. Skip gates in skip_gates.
- **Agent routing**: Read bundle's `agent_routing` to override default Build+ routing when appropriate (e.g., content-site routes SEO tasks to SEO agent).
- **model-routing.md**: Document how bundles interact with model routing — bundle defaults are suggestions, explicit `model:` tags in TODO.md take precedence.
- **AGENTS.md / build.txt**: Document bundle system in capabilities section.

## Acceptance Criteria

- [ ] dispatch.sh uses bundle config for model selection
  ```yaml
  verify:
    method: codebase
    pattern: "bundle\\|get_bundle_config\\|get_model_default"
    path: ".agents/scripts/supervisor/dispatch.sh"
  ```
- [ ] linters-local.sh respects bundle quality gates
  ```yaml
  verify:
    method: codebase
    pattern: "bundle\\|get_quality_gates\\|should_skip_gate"
    path: ".agents/scripts/linters-local.sh"
  ```
- [ ] model-routing.md documents bundle interaction
  ```yaml
  verify:
    method: codebase
    pattern: "[Bb]undle"
    path: ".agents/tools/context/model-routing.md"
  ```
- [ ] All modified scripts pass ShellCheck
  ```yaml
  verify:
    method: bash
    run: "shellcheck .agents/scripts/linters-local.sh .agents/scripts/supervisor/dispatch.sh"
  ```

## Context & Decisions

- Bundle defaults are suggestions, not hard overrides — explicit model: tags in TODO.md always win
- Quality gate skipping is additive — if a bundle says skip shellcheck, it's skipped even if another composed bundle includes it (skip wins)
- Agent routing from bundles is a default — task-level routing (e.g., `--agent SEO`) always overrides

## Relevant Files

- `.agents/scripts/supervisor/dispatch.sh` — dispatch pipeline
- `.agents/scripts/linters-local.sh` — quality gate runner
- `.agents/tools/context/model-routing.md` — model routing docs
- `.agents/AGENTS.md` — capabilities documentation
- `prompts/build.txt` — universal rules

## Dependencies

- **Blocked by:** t1364.4, t1364.5
- **Blocks:** none

## Estimate Breakdown

| Phase | Time | Notes |
|-------|------|-------|
| Research/read | 30m | Review dispatch, linters |
| Implementation | 1.5h | Three integration points |
| Documentation | 30m | model-routing.md, AGENTS.md |
| Testing | 30m | End-to-end bundle flow |
| **Total** | **~3h** | |
