Skip to main content

AXM Logo

axm-ingot — Shared helper library for the AXM forge

CI axm-audit axm-init Coverage PyPI Python 3.12+ Docs


axm-ingot is the AXM forge's shared helper library: the single home for small, general-purpose functions that more than one package needs. Instead of copy-pasting the same logic into axm-ast, axm-audit, axm-init and axm-anvil — and testing it N times, inconsistently — the logic lives here once, is tested once, and is imported as a normal workspace dependency.

It is a Python library with no CLI or MCP tool. Workspace, suite and console helpers read the filesystem; they do not write files or launch processes.

Features

  • uv-workspace resolution — resolve_workspace() parses [tool.uv.workspace], expands member globs, subtracts exclude, keeps only directories carrying a pyproject.toml, and returns members sorted by directory basename.
  • Project-root discovery — find_project_root() walks parents to the first ancestor holding any pyproject.toml (never returns None); find_workspace_root() finds the nearest uv-workspace root specifically.
  • Pure parsing primitive — parse_workspace_members() returns the raw, unexpanded member strings from pyproject text, with no filesystem access.
  • Typed value objects — frozen ResolvedWorkspace and Member dataclasses describe the resolved result.
  • Compact rendering — primitives plus the submodule-level render_result walker for readable text. Preserve structured data when exact types matter.
  • Console and test helpers — console_script locates a script without executing it; tally_outcomes counts supplied outcome lines.
  • Function-specific fallbacks — pyproject read/parse errors and rejected glob patterns have documented fallbacks. Arbitrary inputs and filesystem operations do not share a blanket never-raises guarantee.
  • Modern Python — 3.12+ with strict typing, zero runtime dependencies beyond the standard library.

Installation

Requires Python 3.12 or newer. In a Python project managed by uv:

uv add axm-ingot

Or, as a sibling package inside the workspace, declare it as a workspace dependency in your pyproject.toml:

[project]
dependencies = ["axm-ingot"]

[tool.uv.sources]
axm-ingot = { workspace = true }

Quick Start

Parse workspace declarations without creating any files:

uv run python - <<'PY'
from axm_ingot.uv import parse_workspace_members

members = parse_workspace_members('[tool.uv.workspace]\nmembers = ["packages/*"]\n')
print(members)
PY

This prints ['packages/*']: the declared patterns, without glob expansion or filesystem access.

Usage

Discover workspace members

Run this from a project directory to locate its nearest project and enclosing uv workspace:

from pathlib import Path

from axm_ingot import (
    find_project_root,
    find_workspace_root,
    resolve_workspace,
)

# Walk up to the nearest project root (any pyproject.toml ancestor).
root = find_project_root(Path.cwd())
print("Project:", root)

# Resolve a uv workspace into its sorted members.
ws_root = find_workspace_root(Path.cwd())
workspace = resolve_workspace(ws_root) if ws_root is not None else None
if workspace is not None:
    for member in workspace.members:
        print(member.name, "->", member.path)

else:
    print("No uv workspace found")

Member.name is the directory basename, not the distribution name. Use paths as keys when two members may share a basename. find_project_root falls back to the resolved starting directory if no project exists.

Public API

Symbol Kind Description
resolve_workspace(dir) function Resolve a uv workspace → ResolvedWorkspace | None
find_project_root(start) function Nearest ancestor with any pyproject.toml (never None)
find_workspace_root(start) function Nearest uv-workspace root → Path | None
parse_workspace_members(text) function Raw members from pyproject text (axm_ingot.uv)
ResolvedWorkspace dataclass {root, members} — a resolved workspace
Member dataclass {name, path} — one workspace member
header, labeled_block, compact_table functions Compose readable text
truncate, format_count, format_size functions Shorten text and format quantities
format_duration function Milliseconds → duration text
console_script function Interpreter directory → PATH → unchanged name
tally_outcomes function Count failed/error/skipped/unknown lines

render_result and record_table are imported from axm_ingot.render, not from the package root. See the API reference for exact signatures, import paths and limitations, and the temporary-workspace tutorial for a runnable example. Internal suite-discovery utilities live in axm_ingot.suite.

Why it exists

A monorepo accumulates duplication: the same "walk up to the project root", "read [tool.uv.workspace].members", "resolve the workspace members" snippets reappear in package after package, each with its own subtle bugs and its own half-tested copy. axm-ingot is the deliberate counter-move — a thin, dependency-light ingot of common code that downstream packages melt into their own logic:

  • Factor once, fix once — a bug fixed here is fixed everywhere.
  • Test once, trust everywhere — helpers are covered in this package, so consumers don't re-test the same primitive.
  • Stable public surface — consumers import from axm_ingot, not from each other, avoiding cross-tool coupling.

The shared surface covers workspace discovery, text rendering, durations, console-script lookup and pytest outcome tallies. The library grows by promotion, subject to reuse and dependency checks.

What belongs here (the light-leaf invariant)

axm-ingot is a dependency-graph leaf imported across the whole galaxy. Its value depends on staying light: every consumer that imports it for one small helper inherits all of its dependencies. A fat leaf is no longer a leaf.

Hard rule — a helper may be promoted into axm-ingot only if its dependencies are stdlib-only — it adds no dependency at all. dependencies here stays empty. Even Pydantic — a near-universal AXM dependency — does not belong: it is still a dependency, and adding it breaks the leaf invariant. Value objects here are frozen @dataclass, not BaseModel.

Belongs in ingot ✅ Does not belong ❌
stdlib-only (pathlib, tomllib, re, dataclasses, json…) pulls httpx, pandas, torch, a DB driver, an SDK…
frozen @dataclass value objects pydantic models (Pydantic is a dependency — a fat leaf is no longer a leaf)
e.g. resolve_workspace (tomllib + pathlib) e.g. request_with_retry (needs httpx)

A reusable-but-heavy helper does not come here even when it has several consumers: keep it reuse_in_place (import it from the package that owns it), or give it a thematic light lib of its own (e.g. an axm-net for resilient HTTP) — never the generic leaf. The Rule of Three (≥ 2 consumers) is necessary for promotion but not sufficient; the dependency gate is the second lock.

Documentation

The MkDocs home page is docs/index.md, separate from this README.

Development

This package is part of the axm-forge workspace.

git clone https://github.com/axm-protocols/axm-forge.git
cd axm-forge
uv sync --all-packages --all-groups
uv run --package axm-ingot --directory packages/axm-ingot pytest -x -q

License

Licensed under Apache-2.0. See LICENSE.

Metadata

Release files for axm-ingot 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for axm-ingot 0.5.0
File Size Uploaded
axm_ingot-0.5.0.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axm-ingot 0.5.0
File Interpreter ABI Platform
axm_ingot-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.0 kB

Release files / axm_ingot-0.5.0.tar.gz

Download URL axm_ingot-0.5.0.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
441f86999062d47854bd41aa023c37c059a4b698df5cf26e8d90b098c4bebeeb
BLAKE2b-256 checksum
How to use checksums
f3d4d4a54da35f77e5b08bc68e75ef30d5831c88d236d2f5bf468d128c310ac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / axm_ingot-0.5.0-py3-none-any.whl

Download URL axm_ingot-0.5.0-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38c13c3745761771a4d2e7f5c80cd9d70a980aa4a5e5b8b2cc0351f3e827d041
BLAKE2b-256 checksum
How to use checksums
f5ec0237d6d8179aadba36d4f8c33c521e52026be2af288c483c869df8b19729
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page