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.
86 lines • 6.27 kB
TypeScript
/**
* # frame/session-scheme — the SessionScheme series-registry attribute (ADR-0041 §1/§3, kestrel-wa0j.44)
*
* A `SessionScheme` is a SERIES-REGISTRY attribute (the ADR-0036/0038 registry slot — the same
* surface ADR-0038 runs one axis over for Attribution): it declares an instrument's **monotone
* boundary stream** — the ordered `open` / `close` / session-split boundaries that `SessionOrdinal`'s
* `d-N` addresses index (ADR-0041 §1: scheme-relative ordinals). 24/7 and multi-session markets
* therefore extend the *value inventory* of the existing `SessionOrdinal` sort WITHOUT touching the
* closed roster — a perp's UTC-day convention and an equity RTH day are two schemes over one sort.
*
* ## Which boundaries a scheme carries is DATA (ADR-0041 §3)
* Each scheme declares WHICH boundary kinds it carries ({@link SchemeBoundaries}). A scheme with no
* `close` boundary (a perp's rolling UTC day) makes the `prior-context` pane's close address a
* first-class ABSENCE: "this instrument's scheme has no such boundary" is a rendering, never an
* invented midnight "close" (ADR-0041 §3 — absent-not-hidden reaches the address space). The
* scheme-conditioned paradigm cell (`src/frame/paradigm-ledger.ts`) reads THIS table to decide
* whether `(prior-context × SessionOrdinal)` is DEFECTIVE or ATTESTED-as-today for an instrument.
*
* ## Absent-default = `equity-rth` (no-churn)
* `InstrumentSpec.sessionScheme` is OPTIONAL; an absent value is {@link DEFAULT_SESSION_SCHEME}
* (`equity-rth`, which carries open+close). Every existing frame input — which declares no scheme —
* therefore resolves to `equity-rth` and renders BYTE-IDENTICALLY (the empty-ledger no-churn lesson).
*
* ## ABSENT is the default; an out-of-roster STRING fails closed (never a silent default)
* A DECLARED-but-out-of-roster scheme string is NOT the absent case: coercing it to `equity-rth` would
* be a silent default (the fail-closed doctrine's cardinal sin — a made-up boundary stream rendered as
* if declared). {@link resolveScheme} therefore REFUSES an out-of-roster string by name (naming the
* served value + the closed roster), throwing a {@link ../frame/types.ts KernelHonestyError}; only the
* ABSENT case (undefined/null) resolves to the default. The typed `InstrumentSpec.sessionScheme` path
* cannot reach the refusal (its values are members of the roster or absent) — this is defence-in-depth
* for an untyped caller, per the fail-closed non-negotiable.
*/
import { KernelHonestyError } from "./types.ts";
/** The three boundary KINDS a SessionScheme's monotone stream may carry (ADR-0041 §1). */
export declare const BOUNDARY_KINDS: readonly ["open", "close", "session-split"];
export type BoundaryKind = (typeof BOUNDARY_KINDS)[number];
/**
* The CLOSED v1 SessionScheme roster (a series-registry attribute — ADR-0036/0038 slot). Opened only
* by adding a scheme + its {@link SchemeBoundaries} declaration (the registry-attribute analogue of the
* sort-introduction ceremony). `equity-rth` is the absent-default.
*/
export declare const SESSION_SCHEMES: readonly ["equity-rth", "cme-rth-overnight", "perp-utc-day", "fx-week"];
export type SessionScheme = (typeof SESSION_SCHEMES)[number];
/** The scheme an instrument that DECLARES none resolves to (ADR-0041 §3 no-churn: existing inputs are
* byte-identical). `equity-rth` carries both open and close, so every legacy equity frame is unchanged. */
export declare const DEFAULT_SESSION_SCHEME: SessionScheme;
/**
* The boundary declaration for one scheme (ADR-0041 §3: which boundary kinds it carries is DATA). A
* scheme lacking `close` carries a {@link rollingAnchor} descriptor instead — the sanctioned
* periphrasis names it ("anchor to the declared rolling extreme") so the pane renders that declared
* anchor, never an invented midnight close.
*/
export interface SchemeBoundaries {
readonly open: boolean;
readonly close: boolean;
readonly sessionSplit: boolean;
/** The declared rolling extreme a no-close scheme anchors to instead of a close (e.g. a perp's
* `rolling 24h extreme`). Present iff `close` is false — the periphrasis has something to name. */
readonly rollingAnchor?: string;
}
/** The per-scheme boundary declarations (the DATA ADR-0041 §3 conditions the paradigm cell on). */
export declare const SESSION_SCHEME_BOUNDARIES: Readonly<Record<SessionScheme, SchemeBoundaries>>;
/** True iff `s` is a member of the closed {@link SESSION_SCHEMES} roster. */
export declare function isSessionScheme(s: string): s is SessionScheme;
/**
* The typed refusal for a DECLARED-but-out-of-roster SessionScheme string (ADR-0041 §1/§3): it names
* the served value + the closed {@link SESSION_SCHEMES} roster (the unknown-value-naming-roster idiom),
* so the fix is legible — declare the scheme + its boundaries, or correct the typo. Fail-closed: an
* unknown scheme has no boundary declaration, so its `open`/`close`/split stream cannot be honestly
* rendered — refusing is the only truthful answer (never a silent `equity-rth`).
*/
export declare function unknownSchemeRefusal(served: string): KernelHonestyError;
/**
* Resolve a declared-or-absent scheme to a concrete one. ABSENT (undefined/null) ⇒
* {@link DEFAULT_SESSION_SCHEME} (`equity-rth`, no-churn). A DECLARED value OUTSIDE the closed roster
* FAILS CLOSED — it throws {@link unknownSchemeRefusal} (naming the value + the roster) rather than
* fabricate an unknown scheme's boundaries or silently coerce to the default. ABSENT is not UNKNOWN:
* only an explicit out-of-roster string refuses; a missing declaration stays the default.
*/
export declare function resolveScheme(scheme: string | undefined | null): SessionScheme;
/** True iff `scheme` carries the given boundary kind (ADR-0041 §3 — read from the declaration DATA). */
export declare function schemeHasBoundary(scheme: SessionScheme, kind: BoundaryKind): boolean;
/** The declared rolling extreme a no-close scheme anchors to, or `undefined` when the scheme carries a
* close (the periphrasis is only reachable for a no-close scheme). */
export declare function rollingAnchorOf(scheme: SessionScheme): string | undefined;
//# sourceMappingURL=session-scheme.d.ts.map