scout-ai 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +133 -58
  3. data/README.md +2 -1
  4. data/VERSION +1 -1
  5. data/doc/Improvements.md +490 -148
  6. data/doc/Model.md +53 -10
  7. data/doc/StartHere.md +44 -19
  8. data/doc/developer/Architecture.md +25 -6
  9. data/doc/developer/Backends.md +207 -48
  10. data/doc/developer/ChatLifecycle.md +121 -20
  11. data/doc/developer/DelegationInternals.md +319 -33
  12. data/doc/developer/DesignPrinciples.md +205 -16
  13. data/doc/developer/PathEngine.md +628 -0
  14. data/doc/developer/PromptProcessing.md +332 -82
  15. data/doc/developer/Provenance.md +388 -40
  16. data/doc/developer/Sandbox.md +213 -0
  17. data/doc/user/BuildingAgents.md +130 -18
  18. data/doc/user/Cookbook.md +29 -8
  19. data/doc/user/CoreConcepts.md +7 -6
  20. data/doc/user/Delegation.md +166 -15
  21. data/doc/user/GettingStarted.md +20 -16
  22. data/doc/user/ManagingContext.md +155 -17
  23. data/doc/user/MultiAgentWorkflows.md +105 -15
  24. data/doc/user/Python.md +11 -1
  25. data/doc/user/RunningInference.md +90 -47
  26. data/doc/user/ToolCalling.md +134 -29
  27. data/doc/user/WritingChats.md +56 -27
  28. data/lib/scout/llm/agent/attach.rb +13 -17
  29. data/lib/scout/llm/agent/chat.rb +32 -0
  30. data/lib/scout/llm/agent/construction.rb +64 -0
  31. data/lib/scout/llm/agent/conversation.rb +304 -0
  32. data/lib/scout/llm/agent/delegate.rb +56 -238
  33. data/lib/scout/llm/agent/path/edit.rb +230 -0
  34. data/lib/scout/llm/agent/path/patch.rb +252 -0
  35. data/lib/scout/llm/agent/path/workflow_kinds.rb +175 -0
  36. data/lib/scout/llm/agent/path.rb +1777 -0
  37. data/lib/scout/llm/agent/save.rb +11 -9
  38. data/lib/scout/llm/agent/workflow.rb +77 -16
  39. data/lib/scout/llm/agent.rb +147 -31
  40. data/lib/scout/llm/ask.rb +28 -17
  41. data/lib/scout/llm/backends/anthropic.rb +1 -1
  42. data/lib/scout/llm/backends/bedrock.rb +3 -2
  43. data/lib/scout/llm/backends/default.rb +127 -34
  44. data/lib/scout/llm/backends/glm.rb +28 -1
  45. data/lib/scout/llm/backends/huggingface.rb +1 -1
  46. data/lib/scout/llm/backends/ollama.rb +1 -1
  47. data/lib/scout/llm/backends/openai.rb +7 -6
  48. data/lib/scout/llm/backends/openwebui.rb +14 -7
  49. data/lib/scout/llm/backends/relay.rb +8 -2
  50. data/lib/scout/llm/chat/agent_meta.rb +24 -60
  51. data/lib/scout/llm/chat/parse.rb +1 -1
  52. data/lib/scout/llm/chat/process/files.rb +10 -0
  53. data/lib/scout/llm/chat/process/meta.rb +5 -7
  54. data/lib/scout/llm/chat/process/tools.rb +104 -49
  55. data/lib/scout/llm/chat/prompt/epoch_tool_compactation.rb +355 -0
  56. data/lib/scout/llm/chat/prompt/inbox.rb +188 -0
  57. data/lib/scout/llm/chat/prompt/shorten_tools.rb +797 -13
  58. data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +1 -365
  59. data/lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb +1 -0
  60. data/lib/scout/llm/chat/prompt.rb +24 -10
  61. data/lib/scout/llm/chat/provenance/live.rb +1080 -0
  62. data/lib/scout/llm/chat/provenance/tokens.rb +386 -0
  63. data/lib/scout/llm/chat/provenance.rb +343 -676
  64. data/lib/scout/llm/chat.rb +8 -2
  65. data/lib/scout/llm/embed.rb +15 -3
  66. data/lib/scout/llm/image.rb +4 -1
  67. data/lib/scout/llm/mcp.rb +4 -2
  68. data/lib/scout/llm/request_context.rb +234 -0
  69. data/lib/scout/llm/sandbox.rb +263 -0
  70. data/lib/scout/llm/tools/call.rb +163 -42
  71. data/lib/scout/llm/tools/definition.rb +48 -0
  72. data/lib/scout/llm/tools/knowledge_base.rb +1 -0
  73. data/lib/scout/llm/tools/mcp.rb +50 -43
  74. data/lib/scout/llm/tools/workflow.rb +90 -20
  75. data/lib/scout/llm/tools.rb +14 -41
  76. data/lib/scout/model/decision/base.rb +43 -0
  77. data/lib/scout/model/decision/jev.rb +161 -0
  78. data/lib/scout/model/python/torch.rb +1 -1
  79. data/research/clear-tools-inherit.md +171 -0
  80. data/research/path-engine-dc1-dc2-dc3-fixes.md +279 -0
  81. data/research/path-kind-chat-role.md +96 -0
  82. data/research/path-kind-contract-fixes-engine.md +307 -0
  83. data/research/scout-ai-runtime-availability.md +65 -0
  84. data/research/subsys/README.md +127 -0
  85. data/research/subsys/agent-delegation.md +201 -0
  86. data/research/subsys/agent-society.md +275 -0
  87. data/research/subsys/agentworkflow.md +233 -0
  88. data/research/subsys/backends.md +221 -0
  89. data/research/subsys/chat.md +314 -0
  90. data/research/subsys/embed-image.md +244 -0
  91. data/research/subsys/entry-cli.md +253 -0
  92. data/research/subsys/model-ml.md +326 -0
  93. data/research/subsys/provenance.md +290 -0
  94. data/research/subsys/tools.md +334 -0
  95. data/scout-ai.gemspec +71 -27
  96. data/scout_commands/agent/ask +8 -7
  97. data/scout_commands/llm/abridged +40 -0
  98. data/scout_commands/llm/ask +9 -9
  99. data/scout_commands/llm/md +2 -0
  100. data/scout_commands/llm/prov +724 -59
  101. data/scout_commands/llm/word +4 -0
  102. data/share/word/reference.docx +0 -0
  103. data/test/integration/scout/model/decision/test_jev.rb +144 -0
  104. data/test/scout/llm/agent/test_attach.rb +117 -0
  105. data/test/scout/llm/agent/test_conversation.rb +407 -0
  106. data/test/scout/llm/agent/test_delegate.rb +209 -0
  107. data/test/scout/llm/agent/test_path.rb +1812 -0
  108. data/test/scout/llm/agent/test_path_edit.rb +908 -0
  109. data/test/scout/llm/agent/test_path_errors.rb +390 -0
  110. data/test/scout/llm/agent/test_path_filesystem.rb +532 -0
  111. data/test/scout/llm/agent/test_path_patch.rb +233 -0
  112. data/test/scout/llm/agent/test_path_promotion.rb +386 -0
  113. data/test/scout/llm/agent/test_path_workflow_integration.rb +665 -0
  114. data/test/scout/llm/agent/test_save.rb +70 -15
  115. data/test/scout/llm/agent/test_workflow.rb +130 -4
  116. data/test/scout/llm/backends/test_anthropic.rb +4 -4
  117. data/test/scout/llm/backends/test_bedrock.rb +4 -4
  118. data/test/scout/llm/backends/test_format_other.rb +43 -0
  119. data/test/scout/llm/backends/test_ollama.rb +2 -2
  120. data/test/scout/llm/backends/test_openwebui.rb +12 -8
  121. data/test/scout/llm/backends/test_reasoning.rb +114 -0
  122. data/test/scout/llm/chat/agent_meta_fixtures.rb +28 -27
  123. data/test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb +612 -0
  124. data/test/scout/llm/chat/prov_plot_fixtures.rb +131 -0
  125. data/test/scout/llm/chat/test_agent_meta.rb +40 -80
  126. data/test/scout/llm/chat/test_agent_meta_provenance.rb +67 -28
  127. data/test/scout/llm/chat/test_agent_meta_tokens.rb +59 -8
  128. data/test/scout/llm/chat/test_agent_view.rb +178 -0
  129. data/test/scout/llm/chat/test_live_report.rb +282 -0
  130. data/test/scout/llm/chat/test_live_workload.rb +193 -0
  131. data/test/scout/llm/chat/test_parse.rb +32 -2
  132. data/test/scout/llm/chat/test_prompt.rb +411 -0
  133. data/test/scout/llm/chat/test_prov_cli.rb +310 -15
  134. data/test/scout/llm/chat/test_prov_cli_live.rb +152 -0
  135. data/test/scout/llm/chat/test_prov_plot.rb +213 -0
  136. data/test/scout/llm/chat/test_prov_timeline.rb +355 -0
  137. data/test/scout/llm/chat/test_provenance.rb +67 -22
  138. data/test/scout/llm/chat/test_provenance_index.rb +479 -0
  139. data/test/scout/llm/chat/test_society_view.rb +159 -0
  140. data/test/scout/llm/test_agent.rb +1 -1
  141. data/test/scout/llm/test_embed.rb +103 -1
  142. data/test/scout/llm/test_request_context.rb +299 -0
  143. data/test/scout/llm/test_sandbox.rb +249 -0
  144. data/test/scout/llm/tools/test_agent_pairing.rb +150 -0
  145. data/test/scout/llm/tools/test_call_delegation_conflict.rb +316 -0
  146. data/test/scout/llm/tools/test_definition.rb +332 -0
  147. data/test/scout/llm/tools/test_jobs_file.rb +211 -0
  148. data/test/scout/llm/tools/test_mcp.rb +37 -8
  149. data/test/scout/llm/tools/test_workflow.rb +45 -1
  150. data/test/scout/model/decision/test_jev.rb +453 -0
  151. data/test/scout/model/python/huggingface/causal/test_next_token.rb +7 -10
  152. data/test/scout/model/python/huggingface/test_causal.rb +11 -2
  153. data/test/scout/model/python/huggingface/test_classification.rb +5 -3
  154. data/test/scout/model/python/test_availability.rb +116 -0
  155. data/test/scout/model/python/test_torch.rb +54 -2
  156. data/test/support/availability.rb +72 -174
  157. data/test/support/fake_clients.rb +18 -9
  158. data/test/support/fixtures.rb +75 -6
  159. data/test/support/mock_backend.rb +9 -1
  160. data/test/support/test_fixtures.rb +156 -0
  161. data/test/test_helper.rb +14 -4
  162. metadata +70 -26
  163. data/research/ChatAnalyst-required-changes.md +0 -167
  164. data/research/agent-delegation-analysis.md +0 -810
  165. data/research/agent-meta-provenance-integration-plan.md +0 -622
  166. data/research/agent-workflow-analysis.md +0 -1120
  167. data/research/backends-analysis.md +0 -836
  168. data/research/chat-core-analysis.md +0 -946
  169. data/research/chatanalyst-provenance/00-baseline.md +0 -30
  170. data/research/chatanalyst-provenance/01-repo-map.md +0 -60
  171. data/research/chatanalyst-provenance/02-event-reconstruction.md +0 -55
  172. data/research/chatanalyst-provenance/03-duplication-evidence.md +0 -45
  173. data/research/chatanalyst-provenance/04-tooling-root-cause.md +0 -57
  174. data/research/chatanalyst-provenance/05-fix-plan.md +0 -46
  175. data/research/chatanalyst-provenance/07-critic-review.md +0 -25
  176. data/research/chatanalyst-provenance/final-report.md +0 -45
  177. data/research/chatanalyst-provenance/resumption.md +0 -37
  178. data/research/coding-philosophy-analysis.md +0 -928
  179. data/research/commands-analysis.md +0 -947
  180. data/research/multi-agent-patterns-analysis.md +0 -853
  181. data/research/prompt-strategies-analysis.md +0 -630
  182. data/research/prov-verbosity-fix-notes.md +0 -77
  183. data/research/provenance-analysis.md +0 -469
  184. data/research/provenance-continuation-accounting.md +0 -255
  185. data/research/synthesis-report.md +0 -487
  186. data/research/tools-system-analysis.md +0 -779
