---
phase: 65.1-phase-65-code-review-remediation
plan: 09
type: execute
wave: 3
depends_on:
  - 65.1-03a
  - 65.1-03b
  - 65.1-01
files_modified:
  - src/lib.rs
  - src/type_cache.rs
  - src/query/table_function.rs
  - test/sql/phase651_null_name_inputs.test
autonomous: true
requirements:
  - REM-IN-02
  - REM-IN-03
  - REM-IN-05

must_haves:
  truths:
    - "`src/type_cache.rs` module deleted; `mod type_cache;` / `pub mod type_cache;` declaration removed from `src/lib.rs`"
    - "`type_id_to_display_name` function in `src/query/table_function.rs` (lines 500-568) deleted; no other references in the crate"
    - "sqllogictest `phase651_null_name_inputs.test` populated with assertions: `read_yaml_from_semantic_view(NULL) IS NULL`, `get_ddl(NULL, 'x') IS NULL`, `get_ddl('SEMANTIC_VIEW', NULL) IS NULL`"
    - "Crate compiles, all existing tests pass, ~225 LOC purged (IN-02 + IN-03 combined)"
  artifacts:
    - path: src/type_cache.rs
      provides: "DELETED — module no longer exists"
    - path: src/lib.rs
      provides: "Updated module declarations; `mod type_cache` removed"
    - path: src/query/table_function.rs
      provides: "`type_id_to_display_name` function deleted"
    - path: test/sql/phase651_null_name_inputs.test
      provides: "Three null-input scalar assertions per D-25"
      contains: "IS NULL"
  key_links:
    - from: src/lib.rs
      to: src/type_cache.rs
      via: "DELETED — `mod type_cache;` line removed"
      pattern: "type_cache"
---

<objective>
Three internal cleanups + one sqllogictest addition, all Rust-side or test-side. No C++ changes.

1. **IN-02 (D-23)** — delete `src/type_cache.rs` entirely + the `mod type_cache;` declaration in `src/lib.rs`.
2. **IN-03 (D-23)** — delete `type_id_to_display_name` function from `src/query/table_function.rs:500-568`.
3. **IN-05 (D-25)** — populate `test/sql/phase651_null_name_inputs.test` (Plan 01 stub) with three null-input assertions.

**B-04 absorption (REMOVED from this plan)**: IN-06 dedup work (`probe_catalog_table_present` + `write_err` deletion from `src/ddl/list.rs`) was moved to Plan 03a per plan-checker. Plan 03a is the natural moment for that dedup because it migrates both copies to `&BorrowedConnection`. This plan no longer touches `src/ddl/list.rs`.

~225 LOC purged (IN-02 + IN-03). The IN-06 LOC is now reported in Plan 03a's SUMMARY.

Wave 3 because:
- Depends on Plan 03b (Plan 03b touches `src/query/table_function.rs` for the BorrowedConnection migration of `sv_semantic_view_bind_rust` and `try_infer_schema`; this plan also touches the same file to delete `type_id_to_display_name` — same-file conflict forces sequential ordering)
- Depends on Plan 03a (the IN-06 absorption work landed there; we list the dep for safety against any indirect interaction)
- Depends on Plan 01 (Wave 0 stub `test/sql/phase651_null_name_inputs.test` populated here)

Implements D-23 (IN-02/IN-03) + D-25 (IN-05). D-26 (IN-06) is in Plan 03a.
</objective>

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

<context>
@.planning/PROJECT.md
@.planning/STATE.md
@.planning/phases/65.1-phase-65-code-review-remediation/65.1-CONTEXT.md
@.planning/phases/65.1-phase-65-code-review-remediation/65.1-RESEARCH.md
@.planning/phases/65.1-phase-65-code-review-remediation/65.1-PATTERNS.md
@src/lib.rs
@src/type_cache.rs
@src/query/table_function.rs
@test/sql/phase651_null_name_inputs.test
</context>

<tasks>

