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.4.0.tar.gz (22.8 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.4.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_hats_core-0.4.0.tar.gz
  • Upload date:
  • Size: 22.8 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.4.0.tar.gz
Algorithm Hash digest
SHA256 611f5761a6320d0af870fe13cfc765d8c24ace7cdd4798c383cafbb3e7616793
MD5 d874f3b703ea3ae1675ba133fca1d3a9
BLAKE2b-256 cbde7fa6963a67e0b79e3f5deabe54dbd4dad49672fe26e5774577ff92fcd8b4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ai_hats_core-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03f4bd4d2516f938bfab9e394a0f46cfdc6c9a5354afba5d65a44aa738e9040a
MD5 f1e0fea8c52a2d1a26fe480460757696
BLAKE2b-256 51663b16c619328cc476199d6e618a698be7706dbcd247d43479ed1cf95a89f2

See more details on using hashes here.

Provenance

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