@@ -7,8 +7,9 @@ It is intended for framework contributors.
7
7
 
8
8
  > For the user-facing chat-file format guide, see
9
9
  > [../user/WritingChats.md](../user/WritingChats.md).
10
- > For deep code investigation, see
11
- > [../../research/chat-core-analysis.md](../../research/chat-core-analysis.md).
10
+ > For the probe-verified subsystem study (roles, parse/print round-trip,
11
+ > compilation, persistence), see
12
+ > [../../research/subsys/chat.md](../../research/subsys/chat.md) under `research/`.
12
13
 
13
14
  ---
14
15
 
@@ -48,10 +49,10 @@ recognizes these roles:
48
49
  | `user` | User message | Yes |
49
50
  | `assistant` | Model response | Yes |
50
51
  | `function_call` | Tool invocation request from model | Yes (as provider-specific tool_call) |
51
- | `function_call_output` | Tool execution result. May carry a `meta` key: an Array of already-deserialized receipt field Hashes (delegated inference metadata such as `pt`/`ct`/`tt`/`inference_id`, or `{"job":"<path>"}` producer references), embedded by `LLM.process_calls` when the tool returned an `LLM::Agent`. Legacy chats may instead carry a serialized `agent_meta` key; both are read, `meta` wins when both are present. Outputs may also carry auxiliary `step`/`start_timestamp`/`timestamp` fields; `step` is bookkeeping, not a provenance edge. See [Provenance.md](Provenance.md). | Yes (as provider-specific tool result) |
52
+ | `function_call_output` | Tool execution result. May carry a `meta` key: an Array of already-deserialized receipt field Hashes (delegated inference metadata such as `pt`/`ct`/`tt`/`inference_id`, or `{"job":"<path>"}` producer references), embedded by `LLM.process_calls` when the tool returned an `LLM::Agent`. Only `meta` is read; the legacy serialized `agent_meta` key is no longer accepted, so legacy envelopes contribute no receipt evidence. Outputs may also carry auxiliary `step`/`start_timestamp`/`timestamp` fields; `step` is bookkeeping, not a provenance edge. See [Provenance.md](Provenance.md). | Yes (as provider-specific tool result) |
52
53
  | `meta` | Provenance metadata (tokens, job references) | **No** — stripped before inference |
