Catalog PyPI
PACKAGE EXPLORERView in registry

ai-hats-core

PyPI

Core primitives and shared mechanisms for the ai-hats framework — minimal deps, each load-bearing.

ai-hatsatomic-writefilesystemos.replace
Versions collected1
Direct dependencies2From release 0.14.0
Last observed21 Oct, 10:52 UTC

README

Version 0.14.0 documentation

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 writes — atomic_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-types — CompositionResult / 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 base — YamlModel: pydantic base for YAML-round-trippable models (to_dict / from_dict, extra="ignore").
  • Git-env hygiene — scrubbed_git_env(): os.environ copy minus the three GIT_* plumbing vars that retarget cwd-scoped git subprocesses.
  • Safe deletion — ai_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.13+.

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 and ai_hats_core.lazy module namespaces. lazy.lazy_facade builds the __getattr__/__dir__ pair a package needs to bind its exports on first use.

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 + ai_hats_core.lazy.

License

MIT. See the ai-hats repository.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.14.021 Sept 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
muratovv/ai-hats

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 10:52 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:0fb90b25c3e3a19480d56bbc6437c1fb5630ba83cd71913083e2abcdbf547d21