Skip to main content

Write a compiled-in provider

You add a data source or a brokerage to Taji as a crate under plugins/<provider>/ that builds into the kernel, a tier 1 plugin (plugin tiers), and you see what the kernel reads off it before anyone links a key. You need a checkout built from source, the vendor's API spec and the manifest reference. A process plugin outside the tree is a data source instead.

The worked example throughout is plugins/alpaca (Alpaca): a bars and quotes source and a paper and live venue. How it is built on its vendor, and why, is its ARCHITECTURE.md; each vendor plugin has one (TradeStation's), headed as the template says, and your provider writes its own. Measured limits go on plugins/<provider>/README.md.

1. Create the crate​

Under plugins/<provider>/, add taji-plugin.toml (manifest), Cargo.toml, src/ and tests/. Put the crate's role in the //! header of src/lib.rs. Every client takes a base URL, so a test can point it at wiremock or a fake.

Lay out src/ as plugins/alpaca/src does. A data-only provider, such as plugins/databento/src, has no venue.rs or link.rs.

FileHolds
lib.rsPlugin::build: b.source(...); for a brokerage b.venue(venue::Arm) and b.auth(link::Auth); and the logo the manifest's mark = { file = "ui/mark.svg" } declares, b.mark(include_bytes!("../ui/mark.svg").as_slice())
source.rsFACTS and the Source impl
venue.rsFACTS (VenueFacts) and Arm (VenueArm); the order client sits beside it in exec/
link.rsthe link check (Auth)
offer.rsOFFER
ratelimit.rsthe login's budgets

A provider whose vendor library is Python (plugins/yahoo/src/yahoo.py, plugins/edgar/src/filings.py) runs it in its own confined process, taji_plugin::vendor::python::Worker, which answers plain JSON values.

2. Declare FACTS and OFFER​

The kernel reads what your provider is from statics and never probes it (engine/crates/taji-plugin/src/vendor/). End each literal with ..Facts::NONE (or ..VenueFacts::NONE), so it names only what differs.

Facts (engine/crates/taji-plugin/src/vendor/mod.rs) is one static FACTS in source.rs. The fields Alpaca sets:

FieldSays
id, seat"alpaca"; Seat::Venue, seated on the login a venue row seals (Seat::Keyless needs no credential, Seat::Key a data key)
reads, market_wide, unclassedthe (class, product, Span) triples built, exactly; the products it answers with no symbols; those with no class
sessions, wordsthe (class, session, products) past the regular session, an equity's or an option's; the words it honours that not every provider does
fillsper (class, product), the optional columns its rows fill, exactly: held by taji_plugin::vendor::assert_fills in a decode test over a documented-example body (figures made up), and served as fills on GET /read/data/coverage. A statistics row's are the Stat words it states, a day figure naming its session in ts_ref and an expiry_iv its expiration (the date's UTC midnight); state only what the vendor states, since Taji derives ratios, IV rank and IV percentile per provider at the read (substrate/taji-brokerage/src/derived.rs). A daily figure is stamped at its session date's UTC midnight, a sum over contracts only from a complete set, else no row
formats, parse, rows, barsthe raw formats kept, their parser, the typed rows per product, the bars format and parser
tiers, gatedthe plan a key holds on each tier marker (atp, basic); the classes a plan decides
permits, quote_batch, now_only, delayed_feedsthe gate's shared permits; symbols per quote call; products answered only as they stand now; feeds that serve late
offerSome(&OFFER)