53
54
  | `tool` | Tool definition (inline in chat) | No — extracted into tool registry |
54
- | `introduce` | Workflow/tool introduction | No — extracted, introduces tools to the model context |
55
+ | `introduce` | Workflow introduction | No — extracted; replaced by a `user:` message with the workflow's documentation (generates no tools) |
55
56
  | `mcp` | MCP server declaration | No — extracted into tool registry |
56
57
  | `kb` | Knowledge base declaration | No — extracted into tool registry |
57
58
  | `association` | Association declaration | No — extracted |
@@ -62,6 +63,31 @@ The `meta`, `tool`, `introduce`, `mcp`, `kb`, `option`, and similar roles are
62
63
  **side-channel** roles: they are extracted from the message array during
63
64
  compilation and do not appear in the prompt sent to the model.
64
65
 
66
+ The table above lists the roles that shape the *stored* message array. The
67
+ compilation pipeline consumes further roles that never reach the backend at
68
+ all — each is resolved to ordinary `user:`/`assistant:` content (or removed)
69
+ by the stage named below:
70
+
71
+ | Compiled-away role | Stage (`Chat.chat`) | Resolution |
72
+ |---|---|---|
73
+ | `import` / `continue:` / `last:` | imports (`Chat.imports`) | File read + `LLM.purge`d expansion; `continue:` keeps only the last non-empty message, `last:` only the purged last |
74
+ | `clear` / `clear_tools` / `clean_role` / `clear_role` | clear (`Chat.clear`) | `clear` truncates history at its position; `clear_tools` drops `function_call*` after it; `clean_role`/`clear_role` name roles to clean |
75
+ | `skip` / `previous_response_id` | clean (`Chat.clean`) | Dropped from the prompt (default clean roles) |
76
+ | `config` | config (`Chat.config`) | Applied as `Scout::Config.set(key, value, *tokens)`, message removed |
77
+ | `task` / `inline_task` / `exec_task` | tasks (`Chat.tasks`) | Workflow job created; `exec_task` runs it and inlines the result, `task`/`inline_task` leave a `job`/`inline_job` message |
78
+ | `job` / `inline_job` | jobs (`Chat.jobs`) | Loaded Step rendered as a `function_call` + `function_call_output` pair (or, for `inline_job`, an inline `file`) |
79
+ | `directory` / `step` | files (`Chat.files`) | `directory` expands to a `file` message per file below it; `step` loads the referenced job step's answer as an `assistant` message |
80
+ | `allow_path` / `allow_read_path` | files (`Chat.files`) | Sandbox grant side-effect (`Chat.allow_path` / `Chat.allow_read_path`); message removed (compacted away) |
81
+
82
+ `previous_response_id` deserves a note: it survives compilation in the stored
83
+ chat (`Chat.options` keeps it as a *sticky* option, unlike most options which
84
+ reset after an `assistant` reply) but `Chat.clean` drops it from the prompt
85
+ content, and `Chat.pull`/`Chat.purge` move/remove it so the backend can
86
+ consume it as a provider continuation token.
87
+
88
+ The parser accepts any `role:` prefix, so unrecognized roles pass through
89
+ untouched; only the roles named above have compile-time behavior.
90
+
65
91
  ---
