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.
- millforge/__init__.py +1174 -0
- millforge/_forge/LICENSE +21 -0
- millforge/_forge/PROVENANCE.json +295 -0
- millforge/_forge/UPDATE_POLICY.md +24 -0
- millforge/_forge/__init__.py +14 -0
- millforge/_forge/adapter.py +2232 -0
- millforge/_forge/base_runner.py +121 -0
- millforge/_forge/clients/__init__.py +10 -0
- millforge/_forge/clients/base.py +200 -0
- millforge/_forge/context/__init__.py +23 -0
- millforge/_forge/context/manager.py +178 -0
- millforge/_forge/context/strategies.py +335 -0
- millforge/_forge/core/__init__.py +16 -0
- millforge/_forge/core/inference.py +433 -0
- millforge/_forge/core/messages.py +119 -0
- millforge/_forge/core/runner.py +479 -0
- millforge/_forge/core/steps.py +108 -0
- millforge/_forge/core/workflow.py +400 -0
- millforge/_forge/errors.py +222 -0
- millforge/_forge/guardrails/__init__.py +21 -0
- millforge/_forge/guardrails/error_tracker.py +71 -0
- millforge/_forge/guardrails/guardrails.py +194 -0
- millforge/_forge/guardrails/nudge.py +47 -0
- millforge/_forge/guardrails/response_validator.py +119 -0
- millforge/_forge/guardrails/step_enforcer.py +183 -0
- millforge/_forge/prompts/__init__.py +16 -0
- millforge/_forge/prompts/nudges.py +95 -0
- millforge/_forge/prompts/templates.py +285 -0
- millforge/_version.py +3 -0
- millforge/artifacts.py +570 -0
- millforge/base/__init__.py +97 -0
- millforge/base/composition.py +402 -0
- millforge/base/context.py +285 -0
- millforge/base/harness.py +138 -0
- millforge/base/identity.py +465 -0
- millforge/base/options.py +34 -0
- millforge/base/platform.py +17 -0
- millforge/base/prompt.py +317 -0
- millforge/base/runner.py +546 -0
- millforge/compiled_plan.py +970 -0
- millforge/compiler/__init__.py +231 -0
- millforge/compiler/artifact_validation.py +257 -0
- millforge/compiler/canonicalization.py +169 -0
- millforge/compiler/capabilities.py +66 -0
- millforge/compiler/catalogs.py +500 -0
- millforge/compiler/diagnostics.py +491 -0
- millforge/compiler/graph.py +678 -0
- millforge/compiler/lowering.py +198 -0
- millforge/compiler/output.py +692 -0
- millforge/compiler/parsing.py +1424 -0
- millforge/compiler/requests.py +1180 -0
- millforge/compiler/schema_validation.py +272 -0
- millforge/compiler/semantic.py +490 -0
- millforge/compiler/service.py +448 -0
- millforge/compiler/source.py +375 -0
- millforge/compiler/validators.py +184 -0
- millforge/connectors/__init__.py +95 -0
- millforge/connectors/admission.py +801 -0
- millforge/connectors/broker.py +202 -0
- millforge/connectors/contracts.py +1159 -0
- millforge/connectors/diagnostics.py +189 -0
- millforge/connectors/fake.py +66 -0
- millforge/connectors/runtime.py +236 -0
- millforge/contracts.py +2860 -0
- millforge/custom_tools/__init__.py +67 -0
- millforge/custom_tools/compiler.py +724 -0
- millforge/custom_tools/contracts.py +1093 -0
- millforge/custom_tools/diagnostics.py +205 -0
- millforge/eval_artifacts.py +952 -0
- millforge/eval_boundary.py +2435 -0
- millforge/eval_fixtures/__init__.py +1 -0
- millforge/eval_fixtures/default_pack/__init__.py +1 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.bug_diagnosis.traceback.v1.json +52 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.direct_edit.import_sort.v1.json +52 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.evidence_discipline.no_source_change.v1.json +51 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.false_closure.visible_green.v1.json +52 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.multi_file.api_contract.v1.json +54 -0
- millforge/eval_fixtures/default_pack/fixtures/fixture.08a.recovery.malformed_artifact.v1.json +54 -0
- millforge/eval_fixtures/default_pack/manifest.json +12 -0
- millforge/eval_modes.py +1282 -0
- millforge/eval_presets.py +1398 -0
- millforge/eval_reports.py +2517 -0
- millforge/eval_suite.py +2429 -0
- millforge/eval_trials.py +2632 -0
- millforge/eval_workflow.py +794 -0
- millforge/exceptions.py +122 -0
- millforge/model_backend.py +2098 -0
- millforge/protocols.py +340 -0
- millforge/py.typed +0 -0
- millforge/runtime.py +1791 -0
- millforge/testing/__init__.py +1089 -0
- millforge/tools/__init__.py +83 -0
- millforge/tools/builtin_runtime.py +1339 -0
- millforge/tools/builtins.py +773 -0
- millforge/tools/execution.py +1545 -0
- millforge/tools/path_policy.py +155 -0
- millforge/tools/pi_compat/PI_LICENSE +21 -0
- millforge/tools/pi_compat/PROVENANCE.json +55 -0
- millforge/tools/pi_compat/UPDATE_POLICY.md +36 -0
- millforge/tools/pi_compat/__init__.py +34 -0
- millforge/tools/pi_compat/contracts.py +49 -0
- millforge/tools/pi_compat/editing.py +390 -0
- millforge/tools/pi_compat/mutations.py +57 -0
- millforge/tools/pi_compat/operations.py +401 -0
- millforge/tools/pi_compat/paths.py +155 -0
- millforge/tools/pi_compat/process.py +1375 -0
- millforge/tools/pi_compat/search.py +738 -0
- millforge/tools/pi_compat/truncation.py +267 -0
- millforge/tools/pi_compat_catalog.py +396 -0
- millforge/tools/pi_compat_runtime.py +460 -0
- millforge/tools/registry.py +553 -0
- millforge/tools/results.py +533 -0
- millforge-0.1.0.dist-info/METADATA +844 -0
- millforge-0.1.0.dist-info/RECORD +116 -0
- millforge-0.1.0.dist-info/WHEEL +4 -0
- millforge-0.1.0.dist-info/licenses/LICENSE +201 -0
millforge/exceptions.py
ADDED
|
@@ -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
|
+
"""
|