What Matsya reads¶
Summary
Every call to a language model sends one message made of labeled parts. The first part is the role's instruction text; guide parts, saved pages of the published documentation, follow it, and together with the text they form the beginning that is marked for the provider's prompt cache, the provider's store of a message beginning it has already processed, which a later message with the same beginning reuses at a lower price. Then come the retrieved passages, the source material or the dossier, and any feedback on an earlier answer. The source preparer and the Bellman-SYM writer may also answer a call with one request for a further guide page or index passage; the reading controller, the program's object between the Matsya handlers and the index, answers it within the allowances of the settings and places the result after the cached prefix in the role's next message (§5). The seven instruction texts, the three reference guides and the settings, which name the pages each role receives, the rounds each step may take and the language model each role runs on, come from the configuration folder; the retrieved passages, the source, the dossier, the feedback and the results of requests are produced during the job. Before a message is sent, the program counts its language-model tokens, the units of text in which the provider counts and prices a message, and checks the bounds the settings set on one message and on a whole job. The instruction texts are the trained object \(\mathfrak{t}\) and the settings the trained object \(\mathfrak{s}\) of the guide's first page §1, except the token ceilings, which a training pass holds fixed; the reference guides are copies of published pages, built under a fixed construction policy, and are not trained; the program fixes only names, types and places. A configuration that enables the optional conversation role holds an eighth instruction text and two more settings, and the message of a turn of conversation mode has the same form (§8).
Relationship with other documents
Builds on — the guide's first page §§1–2: the program and the configuration folder, the frame and the job frame, the roles, the Bellman-SYM elaborator and the elaborated semantic object, the dossier; Matsya instructions and Reference guides in Matsya, which define the two kinds of text. Used by — The Matsya handlers, whose functions assemble the messages described here. See also — The retrieval index §§4–8, for passages, links and tags; Collections and weights §6, for which collections a person may read; The Matsya handlers §7, for a turn of conversation mode.
1 The message a language model receives¶
A Matsya handler assembles the parts of a message after the instruction text, each part a pair of a label and a text, and passes them to the Matsya handler call, which puts the role's text first under the label the instructions, passes the number of leading guide parts as the cached prefix and passes the whole to the job frame's call. The job frame's join_parts joins the parts into one text, each part under a line ===== <label> =====; the Matsya handler call records the SHA-256 digest and the length of that text in the job's record, never the text itself. For the Anthropic provider the message is sent in two blocks of the provider's message format: the first holds the instruction text and the guide parts with the provider's cache_control mark, and the second holds the rest. The prefix is identical from call to call of one role, which is what allows later calls of that role to read the prefix from the provider's cache at a lower price.
Before the message is sent, the program counts its language-model tokens (a token is the unit of text, a word or part of a word, in which a provider counts and prices a message). The fixed caller, the class ProviderCaller of roles.py through which every call of a job reaches the provider, sends the same two blocks with the same language model to the provider's counting request, which returns the number of input tokens the message would carry without running the language model and is free of charge. The count is an estimate: the provider states that the input a message uses may differ from it by a small amount (Anthropic, "Token counting", Claude Platform documentation, read on 8 October 2026). A message whose count, with the role's output limit and the counting margin added, exceeds the role's context window, the number of tokens the language model can hold in one call, the message and its output together, is refused without being sent, and the job ends failed with the code prompt_too_long, as a message over the character limit does; the character limit is checked first, before any count. The count also decides whether the call stays within the job's token ceilings (§4). The instruction text and the guide pages of the source preparer, SourceMaterial_to_BellmanStageProse, come to about 72,500 tokens, those of the Bellman-SYM writer to about 70,200, and those of the prose writer to about 43,700.
| Role | Parts after the instruction text, in order |
|---|---|
Source preparer, SourceMaterial_to_BellmanStageProse |
the calculus guide pages and the language guide pages named in preparer_pages; the passages of preparation's initial search, if any, under retrieved Bellman language passages; the addresses you may request; after its first request, the material your requests added; the formulation, if the request named one, under the label the selected formulation; the job's target under the target; the source material; on a later round, feedback on the previous preparation |
Bellman-SYM writer, BellmanStageProse_to_BellmanSYMDeclaration |
the language guide pages named in writer_pages; the retrieved passages, if any: preparation's passages when it writes from \(M\), or the passages of an iteration's own initial search from the concepts of its \(M'\) or later prose; the addresses you may request; after its first request, the material your requests added; the formulation, if named, under the selected formulation; the job's target under the target; where the description states under its heading Structure a structure the program can read, its period templates with their stage keys, one to a line, under the structure the description states; the description; after a refusal by the Bellman-SYM elaborator, the refused files and the refusal |
Prose writer, ElaboratedSemanticObject_to_BellmanStageProse |
the stage interface guide pages named in prose_writer_pages; the dossier; on a second round, your previous description and the form check |
Judge, BellmanStageProse_judge |
no guide pages; optionally the selected formulation and comparison rule; in a cycle, when the job's target is stage, period or recipe, the job's target and comparison rule, which names what the files of that target cannot state; the write-up and the description, in one order and, in a second call, in the other; the form check; after an invalid answer, error in the previous judge answer. In preparation the write-up is the source material and the description is \(M\); in a cycle the write-up is \(M\) and the description is \(M'\) |
distribution_check |
no guide pages; the selected description, the income or shock name and why the writer could not represent its distribution |
Conversation role, conversation_answer, in a configuration that enables it |
the calculus guide pages, the language guide pages and the stage interface guide pages named in conversation_pages; the passages of the turn's search and the retained passages under retrieved Bellman language passages; the addresses you may request; after its first request, the material your requests added; the decision list of the previous turn; the session's entries before the question; the outputs of the job this conversation discusses, when the session holds a job the turn reads without a request (§8); for a stage file the question names, the dossier of the stage file the question names and the prose writer's description of that dossier, or the elaborator's refusal of the stage file the question names; the named fields the caller attached; the question; after an answer that failed its checks, your previous answer and the faults of your previous answer (§8) |
Apart from its instruction text and its guide pages, the prose writer reads only the dossier, the numbered printed description of the elaborated semantic object \(E\); it never receives the description \(M\) or the stage files \(D\), and it makes no request. That separation is what makes its description \(M'\) independent evidence of what the files mean. The judge and the supporting roles make no request either, and their messages are as the table states.
2 The seven instruction texts¶
The texts are stored under texts/ in the configuration folder, one file per role, named by the role's key with its underscores written as hyphens: the text of the role BellmanStageProse_to_BellmanSYMDeclaration is texts/BellmanStageProse-to-BellmanSYMDeclaration.md. Each begins with YAML front matter and is read whole, front matter included; the loader checks nothing of a text's content beyond its digest. The seven role keys are fixed in the program, in ROLES of roles.py, and the key of the optional conversation role in OPTIONAL_ROLES. A configuration that enables that role holds its text texts/conversation-answer.md by the same rule; the loader requires the text of a configuration that names the role and refuses it in one that does not.
| Text | Role | What it instructs | Size |
|---|---|---|---|
SourceMaterial-to-BellmanStageProse.md |
SourceMaterial_to_BellmanStageProse, the source preparer |
read the source material, a paper's text in Markdown or LaTeX or a typed description, alone or among a session's entries, whose kind the message names, and write only the economic description of the dynamic program, citing a paper by the titles of its headings, under the heading Structure, which states the model's stages, periods and trellis and ends with one line for each period template, and the seven headings of the paper form, within 300 to 1,000 words, both stated in a yaml block of the text; state the structure the source describes whatever the job's target, and for a recipe the values, methods, grids and tolerances the source gives; answer with one JSON object whose status is ready, or needs_input with specific questions in place of a guess, with references on a paper, each a quotation and the heading it stands under |
1,745 words |
BellmanStageProse-to-BellmanSYMDeclaration.md |
BellmanStageProse_to_BellmanSYMDeclaration, the Bellman-SYM writer |
write the files of the job's target from the description alone, a stage file, a period with period.yml, a trellis with its period files and trellis.yml, or a recipe with spec.yml, its methods, calibration and settings files and a slot $fill for each value the description does not state, listed in note.md under ## Values left to $fill; copy the supporting sentence under each block as # from: "..."; fill no gap; list supplied assumptions under ## Assumptions supplied; answer with a JSON request when an income or shock law is missing |
2,764 words |
ElaboratedSemanticObject-to-BellmanStageProse.md |
ElaboratedSemanticObject_to_BellmanStageProse, the prose writer |
read the dossier and write the model as a paper's model section in prose and LaTeX, without the stage-file spelling, under seven fixed headings and within 300 to 800 words, both stated in a yaml block of the text |
596 words |
BellmanStageProse-judge.md |
BellmanStageProse_judge, the judge |
compare the write-up with the description on ten economic items, counting omissions, additions and contradictions with exact quotations, the statements under the heading Structure each under the item it concerns, and in an iteration leave out what the target's files cannot state; give a verdict on the form; answer with one JSON block | 990 words |
distribution-check.md |
distribution_check |
decide from the description alone whether the law of a named random variable is specified, missing or unclear, with exact quotations and one question | 277 words |
paraphrase.md |
paraphrase |
reword a description and reorder its sentences while keeping every mathematical statement, symbol and heading | 261 words |
conversation-answer.md, optional |
conversation_answer, the conversation role |
answer one question asked in a session from the material supplied in the turn, keeping apart what a source says, a comparison and the role's own deductions, and naming the user's assumptions by their entry numbers; cite every claim's material with a quotation; request a job's stage files only for a question about their spelling; write no declaration; start a job only when the user asks for one, naming its target, the one the user named or the one inferred from the discussion and stated in the answer; keep the decision list; answer with one JSON object whose status is answered, or needs_input with questions for the user (§8) |
3,139 words |
typed-form-writer.md |
typed_form_writer |
reconstruct the problem from a dossier in a fixed form, states, controls, shocks, laws of motion, value recursion, policy condition, forward operator, parameters and open conditions, citing the dossier line under each equation | 410 words |
A job calls only five of the seven roles, since no Matsya handler calls paraphrase or typed_form_writer; the program nevertheless requires their texts and role settings, because the program that measures a training pass reads them from the same folder. The form of each of the two descriptions is stated in the text of the role that writes it: the Matsya handler prepare runs the form check on the description \(M\) against the headings and word bounds in the yaml block of SourceMaterial-to-BellmanStageProse.md, the heading Structure followed by the seven headings of the paper form within 300 to 1,000 words, and the Matsya handler prose_write runs it on the description \(M'\) written from the dossier against the block of ElaboratedSemanticObject-to-BellmanStageProse.md, the seven headings within 300 to 800 words, so a change of either form is a change of one text.
3 The three reference guides¶
A reference guide is a concatenation of published documentation pages, each page preceded by a marker line ===== <page path> =====, with HTML comments and trailing spaces removed. The guide builder, the operator-run script matsya_guide_builder.py, run with Python and --output naming the configuration's guides/ folder, writes the three guides and guides/manifest.json under the construction policy, the file guide_policy.json beside the script, which states each guide's pages, the pages a link may reach, the rules by which a link is resolved, the topic tags through which two pages may be associated and the limits. The policy is part of the program and stays fixed while a training pass compares configurations, so those configurations hold the same guides.
Each guide holds its core pages first, the pages it held before the builder read links and tags: writer-guide.md every Markdown page of the overview, then of the Bellman-SYM guide, then of its reference section, each folder's pages sorted by name; reader-guide.md the stage-interface index and the pages describing the stage object; calculus-guide.md the pages of the Bellman calculus in the order of the site's navigation. After them, in path order, stand its supporting pages: pages directly under docs/wiki/ or in the guide's own folders to which a core page links, or with which a core page shares a usable topic tag, a tag of the policy's list that names an object of the language, such as stage or perch. A supporting page is one link or one shared tag away from a core page and never further. A guide holds at most as many supporting pages as core pages, and at most twice the saved text of its core pages; the candidates linked from more core pages are admitted first, and a candidate that does not fit is omitted whole and recorded with the limit that excluded it. The builder reads only the Markdown pages the policy admits, mkdocs.yml and the policy, lists the other files under docs/ by name without opening them, and replaces the files under --output only after every step and check has succeeded, so a refused build leaves them as they were.
The page manifest, of the form matsya-guides/3, records for each guide its digest, the part of the policy that governs it, the admitted pages with their digests and the omitted candidates; and for each saved page its path, the digest of its source and of its saved text, the reasons it was saved, its sections, the links written in it and its tag memberships, each with its span in the saved text. A link is available when its target is saved in the same guide and ambiguous when its name matches several pages; otherwise it is unavailable with one reason: missing_page, missing_fragment (the page has no such section), excluded (a file the policy does not admit, which is not opened), external (a web address, never fetched), unsupported (a link form the builder does not resolve) or not_saved (an admitted page this guide did not save). The links and tags are read by the parser packages/matsya/matsya_service/document_metadata.py, which runs only when the guides or the retrieval index are built (The retrieval index §4). A page enters a message when a setting names it or when the source preparer or the Bellman-SYM writer requests it (§5); the reading controller reads a requested page or section, and what the manifest records as related to it, from these records alone.
| Guide | Core pages | Label in the message | Roles that receive pages from it |
|---|---|---|---|
writer-guide.md |
27: the nine overview pages, the eleven root pages of the Bellman-SYM guide and its seven reference pages | the language guide |
the source preparer and the Bellman-SYM writer |
reader-guide.md |
11: the stage-interface index and the ten pages describing the stage object | the stage interface guide |
the prose writer |
calculus-guide.md |
24: the pages of the Bellman calculus in the order of the site's navigation | the calculus guide |
the source preparer |
Built from the pages of 9 October 2026, the writer's guide saves 27 supporting pages and omits 7 candidates, the reader's guide saves 11 and omits 11, and the calculus guide saves 24 and omits 11; in each guide the page limit is reached by candidates of links alone. The three guides then come to 0.70, 0.34 and 0.45 MB, against 0.55, 0.29 and 0.33 MB for their core pages alone, and the page manifest to 1.0 MB. The configuration at version 0.3.3 holds these guides, in the form matsya-guides/3, since 9 October 2026; the earlier form, matsya-guides/2, held the core pages alone and recorded no sections, links or tags.
Which pages of a guide a role receives is a setting: preparer_pages names nine pages (one calculus page and the eight pages that writer_pages also names), writer_pages eight pages of the Bellman-SYM guide, and prose_writer_pages five pages of the stage interface. The Matsya handler select_pages returns the named pages unaltered, in the guide's order. The loader checks that each guide's markers list exactly the pages of guides/manifest.json in order; for a manifest of the form matsya-guides/3 it also checks that each page's saved text has its recorded digest, that each section starts at a heading line and every recorded span lies within its page, and that each available link names a page of the same guide and a section that page records, and it reports a manifest of the form matsya-guides/2 as holding no such records. It does not check that a page list names pages of its guide: a wrong writer_pages or prose_writer_pages entry is found only during a job, which then fails with the code invalid_request, and a wrong preparer_pages entry is dropped without notice, since the helper _preparer_guide_parts of the Matsya handler module keeps only the paths its two guides' manifests list; a page saved in both the writer's and the calculus guide would be supplied twice if preparer_pages named it, which no setting does. The guides of 9 October 2026 were written from the pages as they stood that day, so each recorded source digest is that page's digest at the build; a page edited after the build differs from its saved copy until the guides are rebuilt, and the loader does not notice the difference, since it checks the saved text against the page manifest and not against docs/.
4 The settings¶
settings.json holds exactly fourteen keys, the two keys of the conversation role when the configuration enables that role, and the elective key prose_writer_dossier when the configuration names it, each of one exact type; a missing or extra key, or a value of another type, makes the loader refuse the whole configuration.
| Key | Value on 9 October 2026 | Meaning |
|---|---|---|
cycle_limit |
3 | the iterations after initial writing when a request gives no max_cycles |
cycle_maximum |
5 | the largest max_cycles a request may give |
preparer_rounds |
3 | the most calls of the source preparer before a job ends not_converged |
writer_rounds |
3 | the most calls of the Bellman-SYM writer in one writing step, the first included |
prose_writer_rounds |
2 | the most calls of the prose writer in one iteration; a failed form check prompts another call within this limit, and the final check is recorded even if it still fails. The resulting prose proceeds to judging and writing despite a failed form check. A value of 0 leaves only the initial declaration and ends not_converged with cycle_limit_reached, with no numbered iteration |
judge_rounds |
2 | the attempts the judge gets for each order of the two texts; 0 turns the judge off |
retrieval_passage_limit |
4 | the passages of an initial search, preparation's and each later writing's; 0 turns off the two roles' retrieval: no initial search, and every request of the index refused |
retrieval_search_text |
Bellman-SYM stage file fields perches laws policy blocks |
the query of an initial search when the text it is built from names no concept; otherwise unused |
preparer_pages |
9 page paths | the guide pages the source preparer receives |
writer_pages |
8 page paths | the guide pages the Bellman-SYM writer receives |
prose_writer_pages |
5 page paths | the guide pages the prose writer receives |
prose_writer_dossier |
absent; compact since 0.3.28 |
elective: the printing of the dossier the prose writer reads, full, every card of the elaborated stage, which an absent key also means, or compact, each fact of the stage once, about three tenths of the full printing |
roles |
eight entries, the seven roles and the conversation role, whose entry is the source preparer's but for the cache lifetime | for each role: provider (anthropic, or openai for the two roles a job never calls, since the program holds a language-model token counter for Anthropic alone), model, family, key_variable, the environment variable that holds the service key (below), sampling, retries, max_prompt_characters, context_tokens, the language model's context window, and the elective cache_ttl, 5m or 1h, the lifetime of the prompt-cache entry the role's head block makes, five minutes when the entry names none |
ceilings |
four entries | counting_margin, 1,000 tokens; job, at most 3,000,000 input tokens and 300,000 output tokens for all the calls of one job; turn, at most 600,000 input tokens and 60,000 output tokens for all the calls of one turn, present only when the configuration enables the conversation role; roles, the same two bounds as job for each of the five roles a job calls, 0 for paraphrase and typed_form_writer, and the bounds of turn for the conversation role; not trained |
reading |
three entries | for the source preparer, the Bellman-SYM writer and the conversation role, the five allowances of their requests: request_rounds 4, max_added_characters 12,000, max_related_results 8, max_searches 2 and max_retrieval_tokens 4,000, raised to 12,000 for the source preparer and the Bellman-SYM writer in 0.3.28 (§5), counted over one run of prepare or write, and for the conversation role over one turn; trained |
conversation_rounds |
3 | present only when the configuration enables the conversation role: the conversation role's calls in one turn whose answer is not a request, its first answer and the repairs of answers that fail their checks; at least 1 (§8) |
conversation_pages |
9 page paths | present only when the configuration enables the conversation role: the guide pages of the cached prefix of every message of a turn, the nine paths that were preparer_pages until 0.3.28, which removed the constraints and forms pages from the preparer's list alone (§8) |
Every role of the configuration of 8 October runs on the provider anthropic with the language model claude-fable-5-1, reads its provider access key from the environment variable MATSYA_ANTHROPIC_KEY, makes one attempt per call and refuses a message longer than 600,000 characters; the output limit, the key max_tokens under sampling, is 32,000 language-model tokens for the source preparer and the Bellman-SYM writer and 16,000 for the others. Since 9 October 2026 each role's context_tokens is 1,000,000, the context window of claude-fable-5-1. The access key itself is therefore never written in a file.
The variable that a role's key_variable names holds the service key, the access key of every call whose request supplies no other. A job's or a turn's request may supply a personal Anthropic key, a user's own Anthropic API key, in the header Bellman-Matsya-Anthropic-Key (Reaching the service by HTTP §1), and that key then replaces the service key for every call of that job or turn alone. The route passes the key in memory to the worker of the job or the turn, and the fixed caller built for it, the ProviderCaller of §1, sends every counting request and every message of the job or turn under the key, retries included, without reading the variable; a job that a turn starts receives the turn's key in the same way. No record, ledger, setting, stored request or job frame holds the key, so a personal key changes neither the configuration's ID nor a request's digest, and the record of the job or the turn names only its credential_source, client for a personal key and service for the service key. An answer of HTTP 401 or 403 from Anthropic to a counting request or a message, the provider's refusal of the key, ends the call after that first answer, with no retry and no call under the other key, and the role_call_failed event that the Matsya handler records keeps the handler's own code, provider_error. A turn then ends incomplete with the reason provider_rejected_credential. A job fails with the code provider_rejected_credential when the refusal reaches the job runner, as every refusal outside the judge's calls does. The Matsya handler judge catches a refusal of the judge's call, as it catches every provider error, and records the judging as unavailable with the reason provider_error; the job then continues. If the key is still refused, the job's next call is refused at its first request and the job then fails with the code. A job whose last call was the refused judge's call ends without that code, for example a job that ends needs_input because its target does not hold the level of the prepared structure. The ceilings of ceilings bound a job or a turn whichever key is used for its calls.
The key ceilings bounds what a whole job may use, which no bound on one message does. counting_margin is the number of tokens added to a count wherever the count is compared with a bound, since the count is an estimate. A ceiling is the most input tokens, or output tokens, that may be charged to the calls of one role over the whole job (roles) or to all the calls of the job (job). A call makes an attempt, one request to the provider, and makes a further attempt after a timeout, a lost connection or a rate limit, up to the role's retries. Before each attempt the fixed caller charges the attempt its reservation, the count plus the margin as input and the output limit as output, and refuses the attempt when the totals charged to its role or to the job would then pass a ceiling. When the provider reports what the attempt used, the reported usage replaces the reservation: the input charged is the sum of the uncached input and the input written to and read from the cache, each token counted once and never less than the count, and the output charged is the reported output. An attempt for which the provider reports nothing, one that timed out for instance, keeps its reservation. A refused call ends the job not_converged with the reason token_ceiling_reached, whatever the Matsya handlers then return or raise, every later call of the job is refused, and the job's record keeps its calls and cycles together with the counts and the charges under usage, as counts, digests and names without text. A training pass does not change ceilings, so that the configurations it compares run under the same bounds, and context_tokens changes only with the language model a role names. The loader refuses a configuration under which a role's first call could never be made: a ceiling of 0 for one of the five roles a job calls or for the job's input, an output ceiling below a role's output limit, a context_tokens not above the role's output limit plus the margin, or a role a job calls whose provider has no counter.
A turn of conversation mode has a token ledger of its own, which the turn runner builds for each turn and passes to the fixed caller: the shared ceiling of a turn is ceilings.turn, in the place ceilings.job holds for a job, and each role a turn calls, the conversation role and, for a stage file the question names, the prose writer, is bounded within the turn by its own entry of roles. A call refused at a ceiling ends the turn incomplete with the reason token_ceiling_reached, whatever the Matsya handler then returns or raises, and the turn's record holds the ledger under usage. The loader refuses a configuration that names the conversation role without ceilings.turn or the role's entry, or with an output ceiling of a turn below the output limit of the conversation role or the prose writer, and one that holds either entry without naming the role.
5 The retrieved passages and the requests¶
The Matsya handlers reach the index and the guides' records through the reading controller, the class ReadingController of retrieval/context.py, which the processor builds for each job over the job's snapshot and hands to them as the job frame's index. An invocation is one run of the Matsya handler prepare or write; at its start the Matsya handler binds the controller to the invocation's role, and the controller then holds the job's snapshot, the guides the role may read (the writer's and the calculus guide for the Model-prose-writer, the writer's guide alone for Prose-to-Bellman-Sym), the collections the job's principal may read, the request's source clusters and the role's allowances of the setting reading. A Matsya handler may narrow the controller's filters and never widen them.
The initial search. Each invocation of preparation searches the index once at its start, through the Matsya handler writer_references: the query names the concepts the source material names, terms of the language such as stage or perch and economic concepts such as household or adjustment cost, read with two lists of the Matsya handler module, at most 1,000 characters; retrieval_search_text is the query only when the source material names no concept. When the job continues an earlier job of the same session, a new preparation attempt (below), the terms of the language that the earlier job's questions name stand first, then the concepts the earlier source material did not name. The search returns at most retrieval_passage_limit passages, restricted by the controller to the collections the job's principal may read, the public collections for every principal and each private collection under a grant, whether or not a passage is marked model_prompt, with the sources of the paper under study excluded by their source cluster or, when the request names no cluster, every clustered source excluded; the controller checks each passage again before it places it. The passages stand in the source preparer's message under the label retrieved Bellman language passages, each written as Source <source_id> at <path> (<heading>), address <address>: followed by its text and a line of what is recorded as related to it, and their identities are stored in the record under retrieval.writer_passage_ids. The Bellman-SYM writer receives the same passages for the initial declaration from \(M\); in a numbered iteration it searches again from that iteration's prose and receives none of preparation's passages. The passages of HARK and Buffer Stock Theory may therefore reach the Model-prose-writer and Prose-to-Bellman-Sym in every job, and those of the literature, the articles and the private repository notes only in the job of a principal granted their collection.
The requests. In place of its ordinary answer, the source preparer or the Bellman-SYM writer may return one request, exactly one JSON object whose sole key is matsya_request, alone or inside one JSON code fence:
{"matsya_request": {"source": "guide", "operation": "read", "guide": "writer", "page": "docs/wiki/perch.md", "section": null}}
source is guide or index; operation is read, the text of a page, a section or a passage, related, the candidates recorded as related to one, or, for the index alone, search, with a query. A guide address names the guide, the page and a section or null; an index address is a target, a reference the controller issued with an earlier line or result. The Matsya handler examines every answer for the request form before the role's own parsers, so that a malformed request never reaches the Bellman-SYM writer's parser of a distribution question, and has the controller answer it. The controller answers with one object matsya_result whose status is one of ok, no_matches, unavailable, ambiguous, disallowed, already_supplied, limit_reached, malformed_request and unsupported, and places it, with the text a read returns, in the role's next message under the label the material your requests added, after the cached prefix and once. The controller records the ranges of each page that stand in the message: a read whose text stands there whole answers already_supplied, and a read whose text stands there in part supplies the rest, each range already present replaced by one line naming the section or part that holds it, so that reading a section and then its page leaves every sentence once and the rest of the page reachable. A section is named by its identifier or its heading; a name that several sections carry, two sections written with one explicit identifier such as {#same} among them, answers ambiguous with the candidates and their headings, and the controller substitutes none. A request may name only an address already shown in the invocation, a page or passage supplied or a candidate listed; another is disallowed. An absent index target and a target the restriction forbids receive the same unavailable, and a related or search result over the index leaves forbidden targets out with their names, headings, reasons and counts. The candidates of a related result stand in one order: the targets of the origin's links in the order of the links, then, for each of its topic tags, that tag's defining page and the other candidates by path; each candidate carries its reason, an authored link or a shared tag, and its availability.
The allowances and the part of addresses. Each message of the two roles holds, under the label the addresses you may request, the remaining allowances and, for each guide page supplied, its address, its topic tags and at most max_related_results of the pages its authors link to. A request consumes one of the request_rounds, whether it is valid, malformed or repeated, and none of the rounds in which the role prepares or writes (preparer_rounds, writer_rounds); a search consumes one of the max_searches, the initial search included; a related or search result lists at most max_related_results candidates, the rest reached by position; a result that would carry the material requests add past max_added_characters, or the retrieved material of one message past max_retrieval_tokens, counted with the language-model token counter of §1, is refused as limit_reached, never shortened. A refusal's own block is counted against max_retrieval_tokens too, though not against max_added_characters; a refusal whose block would not fit is replaced by the shortest refusal, limit_reached with no address, and the invocation's later requests are then answered without being carried out, which the part of addresses states. A read result holds at most 4,000 characters of text, a longer page or section being read in parts. When the role answers with a request and no request round remains, the controller does not execute it and the invocation ends: preparation returns not_converged with the reason request_rounds_exhausted, an empty description and empty lists of page references and questions, and a writing returns the files of its earlier rounds, or none, which cycle keeps with that reason. The record of the job holds under reading, for each invocation and each of its calls, the identities of the pages, sections and passages its message held, the digests of the guides and of the snapshot, and the status and reason of each request, never text.
A new preparation attempt. A job that names a session whose earlier job holds a record continues that job: the job store's latest job of the session is read, its identity, status and source digest stand in the new job's record under continues beside the new job's own source digest, and preparation runs again on the whole enlarged source material, the initial search naming the new concepts first. The earlier job's record and the description it accepted are never altered. The record states with the initial search whether the source material gained a concept, changed only its requested formulation, or neither.
6 The source¶
The request's source becomes a Source record through the Matsya handler normalize_source. A typed description is {"kind": "description", "text": ...}; its text is stripped and its digest is the SHA-256 of the stripped text. A paper is {"kind": "paper", "text": ...}, the paper's text in Markdown or LaTeX, kept as sent so that the lines of its references are the lines of the file, and its digest is the SHA-256 of that text; a paper sent as numbered pages or as a PDF is refused with the sentence that a paper is sent as text, and a PDF is converted to Markdown or LaTeX before it is sent. Either text holds at most 8,000,000 characters. A job started from a session whose entries hold a paper entry is sent as a paper, so that the checks of a paper apply to the session's text.
7 Where a text and the code depend on each other¶
The answer formats the texts ask for are read by code in the Matsya handlers that expects exactly those formats, so a change of a text that alters an answer's format needs a matching change of the code: the four JSON fields of the source preparer, the judge's JSON with its ten item names, the distribution check's three fields, the Bellman-SYM writer's ### file: <name> blocks, its # from: lines, its JSON input request and its ## Assumptions supplied heading; the heading Structure of the description \(M\) and its lines - period <name>: <key>, <key>, one for each period template, which the function structure_of of the Matsya handler module reads; and the heading ## Values left to $fill of a recipe's note, which the Matsya handlers write and unresolved_note read. The request form matsya_request, its fields and its statuses, which the texts of the source preparer and the Bellman-SYM writer explain, are read by the reading controller, which is part of the program; a text may explain them differently but cannot change them, and the labels of the controller's parts that the texts name are the controller's. The ten judge items are spelled identically in BellmanStageProse-judge.md and in the Matsya handler module, matsya_handler.py. The texts of 8 October 2026 contain three inconsistencies: the Bellman-SYM writer's text promises "any exemplars permitted for this request", and no Matsya handler sends a part so labeled; the same text says "You have at most three rounds in all", which repeats the setting writer_rounds and would contradict it if the setting changed; and the headings of ElaboratedSemanticObject-to-BellmanStageProse.md and typed-form-writer.md still say "reader", though the role is now called "prose writer".
8 The message of a turn¶
A configuration that enables the optional conversation role, conversation_answer (a provisional key), answers a question asked in a session in a turn, under the instruction text texts/conversation-answer.md. The turn runner, TurnRunner of conversation.py, binds the reading controller for the turn and calls the Matsya handler conversation_reply once (The Matsya handlers §7).
What the role may read. The turn runner binds the controller to the turn's snapshot of the index: the active index when the turn starts, or the earlier snapshot that the request names by index_digest, which can be searched when it was built with the service's encoder and otherwise answers a search request unsupported. It binds it as well to the collections the person asking may read, to the conversation role's allowances of reading, counted over the whole turn, and to three guides, writer, calculus and reader. Unlike a job's controller it excludes no source cluster, since a turn writes no declaration. A passage enters a message when the person may read its collection, whether or not it is marked model_prompt, so that the literature, the articles and the private repository passages appear in a turn's message for a person granted them, as they appear in the results of POST /v1/search and POST /v1/answer, and a request for a passage the person may not read receives the same unavailable as an absent address. The controller has a third source beside the guides and the index, job: the outputs of the jobs started from the session, that is, the description \(M\), the dossier of the elaborated semantic object, the prose writer's description \(M'\), the judge's tables, the comparison profile, the elaborator's refusals and the stage files, each addressed as job:<job>/<output> and read with read. Each job carries a label: the session's name, the version of the session's text the job was built from (the session's revision when the job started, or, for a job a turn submitted, when the turn submitted it), the job's number among the session's jobs and its state, as in Household with firms · version 2 · job 7 · converged, with , built from an earlier version after a job that was not current at its end; the part of addresses gives it beside each output. The job a turn reads without a request is the session's selected job, the job its user chose through POST /v1/sessions/{session_id}/selected-job, or, when none is selected, the latest job that holds a record and was current at its end; a job that was not current, or that its user cancelled, reaches a message only when the selection or a read request names it, and the line that heads its material then states the version of the text it was built from and the version the text is at now. The turn's result names under job the job whose outputs were supplied without a request, with its label, or holds null. The retained evidence of a turn is the set of passages the previous turn of the session cited; the turn runner reads each again from the turn's snapshot and keeps it only when the snapshot holds it and the person may still read it and send it, recording each other one as dropped with the reason not_in_snapshot or not_permitted.
The parts. The starting conversation_reply makes one search from the question and assembles each message in this order: the instruction text and the pages conversation_pages names, from the calculus guide, the language guide and the stage interface guide, as the cached prefix; the passages of the search, then the retained passages, under retrieved Bellman language passages; the addresses you may request, which lists the guide pages and, one line each, the outputs of every job of the session; after the role's first request, the material your requests added; the decision list of the previous turn, the user's decisions and the questions still open, each one sentence with the numbers of the entries it rests on; the session's entries before the question, each under a line naming its number, its kind, the job or turn that wrote it and the entry it replies to; the outputs of the job this conversation discusses, which holds, all but its stage files, the outputs of the job the turn reads without a request, the selected job or else the latest current job, when there is one; for a stage file the question names, which the turn runner elaborates before the Matsya handler runs, the dossier of the stage file the question names with the prose writer's description of that dossier, written by the prose writer from the dossier alone, or the elaborator's refusal of the stage file the question names; the fields the caller attached, refusal, timing and package_version; and the question. No message holds the text of the stage file a question names, and a job's stage files reach a message only by the role's read request, which its instruction text reserves for a question about their spelling.
The answer and its checks. The role answers with one request in the form of §5, or with one JSON object holding status, which is answered or needs_input; answer; citations, each an address copied from the message with a quote from the material at that address; questions; decisions, the decision list brought up to date; and, with answered alone, submit_job when the question asks for a job. The Matsya handler examines every answer for the request form first, checks the rest, and sends an answer whose form, citations or decision list fail back to the role under your previous answer and the faults of your previous answer, within conversation_rounds answers. The turn runner checks the Matsya handler's return again: every citation must name material supplied in the turn and its quote must occur in that material, runs of white space counting as one space, within one supplied part or within parts that stand next to one another in their source, so that two parts with an unread part between them never form a quotation, or the turn ends incomplete with unsupported_citation; a decision item that names an entry above the question is dropped. The turn runner fills in each citation of the result with the material's path, heading, location and standing in the project as the index or the guide records them. A turn that reaches a limit ends incomplete with request_rounds_exhausted, conversation_rounds_exhausted or token_ceiling_reached, and its answer is two fixed sentences of the program, the first naming the reason and the second the request or call not carried out; a call the provider cannot complete ends it incomplete with the call's code, one fixed sentence and the material already supplied listed. The record of a turn, of schema matsya-conversation-turn/1, holds the calls, the reading record, the retained passages kept and dropped, the decision lists and the ledger, and holds no message text and no passage text beyond the result.
A job the turn submits. When the question asks for a job to be started from the session, in whatever words ("submit this as a job"), the role's answer carries submit_job, {"max_cycles": <integer or null>, "target": <target>}, which the Matsya handler accepts with answered alone and checks against the setting cycle_maximum and the four targets, stage, period, trellis and recipe: the target the user's words name or, when they name none, the one the role infers from the discussion and states in its answer, so that the person can correct it in the next turn. Once the answer's citations are accepted, the turn runner submits a job from the turn's session through the job runner, as the person asking, before it stores the turn's record. The job store fixes the job's version at that moment, so that the job's source material is the session's text with the question that asked for it, however long the job waits for a worker. The turn's result names the job under job_started with its label, and the job's record and GET /v1/model-iterations/{job_id} name the turn under started_by. When the service refuses the submission, because the session holds no text but the question, because the answer asks for more cycles than the configuration allows, or because no worker can take the job, job_started is null and the turn runner appends to the answer a fixed sentence that says why; the turn still ends answered. The role cancels no job and selects none; the person does both with the client.