---
phase: 16-integration-hardening
plan: 03
type: execute
wave: 3
depends_on:
  - 16-02
files_modified:
  - .planning/PROJECT.md
autonomous: true
requirements:
  - QUAL-01

must_haves:
  truths:
    - "uv run ruff check . exits 0 — zero violations across all source and test files"
    - "uv run mypy src/ exits 0 — zero type errors in 54+ source files"
    - "uv run pytest --tb=no -q reports 320+ tests passing, 0 failed"
    - "corpus index completes normally against a minimal TS fixture (end-to-end smoke test)"
    - "PROJECT.md v1.5 requirements section updated to reflect IDX-08, IDX-09, QUAL-01 as Validated"
  artifacts:
    - path: ".planning/PROJECT.md"
      provides: "v1.5 requirements IDX-08, IDX-09, QUAL-01 marked Validated"
      contains: "IDX-08"
  key_links:
    - from: "uv run ruff check ."
      to: "tests/ingest/test_chunker.py and src/corpus_analyzer/ingest/ts_chunker.py"
      via: "full-repo lint sweep"
      pattern: "exit 0"
    - from: "uv run mypy src/"
      to: "src/corpus_analyzer/ingest/ts_chunker.py"
      via: "strict type check after lazy import restructure"
      pattern: "exit 0"
    - from: "corpus index"
      to: "chunk_typescript via chunk_file dispatch"
      via: "CLI invocation on TS fixture in tmp_path"
      pattern: "corpus index"
---

<objective>
Validation gate: confirm the entire codebase passes the zero-violation quality gate (ruff + mypy + all tests) after all v1.5 changes. Run an end-to-end smoke test of `corpus index` against a real TS file to confirm dispatch wiring. Update PROJECT.md to mark v1.5 requirements IDX-08, IDX-09, QUAL-01 as Validated.

Purpose: Declare v1.5 milestone complete with evidence. This is the last plan in v1.5.
Output: Confirmed quality gate passage + updated PROJECT.md.
</objective>

<execution_context>
@/home/ollie/.claude/get-shit-done/workflows/execute-plan.md
@/home/ollie/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/REQUIREMENTS.md
@.planning/phases/16-integration-hardening/16-CONTEXT.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Run quality gate — ruff, mypy, full test suite</name>
  <files></files>
  <action>
Run each quality gate command in sequence. All must exit 0 / pass. If any fails, fix the issue before proceeding.

**Step 1 — Ruff lint sweep (full repo):**
```bash
uv run ruff check .
```
Expected: exits 0, no output. If violations remain, fix them before continuing.

**Step 2 — Mypy strict type check:**
```bash
uv run mypy src/
```
Expected: exits 0, "Success: no issues found in 54 source files" (or similar). If errors appear in ts_chunker.py (most likely candidate — lazy import restructure), fix as follows:
- If `Parser` type is unresolved: change `_get_cached_parser` return type to `Any` or ensure `if TYPE_CHECKING:` block imports `Parser`
- Other errors: fix inline without changing behavior

**Step 3 — Full pytest suite:**
```bash
uv run pytest --tb=short -q
```
Expected: 320+ tests, 0 failed. Minimum is 320 (318 pre-phase-16 + 2 new tests from 16-01). If count is lower, investigate immediately — do not continue.

**Step 4 — End-to-end smoke test of `corpus index` against a TS fixture:**

Create a minimal temporary directory with a TS file and run `corpus index`:
```bash
SMOKE_DIR=$(mktemp -d)
cat > "$SMOKE_DIR/example.ts" << 'TSEOF'
export function greet(name: string): string {
    return `Hello, ${name}!`;
}

export const PI = 3.14159;
TSEOF

uv run corpus index "$SMOKE_DIR" --db /tmp/smoke-test-corpus.sqlite
echo "Exit code: $?"
rm -rf "$SMOKE_DIR" /tmp/smoke-test-corpus.sqlite
```

Expected: exit code 0. `corpus index` should complete without errors. The TS file will be indexed via `chunk_typescript()` through the `chunk_file()` dispatch path.

Note: `corpus index` is the LanceDB ingest path (`ingest/indexer.py`), not the SQLite extract path. If the smoke test uses a different CLI verb, check `uv run corpus --help` and use the correct command that invokes chunking on TS files.

