scout-ai 2.0.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.
- checksums.yaml +4 -4
- data/.vimproject +135 -55
- data/README.md +2 -1
- data/VERSION +1 -1
- data/doc/Improvements.md +490 -148
- data/doc/Model.md +53 -10
- data/doc/StartHere.md +44 -19
- data/doc/developer/Architecture.md +25 -6
- data/doc/developer/Backends.md +207 -48
- data/doc/developer/ChatLifecycle.md +121 -20
- data/doc/developer/DelegationInternals.md +320 -34
- data/doc/developer/DesignPrinciples.md +205 -16
- data/doc/developer/PathEngine.md +628 -0
- data/doc/developer/PromptProcessing.md +332 -82
- data/doc/developer/Provenance.md +402 -44
- data/doc/developer/Sandbox.md +213 -0
- data/doc/user/BuildingAgents.md +130 -18
- data/doc/user/Cookbook.md +29 -8
- data/doc/user/CoreConcepts.md +7 -6
- data/doc/user/Delegation.md +166 -15
- data/doc/user/GettingStarted.md +20 -16
- data/doc/user/ManagingContext.md +155 -17
- data/doc/user/MultiAgentWorkflows.md +105 -15
- data/doc/user/Python.md +11 -1
- data/doc/user/RunningInference.md +90 -47
- data/doc/user/ToolCalling.md +134 -29
- data/doc/user/WritingChats.md +56 -27
- data/lib/scout/llm/agent/attach.rb +64 -0
- data/lib/scout/llm/agent/chat.rb +32 -0
- data/lib/scout/llm/agent/construction.rb +64 -0
- data/lib/scout/llm/agent/conversation.rb +304 -0
- data/lib/scout/llm/agent/delegate.rb +56 -238
- data/lib/scout/llm/agent/path/edit.rb +230 -0
- data/lib/scout/llm/agent/path/patch.rb +252 -0
- data/lib/scout/llm/agent/path/workflow_kinds.rb +175 -0
- data/lib/scout/llm/agent/path.rb +1777 -0
- data/lib/scout/llm/agent/save.rb +11 -9
- data/lib/scout/llm/agent/workflow.rb +79 -17
- data/lib/scout/llm/agent.rb +151 -27
- data/lib/scout/llm/ask.rb +37 -27
- data/lib/scout/llm/backends/anthropic.rb +1 -1
- data/lib/scout/llm/backends/bedrock.rb +3 -2
- data/lib/scout/llm/backends/default.rb +131 -32
- data/lib/scout/llm/backends/glm.rb +28 -1
- data/lib/scout/llm/backends/huggingface.rb +1 -1
- data/lib/scout/llm/backends/ollama.rb +1 -1
- data/lib/scout/llm/backends/openai.rb +7 -6
- data/lib/scout/llm/backends/openwebui.rb +14 -7
- data/lib/scout/llm/backends/relay.rb +8 -2
- data/lib/scout/llm/chat/agent_meta.rb +24 -60
- data/lib/scout/llm/chat/parse.rb +1 -1
- data/lib/scout/llm/chat/process/files.rb +10 -0
- data/lib/scout/llm/chat/process/meta.rb +5 -7
- data/lib/scout/llm/chat/process/tools.rb +104 -52
- data/lib/scout/llm/chat/prompt/epoch_tool_compactation.rb +355 -0
- data/lib/scout/llm/chat/prompt/inbox.rb +188 -0
- data/lib/scout/llm/chat/prompt/shorten_tools.rb +797 -13
- data/lib/scout/llm/chat/prompt/shorten_tools_epoch.rb +1 -365
- data/lib/scout/llm/chat/prompt/shorten_tools_epoch_increment.rb +1 -0
- data/lib/scout/llm/chat/prompt.rb +24 -10
- data/lib/scout/llm/chat/provenance/live.rb +1080 -0
- data/lib/scout/llm/chat/provenance/tokens.rb +386 -0
- data/lib/scout/llm/chat/provenance.rb +352 -626
- data/lib/scout/llm/chat.rb +8 -2
- data/lib/scout/llm/embed.rb +15 -3
- data/lib/scout/llm/image.rb +4 -1
- data/lib/scout/llm/mcp.rb +4 -2
- data/lib/scout/llm/request_context.rb +234 -0
- data/lib/scout/llm/sandbox.rb +263 -0
- data/lib/scout/llm/tools/call.rb +163 -42
- data/lib/scout/llm/tools/definition.rb +48 -0
- data/lib/scout/llm/tools/knowledge_base.rb +1 -0
- data/lib/scout/llm/tools/mcp.rb +50 -43
- data/lib/scout/llm/tools/workflow.rb +90 -20
- data/lib/scout/llm/tools.rb +14 -41
- data/lib/scout/model/decision/base.rb +43 -0
- data/lib/scout/model/decision/jev.rb +161 -0
- data/lib/scout/model/python/torch.rb +1 -1
- data/research/clear-tools-inherit.md +171 -0
- data/research/path-engine-dc1-dc2-dc3-fixes.md +279 -0
- data/research/path-kind-chat-role.md +96 -0
- data/research/path-kind-contract-fixes-engine.md +307 -0
- data/research/scout-ai-runtime-availability.md +65 -0
- data/research/subsys/README.md +127 -0
- data/research/subsys/agent-delegation.md +201 -0
- data/research/subsys/agent-society.md +275 -0
- data/research/subsys/agentworkflow.md +233 -0
- data/research/subsys/backends.md +221 -0
- data/research/subsys/chat.md +314 -0
- data/research/subsys/embed-image.md +244 -0
- data/research/subsys/entry-cli.md +253 -0
- data/research/subsys/model-ml.md +326 -0
- data/research/subsys/provenance.md +290 -0
- data/research/subsys/tools.md +334 -0
- data/scout-ai.gemspec +72 -26
- data/scout_commands/agent/ask +8 -7
- data/scout_commands/llm/abridged +40 -0
- data/scout_commands/llm/ask +9 -9
- data/scout_commands/llm/md +2 -0
- data/scout_commands/llm/prov +845 -80
- data/scout_commands/llm/word +4 -0
- data/share/word/reference.docx +0 -0
- data/test/integration/scout/model/decision/test_jev.rb +144 -0
- data/test/scout/llm/agent/test_attach.rb +117 -0
- data/test/scout/llm/agent/test_conversation.rb +407 -0
- data/test/scout/llm/agent/test_delegate.rb +209 -0
- data/test/scout/llm/agent/test_path.rb +1812 -0
- data/test/scout/llm/agent/test_path_edit.rb +908 -0
- data/test/scout/llm/agent/test_path_errors.rb +390 -0
- data/test/scout/llm/agent/test_path_filesystem.rb +532 -0
- data/test/scout/llm/agent/test_path_patch.rb +233 -0
- data/test/scout/llm/agent/test_path_promotion.rb +386 -0
- data/test/scout/llm/agent/test_path_workflow_integration.rb +665 -0
- data/test/scout/llm/agent/test_save.rb +70 -15
- data/test/scout/llm/agent/test_workflow.rb +130 -4
- data/test/scout/llm/backends/test_anthropic.rb +4 -4
- data/test/scout/llm/backends/test_bedrock.rb +4 -4
- data/test/scout/llm/backends/test_format_other.rb +43 -0
- data/test/scout/llm/backends/test_ollama.rb +2 -2
- data/test/scout/llm/backends/test_openwebui.rb +12 -8
- data/test/scout/llm/backends/test_reasoning.rb +114 -0
- data/test/scout/llm/chat/agent_meta_fixtures.rb +109 -22
- data/test/scout/llm/chat/prompt/test_epoch_tool_compactation.rb +612 -0
- data/test/scout/llm/chat/prov_plot_fixtures.rb +131 -0
- data/test/scout/llm/chat/test_agent_meta.rb +40 -80
- data/test/scout/llm/chat/test_agent_meta_provenance.rb +200 -28
- data/test/scout/llm/chat/test_agent_meta_tokens.rb +112 -7
- data/test/scout/llm/chat/test_agent_view.rb +178 -0
- data/test/scout/llm/chat/test_live_report.rb +282 -0
- data/test/scout/llm/chat/test_live_workload.rb +193 -0
- data/test/scout/llm/chat/test_parse.rb +32 -2
- data/test/scout/llm/chat/test_prompt.rb +411 -0
- data/test/scout/llm/chat/test_prov_cli.rb +708 -13
- data/test/scout/llm/chat/test_prov_cli_live.rb +152 -0
- data/test/scout/llm/chat/test_prov_plot.rb +213 -0
- data/test/scout/llm/chat/test_prov_timeline.rb +355 -0
- data/test/scout/llm/chat/test_provenance.rb +67 -22
- data/test/scout/llm/chat/test_provenance_index.rb +479 -0
- data/test/scout/llm/chat/test_society_view.rb +159 -0
- data/test/scout/llm/test_agent.rb +1 -1
- data/test/scout/llm/test_embed.rb +103 -1
- data/test/scout/llm/test_request_context.rb +299 -0
- data/test/scout/llm/test_sandbox.rb +249 -0
- data/test/scout/llm/tools/test_agent_pairing.rb +150 -0
- data/test/scout/llm/tools/test_call_delegation_conflict.rb +316 -0
- data/test/scout/llm/tools/test_definition.rb +332 -0
- data/test/scout/llm/tools/test_jobs_file.rb +211 -0
- data/test/scout/llm/tools/test_mcp.rb +37 -8
- data/test/scout/llm/tools/test_workflow.rb +45 -1
- data/test/scout/model/decision/test_jev.rb +453 -0
- data/test/scout/model/python/huggingface/causal/test_next_token.rb +7 -10
- data/test/scout/model/python/huggingface/test_causal.rb +11 -2
- data/test/scout/model/python/huggingface/test_classification.rb +5 -3
- data/test/scout/model/python/test_availability.rb +116 -0
- data/test/scout/model/python/test_torch.rb +54 -2
- data/test/support/availability.rb +72 -174
- data/test/support/fake_clients.rb +18 -9
- data/test/support/fixtures.rb +75 -6
- data/test/support/mock_backend.rb +9 -1
- data/test/support/test_fixtures.rb +156 -0
- data/test/test_helper.rb +14 -4
- metadata +71 -25
- data/research/ChatAnalyst-required-changes.md +0 -167
- data/research/agent-delegation-analysis.md +0 -810
- data/research/agent-meta-provenance-integration-plan.md +0 -622
- data/research/agent-workflow-analysis.md +0 -1120
- data/research/backends-analysis.md +0 -836
- data/research/chat-core-analysis.md +0 -946
- data/research/chatanalyst-provenance/00-baseline.md +0 -30
- data/research/chatanalyst-provenance/01-repo-map.md +0 -60
- data/research/chatanalyst-provenance/02-event-reconstruction.md +0 -55
- data/research/chatanalyst-provenance/03-duplication-evidence.md +0 -45
- data/research/chatanalyst-provenance/04-tooling-root-cause.md +0 -57
- data/research/chatanalyst-provenance/05-fix-plan.md +0 -46
- data/research/chatanalyst-provenance/07-critic-review.md +0 -25
- data/research/chatanalyst-provenance/final-report.md +0 -45
- data/research/chatanalyst-provenance/resumption.md +0 -37
- data/research/coding-philosophy-analysis.md +0 -928
- data/research/commands-analysis.md +0 -947
- data/research/multi-agent-patterns-analysis.md +0 -853
- data/research/prompt-strategies-analysis.md +0 -630
- data/research/prov-verbosity-fix-notes.md +0 -77
- data/research/provenance-analysis.md +0 -469
- data/research/synthesis-report.md +0 -487
- data/research/tools-system-analysis.md +0 -779
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require 'scout/llm/chat'
|
|
3
|
+
require_relative 'agent_meta_fixtures'
|
|
4
|
+
|
|
5
|
+
# Focused tests for the compact path-based provenance index
|
|
6
|
+
# (`Chat.provenance_graph`): one node per call, lightweight data only,
|
|
7
|
+
# zero-based persisted message indexes, live paths listed but never
|
|
8
|
+
# traversed. Recursive behavior stays in `provenance_closure` and is
|
|
9
|
+
# covered by the other provenance suites.
|
|
10
|
+
class TestChatProvenanceIndex < Test::Unit::TestCase
|
|
11
|
+
include AgentMetaFixtures
|
|
12
|
+
|
|
13
|
+
def graph(root, **options)
|
|
14
|
+
Chat.provenance_graph(root, **options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
## (1) planned invocation triplets: job anchored at the META index
|
|
18
|
+
def test_triplet_chats_are_anchored_at_the_meta_message_index
|
|
19
|
+
TmpFile.with_dir do |dir|
|
|
20
|
+
job = make_job(dir, 'W/ask/Default_w')
|
|
21
|
+
chat = write_chat(dir, 'root.chat', [
|
|
22
|
+
'user: first', "meta: job=#{job}", 'assistant: a1',
|
|
23
|
+
'user: second', "meta: job=#{job}", 'assistant: a2'
|
|
24
|
+
] * "\n" + "\n")
|
|
25
|
+
|
|
26
|
+
index = graph(chat)
|
|
27
|
+
assert_equal :chat, index[:type]
|
|
28
|
+
# Zero-based array indexes of the two meta messages.
|
|
29
|
+
assert_equal({1 => job, 4 => job}, index[:chats])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
## (2) standalone meta reference is enough
|
|
34
|
+
def test_standalone_meta_job_reference
|
|
35
|
+
TmpFile.with_dir do |dir|
|
|
36
|
+
job = make_job(dir, 'W/ask/Default_w')
|
|
37
|
+
chat = write_chat(dir, 'root.chat',
|
|
38
|
+
"user: run\nmeta: job=#{job}\nassistant: done\n")
|
|
39
|
+
|
|
40
|
+
assert_equal({1 => job}, graph(chat)[:chats])
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
## (3) receipt reference anchored at the OUTER output message index
|
|
45
|
+
def test_receipt_reference_is_anchored_at_outer_output_index
|
|
46
|
+
TmpFile.with_dir do |dir|
|
|
47
|
+
job = make_job(dir, 'W/ask/Default_w')
|
|
48
|
+
text = receipt_chat_text({'c1' => [meta_receipt("job=#{job}")]})
|
|
49
|
+
# indexes: 0 user, 1 function_call, 2 function_call_output, 3 assistant
|
|
50
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
51
|
+
|
|
52
|
+
assert_equal({2 => job}, graph(chat)[:chats])
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
## (4) both reference forms in one transcript, same map
|
|
57
|
+
def test_both_reference_forms_merge_into_one_map
|
|
58
|
+
TmpFile.with_dir do |dir|
|
|
59
|
+
a = make_job(dir, 'A/load/Default_a')
|
|
60
|
+
b = make_job(dir, 'B/load/Default_b')
|
|
61
|
+
text = receipt_chat_text({'c1' => [meta_receipt("job=#{a}")]},
|
|
62
|
+
extra: ["meta: job=#{b}"])
|
|
63
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
64
|
+
|
|
65
|
+
assert_equal({2 => a, 3 => b}, graph(chat)[:chats])
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
## (5) multiple references at one index are preserved, not overwritten
|
|
70
|
+
def test_multiple_references_at_one_index_become_an_array
|
|
71
|
+
TmpFile.with_dir do |dir|
|
|
72
|
+
worker = make_job(dir, 'W/ask/Default_w')
|
|
73
|
+
critic = make_job(dir, 'C/ask/Default_c')
|
|
74
|
+
# One receipt envelope listing two job references: both anchor at the
|
|
75
|
+
# same outer output index.
|
|
76
|
+
text = receipt_chat_text(
|
|
77
|
+
{'c1' => [meta_receipt("job=#{worker}"), meta_receipt("job=#{critic}")]})
|
|
78
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
79
|
+
|
|
80
|
+
assert_equal({2 => [worker, critic]}, graph(chat)[:chats])
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
## (6) ask call: index of the call message and Agent#conversation value
|
|
85
|
+
def test_ask_call_records_delegation_at_call_index
|
|
86
|
+
TmpFile.with_dir do |dir|
|
|
87
|
+
chat = write_chat(dir, 'root.chat',
|
|
88
|
+
"user: go\n" \
|
|
89
|
+
'function_call: {"name":"ask","arguments":{"agent":"Workspace","conversation":"plan"},"id":"c1"}' + "\n" \
|
|
90
|
+
'function_call_output: {"name":"ask","content":"ok","id":"c1"}' + "\n" \
|
|
91
|
+
"assistant: done\n")
|
|
92
|
+
|
|
93
|
+
index = graph(chat)
|
|
94
|
+
assert_equal({1 => 'Workspace#plan'}, index[:delegation])
|
|
95
|
+
# An ask with no persisted job= metadata never enters chats.
|
|
96
|
+
assert_empty index[:chats]
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
## (6b) missing conversation argument defaults to 'default'
|
|
101
|
+
def test_ask_without_conversation_defaults
|
|
102
|
+
TmpFile.with_dir do |dir|
|
|
103
|
+
chat = write_chat(dir, 'root.chat',
|
|
104
|
+
"user: go\n" \
|
|
105
|
+
'function_call: {"name":"ask","arguments":{"agent":"Analyst"},"id":"c1"}' + "\n" \
|
|
106
|
+
'function_call_output: {"name":"ask","content":"ok","id":"c1"}' + "\n")
|
|
107
|
+
|
|
108
|
+
assert_equal({1 => 'Analyst#default'}, graph(chat)[:delegation])
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
## (7) a plain reply creates no provenance branch
|
|
113
|
+
def test_plain_response_has_no_provenance
|
|
114
|
+
TmpFile.with_dir do |dir|
|
|
115
|
+
chat = write_chat(dir, 'root.chat',
|
|
116
|
+
"user: explain the code\nassistant: plain ScoutCoder reply\n")
|
|
117
|
+
index = graph(chat)
|
|
118
|
+
|
|
119
|
+
assert_empty index[:chats]
|
|
120
|
+
assert_empty index[:delegation]
|
|
121
|
+
assert_empty index[:dependencies]
|
|
122
|
+
assert_empty index[:live]
|
|
123
|
+
assert_empty index[:warnings]
|
|
124
|
+
assert_equal :chat, index[:type]
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
## (8) job root: references inside the OUTPUT chat
|
|
129
|
+
def test_job_root_reads_references_from_its_output_chat
|
|
130
|
+
TmpFile.with_dir do |dir|
|
|
131
|
+
nested = make_job(dir, 'N/load/Default_n')
|
|
132
|
+
output = "user: run\nmeta: job=#{nested}\nassistant: done\n"
|
|
133
|
+
job = make_job(dir, 'W/ask/Default_w', result: output,
|
|
134
|
+
info: {type: 'chat', status: 'done'})
|
|
135
|
+
|
|
136
|
+
assert_equal({1 => nested}, graph(job, root_type: :job)[:chats])
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
## (9) the job's INPUT chat is never treated as generated output
|
|
141
|
+
def test_job_root_ignores_its_input_chat
|
|
142
|
+
TmpFile.with_dir do |dir|
|
|
143
|
+
input_only = make_job(dir, 'Other/ask/Default_o')
|
|
144
|
+
# The CALLER's chat references input_only; it is the job's input
|
|
145
|
+
# context, persisted next to it, not the job's output.
|
|
146
|
+
write_chat(dir, 'caller.chat',
|
|
147
|
+
"user: call\nmeta: job=#{input_only}\nassistant: done\n")
|
|
148
|
+
job = make_job(dir, 'W/ask/Default_w', result: 'plain text result',
|
|
149
|
+
info: {type: 'tsv', status: 'done'})
|
|
150
|
+
|
|
151
|
+
index = graph(job, root_type: :job)
|
|
152
|
+
assert_empty index[:chats]
|
|
153
|
+
assert_equal :job, index[:type]
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
## (10) non-chat job: dependencies and live files, no chats
|
|
158
|
+
def test_non_chat_job_has_dependencies_but_no_chats
|
|
159
|
+
TmpFile.with_dir do |dir|
|
|
160
|
+
dep = make_job(dir, 'D/load/Default_d')
|
|
161
|
+
job = make_job(dir, 'W/load/Default_w', dependencies: [dep])
|
|
162
|
+
|
|
163
|
+
index = graph(job, root_type: :job)
|
|
164
|
+
assert_equal :job, index[:type]
|
|
165
|
+
assert_empty index[:chats]
|
|
166
|
+
assert_empty index[:delegation]
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
## (11) dependency order preserved; only direct dependencies
|
|
171
|
+
def test_dependencies_are_direct_and_ordered
|
|
172
|
+
TmpFile.with_dir do |dir|
|
|
173
|
+
first = make_job(dir, 'P/one/Default_1')
|
|
174
|
+
second = make_job(dir, 'P/two/Default_2', dependencies: [first])
|
|
175
|
+
third = make_job(dir, 'P/three/Default_3')
|
|
176
|
+
job = make_job(dir, 'W/ask/Default_w',
|
|
177
|
+
dependencies: [third, second, first],
|
|
178
|
+
result: "user: hi\nassistant: done\n",
|
|
179
|
+
info: {type: 'chat'})
|
|
180
|
+
|
|
181
|
+
assert_equal [third, second, first], graph(job, root_type: :job)[:dependencies]
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
## (12) a byte-identical top-level sidecar is still listed in live
|
|
186
|
+
def test_byte_identical_sidecar_is_still_live
|
|
187
|
+
TmpFile.with_dir do |dir|
|
|
188
|
+
text = "user: hi\nassistant: done\n"
|
|
189
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
190
|
+
FileUtils.mkdir_p(chat + '.files')
|
|
191
|
+
File.write(File.join(chat + '.files', 'agent.chat'), text)
|
|
192
|
+
|
|
193
|
+
live = graph(chat)[:live].collect { |path| File.basename(path) }
|
|
194
|
+
assert_equal ['agent.chat'], live
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
## (13) society agent.chat is live, but not authoritative provenance
|
|
199
|
+
def test_society_chat_is_live_but_not_provenance
|
|
200
|
+
TmpFile.with_dir do |dir|
|
|
201
|
+
chat = write_chat(dir, 'root.chat',
|
|
202
|
+
"user: hi\nassistant: done\n")
|
|
203
|
+
society = File.join(chat + '.files', 'agent.society', 'ScoutCoder', 'default')
|
|
204
|
+
FileUtils.mkdir_p(society)
|
|
205
|
+
# Society chat carries its OWN job reference: still not traversed.
|
|
206
|
+
File.write(File.join(society, 'agent.chat'),
|
|
207
|
+
"user: work\nmeta: job=Society/Only/Default_x\nassistant: ok\n")
|
|
208
|
+
|
|
209
|
+
index = graph(chat)
|
|
210
|
+
assert_equal [File.join(society, 'agent.chat')], index[:live]
|
|
211
|
+
assert_empty index[:chats]
|
|
212
|
+
assert_empty index[:delegation]
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
## (14) missing sidecar and society directories give empty live
|
|
217
|
+
def test_missing_files_dirs_give_empty_live
|
|
218
|
+
TmpFile.with_dir do |dir|
|
|
219
|
+
chat = write_chat(dir, 'root.chat', "user: hi\nassistant: done\n")
|
|
220
|
+
assert_empty graph(chat)[:live]
|
|
221
|
+
|
|
222
|
+
job = make_job(dir, 'W/load/Default_w')
|
|
223
|
+
assert_empty graph(job, root_type: :job)[:live]
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
## (15) lightweight data only: no Chat/Step instances, no message bodies
|
|
228
|
+
def test_return_value_contains_no_objects_or_message_bodies
|
|
229
|
+
TmpFile.with_dir do |dir|
|
|
230
|
+
dep = make_job(dir, 'D/load/Default_d')
|
|
231
|
+
output = "user: run\nmeta: job=#{dep}\nassistant: the actual reply text\n"
|
|
232
|
+
job = make_job(dir, 'W/ask/Default_w', result: output,
|
|
233
|
+
dependencies: [dep], info: {type: 'chat'})
|
|
234
|
+
society = File.join(job + '.files', 'agent.society', 'Critic', 'default')
|
|
235
|
+
FileUtils.mkdir_p(society)
|
|
236
|
+
File.write(File.join(society, 'agent.chat'),
|
|
237
|
+
"user: c\nassistant: the actual reply text\n")
|
|
238
|
+
|
|
239
|
+
index = graph(job, root_type: :job)
|
|
240
|
+
collect = lambda do |value, &block|
|
|
241
|
+
case value
|
|
242
|
+
when Hash then value.each_value { |v| collect.call(v, &block) }
|
|
243
|
+
when Array then value.each { |v| collect.call(v, &block) }
|
|
244
|
+
else block.call(value)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
leaves = []
|
|
248
|
+
collect.call(index) { |leaf| leaves << leaf }
|
|
249
|
+
assert(leaves.all? { |leaf| [String, Symbol, Integer, Float, TrueClass, FalseClass, NilClass].any? { |k| k === leaf } },
|
|
250
|
+
"non-scalar leaves: #{leaves.reject { |l| [String, Symbol, Integer, Float, TrueClass, FalseClass, NilClass].any? { |k| k === l } }.inspect}")
|
|
251
|
+
assert_not_include leaves, 'the actual reply text'
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
## Invariants V1/V2/V5/V7 restated as behavior
|
|
256
|
+
def test_live_paths_never_reenter_the_index
|
|
257
|
+
TmpFile.with_dir do |dir|
|
|
258
|
+
chat = write_chat(dir, 'root.chat', "user: hi\nassistant: done\n")
|
|
259
|
+
society = File.join(chat + '.files', 'agent.society', 'W', 'c')
|
|
260
|
+
FileUtils.mkdir_p(society)
|
|
261
|
+
File.write(File.join(society, 'agent.chat'),
|
|
262
|
+
"user: work\nmeta: job=Live/Ref/Default_l\n" \
|
|
263
|
+
'function_call: {"name":"ask","arguments":{"agent":"Analyst"},"id":"k1"}' + "\n")
|
|
264
|
+
|
|
265
|
+
index = graph(chat)
|
|
266
|
+
# The references live inside a live sidecar; the index must not have
|
|
267
|
+
# loaded that chat, so neither entry appears.
|
|
268
|
+
assert_empty index[:chats]
|
|
269
|
+
assert_empty index[:delegation]
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def test_chat_root_has_no_dependencies
|
|
274
|
+
TmpFile.with_dir do |dir|
|
|
275
|
+
chat = write_chat(dir, 'root.chat',
|
|
276
|
+
"user: hi\nmeta: job=X/Y/Default_x\nassistant: done\n")
|
|
277
|
+
assert_empty graph(chat)[:dependencies]
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
## Malformed receipts follow the on_error policy and warn
|
|
282
|
+
def test_malformed_receipt_warns_and_keeps_other_provenance
|
|
283
|
+
TmpFile.with_dir do |dir|
|
|
284
|
+
good = make_job(dir, 'G/load/Default_g')
|
|
285
|
+
broken = File.join(dir, 'broken.chat')
|
|
286
|
+
# One standalone meta plus one receipt whose entry is not a Hash.
|
|
287
|
+
File.write(broken,
|
|
288
|
+
"user: run\nmeta: job=#{good}\n" \
|
|
289
|
+
'function_call: {"name":"ask","arguments":{},"id":"c1"}' + "\n" \
|
|
290
|
+
'function_call_output: {"name":"ask","content":"ok","id":"c1","meta":"not-an-array"}' + "\n" \
|
|
291
|
+
"assistant: done\n")
|
|
292
|
+
|
|
293
|
+
index = graph(broken)
|
|
294
|
+
assert_equal({1 => good}, index[:chats])
|
|
295
|
+
assert_equal 1, index[:warnings].length
|
|
296
|
+
assert_equal :agent_meta, index[:warnings].first[:kind]
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def test_unresolved_receipt_reference_warns_and_is_not_listed
|
|
301
|
+
TmpFile.with_dir do |dir|
|
|
302
|
+
chat = write_chat(dir, 'root.chat',
|
|
303
|
+
"user: run\n" \
|
|
304
|
+
'function_call: {"name":"ask","arguments":{},"id":"c1"}' + "\n" \
|
|
305
|
+
'function_call_output: {"name":"ask","content":"ok","id":"c1","meta":[{"job":"Nope/None/Default_z"}]}' + "\n")
|
|
306
|
+
|
|
307
|
+
index = graph(chat)
|
|
308
|
+
assert_empty index[:chats]
|
|
309
|
+
assert_equal 1, index[:warnings].length
|
|
310
|
+
assert_match(/unresolved_job_reference/, index[:warnings].first[:error].to_s)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def test_strict_mode_raises_on_unresolved_receipt
|
|
315
|
+
TmpFile.with_dir do |dir|
|
|
316
|
+
chat = write_chat(dir, 'root.chat',
|
|
317
|
+
"user: run\n" \
|
|
318
|
+
'function_call: {"name":"ask","arguments":{},"id":"c1"}' + "\n" \
|
|
319
|
+
'function_call_output: {"name":"ask","content":"ok","id":"c1","meta":[{"job":"Nope/None/Default_z"}]}' + "\n")
|
|
320
|
+
|
|
321
|
+
assert_raise ScoutException do
|
|
322
|
+
graph(chat, on_error: :raise)
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
## ROUND 4 — resolved, canonical absolute paths everywhere
|
|
328
|
+
|
|
329
|
+
# A SHORT metadata reference resolves to the job's canonical absolute
|
|
330
|
+
# path. The real spelling is RELATIVE-with-.chat (e.g.
|
|
331
|
+
# 'Planned/ask/Default_x.chat'); load_job_reference resolves it by
|
|
332
|
+
# joining the job fallback bases, so the test stubs the bases to a
|
|
333
|
+
# TmpFile base instead of writing into the user's live var/jobs.
|
|
334
|
+
def test_short_reference_resolves_to_canonical_absolute_job_path
|
|
335
|
+
TmpFile.with_dir do |dir|
|
|
336
|
+
base = File.join(dir, 'var', 'jobs')
|
|
337
|
+
worker = File.join(base, 'W', 'ask', 'Default_w.chat')
|
|
338
|
+
Open.mkdir(File.dirname(worker))
|
|
339
|
+
Open.write(worker, "user: run\nassistant: done\n")
|
|
340
|
+
Open.write(worker + '.info', {}.to_json)
|
|
341
|
+
|
|
342
|
+
Chat.singleton_class.send(:alias_method, :job_reference_fallback_bases_original, :job_reference_fallback_bases)
|
|
343
|
+
Chat.singleton_class.send(:define_method, :job_reference_fallback_bases) { [base] }
|
|
344
|
+
short = 'W/ask/Default_w.chat'
|
|
345
|
+
chat = write_chat(dir, 'root.chat',
|
|
346
|
+
"user: run\nmeta: job=#{short}\nassistant: done\n")
|
|
347
|
+
index = graph(chat)
|
|
348
|
+
assert_equal({1 => worker}, index[:chats])
|
|
349
|
+
assert_empty index[:warnings]
|
|
350
|
+
assert Step === Step.load(index[:chats].values.first)
|
|
351
|
+
ensure
|
|
352
|
+
Chat.singleton_class.send(:remove_method, :job_reference_fallback_bases)
|
|
353
|
+
Chat.singleton_class.send(:alias_method, :job_reference_fallback_bases, :job_reference_fallback_bases_original)
|
|
354
|
+
Chat.singleton_class.send(:remove_method, :job_reference_fallback_bases_original)
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# Follow-up workflow from the round-4 specification, executed end to end.
|
|
359
|
+
def test_follow_up_workflow_with_canonical_paths
|
|
360
|
+
TmpFile.with_dir do |dir|
|
|
361
|
+
dep = make_job(dir, 'D/prepare/Default_d')
|
|
362
|
+
worker = make_job(dir, 'W/ask/Default_w', dependencies: [dep],
|
|
363
|
+
result: "user: run\nassistant: done\n",
|
|
364
|
+
info: {type: 'chat'})
|
|
365
|
+
chat = write_chat(dir, 'root.chat',
|
|
366
|
+
"user: go\nmeta: job=#{worker}\nassistant: done\n")
|
|
367
|
+
|
|
368
|
+
graph = Chat.provenance_graph(chat)
|
|
369
|
+
job_path = graph[:chats].values.flatten.first
|
|
370
|
+
assert File.absolute_path?(job_path)
|
|
371
|
+
assert_equal worker, job_path
|
|
372
|
+
|
|
373
|
+
job = Step.load(job_path)
|
|
374
|
+
job_graph = Chat.provenance_graph(job)
|
|
375
|
+
assert_equal :job, job_graph[:type]
|
|
376
|
+
|
|
377
|
+
job_graph[:dependencies].each do |dependency_path|
|
|
378
|
+
assert File.absolute_path?(dependency_path)
|
|
379
|
+
assert Step === Step.load(dependency_path)
|
|
380
|
+
end
|
|
381
|
+
assert_equal [dep], job_graph[:dependencies]
|
|
382
|
+
|
|
383
|
+
# (5) the job root still inspects its OUTPUT chat for references and
|
|
384
|
+
# delegations found there.
|
|
385
|
+
assert_equal :chat, Chat.load(job_result_output(job)).messages.first[:role] rescue nil
|
|
386
|
+
nested = make_job(dir, 'N/load/Default_n')
|
|
387
|
+
Open.write(job.path.to_s,
|
|
388
|
+
"user: run\nmeta: job=#{nested}\nassistant: done\n")
|
|
389
|
+
assert_equal({1 => nested}, Chat.provenance_graph(job)[:chats])
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
# (2) receipt-derived references get the same treatment.
|
|
394
|
+
def test_receipt_reference_resolves_to_canonical_absolute_job_path
|
|
395
|
+
TmpFile.with_dir do |dir|
|
|
396
|
+
worker = make_job(dir, 'W/ask/Default_w')
|
|
397
|
+
text = receipt_chat_text({'c1' => [meta_receipt("job=#{worker}")]})
|
|
398
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
399
|
+
|
|
400
|
+
assert_equal({2 => worker}, graph(chat)[:chats])
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# (3) multiple references at one index remain intact, as canonical paths.
|
|
405
|
+
def test_multiple_resolved_references_stay_an_array
|
|
406
|
+
TmpFile.with_dir do |dir|
|
|
407
|
+
worker = make_job(dir, 'W/ask/Default_w')
|
|
408
|
+
critic = make_job(dir, 'C/ask/Default_c')
|
|
409
|
+
text = receipt_chat_text(
|
|
410
|
+
{'c1' => [meta_receipt("job=#{worker}"), meta_receipt("job=#{critic}")]})
|
|
411
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
412
|
+
|
|
413
|
+
assert_equal({2 => [worker, critic]}, graph(chat)[:chats])
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Repeated references to the SAME job at one index deduplicate.
|
|
418
|
+
def test_repeated_same_job_reference_at_one_index_deduplicates
|
|
419
|
+
TmpFile.with_dir do |dir|
|
|
420
|
+
worker = make_job(dir, 'W/ask/Default_w')
|
|
421
|
+
text = receipt_chat_text(
|
|
422
|
+
{'c1' => [meta_receipt("job=#{worker}"), meta_receipt("job=#{worker}")]})
|
|
423
|
+
chat = write_chat(dir, 'root.chat', text)
|
|
424
|
+
|
|
425
|
+
assert_equal({2 => worker}, graph(chat)[:chats])
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
# A standalone meta reference that cannot resolve warns (or raises) and
|
|
430
|
+
# is not listed, mirroring the receipt behavior.
|
|
431
|
+
def test_unresolved_standalone_meta_warns
|
|
432
|
+
TmpFile.with_dir do |dir|
|
|
433
|
+
chat = write_chat(dir, 'root.chat',
|
|
434
|
+
"user: run\nmeta: job=Nowhere/None/Default_n\nassistant: done\n")
|
|
435
|
+
|
|
436
|
+
index = graph(chat)
|
|
437
|
+
assert_empty index[:chats]
|
|
438
|
+
assert_equal 1, index[:warnings].length
|
|
439
|
+
assert_match(/unresolved_job_reference/, index[:warnings].first[:error].to_s)
|
|
440
|
+
|
|
441
|
+
assert_raise ScoutException do
|
|
442
|
+
graph(chat, on_error: :raise)
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
# (7)/(8) a Step object is a job root; the same path WITHOUT an explicit
|
|
448
|
+
# root_type stays a CHAT root. Both must inspect the job.
|
|
449
|
+
def test_step_object_and_explicit_root_type_identify_job_root
|
|
450
|
+
TmpFile.with_dir do |dir|
|
|
451
|
+
dep = make_job(dir, 'D/prepare/Default_d')
|
|
452
|
+
output = "user: hi\nassistant: done\n"
|
|
453
|
+
worker = make_job(dir, 'W/ask/Default_w', result: output,
|
|
454
|
+
dependencies: [dep], info: {type: 'chat'})
|
|
455
|
+
step = Step.load(worker)
|
|
456
|
+
|
|
457
|
+
[Chat.provenance_graph(step),
|
|
458
|
+
Chat.provenance_graph(step.path, root_type: :job)].each do |job_index|
|
|
459
|
+
assert_equal :job, job_index[:type]
|
|
460
|
+
assert_equal [dep], job_index[:dependencies]
|
|
461
|
+
# The output chat exists and is readable at step.path; its presence
|
|
462
|
+
# must not flip the path-only call to a chat root... it does not:
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
# Without root_type, the same path is a chat root (the output
|
|
466
|
+
# transcript itself), with no dependencies.
|
|
467
|
+
chat_index = Chat.provenance_graph(step.path)
|
|
468
|
+
assert_equal :chat, chat_index[:type]
|
|
469
|
+
assert_empty chat_index[:dependencies]
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
private
|
|
474
|
+
|
|
475
|
+
# The job's persisted result file when it is a chat-producing job.
|
|
476
|
+
def job_result_output(job)
|
|
477
|
+
Chat.job_result_chat_file(job).to_s
|
|
478
|
+
end
|
|
479
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
|
2
|
+
require 'scout/llm/agent'
|
|
3
|
+
|
|
4
|
+
class TestLLMChatSocietyView < Test::Unit::TestCase
|
|
5
|
+
def wfdir
|
|
6
|
+
@wfdir ||= begin
|
|
7
|
+
dir = Path.setup(Workflow.directory['society-view-wf'])
|
|
8
|
+
Workflow.directory = dir
|
|
9
|
+
dir
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def root_chat
|
|
14
|
+
@root_chat ||= begin
|
|
15
|
+
sf = tmpdir['society-view'].find + '.chat'
|
|
16
|
+
Open.rm_rf(sf)
|
|
17
|
+
FileUtils.mkdir_p(File.dirname(sf))
|
|
18
|
+
FileUtils.touch(sf)
|
|
19
|
+
sf
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def write_info(short_path, status, pid, type: 'string')
|
|
24
|
+
dir = wfdir[short_path].find
|
|
25
|
+
Open.rm_rf dir
|
|
26
|
+
FileUtils.mkdir_p(dir)
|
|
27
|
+
File.write(dir + '.info',
|
|
28
|
+
JSON.dump({status: status, pid: pid, type: type,
|
|
29
|
+
workflow: short_path.split('/').first,
|
|
30
|
+
task_name: short_path.split('/')[1]}))
|
|
31
|
+
dir
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def write_child(agent, conversation, *messages)
|
|
35
|
+
dir = File.join(File.dirname(root_chat), File.basename(root_chat).sub(/\.chat\z/, '.society'), agent, conversation)
|
|
36
|
+
FileUtils.mkdir_p(dir)
|
|
37
|
+
file = File.join(dir, 'agent.chat')
|
|
38
|
+
Open.write(file, Chat.print(messages))
|
|
39
|
+
file
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# ---------------------------------------------------------------
|
|
43
|
+
# Society dir derivation
|
|
44
|
+
# ---------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
def test_society_dir_of_root_save_file
|
|
47
|
+
assert_equal File.join(File.dirname(root_chat), 'society-view.society'),
|
|
48
|
+
Chat.society_dir_of(root_chat)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_society_dir_of_nested_child_matches_agent_rule
|
|
52
|
+
nested = File.join(File.dirname(root_chat), 'society-view.society', 'Worker', 'run', 'agent.chat')
|
|
53
|
+
assert_equal LLM::Agent.new.society_dir(nested),
|
|
54
|
+
Chat.society_dir_of(nested)
|
|
55
|
+
assert_equal File.join(File.dirname(root_chat), 'society-view.society', 'Worker', 'run', 'society'),
|
|
56
|
+
Chat.society_dir_of(nested)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_missing_society_dir_is_silent
|
|
60
|
+
assert_equal [], Chat.society_agent_chats(root_chat)
|
|
61
|
+
assert_equal [], Chat.society_live(root_chat, captured: [])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# ---------------------------------------------------------------
|
|
65
|
+
# Plain child: activity only (no job= meta ever written)
|
|
66
|
+
# ---------------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
def test_active_plain_child_reports_agent_activity
|
|
69
|
+
write_child('Worker', 'run', {role: 'user', content: 'hi'})
|
|
70
|
+
entries = Chat.society_live(root_chat, captured: [])
|
|
71
|
+
assert_equal 1, entries.length
|
|
72
|
+
entry = entries.first
|
|
73
|
+
assert_equal :agent_activity, entry[:kind]
|
|
74
|
+
assert_equal 'Worker', entry[:agent]
|
|
75
|
+
assert_equal 'run', entry[:conversation]
|
|
76
|
+
assert_equal File.join('Worker', 'run', 'agent.chat'), entry[:relative]
|
|
77
|
+
assert_equal :dispatched, entry[:activity][:reason]
|
|
78
|
+
refute entry.key?(:job)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_tool_round_plain_child_reports_agent_activity
|
|
82
|
+
write_child('Worker', 'run',
|
|
83
|
+
{role: 'user', content: 'hi'},
|
|
84
|
+
{role: 'assistant', content: 'hm'},
|
|
85
|
+
{role: 'function_call', content: {name: 'slow', arguments: {}, id: 'c1'}.to_json})
|
|
86
|
+
entries = Chat.society_live(root_chat, captured: [])
|
|
87
|
+
assert_equal 1, entries.length
|
|
88
|
+
assert_equal :agent_activity, entries.first[:kind]
|
|
89
|
+
assert_equal :tool_round_in_flight, entries.first[:activity][:reason]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_finished_child_is_silent
|
|
93
|
+
write_child('Worker', 'run',
|
|
94
|
+
{role: 'user', content: 'hi'},
|
|
95
|
+
{role: 'assistant', content: 'bye'})
|
|
96
|
+
assert_equal [], Chat.society_live(root_chat, captured: [])
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# ---------------------------------------------------------------
|
|
100
|
+
# Workflow-backed child: dangling job wins, activity still included
|
|
101
|
+
# ---------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
def test_workflow_child_with_running_job_reports_dangling_job
|
|
104
|
+
write_info('WF/ask/one', 'running', Process.pid, type: 'chat')
|
|
105
|
+
write_child('Worker', 'run',
|
|
106
|
+
{role: 'user', content: 'go'},
|
|
107
|
+
{role: 'meta', content: 'job=WF/ask/one'})
|
|
108
|
+
entries = Chat.society_live(root_chat, captured: [])
|
|
109
|
+
assert_equal 1, entries.length
|
|
110
|
+
entry = entries.first
|
|
111
|
+
assert_equal :dangling_job, entry[:kind]
|
|
112
|
+
assert_equal 'WF/ask/one', entry[:job]
|
|
113
|
+
assert_equal :running, entry[:state]
|
|
114
|
+
assert_equal 'Worker', entry[:agent]
|
|
115
|
+
# the activity hash is present even when the dangling job wins
|
|
116
|
+
assert_equal :dispatched, entry[:activity][:reason]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_captured_job_of_otherwise_finished_child_is_skipped
|
|
120
|
+
write_info('WF/ask/one', 'running', Process.pid, type: 'chat')
|
|
121
|
+
write_child('Worker', 'run',
|
|
122
|
+
{role: 'user', content: 'go'},
|
|
123
|
+
{role: 'meta', content: 'job=WF/ask/one'})
|
|
124
|
+
assert_equal [], Chat.society_live(root_chat, captured: ['WF/ask/one'])
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_multiple_children_report_sorted_by_path
|
|
128
|
+
write_child('Zeta', 'run', {role: 'user', content: 'go'})
|
|
129
|
+
write_child('Alpha', 'later', {role: 'user', content: 'go'})
|
|
130
|
+
entries = Chat.society_live(root_chat, captured: [])
|
|
131
|
+
assert_equal %w(Alpha Zeta), entries.collect { |e| e[:agent] }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# ---------------------------------------------------------------
|
|
135
|
+
# Guards
|
|
136
|
+
# ---------------------------------------------------------------
|
|
137
|
+
|
|
138
|
+
def test_symlink_out_of_the_tree_is_not_followed
|
|
139
|
+
outer = tmpdir['outer-society'].find
|
|
140
|
+
FileUtils.mkdir_p(outer)
|
|
141
|
+
Open.write(File.join(outer, 'agent.chat'), Chat.print([{role: 'user', content: 'outside'}]))
|
|
142
|
+
link_dir = File.join(File.dirname(root_chat), 'society-view.society', 'Linked', 'run')
|
|
143
|
+
FileUtils.mkdir_p(link_dir)
|
|
144
|
+
File.symlink(outer, File.join(link_dir, 'agent.chat'))
|
|
145
|
+
entries = Chat.society_live(root_chat, captured: [])
|
|
146
|
+
assert_equal [], entries
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_scan_depth_is_bounded
|
|
150
|
+
deep = File.dirname(root_chat)
|
|
151
|
+
200.times do
|
|
152
|
+
deep = File.join(deep, 'society')
|
|
153
|
+
end
|
|
154
|
+
target = File.join(deep, 'a', 'b', 'agent.chat')
|
|
155
|
+
FileUtils.mkdir_p(File.dirname(target))
|
|
156
|
+
Open.write(target, Chat.print([{role: 'user', content: 'deep'}]))
|
|
157
|
+
assert_equal [], Chat.society_agent_chats(root_chat)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -21,7 +21,7 @@ What is my name?
|
|
|
21
21
|
# mock backend records what the agent actually sent.
|
|
22
22
|
LLM::Mock.script('Your name is Miguel')
|
|
23
23
|
|
|
24
|
-
res = agent.prompt chat, persist: false, endpoint: 'mock'
|
|
24
|
+
res = agent.prompt chat, persist: false, endpoint: 'mock', backend: :mock
|
|
25
25
|
|
|
26
26
|
assert_equal 'Your name is Miguel', res
|
|
27
27
|
|