---
phase: 06-rename-cleanup
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - "**/*.cs (all ~62 files — namespace string replace)"
  - Properties/AssemblyInfo.cs
  - FanucProgramManager.csproj → NcProgramManager.csproj
  - FanucProgramManager.sln → NcProgramManager.sln
  - FanucProgramManager.Tests/FanucProgramManager.Tests.csproj → NcProgramManager.Tests/NcProgramManager.Tests.csproj
  - FANUCMachine.cs (delete)
autonomous: true
---

<objective>
## Goal
Rename project from FanucProgramManager to NcProgramManager: namespace, assembly, project files, test folder, and delete dead legacy file.

## Purpose
Product is no longer Fanuc-only. Name FanucProgramManager is wrong. NcProgramManager reflects multi-CN scope.

## Output
- All namespaces: `FanucProgramManager` → `NcProgramManager`
- Project/solution files renamed
- Test folder renamed
- `FANUCMachine.cs` deleted (zero references outside itself)
- Solution builds with no errors
</objective>

<context>
## Project Context
@.paul/PROJECT.md
@.paul/STATE.md

## Key Files
@FanucProgramManager.csproj
@FanucProgramManager.sln
@Properties/AssemblyInfo.cs
@FanucProgramManager.Tests/FanucProgramManager.Tests.csproj
</context>

<acceptance_criteria>

## AC-1: Namespace renamed everywhere
```gherkin
Given any .cs file in the project
When opened
Then namespace declarations and using directives reference NcProgramManager (not FanucProgramManager)
```

## AC-2: Project and solution files updated
```gherkin
Given the renamed solution
When opened in Visual Studio or built with msbuild
Then assembly name is NcProgramManager, test assembly is NcProgramManager.Tests, project reference resolves
```

## AC-3: Dead code removed
```gherkin
Given FANUCMachine.cs
When cleanup completes
Then file does not exist (confirmed zero references before deletion)
```

</acceptance_criteria>

<tasks>

<task type="auto">
  <name>Task 1: Replace FanucProgramManager string in all .cs files</name>
  <files>All *.cs files under project root (recursively)</files>
  <action>
    Run find+sed to replace all occurrences of `FanucProgramManager` with `NcProgramManager` in every .cs file:

    ```bash
    find /path/to/project -name "*.cs" -exec sed -i 's/FanucProgramManager/NcProgramManager/g' {} +
    ```

    This covers:
    - `namespace FanucProgramManager` → `namespace NcProgramManager`
    - `namespace FanucProgramManager.Cnc` → `namespace NcProgramManager.Cnc`
    - `using FanucProgramManager;` → `using NcProgramManager;`
    - `using FanucProgramManager.Cnc.Fanuc;` → `using NcProgramManager.Cnc.Fanuc;`
    - All sub-namespaces (.Cnc, .Cnc.Fanuc, .Cnc.Heidenhain, .Cnc.Siemens, .Cnc.Mitsubishi, .Cnc.Models)
    - `InternalsVisibleTo("FanucProgramManager.Tests")` in AssemblyInfo.cs
    - `AssemblyTitle`, `AssemblyProduct` in AssemblyInfo.cs

    Avoid: editing binary files, NuGet package cache, obj/bin folders.
    Use: `-not -path "*/obj/*" -not -path "*/bin/*" -not -path "*/.paul/*"`
  </action>
  <verify>
    ```bash
    grep -r "FanucProgramManager" --include="*.cs" .
    ```
    Must return zero results.
  </verify>
  <done>AC-1 satisfied: no .cs file contains FanucProgramManager</done>
</task>

<task type="auto">
  <name>Task 2: Update project and solution metadata files</name>
  <files>
    FanucProgramManager.csproj,
    FanucProgramManager.Tests/FanucProgramManager.Tests.csproj,
    FanucProgramManager.sln
  </files>
  <action>
    In `FanucProgramManager.csproj`:
    - `<RootNamespace>FanucProgramManager</RootNamespace>` → `<RootNamespace>NcProgramManager</RootNamespace>`
    - `<AssemblyName>FanucProgramManager</AssemblyName>` → `<AssemblyName>NcProgramManager</AssemblyName>`

    In `FanucProgramManager.Tests/FanucProgramManager.Tests.csproj`:
    - `<RootNamespace>FanucProgramManager.Tests</RootNamespace>` → `<RootNamespace>NcProgramManager.Tests</RootNamespace>`
    - `<AssemblyName>FanucProgramManager.Tests</AssemblyName>` → `<AssemblyName>NcProgramManager.Tests</AssemblyName>`
    - `<ProjectReference Include="..\FanucProgramManager.csproj">` → `<ProjectReference Include="..\NcProgramManager.csproj">`
    - `<Name>FanucProgramManager</Name>` → `<Name>NcProgramManager</Name>`

    In `FanucProgramManager.sln`:
    - Project line: `"FanucProgramManager", "FanucProgramManager.csproj"` → `"NcProgramManager", "NcProgramManager.csproj"`
    - Project line: `"FanucProgramManager.Tests", "FanucProgramManager.Tests\FanucProgramManager.Tests.csproj"` → `"NcProgramManager.Tests", "NcProgramManager.Tests\NcProgramManager.Tests.csproj"`
  </action>
  <verify>
    ```bash
    grep -n "FanucProgramManager" FanucProgramManager.csproj FanucProgramManager.Tests/FanucProgramManager.Tests.csproj FanucProgramManager.sln
    ```
    Must return zero results.
  </verify>
  <done>AC-2 satisfied: all project metadata references NcProgramManager</done>
