Skip to content

Epic: close the drawing-to-candidate loop for generation fidelity #446

Description

@pzfreo

Objective

Close the remaining generation-fidelity gap by giving CAD agents compact, calibrated drawing-to-candidate evidence and a bounded correction path, without weakening build123d-mcp's verified advantages in editing, validity, token cost, and runtime.

This epic is deliberately phased. Each phase must produce measured evidence and may be adopted, revised, or rejected independently. Do not proceed to a full benchmark sweep merely because an API or prompt is technically complete.

Why this is the next hypothesis

A controlled Opus 5 xhigh comparison found:

Metric Official baseline / no MCP build123d-mcp 0.3.81
Overall 0.627 0.639
Generation 0.631 0.596
Editing 0.621 0.706
Valid outputs 75/81 80/81

The generation deficit is concentrated. Six fixtures (102, 106, 116, 126, 145, 150) contribute +2.132 points to no-MCP while the net 49-fixture generation advantage is only +1.730; excluding those six, MCP is slightly ahead.

Trace review shows that the strongest no-MCP generations repeatedly:

  • calibrated drawing pixels from printed dimensions;
  • sampled complex silhouettes and undimensioned curves;
  • rendered matching orthographic projections;
  • overlaid candidate and reference views;
  • made global source rewrites when the representation was wrong.

Current MCP tools inspect the candidate itself. They do not provide a machine-readable, registered comparison between that candidate and the input drawing.

Prior work and lessons

This epic builds on, but must not repeat uncritically:

Design principles

  1. Evidence, not verdicts. Do not return PASS, conforms, or an authoritative completion signal for drawing fidelity.
  2. Drawing-derived and candidate-derived facts stay distinct. Never present model-inferred expectations as observations from the image.
  3. Printed dimensions remain authoritative. Pixel calibration may estimate undimensioned geometry but must not override explicit callouts.
  4. Compact output. Return the few largest actionable discrepancies, not raw CV dumps or unbounded contours.
  5. Preserve model agency. MCP supplies measurements and controlled execution; the agent owns the design hypothesis.
  6. Selective escalation. Normal generation remains lightweight. Global source rewrite or a second candidate is reserved for measured structural mismatch.
  7. No benchmark-specific geometry. Fixture IDs belong only in evaluation plans, never runtime rules, skills, examples, or detector code.
  8. No full sweep without a passed gate. Small paired tests precede broader validation.

Reference evaluation set

Use the existing frozen Opus 5 runs as historical baselines.

MCP-loss cases:

  • 102, 106, 116, 126, 145, 150

MCP-winning controls:

  • 113, 119, 133, 138, 139

The controls are mandatory: an intervention that improves complex contours by distracting the model on ordinary generation is not a success.

Phase 0 — Freeze evidence and contracts

  • Record exact baseline submissions, MCP version, model, effort, prompts, scores, validity, runtime, token usage, and per-fixture results.
  • Classify the 11 fixtures by dominant geometry, view arrangement, explicit dimensions, undimensioned contours, and observed failure mechanism.
  • Define separate schemas for drawing observations, candidate observations, registration, and discrepancies.
  • Define confidence/ambiguity semantics and failure behaviour.
  • Define an output token/size ceiling.
  • Pre-register the phase-1 test and decision rule before scoring treatments.

Exit gate:

  • Frozen comparison table and machine-readable provenance.
  • No schema field implies ground truth or certification.
  • Review demonstrates that printed dimensions cannot be silently overridden.

Phase 1 — Projection registration feasibility, offline first

Prototype and validate registration outside the public MCP surface:

  • Locate the relevant orthographic drawing regions without using fixture-specific coordinates.
  • Render the candidate in matching orthographic orientations.
  • Calibrate image scale using explicit printed dimensions where available.
  • Align candidate projections without normalizing away real scale or orientation errors.
  • Produce silhouette overlap, contour-distance summaries, and a bounded overlay artifact.
  • Surface ambiguity when view association or scale is not reliable.
  • Test annotation, hatch, centreline, and dimension-line rejection.

Measure:

  • Registration success/failure rate.
  • False alignment rate.
  • Sensitivity to deliberate scale, translation, rotation, missing-hole, filled-void, and contour perturbations.
  • Runtime and memory.
  • Stability across repeated renders.
  • Whether discrepancy direction is correct, not merely whether a scalar changes.

Exit gate:

  • Reliable registration on the development/selfbench set and the 11 frozen inputs.
  • Synthetic perturbations are ranked in the correct direction.
  • Uncertain cases fail explicitly rather than returning a confident misleading comparison.

If this gate fails, stop. Do not expose an MCP tool.

Phase 2 — Compact drawing-comparison API

Expose one experimental workflow-level entry point, not a cluster of low-level CV tools.

Candidate contract:

  • drawing/view identity and registration confidence;

  • scale/orientation evidence;

  • a small number of ranked silhouette or interface discrepancies;

  • optional bounded overlay paths;

  • no completion verdict;

  • no hidden automatic correction.

  • Keep it experimental/off by default.

  • Bound image sizes, contour counts, output size, and runtime.

  • Isolate image processing so failure cannot destroy the CAD session.

  • Add adversarial tests for annotation ink, section hatching, partial views, multiple components, symmetry, and similar nearby contours.

  • Ensure tool descriptions distinguish evidence from instruction.

Exit gate:

  • Detector and API tests pass.
  • Output remains compact enough for an agent correction loop.
  • Independent review finds no route by which a low-confidence alignment masquerades as a high-confidence discrepancy.

