Skip to main content

Framework-level document ingestion primitives for Muscles

Project description

muscles-documents

Framework-level document ingestion and chunking package for the Muscles ecosystem.

Purpose

  • Define contracts for documents, chunking, parsing and metadata.
  • Provide an initial pipeline for local files + markdown/text content ingestion.
  • Expose Muscles actions to drive ingestion/diagnostics through any transport.

Ecosystem Position

muscles-documents is a framework extension for document flows. It owns source loading, parsing, chunking, metadata and sync planning; it does not own AI model calls or protocol routing.

Related repositories:

  • muscles - core action contracts, dispatcher, inspect contract and canonical documentation.
  • muscles-ai - AI/RAG actions that can consume document contracts.
  • muscles-sql - SQL persistence for projects that store document metadata or ingestion state.
  • muscles-mcp - MCP projection for document actions when exposed to AI tools.
  • muscles-benchmarks - regression coverage for document extension contracts.

Installation

pip install git+https://github.com/butkoden/muscles-documents.git

The canonical ecosystem install matrix lives in muscles/docs/installation.md.

Configured as a standard module package:

modules:
  documents:
    package: muscles_documents
    sources:
      docs:
        type: local
        path: ./docs

Actions

  • documents.sources.list
  • documents.source.inspect
  • documents.load
  • documents.parse
  • documents.normalize
  • documents.chunk
  • documents.sync.plan
  • documents.sync.request
  • documents.inspect
  • documents.doctor

Ingestion Toolkit

The package exposes portable contracts for the document preparation flow:

source -> DocumentRef -> DocumentBlob -> ParsedDocument
       -> DocumentSection / DocumentBlock -> DocumentChunk
       -> DocumentSyncPlan / DocumentSyncResult

MVP components:

  • local source adapter with stable relative references;
  • raw blob loading with checksums;
  • text, markdown and HTML parsers;
  • safe text normalizer that preserves markdown code fences;
  • fixed-size and heading-aware chunkers;
  • dry-run sync planner;
  • sync request result contract for project executors/jobs;
  • safe inspect and doctor diagnostics.

Projects own persistence and integration policy. They may store refs, blobs, parsed documents, chunks and sync state in PostgreSQL, Elasticsearch, MongoDB, Redis, Qdrant or another system, but muscles-documents does not import those clients and does not write to external stores directly.

muscles-ai can consume DocumentChunk objects after a project stores and exposes them through its own data/search ports. This package does not call LLMs, create embeddings, rank search results or own prompt/RAG behavior.

Python API

from muscles_documents.config import SourceConfig
from muscles_documents.runtime import DocumentPipeline

pipeline = DocumentPipeline(
    key="documents",
    sources={
        "docs": SourceConfig(name="docs", type="local", path="./docs"),
    },
)

refs = pipeline.list_refs("docs")
blob = pipeline.load_blob("docs", refs[0].reference)
parsed = pipeline.parse_blob(blob)
normalized = pipeline.normalize(parsed)
chunks = pipeline.chunk(normalized, strategy="heading")
plan = pipeline.sync_plan("docs")

Scope

MVP is read-only: no writes to external systems are performed. Google Drive, PDF/DOCX, URL/HTTP and richer storage adapters are extension points for later package iterations; the current package keeps parser/source contracts stable for those additions.

Telemetry

muscles-documents resolves telemetry through the neutral Muscles TelemetryProvider; it does not import muscles-otel directly.

When a project registers a provider, document actions emit safe spans:

  • muscles.documents.source.list
  • muscles.documents.load
  • muscles.documents.parse
  • muscles.documents.normalize
  • muscles.documents.chunk
  • muscles.documents.sync.plan
  • muscles.documents.sync.execute
  • muscles.documents.inspect
  • muscles.documents.doctor

Allowed attributes include source name/type, MIME, parser and chunker metadata. Raw document text, HTML body, extracted text, file content, source credentials and tokens must not be stored in span attributes.

Examples

Local source smoke

Run a full documents.* action flow on temporary files:

PYTHONPATH=src python examples/run_documents_pipeline.py

Sync plan and request

Build and inspect a sync plan for configured sources:

PYTHONPATH=src python examples/run_documents_sync.py

Both examples:

  • initialize package via init_package(app, config);
  • use ActionDispatcher for actions;
  • demonstrate load, parse, normalize, chunk, sync.plan, sync.request, inspect, and doctor flows;
  • show neutral telemetry provider usage without requiring muscles-otel.

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

muscles_documents-0.1.1.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

muscles_documents-0.1.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file muscles_documents-0.1.1.tar.gz.

File metadata

  • Download URL: muscles_documents-0.1.1.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_documents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2977b4cb76dfc7d8cc2e73ab8b4ccce12bc6a04d9e223089e5856b258bd6d8be
MD5 98be4c4c0a76914787ed52a212596fec
BLAKE2b-256 66dd8886a15b364fb27958ec46f0ad076af1ea8d200050bc7b1f3d61ded08cfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_documents-0.1.1.tar.gz:

Publisher: release.yml on butkoden/muscles-documents

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

File details

Details for the file muscles_documents-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for muscles_documents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43b564dad2e5ee064c70180b7015459c17acb211c14573cb2bcacbb0cbc85645
MD5 b48679c857fc41b95872705519e223d2
BLAKE2b-256 059fb2ec9ea32aab328b4492163676e9f42f38fb688d50d22ab1918bcaa9b4c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_documents-0.1.1-py3-none-any.whl:

Publisher: release.yml on butkoden/muscles-documents

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