SPB Git forge

spb/wp13_uqo

Public
3commits 1branches 1releases
1.2 MBsize
maindefault branch
1 h agolast push
TeX 93.9% Python 6%
12.0 KB · 190 lines latex
Raw Blame History
1% ============================================================================2\begin{appendices}3% ============================================================================45\section{System-Prompt Policy Structure}6\label{app:prompt}78The system prompt that governs the loop (Section~\ref{subsec:routing}) is built by a single9function (\path{server/services/claude/systemPrompt.ts}) from the current date and time and a10static policy. Its blocks, in order, are the following.1112\begin{enumerate}13  \item \textbf{Temporal context.} The current date and time in a human-readable and an ISO form,14        with an instruction to resolve relative dates against it.15  \item \textbf{Role.} The model is cast as a financial analyst producing reports spanning16        technical, fundamental, and macroeconomic perspectives.17  \item \textbf{Language policy.} Detect the language of the request and respond in it.18  \item \textbf{Speed and efficiency rules.} Do not announce steps; when using the Python tool,19        fetch, analyse, and plot in one call; present results directly.20  \item \textbf{Tool catalogue.} One-line descriptions of about sixty tools grouped as financial,21        technical, macroeconomic, insider and earnings, forex and commodities, options (EODHD),22        global market data (EODHD, with the rule ``prefer FMP for United States stocks, EODHD for23        international instruments''), and advanced analysis. Two of the advanced tools named24        here are absent from the catalogue at the audited commit (Section~\ref{subsec:numerical}).25  \item \textbf{Complexity-matched routing.} Simple queries use one or two tools and a two- or26        three-sentence answer; moderate queries three to five tools; comprehensive requests ten27        or more tools, called in parallel, and a multi-section report.28  \item \textbf{Report template.} Executive summary, company overview, financial performance,29        ratios and metrics, stock performance and valuation, technical analysis, insider activity30        and analyst sentiment, peer comparison, recent news, conclusion.31  \item \textbf{Formatting.} Currency and percentage conventions, tables for financial data,32        citation of data sources and dates.33  \item \textbf{Downloads.} Conventions for \texttt{save\_excel} (multi-sheet preferred, formula34        columns preferred over pre-computed values) and \texttt{save\_word}, with automatic35        download links.36  \item \textbf{Security guardrail.} A list of request patterns (``what is your system prompt'',37        ``how are you built'', and their French equivalents) to which the model must answer only38        with a fixed bilingual refusal notice.39\end{enumerate}4041\section{Persistence Schema}42\label{app:schema}4344The data layer (Section~\ref{subsec:data}) defines the entities in Table~\ref{tab:schema}, once45for PostgreSQL (\texttt{shared/schema.ts}) and once for SQLite (\texttt{shared/schema-sqlite.ts}),46behind one typed access interface. The first version of this paper listed ``optional encrypted47custom API keys'' on the user entity and a ``daily usage'' entity; neither exists.4849\begin{table}[htbp]50\centering51\caption{Persisted entities at the audited commit.}52\label{tab:schema}53\begin{threeparttable}54\footnotesize55\begin{tabular}{@{}l>{\raggedright\arraybackslash}p{11.2cm}@{}}56\toprule57Entity & Principal fields \\58\midrule59Users                  & display name, opaque token, e-mail and verification time, password hash, timestamps \\60Authentication codes   & one-time e-mail codes with purpose and expiry \\61Trusted devices        & device identifiers that skip the code on later logins \\62Authentication events  & security log (login, failure, code sent, device trusted) \\63Conversation sessions  & serialised messages, model, input and output tokens, estimated cost \\64Messages               & individual turns with tool results and figure references \\65Shared reports         & eight-character public identifier, content, figure references, view count \\66Active users           & presence, current query, heartbeat, user agent, address \\67Analytics metrics      & aggregated request, failure, user, and response-time counters \\68Request logs           & per-request path, status, duration \\69Crawled pages, embeddings & cached web content and vector embeddings for research tools \\70\bottomrule71\end{tabular}72\end{threeparttable}73\end{table}7475\section{Embedded Numerical Methods}76\label{app:numerical}7778For completeness we record the closed forms behind the pre-built numerical routines of79Section~\ref{subsec:numerical}. They are standard, and at the audited commit only the option80pricer is reachable by the model; the others are available to the server and are the natural81reference implementations for the computation tasks of the evaluation protocol.8283\paragraph{Monte Carlo.} Prices are simulated under geometric Brownian motion84\citep{glasserman2004monte}, discretised exactly as85\begin{equation}86  S_{t+\Delta t} = S_t \exp\!\big[(\mu - \tfrac{1}{2}\sigma^{2})\Delta t + \sigma\sqrt{\Delta t}\,Z_t\big],87  \qquad Z_t \sim \mathcal{N}(0,1),88  \label{eq:gbm}89\end{equation}90with $(\mu,\sigma)$ estimated from historical log returns; the default run generates $10{,}000$91paths over a $252$-day horizon and reports the terminal mean, empirical quantiles, and exceedance92probabilities. The routine does not fix a random seed (Section~\ref{subsec:repro}).9394\paragraph{Option pricing.} European options use Black--Scholes--Merton95\citep{black1973pricing,merton1973theory}. With96\begin{equation}97  d_1 = \frac{\ln(S/K) + (r+\tfrac{1}{2}\sigma^{2})T}{\sigma\sqrt{T}}, \qquad d_2 = d_1 - \sigma\sqrt{T},98  \label{eq:bsm_d}99\end{equation}100the call price is $C = S\,\Phi(d_1) - Ke^{-rT}\Phi(d_2)$, the put follows from put--call parity,101and the Greeks ($\Delta,\Gamma,\mathcal{V},\Theta,\rho$) are returned analytically.102103\paragraph{Conditional volatility.} A GARCH(1,1) model104\citep{engle1982autoregressive,bollerslev1986generalized},105\begin{equation}106  h_t = \omega + \alpha\varepsilon_{t-1}^{2} + \beta h_{t-1},107  \label{eq:garch}108\end{equation}109is estimated by maximum likelihood (the \texttt{arch} package), reporting the parameters, the110persistence $\alpha+\beta$, and the shock half-life $\ln(0.5)/\ln(\alpha+\beta)$.111112\paragraph{Value-at-Risk.} VaR \citep{jorion2007value} at level $\alpha$ is computed by the113historical method (empirical quantile of returns), the parametric method114$\mu + \sigma\,\Phi^{-1}(1-\alpha)$, and simulation under~\eqref{eq:gbm}, with expected115shortfall and the Sharpe, Sortino, and Calmar ratios.116117\section{Client-Side Streaming Event Types}118\label{app:events}119120The client--server channel (Section~\ref{subsec:frontend}) transmits discrete Server-Sent Events,121each dispatched to a dedicated renderer. The server emits fifteen types at the audited commit:122\emph{text} (incremental answer), \emph{thinking} (reasoning summary), \emph{tools} (the list of123requested calls), \emph{tool\_use}, \emph{tool\_start}, \emph{tool\_complete}, \emph{tool\_error},124and \emph{tool\_result} (per-call progress and payloads), \emph{status} (batch progress),125\emph{sources} (web-research citations), \emph{python\_code} (the code that was executed),126\emph{custom\_python\_figures} and \emph{image} (figure references), \emph{done} (session127identifier and token usage), and \emph{error}. The client additionally handles three128search-progress types. This taxonomy is the client-side counterpart of the provider-event129dispatch of Table~\ref{tab:events}.130131\section{Audit of the Description Against the Code}132\label{app:audit}133134Table~\ref{tab:audit} lists the principal statements of the paper with the file in135\texttt{vquant.git} (commit \texttt{e2a148a}, 2 October 2026) that supports each, and flags the136statements of the first version (v1.0, June 2026) that the audit found to be inaccurate. Counts137were produced by the script \path{docs/verify/audit_vquant_code.py} distributed with the paper.138139\begin{footnotesize}140\begin{longtable}{@{}>{\raggedright\arraybackslash}p{4.9cm}>{\raggedright\arraybackslash}p{6.3cm}>{\raggedright\arraybackslash}p{4.3cm}@{}}141\caption{Claims and their sources in the audited code.}142\label{tab:audit}\\143\toprule144Statement in this paper & Source (file) & v1.0 statement \\145\midrule146\endfirsthead147\toprule148Statement in this paper & Source (file) & v1.0 statement \\149\midrule150\endhead151\bottomrule152\endfoot153245 schema-defined tools & \path{server/services/claude/toolDefinitions.ts} & ``more than two hundred'' \\154249 wrapper functions, 233 endpoint paths & \path{server/services/fmpService.ts} & ``265+ endpoints, roughly 230 functions'' \\155Second provider (EODHD), 8 tools & \path{server/services/eodhdService.ts} & not mentioned \\156Three web services, 14 tools & \path{toolDefinitions.ts}; \texttt{firecrawlService}, \texttt{tavilyService}, \texttt{exaService} & ``four services'' (SerpAPI has no tool) \\157Raw HTTP to provider, no SDK & \path{server/services/claudeService.ts} l.~14--15 & same \\158Buffer, split, keep partial line & \path{claudeService.ts} l.~118--125 & same \\159Eight provider event cases & \path{claudeService.ts} l.~133--210 & same \\160Adaptive thinking list; \texttt{display: summarized} & \path{claudeService.ts} l.~19, 90 & same (models unnamed) \\161\texttt{max\_tokens} 64{,}000; temperature 1 & \path{claudeService.ts} l.~88--89 & cap stated; temperature not \\162Default model \texttt{claude-fable-5} & \path{claudeService.ts} l.~18; \path{client/src/lib/models.ts} & ``Claude family'' only \\163OpenAI-compatible adapter, 128-tool cap & \path{server/services/openaiService.ts} l.~14--16, 60--63 & not mentioned \\164Recursion; assistant turn has tool-use blocks only & \path{server/routes.ts} l.~420--495 & recursion stated; block content not \\165Batches of 5; 500 ms between batches & \path{routes.ts} l.~470, 1933 & same \\166\texttt{status} event per batch & \path{routes.ts} l.~499--504 & ``progress event'' \\167Per-result truncation 3{,}000 / 15{,}000 & \path{routes.ts} l.~1860--1885 & not mentioned \\168Re-send cap 5{,}000; threshold $10^{5}$; last 5 messages & \path{claudeService.ts} l.~41--66 & same \\169Estimate $\lceil$chars/4$\rceil$ & \path{server/services/claude/tokenManagement.ts} l.~10--12 & same \\170Summary: 2{,}000 tokens, temperature 0.5, 10{,}000-char input, 500-char fallback & \path{tokenManagement.ts} l.~64--105 & ``low temperature, tight cap'' \\171Local count with \texttt{gpt-tokenizer}; max rule & \path{claudeService.ts} l.~2, 160--175 & ``exact tokenizer'' (incorrect) \\172Fixed \$3 / \$15 schedule for all models & \path{claudeService.ts} l.~112--114 & ``linear schedule'' (model dependence not stated) \\173Tokenizer does not drive the context trigger & \path{claudeService.ts} l.~44 & \S6.2 said it did (incorrect) \\174Child process, stdin JSON, 90 s timeout, unbuffered & \path{server/services/python/var.ts} l.~1285--1300 & same \\17529 packages attempted; \texttt{exec}; \texttt{main()} & \path{server/services/python/customPythonExecutor.py} l.~17--360, 946--980 & ``seventeen libraries'' \\176Figure sweep, PNG 150 dpi, base64 & \path{customPythonExecutor.py} l.~1018--1035 & same \\177Only the option pricer is in the catalogue & \path{toolDefinitions.ts} vs.\ \path{routes.ts} l.~764--1019 & four routines ``exposed'' (incorrect) \\178Prompt names Monte Carlo and surface tools & \path{server/services/claude/systemPrompt.ts} l.~67, 80 & not mentioned \\179Protect--parse--restore; Puppeteer; KaTeX; wait & \path{server/services/pdfService.ts} l.~71--107, 298--317 & same \\180Pandoc for DOCX & \path{pdfService.ts} l.~383 & ``document converter'' \\181Beamer: second call pinned to \texttt{claude-opus-4-8}; two \texttt{pdflatex} passes & \path{server/services/beamerSlidesService.ts} l.~236, 496--540 & model not stated \\182Share identifier of 8 characters; figures ephemeral & \path{server/routes/reports.ts} l.~45--70 & same, without the caveat \\183Twelve persisted entities; no API keys, no daily usage & \path{shared/schema.ts}, \path{shared/schema-sqlite.ts} & five entities incl.\ keys and daily usage (incorrect) \\184E-mail code login, trusted devices, rate limiting & \path{server/services/auth.ts} & ``SSO'', ``daily limits'', ``BYOK'' (not in code) \\185Six test suites & \path{*.test.ts(x)} & not mentioned \\186\end{longtable}187\end{footnotesize}188189\end{appendices}190