Skip to main content

ai-hats-core

Core primitives and shared mechanisms for the ai-hats framework — minimal dependencies, each load-bearing (currently exactly one: pydantic). No domain schemas: each ai-hats package owns its own.

It ships five mechanisms:

  • Atomic file writesatomic_write_text / atomic_write_bytes: unique-tmp-in-same-dir + os.replace, so a reader never observes a half-written file and a crash never leaves a truncated one.
  • Composition value-typesCompositionResult / ResolvedComponent (frozen dataclasses) + the ComponentKind enum: the immutable result contract of role assembly, composed once by the integrator and injected down into packages.
  • YAML model baseYamlModel: pydantic base for YAML-round-trippable models (to_dict / from_dict, extra="ignore").
  • Git-env hygienescrubbed_git_env(): os.environ copy minus the three GIT_* plumbing vars that retarget cwd-scoped git subprocesses.
  • Safe deletionai_hats_core.safe_delete: trash-bin destructive ops (discard / replace) instead of raw unlink/rmtree, with a per-process session and recovery summary.

Install

pip install ai-hats-core

Requires Python 3.11+.

Usage

from pathlib import Path
from ai_hats_core import atomic_write_text, scrubbed_git_env

atomic_write_text(Path("config.json"), '{"ok": true}\n')

import subprocess
subprocess.run(["git", "status"], cwd=Path("."), env=scrubbed_git_env())

Public API

ai_hats_core.__all__:

  • atomic_write_text(path, text, *, mode=None) / atomic_write_bytes(path, data, *, mode=None)
  • CompositionResult / ResolvedComponent / ComponentKind
  • YamlModel
  • scrubbed_git_env()

plus the ai_hats_core.safe_delete module namespace.

Dependencies

pydantic>=2 — the base of the model layer. Nothing else.

Versioning

SemVer. The public API is ai_hats_core.__all__ + ai_hats_core.safe_delete.

License

MIT. See the ai-hats repository.

Release files for ai-hats-core 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 ai-hats-core 0.5.0
File Size Uploaded
ai_hats_core-0.5.0.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-hats-core 0.5.0
File Interpreter ABI Platform
ai_hats_core-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / ai_hats_core-0.5.0.tar.gz

Download URL ai_hats_core-0.5.0.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a069cc2aa58296d08c5735af037b5ec4b269688e254f5f0386b21379e8ebf9cf
BLAKE2b-256 checksum
How to use checksums
e35fd718c64a74301a5d8ece08536ea86ee9fd32f526a89bf6e8ef618703d93f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 9, 2026.

Transparency log

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

Download URL ai_hats_core-0.5.0-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c995319cfce50982ee37b89c5cf605558647b2980db03ca7a872af8fb66073e
BLAKE2b-256 checksum
How to use checksums
e2cdda000a2dc18aac7d60c16706d1bd8852df90826150c96c701ab3296002ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

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