66
92
 
67
93
  ## The Annotation pattern
@@ -95,27 +121,53 @@ transforms it through several stages:
95
121
  Input (String / file / Array)
96
122
  │
97
123
  ▼
98
- 1. Parse — Chat.parse: text → Array<Hash>
99
- │ (handles role: directives, block form, indented content)
124
+ 1. Parse — Chat.parse: text → Array<Hash>
125
+ │ (handles role: directives, block form, indented content)
126
+ ▼
127
+ 2. Indiferent — every message Hash is set up as an IndiferentHash
128
+ │ (symbol/string-indifferent access)
129
+ ▼
130
+ 3. Imports — import:/continue:/last: references expanded
100
131
  ▼
101
- 2. Extract options — options: directives extracted into options hash
102
- │ (model:, endpoint:, backend:, etc.)
132
+ 4. Clear — clear: directives processed
133
+ │ (removes tool outputs from history)
103
134
  ▼
104
- 3. Extract tools — tool:/introduce:/mcp:/kb: roles extracted
105
- │ into a tool registry hash
135
+ 5. Clean — Chat.clean: default roles dropped from the prompt
136
+ │ ('skip', 'previous_response_id')
106
137
  ▼
107
- 4. Extract clear — clear: directives processed
108
- │ (removes tool outputs from history)
138
+ 6. Config — Chat.config: `config:` messages applied as Scout::Config.set
109
139
  ▼
