forgeproof-cli 0.2.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.
- forge_gate/__init__.py +44 -0
- forge_gate/_deprecated_cli.py +16 -0
- forgeproof/__init__.py +3 -0
- forgeproof/catalog.py +110 -0
- forgeproof/cli.py +560 -0
- forgeproof/config.py +339 -0
- forgeproof/data/gate_catalog.json +66 -0
- forgeproof/data/host_sets.json +7 -0
- forgeproof/debug_caller.py +271 -0
- forgeproof/debug_core.py +368 -0
- forgeproof/fixture_engine.py +81 -0
- forgeproof/fixtures/__init__.py +19 -0
- forgeproof/fixtures/decision_tree_id3.py +90 -0
- forgeproof/fixtures/gradient_descent_momentum.py +73 -0
- forgeproof/fixtures/kmeans_clustering.py +98 -0
- forgeproof/fixtures/knn_classifier.py +79 -0
- forgeproof/fixtures/linear_regression_gd.py +77 -0
- forgeproof/fixtures/logistic_regression.py +85 -0
- forgeproof/fixtures/naive_bayes_text.py +114 -0
- forgeproof/fixtures/perceptron.py +84 -0
- forgeproof/fixtures/polynomial_regression.py +67 -0
- forgeproof/fixtures/ridge_regression_normal_eq.py +75 -0
- forgeproof/ledger.py +633 -0
- forgeproof/lens_tools/__init__.py +11 -0
- forgeproof/lens_tools/guard_lens.py +1250 -0
- forgeproof/lens_tools/invariant_contracts/linear_regression_gd.json +74 -0
- forgeproof/lens_tools/invariant_contracts/polynomial_regression.json +86 -0
- forgeproof/lens_tools/invariant_contracts/ridge_regression_normal_eq.json +86 -0
- forgeproof/lens_tools/invariant_gate.py +199 -0
- forgeproof/lens_tools/metamorphic/__init__.py +9 -0
- forgeproof/lens_tools/metamorphic/relations.py +962 -0
- forgeproof/lens_tools/metamorphic/runner.py +112 -0
- forgeproof/lens_tools/twin_consensus.py +395 -0
- forgeproof/lenses.py +923 -0
- forgeproof/paths.py +56 -0
- forgeproof/reference/ORIGIN.md +29 -0
- forgeproof/reference/decision_tree_id3.py +197 -0
- forgeproof/reference/gradient_descent_momentum.py +141 -0
- forgeproof/reference/kmeans_clustering.py +139 -0
- forgeproof/reference/knn_classifier.py +118 -0
- forgeproof/reference/linear_regression_gd.py +106 -0
- forgeproof/reference/logistic_regression.py +141 -0
- forgeproof/reference/naive_bayes_text.py +152 -0
- forgeproof/reference/perceptron.py +123 -0
- forgeproof/reference/polynomial_regression.py +125 -0
- forgeproof/reference/ridge_regression_normal_eq.py +165 -0
- forgeproof/runner.py +147 -0
- forgeproof/scout/__init__.py +7 -0
- forgeproof/scout/behaviour.py +365 -0
- forgeproof/scout/box.py +581 -0
- forgeproof/scout/cards.py +180 -0
- forgeproof/scout/contract.py +37 -0
- forgeproof/scout/corpus.py +104 -0
- forgeproof/scout/embed.py +217 -0
- forgeproof/scout/engines/__init__.py +1 -0
- forgeproof/scout/engines/chaos.py +454 -0
- forgeproof/scout/engines/chaos_port.py +1331 -0
- forgeproof/scout/engines/chaos_runner.py +178 -0
- forgeproof/scout/engines/executor_port.py +239 -0
- forgeproof/scout/envfit.py +54 -0
- forgeproof/scout/experience.py +161 -0
- forgeproof/scout/fetchproxy.py +368 -0
- forgeproof/scout/ghcache.py +395 -0
- forgeproof/scout/ghpool.py +253 -0
- forgeproof/scout/ghsearch.py +248 -0
- forgeproof/scout/ids.py +82 -0
- forgeproof/scout/intent_lens.py +170 -0
- forgeproof/scout/learn.py +583 -0
- forgeproof/scout/meaning_lens.py +231 -0
- forgeproof/scout/outcomes.py +42 -0
- forgeproof/scout/plant.py +327 -0
- forgeproof/scout/ratify.py +214 -0
- forgeproof/scout/report.py +448 -0
- forgeproof/scout/rule2.py +177 -0
- forgeproof/scout/shape.py +107 -0
- forgeproof/scout/shape_lens.py +71 -0
- forgeproof/scout/signature.py +52 -0
- forgeproof/scout/slots.py +39 -0
- forgeproof/scout/upstream_facts.py +536 -0
- forgeproof/unsupported.py +83 -0
- forgeproof/verifier.py +208 -0
- forgeproof/view_coverage.py +166 -0
- forgeproof_cli-0.2.0.dist-info/METADATA +285 -0
- forgeproof_cli-0.2.0.dist-info/RECORD +89 -0
- forgeproof_cli-0.2.0.dist-info/WHEEL +5 -0
- forgeproof_cli-0.2.0.dist-info/entry_points.txt +3 -0
- forgeproof_cli-0.2.0.dist-info/licenses/LICENSE +201 -0
- forgeproof_cli-0.2.0.dist-info/licenses/NOTICE +23 -0
- forgeproof_cli-0.2.0.dist-info/top_level.txt +2 -0
forge_gate/__init__.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Deprecated alias: Forge Gate was renamed ForgeProof on 2026-11-25.
|
|
2
|
+
|
|
3
|
+
``import forge_gate`` and ``import forge_gate.<module>`` keep working for one release: each
|
|
4
|
+
``forge_gate.<module>`` IS ``forgeproof.<module>`` (the same module object). Import ``forgeproof``
|
|
5
|
+
instead; this alias will be removed in a later release.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import importlib
|
|
9
|
+
import importlib.abc
|
|
10
|
+
import importlib.util
|
|
11
|
+
import sys
|
|
12
|
+
import warnings
|
|
13
|
+
|
|
14
|
+
_OLD, _NEW = "forge_gate", "forgeproof"
|
|
15
|
+
_OWN = (_OLD + "._deprecated_cli",) # real modules of this shim package, never aliased
|
|
16
|
+
|
|
17
|
+
warnings.warn(
|
|
18
|
+
"the 'forge_gate' package was renamed to 'forgeproof' (2026-11-25); import 'forgeproof' instead. "
|
|
19
|
+
"This alias will be removed in a later release.",
|
|
20
|
+
DeprecationWarning,
|
|
21
|
+
stacklevel=2,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _Alias(importlib.abc.MetaPathFinder, importlib.abc.Loader):
|
|
26
|
+
"""Serve ``forge_gate.x`` as the already-imported module ``forgeproof.x``."""
|
|
27
|
+
|
|
28
|
+
def find_spec(self, name, path=None, target=None):
|
|
29
|
+
if name.startswith(_OLD + ".") and name not in _OWN:
|
|
30
|
+
return importlib.util.spec_from_loader(name, self)
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
def create_module(self, spec):
|
|
34
|
+
return importlib.import_module(_NEW + spec.name[len(_OLD):])
|
|
35
|
+
|
|
36
|
+
def exec_module(self, module):
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if not any(isinstance(f, _Alias) for f in sys.meta_path):
|
|
41
|
+
sys.meta_path.insert(0, _Alias())
|
|
42
|
+
|
|
43
|
+
from forgeproof import * # noqa: E402,F401,F403
|
|
44
|
+
from forgeproof import __version__ # noqa: E402,F401
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""The ``forge-gate`` command: renamed ``forgeproof`` on 2026-11-25. Kept for one release."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
NOTICE = ("forge-gate: this command was renamed to 'forgeproof' (2026-11-25). "
|
|
6
|
+
"Running 'forgeproof' now; please update your scripts.")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main(argv=None) -> int:
|
|
10
|
+
print(NOTICE, file=sys.stderr)
|
|
11
|
+
from forgeproof.cli import main as forgeproof_main
|
|
12
|
+
return forgeproof_main(argv)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if __name__ == "__main__":
|
|
16
|
+
sys.exit(main())
|
forgeproof/__init__.py
ADDED
forgeproof/catalog.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""Pattern catalog resolver.
|
|
2
|
+
|
|
3
|
+
Maps a pattern name to its reference implementation and the matching gate fixture.
|
|
4
|
+
`gate_catalog.json` is the curated, gate-ready subset that ships with ForgeProof. The
|
|
5
|
+
reference implementations ship too, in `forgeproof/reference/` (byte copies of library
|
|
6
|
+
patterns; see `reference/ORIGIN.md`), so `forgeproof verify` reads no other project.
|
|
7
|
+
The live library is read only when a caller passes `library_root` or uses
|
|
8
|
+
`load_aura_catalog`, and then through `config.library_dir()` (FORGE_GATE_LIBRARY_DIR).
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import re
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Dict, Optional, Tuple
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CatalogError(Exception):
|
|
19
|
+
"""Raised when a pattern cannot be resolved or is not gate-ready."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _data_dir() -> Path:
|
|
23
|
+
return Path(__file__).resolve().parent / "data"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def reference_dir() -> Path:
|
|
27
|
+
"""The shipped reference implementations (see reference/ORIGIN.md)."""
|
|
28
|
+
return Path(__file__).resolve().parent / "reference"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def reference_path(name: str) -> Path:
|
|
32
|
+
"""The shipped reference implementation for a gate-ready pattern."""
|
|
33
|
+
return reference_dir() / f"{name}.py"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def load_gate_catalog() -> Dict:
|
|
37
|
+
"""Load the curated gate catalog shipped with this package."""
|
|
38
|
+
catalog_path = _data_dir() / "gate_catalog.json"
|
|
39
|
+
with open(catalog_path, encoding="utf-8") as f:
|
|
40
|
+
return json.load(f)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def load_aura_catalog(library_root: Optional[Path] = None) -> Dict[str, Tuple[str, str]]:
|
|
44
|
+
"""Parse CATALOG.md and return {pattern_id: (languages, category)}.
|
|
45
|
+
|
|
46
|
+
This is used for validation and to discover the canonical path of a pattern
|
|
47
|
+
when it is not in the curated gate catalog.
|
|
48
|
+
"""
|
|
49
|
+
if library_root is None:
|
|
50
|
+
from forgeproof.config import library_dir
|
|
51
|
+
|
|
52
|
+
library_root = library_dir()
|
|
53
|
+
catalog_md = library_root / "CATALOG.md"
|
|
54
|
+
if not catalog_md.exists():
|
|
55
|
+
raise CatalogError(f"AURA CATALOG.md not found at {catalog_md}")
|
|
56
|
+
|
|
57
|
+
text = catalog_md.read_text(encoding="utf-8")
|
|
58
|
+
mapping: Dict[str, Tuple[str, str]] = {}
|
|
59
|
+
# Table rows look like: | `id` | python·cpp | Category |
|
|
60
|
+
for line in text.splitlines():
|
|
61
|
+
m = re.match(r"^\|\s*`([^`]+)`\s*\|\s*([^|]+)\|\s*([^|]+)\|\s*$", line)
|
|
62
|
+
if m:
|
|
63
|
+
pid = m.group(1).strip()
|
|
64
|
+
langs = m.group(2).strip()
|
|
65
|
+
category = m.group(3).strip()
|
|
66
|
+
mapping[pid] = (langs, category)
|
|
67
|
+
return mapping
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def resolve_pattern(name: str, library_root: Optional[Path] = None) -> Dict:
|
|
71
|
+
"""Resolve a pattern name to its gate metadata.
|
|
72
|
+
|
|
73
|
+
Returns a dict with keys:
|
|
74
|
+
- name
|
|
75
|
+
- aura_path (absolute Path): the shipped reference copy by default; the file in
|
|
76
|
+
the live library when ``library_root`` is given
|
|
77
|
+
- fixture
|
|
78
|
+
- category
|
|
79
|
+
- description
|
|
80
|
+
"""
|
|
81
|
+
catalog = load_gate_catalog()
|
|
82
|
+
|
|
83
|
+
entry = catalog["patterns"].get(name)
|
|
84
|
+
if not entry:
|
|
85
|
+
raise CatalogError(
|
|
86
|
+
f"Pattern '{name}' is not in the ForgeProof v{catalog['version']} catalog. "
|
|
87
|
+
f"Run `forgeproof list` to see gate-ready patterns."
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
if library_root is None:
|
|
91
|
+
aura_path = reference_path(name).resolve()
|
|
92
|
+
where = "the shipped reference copy (forgeproof/reference/)"
|
|
93
|
+
else:
|
|
94
|
+
aura_path = (Path(library_root) / entry["aura_path"]).resolve()
|
|
95
|
+
where = f"the library at {library_root}"
|
|
96
|
+
if not aura_path.exists():
|
|
97
|
+
raise CatalogError(f"Reference implementation missing for '{name}': {aura_path} ({where}).")
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
"name": name,
|
|
101
|
+
"aura_path": aura_path,
|
|
102
|
+
"fixture": entry["fixture"],
|
|
103
|
+
"category": entry["category"],
|
|
104
|
+
"description": entry.get("description", ""),
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def list_patterns() -> Dict[str, Dict]:
|
|
109
|
+
"""Return all gate-ready patterns."""
|
|
110
|
+
return load_gate_catalog()["patterns"]
|