MiCyte

← The wiki

41 — Archetypes and viewscopes

BuiltRendered from 41-archetypes-and-viewscopes.md in the public repository. Edits belong there.

An archetype is a document that defines a kind of document; a viewscope is the part of an archetype that says how documents of that kind are drawn. Both are datum documents in the MOS store.

ConcernHeld asCode
A document's kindAn archetype documentmicyte/core/archetypes/__init__.py
A document's layoutA viewscope, declared by the archetypemicyte/core/datum_ops/viewscope.py, micyte/tools/_viewscope.py
An iconA glyph document42

Archetypes

An archetype is a document of the shape it defines, with the values blank. A document matches its archetype when folding both with archetype_shape gives the same shape.

build_registry reads only documents whose metadata has role == "archetype" (held in the archetype sandbox), folds them, and does not consult the registry it is building.

Every document requirement in a package carries the hash of the archetype it names. The hashes are pinned in _archetypes.lock.json (in micyte/tools/), written by scripts/lock_archetypes.py and read by micyte/tools/_archetype_lock.py.

Viewscopes

The workbench draws a document in one of three modes: interpreted and raw (both tables of rows) and the viewscope, which draws the document as what it is (a boundary as geometry, a directory as lines). The archetype names the primitives that draw it.

A viewscope reads the subject document from datum_document_semantics and the archetype library with one read per sandbox. It does not load the catalog. A container refuses to draw more than MAX_RENDERED_ROWS (2,000) rows, or 8,000 for a tree, and states the reason.

Editing through a viewscope

refusal_for(primitive, address, radices) in micyte/core/datum_ops/viewscope_edit.py returns why a slot cannot be written, or an empty string. It checks in this order:

  1. The primitive is not editable. Only field_pair and text are.
  2. The field has no address in the sandbox's anchor.
  3. The anchor declares no babelette (radix) at that address.
  4. The radix is not writable as text. Writable radices are ASCII (2-1-1) and a node of the sandbox's own local domain (2-0-5). Any other radix is refused with its meaning, for example a HOPS coordinate run (2-0-1).

The radix of a field is read from the sandbox's own anchor (rows under 3-1-), never from a constant, because two sandboxes can number the same field differently.