crucible-forge 0.1.0__tar.gz

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 (101) hide show
  1. crucible_forge-0.1.0/.gitignore +38 -0
  2. crucible_forge-0.1.0/LICENSE +201 -0
  3. crucible_forge-0.1.0/PKG-INFO +204 -0
  4. crucible_forge-0.1.0/README.md +180 -0
  5. crucible_forge-0.1.0/pyproject.toml +70 -0
  6. crucible_forge-0.1.0/src/crucible/__init__.py +57 -0
  7. crucible_forge-0.1.0/src/crucible/_spec.py +20 -0
  8. crucible_forge-0.1.0/src/crucible/api/__init__.py +25 -0
  9. crucible_forge-0.1.0/src/crucible/api/dispatcher.py +59 -0
  10. crucible_forge-0.1.0/src/crucible/api/input_validation.py +54 -0
  11. crucible_forge-0.1.0/src/crucible/api/phase_classification.py +14 -0
  12. crucible_forge-0.1.0/src/crucible/api/phases/__init__.py +19 -0
  13. crucible_forge-0.1.0/src/crucible/api/phases/_common.py +103 -0
  14. crucible_forge-0.1.0/src/crucible/api/phases/cross_validation.py +70 -0
  15. crucible_forge-0.1.0/src/crucible/api/phases/epic_decomposition.py +40 -0
  16. crucible_forge-0.1.0/src/crucible/api/phases/epic_expansion.py +99 -0
  17. crucible_forge-0.1.0/src/crucible/api/phases/planning_spec.py +82 -0
  18. crucible_forge-0.1.0/src/crucible/api/phases/ticket_decomposition.py +47 -0
  19. crucible_forge-0.1.0/src/crucible/api/phases/ticket_expansion.py +98 -0
  20. crucible_forge-0.1.0/src/crucible/api/scope_resolver.py +70 -0
  21. crucible_forge-0.1.0/src/crucible/api/validate.py +83 -0
  22. crucible_forge-0.1.0/src/crucible/api/version.py +7 -0
  23. crucible_forge-0.1.0/src/crucible/checks/__init__.py +14 -0
  24. crucible_forge-0.1.0/src/crucible/checks/coverage.py +148 -0
  25. crucible_forge-0.1.0/src/crucible/checks/na_validation.py +77 -0
  26. crucible_forge-0.1.0/src/crucible/config/__init__.py +35 -0
  27. crucible_forge-0.1.0/src/crucible/config/data/defaults.yml +198 -0
  28. crucible_forge-0.1.0/src/crucible/config/defaults.py +185 -0
  29. crucible_forge-0.1.0/src/crucible/config/load.py +45 -0
  30. crucible_forge-0.1.0/src/crucible/config/merge.py +39 -0
  31. crucible_forge-0.1.0/src/crucible/config/overrides.py +34 -0
  32. crucible_forge-0.1.0/src/crucible/config/resolver.py +66 -0
  33. crucible_forge-0.1.0/src/crucible/config/schema.py +106 -0
  34. crucible_forge-0.1.0/src/crucible/config/snapshot.py +11 -0
  35. crucible_forge-0.1.0/src/crucible/cross_validation/__init__.py +108 -0
  36. crucible_forge-0.1.0/src/crucible/cross_validation/blueprint.py +61 -0
  37. crucible_forge-0.1.0/src/crucible/cross_validation/dependency_graph.py +212 -0
  38. crucible_forge-0.1.0/src/crucible/cross_validation/emission.py +13 -0
  39. crucible_forge-0.1.0/src/crucible/cross_validation/files.py +154 -0
  40. crucible_forge-0.1.0/src/crucible/cross_validation/ratios/__init__.py +0 -0
  41. crucible_forge-0.1.0/src/crucible/cross_validation/topology.py +118 -0
  42. crucible_forge-0.1.0/src/crucible/cross_validation/waves.py +237 -0
  43. crucible_forge-0.1.0/src/crucible/engines/__init__.py +20 -0
  44. crucible_forge-0.1.0/src/crucible/engines/ratios.py +85 -0
  45. crucible_forge-0.1.0/src/crucible/engines/wave_calculator.py +85 -0
  46. crucible_forge-0.1.0/src/crucible/guidance/__init__.py +0 -0
  47. crucible_forge-0.1.0/src/crucible/guidance/composer/__init__.py +44 -0
  48. crucible_forge-0.1.0/src/crucible/guidance/composer/patterns.py +304 -0
  49. crucible_forge-0.1.0/src/crucible/guidance/engine/__init__.py +21 -0
  50. crucible_forge-0.1.0/src/crucible/guidance/engine/applicability.py +24 -0
  51. crucible_forge-0.1.0/src/crucible/guidance/engine/finding_engine.py +193 -0
  52. crucible_forge-0.1.0/src/crucible/guidance/engine/resolver.py +73 -0
  53. crucible_forge-0.1.0/src/crucible/guidance/engine/structural_checks.py +123 -0
  54. crucible_forge-0.1.0/src/crucible/guidance/engine/value_resolver.py +31 -0
  55. crucible_forge-0.1.0/src/crucible/guidance/fixed_prompts.py +52 -0
  56. crucible_forge-0.1.0/src/crucible/guidance/format/__init__.py +68 -0
  57. crucible_forge-0.1.0/src/crucible/guidance/format/individual_formatter.py +126 -0
  58. crucible_forge-0.1.0/src/crucible/guidance/format/operations_vocabulary.py +29 -0
  59. crucible_forge-0.1.0/src/crucible/guidance/format/templates.py +299 -0
  60. crucible_forge-0.1.0/src/crucible/guidance/format/truncation.py +19 -0
  61. crucible_forge-0.1.0/src/crucible/guidance/rubric/__init__.py +88 -0
  62. crucible_forge-0.1.0/src/crucible/guidance/rubric/data/rubric.json +1414 -0
  63. crucible_forge-0.1.0/src/crucible/models/__init__.py +91 -0
  64. crucible_forge-0.1.0/src/crucible/models/_base.py +23 -0
  65. crucible_forge-0.1.0/src/crucible/models/auxiliary.py +71 -0
  66. crucible_forge-0.1.0/src/crucible/models/blueprint.py +21 -0
  67. crucible_forge-0.1.0/src/crucible/models/enums.py +157 -0
  68. crucible_forge-0.1.0/src/crucible/models/epic.py +40 -0
  69. crucible_forge-0.1.0/src/crucible/models/planning.py +104 -0
  70. crucible_forge-0.1.0/src/crucible/models/specification.py +59 -0
  71. crucible_forge-0.1.0/src/crucible/models/ticket.py +53 -0
  72. crucible_forge-0.1.0/src/crucible/py.typed +0 -0
  73. crucible_forge-0.1.0/src/crucible/scoring/__init__.py +47 -0
  74. crucible_forge-0.1.0/src/crucible/scoring/cascade.py +118 -0
  75. crucible_forge-0.1.0/src/crucible/scoring/field_declarations.py +72 -0
  76. crucible_forge-0.1.0/src/crucible/scoring/global_.py +69 -0
  77. crucible_forge-0.1.0/src/crucible/scoring/per_entity.py +31 -0
  78. crucible_forge-0.1.0/src/crucible/scoring/per_field.py +135 -0
  79. crucible_forge-0.1.0/src/crucible/scoring/quality_checks/__init__.py +147 -0
  80. crucible_forge-0.1.0/src/crucible/scoring/tiers.py +10 -0
  81. crucible_forge-0.1.0/src/crucible/scoring/topology.py +73 -0
  82. crucible_forge-0.1.0/src/crucible/structural/__init__.py +49 -0
  83. crucible_forge-0.1.0/src/crucible/structural/_strict_schema.py +283 -0
  84. crucible_forge-0.1.0/src/crucible/structural/duplicate_order.py +54 -0
  85. crucible_forge-0.1.0/src/crucible/structural/entity_count_check.py +157 -0
  86. crucible_forge-0.1.0/src/crucible/structural/format.py +78 -0
  87. crucible_forge-0.1.0/src/crucible/structural/presence.py +41 -0
  88. crucible_forge-0.1.0/src/crucible/structural/version_resolver.py +17 -0
  89. crucible_forge-0.1.0/src/crucible/types/__init__.py +112 -0
  90. crucible_forge-0.1.0/src/crucible/types/_base.py +30 -0
  91. crucible_forge-0.1.0/src/crucible/types/cascade.py +20 -0
  92. crucible_forge-0.1.0/src/crucible/types/config.py +36 -0
  93. crucible_forge-0.1.0/src/crucible/types/context.py +30 -0
  94. crucible_forge-0.1.0/src/crucible/types/enums.py +42 -0
  95. crucible_forge-0.1.0/src/crucible/types/finding.py +49 -0
  96. crucible_forge-0.1.0/src/crucible/types/guidance.py +41 -0
  97. crucible_forge-0.1.0/src/crucible/types/operations.py +31 -0
  98. crucible_forge-0.1.0/src/crucible/types/phase.py +33 -0
  99. crucible_forge-0.1.0/src/crucible/types/result.py +170 -0
  100. crucible_forge-0.1.0/src/crucible/types/rubric.py +48 -0
  101. crucible_forge-0.1.0/src/crucible/types/scope.py +40 -0
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+ *.so
9
+
10
+ # Virtual envs / tooling
11
+ .venv/
12
+ venv/
13
+ .env
14
+
15
+ # Test / type caches
16
+ .pytest_cache/
17
+ .mypy_cache/
18
+ .ruff_cache/
19
+ .hypothesis/
20
+ .coverage
21
+ htmlcov/
22
+ coverage.xml
23
+
24
+ # uv
25
+ uv.lock
26
+
27
+ # Node (only used by tools/gen_golden.mjs)
28
+ node_modules/
29
+
30
+ # Editors / OS
31
+ .idea/
32
+ .vscode/
33
+ .DS_Store
34
+
35
+ # Local-only, maintainer-only material (engine reference, port notes,
36
+ # publishing runbook, and golden-generation scripts with local source paths)
37
+ docs/
38
+ tools/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Gabriel Augusto GonΓ§alves / blacksmithers
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.4
2
+ Name: crucible-forge
3
+ Version: 0.1.0
4
+ Summary: Self-contained, deterministic validation engine for OpenSpec v1.1 specifications (Python port of the SpecForge validator).
5
+ Project-URL: Homepage, https://github.com/blacksmithers/crucible
6
+ Project-URL: Repository, https://github.com/blacksmithers/crucible
7
+ Project-URL: Issues, https://github.com/blacksmithers/crucible/issues
8
+ Author-email: Gabriel Augusto GonΓ§alves <gab.augustog@gmail.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: openspec,rubric,scoring,spec,specsmither,validation
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: pydantic>=2.6
21
+ Requires-Dist: pyyaml>=6.0
22
+ Requires-Dist: typing-extensions>=4.12
23
+ Description-Content-Type: text/markdown
24
+
25
+ <p align="center">
26
+ <img src="assets/crucibleforge-logo.svg" alt="crucible" width="440">
27
+ </p>
28
+
29
+ <p align="center"><i>A self-contained, deterministic validation engine for OpenSpec v1.1 specifications.</i></p>
30
+
31
+ <p align="center">
32
+ <a href="https://github.com/blacksmithers/crucible/actions"><img src="https://github.com/blacksmithers/crucible/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
33
+ <a href="https://pypi.org/project/crucible-forge/"><img src="https://img.shields.io/pypi/v/crucible-forge.svg" alt="PyPI"></a>
34
+ <img src="https://img.shields.io/pypi/pyversions/crucible-forge.svg" alt="Python versions">
35
+ <img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License: Apache 2.0">
36
+ <img src="https://img.shields.io/badge/types-mypy%20strict-blue.svg" alt="mypy strict">
37
+ </p>
38
+
39
+ <p align="center">
40
+ <code>pip install crucible-forge</code> &nbsp;β€’&nbsp; <code>import crucible</code>
41
+ </p>
42
+
43
+ ---
44
+
45
+ `crucible` takes a software **specification** (with its epics and tickets), scores
46
+ it against a fixed, configurable rubric, and reports a **readiness gate** β€” with
47
+ **no LLM, fully deterministic**. Same input, same score, every time.
48
+
49
+ It is a faithful Python port of the SpecForge `@specforge/validator` engine,
50
+ extracted as a standalone library, and is the **planning gate** of
51
+ [SpecSmither](https://github.com/blacksmithers/specsmither). The output is
52
+ **byte-equivalent to the reference TypeScript engine**, verified by differential
53
+ tests across every phase and output layer.
54
+
55
+ ## Why
56
+
57
+ - 🎯 **Deterministic** β€” pure scoring, no model calls. Reproducible in CI.
58
+ - πŸ“¦ **Self-contained** β€” pure Python; only `pydantic` and `pyyaml` at runtime.
59
+ - πŸ”¬ **Faithful** β€” output matches the reference TS validator (differential-tested).
60
+ - 🎚️ **Configurable** β€” every threshold, tier weight, and check lives in config.
61
+ - 🏷️ **Typed** β€” ships `py.typed`; passes `mypy --strict`.
62
+
63
+ ## Install
64
+
65
+ ```bash
66
+ pip install crucible-forge # β†’ import crucible
67
+ # or
68
+ uv add crucible-forge
69
+ ```
70
+
71
+ Requires Python β‰₯ 3.11.
72
+
73
+ ## Quick start
74
+
75
+ ```python
76
+ from crucible import validate, load_defaults
77
+
78
+ result = validate(spec, {
79
+ "phase": "planning_spec",
80
+ "config": load_defaults(), # optional β€” loaded by default
81
+ "returns": ["structural", "scoring", "guidance"],
82
+ })
83
+
84
+ if result.scoring and not result.scoring.skipped:
85
+ print(result.scoring.gate_result) # 'pass' | 'fail'
86
+ print(result.scoring.local_score) # e.g. 86.11
87
+ print(result.passed) # overall gate for the phase
88
+
89
+ # Canonical camelCase JSON (matches the reference engine):
90
+ result.to_json_dict()
91
+ ```
92
+
93
+ `spec` may be a `crucible.Specification` model **or** a plain `dict` (camelCase,
94
+ the OpenSpec v1.1 shape). The `context` accepts the original keys
95
+ (`phase`, `activeEntityId`, `config`, `returns`) or their snake_case forms.
96
+
97
+ ## The model
98
+
99
+ A spec is a hierarchy:
100
+
101
+ ```
102
+ Specification β†’ Epic β†’ Ticket (+ acceptance criteria, impl steps, tests, files, dependencies)
103
+ β†˜ ticket dependency DAG ↙
104
+ ```
105
+
106
+ `validate()` walks this tree and produces up to four **output layers**:
107
+
108
+ | layer | what it reports |
109
+ |---|---|
110
+ | `structural` | schema issues β€” missing fields, format violations, duplicate orders, entity counts |
111
+ | `scoring` | the readiness score + gate (rubric tiers, weighted blocks, topology penalties, cascade floors) |
112
+ | `crossValidation` | cross-entity consistency β€” cycles, orphan/island tickets, file conflicts, wave coordination, blueprint coverage |
113
+ | `guidance` | human-readable, prioritized fix suggestions composed from the above |
114
+
115
+ Request the layers you want via `returns`; a single phase returns whatever it
116
+ computes, and `phase: "all"` defaults to `["scoring"]`.
117
+
118
+ ## Phases
119
+
120
+ `validate()` is driven by `context["phase"]`:
121
+
122
+ | phase | scope | needs `activeEntityId` |
123
+ |---|---|:---:|
124
+ | `planning_spec` | spec-level fields | |
125
+ | `epic_decomposition` | spec + the epic list | |
126
+ | `epic_expansion` | one epic's fields | βœ“ |
127
+ | `ticket_decomposition` | tickets under one epic | |
128
+ | `ticket_expansion` | one ticket's fields | βœ“ |
129
+ | `cross_validation` | full-tree consistency checks | |
130
+ | `all` | every phase, keyed under `by_phase` | |
131
+
132
+ ```python
133
+ # Summative gate over the whole tree:
134
+ allr = validate(spec, {"phase": "all", "returns": ["scoring", "crossValidation"]})
135
+ planning_passed = (
136
+ allr.by_phase["planning_spec"].scoring
137
+ and allr.by_phase["planning_spec"].scoring.gate_result == "pass"
138
+ )
139
+ ```
140
+
141
+ ## Structural-only
142
+
143
+ When you just need the schema check (no scoring/guidance):
144
+
145
+ ```python
146
+ from crucible import validate_structural, load_defaults
147
+
148
+ res = validate_structural(spec, load_defaults(), "planning_spec")
149
+ if not res.missing_fields and not res.invalid_fields:
150
+ ... # schema-clean
151
+ ```
152
+
153
+ ## Configuration
154
+
155
+ Every gate is config-driven. `load_defaults()` returns the packaged
156
+ `ValidatorConfig` (thresholds, tier weights, the 53-entry rubric thresholds,
157
+ topology penalties, cross-validation rules). Layer overrides with `merge_config`:
158
+
159
+ ```python
160
+ from crucible import load_defaults, merge_config
161
+
162
+ config = merge_config(load_defaults(), {"thresholds": {"global": 85}})
163
+ ```
164
+
165
+ The scoring rubric (53 entries: 16 spec Β· 17 epic Β· 20 ticket) ships as a data
166
+ asset at `crucible/guidance/rubric/data/rubric.json`, generated verbatim from the
167
+ reference source.
168
+
169
+ ## Public API
170
+
171
+ ```python
172
+ from crucible import (
173
+ validate, validate_structural, # entry points
174
+ load_defaults, load_from_file, # config loading
175
+ load_partial_from_file, merge_config,
176
+ CONFIG_DEFAULTS, ValidatorConfigSchema,
177
+ PlanningConfigResolver, # project/spec config resolution
178
+ ValidatorInputError, # raised on bad context
179
+ Specification, Epic, Ticket, Blueprint, # OpenSpec models
180
+ models, types, # full model + result namespaces
181
+ )
182
+ ```
183
+
184
+ ## Development
185
+
186
+ ```bash
187
+ uv sync --all-extras --dev
188
+ uv run ruff check src tests
189
+ uv run mypy
190
+ uv run pytest # 125 tests, incl. differential vs the TS engine
191
+ ```
192
+
193
+ Fidelity is verified against committed golden output captured from the reference
194
+ engine, so CI needs no extra tooling.
195
+
196
+ ## Status
197
+
198
+ `0.1.0` β€” a **complete** port, **verified byte-for-byte against the current TS
199
+ validator** across every phase and all four output layers (structural Β· scoring
200
+ Β· crossValidation Β· guidance).
201
+
202
+ ## License
203
+
204
+ Apache 2.0 Β© Gabriel Augusto GonΓ§alves / blacksmithers
@@ -0,0 +1,180 @@
1
+ <p align="center">
2
+ <img src="assets/crucibleforge-logo.svg" alt="crucible" width="440">
3
+ </p>
4
+
5
+ <p align="center"><i>A self-contained, deterministic validation engine for OpenSpec v1.1 specifications.</i></p>
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/blacksmithers/crucible/actions"><img src="https://github.com/blacksmithers/crucible/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
9
+ <a href="https://pypi.org/project/crucible-forge/"><img src="https://img.shields.io/pypi/v/crucible-forge.svg" alt="PyPI"></a>
10
+ <img src="https://img.shields.io/pypi/pyversions/crucible-forge.svg" alt="Python versions">
11
+ <img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License: Apache 2.0">
12
+ <img src="https://img.shields.io/badge/types-mypy%20strict-blue.svg" alt="mypy strict">
13
+ </p>
14
+
15
+ <p align="center">
16
+ <code>pip install crucible-forge</code> &nbsp;β€’&nbsp; <code>import crucible</code>
17
+ </p>
18
+
19
+ ---
20
+
21
+ `crucible` takes a software **specification** (with its epics and tickets), scores
22
+ it against a fixed, configurable rubric, and reports a **readiness gate** β€” with
23
+ **no LLM, fully deterministic**. Same input, same score, every time.
24
+
25
+ It is a faithful Python port of the SpecForge `@specforge/validator` engine,
26
+ extracted as a standalone library, and is the **planning gate** of
27
+ [SpecSmither](https://github.com/blacksmithers/specsmither). The output is
28
+ **byte-equivalent to the reference TypeScript engine**, verified by differential
29
+ tests across every phase and output layer.
30
+
31
+ ## Why
32
+
33
+ - 🎯 **Deterministic** β€” pure scoring, no model calls. Reproducible in CI.
34
+ - πŸ“¦ **Self-contained** β€” pure Python; only `pydantic` and `pyyaml` at runtime.
35
+ - πŸ”¬ **Faithful** β€” output matches the reference TS validator (differential-tested).
36
+ - 🎚️ **Configurable** β€” every threshold, tier weight, and check lives in config.
37
+ - 🏷️ **Typed** β€” ships `py.typed`; passes `mypy --strict`.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install crucible-forge # β†’ import crucible
43
+ # or
44
+ uv add crucible-forge
45
+ ```
46
+
47
+ Requires Python β‰₯ 3.11.
48
+
49
+ ## Quick start
50
+
51
+ ```python
52
+ from crucible import validate, load_defaults
53
+
54
+ result = validate(spec, {
55
+ "phase": "planning_spec",
56
+ "config": load_defaults(), # optional β€” loaded by default
57
+ "returns": ["structural", "scoring", "guidance"],
58
+ })
59
+
60
+ if result.scoring and not result.scoring.skipped:
61
+ print(result.scoring.gate_result) # 'pass' | 'fail'
62
+ print(result.scoring.local_score) # e.g. 86.11
63
+ print(result.passed) # overall gate for the phase
64
+
65
+ # Canonical camelCase JSON (matches the reference engine):
66
+ result.to_json_dict()
67
+ ```
68
+
69
+ `spec` may be a `crucible.Specification` model **or** a plain `dict` (camelCase,
70
+ the OpenSpec v1.1 shape). The `context` accepts the original keys
71
+ (`phase`, `activeEntityId`, `config`, `returns`) or their snake_case forms.
72
+
73
+ ## The model
74
+
75
+ A spec is a hierarchy:
76
+
77
+ ```
78
+ Specification β†’ Epic β†’ Ticket (+ acceptance criteria, impl steps, tests, files, dependencies)
79
+ β†˜ ticket dependency DAG ↙
80
+ ```
81
+
82
+ `validate()` walks this tree and produces up to four **output layers**:
83
+
84
+ | layer | what it reports |
85
+ |---|---|
86
+ | `structural` | schema issues β€” missing fields, format violations, duplicate orders, entity counts |
87
+ | `scoring` | the readiness score + gate (rubric tiers, weighted blocks, topology penalties, cascade floors) |
88
+ | `crossValidation` | cross-entity consistency β€” cycles, orphan/island tickets, file conflicts, wave coordination, blueprint coverage |
89
+ | `guidance` | human-readable, prioritized fix suggestions composed from the above |
90
+
91
+ Request the layers you want via `returns`; a single phase returns whatever it
92
+ computes, and `phase: "all"` defaults to `["scoring"]`.
93
+
94
+ ## Phases
95
+
96
+ `validate()` is driven by `context["phase"]`:
97
+
98
+ | phase | scope | needs `activeEntityId` |
99
+ |---|---|:---:|
100
+ | `planning_spec` | spec-level fields | |
101
+ | `epic_decomposition` | spec + the epic list | |
102
+ | `epic_expansion` | one epic's fields | βœ“ |
103
+ | `ticket_decomposition` | tickets under one epic | |
104
+ | `ticket_expansion` | one ticket's fields | βœ“ |
105
+ | `cross_validation` | full-tree consistency checks | |
106
+ | `all` | every phase, keyed under `by_phase` | |
107
+
108
+ ```python
109
+ # Summative gate over the whole tree:
110
+ allr = validate(spec, {"phase": "all", "returns": ["scoring", "crossValidation"]})
111
+ planning_passed = (
112
+ allr.by_phase["planning_spec"].scoring
113
+ and allr.by_phase["planning_spec"].scoring.gate_result == "pass"
114
+ )
115
+ ```
116
+
117
+ ## Structural-only
118
+
119
+ When you just need the schema check (no scoring/guidance):
120
+
121
+ ```python
122
+ from crucible import validate_structural, load_defaults
123
+
124
+ res = validate_structural(spec, load_defaults(), "planning_spec")
125
+ if not res.missing_fields and not res.invalid_fields:
126
+ ... # schema-clean
127
+ ```
128
+
129
+ ## Configuration
130
+
131
+ Every gate is config-driven. `load_defaults()` returns the packaged
132
+ `ValidatorConfig` (thresholds, tier weights, the 53-entry rubric thresholds,
133
+ topology penalties, cross-validation rules). Layer overrides with `merge_config`:
134
+
135
+ ```python
136
+ from crucible import load_defaults, merge_config
137
+
138
+ config = merge_config(load_defaults(), {"thresholds": {"global": 85}})
139
+ ```
140
+
141
+ The scoring rubric (53 entries: 16 spec Β· 17 epic Β· 20 ticket) ships as a data
142
+ asset at `crucible/guidance/rubric/data/rubric.json`, generated verbatim from the
143
+ reference source.
144
+
145
+ ## Public API
146
+
147
+ ```python
148
+ from crucible import (
149
+ validate, validate_structural, # entry points
150
+ load_defaults, load_from_file, # config loading
151
+ load_partial_from_file, merge_config,
152
+ CONFIG_DEFAULTS, ValidatorConfigSchema,
153
+ PlanningConfigResolver, # project/spec config resolution
154
+ ValidatorInputError, # raised on bad context
155
+ Specification, Epic, Ticket, Blueprint, # OpenSpec models
156
+ models, types, # full model + result namespaces
157
+ )
158
+ ```
159
+
160
+ ## Development
161
+
162
+ ```bash
163
+ uv sync --all-extras --dev
164
+ uv run ruff check src tests
165
+ uv run mypy
166
+ uv run pytest # 125 tests, incl. differential vs the TS engine
167
+ ```
168
+
169
+ Fidelity is verified against committed golden output captured from the reference
170
+ engine, so CI needs no extra tooling.
171
+
172
+ ## Status
173
+
174
+ `0.1.0` β€” a **complete** port, **verified byte-for-byte against the current TS
175
+ validator** across every phase and all four output layers (structural Β· scoring
176
+ Β· crossValidation Β· guidance).
177
+
178
+ ## License
179
+
180
+ Apache 2.0 Β© Gabriel Augusto GonΓ§alves / blacksmithers