millforge 0.1.0__py3-none-any.whl

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 (116) hide show
  1. millforge/__init__.py +1174 -0
  2. millforge/_forge/LICENSE +21 -0
  3. millforge/_forge/PROVENANCE.json +295 -0
  4. millforge/_forge/UPDATE_POLICY.md +24 -0
  5. millforge/_forge/__init__.py +14 -0
  6. millforge/_forge/adapter.py +2232 -0
  7. millforge/_forge/base_runner.py +121 -0
  8. millforge/_forge/clients/__init__.py +10 -0
  9. millforge/_forge/clients/base.py +200 -0
  10. millforge/_forge/context/__init__.py +23 -0
  11. millforge/_forge/context/manager.py +178 -0
  12. millforge/_forge/context/strategies.py +335 -0
  13. millforge/_forge/core/__init__.py +16 -0
  14. millforge/_forge/core/inference.py +433 -0
  15. millforge/_forge/core/messages.py +119 -0
  16. millforge/_forge/core/runner.py +479 -0
  17. millforge/_forge/core/steps.py +108 -0
  18. millforge/_forge/core/workflow.py +400 -0
  19. millforge/_forge/errors.py +222 -0
  20. millforge/_forge/guardrails/__init__.py +21 -0
  21. millforge/_forge/guardrails/error_tracker.py +71 -0
  22. millforge/_forge/guardrails/guardrails.py +194 -0
  23. millforge/_forge/guardrails/nudge.py +47 -0
  24. millforge/_forge/guardrails/response_validator.py +119 -0
  25. millforge/_forge/guardrails/step_enforcer.py +183 -0
  26. millforge/_forge/prompts/__init__.py +16 -0
  27. millforge/_forge/prompts/nudges.py +95 -0
  28. millforge/_forge/prompts/templates.py +285 -0
  29. millforge/_version.py +3 -0
  30. millforge/artifacts.py +570 -0
  31. millforge/base/__init__.py +97 -0
  32. millforge/base/composition.py +402 -0
  33. millforge/base/context.py +285 -0
  34. millforge/base/harness.py +138 -0
  35. millforge/base/identity.py +465 -0
  36. millforge/base/options.py +34 -0
  37. millforge/base/platform.py +17 -0
  38. millforge/base/prompt.py +317 -0
  39. millforge/base/runner.py +546 -0
  40. millforge/compiled_plan.py +970 -0
  41. millforge/compiler/__init__.py +231 -0
  42. millforge/compiler/artifact_validation.py +257 -0
  43. millforge/compiler/canonicalization.py +169 -0
  44. millforge/compiler/capabilities.py +66 -0
  45. millforge/compiler/catalogs.py +500 -0
  46. millforge/compiler/diagnostics.py +491 -0
  47. millforge/compiler/graph.py +678 -0
  48. millforge/compiler/lowering.py +198 -0
  49. millforge/compiler/output.py +692 -0
  50. millforge/compiler/parsing.py +1424 -0
  51. millforge/compiler/requests.py +1180 -0
  52. millforge/compiler/schema_validation.py +272 -0
  53. millforge/compiler/semantic.py +490 -0
  54. millforge/compiler/service.py +448 -0
  55. millforge/compiler/source.py +375 -0
  56. millforge/compiler/validators.py +184 -0
  57. millforge/connectors/__init__.py +95 -0
  58. millforge/connectors/admission.py +801 -0
  59. millforge/connectors/broker.py +202 -0
  60. millforge/connectors/contracts.py +1159 -0
  61. millforge/connectors/diagnostics.py +189 -0
  62. millforge/connectors/fake.py +66 -0
  63. millforge/connectors/runtime.py +236 -0
  64. millforge/contracts.py +2860 -0
  65. millforge/custom_tools/__init__.py +67 -0
  66. millforge/custom_tools/compiler.py +724 -0
  67. millforge/custom_tools/contracts.py +1093 -0
  68. millforge/custom_tools/diagnostics.py +205 -0
  69. millforge/eval_artifacts.py +952 -0
  70. millforge/eval_boundary.py +2435 -0
  71. millforge/eval_fixtures/__init__.py +1 -0
  72. millforge/eval_fixtures/default_pack/__init__.py +1 -0
  73. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.bug_diagnosis.traceback.v1.json +52 -0
  74. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.direct_edit.import_sort.v1.json +52 -0
  75. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.evidence_discipline.no_source_change.v1.json +51 -0
  76. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.false_closure.visible_green.v1.json +52 -0
  77. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.multi_file.api_contract.v1.json +54 -0
  78. millforge/eval_fixtures/default_pack/fixtures/fixture.08a.recovery.malformed_artifact.v1.json +54 -0
  79. millforge/eval_fixtures/default_pack/manifest.json +12 -0
  80. millforge/eval_modes.py +1282 -0
  81. millforge/eval_presets.py +1398 -0
  82. millforge/eval_reports.py +2517 -0
  83. millforge/eval_suite.py +2429 -0
  84. millforge/eval_trials.py +2632 -0
  85. millforge/eval_workflow.py +794 -0
  86. millforge/exceptions.py +122 -0
  87. millforge/model_backend.py +2098 -0
  88. millforge/protocols.py +340 -0
  89. millforge/py.typed +0 -0
  90. millforge/runtime.py +1791 -0
  91. millforge/testing/__init__.py +1089 -0
  92. millforge/tools/__init__.py +83 -0
  93. millforge/tools/builtin_runtime.py +1339 -0
  94. millforge/tools/builtins.py +773 -0
  95. millforge/tools/execution.py +1545 -0
  96. millforge/tools/path_policy.py +155 -0
  97. millforge/tools/pi_compat/PI_LICENSE +21 -0
  98. millforge/tools/pi_compat/PROVENANCE.json +55 -0
  99. millforge/tools/pi_compat/UPDATE_POLICY.md +36 -0
  100. millforge/tools/pi_compat/__init__.py +34 -0
  101. millforge/tools/pi_compat/contracts.py +49 -0
  102. millforge/tools/pi_compat/editing.py +390 -0
  103. millforge/tools/pi_compat/mutations.py +57 -0
  104. millforge/tools/pi_compat/operations.py +401 -0
  105. millforge/tools/pi_compat/paths.py +155 -0
  106. millforge/tools/pi_compat/process.py +1375 -0
  107. millforge/tools/pi_compat/search.py +738 -0
  108. millforge/tools/pi_compat/truncation.py +267 -0
  109. millforge/tools/pi_compat_catalog.py +396 -0
  110. millforge/tools/pi_compat_runtime.py +460 -0
  111. millforge/tools/registry.py +553 -0
  112. millforge/tools/results.py +533 -0
  113. millforge-0.1.0.dist-info/METADATA +844 -0
  114. millforge-0.1.0.dist-info/RECORD +116 -0
  115. millforge-0.1.0.dist-info/WHEEL +4 -0
  116. millforge-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,773 @@