110
- 5. prepare_prompt — context strategies applied (shorten_tools)
111
- │ EPHEMERAL: operates on a copy, never mutates stored chat
140
+ 7. Tasks — task:/inline_task:/exec_task: messages run eagerly
141
+ │
142
+ ▼
143
+ 8. Jobs — pending jobs produced (Workflow.produce)
144
+ ▼
145
+ 9. Files — file:/directory:/step: roles resolved to content or paths
146
+ ▼
147
+ 10. Setup — Chat.setup: the array is annotated with the Chat DSL,
148
+ producing the compiled chat
149
+
150
+ Steps 2–10 are `Chat.chat`'s own order —
151
+ indiferent → imports → clear → clean → config → tasks → jobs → files →
152
+ setup — with parsing (step 1) done by `Chat.messages` before it. This
153
+ listing is complete; there is no hidden stage.
154
+ │
112
155
  ▼
113
- 6. format_messages — Backend translates into provider-specific format
156
+ Backend path — endpoint/model/backend option: roles and
157
+ tool:/introduce:/mcp:/kb:/association: roles are
158
+ extracted here (Chat.options / Chat.tools), then
159
+ prepare_prompt applies the context strategies
160
+ (EPHEMERAL: operates on a copy, never mutates the stored chat)
161
+ and format_messages translates into the provider format
114
162
  │
