- skills/archify: vendored tt-a1i/archify 2.14.0 (MIT), pure Node 18+, zero deps - extensions/pi-mermaid: renders mermaid blocks as ASCII in TUI; deps beautiful-mermaid + mermaid - skills/project-diagramming-*: orchestration skills, per-project docs/ convention
147 lines
8.7 KiB
Markdown
147 lines
8.7 KiB
Markdown
# Authoring contract
|
||
|
||
Read this reference only after the Fast authoring path calls for more detail. The schemas and examples remain authoritative.
|
||
|
||
## Schema lookup
|
||
|
||
Read both the mode schema and `schemas/common.schema.json`. The mode schemas use `$ref`, so the common file is where shared enums live.
|
||
|
||
- `componentType`: `frontend`, `backend`, `database`, `cloud`, `security`, `messagebus`, `external`
|
||
- `variant`: `default`, `emphasis`, `security`, `dashed`
|
||
- Relationship IDs use the shared identifier pattern and must be unique in their collection.
|
||
|
||
Do not invent fields. Use the nearest matching example for structure, then author fresh IDs, wording, facts, and layout.
|
||
|
||
## Legend contract
|
||
|
||
Omit `meta.legend` for the truthful default: `auto` lists only semantic kinds
|
||
present in typed IR. Use `mode: "all"` for a renderer reference or
|
||
`mode: "hidden"` to remove the full legend. Under `entries`, only keys listed
|
||
by the selected mode schema are valid; each key accepts `label`, `visible`, or
|
||
both. `visible: true` may show an unused supported convention, while
|
||
`visible: false` hides it. `hidden` cannot be overridden.
|
||
|
||
A label override changes reader wording only. Never infer a kind from prose or
|
||
use the legend to compensate for missing nodes, states, messages, or flows.
|
||
Long labels are measured and wrap into deterministic rows. Architecture's
|
||
implicit automatic viewBox grows from that same measured footprint. For
|
||
backwards compatibility, a legacy document with no `meta.legend` may omit an
|
||
implicit auto legend that cannot fit its explicit viewBox; this never changes
|
||
its typed topology. Adding `meta.legend` makes the presentation intentional and
|
||
strict: if its resolved labels cannot fit the authored viewBox, shorten or hide
|
||
them, or widen the viewBox using the emitted diagnostic.
|
||
|
||
## Language consistency
|
||
|
||
Default all reader-facing authored copy to the language of the user's request,
|
||
or to the conversation's dominant language when the request itself is
|
||
language-neutral. Apply that choice to titles, subtitles, node and relationship
|
||
copy, boundaries, lanes, groups, guided views, legend labels, and cards. Use
|
||
another language or bilingual copy only when the user asks for it.
|
||
|
||
Keep exact product names, code identifiers, commands, protocols, API paths, and
|
||
environment names intact. Those terms may remain English inside localized copy,
|
||
but surrounding explanatory prose must still use the selected language. For a
|
||
non-English diagram, localize visible semantic legend labels through
|
||
`meta.legend.entries`; renderer-owned viewer controls remain separate from
|
||
authored copy and are not a reason to mix languages in the specification.
|
||
|
||
## Visual preset default
|
||
|
||
Omit `meta.visual_preset` by default. The renderer then opens the diagram in
|
||
`classic` for both light and dark color modes. Color mode and visual preset are
|
||
independent viewer state: switching Light / Dark must preserve the current
|
||
preset. Author `signal-flow`, `blueprint`, or `editorial` only when the user
|
||
explicitly requests that visual style.
|
||
|
||
## Engineering profile default
|
||
|
||
Omit `meta.engineering_profile` for an ordinary system architecture. Region,
|
||
cluster, and security boundary wording do not by themselves enable an
|
||
engineering profile. Enable `deployment-ownership` only when the user
|
||
explicitly asks for a production deployment topology, ownership handoff, or
|
||
fail-closed deployment review and the source facts are known. Once enabled,
|
||
do not remove the engineering profile merely to pass validation; repair the
|
||
authored facts or report the diagnostics truthfully.
|
||
|
||
## Title hierarchy
|
||
|
||
Use one concise title and let the diagram carry the explanation. Omit
|
||
`meta.subtitle` by default, and never use it to restate the title, nodes, edges,
|
||
or cards. Include one short supporting line only when the user explicitly asks
|
||
for a subtitle; an omitted or blank subtitle must not leave an empty visual row
|
||
in the generated viewer.
|
||
|
||
## Executable geometry rules
|
||
|
||
- Node anchors start at side midpoints. `left`/`right` change the horizontal endpoint; `top`/`bottom` change the vertical endpoint. For an automatic Architecture relationship, unobstructed facing ports whose axis offset is under 16px may share one horizontal or vertical axis when both endpoints retain the 16px corner gutter. If exactly one endpoint belongs to a spread group, only its unshared counterpart moves; relationships spread at both endpoints keep their distinct ports and outside bridge.
|
||
- A side is a direction contract. The first and final route segment must be perpendicular and outward/inward in the named direction.
|
||
- Automatic Port Spread is a default renderer behavior for architecture, workflow, data-flow, and lifecycle diagrams. Shared automatic endpoints spread deterministically and symmetrically with a 16px corner gutter. It does not apply to sequence messages, single relationships, or explicit `via`, `channelX`, `channelY`, `labelAt`, or non-`auto` routes.
|
||
- Showcase route rhythm: every nonzero segment must be at least 8px; every interior segment must be at least 16px. When spread ports are nearly parallel, the router uses a 24px endpoint stub and a 16px outside bridge instead of manufacturing a tiny dogleg.
|
||
- Shared endpoint corridors are allowed only when they remain semantically unambiguous. Unrelated collinear overlap of 8px or more fails showcase.
|
||
- Container borders are intentional pass-through geometry, but a long edge running along a structural border is not.
|
||
- An edge crossing an unrelated opaque node is always a hard failure, independent of quality profile.
|
||
|
||
### Spacing and labels
|
||
|
||
Spacing recommendations mean clear gap between boxes, not center distance. A 200px center distance between 165px-wide nodes leaves only 35px of clear gap.
|
||
|
||
For a relationship label, require:
|
||
|
||
```text
|
||
clear gap > label mask width + 8px breathing room
|
||
label mask width ≈ 6.5px × ASCII units + 13px
|
||
CJK characters count as two units
|
||
```
|
||
|
||
Relationship labels are semantic data. If the gap is too small, move the label,
|
||
adjust the route or spacing, then shorten the wording while preserving meaning.
|
||
Only delete a label when both endpoints fully imply the relationship and it
|
||
contains no protocol, action, direction, synchronous/asynchronous behavior, or
|
||
cross-boundary mechanism. Explain why a deleted label is redundant. Never
|
||
delete a meaningful label merely to pass `showcase`. Apply a diagnosed
|
||
`labelAt`, `labelDx`/`labelDy`, or `labelSegment` before guessing several
|
||
geometry controls at once.
|
||
|
||
### Repair order
|
||
|
||
1. Fix missing/invalid `meta.quality_profile` and schema errors.
|
||
2. Fix node overlap or out-of-range placement.
|
||
3. Fix edge-through-node and endpoint-direction errors.
|
||
4. Fix crossings, ambiguous corridors, border runs, and route rhythm.
|
||
5. Fix label-to-node, label-to-label, then label-to-route clearance.
|
||
|
||
Run `validate` after every edit. Consume `diagnostics[]` by stable `code`, exact `subject`, measured `evidence`, and `supportedFixes`. If the diagnostic gives `labelAt`, use that point instead of estimating another offset.
|
||
|
||
## Mode placement
|
||
|
||
### Architecture
|
||
|
||
Use one left-to-right spine with short vertical branches. Prefer 6–12 primary components and group only real ownership, trust, process, or deployment boundaries. Boundaries do not replace relationships.
|
||
|
||
Grid placement is preferred when the schema supports it. Free positions are appropriate for a bounded exception, not for prose-level coordinate planning. Keep external actors outside the system boundary when that is factually true.
|
||
|
||
### Workflow
|
||
|
||
Lanes express responsibility or phase. Columns express progression. Keep the happy path monotonic; route retries and exception returns outside the main lane corridor.
|
||
|
||
### Sequence
|
||
|
||
Participants are ordered by conversation role. Messages own their vertical order. Use return/async/security variants for meaning, not decoration; sequence does not use Automatic Port Spread.
|
||
|
||
### Dataflow
|
||
|
||
Stages express transformation or custody. Rows separate parallel streams. Label only data contracts, classifications, or cross-boundary movement that is not obvious.
|
||
|
||
### Lifecycle
|
||
|
||
Main phases use columns `0..4`; event and terminal bands use columns `0..2`. A recoverable failure needs a real transition back to an active state. A card or guided view saying “retry” is not topology.
|
||
|
||
## Repository evidence
|
||
|
||
When the diagram must reflect real code, inspect repository entrypoints, runtime boundaries, storage, transports, and deployment configuration before authoring. Record only evidence you actually verified. Use `--repo-root <path>` when the chosen renderer supports evidence receipts. Never infer runtime causality from file proximity or naming alone.
|
||
|
||
## Hand-placed fallback
|
||
|
||
Use only when no renderer can run. Start from `assets/template.html`, keep semantic CSS classes, preserve the inline SVG/accessibility structure, and run the delivery visual checklist. Never introduce inline literal colors that break dark/light parity.
|