</task>

<task type="auto">
  <name>Task 3: Rename files/folder and delete dead code</name>
  <files>
    FANUCMachine.cs (delete),
    FanucProgramManager.csproj → NcProgramManager.csproj (rename),
    FanucProgramManager.sln → NcProgramManager.sln (rename),
    FanucProgramManager.Tests/ → NcProgramManager.Tests/ (folder rename),
    FanucProgramManager.Tests/FanucProgramManager.Tests.csproj → NcProgramManager.Tests/NcProgramManager.Tests.csproj (rename)
  </files>
  <action>
    1. Delete `FANUCMachine.cs` — confirmed dead: no file outside itself references `FANUCMachine`. Also remove its `<Compile Include="FANUCMachine.cs" />` entry from csproj.

    2. Rename project file:
       ```bash
       mv FanucProgramManager.csproj NcProgramManager.csproj
       ```

    3. Rename solution file:
       ```bash
       mv FanucProgramManager.sln NcProgramManager.sln
       ```

    4. Rename test folder (this moves all contents):
       ```bash
       mv FanucProgramManager.Tests NcProgramManager.Tests
       ```

    5. Rename test csproj inside the now-renamed folder:
       ```bash
       mv NcProgramManager.Tests/FanucProgramManager.Tests.csproj NcProgramManager.Tests/NcProgramManager.Tests.csproj
       ```

    Order matters: rename folder BEFORE renaming csproj inside it.
    The .sln file was already updated in Task 2 to reference new paths — verify paths match after rename.

    Avoid: renaming `Cnc/Fanuc/` folder or any Fanuc-prefixed class files — `FanucMachine`, `FanucConnectionConfig` etc. are manufacturer-specific names, keep them.
  </action>
  <verify>
    ```bash
    ls NcProgramManager.csproj NcProgramManager.sln NcProgramManager.Tests/NcProgramManager.Tests.csproj
    ls FANUCMachine.cs 2>&1   # must say: No such file
    grep "FANUCMachine" NcProgramManager.csproj  # must return nothing
    ```
  </verify>
  <done>AC-2 and AC-3 satisfied: files renamed, dead code deleted, .sln paths match physical files</done>
</task>

</tasks>

<boundaries>

## DO NOT CHANGE
- `Cnc/Fanuc/` folder name — Fanuc is a manufacturer name, not a project name
- `FanucMachine.cs`, `FanucConnectionConfig.cs`, `FanucCapabilities.cs` — manufacturer-specific class names, keep
- `FanucProgram.cs` — Fanuc ISO program format class, name is accurate
- `FanucProgramParsingTests.cs` — test file for FanucProgram, name is accurate
- `IFanucMachine.cs` — interface name correct (Fanuc-specific capability set)
- Any class name that describes Fanuc-specific behavior

## SCOPE LIMITS
- No Italian → English rename in this plan (deferred)
- No logic changes — pure rename/delete only
- No NuGet package changes
- No new files created

</boundaries>

<verification>
Before declaring plan complete:
- [ ] `grep -r "FanucProgramManager" --include="*.cs" .` returns zero results
- [ ] `grep -r "FanucProgramManager" --include="*.csproj" .` returns zero results
- [ ] `grep "FanucProgramManager" NcProgramManager.sln` returns zero results
- [ ] `ls FANUCMachine.cs` returns "No such file"
- [ ] `ls NcProgramManager.csproj NcProgramManager.sln NcProgramManager.Tests/` all exist
- [ ] All acceptance criteria met
</verification>

<success_criteria>
- All tasks completed
- All verification checks pass
- No FanucProgramManager references remain in .cs, .csproj, or .sln files
- FANUCMachine.cs deleted
- Project file names match NcProgramManager
</success_criteria>

<output>
After completion, create `.paul/phases/06-rename-cleanup/06-01-SUMMARY.md`
</output>
