Skip to content
An Econ-ARK project

Matsya in three parts

Summary

Matsya turns an economist's description of a dynamic model, or a paper, into a declaration in Bellman-SYM, the project's language for staged Bellman problems, checks the declaration, and answers questions about models and about the language. It has three parts, and this page says what each does and what it does not do: matsya-client, the command you run on your own machine, a program with no language model in it; matsya-architect, the service's job side, which builds and checks a declaration in one run; and matsya-master, the service's conversation side, which answers one question at a time. It then defines the words that the parts share, session, job, turn, version, label and target, and shows how a piece of work moves between the parts.

Relationship with other documents

Builds on — Matsya, the entry page, which says what Matsya does and for whom and maps the pages of its documentation. Continued by — The roles and the work of a job, which names the language-model roles that do the work of a job and of a turn and says which command answers which request. For an assistant — For an assistant using Matsya, the page that an assistant running the client's commands for you reads first: the files the client keeps, the commands of a project folder in their order, and the form of every answer. Explained for developers in — the Matsya developer guide, which describes the program, the configuration, the retrieval index and the Matsya handlers. See also — the wiki pages Matsya collection, Matsya handler and Matsya instructions; Stages in the language guide, for the stage files a job writes.

Note

The service and the client are updated separately. Some installed services still stop on a prose-judge disagreement and do not retain unfinished writings. Those behaviors require a service update; installing this client alone does not change them. The job behavior described below applies after that service update.

1 The three parts

matsya-client is the command bellman-matsya and the Python module bellman_matsya, installed on your machine from the package bellman-matsya-client. It is a program: it holds no language model and makes no decision about economics. It sends your requests to the service with your Matsya token, the password-less identifier, msy_ followed by 32 hexadecimal characters, that the service's administrator gives you and that the service checks on every request; it waits for a job and prints its progress; it writes the files a job produced into a folder in the layout the project's applications use; and it composes the job's report from the job's record (§2). Everything it prints or writes is either the service's answer or a fixed sentence. The Matsya token is required for every request. Anthropic, the provider of the service's language models, charges each language-model call of a job or a question to the account that an Anthropic API key identifies. By default that key is the service key, the service's own Anthropic API key, which stays on the server. A registered holder of a Matsya token may also give the client a personal Anthropic key, an Anthropic API key of their own, so that the language-model calls of the jobs and questions they start are charged to their own Anthropic account; the personal key is an optional addition to the Matsya token, never a substitute for it, and is added only after the Matsya token has been configured (Working with Matsya from the command line §1.1).

matsya-architect is the job side of the service. One job begins with preparation, done once: from the source material, the text of a session or a file submitted on its own, the Model-prose-writer restates the model in prose; the prose-source-judge compares that prose with its source and records any disagreement for the user to assess. Prose-to-Bellman-Sym then writes the initial declaration, and the elaborator checks its stage files. Each subsequent iteration reads the latest elaborated semantic object back into prose, writes one new declaration from that prose, elaborates it, and compares it with the preceding elaborated semantic object. The job ends converged when those adjacent elaborated semantic objects are equivalent. The judges' reports, block quotations and writer's note remain available for the user to assess; none decides convergence. If the comparison differs, another iteration may run within the allowed limit. A job also ends earlier when its stage files cannot be repaired, or when a limit on reading or language-model text is reached. A question the job cannot settle ends it; your reply starts a new job. The question reaches the session only when the job has a session and you added no entry while it ran, including a question to matsya-master; otherwise it remains in the job's record, and you start the next attempt by submitting again. A job runs on the server for minutes and is charged by its language-model tokens, the pieces of text that the provider counts in every message and answer.

matsya-master is the conversation side of the service. It answers one question at a time, asked in a session, from four things: the passages of the retrieval index that your Matsya token may read, the project's documentation and the literature among them; the session's text; the outputs of the session's jobs; and, when the question names a stage file of your own, what the elaborator, the program that checks stage files, makes of it. Its answers quote their sources and cite them. It writes no stage file itself. When you ask it to build, it submits a job to matsya-architect from the session, and tells you so by the job's label.

Part Where it runs What it does What it does not do
matsya-client your machine sends requests, waits, writes the folder, composes the report nothing with a language model
matsya-architect the server builds and checks a declaration in one run of cycles talk to you while it runs
matsya-master the server answers one question in a session; submits a job when asked write a stage file; cancel or select a job

You may type the commands of matsya-client yourself, or have an assistant, such as Claude Code, read these pages, run the commands on your machine and read what they print. The assistant's program runs locally; the language model it calls may run elsewhere. The assistant is not part of Matsya and sends the same requests through the same commands.