Alternative if `corpus index` is not the right command: use the `extract` command with the SQLite database:
```bash
SMOKE_DIR=$(mktemp -d)
echo 'export function greet(name: string): string { return "hi"; }' > "$SMOKE_DIR/example.ts"
uv run corpus extract "$SMOKE_DIR" --db /tmp/smoke-corpus.sqlite
echo "Exit code: $?"
rm -rf "$SMOKE_DIR" /tmp/smoke-corpus.sqlite
```

Either approach confirms end-to-end dispatch wiring works.

Record the actual exit code and any output in the commit message or SUMMARY.
  </action>
  <verify>
    <automated>uv run ruff check . && uv run mypy src/ && uv run pytest --tb=no -q 2>&1 | tail -3</automated>
    <manual>Confirm ruff exits 0, mypy exits 0, pytest shows 320+ tests 0 failed. Confirm smoke test exit code 0.</manual>
  </verify>
  <done>ruff exits 0. mypy exits 0. pytest reports 320+ tests, 0 failed. Smoke test (corpus index or corpus extract on a TS fixture) exits 0.</done>
</task>

<task type="auto">
  <name>Task 2: Update PROJECT.md — mark v1.5 IDX-08, IDX-09, QUAL-01 as Validated</name>
  <files>.planning/PROJECT.md</files>
  <action>
Read the current `.planning/PROJECT.md`. Find the v1.5 requirements section. Update the status of IDX-08, IDX-09, and QUAL-01 from "Active" (or equivalent) to "Validated".

The exact format depends on how PROJECT.md currently tracks requirement status. Common patterns:
- If it uses `[ ]`/`[x]` checkboxes: mark IDX-08, IDX-09, QUAL-01 as `[x]`
- If it uses a status column in a table: change "Active" → "Validated" for those three IDs
- If it has a "Validated" section: move those three IDs there

Also update the "Current focus" or "v1.5 status" line to reflect Phase 16 complete.

If PROJECT.md does not have a v1.5 requirements tracking section, add one at the bottom under a `## v1.5 Milestone Validation` heading:

```markdown
## v1.5 Milestone Validation

**Completed:** 2026-02-24

| Requirement | Description | Status |
|-------------|-------------|--------|
| IDX-08 | Size guard: 50K+ char files fall back to chunk_lines | Validated |
| IDX-09 | ImportError fallback when tree-sitter absent | Validated |
| QUAL-01 | ruff + mypy + 320 tests all pass | Validated |
```

Commit after updating:
`docs(16-03): mark v1.5 requirements IDX-08, IDX-09, QUAL-01 as validated`
  </action>
  <verify>
    <automated>grep -E "IDX-08|IDX-09|QUAL-01" .planning/PROJECT.md</automated>
    <manual>Confirm all three requirement IDs appear in PROJECT.md with Validated status or equivalent</manual>
  </verify>
  <done>PROJECT.md contains IDX-08, IDX-09, QUAL-01 marked as Validated (or equivalent complete state). Commit created for the documentation update.</done>
</task>

</tasks>

<verification>
After completing this plan:

```bash
# Full quality gate
uv run ruff check . && echo "RUFF OK"
uv run mypy src/ && echo "MYPY OK"
uv run pytest --tb=no -q 2>&1 | tail -3

# Confirm requirement IDs in PROJECT.md
grep -E "IDX-08|IDX-09|QUAL-01" .planning/PROJECT.md

# Confirm test count floor
uv run pytest --tb=no -q 2>&1 | grep -E "passed|failed"
```
</verification>

<success_criteria>
1. `uv run ruff check .` exits 0 — zero violations across entire repo
2. `uv run mypy src/` exits 0 — zero type errors
3. `uv run pytest --tb=no -q` reports 320+ tests, 0 failed
4. `corpus index` (or `corpus extract`) smoke test on a TS fixture exits 0
5. PROJECT.md updated: IDX-08, IDX-09, QUAL-01 marked as Validated
6. v1.5 milestone confirmed complete
</success_criteria>

<output>
After completion, create `.planning/phases/16-integration-hardening/16-16-03-SUMMARY.md`
</output>
