Validate Nest, the posting review and console --post now report a "Part spacing" finding for pairs of parts that do not overlap but sit closer than the plate's part spacing. Before, only Auto Nest's Keep/Discard review checked spacing, so hand-edited layouts could be validated and posted with parts too close together. Candidates are found with Auto Nest's own outline test, moved into Core as SpacingOutline (NestLayoutCheck and NestTolerances now use it; Engine tests unchanged). Because that outline circumscribes arcs by more than the spacing slack, each candidate is confirmed on native contours flattened 20x finer than the slack, so arcs placed exactly at the spacing by interactive fills stay clear. The finding reports the measured gap and marks the middle of the closest approach. Overlapping pairs, cut-offs, zero spacing, the plate edge and clamps are not reported as spacing findings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.9 KiB
OpenNest agent instructions
Shared instructions; keep CLAUDE.md as the thin @AGENTS.md import.
OpenNest is a .NET 8 Windows CNC-nesting application with cross-platform libraries.
Working rules
- Prefer Roslyn Bridge MCP for symbols, references and diagnostics when available; fall back to text search.
- Use
varfor locals and namespaces matching project directories. Follow.editorconfig; format only changed C# files withdotnet format OpenNest.sln --include <paths>, then repeat with--verify-no-changes. On Linux, prefix both commands withEnableWindowsTargeting=true. - Keep instructions concise: commands, boundaries and non-obvious safeguards, not class inventories or session history. Update affected instructions and user-facing docs with behavior/build changes; put detailed contracts in
docs/. - Never commit design specs, implementation plans, progress notes or temporary benchmark reports. Keep working records under local, ignored
.hermes/plans/or.hermes/progress/; retain reusable verification procedures indocs/. - Keep vendor manuals/full-text extracts out of source control unless redistribution is authorized. Write project-specific behavior summaries with citations, separating controller rules, machine macros and unconfirmed behavior.
Build and test
# Full solution: Windows
dotnet build OpenNest.sln
# Cross-platform suites: run independently on Linux/macOS/Windows
# Use Release for routine runs; use Debug explicitly for DEBUG-only work counters.
dotnet test OpenNest.Tests/OpenNest.Tests.csproj -c Release
dotnet test OpenNest.Engine.Tests/OpenNest.Engine.Tests.csproj -c Release
dotnet test OpenNest.IO.Tests/OpenNest.IO.Tests.csproj -c Release
dotnet test OpenNest.Server.Tests/OpenNest.Server.Tests.csproj -c Release
# Windows runtime tests
dotnet test OpenNest.WinForms.Tests/OpenNest.WinForms.Tests.csproj
Keep desktop-dependent tests in OpenNest.WinForms.Tests, never add a WinForms reference to OpenNest.Tests. Optional CHR fixtures use local OpenNest.Tests/test-config.json and skip when absent. On Linux, build Windows projects with -p:EnableWindowsTargeting=true; this is not Windows runtime verification. The headless console builds independently with dotnet build OpenNest.Console/OpenNest.Console.csproj.
Releases: follow the release procedure and scripts/Publish-Windows.ps1; workflow artifacts are candidates, not published releases. GitHub (ajisaacs/OpenNest) is the primary repository; Gitea is a read-only backup mirror.
Project map and boundaries
OpenNest.Core: domain (Nest -> Plate -> Part -> Drawing -> CNC.Program), geometry, cutting strategies and diagnostics. Angles are radians; useTolerance.Epsilonfor geometry comparisons.OpenNest.MathshadowsSystem.Math, so qualify the latter.OpenNest.Engine: whole-job API inJobs/, interactive proposals viaPlateFillService, fill strategies, best-fit pairs, packing, sequencing and rapid planning.INestingEngine.Solve(NestJob)returns stock IDs/poses; boundary adapters map drawings and materialize results.NestJobRunnervalidates its candidates before committing demand/stock accounting. Do not assume arbitrary plug-in output or interactive paths received that validation. Job identity is reference-based, not drawing-name-based.- Built-in whole-job engines live in
OpenNest.Engine/NestingEngines/<Name>/, named for the jobs they suit; see nesting engines. A change must beat that engine's current benchmark result with every layout valid. External plug-ins implementINestingEnginewith a public parameterless constructor and load fromEngines/beside the host; keep their projects out of this solution. OpenNest.IO: ACadSharp import/export and ZIP-based.nestpersistence; depends on Core only (an IO.Tests guard enforces it). Best fits persist only when callers passBestFitCacheStore.SharedasNestReader/NestWriter.BestFitStore. All DXF-to-Drawing conversion goes throughCadImporter:Import+BuildDrawingfor editable/reporting flows,ImportDrawingfor headless callers. Preserve source offsets, entity IDs, suppressed entities and bends. Bend repair is opt-in, requires explicit source units and may not alter cut geometry or unrelated marks.OpenNest: WinForms UI (Forms/,Controls/PlateView,Actions/).OpenNest.Dataholds cross-platform persistence; new-nest defaults live in%APPDATA%\OpenNest\defaults.json. Posts live inPosts/OpenNest.Posts.<Name>/and deploy to the desktop output'sPosts/directory.OpenNest.Console,OpenNest.Mcp,OpenNest.Api: front ends;OpenNest.Benchmark: whole-job engine comparisons;OpenNest.Gpu: GPU evaluators;OpenNest.Training: ML data collection. Benchmark timing comparisons require--parallel 1; validate layouts and fulfillment, not just elapsed time.
Geometry and ownership safeguards
- Marks are not material: use
SpecialLayers.IsMaterialwhen deriving nesting/collision geometry; exclude rapid and scribe moves without removing them from display, cutting time or posts. - Engine/validator collision paths retain the hand-written
Collisionkernel; its GPU port is on hold. Material-overlap diagnostics use Clipper2 per pair for connected shared-material islands and interior markers; see material-overlap diagnostics. Polygon consumers useClipperBridge; directional-distance consumers retain native-arc offsets. Validation usesOffsetForValidationandNestTolerances.SpacingSlack, not conservative display/preparation padding; Auto Nest's layout check and the pre-post part-spacing review share Core'sSpacingOutlinefor candidates; the review then confirms each one on finely flattened native contours, so it never warns where Auto Nest's check would pass. Do not loosen tolerances to hide failures. FillLineargeometry caches are per public call, keyed byProgramreference identity; never share them across calls/threads.PartOverlapCheckeris per check; parts/programs must not mutate during its lifetime.FillScoreranks count, utilization, compactness; exact ties keep the current layout. Custom comparers remain authoritative. Preserve extents' negative/nonfinite-input fallback, pair preparation and adjusted-column overlap checks. Do not remove bounds recomputations without threshold/rounding characterization.ObservableListevents own drawing/plate quantity tracking; avoid double accounting. Cutoff parts are excluded from quantity, utilization and overlap checks.- Cutoffs persist as definitions on
Plate.CutOffs; apply throughRegenerateCutOffs, never preview parts. Preserve sequence positions. Batch planning must finish before mutation and roll back on failure. UsePlateSequencing.Applyfor automatic cutoff dependencies, with nominal spans/reference identity rather than trimmed geometry/names. - Fixed emissions (locked programs, drawing-pinned contours) are accepted as given: their violations warn on an UNVERIFIED proposal and never steer the search, while every planner-chosen motion stays strict. Plates without them must keep the
PlanningCharacterizationTestsdigests. - An empty diagnostic is not a clear result unless
IsComplete. Posting must run checks before writing CNC output; warnings require explicit per-attempt consent, never a persisted bypass. Keep inputs stable through analysis/cancellation. - Preserve symbolic G-code variable definitions/references in file round trips. Keep training bitmaps by default; inference checks predictor availability before scalar-only extraction.
Read the relevant contract before changing its behavior:
- Nest file format
- Directional slides and pair-spacing limits
- Lead-in placement and pierce zones: opt-in
PierceDiameterclearance, the hole pole fallback and the planner's perimeter scrap fallback - Breakoffs: tabbed scrap;
Break-layer open cuts that are cut but are not material - Tabbed cutouts: holes cut in pieces around
Tab-layer spans that are material but never cut; nesting reads material throughNestingMaterial.ForNesting, so nothing nests in them - Material-overlap diagnostics
- Automatic cutoffs and sequencing
- Pre-post verification
- Cut-time estimates: simulator/Calculate Cut Time acceleration planner and placeholder machine limits
- Cincinnati CL and CI Fiber
- Fill verification: opt-in benchmarks, frozen oracles, Debug-only counters and predictor initialization. Zero Release counters do not prove work removal.
- Desktop auto-update: Velopack feed,
UpdateFeedUrlsetting andDeploy-OpenNest.ps1.