fix(engine): enforce whole-job safety invariants
Task 5 of the whole-job engine API: add a geometry safety gate that validates every candidate trial before the runner commits accounting. - NestJobPlacementValidator: closed-contour validity, rotation-policy compliance, work-area containment per quadrant, hole-aware material overlap, and required part spacing. Overlap is interior-only, so zero-clearance edge/corner contact remains a valid placement. - NestJobValidator: route candidate validation through the geometry gate; reject unusable/unclosed/degenerate contours up front. - NestJobRunner: wrap candidate evaluation in a progress bridge that tags legacy engine detail with the current candidate context. - LegacyPlateNesterAdapter: forward IProgress to the legacy engine so its progress surfaces under the active candidate. - Tests: geometry (quadrants, rotations, touching, containment, holes, empty stock, real Default/Strip smoke), validation, and cancellation suites; repaired test fakes that emitted out-of-bounds or overlapping placements the gate now correctly rejects. Engine.Tests: 70 passed, 0 failed, 0 skipped in Debug and Release. Windows-only OpenNest.Tests not run on Linux.
This commit is contained in:
@@ -16,7 +16,7 @@ public class FiniteStockJobTests
|
||||
}
|
||||
|
||||
internal static PlateCandidate One(PlatePlacementRequest request) => new(new[]
|
||||
{ new NestJobPlacement(request.Parts[0].Id, 99, 1, 2, 0) });
|
||||
{ new NestJobPlacement(request.Parts[0].Id, 99, 0, 0, 0) });
|
||||
|
||||
[Theory]
|
||||
[InlineData(3, 3, 0, NestJobStatus.Complete, NestJobStopReason.Completed)]
|
||||
@@ -108,7 +108,7 @@ public class FiniteStockJobTests
|
||||
public void MixedStockCanBeEvaluated()
|
||||
{
|
||||
var job = Job();
|
||||
var mixed = new NestJob(job.Parts, job.Plates.Concat(new[] { new NestPlateStock("other", new Size(10, 20), 2) }));
|
||||
var mixed = new NestJob(job.Parts, job.Plates.Concat(new[] { new NestPlateStock("other", new Size(20, 10), 2) }));
|
||||
var result = new NestJobRunner(_ => new Nester(One)).Solve(mixed);
|
||||
Assert.Equal(NestJobStatus.Complete, result.Status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user