Skip to main content

Architecture and package boundaries.

ContractForge is organized around one hard boundary: the core describes ingestion intent, and adapters translate that intent to platform-native behavior.

Layered flow

The core can plan without Spark, Databricks, boto3, Azure SDK, Fabric SDK or Snowflake clients. Platform libraries live in adapter packages only.

Core responsibilities

DomainCore owns
ContractsIngestion, annotations, operations, access and environment models.
SemanticsImmutable semantic contract objects and portable validation.
CapabilitiesCapability declarations, matching and planning statuses.
PlanningAbstract execution plans, blockers, warnings and review markers.
EvidenceNeutral evidence concepts and required fields for operational parity.
DiagnosticsPortability messages, validation errors and adapter authoring expectations.

The core should never contain branches such as if platform == "databricks". Use capability declarations and adapter behavior instead.

Adapter responsibilities

DomainAdapter owns
CapabilitiesWhat the platform can preserve, what requires review and what is unsupported.
RenderingNative SQL, Python, YAML, pipeline definitions, bundle files or review reports.
ExecutionOptional runtime execution against the target platform.
Evidence fillingPlatform-specific values passed into the core evidence API.
Governance applicationNative grants, row filters, masks, tags, comments and policy primitives.
Runtime dependenciesSDKs, Spark, platform clients, drivers and credential resolution.

Databricks is the reference adapter. It owns Delta, Unity Catalog, Auto Loader, Lakeflow, Databricks SQL, Asset Bundles, runtime helpers and Databricks-specific extensions.

Repository layout

src/
contractforge_core/
contracts/
semantic/
capabilities/
planner/
evidence/
connectors/
adapters/base/
adapters/
databricks/
src/
contractforge_databricks/
docs/
specs/
adrs/
site/
docs/
src/

Publication stays split:

DistributionContainsDepends on
contractforge-corecontractforge_coreNo platform adapter.
contractforge-databrickscontractforge_databrickscontractforge-core.
Future adapter wheelsOne adapter package eachcontractforge-core.

Public APIs

The stable core API is used by tooling, CI and adapter authors:

AreaExample entry points
Contract validationvalidate_contract, load_contract_bundle, compose_contract_sections
Semantic normalizationsemantic_contract_from_mapping
Planningplan_contract, PlanningResult, PlanningStatus
CapabilitiesPlatformCapabilities, NativeCapability
Adapter protocolPlatformAdapter, RenderedArtifacts

The Databricks adapter exposes Databricks-specific execution and rendering:

AreaExample entry points
Planning/renderingplan_databricks_contract, render_databricks_contract
Runtime executioningest_databricks_bundle, ingest_databricks_contract
EnvironmentDatabricksEnvironment, DatabricksIngestOptions

Design rules

  • Keep platform SDKs out of contractforge_core.
  • Prefer immutable semantic objects in planner-facing code.
  • Make unsupported semantics explicit.
  • Never silently downgrade write mode, governance behavior or evidence requirements.
  • Add docs, tests, capability mapping and adapter behavior for every new semantic concept.
  • Split modules by stable domain boundaries, not by convenience.

Extension path

To add a new platform adapter:

  1. Implement a capability declaration.
  2. Reuse core planning unless the adapter needs stricter diagnostics.
  3. Render native artifacts from the abstract plan.
  4. Fill the neutral evidence model with platform-specific values.
  5. Document supported, warning, review-required and unsupported behavior.
  6. Publish the adapter as its own wheel.

See Adapter authoring for the full contract.