Skip to main content

fieldworks-core

Core components for the Fieldworks industrial AI framework.

  • fieldworks.topology — load and validate topology.yaml (plant model schema, Part II)
  • fieldworks.agents — build_specialist_prompt(), build_specialists(), build_orchestrator_system(); fieldworks.agents.verdict holds the FINDINGS/SUMMARY output contract (spec Part III, Verdict Blocks) — the templates the prompts embed and parse(), the one parser for them
  • fieldworks.aggregator — load and validate aggregator.json (connection model, Part II)
  • fieldworks.memory — GraphClient/AnalyticalClient/SpecialistMemory (LadybugDB graph + DuckDB analytical + file-based specialist memory) and KnowledgeClient (DuckDB+VSS document retrieval/RAG over facility docs) — requires the memory/knowledge extras, see below
  • fieldworks.topology_builder — MQTT/OPC-UA discovery and topology inference (crawl_mqtt, crawl_opcua, infer_topology)
  • fieldworks.trust — propose/approve/execute intercept and hash-chained audit trail across the four trust modes
  • fieldworks.enterprise — load and validate enterprise.yaml (multi-plant registry, Part V) and federated_read() across plants; the cross-plant orchestrator's contract is in fieldworks.agents (build_enterprise_system(), ENTERPRISE_TOOLS)

Install

pip install fieldworks-core

Optional extras

Extra Adds Unlocks
memory ladybug, duckdb, influxdb-client, pytz GraphClient, AnalyticalClient, SpecialistMemory, MemoryClient
knowledge duckdb, fastembed, pypdf KnowledgeClient, FastEmbedProvider — document ingestion/retrieval (RAG)
adapters mcp>=2.0 fieldworks test-adapter CLI conformance checks
trust cryptography Hash-chained, encrypted audit log

memory and knowledge are independent — a docs-only deployment can pip install fieldworks-core[knowledge] without pulling in ladybug/influxdb-client.

pip install fieldworks-core[memory,knowledge]

Usage

from fieldworks.topology import load, validate
from fieldworks.agents import build_specialist_prompt, build_specialists

topology = load("topology.yaml")
result = validate(topology)
if result.warnings:
    for w in result.warnings:
        print(f"warning: {w}")

specialists = build_specialists(topology)

Knowledge/RAG over facility documentation (pip install fieldworks-core[knowledge]):

from fieldworks.memory import KnowledgeClient, KnowledgeConfig, FastEmbedProvider

knowledge = KnowledgeClient(
    KnowledgeConfig(db_path="knowledge.duckdb"),
    embedding_provider=FastEmbedProvider(),  # local ONNX, no API key
)
knowledge.ingest_directory("facility-docs/")  # .md, .txt, text-layer .pdf

excerpts = knowledge.query("what is the maximum flow rate for the intake pump?", top_k=3)

Service logging — a rotating logs/<name>.log next to the service plus the console, in one format (5 MB × 3 by default; FIELDWORKS_LOG_MAX_BYTES / FIELDWORKS_LOG_BACKUPS override):

from fieldworks.service_logging import setup_logging

setup_logging(__file__, "audit_mcp")  # console defaults to stderr; pass console=sys.stdout to change

.env checks — call just before load_dotenv() to log a warning when a key is defined on more than one line (python-dotenv uses the last) or when a shell export overrides the file. Keys and line numbers only, never values:

from dotenv import find_dotenv, load_dotenv
from fieldworks.service_env import check_env_file, env_source

check_env_file(find_dotenv())
load_dotenv()
env_source("ANTHROPIC_API_KEY")  # "the process environment" or "<path> line N"

Multi-plant enterprise (spec Part V). load() enforces the structural rules; validate() checks each site's topology_file declares the same facility.site_id:

from fieldworks.enterprise import load, validate, federated_read, SiteUnavailable

enterprise = load("enterprise.yaml")
result = validate(enterprise, base_dir=".")  # dir holding enterprise.yaml

async def fetch(site_id, site):           # your transport, one plant at a time
    if not site.aggregator_url:
        raise SiteUnavailable("no aggregator_url in enterprise.yaml")
    return await ask_plant_audit_history(site.aggregator_url)

history = await federated_read(enterprise.sites(), fetch, timeout=30)
history.records       # every plant's records, sorted by ts, each with site_id
history.unavailable   # {site_id: reason} — a dead plant is unknown, never "no history"

The cross-plant orchestrator's agentic loop and model client stay in the host, as Cascade's and Deadband's do; core provides its contract — build_enterprise_system(enterprise), ENTERPRISE_TOOLS (get_plant_status, diagnose_plant, nothing else), and format_plant_summary() / format_plant_unknown() for what each tool returns.

Verdict blocks (spec Part III). Specialist prompts end with the FINDINGS instruction and the orchestrator prompt carries the SUMMARY one, so a host only parses:

from fieldworks.agents.verdict import parse, most_severe_status

v = parse(response_text)              # last complete FINDINGS/SUMMARY block, or None
v["status"], v["confidence"], v["points"]
parse(text_so_far, final=False)       # while streaming: only once the block has closed
most_severe_status(["Normal", "Fault Detected"])   # unknown statuses rank ≥ "Anomaly Detected"

Air-gapped deployment

KnowledgeClient hits the network on first use for two things: DuckDB's vss extension (fetched from DuckDB's extension repository) and FastEmbedProvider's ONNX model weights (fetched from Hugging Face Hub, ~130MB for the default model). Both cache locally after the first fetch, so a deployment that pre-warms the cache while online never needs egress at runtime.

Pre-fetch once, online:

python -c "
from fastembed import TextEmbedding
TextEmbedding(model_name='BAAI/bge-small-en-v1.5', cache_dir='./vendor/fastembed')
"
python -c "
import duckdb
con = duckdb.connect()
con.execute(\"SET extension_directory = './vendor/duckdb-extensions'\")
con.execute('INSTALL vss')
"

Bake ./vendor/ into the deployment image, then point the client at it at runtime:

knowledge = KnowledgeClient(
    KnowledgeConfig(
        db_path="knowledge.duckdb",
        extension_directory="./vendor/duckdb-extensions",
    ),
    embedding_provider=FastEmbedProvider(
        cache_dir="./vendor/fastembed",
    ),
)

Set HF_HUB_OFFLINE=1 in the runtime environment to make the no-network guarantee explicit — fastembed respects it and fails loudly instead of attempting a network call if the cache is somehow cold.

No HNSW index in v1: DuckDB's HNSW index requires an experimental persistence flag for on-disk databases. A brute-force array_cosine_distance scan is correct and fast at facility-doc corpus scale (hundreds to low thousands of chunks); revisit if a deployment's corpus grows much larger.

CLI

fieldworks validate topology.yaml
fieldworks validate topology.yaml --aggregator aggregator.json
fieldworks test-adapter --command mqtt-mcp   # nine-tool contract, incl. readOnly/destructive tool annotations
fieldworks validate-enterprise enterprise.yaml   # Part V registry rules + each site's topology

Gotcha: MCP server lifespan= runs per SSE session, not per process

If you build an MCPServer (from the upstream mcp SDK) with a lifespan= context manager for one-time startup work — seeding a graph, starting a background sync task, ingesting docs — guard it. Under the SSE transport, Server.run() re-enters lifespan on every new connection, not once at process start. A client that opens a fresh SSE session per tool call (a common pattern) re-runs your "startup" code on every call, and if that includes asyncio.create_task(...), the tasks are never cancelled and leak without bound.

Guard with a module-level flag:

_started = False

@asynccontextmanager
async def _lifespan(server: MCPServer) -> AsyncIterator[None]:
    global _started
    if not _started:
        _started = True
        ...  # one-time startup work
    yield

This bit fieldworks-core#34: memory-mcp accumulated one AnalyticalClient.sync_loop() task per SSE session, degrading to DuckDB lock contention after enough tool calls. fieldworks-core doesn't wrap MCPServer itself today, so there's no framework-level code to patch — this note exists so the guard lands by default whenever memory-mcp's server.py is extracted into fieldworks/memory/. (mcp-aggregator was checked and is not exposed: it never passes lifespan= to the low-level Server, and its Starlette-level lifespan= runs once per process via the real ASGI lifespan protocol, not per connection.)

Metadata

Release files for fieldworks-core 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fieldworks-core 1.5.0
File Size Uploaded Provenance Actions
fieldworks_core-1.5.0.tar.gz 94.7 kB With provenance Details for fieldworks_core-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fieldworks-core 1.5.0
File Interpreter ABI Platform Actions
fieldworks_core-1.5.0-py3-none-any.whl Python 3 none any Details for fieldworks_core-1.5.0-py3-none-any.whl

Total release size: 173.9 kB

Release files / fieldworks_core-1.5.0.tar.gz

Download URL fieldworks_core-1.5.0.tar.gz
Size 94.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5e32bc8578d11a1394815552b34e4560f85db471ebbef94590b473a6d089bbf5
BLAKE2b-256 checksum
How to use checksums
c0ae9eb8ee020a78b11ee52d7c85c579f41b5cf52260259b5374648bc6c4e3b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / fieldworks_core-1.5.0-py3-none-any.whl

Download URL fieldworks_core-1.5.0-py3-none-any.whl
Size 79.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6985c47a662683525efe4c51386ee97e078f84cacb09be2056ef275f56172ed
BLAKE2b-256 checksum
How to use checksums
8f864767f6deb085244cd6777a448eae8439a71c3f9c24a4b32f30c621bd1500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for fieldworks-core 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fieldworks_core-1.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page