Phase 3 — Bounded Opus 5 comparison-only A/B

Intervention:

  1. Build the first valid coarse candidate using the normal MCP workflow.
  2. Run one drawing-aligned comparison.
  3. Correct the single largest confirmed mismatch.
  4. Permit one final comparison only after material geometry change.
  5. Validate and export normally.

Do not add source injection, multiple candidates, semantic constructors, or inspect_part prompt changes in this phase.

  • Control: frozen current MCP prompt/tool surface.
  • Treatment: comparison-only addition.
  • Same Opus 5 model, xhigh effort, MCP version, fixture set, timeout, and concurrency.
  • Preserve logs, tool output, token usage, runtime, validity, and correction classification.
  • Score through the authoritative CADGenBench service.

Primary measures:

  • Paired CAD score delta.
  • Median paired delta.
  • Improved/tied/regressed counts.
  • Recovery on the six loss cases.
  • Regression on the five controls.

Secondary measures:

  • Validity.
  • Token/API-equivalent cost.
  • Runtime.
  • Comparison call success.
  • Fraction of discrepancies causing material geometry changes.
  • Fraction of those changes improving official score.

Phase-3 success gate:

  • Recover at least half of the six-fixture 2.132-point deficit, or demonstrate a comparably convincing paired effect after accounting for scorer noise.
  • Positive paired median.
  • Gains are not explained by one fixture.
  • No material validity regression.
  • No meaningful aggregate regression on controls.
  • Cost/runtime remain materially below no MCP.
  • Log review confirms the tool caused correct geometric corrections rather than redundant narration.

Phase 4 — Comparison-informed global reconstruction

Only if phase 3 passes.

Test canonical source as an actuator after a measured structural mismatch:

  • Define a narrow escalation condition: large registered contour mismatch, cross-view inconsistency, or confirmed wrong body family.
  • Use atomic execute_file() for a complete candidate rewrite.
  • Preserve the last valid model if rebuilding fails.
  • Recompare after the rewrite.
  • Do not inject build123d implementation source unless answering a focused API question.

A/B:

  • Phase-3 comparison-only treatment versus comparison plus canonical reconstruction.
  • Same 11-fixture set and measurement contract.

Exit gate:

  • Additional paired improvement beyond phase 3.
  • Global rewrites correlate with measured structural mismatches.
  • No recurrence of the conditional-source regression pattern.
  • Failure recovery preserves validity and prior state.

Phase 5 — Candidate-side semantic feedback

Only after drawing comparison is useful.

Factor inspect_part separately:

  • Drawing comparison only.
  • Drawing comparison plus one bounded inspect_part checkpoint.

Purpose:

  • Test whether candidate feature inventory adds value after the image-derived plan is grounded.
  • Determine whether model-authored expectations introduce errors or premature stopping.
  • Keep inspect_part evidence separate from drawing observations.

Exit gate:

  • Incremental paired improvement or a clear reduction in interface errors.
  • Expectation construction is usually correct.
  • No conformance-style stop-signal regression.

Phase 6 — Optional candidate branching

Only if comparison is a trustworthy selector and residual failures are early-hypothesis errors.

  • Generate at most two coarse candidates.
  • Compare both using the same registered drawing evidence.
  • Record selection rationale and both artifacts.
  • Elaborate only the selected candidate.
  • Compare score gain against added cost and runtime.

Exit gate:

  • Selection predicts the better official result often enough to justify cost.
  • Gain is not obtainable more cheaply through one reconstruction pass.

Phase 7 — Tool-surface and prompt integration

After functionality is proven:

  • Coordinate with Consolidate the default MCP tool surface (decoupled from #417/#420) #421 so comparison does not simply add more permanent schema burden.
  • Decide whether generation receives a narrower surface than editing while preserving one supportable configuration.
  • Keep orchestration in the harness and reusable CAD reasoning in the MCP skill.
  • Remove or demote redundant guidance.
  • Verify that source, skill, prompt, resource, and tool descriptions do not conflict.
  • Run a final paired sample before considering a full sweep.

Phase 8 — Full validation

Only after all preceding adopted phases pass their gates:

  • Freeze commits, dependencies, prompt, model, effort, and run metadata.
  • Run the full benchmark.
  • Package all fixtures correctly, including required empty directories.
  • Publish filtered accreditation logs and safe cost/time aggregates.
  • Compare overall, generation, editing, validity, tokens, cost, and runtime with both verified MCP 0.3.81 and official-baseline/no-MCP Opus 5.
  • Record negative as well as positive results in this epic.

Programme-level success criteria

Adopt the complete workflow only if it:

  • raises verified overall score beyond 0.639 by more than expected noise;
  • raises generation beyond the current MCP 0.596, with a target of exceeding no-MCP 0.631;
  • preserves the editing advantage near 0.706;
  • preserves approximately 80/81 validity or improves it;
  • retains a meaningful token/runtime advantage over no MCP;
  • generalizes beyond the six diagnostic fixtures.

Non-goals

  • Encoding benchmark fixture answers.
  • Replacing Opus's spatial reasoning with a deterministic image-to-CAD solver.
  • Returning a misleading fidelity certification.
  • Adding a large public computer-vision tool family.
  • Running all 81 fixtures before the sample gates pass.
  • Treating source access as geometric evidence.
  • Combining all interventions into one uninterpretable test.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions