Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_hats_core-0.3.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_hats_core-0.3.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file ai_hats_core-0.3.0.tar.gz.

File metadata

  • Download URL: ai_hats_core-0.3.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_hats_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 cd5a6194244125b5ac808d990ddecc6aaad6c6e4ac8f3c254f2f4fe07c52349a
MD5 9527cfc60cd0c73a7780c3e85ce7cf25
BLAKE2b-256 1febfc800ea9a070143cccf82ab2e784309d9a76282a127a8b2f153a9903aadb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_hats_core-0.3.0.tar.gz:

Publisher: release-packages.yml on muratovv/ai-hats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_hats_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ai_hats_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_hats_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f8503e852c8e479c5f6bb163dbd6b0a23eedbde91609947f89ac43c05de779d
MD5 bd71dbb7c4ead3be81c9105b73003ae4
BLAKE2b-256 ce0aee9608944cf874639f61a71415f103b8910e71625d93cf7b9a412f95003c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_hats_core-0.3.0-py3-none-any.whl:

Publisher: release-packages.yml on muratovv/ai-hats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page