115
163
  ▼
116
164
  API call
117
165
  ```
118
166
 
167
+ Note that options and tools extraction happens on the **backend path**, after
168
+ the chat itself has been compiled — that is why `option:`/`tool:` roles are
169
+ compiled away from the prompt but still configure the request.
170
+
119
171
  ### Key properties
120
172
 
121
173
  - **Side-channel extraction**: Roles like `tool`, `option`, and `meta` are
@@ -153,6 +205,24 @@ format (see [../user/WritingChats.md](../user/WritingChats.md)). The
153
205
 
154
206
  - **Load**: `LLM.chat(path)` or `Chat.setup(Chat.parse(File.read(path)))`.
155
207
  - **Save**: `Chat.print(chat)` produces the text representation.
208
+ - `Chat.load(file)` is the **no-compile** reader (`Chat.setup(Chat.parse(...))`
209
+ only, no task/job/file/import expansion). Provenance inspection uses it so
210
+ reading a chat never re-executes anything.
211
+ - Annotated chats carry three writers that all default a bare filename to
212
+ `Scout.chats` and **overwrite by default** — `save` (`LLM.print` of the
213
+ chat), `write` (`self.print` — the processed form), and `write_answer`
214
+ (the final answer text only) all take `force = true`, and an existing file
215
+ is skipped only when called with `force: false`
216
+ (`Chat#save`/`Chat#write`/`Chat#write_answer` in `chat/annotation.rb`).
217
+ If a persistence path must not clobber prior output, pass `force: false`
218
+ explicitly; with `force: false` a colliding write is silently dropped, not
219
+ queued.
220
+ - `.chat` is also a **workflow result type** (`Workflow::TYPE_EXTENSIONS[:chat]`
221
+ with `Persist.save_drivers`/`load_drivers` in `chat/persist.rb`). Saving an
222
+ `LLM::Agent` through that driver writes `current_chat - start_chat` — this
223
+ run's delta, not the seeded preamble — while saving a plain Chat/Array writes
224
+ every message. That is why a `chat_task` result file and the agent's
225
+ full-conversation sidecar (`<job>.files/<name>.chat`) differ in length.
156
226
 
157
227
  The format is human-readable and diffable, making it ideal for version control
158
228
  and inspection.
@@ -166,12 +236,43 @@ and inspection.
166
236
  | `lib/scout/llm/chat.rb` | Chat module definition, `setup`, `parse` |
167
237
  | `lib/scout/llm/chat/annotation.rb` | DSL methods (user, system, ask, follow, etc.) |
168
238
  | `lib/scout/llm/chat/parse.rb` | Text → Array<Hash> parser |
169
- | `lib/scout/llm/chat/process/options.rb` | Option extraction |
170
- | `lib/scout/llm/chat/process/tools.rb` | Tool/introduce/mcp/kb extraction |
171
- | `lib/scout/llm/chat/process/clear.rb` | Clear directive processing |
239
+ | `lib/scout/llm/chat/process.rb` | Pipeline driver (indiferent → imports → clear → clean → config → tasks → jobs → files → setup) |
240
+ | `lib/scout/llm/chat/process/options.rb` | `Chat.config` — option/endpoint resolution |
241
+ | `lib/scout/llm/chat/process/tools.rb` | `Chat.tasks`/`Chat.jobs` plus tool/introduce/mcp/kb extraction |
242
+ | `lib/scout/llm/chat/process/clear.rb` | `Chat.clear`/`Chat.clean` |
243
+ | `lib/scout/llm/chat/process/files.rb` | `Chat.imports`/`Chat.files` |
172
244
  | `lib/scout/llm/chat/process/meta.rb` | Meta messages, provenance, message_index |
