Skip to main content

taji-plugin/1

Source of truth: schema/taji.json; schema_defs_documented (engine/crates/taji/tests/docs.rs) holds this page to it.

One JSON object a line over the process's stdin and stdout, in both directions: Hello, HelloAnswer, KernelMessage (kernel to process; its load and call go to a compiled-in plugin's worker only) and PluginMessage. Either side ignores a key it does not know. A line is 16 MiB at most before its newline.

The process​

A process starts at its first call. Its working directory is $TAJI_PLUGINS/<dir>/, which holds the manifest and the program; run[0] is relative to it, never outside.

Its environment is cleared first, then set:

VariableValueWhen
HOME<state dir>/plugins/<id>/dataalways
TMPDIR<state dir>/plugins/<id>/tmpalways
TAJI_PLUGINits idalways
HTTPS_PROXY, HTTP_PROXYhttp://127.0.0.1:<port>, on Linux http://10.0.2.2:<port>[grants] net.hosts or [sign_in]
https_proxy, http_proxy, ALL_PROXY, all_proxythe sameas above, on macOS and Linux
FTP_PROXY, ftp_proxythe sameas above, on Linux
SSL_CERT_FILE/private/etc/ssl/cert.pemas above, on macOS
TAJI_RELAY1; the relay is on the proxy's listener[sign_in]
TAJI_SITEits lock's packages[process.python] with a lock
SystemRoot, LOCALAPPDATAthe system's (LOCALAPPDATA else HOME's directory)Windows
USERPROFILE, TEMP, TMPHOME's and TMPDIR's directoriesWindows

There is no PATH. stderr is its log, <state dir>/plugins/<id>/log. Under Python, fd 1 is too; taji.send(msg) sends protocol lines.