<task type="auto">
  <name>Task 1: Delete type_cache module and type_id_to_display_name function (IN-02 + IN-03)</name>
  <read_first>
    - src/type_cache.rs (full file — confirm no surprising public API consumed elsewhere; if grep shows consumers, halt and surface)
    - src/lib.rs (find the `mod type_cache;` or `pub mod type_cache;` declaration)
    - src/query/table_function.rs lines 500-568 (the `type_id_to_display_name` function to delete; AFTER Plan 03b's BorrowedConnection migration of nearby functions — confirm line numbers are still valid by grepping for `fn type_id_to_display_name`)
    - .planning/phases/65.1-phase-65-code-review-remediation/65.1-RESEARCH.md lines 716-723 (D-23 detail)
  </read_first>
  <files>src/lib.rs, src/type_cache.rs, src/query/table_function.rs</files>
  <action>
1. **Search for consumers FIRST** before deleting anything:
   ```
   grep -rn "type_cache" src/ tests/ benches/
   grep -rn "type_id_to_display_name" src/ tests/ benches/
   ```
   Document any non-trivial consumers in the SUMMARY. Per RESEARCH.md, both are unused — IF the grep returns more than the deletion sites themselves, halt and report; do not proceed.

2. **Delete `src/type_cache.rs`** in its entirety (`rm src/type_cache.rs` — or use the Write tool with empty content if that's not supported, then delete via shell).

3. **Remove the `mod type_cache;` (or `pub mod type_cache;`) line from `src/lib.rs`.** If a `use type_cache::*;` or similar import exists, remove that too.

4. **Delete `type_id_to_display_name` from `src/query/table_function.rs`** (originally lines 500-568 per research; locate via `grep -n "fn type_id_to_display_name" src/query/table_function.rs` since Plan 03b may have shifted line numbers). Also delete any helper-only-used-by-this-function private items in the same range. Do NOT delete unrelated items.

5. Verify `cargo build` and `cargo test` both succeed — if anything calls `type_id_to_display_name`, the compile fails and points at the consumer; surface that in the summary rather than papering over with `#[allow(dead_code)]`.
  </action>
  <verify>
    <automated>cargo build &gt; /tmp/claude/p09_t1_build.log 2>&amp;1; RC=$?; tail -40 /tmp/claude/p09_t1_build.log; test $RC -eq 0 &amp;&amp; ! test -f src/type_cache.rs &amp;&amp; ! grep -q "mod type_cache" src/lib.rs &amp;&amp; ! grep -q "type_id_to_display_name" src/query/table_function.rs</automated>
  </verify>
  <acceptance_criteria>
    - `src/type_cache.rs` no longer exists
    - `grep -rn "type_cache" src/` returns zero matches
    - `grep -rn "type_id_to_display_name" src/` returns zero matches
    - `cargo build` exits 0
    - `cargo test` exits 0
    - Approximate LOC delta: -225 (per RESEARCH.md estimate; report actual)
  </acceptance_criteria>
  <done>IN-02 + IN-03 closed: dead code purged; build green.</done>
</task>

<task type="auto">
  <name>Task 2: Populate phase651_null_name_inputs.test sqllogictest (IN-05)</name>
  <read_first>
    - test/sql/phase651_null_name_inputs.test (the Plan 01 stub)
    - test/sql/65_metadata_via_sql.test (template for existing scalar null-handling assertions to copy the style)
    - .planning/phases/65.1-phase-65-code-review-remediation/65.1-CONTEXT.md (D-25 — exact assertion shapes)
    - .planning/phases/65.1-phase-65-code-review-remediation/65.1-RESEARCH.md lines 745-763 (target test body)
  </read_first>
  <files>test/sql/phase651_null_name_inputs.test</files>
  <action>
Replace the Plan 01 stub body. The populated test must contain at least these three `query I` blocks (D-25 verbatim assertions):

```
# Phase 65.1 Plan 09 (IN-05, D-25) — null name vector input handling for scalar functions

query I
SELECT read_yaml_from_semantic_view(NULL) IS NULL
----
true

query I
SELECT get_ddl(NULL, 'x') IS NULL
----
true

query I
SELECT get_ddl('SEMANTIC_VIEW', NULL) IS NULL
----
true
```

If any of these scalar functions ALSO accept other null shapes (e.g. `get_ddl(NULL, NULL)`), add those as additional assertions for completeness. But the three above are the D-25 hard requirements.

Confirm the file is in TEST_LIST (Plan 01 added it; verify it's still there).
  </action>
  <verify>
    <automated>just test-sql &gt; /tmp/claude/p09_t2_sql.log 2>&amp;1; RC=$?; tail -40 /tmp/claude/p09_t2_sql.log; test $RC -eq 0 &amp;&amp; grep -q "read_yaml_from_semantic_view(NULL)" test/sql/phase651_null_name_inputs.test &amp;&amp; grep -q "get_ddl(NULL, 'x')" test/sql/phase651_null_name_inputs.test &amp;&amp; grep -q "get_ddl('SEMANTIC_VIEW', NULL)" test/sql/phase651_null_name_inputs.test</automated>
  </verify>
  <acceptance_criteria>
    - File contains all three required `query I` blocks asserting `IS NULL` returns `true`
    - `just test-sql` exits 0 — assertions pass
    - File is still listed in `test/sql/TEST_LIST`
  </acceptance_criteria>
  <done>IN-05 closed: null name vector inputs covered by sqllogictest.</done>
</task>

</tasks>

<verification>
  <automated>just test-all &gt; /tmp/claude/p09_all.log 2>&amp;1; RC=$?; tail -100 /tmp/claude/p09_all.log; test $RC -eq 0</automated>
</verification>

<success_criteria>
- `src/type_cache.rs` deleted; `type_id_to_display_name` deleted; ~225 LOC purged
- `phase651_null_name_inputs.test` populated with 3 required assertions
- IN-06 work landed in Plan 03a (not here) — verify no `src/ddl/list.rs` changes in this plan
- `just test-all` green
</success_criteria>

<output>
Create `.planning/phases/65.1-phase-65-code-review-remediation/65.1-09-SUMMARY.md` when done.
</output>
