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.
| File | Holds |
|---|---|
lib.rs | Plugin::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.rs | FACTS and the Source impl |
venue.rs | FACTS (VenueFacts) and Arm (VenueArm); the order client sits beside it in exec/ |
link.rs | the link check (Auth) |
offer.rs | OFFER |
ratelimit.rs | the 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:
| Field | Says |
|---|---|
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, unclassed | the (class, product, Span) triples built, exactly; the products it answers with no symbols; those with no class |
sessions, words | the (class, session, products) past the regular session, an equity's or an option's; the words it honours that not every provider does |
fills | per (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, bars | the raw formats kept, their parser, the typed rows per product, the bars format and parser |
tiers, gated | the plan a key holds on each tier marker (atp, basic); the classes a plan decides |
permits, quote_batch, now_only, delayed_feeds | the gate's shared permits; symbols per quote call; products answered only as they stand now; feeds that serve late |
offer | Some(&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 inengine/crates/taji-open/Cargo.toml, and add itsPlugin::defaultinkernel()(engine/crates/taji-open/src/lib.rs), as.add(taji_alpaca::Plugin::default)does. - The arm.
engine/crates/taji-trading/src/arms.rsbinds it from the vault record over the login's one token store and budget set, and wraps it inQueued, the login'sWriteSlot. - The source.
FACTSis admitted at boot (engine/crates/taji-trading/src/hub/plugin.rs; testevery_source_is_named_by_its_provider_id). A source that reads futures'instrumentstates what a roll trades as (hub::trades_as; testevery_futures_bars_provider_states_what_a_roll_trades_as). - Raw storage. A product whose answer the store keeps returns
Raw: format<provider>.<product>.v1, arequestper vendor call and never a key, the pages as bytes.raw_readreads it and theparsethatFACTSnames parses it; follow the//!recipe inengine/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_rankinengine/crates/taji-trading/src/hub/products.rs; the data architecture). Where facts leave providers equal, Taji'sTiesorders them (BUILDinengine/crates/taji-open/ties/src/lib.rs, handed in byKernel::ties). A plugin never ranks itself, and the user'slink.prefer.datalist per class leads.Source::downsays 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.
5. Wire the link form
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
- One budget set per login, shared by its arm, hub and streamer (
arms.rs,ratelimit.rs). A bulk backfill builds its own withRateLimits::bulk, whose client waits out a release. Every set reads asGET /read/link/rate_limits. - One chokepoint admits every request.
taji_brokerage::queue::admitcharges every budget a request draws, all or none, never waiting.Kind::Readis refused at once when a budget is short or held, naming its release;Kind::Writeis charged into debt and refused only while the venue holds it. There is no read reserve. - Never resend a 429. Hold its budget (
Budget::hold) and answerRateLimited; 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_bytesinplugins/alpaca/src/lib.rs; testa_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. - 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'sclassify_submit_failure; testtransient_429_too_many_requests_is_ambiguous). What eachBrokerageErrormeans for whether an order exists isRejectReason::VenueRefused's table (substrate/stadium/src/gate.rs). - Venue headers outrank the estimate. A reply's counters re-seat the budget (
Budget::set_quota,Budget::observe). Alpaca readsX-RateLimit-*and holds a 429 toX-RateLimit-Reset, elseRetry-After, else two seconds. - Stream opens take a
Cap(queue::Cap::open), freed on drop. A multiplexed stream reports onestreamrow (Spend::symbols) of the distinct symbols it carries, with a quota only where measured or published. - 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_updatesinvenue.rs) wakes a read and carries no state; triggers mid-pass merge into one next pass. Clients read the record (ReadModel). - A write returns at the venue's answer.
Queuedholds the login'sWriteSlotfor the one adapter call, which answers off the venue's reply with no poll.StadiumHandle::submitandcancel_and_resolvewait on the record (substrate/stadium/src/actor.rs), not the venue. - One change feed.
NotifyingJournal(engine/crates/taji-trading/src/journal.rs) announces every append; the wire serves it as/ws/live. - History in pieces.
hub::servefetches 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 isRateLimitedPart: the bars that landed, theirfrom, 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 mostreach_shareat once;engine/crates/taji-trading/src/hub/gate.rscaps twice it. - 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 HTTPExecutionOpssends throughtaji_plugin::vendor::brokerage::http::order_client; testsa_pooled_client_does_not_follow_a_redirectand, per adapter,place_does_not_follow_a_redirecthold it. - An arm pins its host. Alpaca's paper arm refuses any base URL without
paper-api, its live arm any host butapi.alpaca.markets(assert_paper_base_url,assert_live_base_url; teststhe_paper_assert_refuses_every_non_paper_host,the_live_assert_refuses_every_non_live_host). - A listed order states what the venue's listing says.
asked_offillsAskedfrom the row: an option's open or close aseffect, a multi-leg row'slegsandnet, a group member's price and tranche, andfixedon an order the venue lets no other client modify. A field neither the vendor's docs nor a captured listing shows staysNone(testsa_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:
[
{"name": "coverage", "method": "GET", "route": "/read/data/coverage/crypto"},
{"name": "limits", "method": "GET", "route": "/read/link/rate_limits"}
]
GET /read/data/coverage/cryptoanswers how far back each history read reaches for the class.sourcesare the linked providers,extendthe unlinked: what linking each would add.GET /read/link/rate_limitsanswers 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
-
Unit. Test with
wiremockor the crate's fake, never a vendor. A 429 test asserts the request count, the hold and the next request refused unsent. -
Provider live suite. Run the adapter against the vendor's paper or demo host with no kernel, following the contract in the
//!ofsubstrate/taji-live/src/lib.rs. Write one test per order word and per data product, each printing aCELLline (seeplugins/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.shruns every vendor's suite and skips any vendor with no keys. -
Kernel walk. Drive a headless kernel phase by phase with a script (see
plugins/massive/scripts/massive_walk.py). It takes its state dir fromwalklog.state_dir(), which refuses whenTAJI_STATE_DIRis unset, so a walk never reaches your own Taji. -
Evidence. Change a measured cell or a figure on
plugins/<provider>/README.mdonly on dated suite or walk output; an inconclusive run leaves it unknown.
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,VenueFactsand 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 returnsRateLimitedPart. -
OFFERinoffer.rs; coverage regenerated. -
plugins/<provider>/README.mdwith its limits and 429 behaviour, and itsARCHITECTURE.md; the manifest'saboutline. -
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'smarkandb.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 listsreads,permitsorbars. Delete them;FACTSstates them.
Next
- The manifest reference: every table
taji-plugin.tomltakes. - Coverage: what each provider serves, cell by cell, rendered from
OFFER. - Alpaca's architecture: the worked example, end to end.
- Decision 0004: why a capability is a platform product, never a vendor's route.