1
+ """Descriptor-only production built-in tool catalog data."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Mapping
6
+ from typing import Any
7
+
8
+ from millforge import IdempotencyClass, SideEffectClass
9
+ from millforge.compiler.catalogs import ToolCatalogSnapshot
10
+ from millforge.tools.registry import (
11
+ ToolDescriptor,
12
+ ToolOutputPolicy,
13
+ ToolRegistry,
14
+ ToolTimeoutPolicy,
15
+ )
16
+
17
+ JsonObject = dict[str, Any]
18
+
19
+ BUILTIN_TOOL_VERSION = 1
20
+
21
+ BUILTIN_CAP_REQUEST_READ = "request.read"
22
+ BUILTIN_CAP_WORKSPACE_READ = "workspace.read"
23
+ BUILTIN_CAP_WORKSPACE_SEARCH = "workspace.search"
24
+ BUILTIN_CAP_WORKSPACE_WRITE = "workspace.write"
25
+ BUILTIN_CAP_WORKSPACE_DIFF_READ = "workspace.diff.read"
26
+ BUILTIN_CAP_PROCESS_TEST = "process.test"
27
+ BUILTIN_CAP_PROCESS_STATIC_CHECK = "process.static_check"
28
+ BUILTIN_CAP_ARTIFACT_READ = "artifact.read"
29
+ BUILTIN_CAP_ARTIFACT_WRITE = "artifact.write"
30
+ BUILTIN_CAP_TERMINAL_INTENT = "terminal.intent"
31
+
32
+ BUILTIN_CAPABILITY_IDS = (
33
+ BUILTIN_CAP_ARTIFACT_READ,
34
+ BUILTIN_CAP_ARTIFACT_WRITE,
35
+ BUILTIN_CAP_PROCESS_STATIC_CHECK,
36
+ BUILTIN_CAP_PROCESS_TEST,
37
+ BUILTIN_CAP_REQUEST_READ,
38
+ BUILTIN_CAP_TERMINAL_INTENT,
39
+ BUILTIN_CAP_WORKSPACE_DIFF_READ,
40
+ BUILTIN_CAP_WORKSPACE_READ,
41
+ BUILTIN_CAP_WORKSPACE_SEARCH,
42
+ BUILTIN_CAP_WORKSPACE_WRITE,
43
+ )
44
+
45
+ _DEFAULT_TIMEOUT_POLICY = ToolTimeoutPolicy(
46
+ timeout_seconds=300,
47
+ cancellation_grace_seconds=10,
48
+ )
49
+ _SHELL_TIMEOUT_POLICY = ToolTimeoutPolicy(
50
+ timeout_seconds=1800,
51
+ cancellation_grace_seconds=30,
52
+ )
53
+ _TERMINAL_TIMEOUT_POLICY = ToolTimeoutPolicy(
54
+ timeout_seconds=30,
55
+ cancellation_grace_seconds=5,
56
+ )
57
+ _DEFAULT_OUTPUT_POLICY = ToolOutputPolicy(
58
+ max_output_bytes=1_048_576,
59
+ max_summary_utf8=8192,
60
+ redact_secrets=True,
61
+ )
62
+
63
+ _EMPTY_INPUT_SCHEMA: JsonObject = {
64
+ "type": "object",
65
+ "properties": {},
66
+ "required": [],
67
+ "additionalProperties": False,
68
+ }
69
+ _STATUS_SCHEMA: JsonObject = {
70
+ "type": "string",
71
+ "enum": ["success", "soft_failure", "hard_failure"],
72
+ }
73
+ _STRING_ARRAY_SCHEMA: JsonObject = {
74
+ "type": "array",
75
+ "items": {"type": "string"},
76
+ }
77
+ _COMMON_STATUS_SUMMARY_PROPERTIES: JsonObject = {
78
+ "status": _STATUS_SCHEMA,
79
+ "summary": {"type": "string"},
80
+ }
81
+ _REQUEST_INSPECT_OUTPUT_SCHEMA: JsonObject = {
82
+ "type": "object",
83
+ "properties": {
84
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
85
+ "request_id": {"type": "string"},
86
+ "stage_id": {"type": "string"},
87
+ "objective": {"type": "string"},
88
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
89
+ "truncated": {"type": "boolean"},
90
+ },
91
+ "required": [
92
+ "status",
93
+ "summary",
94
+ "request_id",
95
+ "stage_id",
96
+ "objective",
97
+ "artifact_refs",
98
+ ],
99
+ "additionalProperties": False,
100
+ }
101
+ _REQUEST_REQUIREMENTS_OUTPUT_SCHEMA: JsonObject = {
102
+ "type": "object",
103
+ "properties": {
104
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
105
+ "requirements": _STRING_ARRAY_SCHEMA,
106
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
107
+ "truncated": {"type": "boolean"},
108
+ },
109
+ "required": ["status", "summary", "requirements", "artifact_refs"],
110
+ "additionalProperties": False,
111
+ }
112
+ _WORKSPACE_LIST_INPUT_SCHEMA: JsonObject = {
113
+ "type": "object",
114
+ "properties": {
115
+ "root": {"type": "string"},
116
+ "glob": {"type": "string"},
117
+ "max_results": {"type": "integer"},
118
+ },
119
+ "required": ["root"],
120
+ "additionalProperties": False,
121
+ }
122
+ _WORKSPACE_LIST_OUTPUT_SCHEMA: JsonObject = {
123
+ "type": "object",
124
+ "properties": {
125
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
126
+ "paths": _STRING_ARRAY_SCHEMA,
127
+ "truncated": {"type": "boolean"},
128
+ },
129
+ "required": ["status", "summary", "paths", "truncated"],
130
+ "additionalProperties": False,
131
+ }
132
+ _WORKSPACE_READ_INPUT_SCHEMA: JsonObject = {
133
+ "type": "object",
134
+ "properties": {
135
+ "path": {"type": "string"},
136
+ "max_bytes": {"type": "integer"},
137
+ },
138
+ "required": ["path"],
139
+ "additionalProperties": False,
140
+ }
141
+ _WORKSPACE_READ_OUTPUT_SCHEMA: JsonObject = {
142
+ "type": "object",
143
+ "properties": {
144
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
145
+ "content": {"type": "string"},
146
+ "truncated": {"type": "boolean"},
147
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
148
+ },
149
+ "required": ["status", "summary", "content", "truncated", "artifact_refs"],
150
+ "additionalProperties": False,
151
+ }
152
+ _WORKSPACE_SEARCH_INPUT_SCHEMA: JsonObject = {
153
+ "type": "object",
154
+ "properties": {
155
+ "query": {"type": "string"},
156
+ "root": {"type": "string"},
157
+ "glob": {"type": "string"},
158
+ "max_results": {"type": "integer"},
159
+ },
160
+ "required": ["query"],
161
+ "additionalProperties": False,
162
+ }
163
+ _WORKSPACE_SEARCH_OUTPUT_SCHEMA: JsonObject = {
164
+ "type": "object",
165
+ "properties": {
166
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
167
+ "matches": {
168
+ "type": "array",
169
+ "items": {
170
+ "type": "object",
171
+ "properties": {
172
+ "path": {"type": "string"},
173
+ "line": {"type": "integer"},
174
+ "snippet": {"type": "string"},
175
+ },
176
+ "required": ["path", "line", "snippet"],
177
+ "additionalProperties": False,
178
+ },
179
+ },
180
+ "truncated": {"type": "boolean"},
181
+ },
182
+ "required": ["status", "summary", "matches", "truncated"],
183
+ "additionalProperties": False,
184
+ }
185
+ _WORKSPACE_WRITE_INPUT_SCHEMA: JsonObject = {
186
+ "type": "object",
187
+ "properties": {
188
+ "path": {"type": "string"},
189
+ "content": {"type": "string"},
190
+ "expected_sha256": {"type": "string"},
191
+ },
192
+ "required": ["path", "content"],
193
+ "additionalProperties": False,
194
+ }
195
+ _WORKSPACE_WRITE_OUTPUT_SCHEMA: JsonObject = {
196
+ "type": "object",
197
+ "properties": {
198
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
199
+ "path": {"type": "string"},
200
+ "content_sha256": {"type": "string"},
201
+ },
202
+ "required": ["status", "summary", "path", "content_sha256"],
203
+ "additionalProperties": False,
204
+ }
205
+ _WORKSPACE_PATCH_INPUT_SCHEMA: JsonObject = {
206
+ "type": "object",
207
+ "properties": {
208
+ "patch": {"type": "string"},
209
+ "expected_base_sha256": {"type": "string"},
210
+ },
211
+ "required": ["patch"],
212
+ "additionalProperties": False,
213
+ }
214
+ _WORKSPACE_PATCH_OUTPUT_SCHEMA: JsonObject = {
215
+ "type": "object",
216
+ "properties": {
217
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
218
+ "changed_paths": _STRING_ARRAY_SCHEMA,
219
+ "diff_sha256": {"type": "string"},
220
+ },
221
+ "required": ["status", "summary", "changed_paths", "diff_sha256"],
222
+ "additionalProperties": False,
223
+ }
224
+ _WORKSPACE_DIFF_INPUT_SCHEMA: JsonObject = {
225
+ "type": "object",
226
+ "properties": {
227
+ "paths": _STRING_ARRAY_SCHEMA,
228
+ "max_bytes": {"type": "integer"},
229
+ },
230
+ "required": [],
231
+ "additionalProperties": False,
232
+ }
233
+ _WORKSPACE_DIFF_OUTPUT_SCHEMA: JsonObject = {
234
+ "type": "object",
235
+ "properties": {
236
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
237
+ "diff": {"type": "string"},
238
+ "truncated": {"type": "boolean"},
239
+ "diff_sha256": {"type": "string"},
240
+ },
241
+ "required": ["status", "summary", "diff", "truncated", "diff_sha256"],
242
+ "additionalProperties": False,
243
+ }
244
+ _SHELL_TEST_INPUT_SCHEMA: JsonObject = {
245
+ "type": "object",
246
+ "properties": {
247
+ "profile": {"type": "string"},
248
+ "selector": {"type": "string"},
249
+ "max_output_bytes": {"type": "integer"},
250
+ },
251
+ "required": ["profile"],
252
+ "additionalProperties": False,
253
+ }
254
+ _SHELL_STATIC_CHECK_INPUT_SCHEMA: JsonObject = {
255
+ "type": "object",
256
+ "properties": {
257
+ "profile": {"type": "string"},
258
+ "selector": {"type": "string"},
259
+ "max_output_bytes": {"type": "integer"},
260
+ },
261
+ "required": ["profile"],
262
+ "additionalProperties": False,
263
+ }
264
+ _SHELL_OUTPUT_SCHEMA: JsonObject = {
265
+ "type": "object",
266
+ "properties": {
267
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
268
+ "exit_code": {"type": "integer"},
269
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
270
+ "truncated": {"type": "boolean"},
271
+ },
272
+ "required": ["status", "summary", "exit_code", "artifact_refs", "truncated"],
273
+ "additionalProperties": False,
274
+ }
275
+ _ARTIFACT_READ_INPUT_SCHEMA: JsonObject = {
276
+ "type": "object",
277
+ "properties": {
278
+ "artifact_id": {"type": "string"},
279
+ "max_bytes": {"type": "integer"},
280
+ },
281
+ "required": ["artifact_id"],
282
+ "additionalProperties": False,
283
+ }
284
+ _ARTIFACT_READ_OUTPUT_SCHEMA: JsonObject = {
285
+ "type": "object",
286
+ "properties": {
287
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
288
+ "artifact_id": {"type": "string"},
289
+ "content": {"type": "string"},
290
+ "content_sha256": {"type": "string"},
291
+ "truncated": {"type": "boolean"},
292
+ },
293
+ "required": [
294
+ "status",
295
+ "summary",
296
+ "artifact_id",
297
+ "content",
298
+ "content_sha256",
299
+ "truncated",
300
+ ],
301
+ "additionalProperties": False,
302
+ }
303
+
304
+
305
+ def _fixed_artifact_read_output_schema(artifact_id: str) -> JsonObject:
306
+ return {
307
+ "type": "object",
308
+ "properties": {
309
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
310
+ "artifact_id": {"type": "string", "enum": [artifact_id]},
311
+ "content": {"type": "string"},
312
+ "content_sha256": {"type": "string"},
313
+ "truncated": {"type": "boolean"},
314
+ },
315
+ "required": [
316
+ "status",
317
+ "summary",
318
+ "artifact_id",
319
+ "content",
320
+ "content_sha256",
321
+ "truncated",
322
+ ],
323
+ "additionalProperties": False,
324
+ }
325
+
326
+
327
+ _ARTIFACT_READ_PLAN_OUTPUT_SCHEMA = _fixed_artifact_read_output_schema("plan")
328
+ _ARTIFACT_READ_PATCH_SUMMARY_OUTPUT_SCHEMA = _fixed_artifact_read_output_schema(
329
+ "patch_summary"
330
+ )
331
+ _ARTIFACT_READ_TEST_RESULTS_OUTPUT_SCHEMA = _fixed_artifact_read_output_schema(
332
+ "test_results"
333
+ )
334
+ _ARTIFACT_READ_WORKSPACE_DIFF_OUTPUT_SCHEMA = _fixed_artifact_read_output_schema(
335
+ "workspace_diff"
336
+ )
337
+ _ARTIFACT_READ_CHECKER_VERDICT_OUTPUT_SCHEMA = _fixed_artifact_read_output_schema(
338
+ "checker_verdict"
339
+ )
340
+ _ARTIFACT_WRITE_PLAN_INPUT_SCHEMA: JsonObject = {
341
+ "type": "object",
342
+ "properties": {"plan": {"type": "string"}},
343
+ "required": ["plan"],
344
+ "additionalProperties": False,
345
+ }
346
+ _ARTIFACT_WRITE_PATCH_SUMMARY_INPUT_SCHEMA: JsonObject = {
347
+ "type": "object",
348
+ "properties": {"summary": {"type": "string"}},
349
+ "required": ["summary"],
350
+ "additionalProperties": False,
351
+ }
352
+ _ARTIFACT_WRITE_TEST_RESULTS_INPUT_SCHEMA: JsonObject = {
353
+ "type": "object",
354
+ "properties": {"results": {"type": "string"}},
355
+ "required": ["results"],
356
+ "additionalProperties": False,
357
+ }
358
+ _ARTIFACT_WRITE_CHECKER_VERDICT_INPUT_SCHEMA: JsonObject = {
359
+ "type": "object",
360
+ "properties": {"verdict": {"type": "string"}},
361
+ "required": ["verdict"],
362
+ "additionalProperties": False,
363
+ }
364
+ _ARTIFACT_WRITE_ARBITER_VERDICT_INPUT_SCHEMA: JsonObject = {
365
+ "type": "object",
366
+ "properties": {"verdict": {"type": "string"}},
367
+ "required": ["verdict"],
368
+ "additionalProperties": False,
369
+ }
370
+ _ARTIFACT_WRITE_VERDICT_INPUT_SCHEMA: JsonObject = {
371
+ "type": "object",
372
+ "properties": {
373
+ "artifact_id": {
374
+ "type": "string",
375
+ "enum": ["checker_verdict", "arbiter_verdict"],
376
+ },
377
+ "verdict": {"type": "string"},
378
+ },
379
+ "required": ["artifact_id", "verdict"],
380
+ "additionalProperties": False,
381
+ }
382
+ _ARTIFACT_WRITE_OUTPUT_SCHEMA: JsonObject = {
383
+ "type": "object",
384
+ "properties": {
385
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
386
+ "artifact_id": {"type": "string"},
387
+ "content_sha256": {"type": "string"},
388
+ },
389
+ "required": ["status", "summary", "artifact_id", "content_sha256"],
390
+ "additionalProperties": False,
391
+ }
392
+ _TERMINAL_SUBMIT_INPUT_SCHEMA: JsonObject = {
393
+ "type": "object",
394
+ "properties": {
395
+ "terminal_result": {"type": "string"},
396
+ "summary": {"type": "string"},
397
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
398
+ },
399
+ "required": ["terminal_result", "summary"],
400
+ "additionalProperties": False,
401
+ }
402
+ _TERMINAL_REJECT_INPUT_SCHEMA: JsonObject = {
403
+ "type": "object",
404
+ "properties": {
405
+ "terminal_result": {"type": "string"},
406
+ "summary": {"type": "string"},
407
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
408
+ },
409
+ "required": ["terminal_result", "summary"],
410
+ "additionalProperties": False,
411
+ }
412
+ _TERMINAL_ESCALATE_INPUT_SCHEMA: JsonObject = {
413
+ "type": "object",
414
+ "properties": {
415
+ "terminal_result": {"type": "string"},
416
+ "summary": {"type": "string"},
417
+ "blocker": {"type": "string"},
418
+ "artifact_refs": _STRING_ARRAY_SCHEMA,
419
+ },
420
+ "required": ["terminal_result", "summary", "blocker"],
421
+ "additionalProperties": False,
422
+ }
423
+ _TERMINAL_OUTPUT_SCHEMA: JsonObject = {
424
+ "type": "object",
425
+ "properties": {
426
+ **_COMMON_STATUS_SUMMARY_PROPERTIES,
427
+ "terminal_result": {"type": "string"},
428
+ },
429
+ "required": ["status", "summary", "terminal_result"],
430
+ "additionalProperties": False,
431
+ }
432
+
433
+
434
+ def _descriptor(
435
+ *,
436
+ tool_id: str,
437
+ model_tool_name: str,
438
+ description: str,
439
+ input_schema: Mapping[str, Any],
440
+ output_schema: Mapping[str, Any],
441
+ required_capabilities: tuple[str, ...],
442
+ produced_artifact_ids: tuple[str, ...] = (),
443
+ side_effect_class: SideEffectClass,
444
+ idempotency: IdempotencyClass,
445
+ timeout_policy: ToolTimeoutPolicy = _DEFAULT_TIMEOUT_POLICY,
446
+ ) -> ToolDescriptor:
447
+ return ToolDescriptor.model_validate(
448
+ {
449
+ "tool_id": tool_id,
450
+ "tool_version": BUILTIN_TOOL_VERSION,
451
+ "implementation_id": f"impl.{tool_id}.v1",
452
+ "model_tool_name": model_tool_name,
453
+ "description": description,
454
+ "input_schema": input_schema,
455
+ "output_schema": output_schema,
456
+ "required_capabilities": required_capabilities,
457
+ "produced_artifact_ids": produced_artifact_ids,
458
+ "side_effect_class": side_effect_class,
459
+ "idempotency": idempotency,
460
+ "timeout_policy": timeout_policy,
461
+ "output_policy": _DEFAULT_OUTPUT_POLICY,
462
+ }
463
+ )
464
+
465
+
466
+ BUILTIN_TOOL_DESCRIPTORS: tuple[ToolDescriptor, ...] = (
467
+ _descriptor(
468
+ tool_id="builtin.request.inspect",
469
+ model_tool_name="inspect_request",
470
+ description="Inspect the active request context.",
471
+ input_schema=_EMPTY_INPUT_SCHEMA,
472
+ output_schema=_REQUEST_INSPECT_OUTPUT_SCHEMA,
473
+ required_capabilities=(BUILTIN_CAP_REQUEST_READ,),
474
+ side_effect_class=SideEffectClass.READ_ONLY,
475
+ idempotency=IdempotencyClass.IDEMPOTENT,
476
+ ),
477
+ _descriptor(
478
+ tool_id="builtin.request.read_requirements",
479
+ model_tool_name="read_request_requirements",
480
+ description="Read the active request requirements.",
481
+ input_schema=_EMPTY_INPUT_SCHEMA,
482
+ output_schema=_REQUEST_REQUIREMENTS_OUTPUT_SCHEMA,
483
+ required_capabilities=(BUILTIN_CAP_REQUEST_READ,),
484
+ side_effect_class=SideEffectClass.READ_ONLY,
485
+ idempotency=IdempotencyClass.IDEMPOTENT,
486
+ ),
487
+ _descriptor(
488
+ tool_id="builtin.workspace.list_files",
489
+ model_tool_name="list_workspace_files",
490
+ description="List workspace-relative files under a root.",
491
+ input_schema=_WORKSPACE_LIST_INPUT_SCHEMA,
492
+ output_schema=_WORKSPACE_LIST_OUTPUT_SCHEMA,
493
+ required_capabilities=(BUILTIN_CAP_WORKSPACE_READ,),
494
+ side_effect_class=SideEffectClass.READ_ONLY,
495
+ idempotency=IdempotencyClass.IDEMPOTENT,
496
+ ),
497
+ _descriptor(
498
+ tool_id="builtin.workspace.read_file",
499
+ model_tool_name="read_workspace_file",
500
+ description="Read a workspace-relative file.",
501
+ input_schema=_WORKSPACE_READ_INPUT_SCHEMA,
502
+ output_schema=_WORKSPACE_READ_OUTPUT_SCHEMA,
503
+ required_capabilities=(BUILTIN_CAP_WORKSPACE_READ,),
504
+ side_effect_class=SideEffectClass.READ_ONLY,
505
+ idempotency=IdempotencyClass.IDEMPOTENT,
506
+ ),
507
+ _descriptor(
508
+ tool_id="builtin.workspace.search_text",
509
+ model_tool_name="search_workspace_text",
510
+ description="Search workspace-relative text by query.",
511
+ input_schema=_WORKSPACE_SEARCH_INPUT_SCHEMA,
512
+ output_schema=_WORKSPACE_SEARCH_OUTPUT_SCHEMA,
513
+ required_capabilities=(
514
+ BUILTIN_CAP_WORKSPACE_READ,
515
+ BUILTIN_CAP_WORKSPACE_SEARCH,
516
+ ),
517
+ side_effect_class=SideEffectClass.READ_ONLY,
518
+ idempotency=IdempotencyClass.IDEMPOTENT,
519
+ ),
520
+ _descriptor(
521
+ tool_id="builtin.workspace.write_file",
522
+ model_tool_name="write_workspace_file",
523
+ description="Write a workspace-relative file.",
524
+ input_schema=_WORKSPACE_WRITE_INPUT_SCHEMA,
525
+ output_schema=_WORKSPACE_WRITE_OUTPUT_SCHEMA,
526
+ required_capabilities=(BUILTIN_CAP_WORKSPACE_WRITE,),
527
+ side_effect_class=SideEffectClass.WORKSPACE_WRITE,
528
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
529
+ ),
530
+ _descriptor(
531
+ tool_id="builtin.workspace.apply_patch",
532
+ model_tool_name="apply_workspace_patch",
533
+ description="Apply an idempotent workspace patch.",
534
+ input_schema=_WORKSPACE_PATCH_INPUT_SCHEMA,
535
+ output_schema=_WORKSPACE_PATCH_OUTPUT_SCHEMA,
536
+ required_capabilities=(BUILTIN_CAP_WORKSPACE_WRITE,),
537
+ side_effect_class=SideEffectClass.WORKSPACE_WRITE,
538
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
539
+ ),
540
+ _descriptor(
541
+ tool_id="builtin.workspace.read_diff",
542
+ model_tool_name="read_workspace_diff",
543
+ description="Read workspace diff data.",
544
+ input_schema=_WORKSPACE_DIFF_INPUT_SCHEMA,
545
+ output_schema=_WORKSPACE_DIFF_OUTPUT_SCHEMA,
546
+ required_capabilities=(BUILTIN_CAP_WORKSPACE_DIFF_READ,),
547
+ side_effect_class=SideEffectClass.READ_ONLY,
548
+ idempotency=IdempotencyClass.IDEMPOTENT,
549
+ ),
550
+ _descriptor(
551
+ tool_id="builtin.shell.run_tests",
552
+ model_tool_name="run_test_profile",
553
+ description="Run a controlled test profile.",
554
+ input_schema=_SHELL_TEST_INPUT_SCHEMA,
555
+ output_schema=_SHELL_OUTPUT_SCHEMA,
556
+ required_capabilities=(BUILTIN_CAP_PROCESS_TEST,),
557
+ side_effect_class=SideEffectClass.PROCESS_EXECUTION,
558
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
559
+ timeout_policy=_SHELL_TIMEOUT_POLICY,
560
+ ),
561
+ _descriptor(
562
+ tool_id="builtin.shell.run_static_check",
563
+ model_tool_name="run_static_check_profile",
564
+ description="Run a controlled static-check profile.",
565
+ input_schema=_SHELL_STATIC_CHECK_INPUT_SCHEMA,
566
+ output_schema=_SHELL_OUTPUT_SCHEMA,
567
+ required_capabilities=(BUILTIN_CAP_PROCESS_STATIC_CHECK,),
568
+ side_effect_class=SideEffectClass.PROCESS_EXECUTION,
569
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
570
+ timeout_policy=_SHELL_TIMEOUT_POLICY,
571
+ ),
572
+ _descriptor(
573
+ tool_id="builtin.artifact.read",
574
+ model_tool_name="read_artifact",
575
+ description="Read a declared artifact.",
576
+ input_schema=_ARTIFACT_READ_INPUT_SCHEMA,
577
+ output_schema=_ARTIFACT_READ_OUTPUT_SCHEMA,
578
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
579
+ side_effect_class=SideEffectClass.READ_ONLY,
580
+ idempotency=IdempotencyClass.IDEMPOTENT,
581
+ ),
582
+ _descriptor(
583
+ tool_id="builtin.artifact.read_plan",
584
+ model_tool_name="read_plan_artifact",
585
+ description="Read the fixed plan artifact.",
586
+ input_schema=_EMPTY_INPUT_SCHEMA,
587
+ output_schema=_ARTIFACT_READ_PLAN_OUTPUT_SCHEMA,
588
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
589
+ side_effect_class=SideEffectClass.READ_ONLY,
590
+ idempotency=IdempotencyClass.IDEMPOTENT,
591
+ ),
592
+ _descriptor(
593
+ tool_id="builtin.artifact.read_patch_summary",
594
+ model_tool_name="read_patch_summary_artifact",
595
+ description="Read the fixed patch summary artifact.",
596
+ input_schema=_EMPTY_INPUT_SCHEMA,
597
+ output_schema=_ARTIFACT_READ_PATCH_SUMMARY_OUTPUT_SCHEMA,
598
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
599
+ side_effect_class=SideEffectClass.READ_ONLY,
600
+ idempotency=IdempotencyClass.IDEMPOTENT,
601
+ ),
602
+ _descriptor(
603
+ tool_id="builtin.artifact.read_test_results",
604
+ model_tool_name="read_test_results_artifact",
605
+ description="Read the fixed test results artifact.",
606
+ input_schema=_EMPTY_INPUT_SCHEMA,
607
+ output_schema=_ARTIFACT_READ_TEST_RESULTS_OUTPUT_SCHEMA,
608
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
609
+ side_effect_class=SideEffectClass.READ_ONLY,
610
+ idempotency=IdempotencyClass.IDEMPOTENT,
611
+ ),
612
+ _descriptor(
613
+ tool_id="builtin.artifact.read_workspace_diff",
614
+ model_tool_name="read_workspace_diff_artifact",
615
+ description="Read the fixed workspace diff artifact.",
616
+ input_schema=_EMPTY_INPUT_SCHEMA,
617
+ output_schema=_ARTIFACT_READ_WORKSPACE_DIFF_OUTPUT_SCHEMA,
618
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
619
+ side_effect_class=SideEffectClass.READ_ONLY,
620
+ idempotency=IdempotencyClass.IDEMPOTENT,
621
+ ),
622
+ _descriptor(
623
+ tool_id="builtin.artifact.read_checker_verdict",
624
+ model_tool_name="read_checker_verdict_artifact",
625
+ description="Read the fixed checker verdict artifact.",
626
+ input_schema=_EMPTY_INPUT_SCHEMA,
627
+ output_schema=_ARTIFACT_READ_CHECKER_VERDICT_OUTPUT_SCHEMA,
628
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_READ,),
629
+ side_effect_class=SideEffectClass.READ_ONLY,
630
+ idempotency=IdempotencyClass.IDEMPOTENT,
631
+ ),
632
+ _descriptor(
633
+ tool_id="builtin.artifact.write_plan",
634
+ model_tool_name="write_plan_artifact",
635
+ description="Write a plan artifact.",
636
+ input_schema=_ARTIFACT_WRITE_PLAN_INPUT_SCHEMA,
637
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
638
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
639
+ produced_artifact_ids=("plan",),
640
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
641
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
642
+ ),
643
+ _descriptor(
644
+ tool_id="builtin.artifact.write_patch_summary",
645
+ model_tool_name="write_patch_summary_artifact",
646
+ description="Write a patch summary artifact.",
647
+ input_schema=_ARTIFACT_WRITE_PATCH_SUMMARY_INPUT_SCHEMA,
648
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
649
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
650
+ produced_artifact_ids=("patch_summary",),
651
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
652
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
653
+ ),
654
+ _descriptor(
655
+ tool_id="builtin.artifact.write_test_results",
656
+ model_tool_name="write_test_results_artifact",
657
+ description="Write a test results artifact.",
658
+ input_schema=_ARTIFACT_WRITE_TEST_RESULTS_INPUT_SCHEMA,
659
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
660
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
661
+ produced_artifact_ids=("test_results",),
662
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
663
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
664
+ ),
665
+ _descriptor(
666
+ tool_id="builtin.artifact.write_workspace_diff",
667
+ model_tool_name="write_workspace_diff_artifact",
668
+ description="Write the current workspace diff artifact.",
669
+ input_schema=_EMPTY_INPUT_SCHEMA,
670
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
671
+ required_capabilities=(
672
+ BUILTIN_CAP_WORKSPACE_DIFF_READ,
673
+ BUILTIN_CAP_ARTIFACT_WRITE,
674
+ ),
675
+ produced_artifact_ids=("workspace_diff",),
676
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
677
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
678
+ ),
679
+ _descriptor(
680
+ tool_id="builtin.artifact.write_checker_verdict",
681
+ model_tool_name="write_checker_verdict_artifact",
682
+ description="Write a checker verdict artifact.",
683
+ input_schema=_ARTIFACT_WRITE_CHECKER_VERDICT_INPUT_SCHEMA,
684
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
685
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
686
+ produced_artifact_ids=("checker_verdict",),
687
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
688
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
689
+ ),
690
+ _descriptor(
691
+ tool_id="builtin.artifact.write_arbiter_verdict",
692
+ model_tool_name="write_arbiter_verdict_artifact",
693
+ description="Write an arbiter verdict artifact.",
694
+ input_schema=_ARTIFACT_WRITE_ARBITER_VERDICT_INPUT_SCHEMA,
695
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
696
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
697
+ produced_artifact_ids=("arbiter_verdict",),
698
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
699
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
700
+ ),
701
+ _descriptor(
702
+ tool_id="builtin.artifact.write_verdict",
703
+ model_tool_name="write_verdict_artifact",
704
+ description="Write checker or arbiter verdict artifacts.",
705
+ input_schema=_ARTIFACT_WRITE_VERDICT_INPUT_SCHEMA,
706
+ output_schema=_ARTIFACT_WRITE_OUTPUT_SCHEMA,
707
+ required_capabilities=(BUILTIN_CAP_ARTIFACT_WRITE,),
708
+ produced_artifact_ids=("checker_verdict", "arbiter_verdict"),
709
+ side_effect_class=SideEffectClass.ARTIFACT_WRITE,
710
+ idempotency=IdempotencyClass.IDEMPOTENT_WITH_KEY,
711
+ ),
712
+ _descriptor(
713
+ tool_id="builtin.terminal.submit",
714
+ model_tool_name="submit_terminal_intent",
715
+ description="Submit a terminal result intent.",
716
+ input_schema=_TERMINAL_SUBMIT_INPUT_SCHEMA,
717
+ output_schema=_TERMINAL_OUTPUT_SCHEMA,
718
+ required_capabilities=(BUILTIN_CAP_TERMINAL_INTENT,),
719
+ side_effect_class=SideEffectClass.TERMINAL,
720
+ idempotency=IdempotencyClass.NON_IDEMPOTENT,
721
+ timeout_policy=_TERMINAL_TIMEOUT_POLICY,
722
+ ),
723
+ _descriptor(
724
+ tool_id="builtin.terminal.reject",
725
+ model_tool_name="reject_terminal_intent",
726
+ description="Submit a terminal rejection intent.",
727
+ input_schema=_TERMINAL_REJECT_INPUT_SCHEMA,
728
+ output_schema=_TERMINAL_OUTPUT_SCHEMA,
729
+ required_capabilities=(BUILTIN_CAP_TERMINAL_INTENT,),
730
+ side_effect_class=SideEffectClass.TERMINAL,
731
+ idempotency=IdempotencyClass.NON_IDEMPOTENT,
732
+ timeout_policy=_TERMINAL_TIMEOUT_POLICY,
733
+ ),
734
+ _descriptor(
735
+ tool_id="builtin.terminal.escalate",
736
+ model_tool_name="escalate_terminal_intent",
737
+ description="Submit a terminal escalation intent.",
738
+ input_schema=_TERMINAL_ESCALATE_INPUT_SCHEMA,
739
+ output_schema=_TERMINAL_OUTPUT_SCHEMA,
740
+ required_capabilities=(BUILTIN_CAP_TERMINAL_INTENT,),
741
+ side_effect_class=SideEffectClass.TERMINAL,
742
+ idempotency=IdempotencyClass.NON_IDEMPOTENT,
743
+ timeout_policy=_TERMINAL_TIMEOUT_POLICY,
744
+ ),
745
+ )
746
+
747
+
748
+ def iter_builtin_tool_descriptors() -> tuple[ToolDescriptor, ...]:
749
+ """Return the immutable descriptor-only built-in catalog."""
750
+ return BUILTIN_TOOL_DESCRIPTORS
751
+
752
+
753
+ def create_builtin_tool_registry() -> ToolRegistry:
754
+ """Create a registry populated with the descriptor-only built-in catalog."""
755
+ registry = ToolRegistry()
756
+ for descriptor in BUILTIN_TOOL_DESCRIPTORS:
757
+ registry.register(descriptor)
758
+ return registry
759
+
760
+
761
+ def create_builtin_tool_snapshot() -> ToolCatalogSnapshot:
762
+ """Create a frozen exact-version snapshot for the built-in catalog."""
763
+ return create_builtin_tool_registry().freeze()
764
+
765
+
766
+ __all__ = [
767
+ "BUILTIN_CAPABILITY_IDS",
768
+ "BUILTIN_TOOL_DESCRIPTORS",
769
+ "BUILTIN_TOOL_VERSION",
770
+ "create_builtin_tool_registry",
771
+ "create_builtin_tool_snapshot",
772
+ "iter_builtin_tool_descriptors",
773
+ ]