Both sides of the service read the retrieval index, the store of passages, short pieces of the indexed files, each with its place in its file, from which a search returns those that best match a query. The indexed files are this project's documentation and stage files, the source code and documentation of HARK, the paper Theoretical Foundations of Buffer Stock Saving, a literature on dynamic programming and journal articles; a request reads only the parts that the service's administrator has granted to the holder of its Matsya token (Collections and weights §§1–2). Each version of the index is named by its digest, a 64-character code computed from the index's contents, which changes whenever the index is rebuilt.

2 Sessions, jobs and turns

A session is the kept, numbered text of one model: the description you write, a paper you attach, the questions you ask matsya-master, the questions Matsya puts to you and your replies, and the answers of matsya-master, of which only those you accept belong to the text a job reads. Each of these is an entry of the session, numbered in the order the entries arrive, and the version of the text is the number of the last entry you wrote or accepted; an entry Matsya writes does not change the version. A session is neither a job nor a conversation: both sides use it. A session may hold nothing but questions and answers, or it may prepare and hold several jobs.

A job is one run of matsya-architect, from one version of the text, and it names its target, the level of the declaration it is to return: a stage, one decision problem, written as one stage file; a period, the stages of one model period and the connections between them, written as the stage files and the period file period.yml; a trellis, the model's periods in time up to the terminal period, written as the stage files, the period files and the trellis file trellis.yml; or a recipe, the files of a trellis with a methods file for each stage whose solution method the source states, the calibration and settings files and the recipe file spec.yml, which Bellman Workbench loads and solves. The model prose states the model's structure, its stages, its periods and how the periods repeat; a target that holds that structure is admitted, a wider one included, and a narrower one ends the job with one question before any stage file is written (The roles and the work of a job §1). The wiki pages stage, period, trellis and specification factory define the four objects in the language.

Within its session a job has a number, its rank among the session's jobs, and a label that names the model, the target, the version of the text the job read, its number and its state, for instance "Household with firms · trellis · version 2 · job 7 · running". A job that was still running when you wrote an entry, a question to matsya-master included, is marked text changed since while it runs and built from an earlier version once it has ended converged, not converged or with questions; its questions are not added to the session (§1), and matsya-master discusses it only when you select it (§3). Several jobs may belong to one session; each keeps its own record, and submitting again never overwrites an earlier job.

A turn is one question answered by matsya-master in a session: the question, the passages read, the answer with its citations, and the record of what was read. A turn makes a few calls of a language model, where a job makes several in preparation, initial writing and its iterations, so a turn usually takes less time and costs less than a job.

Once a job has run, the service keeps its record: the initial declaration, what each numbered iteration produced and found, and an account of every call it made; a job that failed, that a restart of the service interrupted, or that was cancelled before it started holds none. What the service returns by default is the available declaration files and the prose from which they were written, even when a later iteration produced no files or the job ended not_converged; the questions, when it stopped for input; the prose judges' findings; the latest completed comparison of adjacent elaborated semantic objects and whether a later iteration stopped before comparison; and the language-model tokens charged. Files from a not_converged job are proposals for review; the status and reason remain with them. The full record, including each iteration's prose and files, is returned when requested for examination or training.

3 How a piece of work moves between the parts

You write the model's description in a Markdown file and submit it. matsya-client creates a session named after the file, appends the text to it, and asks the server to start a job from that session. matsya-architect runs the job; matsya-client, asked to wait with bellman-matsya job wait, prints each step and cycle, and, asked with bellman-matsya job files once the job has ended, writes the stage files, the model prose and the report into a folder.

If the job ends with a question, the question is an entry of the session. You reply with a file, naming the question's entry; the first reply starts the next job, which reads the text with your reply in it. The question's entry names the job that asked it, and the command that adds the reply prints the job it started.

You ask about the result in the same session: what the declaration assumes, how a constraint is written, why a judge disagreed. matsya-master answers each question from the index, the session's text and the job's outputs, and names the job it read. The job it reads is the session's selected job, the job of the session that you chose with bellman-matsya session select; when none is selected, it reads the latest job of the session that holds a record, was not cancelled and ran while you added no entry to the session. If you say "submit this as a job", matsya-master starts one from the session's text as it then stands, your request included, and its answer gives the job's label; matsya-client can stay attached to that job until it ends and then write the folder.

Nothing passes between matsya-architect and matsya-master except through the session's written record and the jobs' stored results. Neither reads the other's working memory, and the client reads only what the server returns.