VenueFacts (venue.rs): name and handle ("Alpaca" and "alpaca"; a row id spells the handle), records (the vault record for each Env: paper alpaca, live alpaca-live, no fallback between them), fee per class with its source and date, declared (the arm's capability and protection matrices), env_pair (the .env names of a paper pair), link (LinkFacts::of(LinkMethod::Key)) and offer.

OFFER (offer.rs) is what the vendor's own spec offers, not what Taji sends, and it routes nothing. Offer carries data (per class: the history, live and realtime products, with source and as_of), reach, fresh (stream or poll, hours, why a feed is late), unclassed and classless; VenueOffer carries trades, multi_leg, orders (order words, time in force, sessions, notional, fractional, short, per class) and measured. Each cell names its spec and the date it was read; a cell with no source stays None. A vendor with no published spec offers what its web app asks: record a HAR of each page and run python3 -I engine/crates/taji/scripts/har_ws.py <file.har>, which lists the REST paths with their query keys and each socket's subscriptions and sample rows, and prints no token.

reads, fills and OFFER are the only coverage you write; what the vendor offers that you do not read is ### Offered, not read in your ARCHITECTURE.md. engine/crates/taji/src/wire/coverage.rs renders it into coverage and docs/reference/coverage/<provider>.md, and engine/crates/taji/src/wire/coverage/panels.rs renders the panel table off the hub's routing. Regenerate them:

cargo test -p taji --lib wire::fixture::write_the_wire_fixture -- --ignored
pnpm --filter @taji/wire gen

3. Implement the traits​

Implement the brokerage and hub traits from taji_plugin::vendor::brokerage: ExecutionOps and VenueReads for a venue, HistoricalData for a bars source, LiveStream for a stream. A Source or VenueArm refuses with VendorError (engine/crates/taji-plugin/src/vendor/error.rs). A key whose plan does not cover a read answers PlanRefused; on live, TickEvent::PlanRefused.

Stadium reads the venue through ReconcileOps (substrate/stadium/src/reconcile_ops.rs), which every ExecutionOps provides.

A venue that keeps its own position groups answers them from VenueReads::groups and edits them through ExecutionOps::regroup. It implements both or neither: None, the default, leaves the account's groups to the kernel. A member names its instrument as InstrumentPosition::instrument_id spells it, never a venue's position id, and its quantity is signed. plugins/tradestation/src/groups.rs is the example, decoded from a captured stream tape under plugins/tradestation/tests/fixtures/positiongroups/.

4. Compose it into the kernel​

  • The kernel. List the crate in the root Cargo.toml's workspace members, depend on it in engine/crates/taji-open/Cargo.toml, and add its Plugin::default in kernel() (engine/crates/taji-open/src/lib.rs), as .add(taji_alpaca::Plugin::default) does.
  • The arm. engine/crates/taji-trading/src/arms.rs binds it from the vault record over the login's one token store and budget set, and wraps it in Queued, the login's WriteSlot.
  • The source. FACTS is admitted at boot (engine/crates/taji-trading/src/hub/plugin.rs; test every_source_is_named_by_its_provider_id). A source that reads futures' instrument states what a roll trades as (hub::trades_as; test every_futures_bars_provider_states_what_a_roll_trades_as).
  • Raw storage. A product whose answer the store keeps returns Raw: format <provider>.<product>.v1, a request per vendor call and never a key, the pages as bytes. raw_read reads it and the parse that FACTS names parses it; follow the //! recipe in engine/crates/taji-trading/src/hub/raw.rs.
  • Ranking. A joined product (engine/crates/taji-trading/src/hub/join.rs: earnings, fundamentals) ranks each field group (group_rank in engine/crates/taji-trading/src/hub/products.rs; the data architecture). Where facts leave providers equal, Taji's Ties orders them (BUILD in engine/crates/taji-open/ties/src/lib.rs, handed in by Kernel::ties). A plugin never ranks itself, and the user's link.prefer.data list per class leads. Source::down says why a source serves nothing until restarted, so routing passes it over unpinned.

Every capability is a DataProduct row or a seam trait's answer, never a surface of the provider's own (0004). What fits neither is a line in plugins/<provider>/README.md, never a route.

The manifest's [[link]] tables name the fields the user types. link.rs checks them, and the kernel seals them in the vault (engine/crates/taji-secrets, engine/crates/taji/src/entitlements/). Secrets enter only through the window's link sheet or taji-link; never print or log a key or token, or put one in a URL or an error (0005).

6. Follow the request rules​

  1. One budget set per login, shared by its arm, hub and streamer (arms.rs, ratelimit.rs). A bulk backfill builds its own with RateLimits::bulk, whose client waits out a release. Every set reads as GET /read/link/rate_limits.
  2. One chokepoint admits every request. taji_brokerage::queue::admit charges every budget a request draws, all or none, never waiting. Kind::Read is refused at once when a budget is short or held, naming its release; Kind::Write is charged into debt and refused only while the venue holds it. There is no read reserve.
  3. Never resend a 429. Hold its budget (Budget::hold) and answer RateLimited; the caller decides. Send a write once. A read retries a timeout, a failed connect, a 5xx or a body-read fault up to five times, re-admitted each attempt (fetch_bytes in plugins/alpaca/src/lib.rs; test a_get_429_is_rate_limited_and_never_resent). The 401 refresh and its one resend belong to auth; a streamer's reconnect backoff is a redial.
  4. Classify each 429. A 429 before the venue takes a write is a definite refusal, RateLimited; one that may follow a landed order is outcome unknown, AckedUnconfirmed, resolved by a read (Alpaca's classify_submit_failure; test transient_429_too_many_requests_is_ambiguous). What each BrokerageError means for whether an order exists is RejectReason::VenueRefused's table (substrate/stadium/src/gate.rs).
  5. Venue headers outrank the estimate. A reply's counters re-seat the budget (Budget::set_quota, Budget::observe). Alpaca reads X-RateLimit-* and holds a 429 to X-RateLimit-Reset, else Retry-After, else two seconds.
  6. Stream opens take a Cap (queue::Cap::open), freed on drop. A multiplexed stream reports one stream row (Spend::symbols) of the distinct symbols it carries, with a quota only where measured or published.
  7. Stadium is the only reader of the account and its orders. Per account, one refresh loop (spawn_reconcile_driver, engine/crates/taji-trading/src/root.rs) lists orders once per pass. The venue's push (trade_updates in venue.rs) wakes a read and carries no state; triggers mid-pass merge into one next pass. Clients read the record (ReadModel).
  8. A write returns at the venue's answer. Queued holds the login's WriteSlot for the one adapter call, which answers off the venue's reply with no poll. StadiumHandle::submit and cancel_and_resolve wait on the record (substrate/stadium/src/actor.rs), not the venue.
  9. One change feed. NotifyingJournal (engine/crates/taji-trading/src/journal.rs) announces every append; the wire serves it as /ws/live.
  10. History in pieces. hub::serve fetches missing pieces, one per series at a time, each merged under the series lock (engine/crates/taji-trading/src/hub/store.rs). A refusal after part of a range is RateLimitedPart: the bars that landed, their from, and when the rest may be asked. A paged adapter walks latest first, so what landed is [from, end). A reach or scroll-back puts every chunk in flight, at most reach_share at once; engine/crates/taji-trading/src/hub/gate.rs caps twice it.
  11. A client lives with its login, and an order client never follows a redirect. An adapter holds its reqwest::Clients beside the login's token store and budgets, one per login, never per call. Every HTTP ExecutionOps sends through taji_plugin::vendor::brokerage::http::order_client; tests a_pooled_client_does_not_follow_a_redirect and, per adapter, place_does_not_follow_a_redirect hold it.
  12. An arm pins its host. Alpaca's paper arm refuses any base URL without paper-api, its live arm any host but api.alpaca.markets (assert_paper_base_url, assert_live_base_url; tests the_paper_assert_refuses_every_non_paper_host, the_live_assert_refuses_every_non_live_host).
  13. A listed order states what the venue's listing says. asked_of fills Asked from the row: an option's open or close as effect, a multi-leg row's legs and net, a group member's price and tranche, and fixed on an order the venue lets no other client modify. A field neither the vendor's docs nor a captured listing shows stays None (tests a_listed_option_orders_position_intent_is_its_asked_effect, a_listed_spread_states_its_legs_and_net).

7. Read what the kernel takes from it​

Before anyone links a key, a kernel already serves what your statics declare. At the checkout's root, build Taji (cargo build --locked -p taji-open) and boot it headless on new state, so it holds no key of yours:

export TAJI_STATE_DIR=$(mktemp -d) TAJI_STORE_DIR=$(mktemp -d) TAJI_HOME=$(mktemp -d) TAJI_WIRE=0
TAJI_HEADLESS=1 target/debug/taji &

The kernel writes its port to $TAJI_STATE_DIR/wire-port and its token to $TAJI_STATE_DIR/wire-token (the wire reference). Send two reads, each with the token in x-taji-token:

calls.json
[
{"name": "coverage", "method": "GET", "route": "/read/data/coverage/crypto"},
{"name": "limits", "method": "GET", "route": "/read/link/rate_limits"}
]
  1. GET /read/data/coverage/crypto answers how far back each history read reaches for the class. sources are the linked providers, extend the unlinked: what linking each would add.
  2. GET /read/link/rate_limits answers one row per login holding a rate scope this run.

The crypto coverage:

{
"class": "crypto",
"default_session": "regular",
"rows": [
{
"product": "bars",
"granularity": "D",
"from": null,
"sources": [
{
"source": "yahoo",
"from": null,
"adjustment": "split",
"total_return": false,
"sessions": [
"regular"
],
"history": "range",
"rolling_days": null
}
],
"extend": [
{
"link": "alpaca",
"from": "2021-01-01",
"cost": "free",
"history": "range"
},
{
"link": "tradestation",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "robinhood-web",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "range"
}
]
},
{
"product": "bars",
"granularity": "1m",
"from": null,
"sources": [
{
"source": "yahoo",
"from": null,
"adjustment": "split",
"total_return": false,
"sessions": [
"regular"
],
"history": "range",
"rolling_days": null
}
],
"extend": [
{
"link": "alpaca",
"from": "2021-01-01",
"cost": "free",
"history": "range"
},
{
"link": "tradestation",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "robinhood-web",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "range"
}
]
},
{
"product": "trades",
"granularity": null,
"from": null,
"sources": [],
"extend": [
{
"link": "alpaca",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "range"
}
]
},
{
"product": "quotes",
"granularity": null,
"from": null,
"sources": [],
"extend": [
{
"link": "alpaca",
"from": null,
"cost": "free",
"history": "range"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "range"
}
]
},
{
"product": "screener",
"granularity": null,
"from": null,
"sources": [],
"extend": [
{
"link": "alpaca",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "today"
}
]
},
{
"product": "search",
"granularity": null,
"from": null,
"sources": [
{
"source": "yahoo",
"from": null,
"adjustment": null,
"total_return": false,
"sessions": [],
"history": "today",
"rolling_days": null
}
],
"extend": [
{
"link": "tradestation",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-agentic",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-web",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "today"
}
]
},
{
"product": "instrument",
"granularity": null,
"from": null,
"sources": [
{
"source": "yahoo",
"from": null,
"adjustment": null,
"total_return": false,
"sessions": [
"regular"
],
"history": "today",
"rolling_days": null
}
],
"extend": [
{
"link": "alpaca",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "tradestation",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-agentic",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-web",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "today"
}
]
},
{
"product": "details",
"granularity": null,
"from": null,
"sources": [
{
"source": "yahoo",
"from": null,
"adjustment": null,
"total_return": false,
"sessions": [
"regular"
],
"history": "today",
"rolling_days": null
}
],
"extend": [
{
"link": "alpaca",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "tradestation",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-agentic",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "robinhood-web",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "massive",
"from": null,
"cost": "free",
"history": "today"
},
{
"link": "ibkr",
"from": null,
"cost": "free",
"history": "today"
}
]
}
]
}

yahoo, keyless, is the one linked source of crypto bars. alpaca sits in extend for bars at D and 1m, from 2021-01-01, and for trades, quotes, screener, instrument and details: its FACTS and OFFER, read with no key. Linking it moves it to sources.

The rate limits:

{
"logins": [
{
"provider": "cboe-daily",
"login": "process",
"limits": []
},
{
"provider": "databento",
"login": "process",
"limits": [
{
"name": "timeseries",
"kind": "rate",
"draws": [
"bars",
"trades",
"quotes",
"depth"
],
"used": 0,
"quota": 100,
"window_s": 1,
"basis": "published",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
},
{
"name": "symbology",
"kind": "rate",
"draws": [
"reference"
],
"used": 0,
"quota": 100,
"window_s": 1,
"basis": "published",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
},
{
"name": "metadata",
"kind": "rate",
"draws": [
"reference"
],
"used": 0,
"quota": 20,
"window_s": 1,
"basis": "published",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
},
{
"name": "batch_list",
"kind": "rate",
"draws": [
"bars"
],
"used": 0,
"quota": 20,
"window_s": 1,
"basis": "published",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
},
{
"name": "batch_submit",
"kind": "rate",
"draws": [
"bars"
],
"used": 0,
"quota": 20,
"window_s": 60,
"basis": "published",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
},
{
"name": "batch_files",
"kind": "rate",
"draws": [
"bars"
],
"used": 0,
"quota": null,
"window_s": 60,
"basis": "unbounded",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
}
]
},
{
"provider": "edgar",
"login": "process",
"limits": [
{
"name": "requests",
"kind": "rate",
"draws": [
"filings",
"fundamentals",
"holdings"
],
"used": 0,
"quota": null,
"window_s": 60,
"basis": "unbounded",
"frees_utc": null,
"clears_utc": null,
"held_until_utc": null,
"debt": 0
}
]
},
{
"provider": "yahoo",
"login": "process",
"limits": []
}
]
}

Each row is one login's budget set (request rule 1). Four sources hold a process login this run: cboe-daily and yahoo with limits: [], databento and edgar with budgets whose basis says where each quota comes from (published, unbounded). alpaca has no row: nothing linked it this run, so no login of it holds a rate scope.

Captured 2026-12-03 on a keyless headless kernel.

Stop the kernel with target/debug/taji quit.

8. Test it​

  1. Unit. Test with wiremock or the crate's fake, never a vendor. A 429 test asserts the request count, the hold and the next request refused unsent.

  2. Provider live suite. Run the adapter against the vendor's paper or demo host with no kernel, following the contract in the //! of substrate/taji-live/src/lib.rs. Write one test per order word and per data product, each printing a CELL line (see plugins/ibkr/tests/live.rs). It needs the vendor's key. Run one vendor with:

    cargo test -p <package> --test live -- --ignored --test-threads=1 [filter]

    engine/crates/taji-open/scripts/vendor_live.sh runs every vendor's suite and skips any vendor with no keys.

  3. Kernel walk. Drive a headless kernel phase by phase with a script (see plugins/massive/scripts/massive_walk.py). It takes its state dir from walklog.state_dir(), which refuses when TAJI_STATE_DIR is unset, so a walk never reaches your own Taji.

  4. Evidence. Change a measured cell or a figure on plugins/<provider>/README.md only on dated suite or walk output; an inconclusive run leaves it unknown.

danger

A live suite places orders on paper or demo hosts only: quantity 1, a resting price at least 30% from the last, every order cancelled in its test, and any fill sold back; taji-live's guard enforces this. A venue with no paper account (Schwab) skips its order tests unless SCHWAB_LIVE_ORDERS=1 (engine/crates/taji-open/tests/schwab_live.rs), and every order it then places is real.

Before you land it​

  • The crate with its manifest and FACTS; a venue's traits, VenueFacts and arm; a key's link form.
  • One budget set per login through queue::admit; a 429 held, never resent.
  • Each 429 classified, with a test per class.
  • Venue writes and account reads following request rules 7 and 8.
  • A bars source through hub::serve; a refused later page returns RateLimitedPart.
  • OFFER in offer.rs; coverage regenerated.
  • plugins/<provider>/README.md with its limits and 429 behaviour, and its ARCHITECTURE.md; the manifest's about line.
  • agent/skills/taji/references/ updated where the agent's view changed.
  • A not-entitled answer returns PlanRefused.
  • No surface of its own (step 4).

If it fails​

  • plugin `<provider>` declares `mark` in its taji-plugin.toml, but registers no bytes for it with Build::mark, or the reverse, registers bytes with Build::mark, but its taji-plugin.toml declares no `mark` : the manifest's mark and b.mark(...) come together. Add the one you lack.
  • source <provider>: a compiled-in source's facts are its code's; [[sources]] holds id alone: your manifest's [[sources]] row lists reads, permits or bars. Delete them; FACTS states them.

Next​