Field Guide

05 · Field guide

FabricLedgerSDK

Compile the minimum sufficient context before the prompt goes out.

Ready

What it does

FabricLedgerSDK is the library form of the governance layer. Before a prompt leaves your runtime it compiles a minimum sufficient context package against a token budget, scrubs secrets, and checks the tool call against declared boundaries.

Enforcement lives in a local sidecar process rather than in the library, so policy decisions are made outside the code that is being governed.

The doctor command is deliberately useful before the sidecar is running: it reports the SDK's own configuration — mode, budget, sync, tenant token — so you can confirm wiring in isolation.

Who it’s for

Teams embedding governance directly into an agent runtime.

What you need

  • ·Node.js 20 or newer
  • ·Local sidecar binary for enforcement (optional for doctor)

Quick start

# install & run$ npm install @contextecf/fabric-ledger-sdk$ npx fabric-ledger doctor

Requires Node.js 20+. doctor reports SDK config even before the local sidecar binary is running.

Step by step

  1. 01

    Add the SDK to your runtime

    Install as a project dependency, not globally — configuration is per-runtime.

    $ npm install @contextecf/fabric-ledger-sdk
  2. 02

    Check configuration first

    doctor prints mode, sidecar URL, context budget, sync state, and tenant token status without requiring the sidecar.

    $ npx fabric-ledger doctor
  3. 03

    Start the sidecar when you want enforcement

    Until the sidecar is running on 127.0.0.1:47321, doctor will report it unavailable — that is expected, not a failure.

  4. 04

    Tune the context budget

    The default 4096-token budget is the lever: it forces the SDK to compile the minimum sufficient package instead of everything available.

What you’ll see

FabricLedgerSDK doctorMode: standalone local sidecarSidecar health: unavailableSidecar error: FabricLedgerSDK sidecar unavailable at http://127.0.0.1:47321: fetch failedSidecar URL: http://127.0.0.1:47321Context budget: 4096Fabric sync enabled: noTenant token configured: no

"Sidecar unavailable" is expected here — the doctor command reports config even before you've started the local sidecar binary separately.

If something goes wrong

Sidecar health is unavailable.

Expected until you start the sidecar binary separately. doctor reports SDK configuration regardless.

Tenant token configured: no.

Standalone local mode does not need one. A tenant token is only required when syncing to a hosted Fabric.