Arcology Engine

Arroyo Literate Programming Environment

Contents

Arroyo is a Literate Programming system that sits on top of org-mode to make it easy for cross-file development of complex software. It is the pattern that is expressed in this arcology2go project, the prior arcology-django project and the Complete Computing Project. In general, it uses regular, bog standard org-babel, but it also expands upon it with blocks that are programmable on export.

The programmable blocks can be used, for example, to extract data values from org-mode tables and embed them as configuration. An HTML web view of the file presented by the Arcology web stack would show the configuration values as human legible tables, and the org-babel tooling will extract those in to the source code.

The programmable blocks can also be used to query the Roam Data Models to, for example, automatically generate import manifests for the software so that a single system can be spread across multiple per-feature org-mode files without a user needing to update the central registry.

It should be as simple as downloading a document or cloning a git repo, then clicking a button to give your computer cluster new powers. The document should not only declare how to install the software, but they could explain how to use it, present a table of keybindings and configurations, links and resources, all acting as the source of truth.

INPROGRESS Usage

→ Rebuild of the Complete Computer 0x02.22: This is (Not) Advanced

  • arroyo-system README.org file

  • mark locations where usernames etc need to be defined. consider making that programmable or informed by SOPs!

  • record screencast

Work Plan

The work is organized in to seven sprints. The priority is CCE migration: making the existing Complete Computing Environment work with the new Kotlin-based tooling before building outward-facing bootstrapping workflows. The tooling assumes an ~/org/ directory, indexed and cross-referenced by the roam-indexer.

DONE Sprint 1: Arroyo DB Schema + CLI Query Tool

The indexer captures ARROYO_* file properties into SQLDelight tables. A CLI exposes queries directly to stdout — no internal API needed yet, just callable from terminal or Emacs.

  • SQLDelight schema: unified arroyo_keywords table (PK file, kw, value, node_id?) with arroyo_generator_roles for role registry and node_ancestors closure table for property inheritance. Role inclusion/exclusion computed at query time via self-joins against arroyo_keywords and node_ancestors — no per-module-type tables, no junction tables.

  • IndexerPlugin interface extracted to roam/models.org — each domain (arroyo, quiz, tasks) provides its own plugin

  • ArroyoIndexerPlugin extracted to arroyo/generators.org — single-phase: collect all ARROYO_* keywords from file properties, heading properties, and keyword lines; dispatch roles to arroyo_generator_roles, everything else to arroyo_keywords; populate node_ancestors closure table for heading inheritance

  • Role semantics: no ARROYO_SYSTEM_ROLE → applies to ALL roles; explicit roles → only those roles; ARROYO_SYSTEM_EXCLUDE → filtered out at query time. Roles inherit through node_ancestors — file-level roles apply to all headings; heading-scoped roles apply to that heading and children.

  • Multi-valued keywords (e.g. ARROYO_SYSTEM_ROLE: edge server) are split on whitespace and stored as separate rows

  • ARROYO_MODULE_WANTED support — inverse of ARROYO_MODULE_WANTS, stored alongside snippets; wants values are heading IDs resolved directly

  • CLI subcommands that query the DB and print results:

    • arcology nixos-modules --role server → sorted import list to stdout

    • arcology home-modules --role endpoint → sorted import list

    • arcology emacs-snippets → topologically ordered file paths

    • arcology emacs-epkgs → Nix override blocks

    • arcology keywords ARROYO_TANGLE_THIS → file list

  • Tests against real CCE org files as fixtures

Results

Indexed 237 files from ~/org/cce/. All Arroyo tables populated:

Table Rows Description
arroyo_keywords 299 Unified store for all ARROYO_* values (NIXOS_MODULE, HOME_MODULE, EMACS_MODULE, HOME_EPKGS, TANGLE_THIS, SYSTEM_EXCLUDE, MODULE_WANTS, INPUT, OUTPUT, SYSTEM_OVERLAY, etc.) with optional node_id for heading-scoped keywords
arroyo_generator_roles 149 System role assignments (endpoint, server, settop, edge, droid) with optional node_id for heading-scoped roles
node_ancestors — Closure table mapping each heading node to all ancestor headings for property inheritance

Dependency resolution: 198 snippets have ARROYO_MODULE_WANTS, 13 have ARROYO_MODULE_WANTED. The emacs-snippets CLI topologically sorts by querying arroyo_keywords for =ARROYO_MODULE_WANTS=/=ARROYO_MODULE_WANTED= entries, resolving heading-ID wants to module names via nodeIdToModule maps, and adding reverse edges from wanted.

Four extraction paths cover all CCE formats:

  1. Preamble :PROPERTIES: drawer entries → fileProperties → denormalized tables

  2. Preamble =#+ARROYO_= keyword lines → regex scan of raw content 3. Heading-level =#+ARROYO_= keyword lines → recursive section body scan

  3. Heading-level :PROPERTIES: drawer entries → nodeProperties → denormalized tables

Files created

  • arroyo/generators.org — noweb-decomposed: schema, repository, plugin, topological sort, CLI commands, tests

  • arroyo/arroyo.org — work plan, sprint tracking, design decisions

Files modified

  • roam/models.org — IndexerPlugin interface

  • roam/parser.org — implemented extractFileProperties() (was empty stub)

  • roam/indexer.org — removed arroyoRepository param, inline task/flashcard extraction; replaced with plugin invocation loop

  • roam/indexer-platform.org — wired ArroyoIndexerPlugin, QuizIndexerPlugin in factory

  • roam/cli.org — registered 5 new subcommands

  • quiz/flashcard.org — added QuizIndexerPlugin

  • arroyo/generators.org — fixed allKeywords to include nodeProperties; fixed ARROYO_EMACS_MODULE handler to search allKeywords instead of fileProperties; added file-path-to-module-name resolution for =wants=/=wanted=; added wanted reverse edges to topological sort; added tests for keyword-line format and wanted reverse edges

