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,122 @@
1
+ """Exception hierarchy for the millforge library.
2
+
3
+ All millforge-specific exceptions are subclasses of `MillforgeError`.
4
+ Downstream code should catch ``MillforgeError`` when handling any
5
+ expected millforge failure mode, or catch specific subclasses for
6
+ targeted recovery.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Literal, Optional
12
+
13
+ from millforge.contracts import redact_diagnostic_text
14
+
15
+
16
+ class MillforgeError(Exception):
17
+ """Base exception for all millforge errors.
18
+
19
+ All millforge-specific exceptions inherit from this class so that
20
+ downstream code can catch ``MillforgeError`` as a blanket handler.
21
+ """
22
+
23
+ def __init__(self, message: str, *, cause: Optional[Exception] = None) -> None:
24
+ super().__init__(message)
25
+ self._cause = cause
26
+ if cause is not None:
27
+ self.__cause__ = cause
28
+
29
+ def __str__(self) -> str:
30
+ """Return the redacted owned message without cause text."""
31
+ return redact_diagnostic_text(self.args[0]) if self.args else ""
32
+
33
+ def __repr__(self) -> str:
34
+ """Return the redacted owned message without cause text."""
35
+ return redact_diagnostic_text(self.args[0]) if self.args else ""
36
+
37
+
38
+ class MillforgeConfigError(MillforgeError):
39
+ """Configuration or contract validation error.
40
+
41
+ Raised when millforge configuration values are invalid, missing, or
42
+ inconsistent, or when a runtime contract validation fails.
43
+ """
44
+
45
+
46
+ class MillforgeBaseClosedError(MillforgeError):
47
+ """A live ``millforge-base`` runner was used after asynchronous close."""
48
+
49
+ def __init__(self) -> None:
50
+ super().__init__("millforge-base live runner is closed")
51
+
52
+
53
+ class UnsupportedPlatformError(MillforgeConfigError):
54
+ """The base runner was invoked on an unsupported native platform."""
55
+
56
+ platform_id: str
57
+ supported_platforms: tuple[Literal["linux", "darwin"], ...]
58
+
59
+ def __init__(self, platform_id: str) -> None:
60
+ self.platform_id = platform_id
61
+ self.supported_platforms = ("linux", "darwin")
62
+ super().__init__(
63
+ "millforge-base requires Linux, macOS, or WSL; "
64
+ f"native platform {platform_id} is unsupported"
65
+ )
66
+
67
+
68
+ class HarnessMismatchError(MillforgeError):
69
+ """Compiled-harness mismatch error.
70
+
71
+ Raised when the runtime environment does not match the harness
72
+ definition that a plan or artifact was compiled against.
73
+ """
74
+
75
+
76
+ class BackendTranslationError(MillforgeError):
77
+ """Backend translation error.
78
+
79
+ Raised when a request or response cannot be translated between
80
+ millforge's internal representation and a backend-specific format.
81
+ """
82
+
83
+
84
+ class ModelTransportError(MillforgeError):
85
+ """Model transport error.
86
+
87
+ Raised when a model request cannot be sent or a response cannot be
88
+ received over the transport layer (HTTP, IPC, etc.).
89
+ """
90
+
91
+
92
+ class ToolInvokeError(MillforgeError):
93
+ """Tool execution error.
94
+
95
+ Raised when a tool callable raises during invocation or returns an
96
+ unexpected result.
97
+ """
98
+
99
+
100
+ class DeadlineExceededError(MillforgeError):
101
+ """Operation deadline exceeded.
102
+
103
+ Raised when an operation (model call, tool execution, workflow step)
104
+ exceeds its configured timeout.
105
+ """
106
+
107
+
108
+ class OperationCancelledError(MillforgeError):
109
+ """Operation was cancelled.
110
+
111
+ Raised when an operation is cancelled via an explicit cancellation
112
+ signal before completion.
113
+ """
114
+
115
+
116
+ class ArtifactWriteError(MillforgeError):
117
+ """Artifact write error.
118
+
119
+ Raised when an artifact cannot be written to its target location,
120
+ including permission errors, disk-full conditions, or serialisation
121
+ failures.
122
+ """