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.
| Concern | Held as | Code |
|---|---|---|
| A document's kind | An archetype document | micyte/core/archetypes/__init__.py |
| A document's layout | A viewscope, declared by the archetype | micyte/core/datum_ops/viewscope.py, micyte/tools/_viewscope.py |
| An icon | A glyph document | 42 |
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:
- The primitive is not editable. Only
field_pairandtextare. - The field has no address in the sandbox's anchor.
- The anchor declares no babelette (radix) at that address.
- 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.