The Views
CnD exposes four views over an instance, selected from the buttons in the top nav: Graph, Table, Script, and Edit. Only Graph and Edit are driven by the CnD spec; Table and Script are independent surfaces.
Graph view
The default view, and the one you'll spend most of your time in. It renders the current Alloy/Forge instance as a constraint-solved diagram, using the active CnD spec to decide layout and styling.
The Layout drawer (right-hand side) holds the CnD editor. Projections and temporal-trace navigation also surface here — see Projections and Temporal Mode.
Code View vs Structured Builder
Inside the Layout drawer, the CnD editor has two modes, toggled at the top of the drawer:
- Code View — a raw YAML editor over
constraints:anddirectives:blocks. This is the canonical surface, and the recommended one for anyone (human or agent) already familiar with the CnD language. The full grammar is in the YAML Specification. - Structured Builder — a form-based editor where constraints and directives are added, removed, and reordered through UI controls instead of typed YAML. Useful for learning the vocabulary by exploration, and for readers who aren't comfortable editing YAML directly.
The two views share a single underlying spec: switching modes regenerates the other representation from the current one, and undo/redo works across the toggle. The Structured Builder covers constraints and directives; projections: and temporal: blocks are not yet surfaced in the form UI, but are preserved through round-trips so they won't be lost by switching.
Three actions sit above the editor:
- Apply Layout — commits the current spec and re-renders the diagram.
- Describe layout… — drafts a spec from a plain-language description.
- Upload
.cnd— loads a spec from a local file.
Suggest sits in the editor's own toolbar, beside the Builder/Code toggle. It uses Cope and Drag's Magic Alloy-inspired heuristics to analyze the raw Alloy/Forge schema and representative states, validates the generated CnD constraints through the real layout pipeline for every state, weakens or omits candidates that fail, and loads the strongest valid spec into the editor. Like any hand edit, the suggestion is a single undo step and does not touch the diagram until you press Apply Layout — so a suggestion can be read, adjusted, or undone before it changes anything. Each candidate the resolver tried is listed underneath with its rationale, confidence, and whether it was applied, weakened, or omitted.
Suggestion policy deliberately lives in Cope and Drag rather than wrapping spytial-core.suggestLayout: Cope owns its Alloy metadata adapter, CnD-specific candidate families, confidence ordering, fallbacks, and dependencies, while spytial-core owns the affordance itself (through its domain-agnostic LayoutAssistant hook) and remains the parser/evaluator/layout execution boundary.
Suggestions adapt Alloy's Magic Layout heuristics—enumerations, projections, structural relations, attributes, and presentation—and add topology checks for chains, rings, trees, back-links, and temporal stability. Candidate dependencies prevent destructive combinations, such as hiding an enum whose attribute conversion failed. If the validation pipeline itself is unavailable, the editor keeps its current spec and shows why.
When the installed spytial-core exposes selector synthesis, structural suggestions can also target edge sets that no single declared field denotes. The division of labor is strict: the heuristic infers the visual intent (this is a tree; children go below) and collects the intended atoms or directed pairs, while synthesis only discovers a selector expression naming that extension—for example lc + rc for a tree split across two fields, or ~boss when the declared field points from child to parent. This also covers derived and restricted relations: a field name declared on several sigs is restricted to one declaration with a type intersection such as f & (A -> A) (the bare name would denote the union of all declarations), a field declared on a supertype can be narrowed to the subtype family where its topology is clean, and a hierarchy reached through an indirection type is composed into a single spine such as contents.object. Candidate expressions constructed directly from the declared relations are verified first and preferred; the bounded relational search runs only as a fallback, and when several expressions denote the same extension the simplest one wins, with a bare declared name always beating an equivalent derived expression. Every accepted selector—guided or searched—is independently re-evaluated against each available state and accepted only on an exact ordered match; expressions that mention concrete atom names are rejected, and each suggestion's evidence records how its selector was obtained. If synthesis is unavailable or fails, the ordinary direct-selector candidates and fallbacks apply unchanged.
For agents writing
.cndspecs: prefer Code View and write against the grammar in YAML Specification. The Structured Builder is a pedagogical surface, not a canonical one.
Table view
A tabular browse of the instance: sigs and their fields rendered as HTML tables. The Table view does not consult the CnD spec — it's a plain data browser for the raw solver output, useful for cross-referencing what the diagram shows against what the instance actually contains.
Script view
A split pane: a Monaco JavaScript editor on one side, a live rendering stage on the other. You write imperative visualization code against the raw instance, with D3 and the SpyTial visualization APIs available. Run with Ctrl+Enter.
The Script view is independent of the CnD spec. Reach for it when CnD's declarative vocabulary isn't enough and you need imperative, bespoke control over the rendering — custom charts, non-graph layouts, algorithmic visualizations. For standard relational-diagram work, Graph view is the right tool.
Edit view
Experimental. An interactive editor for building or modifying instances by hand — add atoms, connect fields, modify relations — and then exporting the result as a Forge/Alloy inst block you can paste back into a model file. The Edit view respects the active CnD spec while you edit, so constraints and directives apply during construction.
→ See Edit Mode (experimental) for the full walkthrough.