Skip to main content

Spine 家族的薄共享核:domain-neutral 底层原语(缝注册表 / observability / LLM 缝 / config / queue / conformance 基座)。

Project description

corespine

Spine 家族的薄共享核(见 ADR 0001)。 只装 domain-neutral 的底层原语——既不属于 RAG 也不属于 agent 的稳定地基,被 ragspine / agentspine 兄弟包各自依赖,含任何它们的领域概念。

刻意地薄。按证据(rule of three)增长,不预先造框架。详见 CLAUDE.md 宪章。

🤖 给 AI / LLM: 用本库前先读 llms.txt(精简索引)与 docs/llms/(完整 API / recipes / 陷阱);pip install 后这些文档随包位于 site-packages/corespine/_llms/

缝的元模式

每条缝都长一个样,核心 import 零 SDK、离线可跑:

Protocol + 离线确定性默认 + Registry / make_* 工厂 + 参数化 conformance

里面有什么

模块 原语
seam/registry.py Registry:name→factory 解析(大小写/留白/连字符不敏感)+ entry-point 自动发现(corespine.<seam> group)+ 未知 spec 列清可用名 + lazy_extra_import(缺 extra 给"pip install …"友好提示)
observability/trace.py TraceSink 协议 + InProcessPrivacyTraceSink:只记 code/计数/耗时,拒绝任何携带正文(answer/value/text/content…)的载荷
llm/provider.py LLMProvider 协议 + 离线确定性 MockProvider(零网络、零 key、可复现)
config/env.py load_from_env:把 PREFIX_* 环境变量读进一个 frozen dataclass(范式同 ragspine from_env)
queue/task_queue.py TaskQueue 协议 + FakeQueue:同步内联执行 + 记录,离线/测试用
conformance/harness.py ConformanceSuite × InvariantPack:把"实现 × 不变量"绑成笛卡尔积逐格执行(机制,具体不变量由各 app 自己绑)

本地开发(始终从包根)

uv venv .venv
VIRTUAL_ENV="$(pwd)/.venv" uv pip install -e ".[dev]"
.venv/bin/python -m pytest -q
.venv/bin/python -c "import corespine"

30 秒上手

from corespine import Registry, MockProvider, InProcessPrivacyTraceSink, FakeQueue

# 缝:一个 spec 选实现(大小写/留白不敏感;找不到列清可用名;还能 entry-point 自动发现)
reg: Registry = Registry("llm")
reg.register("mock", lambda **kw: MockProvider(**kw))
provider = reg.make("  MOCK ")
# OpenAI chat-completions 规范:messages 进,OpenAI 形状的 ChatCompletion 出(确定性可复现)
out = provider.chat([{"role": "user", "content": "hello"}])
print(out.choices[0].message.content)

# 隐私 trace:只记元数据;塞正文会被直接拒绝(raise TraceError)
sink = InProcessPrivacyTraceSink()
sink.emit("retrieve", count=3, took_ms=12)

# 任务队列:同步内联执行
q = FakeQueue()
jid = q.enqueue(lambda p: {"doubled": p["n"] * 2}, {"n": 21})
print(q.get(jid).result)                 # {'doubled': 42}

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

corespine-0.1.0.tar.gz (48.3 kB view details)

Uploaded Source

Built Distribution

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

corespine-0.1.0-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file corespine-0.1.0.tar.gz.

File metadata

  • Download URL: corespine-0.1.0.tar.gz
  • Upload date:
  • Size: 48.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for corespine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cdacbffdf58fda9595451ced3ea0f09c425054d79eeb005b6885fc2f2bce6dad
MD5 d9097828ddb5139251b9a39753d1f8a6
BLAKE2b-256 2dde6eb167d5fd18c3e2fb8d9bcf8f2aba9e7566e4dbd28bf08923f7ebf48d02

See more details on using hashes here.

File details

Details for the file corespine-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: corespine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for corespine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0de8d478f87a44912ecdfe0249df0a6066cfbee9931d5702c732f17b1298ee15
MD5 f36d3eddf0f6c882ccde305c8ea3d62b
BLAKE2b-256 c6c52c6bc5e1100eb5859baa31bfa5914d52204b627845cba824d9a065b9c306

See more details on using hashes here.

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