nc_program_manager/.paul/STATE.md
dtrentin 3312a57757 feat(08-license-integration): wire RSA license check, remove -chiave arg
Replace AES checkLicense with MachineFingerprint+LicenseFile+LicenseValidator.
License.lic hardcoded next to EXE; -chiave= CLI arg and InputArgs.chiave removed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 23:10:05 +02:00

5.4 KiB

Project State

Project Reference

See: .paul/PROJECT.md (updated 2026-05-17)

Core value: Machinists transfer CNC programs to/from any controller without manual steps or internet Current focus: v0.2 — Phase 08 complete, Phase 09 (license-generator) next

Current Position

Milestone: v0.2 NcProgramManager Phase: 4 of 4 (09-license-generator) — Not started Status: Phase 08 complete, ready to plan Phase 09 Last activity: 2026-05-17 — Phase 08 license-integration complete (UNIFY done)

Progress:

  • Milestone v0.1: [██████████] 100% (complete)
  • Milestone v0.2: [███████░░░] 75%
  • Phase 09: [░░░░░░░░░░] 0%

Loop Position

PLAN ──▶ APPLY ──▶ UNIFY
  ✓        ✓        ✓     [Phase 08 closed]

What Was Built (v0.1 Multi-CN Release)

Phase 1 — CNC Abstraction

  • Namespace: Fanuc_integration.Cnc.*FanucProgramManager.Cnc.* (29 files)
  • IFocasDialect extended: UploadStart/DownloadStart accept short fileType
  • IFanucMachine created: extends ICncMachine with tool offset + work zero R/W
  • CncManufacturer enum: Fanuc, Heidenhain, Siemens, Mitsubishi
  • All 29 Cnc/**/*.cs files added to csproj

Phase 2 — Heidenhain LSV2

  • HeidenhainConnectionConfig — IP, port 19000, credentials, timeout
  • Lsv2Client — TCP framing, CRC-16/CCITT, login (SELECT+LOG_IN), ReceiveFile/SendFile
  • HeidenhainMachine : ICncMachine — RunGuardedAsync pattern, state machine

Phase 3 — Siemens + Mitsubishi FTP

  • SiemensConnectionConfig / SiemensFtpClient / SiemensMachine : ICncMachine
  • MitsubishiConnectionConfig / MitsubishiFtpClient / MitsubishiMachine : ICncMachine

Phase 4 — Wiring

  • CncMachineFactory — creates right ICncMachine from InputArgs
  • InputArgs — added manufacturer, username, password fields
  • Program.cs — full rewrite using ICncMachine; Fanuc 3-file via IFanucMachine cast

Phase 5 — NC Validator

  • ValidationSeverity / ValidationError / ValidationResult model types
  • INcProgramValidator + NcProgramValidator (5 universal + per-manufacturer rules)
  • Validator injected into all 4 machine classes; upload blocked on Error severity
  • NcProgramValidatorTests — 30+ NUnit tests

Test Infrastructure

  • NcProgramManager.Tests/ — NUnit 3.13.3 + Moq 4.18.4, .NET 4.7.2
  • FtpServerStub + Lsv2ServerStub — in-process TCP stubs
  • Unit + integration tests; Fanuc FOCAS tests [Ignore]d (Windows-only DLL)

What Was Built (v0.2 NcProgramManager — in progress)

Phase 06 — Rename Cleanup

  • Namespace: FanucProgramManager.*NcProgramManager.* (all files)
  • Project renamed, test folder renamed, dead FANUCMachine.cs deleted

Phase 07 — License Core

  • IMachineFingerprint / ILicenseValidator interfaces
  • MachineFingerprint — WMI CPU/BIOS fingerprint, SHA256 hash
  • LicenseFile.TryRead — reads .lic file, returns base64 signature
  • LicenseValidator.Validate — RSA-SHA256 verify; PLACEHOLDER public key until Phase 09
  • LicenseValidatorTests — 6 unit tests (testable via internal ctor injection)

Phase 08 — License Integration

  • Program.cscheckLicense deleted; RSA check wired at startup:
    string _licPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "license.lic");
    if (!LicenseFile.TryRead(_licPath, out _licBase64)
        || !new LicenseValidator().Validate(_licFingerprint, _licBase64)) { ... }
    
  • InputArgs.cschiave field removed
  • -chiave= CLI arg removed; license file hardcoded next to EXE as license.lic
  • MostraAiuto updated: instructs user to place license.lic next to executable

CLI Args (current)

  • -manufacturer=fanuc|heidenhain|siemens|mitsubishi (default: fanuc)
  • -azione= — action (Scarica/Invia/etc.)
  • -ip= — CNC IP
  • -porta= — port
  • -username= (Heidenhain/Siemens/Mitsubishi)
  • -password= (Heidenhain/Siemens/Mitsubishi)
  • License: place license.lic next to the EXE (no CLI arg)

Accumulated Context

Decisions

  • .NET 4.7.2 locked — max compatibility
  • RSA asymmetric offline licensing: private key vendor-only, public key embedded in binary
  • license.lic always at AppDomain.CurrentDomain.BaseDirectory — no CLI override
  • RSACryptoServiceProvider + SHA256CryptoServiceProvider (not HashAlgorithmName) — .NET 4.7.2 compat
  • Constructor injection pattern: internal ctor accepts key XML — testable without Windows WMI
  • PublicKeyXml = PLACEHOLDER until Phase 09 generates real key pair
  • Heidenhain: LSV2 port 19000, needs real hardware testing
  • Siemens: FTP /_N_MPF_DIR/, needs Sinumerik FTP option enabled on machine
  • # = Warning in Fanuc/Mitsubishi — macro variable indicator

Deferred Issues

  • Real RSA key pair — Phase 09 output; copy PublicKeyXml into LicenseValidator.cs
  • AesCrypt.cs dead code — remove in future cleanup phase
  • Heidenhain: ReadActiveProgramAsync / SelectMainProgram not implemented
  • Siemens: same as Heidenhain
  • Build + integration not verifiable on Linux (fwlib32 Windows-only)
  • MachineFingerprint WMI — code-review verified, needs real Windows hardware test

Blockers/Concerns

None — Phase 09 can start.

Session Continuity

Last session: 2026-05-17 Stopped at: Phase 08 UNIFY complete Next action: /paul:plan phase 09 license-generator Resume file: .paul/ROADMAP.md


STATE.md — Updated after every significant action