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.2.0.tar.gz (18.5 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.2.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_hats_core-0.2.0.tar.gz
  • Upload date:
  • Size: 18.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 3caf2ef773ed9990030b81ff38153124671f774c09a88c8b4b15ceceb0b2e907
MD5 37f590f5a561e7f90c86d15dbe5a65ee
BLAKE2b-256 35ba6764608952a5be186aefde9e13684822976d6e843ca328bb6f44fbddd0bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_hats_core-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: ai_hats_core-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5259172d36944b5b8f04116cc4f87c5bc566acddaa3b22770a746c134bc8a284
MD5 05ec913252afd1fadec6c7af924cc3b1
BLAKE2b-256 c92d98f37c8f420943156a55d3a3b91264ecf44095ed3d0ede094efd524ef5d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_hats_core-0.2.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