173
- | `lib/scout/llm/chat/prompt.rb` | Prompt strategies (prepare_prompt, shorten_tools) |
245
+ | `lib/scout/llm/chat/prompt.rb` | `prepare_prompt` dispatch only; the strategies themselves live in the `chat/prompt/` strategy files below |
246
+ | `lib/scout/llm/chat/prompt/shorten_tools.rb` | Truncation strategy (not in the default list) |
247
+ | `lib/scout/llm/chat/prompt/shorten_tools_epoch.rb` | Cache-friendly epoch strategy |
248
+ | `lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb` | Growing-window epoch strategy |
249
+ | `lib/scout/llm/chat/prompt/epoch_tool_compactation.rb` | Epoch schedule with pairwise tool removal + metadata records (default) |
250
+ | `lib/scout/llm/chat/prompt/inbox.rb` | Consume-once inbox strategy |
251
+
252
+ The prompt strategies are documented in
253
+ [PromptProcessing.md](PromptProcessing.md); this table only maps the files.
254
+
174
255
  | `lib/scout/llm/chat/persist.rb` | .chat file load/save |
256
+ | `lib/scout/llm/chat/provenance.rb` | Provenance/receipt traversal primitives |
257
+ | `lib/scout/llm/chat/tool_calls.rb` | Tool-call message normalization |
258
+ | `lib/scout/llm/chat/agent_meta.rb` | Agent receipt (`meta`) message shaping |
259
+
260
+ ---
261
+
262
+ ## Tests that pin this
263
+
264
+ Behavior in this document is pinned by the tests under `test/scout/llm/chat/`;
265
+ no dedicated unit test pins the `force` semantics of the persistence writers
266
+ (`Chat#save`/`#write`/`#write_answer`), which are documented from
267
+ `chat/annotation.rb` directly.
268
+
269
+ | Area | Test file | Representative cases |
270
+ |---|---|---|
271
+ | Parsing / printing round-trip | `test/scout/llm/chat/test_parse.rb` | `test_no_leading_empty_user_message`, `test_protect_print` |
272
+ | Task/job pipeline | `test/scout/llm/chat/test_process.rb` | `test_tasks_creates_jobs_and_calls_workflow_produce` |
273
+ | Meta segments / provenance metadata | `test/scout/llm/chat/process/test_meta.rb` | `test_message_identity_includes_non_meta_history`, `test_project_keeps_inference_meta_inline_with_one_job_marker`, `test_serialize_meta_quotes_value_containing_equals` (round-trips) |
274
+ | Inbox + prompt preparation | `test/scout/llm/chat/test_prompt.rb` | `test_inbox_is_consume_once`, `test_inbox_abort_file_aborts_inference_and_is_consumed_once`, `test_prepare_prompt_forwards_save_file_only_to_strategies_that_accept_it` |
275
+ | Agent receipt shaping | `test/scout/llm/chat/test_agent_meta.rb`, `test_agent_meta_tokens.rb`, `test_agent_meta_provenance.rb` | see [Provenance.md](Provenance.md) |
175
276
 
176
277
  ---
177
278
 
@@ -180,4 +281,4 @@ and inspection.
180
281
  - [../user/WritingChats.md](../user/WritingChats.md) — Chat-file format from the user perspective.
181
282
  - [PromptProcessing.md](PromptProcessing.md) — Context management internals.
182
283
  - [Provenance.md](Provenance.md) — Provenance data model.
183
- - [../../research/chat-core-analysis.md](../../research/chat-core-analysis.md) — Deep investigation.
284
+ - [../../research/subsys/chat.md](../../research/subsys/chat.md) — Probe-verified subsystem study (roles, parsing, compilation, persistence).