EventResult
No hello in 30 soff until the next boot
A call unanswered in call_timeout_sthat call answers 504 timeout; the process keeps running
Ten non-JSON lines in a rowexit
A line over 16 MiBexit
A ping unanswered in call_timeout_s (sent every 10 s while it streams; any answer counts)exit
An exitcalls in flight answer 502 plugin_exited
A call after an exit502 plugin_exited naming the seconds left, for 1, 2, 4, then 8 s (doubling per exit in 10 minutes); the first call after the wait (while streaming, the wait's end) restarts it
A fifth exit in 10 minutesoff until the next boot

Handshake and calls​

Hello​

The process says it first.

KeyTypeMeaning
hello"taji-plugin/1"the protocol
idstringequals the manifest's
versionstringthe plugin's version

HelloAnswer​

KeyTypeMeaning
hello"taji-plugin/1"the protocol
tajistringthe contract version the kernel speaks
loginobject or null, absent without [sign_in]{id, label, secrets}: id is <plugin id>.<16 hex>, secrets a marker (taji-ref-<32 hex>) per admitted field, never a value; null while unlinked or locked
→ {"hello":"taji-plugin/1","id":"acme","version":"0.1.0"}
← {"hello":"taji-plugin/1","taji":"0.7.0","login":{"id":"acme.<16 hex>","label":"…","secrets":{"key":"taji-ref-<32 hex>"}}}

KernelMessage: calls​

A call is {"id": n, <kind>: body}. The process answers {"id": n, "ok": …} or {"id": n, "refusal": …} (Errors).

KindBodyAnswer ok
verb{route, bindings, args}: the [[kernel.verbs]] route, its {name} segments as called, the bodythe verb's answer
reada ReadAsk (Row shapes){"rows": [...]}; chains: {"rows": [...], "spot"?}
subscribe{subs: [SubAsk]} (Streams){}
check{}; sent to a [sign_in] plugin only{}
ping{}; sent every 10 s while it streams a subanything, a refusal included
load{module, file, source}; a compiled-in plugin's worker only{}
call{module, lane, name, args, within}; a compiled-in plugin's worker onlythe function's JSON answer; refused 404 no_module, 429 rate_limited, 504 timeout or 500 python

A call of a kind the process does not serve is refused 400 unknown_kind.

PluginMessage: unasked​

The process sends these with no top-level id.

KeyBodyMeaning
set{node, value}a declared [[kernel.nodes]] path's new value
push{sub, rows}rows of a sub (Streams)
end{sub, status, reason}a sub is over
shut{sub, reason}a sub publishes nothing now
ask{"ask": n, <kind>: body}a read of the hub: get, stream or unsubscribe; n is the process's own counter

Asks​

An ask is answered {"ask": n, "ok": …} or {"ask": n, "refusal": …}. Keep reading stdin while an ask waits: the kernel may call your read. Eight asks may wait; a ninth drops unanswered, and nine dropped in a row stop the process.

get: {"ask": n, "get": {"product", "query", "rows"?}} is GET /get/<product>?<query>.

rowsok
absent or false{"status", "content_type", "body_b64"}: the reply's body, base64; an Arrow IPC stream for rows, JSON where content_type says so
true{"rows", "knowable_utc", "spot"?, "scope"?}: Arrow decoded, one object a row keyed by column name; a JSON reply is refused 400 bad_ask

Python's await p.get(product, query) sends no rows and answers the first form; taji-sdk's Cx::get sends rows: true.

stream: {"ask": n, "stream": {"product", "query"}}. chains, depth and trades stream, granted and queried as a get (an equity's trades or depth naming no session reads 24h, every print and book; name one to narrow it). Answered {"ask": n, "ok": {"feed": n}}; 16 feeds may be open. A feed's frames follow.

unsubscribe: {"ask": n, "unsubscribe": {"feed": m}}. Answered ok {}; no frame of the feed follows.

An end frame, an unsubscribe or your exit closes a feed.

→ {"ask":4,"stream":{"product":"trades","query":"symbols=equity:SPY"}}
← {"ask":4,"ok":{"feed":4}}
← {"feed":4,"seq":1,"knowable_utc":1764500060,"knowable_ms":1764500060123,"rows":[{…},{…},{…}]}
← {"feed":4,"gap":{"from_seq":4,"to_seq":6}}
← {"feed":4,"end":{"status":403,"error":"plan","reason":"…"}}
→ {"ask":5,"unsubscribe":{"feed":4}}
← {"ask":5,"ok":{}}

Feed frames​

FrameKeysMeaning
rowsfeed, seq, knowable_utc, knowable_ms (epoch ms), rows; symbol (a depth frame: its book), spot, scope (a depth book's {"levels", "venues"}, as GET /get/depth states it, its own symbol's)rows, spot and scope as a get with rows: true answers them
gapfeed, gap: {from_seq, to_seq}trades rows Taji could not hold; their numbers are taken
shutfeed, knowable_ms, knowable_utc, shut: {symbol, reason}; no seqa depth symbol's book is gone, the feed open
endfeed, end: {status, error, reason}the feed is over; nothing follows

A frame waits until you have read the one before it; Taji drops none.

Productseqevery (seconds to the millisecond)
chainscounts frames from 1, never a gap1 to 3600, default 60
depthcounts frames from 10.25 to 3600; absent: a frame per book update
tradesnumbers a frame's first row, from 1refused: trades is lossless

every out of range is refused 400 bad_ask with every is seconds to the millisecond, 0.25 to 3600 on depth, 1 to 3600 on chains: not `<raw>` .

chains frames at most one snapshot for each every cell of UTC. A cell's frame goes out once Taji holds every underlying's spot, or at the cell's close without it; later updates of a cell fold into the next frame. spot is the underlying's price, stated only when the feed has one underlying and Taji holds its spot.

trades is lossless. A gap before the next frame names the rows Taji could not hold.

depth takes ticks and levels, each 1 to 1000, as GET /get/depth does: ticks sums orders by price onto rows that are multiples of step; levels keeps each side's best rows. Without ticks, rows go as sent and peak and step are null. A frame is one symbol's book, named in symbol.

WithA frame
everygoes out at each close of the UTC grid for every known symbol (a book seen since open or its last shut), unchanged ones too; knowable_ms and each row's ts_init are the close. A book on another tick grid closes its symbol's slice at once. With ticks too, it holds every row seen in the slice: live rows first, best first, level 0 up, then rows pulled meanwhile (size 0) by price, each with its peak, its largest size in the slice. Taji keeps one closed slice waiting, so a slower reader loses whole slices, never one symbol's
no everygoes out per book at its receipt, peak null; a newer book replaces its symbol's unsent one

A lapsed book does not end a depth feed. Taji frames the symbol's open slice, then sends a shut frame, drops the book and reopens the symbol after 1 s, doubling to 60 s, until a book comes. On shut push nothing and send {"shut": {"sub", "reason"}} (Sub::shut in the Rust SDK); the next row resumes.

Where no linked source streams the product, Taji reads now at open and at each multiple of every (60 s for depth without one). A depth every under 1 s is then refused 400 bad_ask. A cell whose read answers 408, 429 or a 5xx other than 501 is skipped, and the third such cell in a row ends the feed; any other refusal ends it.

Row shapes​

A read call carries a ReadAsk; every key is present.

KeyTypeMeaning
sourcestringthe [[sources]] id asked
productstringthe product
classstringthe instrument class
askedstring or nullthe item's key; null where the read names no item
frominteger or nullUTC seconds, inclusive; null open
tointeger or nullUTC seconds, exclusive; null open
limitinteger or nullthe most rows asked; null no limit
wordsobject of stringsthe product's other words, as asked
← {"id":7,"read":{"source":"acme","product":"acme.levels","class":"index","asked":"$TOY","from":1704067200,"to":1706832000,"limit":null,"words":{}}}
→ {"id":7,"ok":{"rows":[{"ts_utc":1704153600,"price":"20.25","size":100.0}]}}

asked is the item's canonical uppercase key:

Classasked
equitythe symbol (SPY)
indexthe symbol with $ ($TOY, even for index:TOY)
future<ROOT><M><yy> (ESZ26)
optionOCC
future_option<contract>
crypto, forexBASE/QUOTE

On chains, asked is the underlying's key. Answer rows in [from, to), never in your product's history.

A row off its $def refuses the answer, naming the row (row <i>: <why>). A decimal below is a string.

IndexDailyRow​

A day of one index, read at index_daily. The hub stores index_daily and bars answers.

KeyTypeMeaning
symbolstringequals asked
ts_utcintegerthe date's 00:00 UTC, seconds
open, high, lowdecimal or nullnull where the index states none
closedecimal
knowable_utcintegerUTC seconds from which the row is known

BarRow​

A bars read (words: timeframe, session, adjustment) and a bars push. Rows are closed bars on the grid: ts_utc a whole minute at 1m, a trading day's 00:00 UTC at D; ascending inside [from, to) without a duplicate. A row off the grid or out of order refuses the answer.

KeyTypeMeaning
ts_utcintegerthe bar's open, UTC seconds
open, high, low, closedecimal
volumedecimal or null, never negativenull where the vendor states none, held as 0
vwapdecimal or nullnull where the vendor gives none
trade_countdecimal or null, never negativenull where the vendor gives none
closedbooleana pushed row: false while the bar forms (the next push of its ts_utc replaces it); absent or true once final. A read answers final bars only

Declare bars = { timeframes = [...] } on the source, a subset of 1m and D: the hub folds 5m, 30m, 1h and 4h from 1m; an undeclared timeframe is never asked.

QuoteRow and TradeRow​

A quotes read at now answers at most one QuoteRow (book top) and one TradeRow (last print). A row with a price is the TradeRow. The kernel sets symbol, class, provider and receipt time.

QuoteRow keyTypeMeaning
bid_price, ask_pricedecimal or nullnull where the vendor gives none
bid_size, ask_sizedecimal or null, never negative
ts_eventstring or nullthe vendor's stamp, UTC nanoseconds
delayedboolean or nullwhether the vendor says the row is delayed
haltedboolean or nullwhether the vendor says the item is halted
sessionpre, regular, post, 24h or nullthe session the vendor says the quote is of
TradeRow keyTypeMeaning
pricedecimalrequired
sizedecimal or null, never negative
exchangestring or nullan ISO 10383 MIC, only where the vendor states one
conditionsarray of stringsthe vendor's condition codes as text
ts_eventstring or nullthe vendor's stamp, UTC nanoseconds
delayedboolean or nullwhether the vendor says the row is delayed
aggressorbuy, sell or nullthe side that initiated the print, only where the vendor states it; never a tick-rule estimate
off_exchangeboolean or nulltrue reported to a FINRA facility (TRF, ADF, ORF), false an exchange print

DepthRow​

A depth read at now answers the whole book, one row a level of a side; send no symbol. A depth push is the whole book too.

KeyTypeMeaning
sidebid or askrequired
levelinteger0 the best; required
pricedecimalrequired
sizedecimal or null, never negative
countinteger or nullorders at the level
ts_eventstring or nullthe vendor's stamp, UTC nanoseconds

ChainRow​

A chains read (class option, asked the underlying, words the ask's chain words) answers {"rows": [ChainRow], "spot": "187.20"}, the optional spot the underlying's price. A ChainRow states only the vendor's figures; the kernel derives the rest. A contract not an option of the underlying refuses the answer.

KeyTypeMeaning
contractstringrequired; an OCC symbol of the underlying
bid, ask, last, iv, delta, gamma, theta, vega, rhodecimal or nullnull where the vendor gives none
volume, open_interestinteger or null, never negative
tradableboolean or null
tsstring or nullthe vendor's stamp, UTC nanoseconds

EarningsRow​

An earnings read (class equity, asked the symbol) answers {"rows": [EarningsRow]}, read at history and keyed by ts_utc. A row states only what the vendor states. The kernel adds item, name, primary, provider, revenue_estimate_provider, revenue_actual_provider, eps_surprise, eps_surprise_pct, revenue_surprise and revenue_surprise_pct; a row that states any of them refuses the answer.

KeyTypeMeaning
symbolstringequals asked
ts_utcintegerreport_date's 00:00 UTC, seconds
report_datestringthe report's New York date, YYYY-MM-DD
knowable_utcinteger, at least 1UTC seconds from which the row is known: a scheduled report's announcement, a reported one's release
timing"bmo", "amc" or nullbefore the open or after the close
fiscal_yearinteger or nullthe fiscal year the quarter belongs to
fiscal_period"Q1" to "Q4" or nullthe fiscal quarter
eps_estimate, eps_actualdecimal or nullthe consensus and the reported EPS; eps_actual is null until reported
revenue_estimate, revenue_actualdecimal or nullwhole US dollars
verifiedboolean or nullfalse: the date is tentative
← {"id":8,"read":{"source":"acme","product":"earnings","class":"equity","asked":"TOY","from":null,"to":null,"limit":null,"words":{}}}
→ {"id":8,"ok":{"rows":[{"symbol":"TOY","ts_utc":1706140800,"report_date":"2024-01-25","knowable_utc":1706216700,"timing":"amc","fiscal_year":2023,"fiscal_period":"Q4","eps_estimate":"2.00","eps_actual":"2.10"}]}}

Column and ProductRow​

A [[products]] row is the product <id>.<name>, served by your [[sources]] alone, read as GET /get/<id>.<name> and streamed on /ws/market. A ProductRow is an object of exactly its Columns; a row with another key is refused by row and key.

Column keyTypeMeaning
namestring, ^[a-z0-9_]+$the key in each row
typestring, int, float, decimal, bool, date, list<float>, list<decimal>, list<int>its JSON form in a row
nullableboolean, default falsewhether a row may hold null; else null or absent is refused
unitprice, usd, shares, contracts, ratio, percent, countwhat its numbers count; not on string, bool or date
estimatedboolean, default falsecomputed under the product's model, not observed
docstringone sentence on what it holds
typeIn a rowAs Arrow
stringa JSON string
intan integer, never a string or a fractionInt64
floata numberFloat64
decimala decimal string, never a numberDecimal128(38, 10)
boola boolean
dateYYYY-MM-DD
list<float>, list<decimal>, list<int>an array of that item's form, items never null

At history a product declares ts_utc, a non-nullable int of epoch seconds. The kernel adds knowable_utc, recorded and version; at= cuts on knowable_utc.

  • A pushed row's knowable_utc is its receipt, and it is final at its instant unless marks.
  • A history row's is the latest of its ts_utc and when Taji had each input at or before it. An input is a row of a get of its own call, timed as its hub product states it; an answer with no such rows counts at its own stamp. A row reads no input after its instant. A bar is knowable at its close.
  • store records rows, pushed or answered, per item and words, not version, asking history only for unrecorded spans.
  • words take no reserved name.

Streams​

A subscribe call is every sub to stream now, replacing the last set (empty ends all), and is resent unchanged after each start. It is answered ok {} once taken.

SubAsk​

KeyTypeMeaning
subinteger, 1 or morethe kernel's id of the sub, kept across a restart; push, end and shut name it
sourcestringthe [[sources]] id asked
productbars, quotes, depth, trades or <id>.<name>one of its own [[products]]
classstringthe instrument class
askedstringthe item's key ($TOY)
wordsobject of stringsa bars sub's timeframe; absent where it has none
← {"id":8,"subscribe":{"subs":[{"sub":3,"source":"acme","product":"acme.levels","class":"index","asked":"$TOY"}]}}
→ {"id":8,"ok":{}}
→ {"push":{"sub":3,"rows":[{"ts_utc":1731400000,"price":"20.25","size":100.0}]}}

push, end, shut​

MessageRule
{"push": {"sub", "rows"}}at most 128 rows of its sub's item; more ends the sub. A row is a QuoteRow, TradeRow, BarRow or DepthRow for quotes, trades, bars or depth (one push the whole book), else your product's row. A bars sub's forming bar is pushed closed: false as it moves, then closed: true
{"end": {"sub", "status", "reason"}}ends the sub: 400 and 404 the ask's doing, 403 the plan does not stream it, any other lapsed
{"shut": {"sub", "reason"}}nothing publishes now (its hours); the next row resumes

Sign-in and the relay​

[sign_in] needs [process] and exactly one [[sources]] row, its id the manifest's. The process never holds a value: login.secrets holds a marker (taji-ref-<32 hex>) per field (key; or, for oauth, client_id, client_secret, refresh_token); login is null while unlinked or locked. A changed login restarts the process, with a new hello and its open subs resent.

Send a request needing a secret through the relay, at HTTP_PROXY's host:port (<relay>), its marker in place of the value (header, query, body):

RequestReaches
<METHOD> http://<relay>/http/<host>[:port]/<path>https to a name; http to a loopback ip:port in hosts
GET http://<relay>/ws/<host>[:port]/<path>[?query]a websocket. A marker in its query is swapped form-encoded, in a text message raw (JSON-escaped when the message is JSON), in a binary one only when the message is one msgpack value

A marker passes in a GET, a websocket, a POST to a seal url, or any method under a posts prefix, toward hosts only; else a 403 names the line to add. Answers return markers for values.

BehaviourRule
An answer, chunked or server-sent events alikerelayed as it arrives, with no size cap or idle cut, until you close
A websocketthe relay pings the vendor every 10 s and closes both legs with 1001 after 30 s with no vendor frame (pongs count); it answers your pings itself
A seal url's JSON answerread whole; the fields at its pointers ("/access_token") move into the login and reach you as markers; a pointer may not end in a field the user types
Caps8 requests awaiting an answer's head, 30 s to it; a request body 8 MiB, sent with content-length; a seal answer 8 MiB; 8 sockets of 1 MiB messages

A vendor's client library runs unmodified with base URL http://<relay>/http/<host>, stream URL ws://<relay>/ws/<host><path>, and the markers as credentials. It reaches the relay directly, via HTTP_PROXY, or CONNECT (Python websockets for ws://). No CA is needed: your leg is plain HTTP to the kernel; the kernel checks the vendor's certificate. Libraries forcing https/wss or non-string credentials cannot.

{"id": n, "check": {}} asks one authenticated read: answer ok {}. OAuth: you refresh, POSTing your markers to token (a seal url); its 400 or 401 unlinks: you restart with login: null, reads answer 422 not_linked, data.<id>.expired is true until a new sign-in.

Errors​

A refusal is {"refusal": {"status", "error", "reason"}}: status 400-599, error ^[a-z_]+$, reason a sentence. An answer neither ok nor such a refusal, or refusing in a word only Taji says (plugin_exited, plugin_disabled, timeout, bad_answer), reaches the caller as 502 bad_answer.

A process refuses a call with:

RefusalWhen
400 unknown_kinda kind it does not serve
404 not_listeda read of an item it does not serve
400 bad_aska read it cannot take
401, 403a check the vendor refused (other statuses: unreachable)
any othera vendor error, as is a row off its shape (row <i>: <why>)

A process's caller is refused 403 plugin_disabled while it is off (The process; a failed sandbox) and 422 not_linked (a [sign_in] plugin with no login).

The kernel refuses an ask with:

RefusalWhen
400 unknown_askno kind, several, or one not get, stream or unsubscribe
400 bad_aska get or stream that is not {product, query}, two strings; rows not a boolean; at not epoch seconds; a product that does not stream; every out of its range or on trades; ticks or levels not 1 to 1000; a 17th feed; a depth every under 1 s from a polled source; a rows: true get of a JSON answer
404 not_listedan unsubscribe of no open feed
403 not_granteda product neither [grants] reads nor your [[sources]] name; provider= another source; refresh, wait or first (the kernel paces vendor fetches)
413 too_largean answer over 16 MiB as one line: page with limit
the read's own status, error and reason502 bad_reply where a non-2xx answer has no refusal body