Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(architecture): simplify authoring and align reciprocal routes

tt-a1i1dc9dbec43d9
diff --git a/archify.zip b/archify.zip
index 9c1fa2d0..9f400007 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/SKILL.md b/archify/SKILL.md
index f4de44be..4405a87c 100644
--- a/archify/SKILL.md
+++ b/archify/SKILL.md
@@ -14,21 +14,21 @@ Create an interactive HTML diagram from typed JSON. Static output is the default
Run commands from your working directory, keeping candidate JSON and output artifacts there. Replace `bin/archify.mjs` in the commands below with the installed package's absolute path, or its path relative to your working directory; input and output paths resolve from that working directory.
-For a real codebase, read [Repository authoring](references/repository-authoring.md) for exploration and example selection. A system description uses the steps below; an existing JSON uses the handoff path.
+For a real codebase, read [Repository authoring](references/repository-authoring.md) while tracing the requested behavior. A system description uses the steps below; an existing JSON uses the handoff path.
## Existing candidate handoff
When the user supplies a frozen candidate, run `finalize` first as one CLI invocation. Its passing receipt completes the automated gates; follow any visual review recommendation under Delivery before claiming visual quality. For repair, follow step 5.
-The update check is outside the delivery critical path. A harness may start it concurrently with `finalize`; if it cannot, omit it for this task. Never add a foreground tool turn or delay a required gate for update information.
+The optional update check never delays `finalize`; see Update awareness.
## Fast authoring path
-Use this bounded path for ordinary generation. Do not read the optional Viewer Runtime reference unless the user asks about those features.
+Use this path for ordinary generation. Read branch references only when their stated trigger applies.
1. Choose `architecture`, `workflow`, `sequence`, `dataflow`, or `lifecycle` from the question.
-2. Use the exact paths in the Type router; do not list `schemas/` or `examples/` first. For Architecture, read `references/authoring-defaults.md` and the matching showcase example in a bounded output batch separate from project documents and complete schemas. Recover any truncated reference section before writing; raising a nested command limit does not prevent a combined tool response from truncating. The example includes boundaries, guided views, and conclusion cards. For Workflow, read defaults and its starter together. Read the relevant schema definition for any new field, enum choice, or constrained text; an example shows shape, not every allowed value or length. Boundary kinds and guided-view notes need their schema constraints before writing. For Sequence, Dataflow, and Lifecycle, read defaults, schema, common schema, and example together. Fresh authorship means new IDs, domain wording, and layout; examples provide shape, not facts. Do not run help, doctor, validate a starter, create a temporary diagram, pre-create/list output paths, or query brands. Only for explicitly requested branded marks may you query `node bin/archify.mjs brands "<name>" --json`; read `references/brand-marks.md` only for an unknown brand with a user-provided URL.
-3. Artifact first: once requested scope and source evidence are covered, write the candidate directly; do not plan coordinates in prose. For Architecture, default to a system overview led by the main user journey, with its necessary branches close. Choose subsystem-level nodes before coordinates; cooperating roles may share an accurately named node when their distinction is not the reader’s question. Keep secondary and opt-in capabilities in concise sourced notes unless their path is needed to understand that journey or a requested boundary. Preserve behavior-changing conditions and the requested scope. Use the defaults’ classic styling and title-only header unless the user requests otherwise. Choose abstraction for the reader's question using [Composition and meaning](references/authoring-defaults.md#composition-and-meaning). Split an overview node only when combining it would mislead the reader about a requested interaction or important boundary; expand internals when the user asks for that mechanism. Keep source evidence for every claim. Never use node, relationship, source-reference, view, card, or boundary counts as an authoring target, ceiling, or performance lever. Add guided views and conclusion cards only when they answer an additional reader question. Set `meta.quality_profile` to `"showcase"` unless the user requests dense `standard`. Place nodes by their actual connections using Layout and routing in the defaults: main-path neighbors stay adjacent, branches sit beside their owner, and return paths have an outside corridor. Check every relationship against that placement before writing positions; automatic routing cannot rearrange nodes. Leave clear gaps for actual relationship labels. Start with automatic routes and let them align main-path endpoints. Pin an endpoint side only for a necessary branch/return constraint or user-supplied geometry; facing-side pins can introduce doglegs between unequal-height nodes. Do not guess `via`, `channelX`, `channelY`, or label coordinates before measured geometry. Use the smallest control that expresses the intended route.
+2. Use the exact schema and example paths in the Type router without listing their directories. Read [Authoring defaults](references/authoring-defaults.md) and the mode's example in a bounded batch separate from project documents and complete schemas so neither is truncated; recover any missing section before writing. For Architecture, use the matching showcase example. For Sequence, Dataflow, and Lifecycle, also read the mode and common schemas. Read the relevant schema definition before choosing any new field, enum, or constrained text, especially boundary kinds and guided-view notes. Examples teach shape, not facts. Use fresh IDs, wording, and layout. Go directly to the candidate without preliminary help, doctor, starter validation, temporary diagrams, or output-path listing. Query brands only for an explicitly requested mark; read [Brand marks](references/brand-marks.md) for an unknown mark with a user-provided URL.
+3. Once the requested scope and, for a real codebase, [source evidence](references/repository-authoring.md) are covered, write the complete candidate directly without planning coordinates in prose. Choose Architecture abstraction and connected placement using Authoring defaults before coordinates: show the main user journey and necessary branches, preserve control roles and behavior-changing conditions, and leave enough room for actual relationship labels. No node, relationship, source, view, card, or boundary count is a target or ceiling. Use automatic routes first; add explicit routing only for necessary branch, return, supplied geometry, or measured repair. Set `meta.quality_profile` to `"showcase"` unless the user requests dense `standard`.
4. Once the complete first candidate is written, run `finalize` directly. Its first gate is showcase validation; successful first drafts need no separate pre-validation. Keep the candidate unchanged while the command runs:
```bash
@@ -37,18 +37,18 @@ Use this bounded path for ordinary generation. Do not read the optional Viewer R
For a repository-backed candidate, include evidence on the first draft and use the complete first command: `node bin/archify.mjs finalize <type> <candidate.json> <output.html> --repo-root <repo-root> --quality showcase --json`.
- A passing receipt proves that the included `validate`, `deliver`, strict `check`, and deterministic real-browser `browser-check` gates passed. Do not read its full sidecar or rerun individual commands afterward; use a standalone command only for an explicitly separate execution or focused failure diagnosis.
+ A passing receipt proves the included `validate`, `deliver`, strict `check`, and real-browser `browser-check` gates passed. Use its compact summary; run standalone commands only for a separate request or focused failure diagnosis.
-5. A non-zero exit is never success. Use its compact stdout or `evidence.summaryReceipt`; read the full receipt only if the summary is truncated and lacks enough evidence for a coherent repair. After a validation failure, edit the connected neighborhood named by the evidence in one coherent change. When several affected routes share nodes, read [Architecture layout repair](references/architecture-layout-repair.md) for Architecture, then reposition those nodes and their neighbors together. Choose endpoint sides for the main rail and return corridors as part of that same repair; reserve detailed waypoints or label overrides for an isolated remaining defect. Keep unrelated geometry intact only when the surrounding composition already reads clearly; a blocked main path requires reflowing the connected scene. Do not run validate, layout, render, or finalize first; edit the existing JSON in place. Preserve the requested meaning and its evidence during repair. For an authored overview that chose the wrong abstraction, follow Composition and meaning before regrouping; user-supplied or agreed topology stays fixed. For geometry defects, reroute, reposition, or add readable canvas space. After the edit, rerun the complete `finalize` command from step 4 once, retaining `--quality showcase` and `--repo-root <repo-root>` for repository-backed candidates. If that output already has browser evidence from a different candidate, preserve it and add a fresh `--out-dir <output-stem>.review-<revision>` for the new candidate; use the same directory for its `visual-check`. After editing, omit any earlier `--candidate-sha256`: it binds the previous candidate. Use `--layout-json` before the edit only when compact evidence lacks needed geometry. A receipt with only 4 artifact checks is basic validation: require all 9 checks with 0 composition errors and 0 warnings. Fix `meta.quality_profile` before geometry. For workflow v2, use the stable compiler receipt; solver internals are not authoring controls. Use standalone `validate` only for focused diagnosis, with `--repo-root <repo-root>` for a repository. A passing validation returns `candidateFrozen: true`; do not edit, revalidate, or reread it. Run its `nextAction.arguments`, replacing only `<output.html>`. Retry later environment or evidence failures against the frozen candidate. If measured evidence requires a source edit, treat it as a new candidate and rerun the complete `finalize` command without the old hash. If one issue survives two focused repairs, inspect measured geometry or the relevant contract; after one evidence-based retry, stop truthfully. A lower error count never justifies changing meaning.
+5. A non-zero exit is never success. Read compact stdout or `evidence.summaryReceipt`, then [repair the failed gate](references/delivery-contract.md#failed-finalize-and-candidate-repair), including its repair limit. Preserve requested meaning and source evidence. For several tangled Architecture routes, read [Architecture layout repair](references/architecture-layout-repair.md); for measured field or geometry failures, read [Authoring contract](references/authoring-contract.md). Edit the connected neighborhood and rerun the complete `finalize` command from step 4.
## Update awareness
-After the first candidate exists, a harness with true parallel tool calls may run the packaged checker `scripts/check-update.mjs` once alongside validation or `finalize`. Otherwise skip it; do not serialize it into the user's delivery path. If the checker cannot run, continue without mentioning it.
+After the first candidate exists, a harness with true parallel tool calls may run `scripts/check-update.mjs` once alongside `finalize`. Otherwise skip it without delaying delivery.
- For `silent`, continue without mentioning the update check.
- For `update_available`, read `references/update-awareness.md`, follow it, then continue the requested task.
-Do not read `bin/` implementation, renderer or validator source, tests, or benchmarks before the first candidate; the commands above are sufficient. Inspect implementation only for a diagnostic without actionable evidence or after two focused repairs fail.
+Before the first candidate, use the authoring references and relevant repository source, not Archify implementation or tests. Inspect Archify implementation if diagnostics remain unactionable after focused repairs.
## Type router
@@ -74,25 +74,15 @@ Read Mermaid for topology and meaning, then author fresh Archify JSON; do not me
Use the `finalize` command above for the first candidate and after a repair.
-`finalize` stops at the first non-passing gate. Its compact stdout and `<output-stem>.finalize-summary.json` are the normal evidence; `<output-stem>.finalize.json` is full audit detail, not ordinary repair context. A passing `finalize` receipt reports `visualReview: "not-requested"` and creates no screenshots; report the subsequent perceptual review separately.
+`finalize` stops at the first non-passing gate. Its compact stdout and `<output-stem>.finalize-summary.json` are ordinary evidence. A passing run creates no screenshots and reports `visualReview: "not-requested"`.
-Perceptual review is optional in ordinary generation: a new or repositioned Architecture does not by itself require screenshots or an image-reading step. Use it when the user requests a visual review, during development audits, or when a concrete route/browser concern needs visual diagnosis. `visualReviewRecommendation` is advisory, not a delivery gate or proof of a defect. Run `node bin/archify.mjs visual-check <output.html> --summary --require-provenance` and the same `--out-dir` as finalize, if used; compact JSON links all captures and the full receipt. If you choose to review, inspect the relevant viewport/theme captures and trace the affected relationships. For tangled routes, follow [Architecture layout repair](references/architecture-layout-repair.md); preserve meaning and evidence, then finalize the revised candidate. Without image inspection, report automated checks only and leave perceptual review unclaimed. If perceptual review is unavailable, report that quality remains unverified for that requested review.
+Perceptual review is optional for ordinary generation, including a newly positioned Architecture. Use [Optional capture evidence](references/delivery-contract.md#optional-capture-evidence) when the user requests visual review, during development audits, or for a concrete route/browser concern. `visualReviewRecommendation` is advisory. Inspect captures before claiming visual quality; otherwise report automated checks only.
-For recovery, the required order stays `deliver` → strict provenance `check` → `browser-check`. Run `visual-check` only against a strict-provenance artifact. Read `references/delivery-contract.md` for standalone syntax, any failed gate, stale provenance, recovery metadata, repeated delivery to one path, export evidence, or post-delivery opening.
+Read [Delivery contract](references/delivery-contract.md) for failed gates, standalone commands, provenance/recovery, repeated delivery, exports, or opening. Recovery follows `deliver` → strict provenance `check` → `browser-check`; captures require strict provenance.
For workflow viewport overflow, read [Workflow viewport repair](references/authoring-contract.md#workflow-viewport-repair) before the next layout edit.
-`browser-check` collects machine-readable browser evidence from the exact delivered HTML without modifying, rerendering, or capturing it. `visual-check` is the capture-producing command for an escalated perceptual review.
-
-Keep the claims separate: `deliver` proves deterministic artifact checks, `browser-check` proves bounded behavior in a real browser, `visual-check` adds artifact-bound captures, and perceptual review requires an actual human or image-capable reviewer. Report optional perceptual review only when it was requested or triggered by the escalation rules above.
-
-For a standalone `deliver` invocation, add `--open` only when the user wants an immediate local preview; `finalize` does not accept that flag. For an active desktop authoring loop, the optional command is:
-
-```bash
-node bin/archify.mjs preview <type> <input>.json <output>.html --quality showcase
-```
-
-Never start preview by default.
+Report artifact checks, browser evidence, captures, and actual perceptual review as distinct results. For an explicitly requested immediate preview or active desktop loop, see [Optional opening](references/delivery-contract.md#optional-opening).
## Optional viewer capabilities
@@ -102,7 +92,7 @@ Read `references/viewer-runtime.md` only when the user explicitly asks for Share
## Setup and fallback
-No install is required inside the skill package. Verify with:
+No install is required inside the skill package. For setup diagnosis, verify with:
```bash
node bin/archify.mjs doctor
diff --git a/archify/references/authoring-contract.md b/archify/references/authoring-contract.md
index 0b9d2c75..59f02994 100644
--- a/archify/references/authoring-contract.md
+++ b/archify/references/authoring-contract.md
@@ -2,6 +2,16 @@
Read this reference only after the Fast authoring path calls for more detail. The schemas and examples remain authoritative.
+## Composition repair
+
+When correcting an authored overview's abstraction, map every affected role, relationship direction, protocol, boundary, condition, and source reference to its surviving node or relationship before regrouping. A startup citation does not prove a message protocol. Preserve each claim's inspected evidence. Keep user-supplied or agreed topology fixed; fewer routes alone do not justify merging. A boundary around one node requires an explicit isolation fact and must not merely repeat its label.
+
+## Label repair
+
+When a relationship label collides, move the label, adjust the route or spacing, then shorten the wording while preserving meaning. Omit wording only when both endpoints fully imply it and it conveys no protocol, action, direction, synchronous or asynchronous behavior, or cross-boundary mechanism. Spacing means clear gap rather than center distance; measured mask width takes precedence. The first-draft gap budget is in [Layout and routing](authoring-defaults.md#layout-and-routing).
+
+For a disproportionate sublabel, keep its exact role or protocol concise and place the supplementary fact in a note or card. Preserve every required responsibility, protocol, and boundary fact. Use the first-draft node-width budget in [Layout and routing](authoring-defaults.md#layout-and-routing).
+
## 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.
@@ -21,6 +31,10 @@ edge labels are never deleted as a spacing repair. Do not change only
[migration and layout-receipt contract](../renderers/workflow/README.md#migration-and-layout-receipt).
The complete normative invariants live in the workflow renderer's
[layout contracts](../renderers/workflow/README.md#layout-contracts).
+For sequential stages stacked in one container, use one v2 lane and group,
+omit `meta.viewBox`, and center nodes around the lane content with symmetric
+`yOffset` values such as `-90 / 0 / 90`. Keep semantic edge labels and act on
+compiler diagnostics.
## Legend contract
@@ -103,7 +117,9 @@ 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.
+Generate one responsive artifact for laptops and external displays, preserving the authored SVG/viewBox, proportions, semantic geometry, and normal document flow. Use meaningful content rows and the Reader-declared readable page-scroll behavior when the complete diagram needs more height; viewport fitting does not authorize alternate topology or smaller typography.
+
+- 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 unless a reciprocal facing pair can jointly use separate straight lanes while preserving endpoint spacing, labels, and all surrounding route and obstacle clearances.
- A side is a direction contract. The first and final route segment must be perpendicular and outward/inward in the named direction.
- In architecture, data-flow, and lifecycle diagrams, explicit `route: "straight"` requests one direct segment, which may be diagonal when endpoint sides are not pinned. The artifact checker preserves this intent; explicit sides, opaque-node clearance, and other quality gates still apply. `via` takes precedence and retains existing rules, including data-flow's requirement for orthogonal via segments.
- 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.
@@ -279,6 +295,8 @@ Main phases use columns `0..4`; event and terminal bands use columns `0..2`.
Event/terminal column `N` aligns to the same x coordinate as main column
`N + 2`. A recoverable failure needs a real transition back to an active state.
A card or guided view saying “retry” is not topology.
+Every lane other than `main` and `terminal` shares one middle band; states in
+the same column there need distinct `yOffset` values.
## Repository evidence
diff --git a/archify/references/authoring-defaults.md b/archify/references/authoring-defaults.md
index 78657c89..fd4e9da4 100644
--- a/archify/references/authoring-defaults.md
+++ b/archify/references/authoring-defaults.md
@@ -1,78 +1,33 @@
# Authoring defaults
-Read this file once before writing a fresh candidate. A frozen existing candidate that is going straight to `finalize` does not need it unless a failed gate requires repair.
+Read once before writing a fresh candidate. An existing frozen candidate going straight to `finalize` needs this only if repair changes its authorship.
## Composition and meaning
-- For Architecture, default to a system overview unless the user requests a narrower mechanism, module map, or deployment topology. Lead with the main user journey and keep necessary branches close. Group cooperating implementation roles into accurately named subsystems; a group may contain multiple processes without implying they are one process. Expose a separate role or interaction when combining it would hide a requested mechanism or an important boundary. Retain secondary and opt-in capabilities as concise sourced notes by default; draw their path when needed to understand the main journey or a requested boundary. Preserve their role and trust conditions in either form. Name a deliberately narrower scope in the title rather than silently omitting it.
-- Choose abstraction by the reader's question: would combining these responsibilities mislead the reader about the requested behavior, control ownership, trust, lifecycle, or persistence? If so, keep them separate; otherwise use an accurately named overview node with supporting labels and source references. Keep a behavior-changing condition visible on its affected node or relationship: an approval, authorization, or state-transition gate must not look unconditional while its qualifier appears only in a card. Separate source files, classes, protocols, or internal services do not by themselves require separate nodes. For example, an overview may show one local HTTP / WebSocket service; a transport-mechanism diagram may expand it. A cloud relay and a local decrypting bridge stay distinct when the remote trust boundary matters.
-- Cover the requested meaning, with evidence for every claim. An overview need not enumerate every implementation role discovered during source reading. Put useful supporting facts in sublabels or concise cards; expand a subsystem in a focused diagram when its mechanism is requested. Guided views focus existing topology and do not collapse a crowded default overview. Add `meta.views` or cards only for a real reader question, with no quota.
-- Let the requested question and source facts determine node and relationship counts; never target a number. Choose scope and abstraction before routing. Once authoring or repairing an agreed detailed graph, preserve its required roles, relationships, meaningful labels, and evidence; geometry failures do not authorize silently reducing that scope.
-- When correcting an authored overview's abstraction, map every affected role, relationship direction, protocol, boundary, and source reference to its surviving node or relationship before regrouping. Carry the inspected references for each retained claim onto the relevant surviving component; a citation proving process startup does not also prove its message protocol. Check that requested meaning and evidence still have a home. User-supplied or agreed topology stays fixed; fewer routes alone do not justify merging.
-- A boundary is evidence, not decoration. Use it when it communicates a real trust, runtime, process, ownership, or persistence boundary; a boundary around one node needs an explicit isolation fact. Do not box every concern or duplicate the node label as a boundary title.
-- Relationship labels are semantic data. When one collides, move the label, adjust the route or spacing, then shorten the wording while preserving meaning. Omit only wording that is already fully implied by both endpoints and contains no protocol, action, direction, synchronous/asynchronous behavior, or cross-boundary mechanism. Preserve every meaningful label; deleting it is not a geometry repair. If a relationship starts unlabeled because its endpoints fully imply it, explain why the wording is redundant; this is a semantic authoring choice, not a geometry repair.
+For Architecture, default to a system overview led by the main user journey unless the user asks for a narrower mechanism, module map, or deployment topology. Group cooperating roles in accurately named subsystems when that still explains the requested interaction. Separate roles when grouping would hide control ownership, a trust or persistence boundary, lifecycle behavior, or another distinction the reader asked about. Keep secondary and opt-in capabilities in concise sourced notes unless their path matters to the requested question. Name a deliberately narrower scope in the title.
-## Layout and routing
-
-- Place Architecture nodes from connectivity before assigning coordinates: lay the main interaction path in order, place a branch beside the node it actually connects to, and place a shared store beside its main readers/writers. A category row (all runtimes, then all workers, then all stores) is useful only when the actual edges also follow it. Keep each tightly connected neighborhood together; give real return paths a clear outside corridor. Mentally trace every relationship across the proposed boxes before writing: if an unrelated node or another neighborhood blocks it, move the connected neighborhood now. The router chooses paths around fixed boxes; it does not rearrange a poor node layout. Choose the main path by the reader’s task, not by component category or the longest graph path. Keep a second data-processing chain in its own consistent reading order; place its scheduler beside the stage it drives. Do not move the main actor to a distant row to make room for a background worker. This is part of writing the first JSON, not an extra planning document or tool pass.
-- Treat the standalone desktop viewer as a first-screen artifact by default, not a shallow strip. Generate one responsive artifact for laptops and external displays, preserving the authored SVG/viewBox, proportions, semantic geometry, and normal document flow. Start the first meaningful row near the canvas origin and use real content rows to create vertical rhythm; empty leading rows only enlarge the canvas and shrink the drawing. Keep the diagram panel and necessary conclusion cards balanced across wide and tall desktops. For a fresh Architecture, omit `meta.viewBox` by default so the renderer measures the real content and declares intrinsic-height Reader behavior. Author a fixed viewBox only when the user supplied fixed geometry or measured evidence shows it is necessary and the resulting text remains comfortably readable.
-- For a medium Architecture, encode one obvious main path, but let it step across multiple rows when one horizontal rail would create a shallow strip, long empty corridors, or force semantic compression. Put short branches above or below their nearest hub. Start with automatic routes. Leave main-path `fromSide` / `toSide` unset so the router can align endpoints across different node heights. Pin a side only for a necessary branch or return constraint, such as a return edge on the outer side of a hub. Reserve `via`, `channelX`, `channelY`, and label-position controls for measured geometry. Never make unrelated orthogonal segments share the same axis for 8px or more; keep nonzero segments at least 8px and interior turns at least 16px.
-- Before writing, apply `6.5px × ASCII units + 21px`, counting each CJK character as two units, to every labeled connection on the main path. Treat the result as that edge's minimum clear gap, never as one fixed gap shared across the row. Increase the gap or choose a clear segment when the budget does not fit; do not wait for a predictable label-route collision.
-- Spacing means clear gap, not center distance. For a relationship label, clear gap must exceed its measured mask width; follow the label-preserving repair order.
-- Architecture sublabels render at a preferred 9px before responsive projection. Size each component for that preferred size (`5.4px × text units + 8px`, counting each CJK character as two units) instead of relying on shrink-to-fit. If a supporting phrase would make the node disproportionately wide, keep the node's exact role or protocol concise and preserve the supplementary fact in a guided-view note or conclusion card. Never remove a responsibility, protocol, or boundary fact just to shorten text.
-- Never accept an edge crossing an unrelated opaque node, an ambiguous shared corridor, or a relationship label masking another route.
-
-## Repository-backed first draft
-
-When the diagram reflects a real repository, finish the evidence shape while inspecting source, not after validation fails. Copy the credential-free origin returned by `git remote get-url origin` without converting its transport or path, and record the full 40-character commit, add `meta.repository`, and attach at least one inspected `sources` entry to every key semantic node. Use only real repository-relative files and line numbers; source references are evidence, never decoration. The minimum shape is:
-
-```json
-"meta": { "repository": { "url": "<credential-free-origin>", "revision": "<40-char-commit>" } },
-"components": [{ "id": "runtime", "sources": [{ "path": "src/runtime.ts", "line": 1, "label": "runtime entry" }] }]
-```
+Preserve every requested responsibility, relationship direction, protocol, and behavior-changing condition. Show approval, authorization, and state-transition gates on the affected node or relationship; a card alone cannot qualify an otherwise unconditional arrow. Keep source evidence with each asserted claim. Boundaries express real isolation, ownership, runtime, or persistence facts. Guided views and cards answer additional reader questions; they do not replace required topology. There is no node, edge, source, view, card, or boundary quota. If an authored overview needs regrouping after failure, use [Composition repair](authoring-contract.md#composition-repair); user-supplied or agreed topology remains fixed.
-For an SSH origin, an unsupported forge, or intentionally local-only source links, set `meta.repository.link_mode` to `"local-only"` and retain `url` and `revision`. Web links require a supported GitHub/Gitee HTTPS origin. Local-only disables web hyperlinks while preserving local identity and source verification.
+Relationship labels carry meaning. Give them clear space and preserve action, protocol, direction, async behavior, or cross-boundary meaning. A label may start absent only when both endpoints already fully imply it; a collision calls for spacing or routing repair. See [Label repair](authoring-contract.md#label-repair) when measured evidence reports a collision.
-Keep `<repo-root>` from source inspection and pass it to the first `finalize` call. Choose the diagram's abstraction using Composition and meaning; retain required facts and evidence at that level.
-
-A source reference proves only the implementation visible at that location. When separate files or locations establish materially different relationships, protocols, lifecycle transitions, persistence behavior, or conclusion-card claims, attach those inspected locations to the relevant semantic node. Let the real claims determine the references; never target a total reference count or reuse one citation as a proxy for evidence it does not contain.
-
-## Field constraints before writing
-
-Examples demonstrate valid field shape. Before choosing a different boundary kind or writing a guided-view note, inspect `properties.boundaries.items` in `schemas/architecture.schema.json` and `$defs.guidedViews` in `schemas/common.schema.json`. Use their actual enums and length limits. Keep longer evidence in a conclusion card; do not remove the underlying fact to fit a note. Finished showcase examples may contain measured route repairs; transfer their semantic shape, then follow the automatic-routing first-draft rule in Layout and routing.
-
-## Presentation defaults
+## Layout and routing
-- Omit `meta.visual_preset` by default so every diagram opens in `classic`, regardless of whether its resolved color mode is light or dark. Switching Light / Dark preserves the current preset. Set `signal-flow`, `blueprint`, or `editorial` only when the user explicitly requests that visual style.
-- Omit `meta.subtitle` by default. Never invent a subtitle that restates the title, nodes, or cards; include one short supporting line only when the user explicitly asks for it.
-- Omit `meta.legend` for the truthful `auto` default. When needed, use only `mode: auto|all|hidden` and renderer-supported `entries.<kind>.label|visible`; labels never change semantics.
-- Component types are `frontend`, `backend`, `database`, `cloud`, `security`, `messagebus`, and `external`. Components do not accept a `variant` field. Relationship variants are `default`, `emphasis`, `security`, and `dashed`; when an optional component must be visible, mark it in the component label and use a dashed relationship instead.
-- Omit `meta.engineering_profile` by default. Region, cluster, and security boundary wording do not by themselves enable it. 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, must not remove the engineering profile merely to pass validation; repair the facts or report the diagnostics truthfully.
+Place Architecture nodes by their actual connections before assigning coordinates. Keep main-path neighbors adjacent, put each branch beside its owner and shared stores near their readers and writers, and reserve an outside corridor for real returns. Trace every relationship against that placement before writing positions; the router cannot rearrange boxes. Let a medium main path step through meaningful rows instead of making a shallow horizontal strip. Start the main actor and its first connected step together near the canvas origin; use content rows for vertical rhythm. Omit `meta.viewBox` for a fresh Architecture so the Reader measures intrinsic height. Keep supplied fixed geometry authoritative.
-## Language and identity
+Start with automatic routes and endpoint sides. Pin a side only for a necessary branch, return, or supplied geometry. Reserve `via`, `channelX`, `channelY`, and label coordinates for measured defects. Before writing positions, budget each labeled main-path edge at `6.5px × ASCII units + 21px` of clear gap, counting CJK as two units; use its own label length, not a row-wide fixed gap. Size Architecture sublabels for their preferred 9px text at `5.4px × text units + 8px`, with CJK counting twice; keep supporting copy concise without dropping required facts. Do not trade readability or meaning for fewer crossings. The [Geometry reference](authoring-contract.md#executable-geometry-rules) has measured spacing, port, canvas, and route rules for a diagnosed layout problem.
-- Choose one primary authored language from an explicit user choice; otherwise follow the request or conversation's dominant language. `meta.locale` controls only renderer-owned Viewer UI: use `"en"`, `"zh-CN"`, or `"es"` for the corresponding supported primary language. For every other language, omit `meta.locale` and explicitly disclose that the fixed Viewer UI and `<html lang>` fall back to English. The renderer never translates authored content. See `authoring-contract.md` for details.
-- Preserve exact product names, code identifiers, commands, protocols, API paths, and environment names. They may remain English inside localized copy, but never justify leaving the surrounding explanatory prose in another language.
-- Keep node and boundary headings concise in that primary language. Do not append a parenthesized translation that merely repeats the same meaning; keep only exact product or protocol identifiers in their original form and move useful explanation into the sublabel, guided-view note, or card.
-- Brand identity is optional and explicit. Put a canonical built-in ID in `brand` when the node names that real product. If no preset matches and the user supplied the official HTTP(S) URL, first run `node bin/archify.mjs brands capture "<url>" --json`, then author the returned digest-pinned `brand` object. Render and validate never perform an unpinned capture. Otherwise omit `brand`. Never infer a brand from a vague role such as "database", and never let a badge replace the semantic `type`, label, or relationship facts.
+## Evidence and schema
-## Output path
+For a real repository, follow [Repository authoring](repository-authoring.md) while inspecting source. Freeze its credential-free origin and 40-character commit in `meta.repository`, attach inspected repository-relative `sources` to each key semantic node, and pass `--repo-root` to the first `finalize`. Each reference proves only the fact visible at that location. Follow material relationships and conditions to their actual source; do not reuse a startup citation as protocol or persistence evidence.
-Set required `meta.output` to a portable POSIX-relative `.html` path, such as `reports/diagram.html`. It resolves from the working directory and must remain inside it. An explicit native CLI output may be elsewhere but does not replace this authored contract. See [Output path contracts](delivery-contract.md#output-path-contracts) for native Windows paths, aliases, and long filenames.
+Examples show field shape, not legal values or source facts. Read the mode schema and shared definition before adding a field, enum, or constrained text. In particular, inspect Architecture boundary kinds and common guided-view note limits. Keep longer evidence in a card while retaining the fact. See [Schema lookup](authoring-contract.md#schema-lookup) for details.
-## Reader and routing reference
+## Presentation and modes
-- Let `finalize` run the real browser check at 1440×900, 1600×1000, 1920×1080, and 2048×1320. Require zero horizontal overflow. Prefer full first-screen containment only when the complete diagram stays comfortably readable. The 6px projected-text check is a hard failure floor, not a layout target; at 1440px, aim for ordinary context text around 7.5px or larger. If semantic completeness needs more room, add meaningful vertical rows and use Reader-declared vertical page scroll with an intrinsic-height diagram instead of merging responsibilities, dropping evidence, or squeezing typography. Repair every other overflow by removing genuinely redundant content or compacting spacing before shrinking nodes, labels, or the main panel. Never counterfeit a pass with `overflow: hidden`, clipped content, an internal diagram scroller, stretched SVG height, or smaller typography. See [Automated browser evidence](delivery-contract.md#automated-browser-evidence) for the authoritative rule.
-- If the largest viewport still has a conspicuous empty lower band at the viewer's width cap, redistribute authored Y positions and increase the viewBox height proportionally; do not add filler copy or decorative cards.
-- Automatic routes own their endpoint sides. A relationship does not accept a `side` field; use `fromSide` or `toSide` when a deliberate branch or return direction is needed. Each endpoint side is a direction contract: the first and final segment must leave/enter perpendicular to that side.
-- Estimate the resolved Architecture content width before the first write. At 1440px, legacy, unknown, and authored-viewBox artifacts use the conservative 930px diagram budget. A fresh automatic wide Architecture with the recognized Reader contract instead reports its declared budget and cap in `composition.desktopReadability`; use that evidence before changing a semantic node or relationship label. Keep ordinary context text comfortably above the 6px hard floor by adding meaningful rows or using intrinsic-height layout, not by dropping meaning or designing to a fixed viewBox width.
-- Automatic Port Spread is a default renderer behavior for architecture, workflow, data-flow, and lifecycle. It skips single relationships and explicit `via`, `channelX`, `channelY`, `labelAt`, or non-`auto` routes. Near parallel ports use an outside bridge so automatic routing cannot create a sub-8px segment or sub-16px interior turn. Architecture separately keeps unobstructed facing automatic ports (`left`/`right` or `top`/`bottom`) on one shared axis when their offset is under 16px and both ports retain corner clearance. If exactly one endpoint was spread, only the unshared endpoint may move onto that axis; if both endpoints were spread, keep the outside bridge so competing ports remain distinct.
-- In showcase Architecture, an explicit route must stay proportionate to the shortest legal orthogonal route. `composition/excessive-route-detour` reports the actual length, obstacle-aware shortest length, ratio, and empty-space excursion. Remove an unnecessary `via` or move the diagnosed corridor inward; do not enlarge the canvas to legitimize the detour. Related edges may share one deliberate outer bus.
+Use one primary authored language from the user's choice or the request/conversation. Set `meta.locale` for supported English (`en`), Simplified Chinese (`zh-CN`), or Spanish (`es`); otherwise omit it and disclose the fixed Viewer UI and `<html lang>` English fallback. Keep exact product, code, protocol, command, API, and environment names while localizing surrounding explanation. See [Language consistency](authoring-contract.md#language-consistency) for bilingual cases.
-## Type-specific defaults
+Omit `meta.visual_preset` for classic, `meta.subtitle` for a title-only header, `meta.legend` for truthful auto, and `meta.engineering_profile` for an ordinary system overview. Explicit styles and a subtitle require a user request. Use legend or deployment ownership under the [legend](authoring-contract.md#legend-contract) or [engineering profile](authoring-contract.md#engineering-profile-default) contracts. Branding is optional and explicit when a node names a real product; [Brand marks](brand-marks.md) gives lookup and capture rules for that branch. Never let a badge replace semantic type, label, or relationship facts. Set required `meta.output` to a portable POSIX-relative `.html` path within the working directory; see [Output path contracts](delivery-contract.md#output-path-contracts) for native path exceptions.
-- Workflow: use schema v2 for new workflows and preserve schema v1 for an existing source with fixed legacy geometry. For sequential stages stacked in one container, use one v2 lane and one group, omit `meta.viewBox`, and place nodes around the lane content center with symmetric `yOffset` values such as `-90 / 0 / 90`. Keep semantic edge labels and act on compiler diagnostics. The canonical contract is in [`../renderers/workflow/README.md`](../renderers/workflow/README.md#layout-contracts).
-- Sequence: omit `meta.column_fit` for the stable `fixed` layout. Set it to `"spread"` when a wide viewBox leaves unused horizontal space or meaningful participant labels do not fit fixed boxes; do not shorten semantic labels before trying `spread`.
-- Lifecycle: phase columns `0..4` occupy the main rail. Event or terminal column `N` in `0..2` aligns beneath main column `N + 2`. Every lane other than `main` and `terminal` shares the one middle band, so two such states in the same column need distinct `yOffset` values. A recoverable state uses `type: "failure"` plus a real transition back to the active state.
+For new Workflow use schema v2, preserving v1 for a fixed legacy source; use its [layout contracts](../renderers/workflow/README.md#layout-contracts) when lane or group geometry needs detail. For Sequence start with fixed columns; use `spread` when a wide viewBox leaves unused horizontal space or meaningful labels need width. For Lifecycle, main phases use columns `0..4`, event and terminal bands use `0..2` aligned beneath main `N + 2`; a recoverable failure needs a real transition back. Read [Mode placement](authoring-contract.md#mode-placement) when a mode-specific placement or viewport problem needs more detail.
-Read `authoring-contract.md` only when field enums, spacing math, geometry repair rules, repository evidence, or more mode-specific placement is needed.
+`finalize` performs the browser gate. Keep the complete drawing comfortably readable on desktop, with zero horizontal overflow. Use meaningful vertical rows and intrinsic-height page scroll when necessary. The 6px projected-text check is a failure floor; at 1440px, aim for ordinary context text around 7.5px or larger. See [Automated browser evidence](delivery-contract.md#automated-browser-evidence) when viewport evidence fails.
diff --git a/archify/references/delivery-contract.md b/archify/references/delivery-contract.md
index a908089b..9e4d32fe 100644
--- a/archify/references/delivery-contract.md
+++ b/archify/references/delivery-contract.md
@@ -1,5 +1,15 @@
# Delivery contract
+## Failed finalize and candidate repair
+
+`finalize` stops at the first non-passing gate. Use compact stdout or `evidence.summaryReceipt`; read its full sidecar only when the summary lacks evidence needed for a coherent repair. A receipt with four artifact checks is basic validation, not showcase acceptance: require all nine checks, zero composition errors, and zero warnings. Fix `meta.quality_profile` and schema errors before geometry.
+
+For a validation failure, edit the existing JSON in the connected neighborhood named by diagnostics before rerunning a command. Preserve requested semantics, meaningful labels, source evidence, and fixed or agreed topology. Several routes sharing nodes call for one placement repair; read [Architecture layout repair](architecture-layout-repair.md) for that case. Reflow a blocked main path rather than nudging unrelated labels. Keep unrelated geometry when its composition already reads clearly. Use `--layout-json` before editing only when compact evidence lacks needed measurements. Workflow v2 uses its stable compiler receipt, not solver internals, as authoring evidence.
+
+After the edit, rerun the complete `finalize` command with `--quality showcase` and, for repository-backed work, `--repo-root <repo-root>`. If the output path already has browser evidence from another candidate, use a fresh `--out-dir <output-stem>.review-<revision>` for both the new `finalize` and any `visual-check`. Omit an earlier `--candidate-sha256` after editing because it binds the previous candidate. Compare diagnostics by code, subject, stage, and evidence, never by declining error count alone. If an issue survives two focused repairs, inspect measured geometry or the relevant contract; after one evidence-based retry, report the concrete gap.
+
+Use standalone `validate` only for focused diagnosis, passing `--repo-root` for repository-backed work. Its passing receipt marks `candidateFrozen: true`; run `nextAction.arguments`, replacing only `<output.html>`, without editing, revalidating, or rereading the candidate. Retry later environmental or evidence failures against those frozen bytes. A measured reason to edit creates a new candidate and calls for the complete `finalize` without the old hash.
+
## Validate and deliver
`render` and direct renderer entry points print classified authoring failures
diff --git a/archify/references/repository-authoring.md b/archify/references/repository-authoring.md
index d531be27..f2e8dc02 100644
--- a/archify/references/repository-authoring.md
+++ b/archify/references/repository-authoring.md
@@ -12,8 +12,10 @@ fact has supporting source evidence.
userinfo (including usernames, passwords, and tokens) before recording the
origin or placing it in the candidate. Preserve its transport, port, path and
`.git` suffix; do not rewrite an internal SSH origin as HTTPS. Pin the credential-free URL and
- forty-character revision in `meta.repository`; use `link_mode: "local-only"`
- for a local fixture whose HTTPS URL is only a repository identity. If the
+ forty-character revision in `meta.repository`. Use `link_mode: "local-only"`
+ for an SSH origin, unsupported forge, intentionally local-only source links,
+ or a local fixture whose HTTPS URL is only a repository identity; retain the
+ URL and revision. Web links require a supported GitHub or Gitee HTTPS origin. If the
worktree is dirty, record the changed paths. Repository evidence is verified
against committed bytes at the pinned revision, not working-tree edits:
inspect a clean checkout at that revision for any cited changed path. Do not
@@ -28,10 +30,14 @@ fact has supporting source evidence.
side effect. Read a small connected slice instead of scanning the repository
for a convenient label.
-3. **Trace ownership.** For each step, name the controller that owns the
- decision, the runtime that performs it, and the filesystem or durable store
- that supplies or receives bytes. Keep control ownership separate from file
- I/O in your source understanding. Choose which distinctions need separate
+3. **Trace ownership.** Derive runtime and I/O relationships from the observed
+ actor, operation, and target at their call sites; deployment and trust
+ relationships use the corresponding configuration or enforcement evidence. Distinguish the controller requesting
+ an operation from the runtime that executes it and the store receiving bytes.
+ For a file or database edge, the source must identify its actual reader or
+ writer; a responsibility statement such as “maintains tasks” does not prove
+ direct I/O. Keep these facts with the source locations while reading, without
+ a separate planning artifact. Choose which distinctions need separate
nodes using [Composition and meaning](authoring-defaults.md#composition-and-meaning);
discovering an implementation role does not automatically add it to the overview.
A configured provider, an injected adapter, a local stub, and a durable
@@ -41,7 +47,10 @@ fact has supporting source evidence.
inclusive line ranges for each component and meaningful relationship. Follow
actual branches, retries, fallbacks, and error handling. A function that is
exported or configured but never called by the normal path is an optional
- capability, not a required runtime edge.
+ capability, not a required runtime edge. For a claim about authoritative
+ state change or control ownership, trace to the actual write or execution
+ site and the conditions that permit it; an upstream caller alone does not
+ establish those conditions.
5. **Name uncertainty.** Write unresolved questions beside the claim they
affect: for example, “`writeFile` is called here; durability is unknown.”
diff --git a/archify/renderers/architecture/routing.mjs b/archify/renderers/architecture/routing.mjs
index ee62bc4e..fbb85597 100644
--- a/archify/renderers/architecture/routing.mjs
+++ b/archify/renderers/architecture/routing.mjs
@@ -13,6 +13,7 @@ import {
properSegmentIntersection,
routeHonorsEndpointSides,
normalizeRoutePoints,
+ rectsOverlap,
roundedPath,
collectBorderRuns,
collectRouteRhythmIssues,
@@ -102,6 +103,8 @@ export function createRouter(components, connections = [], {
crossoverRoutedCount: 0,
readabilityCandidateCount: 0,
readabilityImprovedCount: 0,
+ reciprocalCandidateCount: 0,
+ reciprocalImprovedCount: 0,
gridAttempts: [],
};
@@ -632,6 +635,11 @@ export function createRouter(components, connections = [], {
);
}
+ function hasAuthoredLabelPlacement(conn) {
+ return ['labelAt', 'labelDx', 'labelDy', 'labelSegment']
+ .some((field) => conn?.[field] !== undefined);
+ }
+
// A route can change sides after the initial port spread. Reserve slots on
// the final side as well: falling back to its midpoint can put an arrow
// between two existing slots, or directly on another incoming arrow.
@@ -865,11 +873,150 @@ export function createRouter(components, connections = [], {
top: Math.min(...scenePoints.map(([, y]) => y)), bottom: Math.max(...scenePoints.map(([, y]) => y)),
};
const withinScene = ([x, y]) => x >= bounds.left && x <= bounds.right && y >= bounds.top && y <= bounds.bottom;
+ const jointlyImproved = new Set();
+ function improveReciprocalPairs() {
+ // A one-route sweep cannot repair reciprocal facing edges whose initial
+ // spread groups differ. Try both direct lanes together after final side
+ // geometry is known, leaving every other route and authored port in place.
+ const paired = new Set();
+ for (const first of resolvedRoutes) {
+ const conn = first.conn;
+ if (paired.has(conn) || hasAuthoredRouteGeometry(conn) || hasAuthoredLabelPlacement(conn)
+ || (conn.fromSide && conn.fromSide !== 'auto')
+ || (conn.toSide && conn.toSide !== 'auto')) continue;
+ const second = resolvedRoutes.find((entry) => entry !== first
+ && entry.conn.from === conn.to && entry.conn.to === conn.from
+ && !hasAuthoredRouteGeometry(entry.conn) && !hasAuthoredLabelPlacement(entry.conn)
+ && (!entry.conn.fromSide || entry.conn.fromSide === 'auto')
+ && (!entry.conn.toSide || entry.conn.toSide === 'auto'));
+ if (!second) continue;
+ paired.add(conn);
+ paired.add(second.conn);
+ const firstSides = inferredConnectionSides(conn);
+ const secondSides = inferredConnectionSides(second.conn);
+ const horizontal = firstSides.fromSide === 'right' && firstSides.toSide === 'left'
+ && secondSides.fromSide === 'left' && secondSides.toSide === 'right';
+ const horizontalReverse = firstSides.fromSide === 'left' && firstSides.toSide === 'right'
+ && secondSides.fromSide === 'right' && secondSides.toSide === 'left';
+ const vertical = firstSides.fromSide === 'bottom' && firstSides.toSide === 'top'
+ && secondSides.fromSide === 'top' && secondSides.toSide === 'bottom';
+ const verticalReverse = firstSides.fromSide === 'top' && firstSides.toSide === 'bottom'
+ && secondSides.fromSide === 'bottom' && secondSides.toSide === 'top';
+ if (!horizontal && !horizontalReverse && !vertical && !verticalReverse) continue;
+ if (first.points.length <= 2 && second.points.length <= 2) continue;
+ const axis = horizontal || horizontalReverse ? 1 : 0;
+ const others = resolvedRoutes.filter((entry) => entry !== first && entry !== second);
+ const firstGeometry = connectionGeometry(conn, firstSides);
+ const secondGeometry = connectionGeometry(second.conn, secondSides);
+ if (firstGeometry.crowded || secondGeometry.crowded) continue;
+ const previousLabels = reservedLabels;
+ let improved = false;
+ reservedLabels = reservedLabels.filter((entry) => entry.conn !== conn && entry.conn !== second.conn);
+ try {
+ const lanes = (geometry) => [...new Set([geometry.start[axis], geometry.end[axis]])];
+ const direct = (geometry, lane) => {
+ const start = [...geometry.start];
+ const end = [...geometry.end];
+ start[axis] = lane;
+ end[axis] = lane;
+ return { points: [start, end], d: roundedPath([start, end], 8) };
+ };
+ const endpointSlotsClear = (candidateRoutes) => {
+ const entries = [...others, ...candidateRoutes];
+ for (const candidate of candidateRoutes) {
+ const sides = candidate.conn === conn ? firstSides : secondSides;
+ for (const [componentId, side, point] of [
+ [candidate.conn.from, sides.fromSide, candidate.points[0]],
+ [candidate.conn.to, sides.toSide, candidate.points.at(-1)],
+ ]) {
+ const coordinate = side === 'left' || side === 'right' ? 1 : 0;
+ for (const other of entries) {
+ if (other.conn === candidate.conn) continue;
+ const otherSides = other.conn === conn ? firstSides
+ : other.conn === second.conn ? secondSides : selectedSides.get(other.conn);
+ for (const [otherId, otherSide, otherPoint] of [
+ [other.conn.from, otherSides.fromSide, other.points[0]],
+ [other.conn.to, otherSides.toSide, other.points.at(-1)],
+ ]) {
+ if (componentId === otherId && side === otherSide
+ && Math.abs(point[coordinate] - otherPoint[coordinate])
+ < portSpacing(candidate.conn, other.conn) - 0.0001) return false;
+ }
+ }
+ }
+ }
+ return true;
+ };
+ const labelClears = (rect, owner, entries, labels) => {
+ if (!rect) return !owner.label;
+ if (!withinScene([rect.x, rect.y])
+ || !withinScene([rect.x + rect.width, rect.y + rect.height])
+ || labels.some((other) => rectsOverlap(rect, other.rect, 2))) return false;
+ return entries.every((entry) => entry.conn === owner || entry.points.slice(1).every((end, index) =>
+ !segmentIntersectsRect({ start: entry.points[index], end }, rect, LABEL_CLEARANCE)));
+ };
+ let best = null;
+ let bestCost = readabilityCost(conn, first, [...others, second])
+ + readabilityCost(second.conn, second, [...others, first]);
+ for (const firstLane of lanes(firstGeometry)) {
+ for (const secondLane of lanes(secondGeometry)) {
+ planningMetrics.reciprocalCandidateCount += 1;
+ const firstRoute = { conn, ...direct(firstGeometry, firstLane) };
+ const secondRoute = { conn: second.conn, ...direct(secondGeometry, secondLane) };
+ const candidates = [firstRoute, secondRoute];
+ if (!candidates.every((entry) => entry.points.every(withinScene))) continue;
+ if (!endpointSlotsClear(candidates)) continue;
+ if (!candidates.every((entry, index) => {
+ const geometry = entry.conn === conn ? firstGeometry : secondGeometry;
+ if (!portHasCornerClearance(geometry.from, geometry.fromSide, entry.points[0])
+ || !portHasCornerClearance(geometry.to, geometry.toSide, entry.points.at(-1))) return false;
+ return routeIsClear(entry.conn, entry, geometry, [...others, candidates[1 - index]]);
+ })) continue;
+ const firstRect = labelRectFor?.(conn, firstRoute.points, {
+ routes: [...others.map((entry) => entry.points), ...candidates.map((entry) => entry.points)],
+ labels: reservedLabels.map((entry) => entry.rect),
+ });
+ if (!labelClears(firstRect, conn, [...others, secondRoute], reservedLabels)) continue;
+ const secondRect = labelRectFor?.(second.conn, secondRoute.points, {
+ routes: [...others.map((entry) => entry.points), ...candidates.map((entry) => entry.points)],
+ labels: [...reservedLabels.map((entry) => entry.rect), ...(firstRect ? [firstRect] : [])],
+ });
+ if (!labelClears(secondRect, second.conn, [...others, firstRoute], [
+ ...reservedLabels, ...(firstRect ? [{ conn, rect: firstRect }] : []),
+ ])) continue;
+ const cost = readabilityCost(conn, firstRoute, [...others, secondRoute])
+ + readabilityCost(second.conn, secondRoute, [...others, firstRoute]);
+ if (cost < bestCost) {
+ best = { firstRoute, secondRoute, firstRect, secondRect };
+ bestCost = cost;
+ }
+ }
+ }
+ if (!best) continue;
+ cachePath(conn, best.firstRoute, firstSides);
+ cachePath(second.conn, best.secondRoute, secondSides);
+ first.points = best.firstRoute.points;
+ second.points = best.secondRoute.points;
+ planningMetrics.reciprocalImprovedCount += 1;
+ jointlyImproved.add(conn);
+ jointlyImproved.add(second.conn);
+ improved = true;
+ reservedLabels = [
+ ...reservedLabels,
+ ...(best.firstRect ? [{ conn, rect: best.firstRect }] : []),
+ ...(best.secondRect ? [{ conn: second.conn, rect: best.secondRect }] : []),
+ ];
+ } finally {
+ if (!improved) reservedLabels = previousLabels;
+ }
+ }
+ }
allowGridSearch = false;
try {
+ improveReciprocalPairs();
for (const entry of resolvedRoutes) {
const { conn } = entry;
- if (hasAuthoredRouteGeometry(conn) || conn.labelAt) continue;
+ if (jointlyImproved.has(conn) || hasAuthoredRouteGeometry(conn) || conn.labelAt) continue;
const others = resolvedRoutes.filter((other) => other !== entry);
// Preserve uncomplicated routes and their established inferred sides.
// Spend the comparison budget where the complete scene has a reading
diff --git a/archify/test/adaptive-reader-layout.test.mjs b/archify/test/adaptive-reader-layout.test.mjs
index ef740415..f398c807 100644
--- a/archify/test/adaptive-reader-layout.test.mjs
+++ b/archify/test/adaptive-reader-layout.test.mjs
@@ -127,10 +127,14 @@ test('reader remeasures real content and reduces width before allowing desktop p
assert.match(reader, /new MutationObserver\(schedule\)/);
assert.match(reader, /document\.documentElement\.scrollHeight/);
assert.match(reader, /lastWidth - overflow \* ratio - 4/);
- assert.match(skill, /1440×900, 1600×1000, 1920×1080, and 2048×1320/);
- assert.match(skill, /Reader-declared vertical page scroll/);
- assert.match(skill, /Generate one responsive artifact for laptops and external displays/);
- assert.match(skill, /preserv(?:e|ing) the authored SVG\/viewBox, proportions, semantic geometry/);
+ assert.match(skill, /Automated browser evidence\]\(delivery-contract\.md#automated-browser-evidence\)/);
+ assert.match(skill, /intrinsic-height page scroll/);
+ const delivery = fs.readFileSync(path.join(skillRoot, 'references/delivery-contract.md'), 'utf8');
+ const authoring = fs.readFileSync(path.join(skillRoot, 'references/authoring-contract.md'), 'utf8');
+ assert.match(delivery, /1440×900, 1600×1000, 1920×1080, and\s+2048×1320/);
+ assert.match(delivery, /Reader-declared readable exception/);
+ assert.match(authoring, /Generate one responsive artifact for laptops and external displays/);
+ assert.match(authoring, /preserv(?:e|ing) the authored SVG\/viewBox, proportions, semantic geometry/);
});
test('reader exposes an explicit stable-dimensions contract for browser evidence', () => {
diff --git a/archify/test/authoring-safety-contract.test.mjs b/archify/test/authoring-safety-contract.test.mjs
index 893f3e93..b0112e18 100644
--- a/archify/test/authoring-safety-contract.test.mjs
+++ b/archify/test/authoring-safety-contract.test.mjs
@@ -15,7 +15,12 @@ const authoringContract = fs.readFileSync(
const schemaReadme = fs.readFileSync(path.join(skillRoot, 'schemas', 'README.md'), 'utf8');
test('semantic relationship labels are preserved and deletion is not a geometry repair', () => {
- for (const [name, source] of [['authoring defaults', authoringDefaults], ['authoring contract', authoringContract]]) {
+ assert.match(authoringDefaults, /Relationship labels carry meaning/);
+ assert.match(authoringDefaults, /preserve action, protocol, direction, async behavior, or cross-boundary meaning/);
+ assert.match(authoringDefaults, /both endpoints already fully imply it/);
+ assert.match(authoringDefaults, /Label repair\]\(authoring-contract\.md#label-repair\)/);
+ assert.match(authoringContract, /## Label repair/);
+ for (const [name, source] of [['authoring contract', authoringContract]]) {
assert.match(source, /Relationship labels are semantic data/i, name);
assert.match(source, /move the label[\s\S]*adjust the route or spacing[\s\S]*shorten/i, name);
assert.match(source, /protocol[\s\S]*action[\s\S]*direction[\s\S]*synchronous[\s\S]*asynchronous[\s\S]*cross-boundary mechanism/i, name);
@@ -32,10 +37,11 @@ test('schema policy documents the workflow v1/v2 compatibility boundary', () =>
});
test('deployment ownership stays explicit, fact-backed, and cannot be removed to pass', () => {
- assert.match(authoringDefaults, /Omit `meta\.engineering_profile` by default/);
- assert.match(authoringDefaults, /Region.*cluster.*security boundar.*do not.*enable/i);
- assert.match(authoringDefaults, /production deployment topology.*ownership.*fail-closed deployment review/i);
- assert.match(authoringDefaults, /must not remove.*engineering profile.*pass validation/i);
+ assert.match(authoringDefaults, /`meta\.engineering_profile` for an ordinary system overview/);
+ assert.match(authoringDefaults, /engineering profile\]\(authoring-contract\.md#engineering-profile-default\)/);
+ assert.match(authoringContract, /Region,[\s\S]*cluster,[\s\S]*security boundary[\s\S]*do not[\s\S]*engineering profile/i);
+ assert.match(authoringContract, /production deployment topology, ownership handoff, or\s+fail-closed deployment review/i);
+ assert.match(authoringContract, /do not remove the engineering profile merely to pass validation/i);
});
test('visual-check stays a pending sidecar receipt instead of a polish claim', () => {
@@ -43,10 +49,10 @@ test('visual-check stays a pending sidecar receipt instead of a polish claim', (
path.join(skillRoot, 'references', 'delivery-contract.md'),
'utf8',
);
- assert.match(skill, /Run `node bin\/archify\.mjs visual-check <output\.html> --summary --require-provenance`/);
- assert.match(skill, /machine-readable browser evidence[\s\S]*perceptual review/i);
+ assert.match(skill, /Optional capture evidence\]\(references\/delivery-contract\.md#optional-capture-evidence\)/);
+ assert.match(skill, /Inspect captures before claiming visual quality; otherwise report automated checks only/);
assert.match(skill, /references\/delivery-contract\.md/);
- assert.match(skill, /without (?:rerendering or )?modifying/i);
+ assert.match(deliveryContract, /Both browser commands inspect the exact delivered HTML without modifying or rerendering it/);
assert.match(deliveryContract, /visual-check <output\.html> --summary/);
assert.match(deliveryContract, /1440×900[\s\S]*1600×1000[\s\S]*1920×1080[\s\S]*2048×1320/);
diff --git a/archify/test/automatic-port-spread.test.mjs b/archify/test/automatic-port-spread.test.mjs
index 3c782c71..e4b20ba6 100644
--- a/archify/test/automatic-port-spread.test.mjs
+++ b/archify/test/automatic-port-spread.test.mjs
@@ -35,6 +35,12 @@ function connectionPoints(html, id) {
return match[1].split(';').map((point) => point.split(',').map(Number));
}
+function connectionLabelPoint(html, id) {
+ const match = html.match(new RegExp(`data-detail="context"[^>]+data-edge-id="${id}"[^>]*>\\s*<rect[^>]*>\\s*<text x="([^"]+)" y="([^"]+)"`));
+ assert.ok(match, `missing rendered connection label ${id}`);
+ return [Number(match[1]), Number(match[2])];
+}
+
function fanOutArchitecture(connections) {
return {
schema_version: 1,
@@ -50,6 +56,99 @@ function fanOutArchitecture(connections) {
};
}
+function reciprocalArchitecture(connections, transpose = false) {
+ const position = ([x, y]) => transpose ? [y, x] : [x, y];
+ const size = ([width, height]) => transpose ? [height, width] : [width, height];
+ return {
+ schema_version: 1,
+ diagram_type: 'architecture',
+ meta: { title: 'Reciprocal automatic channels' },
+ components: [
+ { id: 'sender', type: 'backend', label: 'Sender', pos: position([125, 250]), size: size([192, 76]) },
+ { id: 'receiver', type: 'backend', label: 'Receiver', pos: position([445, 250]), size: size([182, 76]) },
+ { id: 'store', type: 'database', label: 'Store', pos: position([445, 435]), size: size([182, 76]) },
+ ],
+ connections,
+ };
+}
+
+test('architecture: reciprocal automatic relationships with a third inferred port use separate straight channels', () => {
+ for (const transpose of [false, true]) {
+ const connections = [
+ { id: 'send', from: 'sender', to: 'receiver', ...(!transpose ? { label: 'request' } : {}) },
+ { id: 'reply', from: 'receiver', to: 'sender', ...(!transpose ? { label: 'response' } : {}) },
+ { id: 'persist', from: 'sender', to: 'store', ...(!transpose ? { label: 'persist' } : {}) },
+ ];
+ for (const ordered of [connections, [...connections].reverse()]) {
+ const html = render('architecture', reciprocalArchitecture(ordered, transpose));
+ const send = connectionPoints(html, 'send');
+ const reply = connectionPoints(html, 'reply');
+ const persist = connectionPoints(html, 'persist');
+ assert.equal(send.length, 2, JSON.stringify({ transpose, send, reply }));
+ assert.equal(reply.length, 2, JSON.stringify({ transpose, send, reply }));
+ const axis = transpose ? 0 : 1;
+ assert.equal(send[0][axis], send[1][axis]);
+ assert.equal(reply[0][axis], reply[1][axis]);
+ assert.notEqual(send[0][axis], reply[0][axis]);
+ assert.notDeepEqual(send[0], reply[1]);
+ assert.notDeepEqual(send[1], reply[0]);
+ const travel = transpose ? 1 : 0;
+ assert.ok(send[0][travel] < send[1][travel], 'forward arrow still points to receiver');
+ assert.ok(reply[0][travel] > reply[1][travel], 'reverse arrow still points to sender');
+ assert.notDeepEqual(persist[0], send[0]);
+ assert.notDeepEqual(persist[0], reply.at(-1));
+ if (persist[0][travel] === send[0][travel]) {
+ assert.ok(Math.abs(persist[0][axis] - send[0][axis]) >= 14);
+ assert.ok(Math.abs(persist[0][axis] - reply.at(-1)[axis]) >= 14);
+ }
+ }
+ }
+});
+
+test('architecture: reciprocal repair preserves an authored side and via geometry', () => {
+ const connections = [
+ { id: 'send', from: 'sender', to: 'receiver', fromSide: 'right', toSide: 'left' },
+ { id: 'reply', from: 'receiver', to: 'sender', via: [[400, 230], [355, 230]] },
+ { id: 'persist', from: 'sender', to: 'store' },
+ ];
+ const html = render('architecture', reciprocalArchitecture(connections));
+ const send = connectionPoints(html, 'send');
+ const reply = connectionPoints(html, 'reply');
+ assert.deepEqual(send[0][0], 317);
+ assert.deepEqual(send.at(-1)[0], 445);
+ assert.deepEqual(reply.slice(1, -1), [[400, 230], [355, 230]]);
+
+ const preset = render('architecture', reciprocalArchitecture([
+ { id: 'send', from: 'sender', to: 'receiver' },
+ { id: 'reply', from: 'receiver', to: 'sender', route: 'orthogonal-h' },
+ { id: 'persist', from: 'sender', to: 'store' },
+ ]));
+ const presetReply = connectionPoints(preset, 'reply');
+ assert.ok(presetReply.length > 2, 'authored route preset keeps its bend');
+ assert.deepEqual(presetReply[1], [381, 288]);
+});
+
+test('architecture: reciprocal repair preserves explicit relationship label placement controls', () => {
+ for (const placement of [
+ { labelSegment: 1, labelDy: -30 },
+ { labelDx: 0 },
+ { labelDy: 0 },
+ ]) {
+ const connections = [
+ { id: 'send', from: 'sender', to: 'receiver', label: 'request', ...placement },
+ { id: 'reply', from: 'receiver', to: 'sender', label: 'response' },
+ { id: 'persist', from: 'sender', to: 'store', label: 'persist' },
+ ];
+ const html = render('architecture', reciprocalArchitecture(connections));
+ assert.ok(connectionPoints(html, 'send').length > 2,
+ `explicit ${JSON.stringify(placement)} keeps its authored label segment meaningful`);
+ if (placement.labelSegment !== undefined) {
+ assert.deepEqual(connectionLabelPoint(html, 'send'), [341, 259.5],
+ 'labelSegment: 1 remains on the second segment with the authored vertical offset');
+ }
+ }
+});
+
test('architecture: automatic fan-out uses distinct symmetric ports with corner clearance', () => {
const html = render('architecture', fanOutArchitecture([
{ id: 'to-upper', from: 'hub', to: 'upper' },
@@ -360,14 +459,14 @@ test('lifecycle: same-band port spread remains orthogonal', () => {
]);
});
-test('skill and READMEs describe automatic port spread as bounded default behavior', () => {
- const skill = fs.readFileSync(path.join(skillRoot, 'references/authoring-defaults.md'), 'utf8');
- assert.match(skill, /Automatic Port Spread is a default renderer behavior/);
- assert.match(skill, /single relationship|single relationships/);
- assert.match(skill, /explicit `via`.*`channelX`.*`channelY`.*`labelAt`/);
- assert.match(skill, /facing automatic ports \(`left`\/`right` or `top`\/`bottom`\).*one shared axis/);
-
+test('authoring defaults point to the bounded automatic port rules and READMEs describe the default', () => {
+ const defaults = fs.readFileSync(path.join(skillRoot, 'references/authoring-defaults.md'), 'utf8');
+ assert.match(defaults, /Start with automatic routes and endpoint sides/);
+ assert.match(defaults, /Geometry reference.*measured spacing, port, canvas, and route rules/);
const authoringContract = fs.readFileSync(path.join(skillRoot, 'references/authoring-contract.md'), 'utf8');
+ assert.match(authoringContract, /Automatic Port Spread is a default renderer behavior/);
+ assert.match(authoringContract, /single relationships/);
+ assert.match(authoringContract, /explicit `via`, `channelX`, `channelY`, `labelAt`/);
assert.match(authoringContract, /unobstructed facing ports.*may share one horizontal or vertical axis/);
const repoRoot = path.resolve(skillRoot, '..');
diff --git a/archify/test/delivery-contract.test.mjs b/archify/test/delivery-contract.test.mjs
index a6c5c443..cfbad3bc 100644
--- a/archify/test/delivery-contract.test.mjs
+++ b/archify/test/delivery-contract.test.mjs
@@ -61,7 +61,9 @@ test('required browser evidence stays deterministic and capture-free', () => {
});
test('delivery, browser evidence, capture evidence, and perceptual review remain distinct', () => {
- for (const [name, source] of [['SKILL.md', skill], ['delivery contract', delivery]]) {
+ assert.match(skill, /artifact checks, browser evidence, captures, and actual perceptual review as distinct results/);
+ assert.match(skill, /Delivery contract\]\(references\/delivery-contract\.md\)/);
+ for (const [name, source] of [['delivery contract', delivery]]) {
assert.match(source, /deliver[\s\S]*deterministic/i, name);
assert.match(source, /browser-check[\s\S]*browser evidence/i, name);
assert.match(source, /visual-check[\s\S]*capture|screenshots/i, name);
@@ -74,14 +76,14 @@ test('delivery, browser evidence, capture evidence, and perceptual review remain
test('strict provenance succeeds before either browser command', () => {
const ordering = delivery.match(/Run strict `check` after `deliver` exits zero\.[\s\S]*?collecting new browser evidence\./)?.[0] ?? '';
assert.match(ordering, /Run `browser-check` or optional\s+`visual-check` only after that strict check exits zero/i);
- assert.match(skill, /required order stays `deliver` → strict provenance `check` → `browser-check`/);
- assert.match(skill, /Run `visual-check` only against a strict-provenance artifact/);
+ assert.match(skill, /Recovery follows `deliver` → strict provenance `check` → `browser-check`/);
+ assert.match(skill, /captures require strict provenance/);
});
test('perceptual review is optional for fresh architectures and available for visual diagnosis', () => {
assert.match(perceptualReviewSection, /visual_review: not_requested/);
assert.match(perceptualReviewSection, /Ordinary generation does not require screenshots/);
- assert.match(skill, /Perceptual review is optional in ordinary generation/);
+ assert.match(skill, /Perceptual review is optional for ordinary generation/);
assert.match(perceptualReviewSection, /user explicitly requests an aesthetic or visual review/i);
assert.match(perceptualReviewSection, /template, renderer, or Viewer change/i);
assert.match(perceptualReviewSection, /novel layout or browser diagnostic leaves low confidence/i);
@@ -89,7 +91,8 @@ test('perceptual review is optional for fresh architectures and available for vi
assert.match(perceptualReviewSection, /run `visual-check`[\s\S]*contact sheet/i);
assert.match(perceptualReviewSection, /never exceed two focused correction rounds/i);
assert.match(perceptualReviewSection, /Never report\s+`visual_review: passed` without inspecting/i);
- assert.match(skill, /If perceptual review is unavailable, report that quality remains unverified/i);
+ assert.match(skill, /Inspect captures before claiming visual quality; otherwise report automated checks only/);
+ assert.match(perceptualReviewSection, /visual_review: skipped \(image reader unavailable\)[\s\S]*requested or triggered review could not run/i);
assert.match(perceptualReviewSection, /visualReviewRecommendation/);
assert.match(delivery, /Open the HTML contact sheet in a browser or inspect the viewport PNGs/i);
});
diff --git a/archify/test/ordinary-model-floor.test.mjs b/archify/test/ordinary-model-floor.test.mjs
index a4325df6..d0b2492e 100644
--- a/archify/test/ordinary-model-floor.test.mjs
+++ b/archify/test/ordinary-model-floor.test.mjs
@@ -894,68 +894,49 @@ test('benchmark documentation locks the fair-run and truthful-evidence contract'
}
});
-test('packaged skill puts a bounded ordinary-model path before progressive feature references', () => {
- const skill = fs.readFileSync(path.join(skillRoot, 'SKILL.md'), 'utf8');
- const authoringDefaults = fs.readFileSync(path.join(skillRoot, 'references', 'authoring-defaults.md'), 'utf8');
- const authoring = fs.readFileSync(path.join(skillRoot, 'references', 'authoring-contract.md'), 'utf8');
- const viewer = fs.readFileSync(path.join(skillRoot, 'references', 'viewer-runtime.md'), 'utf8');
+test('packaged skill keeps first-draft rules inline and repair contracts behind reachable triggers', () => {
+ const read = (file) => fs.readFileSync(path.join(skillRoot, file), 'utf8');
+ const skill = read('SKILL.md');
+ const defaults = read('references/authoring-defaults.md');
+ const authoring = read('references/authoring-contract.md');
+ const delivery = read('references/delivery-contract.md');
+ const repository = read('references/repository-authoring.md');
+ const fastPath = skill.slice(skill.indexOf('## Fast authoring path'), skill.indexOf('## Update awareness'));
assert.match(skill, /## Existing candidate handoff[\s\S]*run `finalize` first as one CLI invocation/);
- assert.match(skill, /After editing, omit any earlier `--candidate-sha256`/);
- const fastPath = skill.indexOf('## Fast authoring path');
- // A diagnosed repair may link to a reference inside the fast path. Bound
- // the contract by its next section, not by the first inline link.
- const fastPathEnd = skill.indexOf('## Type router', fastPath);
-
- assert.ok(fastPath > 0, 'fast authoring path must exist');
- assert.ok(fastPathEnd > fastPath, 'fast authoring path must precede the type router');
- assert.ok(skill.trimEnd().split('\n').length <= 160, 'ordinary authors must not ingest the viewer catalogue');
- for (const required of [
- 'exact paths in the Type router',
- 'do not list `schemas/` or `examples/` first',
- 'once requested scope and source evidence are covered, write the candidate directly',
- 'do not plan coordinates in prose',
- 'Fresh authorship means new IDs, domain wording, and layout',
- 'Start with automatic routes',
- 'let them align main-path endpoints',
- 'Pin an endpoint side only for a necessary branch/return constraint or user-supplied geometry',
- 'Do not guess `via`, `channelX`, `channelY`, or label coordinates before measured geometry',
- 'Set `meta.quality_profile` to `"showcase"`',
- 'Once the complete first candidate is written, run `finalize` directly',
- 'Keep the candidate unchanged while the command runs',
- 'A passing validation returns `candidateFrozen: true`',
- 'A receipt with only 4 artifact checks is basic validation',
- 'require all 9 checks with 0 composition errors and 0 warnings',
- 'Fix `meta.quality_profile` before geometry',
- 'finalize <type> <candidate.json> <output.html> --quality showcase --json',
- 'successful first drafts need no separate pre-validation',
- 'Do not read its full sidecar or rerun individual commands afterward',
- 'A non-zero exit is never success',
- 'Do not read `bin/` implementation',
- 'reposition those nodes and their neighbors together',
- 'After the edit, rerun the complete `finalize` command from step 4 once',
- ]) {
- assert.match(
- skill.slice(fastPath, fastPathEnd),
- new RegExp(required.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i'),
- );
- }
- assert.doesNotMatch(skill.slice(fastPath, fastPathEnd), /Then run exactly one `validate/);
- assert.match(skill.slice(fastPath, fastPathEnd), /references\/authoring-defaults\.md/);
- assert.match(skill, /default to a system overview/i);
- assert.match(skill, /Never use node, relationship, source-reference, view, card, or boundary counts as an authoring target/i);
- assert.match(authoringDefaults, /Let the requested question and source facts determine node and relationship counts/i);
- assert.match(authoringDefaults, /never target a total reference count/i);
- for (const instructions of [skill, authoringDefaults]) {
- assert.doesNotMatch(
- instructions,
- /(?:at most|no more than|maximum of|cap(?:ped)? at|limit(?:ed)? to)\s+\d+\s+(?:nodes?|components?|relationships?)/i,
- 'authoring instructions must not impose a fixed topology quota',
- );
+ assert.match(fastPath, /exact schema and example paths in the Type router without listing their directories/);
+ assert.match(fastPath, /references\/authoring-defaults\.md/);
+ assert.match(fastPath, /bounded batch separate from project documents and complete schemas/);
+ assert.match(fastPath, /recover any missing section before writing/);
+ assert.match(fastPath, /write the complete candidate directly without planning coordinates in prose/);
+ assert.match(fastPath, /Set `meta\.quality_profile` to `"showcase"`/);
+ assert.match(fastPath, /successful first drafts need no separate pre-validation/);
+ assert.match(fastPath, /Keep the candidate unchanged while the command runs/);
+ assert.match(fastPath, /finalize <type> <candidate\.json> <output\.html> --repo-root <repo-root> --quality showcase --json/);
+ assert.match(fastPath, /standalone commands only for a separate request or focused failure diagnosis/);
+ assert.match(fastPath, /A non-zero exit is never success/);
+ assert.match(fastPath, /references\/delivery-contract\.md#failed-finalize-and-candidate-repair/);
+ const repair = delivery.match(/## Failed finalize and candidate repair[\s\S]*?(?=\n## |$)/)?.[0] ?? '';
+ assert.match(repair, /candidateFrozen: true/);
+ assert.match(repair, /--candidate-sha256/);
+ assert.match(repair, /fresh `--out-dir/);
+ assert.match(repair, /all nine checks, zero composition errors, and zero warnings/);
+ assert.match(repair, /two focused repairs[\s\S]*one evidence-based retry/);
+ assert.match(defaults, /default to a system overview/);
+ assert.match(defaults, /There is no node, edge, source, view, card, or boundary quota/);
+ assert.match(defaults, /Start with automatic routes and endpoint sides/);
+ assert.match(defaults, /Pin a side only for a necessary branch, return, or supplied geometry/);
+ assert.match(defaults, /Before writing positions[\s\S]*6\.5px × ASCII units \+ 21px/);
+ assert.match(defaults, /9px[\s\S]*5\.4px × text units \+ 8px/);
+ assert.match(defaults, /card alone cannot qualify an otherwise unconditional arrow/);
+ assert.match(repository, /local-only[\s\S]*SSH origin, unsupported forge/);
+ assert.match(repository, /actual write or execution\s+site and the conditions/);
+ for (const instructions of [skill, defaults]) {
+ assert.doesNotMatch(instructions, /(?:at most|no more than|maximum of|cap(?:ped)? at|limit(?:ed)? to)\s+\d+\s+(?:nodes?|components?|relationships?)/i);
}
- assert.match(authoringDefaults, /A recoverable state uses `type: "failure"` plus a real transition back to the active state/);
+ assert.match(defaults, /recoverable failure needs a real transition back/);
assert.match(authoring, /componentType/);
assert.match(authoring, /clear gap between boxes, not center distance/i);
- assert.match(viewer, /Direct Relationship Pin/);
+ assert.match(read('references/viewer-runtime.md'), /Direct Relationship Pin/);
});
test('dated three-model evidence retains every frozen attempt-1 candidate and truthful gate result', () => {
diff --git a/archify/test/sequence-column-fit.test.mjs b/archify/test/sequence-column-fit.test.mjs
index 5a9bbc94..fbfd958d 100644
--- a/archify/test/sequence-column-fit.test.mjs
+++ b/archify/test/sequence-column-fit.test.mjs
@@ -133,7 +133,7 @@ test('the fast authoring path explains when to opt into spread', () => {
assert.match(description, /wide viewBox/);
assert.match(description, /meaningful participant labels/);
- assert.match(skill, /do not shorten semantic labels before trying `spread`/);
+ assert.match(skill, /use `spread` when a wide viewBox leaves unused horizontal space or meaningful labels need width/);
assert.match(rendererReadme, /Use `"spread"` when a wide/);
assert.match(rendererReadme, /try `meta\.column_fit: "spread"` before shortening/);
});
diff --git a/archify/test/skill-metadata.test.mjs b/archify/test/skill-metadata.test.mjs
index b4b8ada0..a241f60c 100644
--- a/archify/test/skill-metadata.test.mjs
+++ b/archify/test/skill-metadata.test.mjs
@@ -63,13 +63,11 @@ test('update awareness is notification-only and never replaces the requested wor
test('language behavior stays within the bounded locale contract', () => {
assert.match(defaults, /one primary authored language/);
- assert.match(defaults, /explicit user choice; otherwise follow the request or conversation's dominant language/);
- assert.match(defaults, /`meta\.locale` controls only renderer-owned Viewer UI/);
- assert.match(defaults, /use `"en"`, `"zh-CN"`, or `"es"`/);
- assert.match(defaults, /For every other language, omit `meta\.locale`/);
- assert.match(defaults, /fixed Viewer UI and `<html lang>` fall back to English/);
- assert.match(defaults, /renderer never translates authored content/i);
- assert.match(defaults, /product names.*code identifiers.*protocols.*API paths.*environment names/);
+ assert.match(defaults, /user's choice or the request\/conversation/);
+ assert.match(defaults, /English \(`en`\), Simplified Chinese \(`zh-CN`\), or Spanish \(`es`\)/);
+ assert.match(defaults, /otherwise omit it and disclose the fixed Viewer UI and `<html lang>` English fallback/);
+ assert.match(defaults, /exact product, code, protocol, command, API, and environment names/);
+ assert.match(defaults, /Language consistency\]\(authoring-contract\.md#language-consistency\)/);
assert.match(authoringContract, /`meta\.locale` controls only renderer-owned reader surfaces/);
assert.match(authoringContract, /outside `en`, `zh-CN`, and `es`/);
assert.match(authoringContract, /artifact is\s+not fully localized/);
@@ -80,7 +78,8 @@ test('language behavior stays within the bounded locale contract', () => {
});
test('skill keeps the title hierarchy compact by default', () => {
- assert.match(defaults, /Omit `meta\.subtitle` by default/);
- assert.match(defaults, /Never invent a subtitle that restates the title, nodes, or cards/);
+ assert.match(defaults, /`meta\.subtitle` for a title-only header/);
+ assert.match(defaults, /Explicit styles and a subtitle require a user request/);
+ assert.match(authoringContract, /never use it to restate the title, nodes, edges,\s+or cards/);
assert.match(authoringContract, /omitted or blank subtitle must not leave an empty visual row/);
});