canRunA verb that cannot do what it was asked refuses: it resolves with
ok: false and an error, and the model, its history and its ids are as
they were. This page is the contract for those refusals, and for
canRun, which asks a verb whether it would accept its operands before
anything is built.
interface VerbError<C extends string> {
code: C; // a stable tag to branch on
message: string; // a sentence to show the user
violations?: readonly string[]; // postcondition-refused: the validator rules broken
cause?: string; // threw, non-manifold: the kernel's internal tag, for bug reports
}
code is one of the verb's refusal codes. Each verb's signature names
them: merge resolves to VerbResult<MergeTrianglesValue, RefusalCode<'merge'>>,
so a switch on error.code is checked by TypeScript. RefusalCode<V>
is the verb's own codes and the general ones below; refusalCodes(verb)
returns the same list at run time, the verb's own first, for a table of
messages or enablement rules or a test that a host handles each.
A code is never outside its verb's list. A kernel failure the verb does
not name comes back as threw, with the kernel's internal tag in cause
(not part of the contract). A code added to or removed from a verb is a
change to the contract, called out in the release notes.
message is the sentence the user should read, written by the
kernel: show it as it stands. It can name an id or a distance (written
with the host's formatDistance, when the context has one). A host that
wants its own wording branches on code and writes its own; the
kernel's sentence then stays a good fallback for a code the host does
not know.
Every verb may return these:
| Code | Meaning |
|---|---|
invalid-operands |
The operands do not parse: a missing or extra field, a number that is not finite, an amount the verb needs and was not given. |
postcondition-refused |
The step would leave the model invalid (the postcondition gate); violations names the rules. |
read-only-context |
The host keeps the mesh this context edits read-only. |
not-committed |
The history did not keep the step and gave no reason. |
load-failed |
A part of the kernel the verb needs did not load. |
unsupported-geometry |
The context has no mesh to edit. |
threw |
The kernel failed in a way no rule of the verb names; cause carries its tag. |
A draw verb that makes edges also returns non-manifold: the edge it
would draw breaks the non-manifold policy (ADR-034), for example a line
run off the face it starts in along a line already drawn into it. Its
cause is the policy's own tag (unspecified-non-manifold,
manifold-edge, …), for bug reports like threw's.
Each verb adds its own, from its operand rules (unknown-face,
not-a-frame, axis-pierces-face, offset.curved-push-unsupported, …)
and from what building it finds (offset.face-too-far, locked,
seam-gap, …). Each verb's own codes below
lists them, and refusalCodes(verb) returns them at run time.
canRunconst asked = await canRun(ctx, 'revolve', {
profile: { kind: 'face', faceId },
axis: { from: [0, 0, 0], to: [0, 0, 1] },
// no `degrees` yet: the user has not typed an angle
});
if (!asked.ok) greyOut('Revolve', asked.message); // asked.code: RefusalCode<'revolve'>
canRun(ctx, verb, operands) runs the checks the verb's commit runs
before it builds anything, on the same code, and answers { ok: true }
or the code and message the commit would refuse with. Its chunks
load (the first call, as the first commit would), the ids resolve, and
the verb's operand rules apply: Revolve's profile and axis, Offset's
curved-push, slant and frame-inset rules, Loft's profiles and rails,
Fold's sheet, Merge's triangle pairs, Flip Grain's ruled quads. Nothing
is built: the model, the history and the entity ids are untouched.
The verb names are the API's: the bare verbs ('offset', 'revolve',
'merge', …) and the shapes as 'draw.line', 'draw.cuboid', ….
The amount a host asks before the user has chosen it may be left out:
Offset's distance and vector, Revolve's degrees, Fillet's radius
(CanRunOperands<V>). A draw verb is checked with all its operands.
ok says the operands pass. The commit can still refuse for what only
building it finds: an amount too large (offset.face-too-far), a fold
that locks, a result the postcondition gate refuses. To know the result
of a particular amount, run the verb.
canRun |
the verb | |
|---|---|---|
| Changes the model | never | when ok |
| Needs the amount | no | yes |
| Cost | the operand checks (no build) | the whole solve |
| Codes | the operand rules' | all of the verb's |
The codes each verb adds to the general ones, in the order
refusalCodes(verb) returns them. src/core/kernelRefusalsDoc.test.ts
holds this table to the code, so it is the list the kernel returns.
transformEntities's are also exported as TRANSFORM_REFUSAL_CODES
(Move, rotate and scale).
| Verb | Its own codes |
|---|---|
draw.line |
zero-length-segment, unknown-face, not-a-ruled-host, non-manifold |
draw.rectangle |
degenerate-rectangle, not-a-rectangle, non-manifold |
draw.points |
(the general codes only) |
draw.circle |
radius-too-small, zero-normal, unknown-face, degenerate-face, normal-off-host, center-off-host, unsupported-host, host-kind-unsupported, non-developable-host, development-deferred, promote-region-unsupported, face-not-in-mesh, degenerate-host, invalid-radius, exits-host-face, wraps-band, crosses-edge, offset-past-focal, bump-unsupported, decal-too-wide-for-straight-cut, through-cut-unsupported, past-cut-locus, geodesic-unconverged, stretch-unsupported, non-manifold |
draw.ellipse |
radius-too-small, ellipse-on-curved-wall, zero-normal, unknown-face, degenerate-face, normal-off-host, center-off-host, non-manifold |
draw.arc |
zero-chord, collinear-points, zero-normal, zero-radius, start-off-plane, zero-sweep, full-turn, host-kind-unsupported, non-developable-host, development-deferred, promote-region-unsupported, face-not-in-mesh, degenerate-host, invalid-radius, exits-host-face, wraps-band, crosses-edge, offset-past-focal, bump-unsupported, decal-too-wide-for-straight-cut, through-cut-unsupported, past-cut-locus, geodesic-unconverged, stretch-unsupported, non-manifold |
draw.arcTwoPoint |
zero-chord, collinear-points, zero-normal, zero-radius, start-off-plane, zero-sweep, full-turn, host-kind-unsupported, non-developable-host, development-deferred, promote-region-unsupported, face-not-in-mesh, degenerate-host, invalid-radius, exits-host-face, wraps-band, crosses-edge, offset-past-focal, bump-unsupported, decal-too-wide-for-straight-cut, through-cut-unsupported, past-cut-locus, geodesic-unconverged, stretch-unsupported, non-manifold |
draw.arcCenterRadius |
zero-chord, collinear-points, zero-normal, zero-radius, start-off-plane, zero-sweep, full-turn, host-kind-unsupported, non-developable-host, development-deferred, promote-region-unsupported, face-not-in-mesh, degenerate-host, invalid-radius, exits-host-face, wraps-band, crosses-edge, offset-past-focal, bump-unsupported, decal-too-wide-for-straight-cut, through-cut-unsupported, past-cut-locus, geodesic-unconverged, stretch-unsupported, non-manifold |
draw.curve |
zero-chord, non-manifold |
draw.cuboid |
degenerate-base, degenerate-height, invalid-sweep, non-planar-base, rim-off-plane, non-manifold |
loft |
unknown-face, unknown-edge, unknown-corner, same-face, empty, inner-loops, non-line-edge, too-few-corners, chain-unequal-counts, chain-curved, rail-not-a-wire, rail-misses-profile, rail-curve-kind, rails-share-corner, curved-unpaired, degenerate-profile, uncorrespondable-profiles, kernel-rejected |
revolve |
unknown-face, unknown-edge, profile-not-a-wire, profile-not-open-chain, face-has-holes, face-too-few-corners, face-curved-edges, degenerate-axis, axis-pierces-face, axis-crosses-outline-often, profile-shares-edges, curve-not-revolvable, curve-meets-axis, corner-touches-axis, curve-evaluator-loading |
skin |
unknown-edge, same-edge, skin-rejected |
sweep |
unknown-face, unknown-edge, path-not-a-wire, path-not-open-chain, sweep.path-folds-back, sweep.curved-profile-path, sweep.translation-path |
imprint |
unknown-face, same-face, kernel-rejected, not-loaded, face-not-in-mesh, surface-unresolved, no-intersection, faces-overlap, surface-kind-unsupported, face-kind-unsupported, rails-not-carried, off-face, outside-face, wraps-band, band-hosts-features, edge-unreadable, runs-beside-edge, curve-unsplittable, on-boundary |
merge |
nothing-to-merge |
erase |
unknown-entity |
unite |
same-operand, empty-result, disjoint, numerical-failure, unsupported-input, non-manifold-result, tolerance-over-cap, invalid-operand, inverted-operand |
subtract |
same-operand, empty-result, disjoint, numerical-failure, unsupported-input, non-manifold-result, tolerance-over-cap, invalid-operand, inverted-operand |
intersect |
same-operand, empty-result, disjoint, numerical-failure, unsupported-input, non-manifold-result, tolerance-over-cap, invalid-operand, inverted-operand |
move |
not-rigid |
transformEntities |
nothing-to-transform, unknown-entity, not-affine, reflects, degenerate-matrix, too-far, no-change, would-stretch, face-inverts, edge-collapses, needs-new-edge, ill-conditioned, over-constrained, curved-neighbor, holed-face, cannot-fold, face-kind-invariant |
offset |
unknown-face, unknown-edge, unknown-vertex, nothing-to-offset, offset.curved-push-unsupported, offset.cannot-slant, offset.frame-inset-curved, offset.frame-inset-not-flat, offset.not-a-chain, offset.mixed-selection, offset-ladder-intersection-edge, offset-ladder-curve-kind, offset-ladder-zero, offset-ladder-refused, offset-ladder-loading, offset-wall-refused, offset-chain-refused, offset-group-zero, offset-group-refused, offset.rejected, offset.void-through-wall, offset.face-too-far, offset.invalid-result, offset.fuse-not-exact, offset.self-crossing-solid, offset.sheet-wall-overlap, offset.degenerate-face, offset.island-undercut, offset.frame-inset-zero, offset.frame-inset-too-far, offset.frame-inset-failed, offset.frame-outset-off-face, offset.carve-not-exact, offset.composer-failed, offset.composer-loading, offset.join-loading, offset.patch-push-refused, offset.strip-through-unsupported, offset.sub-region-failed, offset.sweep-failed, offset.through-cut-failed, offset.rail-drill-unavailable, offset.rail-offset-failed, offset.rail-sweep-failed, offset.rail-sweep-loading, offset.rail-sweep-unavailable, offset-surface-not-a-rail-pair, offset-past-focal, reaches-far-wall, boundary-would-change, boundary-unsupported |
develop |
degenerate-rail, degenerate-ruling, degenerate-directrix |
regrain |
nothing-to-flip, unknown-face, no-ruled-quads |
markCrease |
not-a-crease, nothing-to-mark |
fold |
empty, unknown-face, not-flat, not-connected, not-a-disk, branching-edge, curved-edge, corrupt-ring, unknown-crease, nothing-to-fold, locked, contact, steps-lost, no-such-step, plate, has-holes, curved-sides, fixed-vertex, odd-vertex, not-closed |
foldCurvedCrease |
unknown-crease, crease-not-curved, not-two-panels, not-flat, panel-shape, sheet-edited, fold-out-of-range, degenerate, crease-not-graph, crease-corner, too-steep, arc-wraps, no-fit |
layOutNet |
not-one-net, not-flat, has-hole, curved-edge, refused-face, hem-mold-line, curved-fold, corner-relief, failed |
foldUpNet |
empty, unknown-face, not-flat, not-connected, not-a-disk, branching-edge, curved-edge, corrupt-ring, unknown-crease, nothing-to-fold, locked, contact, steps-lost, no-such-step, plate, seam-gap, not-closed |
fillet |
unknown-edge, not-a-line, same-edge, invalid-geometry, manifold-edge, not-a-solid-edge, curved-face, flat-edge, vertex-blend, end-face-not-square, radius-too-large, invalid-radius, shared-edge |
patch |
unknown-edge, not-a-frame, unsupported-side, arc-too-wide, corners-do-not-meet, weight-not-positive, not-divisible, no-nudge, degenerate-patch, patch-rejected |