DONE Sprint 2: Table Integration + Parameterized Noweb

Org-mode tables are already parsed by orgmode-kmp (OrgChunk.OrgTable with header, subtables, formula line). The work is in the tangle layer: extracting tables as structured data, binding them to source blocks via :var, and supporting parameterized <<ref(arg)>> noweb calls.

  • Table extraction: convert OrgTable to List<List<String>> using plainText() on each cell to strip org link syntax

  • =:var tbl=tableName= parsing: headerArgs["var"] already stored by the parser; split on = to extract (varName, tableName). tableName resolves to a #+name: block of type OrgTable.

  • <<ref(arg)>> parameterized noweb: extend OrgTangle.resolveNoweb regex from <<([^>]+)>> to <<([^(>]+)(\(([^)]*)\))?>>. When a ref has an argument, pass the arg name through to the generator block's :var scope for execution of the code instead of for raw embedding.

  • `:results raw` convention: blocks with :results raw (the existing CCE convention) have their evaluated output embedded verbatim at the <<ref>> call site, not wrapped in delimiter comments. This is used to output org-mode syntax for tables of content, etc.

  • Unit tests against real CCE table formats (rix-pkgs, wrapWine-pkgs, python-pkgs tables in arroyo-nix.org)

Results

Three changes in arroyo/core.org and six new tests shipped:

  • TangleModels — added UnresolvedTableRef(tableName, inBlockName) warning type for parameterized noweb arg validation

  • OrgParseUtils — added NamedTable data class (name + rows), collectNamedTables() (walks the document tree alongside collectNamedBlocks, collecting named OrgTable chunks), OrgTable.toNestedList() (flattens header + subtables rows into List<List<String>> via plainText() cell stripping), and parseVarHeaderArg() (splits =:var tbl=tableName= into varName/tableName)

  • OrgTangle — collects tableBlocks and varBindings maps during tangle(); resolveNoweb regex extended from <<([^>]+)>> to <<([^(>]+)(?:\\(([^)]*)\\))?>> capturing optional arguments; unresolved table args emit UnresolvedTableRef warning but block body still expanded; plain <<ref>> (no args) still resolves correctly

  • TangleCommand — added UnresolvedTableRef case to the warning handler

  • Six new tests: named table collection, unnamed table skip, <<gen-overlay(rix-pkgs)>> parameterized noweb, unresolved table warning, org-link stripping via plainText(), and backward-compatible plain <<ref>> resolution

