Metadata-Version: 2.5
Name: axiom-data-workflow
Version: 2.1.0
Summary: Core abstractions, base contracts, and payload containers for all user-defined and internal data workflows in the Axiom data pipeline.
Project-URL: Homepage, https://github.com/zephytiju/AxiomDataWorkflow
Project-URL: Repository, https://github.com/zephytiju/AxiomDataWorkflow.git
Author-email: Juntai Team <dev@juntai.com>
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: jsonschema>=4.23.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: polars>=1.0.0
Requires-Dist: pyarrow>=14.0.0
Requires-Dist: pydantic>=2.0.0
Description-Content-Type: text/markdown

# Axiom Data Workflow

[简体中文](README_zh.md) · [Development](DEVELOPMENT.md)

`axiom-data-workflow` is the independently released, runtime-neutral Python
contract package for Axiom workflows, portable external sources, source bindings,
source checkpoints, and raw-ingestion bundles. Definition, Runtime, connectors,
and local collectors consume the same immutable value models and conformance
fixtures.

The package does not select a storage Engine or Adapter. It contains no provider
messaging contract, physical table or bucket identity, Meridian binding, service
implementation, CLI storage, IaC object, or deployment authority.

## Portable v1 contracts

Supported imports are available from `juntai.sdk.axiom.data_workflow`:

- `WorkflowDefinition` publishes workflow identity, portable input/output
  contracts, BCP 47 language selection, and logical application-Resource
  requirements as `axiom.workflow/v1`.
- `ExternalSourceDescriptor` computes a canonical fingerprint from stable outside
  identity. Credentials, provider cursors, local paths, and Axiom-generated IDs
  are not fields in `axiom.external-source/v1`.
- `SourceBinding` maps one canonical source to accepted raw contracts, one of four
  checkpoint policies, and declared `REMOTE_ACQUISITION` / `SUPPLIED_RAW` paths.
- `SourceCheckpoint` describes one binding, source fingerprint, partition, and
  epoch. There is no heterogeneous pipeline-wide watermark.
- `RawIngressEnvelope`, `RawRecordReference`, and `CoverageReceipt` converge remote
  and supplied-raw inputs at one digest-addressed durable landing boundary.
- `IngestionManifest` and `validate_bundle` implement
  `axiom.ingestion-manifest/v1` for relative NDJSON, zstd NDJSON, and Parquet
  segments with exact schemas, sizes, record counts, and SHA-256 digests.

All models are frozen and reject undeclared fields. A physical `engine`, `adapter`,
provider topic, SQL statement, table, bucket, or deployment field therefore fails
validation instead of leaking into a portable publication.

## Language selection

`IngestionLanguages` accepts canonical BCP 47 tags. `resolve_language_plan` bounds
the requested subset and required features against one exact
`juntai.ingestion-language-capabilities/v1` document and immutable Configuration
reference.

```python
from juntai.sdk.axiom.data_workflow import (
    ExactConfigurationReference,
    IngestionLanguages,
    UniversalLanguageCapabilities,
    resolve_language_plan,
)

selection = IngestionLanguages(
    requested=("en", "es", "zh-Hans"),
    default="en",
    detection="detect-then-fallback",
    required_features=("normalize",),
)
universal = UniversalLanguageCapabilities.model_validate(universal_document)
plan = resolve_language_plan(
    selection,
    universal,
    ExactConfigurationReference.model_validate(exact_configuration_reference),
)
```

An unsupported tag or feature raises a stable `PortableContractError`. A later
platform capability expansion does not change an already resolved plan.

## Dual-path connectors

`DataConnectorWorkflow` is the provider-neutral declaration shared by connector
authors and runtime consumers:

```python
class SocialConnector:
    async def acquire_remote(self, source, checkpoint, context):
        ...  # yields RawIngressEnvelope values

    async def process_raw(self, raw, context):
        ...  # consumes a durable RawRecordReference
```

Remote acquisition lands raw bytes before `process_raw` runs. Portable imports
enter the same `process_raw` path after identity, raw-contract, digest, coverage,
and checkpoint validation. Supplied raw data never bypasses its published
connector route.

## Policy-bound application data

Workflows declare logical `ApplicationDataRequirements` and receive an
`ApplicationDataQueryProtocol`. Queries use resource aliases, logical predicates,
bounded selections, and cursor pagination. `authorize_query` verifies that a
resource, operation, and maximum result count were declared before a runtime
implementation evaluates the request against its policy-authorized Resource
handle.

These contracts expose neither a Meridian binding nor a physical query plan.

## Schemas and conformance fixtures

Canonical Draft 2020-12 JSON Schemas ship under the installed package's
`schemas/v1` directory. `load_packaged_json_schema` provides supported access to
those immutable artifacts.

The wheel also contains valid and invalid producer fixtures. Every consumer can
run the identical suite:

```python
from juntai.sdk.axiom.data_workflow import assert_packaged_conformance

results = assert_packaged_conformance()
```

The suite validates workflow, source, binding, checkpoint, and bundle examples;
it also proves deterministic rejection of unsupported languages and physical
provider fields.

## Offline bundle validation

```python
from juntai.sdk.axiom.data_workflow import validate_bundle

result = validate_bundle(
    "./osint-2026-08-23",
    universal_languages=universal_document,
    universal_reference=exact_configuration_reference,
)
```

Validation remains offline: it reads bundle files and exact policy inputs only.
It does not contact a provider, discover mutable source state, store credentials,
advance a Runtime checkpoint, or dispatch work.

## Compatibility contracts

The pre-2.1 workflow base classes, dataframe payloads, runtime-artifact helpers,
and production-service-shaped models remain importable for coordinated consumer
migration. They are compatibility surfaces, not the target portable publication
format. New Definition and Runtime work should use the v1 contracts above.

## Verification

```bash
uv sync --group dev
.venv/bin/python scripts/generate_portable_contract_artifacts.py
.venv/bin/python -m pytest
.venv/bin/ruff check src tests scripts
.venv/bin/python -m build
.venv/bin/python scripts/verify_clean_consumer.py
```

The release pipeline publishes the immutable `2.1.0` distributions through PyPI
Trusted Publishing and creates the matching GitHub release from the merged commit.

## License

See [LICENSE](LICENSE).
