arch.Architectonic: The Central Registry#

Architectonic is the core of the package: a pydantic model that loads a four-level tree of Cell rows from an architectonic file, maps every Idx to its source language, filesystem path, and database record, and exposes the whole structure through mapping-style access. A single default instance is constructed at import time and exported as ARCH, located via $MY_ARCH or the nearest architectonic file below the current directory.

class arch.Architectonic.Architectonic(*, root, file, size=511, data={}, parameters={}, jinja=None)#

The in-memory architectonic: a mapping of Idx to Cell, plus the machinery around it.

Built from an architectonic.yaml file below a root directory, it layers on the filesystem naming conventions, a static parameter cache, a jinja template environment, the irix color palettes, and an optional async database connection. A default instance is exported as ARCH at import time, located via $MY_ARCH or the current directory.

model_config = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod setup()#

Perform one-time class setup: load the irix palettes and connect the DB if configured.

classmethod connect_db()#

Create the async SQLAlchemy engine from the MY_DB_* environment variables.

async classmethod disconnect_db()#

Dispose of the database engine, if one was created.

classmethod new(root, **kwargs)#

Build an architectonic from a root directory containing an architectonic.yaml file.

create()#

Populate the parameter cache and jinja environment after validation.

serialize()#

Serialize the architectonic as a sorted mapping of index strings to dumped cells.

classmethod load(file, kwargs)#

Read an architectonic file into a dict of cells, prepending the base cell.

get_lang(idx)#

Get the language for a given index.

classmethod setup_irix()#

Read the irix YAML files into nested lists of dark and light colors.

infer_idx(path)#

Infer the index of a path from its architectonic directory parts, if possible.

dir_filter(paths)#

Filter the given paths down to architectonic directories, sorted by name.

file_filter(paths)#

Filter the given paths down to instance files, sorted by path.

read_parameter_cache()#

Read the cached parameter files into a mapping of index to per-class parameters.

keys()#

Return the indices of all cells.

values()#

Return all cells.

items()#

Return all (index, cell) pairs.

idx_iter()#

Yield the indices of all cells.

property langs#

Return the set of languages explicitly assigned to any cell.

get_filename(idx, lang=None)#

Construct the architectonic filename for an index, e.g. _Element.py or _a_Word.md.

get_dirname(idx)#

Construct the architectonic directory name for an index, e.g. _0_elements.

get_dir(idx)#

Construct the absolute directory path for an index below the root.

get_file(idx, lang=None)#

Construct the absolute path of the architectonic file for an index.

db_session()#

Yield an async database session, rolling back on SQLAlchemy errors.

get_template(filename)#

Fetch a jinja template by filename, caching compiled templates globally.

render(filename, data, **kwargs)#

Render the named jinja template with the given data.

get_parameters(idx, name)#

Look up the static parameters for a named class, falling back to ancestors’ files.

index_file(idx)#

Get an index file, preferring this instance’s mirrored constitution data.

classmethod find_arch_file(root)#

Find the architectonic file in a given directory.

classmethod resolve_arch_root(arch_root)#

Resolve the architectonic root, preferring a worktree root when inside one.

When arch_root (typically from $MY_ARCH) points at the primary checkout but the current working directory is inside a linked worktree of the same repository, return the worktree’s root instead. This ensures tests and tooling that spawn subprocesses with cwd=ARCH.root exercise the worktree’s code, not the primary tree’s. Primary-tree runs are unaffected: when cwd is not inside a worktree (or is inside the primary tree itself), the original arch_root is returned unchanged.