Deferred to Sprint 3: :results raw output behavior (only meaningful once block evaluation exists), tableFor() on the Arroyo host object (needs eval context), and actually passing :var data into generator blocks (plumbing exists, eval engine doesn't).

Files modified

  • arroyo/core.org — updated tangle-models, org-parse-utils, org-tangle, and tangle-command source blocks

  • arroyo/tests.org — added six Sprint 2 tests to tangle-test source block

DONE Sprint 3: Generator Evaluation #+begin_src lua :eval arroyo

Generator blocks use #+begin_src lua :eval arroyo with an Arroyo host object implicitly in scope. Scripts are evaluated by LuaJ (org.luaj:luaj-jse:3.0.1) — a single JAR, works on Android, zero compiler embedding. The :eval arroyo header arg signals to the tangle engine that this block is evaluated rather than extracted.

  • The arroyo Lua table exposes (see Sprint 6 Results for the full 18-function list):

    • arroyo.nixos_modules(role: String? nil): table= — sorted NixOS module imports from the DB

    • arroyo.home_modules(role: String? nil): table= — sorted Home Manager module imports

    • arroyo.emacs_snippets(): table — topologically ordered Emacs module files

    • arroyo.epkg_overrides(): table — Nix override blocks from ARROYO_HOME_EPKGS

    • arroyo.system_overlays(role: String? nil): table= — file contents of ARROYO_SYSTEM_OVERLAY entries

    • arroyo.inputs(role: String? nil): table= — file contents of ARROYO_INPUT entries

    • arroyo.outputs(): table — file contents of ARROYO_OUTPUT entries

    • arroyo.emacs_init(): string — concatenated Emacs module .el files in topological order

  • =:var tbl=tableName= bindings are converted from List<List<String>> to 1-indexed Lua nested tables and set as globals before execution

  • <<ref(arg)>> parameterized noweb passes the arg table data to the eval block, overriding the default :var binding

  • Block output (:results raw) is captured and embedded at the <<ref>> call site without delimiter wrapping

  • :results raw on a non-eval block also skips delimiter wrapping

  • Error handling: eval errors per block emit EvalError warnings (one broken generator doesn't halt the pipeline)

  • Missing eval context (no --db flag) emits MissingEvalContext warning and uses raw body

  • :tangle ~/path paths now expand tilde to $HOME

  • make tangle-stable accepts DB parameter for eval context: make tangle-stable ORG... DB=arcology.db=

Results

Pivoted from JSR-223/Kotlin scripting to LuaJ — single JAR, works on Android, zero compiler embedding. The architecture is split cleanly: ArroyoTangleContext interface in commonMain, LuaJ implementation (ArroyoScriptHost) in jvmMain.

  • build.gradle.kts + libs.versions.toml — added luaj-jse { module "org.luaj:luaj-jse", version "3.0.1" }= to jvmMain and androidMain deps

  • TangleModels — added EvalError(blockName, message) and MissingEvalContext(blockName, language) warning types

  • ArroyoTangleContext (new, commonMain) — interface exposing nixosModules(), homeModules(), emacsSnippets(), epkgOverrides(), tableFor(), evalBlock()

  • OrgTangle — tangle() accepts optional evalContext; :eval arroyo blocks evaluated via evaluateBlock() in main loop and resolveNoweb() for <<ref(arg)>> references; :results raw skips delimiter wrapping; :var bindings resolved and passed to eval context; parameterized <<ref(arg)>> overrides default :var table; errors caught per-block, emit EvalError warnings, pipeline continues; resolveTanglePath expands ~ in :tangle ~/... paths and handles absolute paths correctly

  • ArroyoScriptHost (new, jvmMain) — LuaJ JsePlatform.standardGlobals(); arroyo.* functions as Lua callbacks; List<List<String>> converted to 1-indexed Lua nested tables; one Globals instance per tangle session

  • TangleCommand — accepts --db flag; constructs ArroyoScriptHost with ArroyoRepositoryImpl when db exists; passes eval context to OrgTangle.tangle()

  • Makefile — tangle-stable accepts optional DB parameter and passes --repo-root .

  • Seven new tests: eval block with mock context, null context warning, eval error fallback, :var table binding, :results raw no wrapping, parameterized <<ref(arg)>> to eval block, backward-compatible plain <<ref>>

  • context/my_nixos_configuration.org — copy of ~/org/cce/my_nixos_configuration.org with the arroyo_nixos_imports generator ported from elisp to #+begin_src lua :eval arroyo :results raw

Files created

  • arroyo/core.org — ArroyoTangleContext interface source block

  • arroyo/generators.org — ArroyoScriptHost LuaJ source block

  • context/my_nixos_configuration.org — CCE NixOS config with Lua generator

Files modified

  • arroyo/core.org — tangle-models (new warning types), org-tangle (eval support, tilde expansion), tangle-command (--db flag)

  • arroyo/tests.org — tangle-test (7 new eval test methods)

  • Makefile — tangle-stable accepts DB parameter

  • build.gradle.kts, libs.versions.toml — LuaJ dependency

DONE Sprint 4: Convert CCE Generators

Replace the elisp arroyo-generate-imports / arcology-api-generator calls in the CCE org files with #+begin_src kotlin :eval arroyo blocks. Migrate away from #+PROPERTY: header-args file-level propagation — all header args are placed inline on each source block.

  • =arroyo-nix.org='s table-driven package generation (gen-pkg-overlays, gen-python-overlays) — these are the <<ref(arg)>> patterns where tables are passed as arguments

  • =arroyo-emacs.org='s generate_epkg_overrides and arroyo-emacs-init-location

  • =cce.org='s Emacs Module Index, NixOS Module Index, Home Manager Module Index

  • arroyo-nixos.org and arroyo-home-manager.org import generators

  • Normalize ARROYO_MODULE_WANTS whitespace (CCE files have tabs, trailing spaces)

  • All produce the same output the current Python/elisp system generates

  • Tests against real ~/org/cce files to verify output matches legacy system

DONE Sprint 4.5: Cross-file table inclusion

The edgeserver.org file uses :var tbl=nginx-common.org:hosts — a cross-file table reference where a table from another org file is bound to a variable for :eval arroyo blocks. The tangle tool now resolves these references.

  • OrgParseUtils: added TableRef data class + parseTableRef() — splits other.org:tableName into (fileName, tableName) using the last : preceded by a . as the cross-file delimiter

  • OrgTangle.tangle(): added optional fileReader: ((String) -> String?)? = null parameter. A resolveTable closure is built inside tangle() that checks local tableBlocks first, then falls back to parsing the external file via fileReader + OrgLexer + collectNamedTables(). External files are cached in externalTableCache so each file is parsed at most once per session

  • All four internal methods (evaluateBlock(), resolveNoweb(), resolveVarBindingsForEval(), evalBlockForRef()) now accept a resolveTable lambda instead of a Map<String, List<List<String>>>, enabling transparent cross-file resolution everywhere a table ref is used

  • TangleCommand: constructs a fileReader lambda that resolves external org files relative to the current org file's parent directory on disk

  • :var tbl=other.org:tableName refs are validated eagerly — they resolve correctly when the external file exists, and emit UnresolvedTableRef warnings when the file is missing or the table is not found

  • Two new tests: happy path (external table data passes through to eval context) and error path (missing file emits warning)

Results

Two new tests pass: cross-file table references resolve correctly and pass data through to eval contexts; missing files emit the expected warnings. The feature is ready for converting the edgeserver.org generator from Elisp to Lua.

Files modified

  • arroyo/core.org — org-parse-utils (TableRef + parseTableRef()), org-tangle (fileReader param, resolveTable closure, all internal methods switched to lambda), tangle-command (CLI fileReader wiring)

  • arroyo/tests.org — tangle-test (2 new cross-file tests)

DONE Sprint 5: The arroyo flood Command

CLI that orchestrates the full rebuild pipeline: index → tangle with eval.

  • Indexes the org directory to populate ARROYO_* metadata tables

  • Queries ARROYO_TANGLE_THIS keywords, filters by --role if specified

  • --all-modules / -a flag: tangles all files with ARROYO_NIXOS_MODULE, ARROYO_HOME_MODULE, ARROYO_EMACS_MODULE, or ARROYO_TANGLE_THIS (not just TANGLE_THIS)

  • findRepoRoot walks up from the org file to find a .git .hg etc marker, then uses repo-root-relative paths for tangle markers

  • Absolute tangle paths (starting with /) are written directly instead of relative to org dir

  • Tangles matching files with :eval arroyo blocks evaluated using DB queries

  • Files with ARROYO_TANGLE_THIS: yes match any role; values are space-delimited tokens

  • --ignore-errors flag continues on file failure; default exits with code 1 on failure

  • --dry-run lists files without modifying

Pipeline

  1. Index org directory → populate DB with module metadata

  2. Query ARROYO_TANGLE_THIS (and ARROYO_NIXOS_MODULE/HOME_MODULE/EMACS_MODULE with --all-modules) → filter by role

  3. Tangle each matching file with ArroyoScriptHost eval context

With --all-modules the flood runs in two phases: module snippets (ARROYO_NIXOS_MODULE ARROYO_HOME_MODULE ARROYO_EMACS_MODULE) are tangled first, then ARROYO_TANGLE_THIS files are tangled in a second pass. A file carrying both a module keyword and ARROYO_TANGLE_THIS is tangled in both phases — the TANGLE_THIS phase produces entry-point outputs (flake.nix, init.el) whose Lua generators consume the module snippets the first phase just wrote to disk, so it must run last. The same files contain both static :tangle blocks and dynamic generators.

Emacs Integration

arroyo.el (tangled from arroyo/emacs-integration.org to lisp/arroyo.el) provides:

  • M-x arroyo-flood — full rebuild, async with prefix-arg for role filter

  • M-x arroyo-tangle-and-index — tangle + index current file (only if #+AUTO_TANGLE: t)

  • arroyo-auto-tangle-mode — replaces org-auto-tangle-mode

Results

FloodCommand implemented with role filtering, dry-run, and ignore-errors support. Six tests cover role matching (space-delimited tokens, bare yes, case sensitivity, whitespace handling). Emacs integration provides the M-x arroyo-flood entry point matching the legacy arroyo-nixos-full-spread behavior.

Files created

  • arroyo/emacs-integration.org — tangles to lisp/arroyo.el

Files modified

  • arroyo/generators.org — FloodCommand source block in generators-commands

  • roam/cli.org — CLI registration, Makefile flood target, documentation

  • arroyo/tests.org — FloodCommandTest with 6 test cases

  • arroyo/arroyo.org — Sprint 5 results

  • Makefile — make flood target

DONE Sprint 6: Nix Flake Generation + Submodule Modularization

Generate a flake.nix into ~/nix/ — the tangle output directory for the arroyo-system repo. CCE submodules (cce-core, cce-emacs, cce-workstation, cce-wobserver) are pure org-file repositories under ~/org/ — no flake.nix of their own. The generated flake composes them by reading ARROYO_INPUT and ARROYO_OUTPUT file contents from the DB and concatenating them directly. This avoids pulling journals or PARA notes into the nix store.

The submodules are not flake inputs in the traditional sense — they're indexed org-file repos whose ARROYO_NIXOS_MODULE ARROYO_HOME_MODULE ARROYO_EMACS_MODULE entries are queried at tangle time. ARROYO_INPUT and ARROYO_OUTPUT entries point at files on disk (resolved relative to ~/nix/), whose contents are inlined into the generated flake.nix.

Repository Clustering

The ~220 flat org files in the old ~/org/cce/ split into 4 org-file repos plus the arroyo-system entry-point repo:

Repo Org files Contents Role

-----------|----------|------| | cce-core | 53 | Arroyo generators (arroyo-nixos.org, arroyo-home-manager.org, arroyo-emacs.org, arroyo-nix.org), cce.org index, shared infrastructure (ssh, syncthing, gnupg, yubikey, zfs, direnv, nixpkgs overlay, package tables), version-pins, morph, nixops, nix-on-droid | all | | cce-emacs | 103 | ~100 ARROYO_EMACS_MODULE files (evil-mode, org-roam, magit, hydra, exwm, gnus, consult, etc.) | all | | cce-workstation | 40 | Desktop-specific: KDE, audio, laptop hardware, applications, riverwm, xmonad, firefox, waydroid, mpd, mbsync, bitwarden, etc. | endpoint, settop | | cce-wobserver | 26 | Server-specific: akkoma, nginx, gitea, matrix, jellyfin, vaultwarden, nextcloud, postgres, paperless, blocky, backups, wobserver-docker, etc. | server, edge, settop | | arroyo-system | 5 | Entry points (my_nixos_configuration.org, nixos-wobserver.org, home-manager.org, arroyo-flake.org, systems.org), host definitions, role configs | entry points |

arroyo-system/flake.nix (generated)

Produced by a Lua generator in arroyo-system/arroyo-flake.org. The flake inputs and outputs are generated from the DB: arroyo.inputs() and arroyo.outputs() return the file contents of ARROYO_INPUT and ARROYO_OUTPUT entries (paths resolved relative to ~/nix/), concatenated directly into the flake. System overlays come from arroyo.system_overlays(). Host module lists are produced by arroyo.nixos_role_modules(role) in arroyo-system/systems.org, which returns ./modulePath lines for each ARROYO_NIXOS_MODULE entry filtered by role. A third-party module just needs org files with the right keywords — the indexer picks them up and the generator includes them automatically.

nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
    <<arroyo_inputs()>>
  };
  outputs = { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; overlays = [ <<arroyo_system_overlays()>> ]; };
    in {
      <<arroyo_outputs()>>
    };
}

Migration Steps

  1. Create submodule repos; hand-write flake.nix for each

  2. Move org files into submodules. ARROYO_MODULE_WANTS paths (cce/foo.org) stay relative within each repo

  3. Convert #+PROPERTY: header-args to inline :tangle on every elisp source block (remaining Sprint 4 work)

  4. Rewrite :tangle paths: ~/arroyo-nix/nixos/foo.nix → nixos/foo.nix (relative to submodule root). Entry point tangles move to arroyo-system

  5. Move entry points (my_nixos_configuration.org, nixos-wobserver.org, home-manager.org) to arroyo-system

  6. Create arroyo-system/arroyo-flake.org with Lua generators that produce flake.nix

  7. Build new arroyo.* Lua functions: inputs(), outputs(), system_overlays(), nixos_role_modules(role), home_role_modules(role), emacs_init(), packages()

  8. Wire arroyo flood to index all submodules and tangle arroyo-system

  9. Delete ~/arroyo-nix/ (replaced by flake-native output)

Results

Sprint 6 is largely complete. The CCE submodules are split in to four org-file repos (cce-core, cce-emacs, cce-workstation, cce-wobserver) and the arroyo-system entry-point repo. arroyo flood --all-modules indexes all submodules and tangles the arroyo-system files to produce ~/nix/flake.nix. The generated flake passes nix flake check.

Unified schema + node_ancestors closure table

The per-module tables (nixos_modules, home_manager_modules, arroyo_emacs_snippets, arroyo_emacs_epkgs, and their role junction tables) are gone. All ARROYO_* values are stored in a single arroyo_keywords table with PK (file, kw, value) and an optional node_id column for heading-scoped keywords. A node_ancestors closure table maps each heading node to all its ancestor headings, enabling property inheritance: a file-level role applies to all headings in the file; a heading-scoped role applies to that heading and its children. Role-filter queries use IN (SELECT ancestor_id FROM node_ancestors WHERE node_id ak.node_id)= to match inherited roles and exclusions.

Heading-scoped roles and exclusions

ARROYO_SYSTEM_ROLE, ARROYO_SYSTEM_EXCLUDE, ARROYO_NIXOS_MODULE, ARROYO_HOME_MODULE, ARROYO_EMACS_MODULE, ARROYO_HOME_EPKGS, ARROYO_INPUT, ARROYO_SYSTEM_OVERLAY, ARROYO_MODULE_WANTS, and ARROYO_MODULE_WANTED can all appear in heading :PROPERTIES: drawers, not just file-level :PROPERTIES: or =#+ARROYO_= keyword lines. The indexer extracts these via nodeProperties and populates node_ancestors so that role/exclusion inheritance works correctly. =#+ARROYO_= keyword lines are always file-scoped (node_id null=) regardless of where they appear in the document.

Multi-valued keyword splitting

Keywords with space-delimited values (e.g. ARROYO_SYSTEM_ROLE: edge server) are split on whitespace and inserted as separate rows. This applies to ARROYO_SYSTEM_ROLE, ARROYO_NIXOS_MODULE, ARROYO_HOME_MODULE, ARROYO_EMACS_MODULE, ARROYO_HOME_EPKGS, ARROYO_INPUT, ARROYO_SYSTEM_OVERLAY, ARROYO_MODULE_WANTS, ARROYO_MODULE_WANTED, and ARROYO_SYSTEM_EXCLUDE.

New Lua functions

The arroyo Lua table now exposes 18 functions:

  • arroyo.nixos_modules(role), arroyo.nixos_modules_meta(role) — NixOS module imports from ARROYO_NIXOS_MODULE

  • arroyo.home_modules(role), arroyo.home_modules_meta(role) — Home Manager module imports from ARROYO_HOME_MODULE

  • arroyo.emacs_snippets() — topologically ordered Emacs module file paths

  • arroyo.emacs_init() — concatenated contents of all Emacs module .el files in topological order (paths resolved relative to ~/nix/lisp/)

  • arroyo.emacs_modules_meta() — Emacs module metadata with dependency info

  • arroyo.epkg_overrides() — Nix override blocks from ARROYO_HOME_EPKGS

  • arroyo.file_title_for(path), arroyo.org_dir() — metadata helpers

  • arroyo.flake_inputs(orgDir) — submodule directory names from indexed files

  • arroyo.nixos_role_modules(role), arroyo.home_role_modules(role) — ./modulePath lines for role-filtered modules (used by arroyo-system/systems.org)

  • arroyo.system_overlays(role) — file contents of ARROYO_SYSTEM_OVERLAY entries (paths resolved relative to ~/nix/)

  • arroyo.inputs(role) — file contents of ARROYO_INPUT entries (paths resolved relative to ~/nix/)

  • arroyo.outputs() — file contents of ARROYO_OUTPUT entries (paths resolved relative to ~/nix/)

system_overlays, inputs, and outputs return file contents, not paths — the Lua generators in arroyo-flake.org concatenate them directly into the flake. This is the key design shift from the old submodule-input model: instead of importing .nix files from flake input store paths, the flake is assembled from file contents queried at tangle time.

EmacsSnippetsCommand rewrite

EmacsSnippetsCommand now uses getArroyoKeywordsWithNodeId("ARROYO_MODULE_WANTS") and getArroyoKeywordsWithNodeId("ARROYO_MODULE_WANTED") instead of the old getEmacsSnippets(): List<EmacsSnippetRow>. Wants values are heading IDs resolved directly via nodeIdToModule / moduleToNodeId maps built from ARROYO_EMACS_MODULE entries — no more file-path-to-module-name resolution.

FloodCommand improvements

  • --all-modules / -a flag: tangles all files with ARROYO_NIXOS_MODULE, ARROYO_HOME_MODULE, ARROYO_EMACS_MODULE, or ARROYO_TANGLE_THIS (not just TANGLE_THIS)

  • findRepoRoot: walks up from the org file to find a .git .hg etc marker, then uses repo-root-relative paths for tangle markers

  • Absolute path handling: if a tangle output path starts with /, writes to that absolute path instead of relative to org dir

Tangle engine improvements

  • OrgTable.toNestedList() no longer includes the header row — the tangle tool strips it automatically. Lua :eval arroyo generators receive only data rows.

  • uncommaBody now handles leading whitespace: org-escape commas after indentation are un-escaped correctly (e.g. indented ,* comment lines in source blocks)

  • applyLinePrefix: when a noweb ref appears on a line with a prefix (e.g. # <<ref>>) and the replacement is multi-line, the prefix is propagated to all subsequent lines, preserving comment/indentation structure

  • FlakeModuleRef simplified: cceSubmodule field removed, only modulePath remains. Root-level files with ARROYO_NIXOS_MODULE / ARROYO_HOME_MODULE are no longer skipped — all modules are included regardless of directory depth.

Files modified

  • arroyo/core.org — ArroyoTangleContext interface (4 new methods), FlakeModuleRef (cceSubmodule removed), OrgTangle (uncommaBody, applyLinePrefix), OrgTable.toNestedList() (header stripping)

  • arroyo/generators.org — unified schema (arroyo_keywords + node_ancestors), ArroyoRepository (removed per-module methods, added unified queries), ArroyoIndexerPlugin (heading-property extraction, multi-valued splitting, node_ancestors population), ArroyoScriptHost (4 new Lua functions), FloodCommand (--all-modules, findRepoRoot, absolute paths), EmacsSnippetsCommand (heading-ID resolution)

  • arroyo/tests.org — heading-scoped role/exclusion tests, multi-valued keyword tests, system_overlays/inputs/outputs tests, applyLinePrefix test

DONE port away from morph to a flake-native tool like deploy-rs

Take the existing morph-wrappers in CCE and update them so I can type deploy the-hostname to build a new system and push it to that host, and also update the M-x arroyo-flood command to match

INPROGRESS Sprint 7: Rebuild Docs + Community

Update Rebuild pages to reflect Kotlin-based tooling, build "Build Your Own Arroyo" guide, publish Nix flake template.

DONE Shebang support + expanded comment types

Two related improvements to the tangle engine so it can produce executable scripts and correctly comment-wrap a wider range of file types.

:shebang header arg

#+begin_src bash :tangle ../scripts/foo.sh :shebang t now prepends a #! line and marks the output file executable. The CLI layer (TangleCommand, FloodCommand) calls setExecutable(true, true) after writing, driven by a new executableFiles: Set<String> field on TangleResult.

  • :shebang t / :shebang yes — use defaultShebangFor(language) to pick a sensible interpreter (bash → #!/usr/bin/env bash, python → #!/usr/bin/env python3, ruby, perl, make, etc.). Languages with no obvious default return null and emit no shebang.

  • :shebang "/path/to/interp" — use the literal string.

  • :shebang no — opt out (no shebang, not executable).

  • When multiple blocks target the same file, only the first block's shebang is applied — the engine guards against duplicate #! lines.

Expanded comment styles

commentPrefixFor is now a thin wrapper over commentStyleFor, which returns a ~CommentStyle(prefix, suffix)= pair to support languages with non-symmetric comment delimiters. New and corrected mappings:

  • shell, sh, zsh, fish → #

  • yaml, yml, toml, ini, conf, properties, dockerfile, terraform, hcl → #

  • jinja, jinja2 → #; jinja-html html+jinja django-html → {# … #}

  • html, xml, svg, markdown → <!-- … -->

  • css, scss, sass, less → =/ … /=

  • lua → --; vim → "

  • Kotlin/Java/C/C++/Rust/Go/JS/TS/Scala/Swift/Dart/Groovy → // (unchanged)

  • Nix/Makefile/Python/Ruby/Perl/Elisp/Lisp/SQL/Haskell → unchanged

The OrgDetangle delimiter regex was broadened to recognize the new prefixes (<!--, /*, {#) and the optional suffixes on the end delimiter, so the round-trip works for HTML/CSS/Jinja tangles.

Files modified

  • arroyo/core.org — tangle-models (executableFiles field on TangleResult), org-parse-utils (CommentStyle data class, commentStyleFor, defaultShebangFor, commentPrefixFor as wrapper, narrative for shebang + comment styles), org-tangle (shebang collection loop, executableFiles return), org-detangle (broadened delimiter regex), tangle-command (chmod +x after write)

  • arroyo/generators.org — flood-command (chmod +x after write)

  • arroyo/tests.org — tangle-test (15 new tests: shebang t/yes/no/explicit, multi-block dedup, shell/yaml/toml/html/css/jinja/lua/vim/unknown comment prefixes, defaultShebangFor unit test)

  • arroyo/arroyo.org — this Sprint 7.5 entry

DONE Eval failures are hard errors, not recoverable warnings

Sprint 3 shipped eval-error handling as "emit EvalError warning, embed the raw Lua source in the tangled output, keep going." That was wrong: broken Lua ends up silently in generators.py sites.json .css files and ships to production. Embedding the raw source — or embedding nothing — is worse than failing loudly.

  • TangleModels — added TangleEvalException(blockName, message, cause), a regular Exception subclass (not a TangleWarning). The EvalError warning type is kept for visibility but no longer controls flow.

  • OrgTangle.evaluateBlock and OrgTangle.evalBlockForRef now add the EvalError warning (so the user sees which block failed) AND re-throw as TangleEvalException. The raw block body is never returned on eval failure.

  • tangle() propagates the exception to its caller.

  • TangleCommand catches TangleEvalException around the tangle() call, prints ERROR: <message> to stderr, and calls exitProcess(1) immediately. No files from the failing org file are written. Files from earlier org files in the same invocation already on disk stay on disk.

  • FloodCommand catches TangleEvalException; with --ignore-errors the failed file is skipped and counted toward the failure total, otherwise exitProcess(1) immediately without tangling further files.

  • Three tests in arroyo/tests.org:

    • eval error throws TangleEvalException and writes no file (replaces the old "uses raw body" test)

    • eval error in parameterized noweb ref throws TangleEvalException

    • eval error in one of two blocks targeting same file throws and writes nothing

Files modified

  • arroyo/core.org — tangle-models (TangleEvalException), org-tangle (evaluateBlock / evalBlockForRef re-throw), tangle-command (catch + exitProcess)

  • arroyo/generators.org — generators-commands FloodCommand (catch + exitProcess / --ignore-errors skip)

  • arroyo/tests.org — tangle-test (3 new tests, old "uses raw body" test replaced)

DONE arcology flood rebuild subcommand

flood populates ~/nix but it also needs to carry a CLI flag "--build thehost" that will:

  • git add untracked tangled files

  • =nixos-rebuild build --flake ~/nix#thehost --target-host=thehost --ask-sudo-password --sudo=

DONE orgmode-kmp parseParagraph should stop on Token.{File,Generic,}Keyword

orgmode-kmp's parseParagraph (orgmode-kmp/orgmode/src/commonMain/kotlin/xyz/lepisma/orgmode/OrgChunk.kt:539) has a trail-stop predicate that only halts on EOF, list markers, HeadingStars, and certain =BlockStart=/=BlockEnd= types. It does NOT halt on Token.Keyword (#+NAME:, #+RESULTS:, …), Token.FileKeyword, or Token.GenericKeyword. When prose runs directly into a #+NAME: line with no blank line between them, the paragraph parser greedily consumes the #+NAME: token and everything after it — including table rows — as inline paragraph text.

Concrete failure surfaced in arcology-django's configuration.org: the roam_allowed_keywords and my_roam_allowed_keywords tables (under ** Roam Allowed Keywords) are preceded by prose ending in : then #+NAME: on the very next line — no blank line. Those tables never parse as OrgChunk.OrgTable; the chunk dump shows them truncated into OrgParagraph text. collectNamedTables returns 8 tables from the file, missing exactly those two, and tangle then emits Unresolved table arg 'roam_allowed_keywords' for gen-config-list and the-code/1.

Other tables in the same file (arroyo-roles, ignored_roam_tags, arcology_apps, etc.) work because they have a blank line between the preceding prose and #+NAME:, which terminates the paragraph via the two-consecutive-=LineBreak= rule. arroyo-roles also has prose-then-#+NAME: with no blank line but parses correctly — the exact trigger is the specific mix of inline elements in the preceding paragraph (e.g. =#+KEYWORD='s= verbatim markup) that lets the paragraph stopper fire on the double-LF before the #+NAME: line; the two failing tables have a single-line preceding paragraph ending in : that doesn't trip the double-LF rule before #+NAME:.

Fix: add Token.Keyword, Token.FileKeyword, and Token.GenericKeyword to the stop conditions in =parseParagraph='s trail predicate (OrgChunk.kt:539-578) so affiliated keywords terminate a paragraph regardless of surrounding blank lines. Emacs' org-element treats #+NAME: as a keyword line in this position; we should match.

The Elisp tangle path (Emacs org-babel-tangle) handles this case correctly — the legacy site is being kept alive with the Elisp tangle while arcology2go rolls forward.

Fix shipped

=parseParagraph='s trail-stop predicate (orgmode-kmp/orgmode/src/commonMain/kotlin/xyz/lepisma/orgmode/OrgChunk.kt:539) now returns true for Token.Keyword, Token.FileKeyword, and Token.GenericKeyword unconditionally, and for Token.CommentStart only when the paragraph has already consumed tokens. Affiliated keywords don't need a separate token type here: #+ATTR_HTML, #+CAPTION, #+NAME, #+RESULTS, #+TBLFM all lex as Token.Keyword tagged with a KeywordType in the lexer, so the three keyword cases cover Emacs' affiliated-keyword set. The CommentStart guard exists because parseCommentLine is commented out of the parseChunk oneOf chain: a chunk-initial comment line is consumed by parseParagraph as paragraph text (via parsePlainText), and an unguarded comment stop would make parseParagraph fail with "No inline elements parsed", failing the chunk parse — and every file with a comment line after a blank line would stop parsing entirely.

Four regression tests in orgmode-kmp/orgmode/src/commonTest/kotlin/xyz/lepisma/orgmode/OrgParserTest.kt:

  • testParagraphParsing_KeywordLineNoBlankLine should stop paragraph before NAME and parse the table — prose ending in : runs into #+NAME: with no blank line; asserts the paragraph/keyword-line/table chunk split reproducing the configuration.org failure shape, and that the paragraph no longer contains the name or table rows.

  • testParagraphParsing_FileAndGenericKeywordNoBlankLine should stop paragraph — mid-body #+RESULTS: / #+TITLE: (Token.Keyword and Token.FileKeyword) and #+ARCOLOGY_KEY: (Token.GenericKeyword) each terminate a paragraph.

  • testParagraphParsing_CommentLineNoBlankLine should stop in-flight paragraph but keep paragraph-initial comments — pins the CommentStart guard on both sides: prose stops before a trailing comment line, while a paragraph-initial comment still parses (legacy chunk-initial behavior).

  • testParagraphParsing_KeywordWithBlankLine should still parse keyword line and table — the double-=LineBreak= path is unchanged.

Files modified

  • orgmode-kmp/orgmode/src/commonMain/kotlin/xyz/lepisma/orgmode/OrgChunk.kt — parseParagraph stop predicate: keyword token stops + guarded Token.CommentStart stop

  • orgmode-kmp/orgmode/src/commonTest/kotlin/xyz/lepisma/orgmode/OrgParserTest.kt — four paragraph-boundary regression tests

Validation: make test-orgmode (OrgParserTest 42 tests, 0 failures), make test, make build, and make test-app all pass. No submodule pointer bump or commit yet — awaiting explicit instruction.

DONE orgmode-kmp OrgBlock parsing needs to support parsing multiple :var keywords

parseSourceBlock (orgmode-kmp/orgmode/src/commonMain/kotlin/xyz/lepisma/orgmode/OrgBlock.kt:128-140) parsed header args into Map<String, String> keyed by arg name. Repeated :var keys overwrote earlier ones — =:var sites=sites-config :var domains=domains-config= ended up as just ={var: domains=domains-config}=, and the Lua script saw nil for sites. Same for =:var site="default-colors" :var tbl=site-colors= — only the tbl binding survived, so the quoted string site arg was lost.

Concrete failures in arcology-django's configuration.org:

  • elisp-join-tables (sites.json generator): both sites and domains bindings lost except the last; Lua got nil for whichever was missing → "table expected, got nil" eval error.

  • mk-site-colors (per-site CSS generator): =:var site="default-colors" :var tbl=site-colors= collapsed to just =tbl=site-colors=. Then the parameterized noweb <<mk-site-colors("default-colors")>> in resolveVarBindingsForEval bound the quoted-string arg to the FIRST :var name — which was now tbl (because the site binding was lost). Lua's ipair(tbl) received a string → "table expected, got string" eval error.

Fixed by changing OrgSourceBlock.headerArgs to Map<String, List<String>> (preserve all occurrences in document order; scalar args read through a scalar helper that takes the last occurrence — org-babel last-wins semantics). The parser at OrgBlock.kt appends rather than overwrites.

Design decisions:

  • Scalar args (tangle, eval, noweb, shebang, comments, noweb-ref) take lastOrNull() uniformly via Map<String, List<String>>.scalar.

  • mergeHeaderArgs (heading-level header-args propagation) uses simple per-key override: the block's own list wins when the key is present on the block, the heading's list fills only keys the block lacks. CCE files are migrated away from file-level propagation so this path is low-stakes.

  • evaluateBlock iterates ALL :var bindings for a block: quoted values become string bindings, unquoted values resolve through resolveTable into table bindings, unresolvable names emit UnresolvedTableRef warnings per binding.

  • resolveVarBindingsForEval: for <<ref(arg)>>, the arg overrides the first table-typed :var binding (the one whose default value is not a quoted string); quoted-string bindings pass through unchanged; a quoted-string arg binds to the first binding's name; on unresolved arg table, the overridden binding falls back to its own default table.

  • ArroyoScriptHost.evalBlock already took Map<String, List<List<String>>> + Map<String, String> — the Lua boundary is unchanged.

The Elisp tangle path preserves multiple :var bindings and works.

Files modified

  • orgmode-kmp — OrgBlock.kt (headerArgs: Map<String, List<String>>, append-on-repeat parser), OrgParserTest.kt (list-shape assertions, two new multi-=:var= preservation tests)

  • arroyo/core.org — org-parse-utils (scalar helper, list-shaped parseHeaderArgsPropertyValue, extractHeadingHeaderArgs, list-shaped mergeHeaderArgs), org-tangle (multi-binding varBindings, evaluateBlock, resolveVarBindingsForEval, resolveNoweb param, all scalar reads via scalar)

  • web/renderer.org — renderSourceBlock / renderSourceBlockCaption noweb-ref reads and list-valued header-arg rendering; test fixtures wrapped in listOf

  • arroyo/tests.org / TangleTest.kt — multiple var bindings all reach eval, quoted string and table var bindings coexist, parameterized arg overrides only the table typed var binding (the mk-site-colors regression)

  • arroyo/arroyo.org — this entry

DONE OrgTangle noweb-ref blocks with the same name should concatenate in document order

OrgTangle.tangle() (src/commonMain/kotlin/computer/whatthefuck/arroyo/OrgTangle.kt:39) builds nowebBlocks allBlocks.associate { it.name to it.block.body }= — a Map<String, String>. When two or more source blocks share a name (both have :noweb-ref theref, or both follow #+NAME: theref), associate silently keeps only the last one in document order. Emacs org-babel concatenates all blocks with a given :noweb-ref in document order when <<theref>> is expanded; we should match.

Same root shape as the multi-:var bug: a Map keyed by name can't hold multiple values. Fix: change nowebBlocks to Map<String, List<String>> (or Map<String, String> built by joining the bodies with "\n"). resolveNoweb (OrgTangle.kt:197-269) then looks up the list and joins with "\n" (or uses the pre-joined string). blockMap (line 33, allBlocks.associateBy { it.name }) has the same problem for the :eval arroyo lookup at line 233 — needs the same treatment, or at minimum a decision about which block "wins" for eval (probably: the last one, matching current behavior, OR an error if they disagree on :eval).

Tests to add in arroyo/tests.org / TangleTest.kt:

  • multiple noweb-ref blocks concatenate in order — two #+begin_src kotlin :noweb-ref combined blocks with bodies "val a 1" and "val b 2"; a consumer <<combined>>; assert the tangled output contains both lines in order.

  • multiple NAME blocks with same name concatenate — same but using #+NAME: combined on consecutive blocks (no :noweb-ref).

  • multiple noweb-ref blocks with :eval arroyo — decide and assert the behavior for which block's header args win for eval lookup.

DONE Tangle comment delimiters and the :comments / :results separation

tangleCommentFor (src/commonMain/kotlin/computer/whatthefuck/arroyo/OrgParseUtils.kt:224) emitted the heading-ID link line with style.prefix but omitted style.suffix. For symmetric comment languages (//, #, ;) this is invisible, but for CSS the start delimiter was =/ ... with no closing /=, so the rest of the tangled file was swallowed as a CSS comment until the ends here */ line. Fix: append style.suffix to the heading-link line, matching the start and end delimiters.

Separately, wrapWithComments (OrgTangle.kt:296) treated :results raw as a tangle knob that suppressed delimiter wrapping. This is wrong: :results is org-babel's evaluation-output embedding control (raw, drawer, value, output, etc.), not a tangle control. The proper org-babel knob for comment wrapping is :comments (none, no, link, org, both). The tangle engine now recognizes :comments none and :comments no as the only no-wrap triggers and ignores :results entirely. Nine blocks in web/templates.org and web/domains.org that had been using :results raw as a no-wrap hack were migrated to :comments none.

Files modified

  • arroyo/core.org — org-parse-utils (tangleCommentFor heading-link suffix), org-tangle (wrapWithComments honors :comments none|no only; ignores :results), narrative for :comments semantics

  • arroyo/tests.org — tangle-test (new: comments no not wrapped, heading id delimiter is closed for non-symmetric comment styles, results raw is not a tangle knob and does not skip wrapping; renamed results raw eval block has no delimiter wrapping → comments none on eval block skips delimiter wrapping)

  • arroyo/tools.org — agent docs and key rules now describe :comments none as the no-wrap knob and note that :results is not a tangle knob

  • web/templates.org, web/domains.org — eight Pebble template blocks and the domains.json generator migrated from :results raw to :comments none