Checking how many agents are working

How this works
Contact
← Blog
A dark wooden shelf holding many small identical olive-lit boxes with teal labels, the AMARBARO mark centered on the middle box.
✎blog post

The Mojo libraries: a shelf of small, checked parts

The short version

Each library in the amarbaro Mojo table is its own public repository under github.com/amarbaro, with tests checked against an oracle, a conda package, and its own API and design pages.

Part 13 of 20 in Tools we built and why. Previous: ABCam: using your Android phone as a webcam · Next: Why our Mojo libraries copy Python byte for byte

What this is about

A library is a set of ready-made parts. Instead of writing a JSON reader every time you need one, you borrow a library that already has it. Programmers use libraries all the time. Our Mojo libraries are small, single-purpose packages. Each one is its own repository on GitHub, and each is tested against the tool it copies.

This post is a map of the shelf. It tells you what kinds of parts are there, how they are checked, and how to find the one you need.

Why it matters

When a library is checked against a well-known one, you can swap it in and expect the same results. That saves you from learning a new set of rules, and from finding out later that your data was read differently.

It also matters that the parts are small. A small library is easy to read, easy to test, and easy to replace. When one of our tools needs a part that a library lacks, we add it to the library, check it there, and reuse it. That is how a tool stays short.

What is on the shelf

The amarbaro.com page lists thirty-eight libraries. Here they are in groups.

  • Files and formats: mojo-json, mojo-csv, mojo-toml, mojo-msgpack, mojo-struct, mojo-base64, mojo-zip, mojo-gzip, mojo-zstd, mojo-safetensors, mojo-gguf-core, mojo-gguf, mojo-mmap.
  • Text and numbers: mojo-uregex for regular expressions, mojo-pyformat for Python-style number formatting, mojo-semver, mojo-uuid, mojo-hashlib, mojo-xxhash, mojo-glob, mojo-tokenizers.
  • The command line and the system: mojo-args, mojo-subprocess, mojo-posix, mojo-inotify, mojo-systemd, mojo-log.
  • Networks and servers: mojo-aio, mojo-tls, mojo-bento, mojo-prometheus.
  • Data: mojo-sqlite.
  • Pictures and screens: mojo-cv, mojo-imkit, mojo-supervision, mojo-vattn.
  • The graphics card: mojo-amdgpu.
  • Checking and measuring: mojo-bench, mojo-proptest.

Each name tells you what it copies. mojo-json behaves like Python's json. mojo-semver is identical to Python semver. mojo-sqlite is measured against Python's sqlite3. The table on the page says in one line what each library does and gives its version.

How to find the one you need

  1. Say what you need in one sentence. For example: "read a CSV file".
  2. Look at the groups above. If your sentence matches a name, open that library.
  3. Open the table on the Mojo libraries page. Every row says what the library does.
  4. Open its repository and read three things: the quick example at the top, the "What you get" list, and the "Limits" or "What it is not" section.
  5. Run its check script before you rely on it.

How to install one

Every library is a conda package named mojo-<name>. The page shows the commands:

pixi init app && cd app
pixi workspace channel add https://conda.modular.com/max https://prefix.dev/amarbaro/amarbaro
pixi add mojo-json

The toolchain is Mojo 1.2 stable. A weekly build also tries every library on the current nightly. You can also use a library straight from a clone. Compile with -I pointing at its src folder.

Some older individual repositories now say "Moved" at the top and point to the libs folder in mojo-libs. That is the same code in one place, and the old repository is read-only.

How each one is checked

Every library has the same pieces: tests checked against an oracle, a CI badge, a docs/api.md, a docs/design.md, and an agent skill in a skills folder. The oracle is whatever the library copies. For mojo-cv it is OpenCV. For mojo-json it is Python's json. For mojo-toml it is the full toml-test suite. The next posts in this series look at four of them closely.

What this does not mean

  • A library that matches Python on its tests may still differ on an input nobody tried. The Limits sections say where we know it does.
  • Some libraries are young. Version numbers in the table are mostly 0.1 and 0.2.
  • A few libraries load a system library. mojo-sqlite loads libsqlite3 at run time, and mojo-gzip uses the system libz. Others, such as mojo-tls and mojo-zstd, use no C library.
  • Mojo is itself a young language, and these libraries follow its changes.

An example of picking

Say you are writing a small tool that reads a list of jobs from a CSV file, logs what it does, and keeps the results in a database. You would reach for mojo-csv for the file, mojo-log for the messages, and mojo-sqlite for the results. If the tool takes options on the command line, mojo-args gives you Python argparse behavior. If it must run another program and capture its output, mojo-subprocess behaves like Python subprocess.run. Five small parts, each with its own README, each checked against the thing it copies. That is the shelf working as intended: you read five short pages instead of learning five new rule books.

Words you may not know

  • Library: a set of ready-made parts.
  • Package: a library wrapped so a tool can install it for you.
  • Oracle: a trusted program whose answers we compare with.
  • Conda: a way to install packages.
  • Toolchain: the compiler and tools needed to build code.
  • Nightly: a build made every night, before it is released.
  • Repository: a folder of code and its history on GitHub.

Try it

Comments

No comments yet.

Log in to comment.