kestrel.markets
Version:
A typed, token-efficient language + runtime for agentic trading: agents author bounded plans, the runtime fires them at the tick. CLI + typed library + MCP server.
38 lines (37 loc) • 2.72 kB
JavaScript
/**
* # cli/backend/catalog-records — the LOADER for the baked catalog-conformant contract fixture (kestrel-djm.5, kestrel-nvxb)
*
* The pre-computed, content-addressed protocol artifacts the catalog-conformant contract server
* ({@link ./mock.ts}) serves so the SDK's HTTP transport returns the SAME protocol Blotter / transcript /
* grade / root the LOCAL projection yields (the djm.5 headline reconciliation).
*
* kestrel-nvxb (arch-review A8): the ~7,200-line generated `CATALOG_RECORDS` literal that used to live INLINE
* in this source file — 99% of the largest file in the tree — is now a BUILD ARTIFACT at
* {@link ../../../artifacts/sdk/catalog-records.json}, generated by scripts/sdk/bake-catalog-records.ts. This
* module is a thin, hand-written, STABLE loader: it statically imports that JSON data artifact (a pure-data
* value edge — no engine, no code) and re-exports it under the djm.2 protocol types. Moving the literal out
* of `src/` does NOT change the served bytes: `mock.ts`'s `json()` stringifies the SAME in-memory objects in
* the SAME key order (JSON.parse preserves the artifact's key order), so `GET /catalog` and the served
* records are byte-identical to the old inline form.
*
* Guards on this fixture:
* - tests/sdk.transports.test.ts — HTTP↔LOCAL protocol digest parity (the drift guard).
* - tests/sdk.transport-fixture-freshness.test.ts — every baked record byte-equals a fresh LOCAL engine run.
* - tests/cli.mock-catalog-bytes.test.ts — the REAL mock server serves byte-identical records through the
* loader+artifact seam (the kestrel-nvxb served-byte parity guard).
* Regenerate on any engine / catalog-root change:
* bun scripts/sdk/bake-catalog-records.ts
*
* LIGHT: the loader imports ONLY the pure-data JSON artifact + type-only protocol imports (erased) — the
* server stays on the light remote graph (tests/package.boundary.test.ts).
*/
import catalogRecordsArtifact from "../../../artifacts/sdk/catalog-records.json" with { type: "json" };
const artifact = catalogRecordsArtifact;
/** The djm.8 mirror view — the SAME CatalogEntry[] the LOCAL loader yields (baked so the light server needs
* no engine to serve GET /catalog). The transport-parity test pins byte-equality with `catalogEntries()`. */
export const CATALOG_ENTRIES = artifact.catalogEntries;
/** The baked per-entry Session records, keyed by catalog entry id. */
export const CATALOG_RECORDS = artifact.records;
/** Reverse map: a baked Session id → its catalog entry id (the server dispatches /grade on the graded
* Blotter's sessionId). */
export const SESSION_TO_ENTRY = artifact.sessionToEntry;