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:
| Variable | Value | When |
|---|---|---|
HOME | <state dir>/plugins/<id>/data | always |
TMPDIR | <state dir>/plugins/<id>/tmp | always |
TAJI_PLUGIN | its id | always |
HTTPS_PROXY, HTTP_PROXY | http://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_proxy | the same | as above, on macOS and Linux |
FTP_PROXY, ftp_proxy | the same | as above, on Linux |
SSL_CERT_FILE | /private/etc/ssl/cert.pem | as above, on macOS |
TAJI_RELAY | 1; the relay is on the proxy's listener | [sign_in] |
TAJI_SITE | its lock's packages | [process.python] with a lock |
SystemRoot, LOCALAPPDATA | the system's (LOCALAPPDATA else HOME's directory) | Windows |
USERPROFILE, TEMP, TMP | HOME's and TMPDIR's directories | Windows |
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.
| Event | Result |
|---|---|
| No hello in 30 s | off until the next boot |
A call unanswered in call_timeout_s | that call answers 504 timeout; the process keeps running |
| Ten non-JSON lines in a row | exit |
| A line over 16 MiB | exit |
A ping unanswered in call_timeout_s (sent every 10 s while it streams; any answer counts) | exit |
| An exit | calls in flight answer 502 plugin_exited |
| A call after an exit | 502 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 minutes | off until the next boot |
Handshake and calls
Hello
The process says it first.
| Key | Type | Meaning |
|---|---|---|
hello | "taji-plugin/1" | the protocol |
id | string | equals the manifest's |
version | string | the plugin's version |
HelloAnswer
| Key | Type | Meaning |
|---|---|---|
hello | "taji-plugin/1" | the protocol |
taji | string | the contract version the kernel speaks |
login | object 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).
| Kind | Body | Answer ok |
|---|---|---|
verb | {route, bindings, args}: the [[kernel.verbs]] route, its {name} segments as called, the body | the verb's answer |
read | a 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 sub | anything, 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 only | the 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.
| Key | Body | Meaning |
|---|---|---|
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>.
rows | ok |
|---|---|
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
| Frame | Keys | Meaning |
|---|---|---|
| rows | feed, 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 |
gap | feed, gap: {from_seq, to_seq} | trades rows Taji could not hold; their numbers are taken |
shut | feed, knowable_ms, knowable_utc, shut: {symbol, reason}; no seq | a depth symbol's book is gone, the feed open |
end | feed, end: {status, error, reason} | the feed is over; nothing follows |
A frame waits until you have read the one before it; Taji drops none.
| Product | seq | every (seconds to the millisecond) |
|---|---|---|
chains | counts frames from 1, never a gap | 1 to 3600, default 60 |
depth | counts frames from 1 | 0.25 to 3600; absent: a frame per book update |
trades | numbers a frame's first row, from 1 | refused: 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.
| With | A frame |
|---|---|
every | goes 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 every | goes 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.
| Key | Type | Meaning |
|---|---|---|
source | string | the [[sources]] id asked |
product | string | the product |
class | string | the instrument class |
asked | string or null | the item's key; null where the read names no item |
from | integer or null | UTC seconds, inclusive; null open |
to | integer or null | UTC seconds, exclusive; null open |
limit | integer or null | the most rows asked; null no limit |
words | object of strings | the 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:
| Class | asked |
|---|---|
equity | the symbol (SPY) |
index | the symbol with $ ($TOY, even for index:TOY) |
future | <ROOT><M><yy> (ESZ26) |
option | OCC |
future_option | <contract> |
crypto, forex | BASE/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.
| Key | Type | Meaning |
|---|---|---|
symbol | string | equals asked |
ts_utc | integer | the date's 00:00 UTC, seconds |
open, high, low | decimal or null | null where the index states none |
close | decimal | |
knowable_utc | integer | UTC 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.
| Key | Type | Meaning |
|---|---|---|
ts_utc | integer | the bar's open, UTC seconds |
open, high, low, close | decimal | |
volume | decimal or null, never negative | null where the vendor states none, held as 0 |
vwap | decimal or null | null where the vendor gives none |
trade_count | decimal or null, never negative | null where the vendor gives none |
closed | boolean | a 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 key | Type | Meaning |
|---|---|---|
bid_price, ask_price | decimal or null | null where the vendor gives none |
bid_size, ask_size | decimal or null, never negative | |
ts_event | string or null | the vendor's stamp, UTC nanoseconds |
delayed | boolean or null | whether the vendor says the row is delayed |
halted | boolean or null | whether the vendor says the item is halted |
session | pre, regular, post, 24h or null | the session the vendor says the quote is of |
TradeRow key | Type | Meaning |
|---|---|---|
price | decimal | required |
size | decimal or null, never negative | |
exchange | string or null | an ISO 10383 MIC, only where the vendor states one |
conditions | array of strings | the vendor's condition codes as text |
ts_event | string or null | the vendor's stamp, UTC nanoseconds |
delayed | boolean or null | whether the vendor says the row is delayed |
aggressor | buy, sell or null | the side that initiated the print, only where the vendor states it; never a tick-rule estimate |
off_exchange | boolean or null | true 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.
| Key | Type | Meaning |
|---|---|---|
side | bid or ask | required |
level | integer | 0 the best; required |
price | decimal | required |
size | decimal or null, never negative | |
count | integer or null | orders at the level |
ts_event | string or null | the 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.
| Key | Type | Meaning |
|---|---|---|
contract | string | required; an OCC symbol of the underlying |
bid, ask, last, iv, delta, gamma, theta, vega, rho | decimal or null | null where the vendor gives none |
volume, open_interest | integer or null, never negative | |
tradable | boolean or null | |
ts | string or null | the 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.
| Key | Type | Meaning |
|---|---|---|
symbol | string | equals asked |
ts_utc | integer | report_date's 00:00 UTC, seconds |
report_date | string | the report's New York date, YYYY-MM-DD |
knowable_utc | integer, at least 1 | UTC seconds from which the row is known: a scheduled report's announcement, a reported one's release |
timing | "bmo", "amc" or null | before the open or after the close |
fiscal_year | integer or null | the fiscal year the quarter belongs to |
fiscal_period | "Q1" to "Q4" or null | the fiscal quarter |
eps_estimate, eps_actual | decimal or null | the consensus and the reported EPS; eps_actual is null until reported |
revenue_estimate, revenue_actual | decimal or null | whole US dollars |
verified | boolean or null | false: 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 key | Type | Meaning |
|---|---|---|
name | string, ^[a-z0-9_]+$ | the key in each row |
type | string, int, float, decimal, bool, date, list<float>, list<decimal>, list<int> | its JSON form in a row |
nullable | boolean, default false | whether a row may hold null; else null or absent is refused |
unit | price, usd, shares, contracts, ratio, percent, count | what its numbers count; not on string, bool or date |
estimated | boolean, default false | computed under the product's model, not observed |
doc | string | one sentence on what it holds |
type | In a row | As Arrow |
|---|---|---|
string | a JSON string | |
int | an integer, never a string or a fraction | Int64 |
float | a number | Float64 |
decimal | a decimal string, never a number | Decimal128(38, 10) |
bool | a boolean | |
date | YYYY-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_utcis its receipt, and it is final at its instant unlessmarks. - A
historyrow's is the latest of itsts_utcand when Taji had each input at or before it. An input is a row of agetof 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. storerecords rows, pushed or answered, per item and words, not version, askinghistoryonly for unrecorded spans.wordstake 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
| Key | Type | Meaning |
|---|---|---|
sub | integer, 1 or more | the kernel's id of the sub, kept across a restart; push, end and shut name it |
source | string | the [[sources]] id asked |
product | bars, quotes, depth, trades or <id>.<name> | one of its own [[products]] |
class | string | the instrument class |
asked | string | the item's key ($TOY) |
words | object of strings | a 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
| Message | Rule |
|---|---|
{"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):
| Request | Reaches |
|---|---|
<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.
| Behaviour | Rule |
|---|---|
| An answer, chunked or server-sent events alike | relayed as it arrives, with no size cap or idle cut, until you close |
| A websocket | the 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 answer | read 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 |
| Caps | 8 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:
| Refusal | When |
|---|---|
400 unknown_kind | a kind it does not serve |
404 not_listed | a read of an item it does not serve |
400 bad_ask | a read it cannot take |
401, 403 | a check the vendor refused (other statuses: unreachable) |
| any other | a 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:
| Refusal | When |
|---|---|
400 unknown_ask | no kind, several, or one not get, stream or unsubscribe |
400 bad_ask | a 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_listed | an unsubscribe of no open feed |
403 not_granted | a product neither [grants] reads nor your [[sources]] name; provider= another source; refresh, wait or first (the kernel paces vendor fetches) |
413 too_large | an answer over 16 MiB as one line: page with limit |
the read's own status, error and reason | 502 bad_reply where a non-2xx answer has no refusal body |