specfuse-loop 0.2.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 (89) hide show
  1. specfuse_loop-0.2.0/LICENSE +201 -0
  2. specfuse_loop-0.2.0/NOTICE +6 -0
  3. specfuse_loop-0.2.0/PKG-INFO +192 -0
  4. specfuse_loop-0.2.0/README.md +163 -0
  5. specfuse_loop-0.2.0/pyproject.toml +63 -0
  6. specfuse_loop-0.2.0/setup.cfg +4 -0
  7. specfuse_loop-0.2.0/specfuse/loop/__init__.py +5 -0
  8. specfuse_loop-0.2.0/specfuse/loop/_miniyaml.py +466 -0
  9. specfuse_loop-0.2.0/specfuse/loop/adopt_feature.py +217 -0
  10. specfuse_loop-0.2.0/specfuse/loop/gate_eval.py +503 -0
  11. specfuse_loop-0.2.0/specfuse/loop/gh_backend.py +82 -0
  12. specfuse_loop-0.2.0/specfuse/loop/gh_features.py +98 -0
  13. specfuse_loop-0.2.0/specfuse/loop/lint_plan.py +616 -0
  14. specfuse_loop-0.2.0/specfuse/loop/loop.py +3504 -0
  15. specfuse_loop-0.2.0/specfuse/loop/validate_event.py +282 -0
  16. specfuse_loop-0.2.0/specfuse_loop.egg-info/PKG-INFO +192 -0
  17. specfuse_loop-0.2.0/specfuse_loop.egg-info/SOURCES.txt +87 -0
  18. specfuse_loop-0.2.0/specfuse_loop.egg-info/dependency_links.txt +1 -0
  19. specfuse_loop-0.2.0/specfuse_loop.egg-info/entry_points.txt +3 -0
  20. specfuse_loop-0.2.0/specfuse_loop.egg-info/requires.txt +7 -0
  21. specfuse_loop-0.2.0/specfuse_loop.egg-info/top_level.txt +1 -0
  22. specfuse_loop-0.2.0/tests/test_adopt_feature.py +260 -0
  23. specfuse_loop-0.2.0/tests/test_attempt_outcome_emission.py +615 -0
  24. specfuse_loop-0.2.0/tests/test_backend.py +270 -0
  25. specfuse_loop-0.2.0/tests/test_bookkeeping_commit_hook_crash.py +104 -0
  26. specfuse_loop-0.2.0/tests/test_closing_deliverable_guard.py +918 -0
  27. specfuse_loop-0.2.0/tests/test_cost_tracking.py +284 -0
  28. specfuse_loop-0.2.0/tests/test_deliverable_presence_gate.py +409 -0
  29. specfuse_loop-0.2.0/tests/test_driver_integration.py +314 -0
  30. specfuse_loop-0.2.0/tests/test_driver_lock.py +49 -0
  31. specfuse_loop-0.2.0/tests/test_duration_tracking.py +215 -0
  32. specfuse_loop-0.2.0/tests/test_empty_files_escalation.py +316 -0
  33. specfuse_loop-0.2.0/tests/test_ensure_feature_branch.py +191 -0
  34. specfuse_loop-0.2.0/tests/test_extra_gates.py +143 -0
  35. specfuse_loop-0.2.0/tests/test_force_full_close.py +342 -0
  36. specfuse_loop-0.2.0/tests/test_gate_eval.py +689 -0
  37. specfuse_loop-0.2.0/tests/test_gate_eval_calibration.py +299 -0
  38. specfuse_loop-0.2.0/tests/test_gate_eval_intermediate_wiring.py +787 -0
  39. specfuse_loop-0.2.0/tests/test_gate_eval_terminal_wiring.py +313 -0
  40. specfuse_loop-0.2.0/tests/test_gh_backend.py +150 -0
  41. specfuse_loop-0.2.0/tests/test_gh_features.py +231 -0
  42. specfuse_loop-0.2.0/tests/test_git_env_isolation.py +85 -0
  43. specfuse_loop-0.2.0/tests/test_hashed_denylist.py +161 -0
  44. specfuse_loop-0.2.0/tests/test_hashed_denylist_ci.py +194 -0
  45. specfuse_loop-0.2.0/tests/test_leak_scan.py +430 -0
  46. specfuse_loop-0.2.0/tests/test_leak_scan_content.py +136 -0
  47. specfuse_loop-0.2.0/tests/test_legacy_4wu_terminal_flips.py +196 -0
  48. specfuse_loop-0.2.0/tests/test_lifecycle_integration.py +464 -0
  49. specfuse_loop-0.2.0/tests/test_lint_close_intermediate.py +402 -0
  50. specfuse_loop-0.2.0/tests/test_lint_close_wu.py +142 -0
  51. specfuse_loop-0.2.0/tests/test_lint_correlation_id.py +217 -0
  52. specfuse_loop-0.2.0/tests/test_lint_correlation_id_close_intermediate.py +41 -0
  53. specfuse_loop-0.2.0/tests/test_lint_oracle_env.py +192 -0
  54. specfuse_loop-0.2.0/tests/test_lint_plan_errors.py +240 -0
  55. specfuse_loop-0.2.0/tests/test_lint_plan_next_draft.py +277 -0
  56. specfuse_loop-0.2.0/tests/test_lint_produces_driver_helper.py +299 -0
  57. specfuse_loop-0.2.0/tests/test_lint_sections.py +112 -0
  58. specfuse_loop-0.2.0/tests/test_lint_task_graph_yaml_selection.py +140 -0
  59. specfuse_loop-0.2.0/tests/test_loop_auto_archive.py +207 -0
  60. specfuse_loop-0.2.0/tests/test_loop_caveman_preamble.py +58 -0
  61. specfuse_loop-0.2.0/tests/test_loop_close_intermediate.py +56 -0
  62. specfuse_loop-0.2.0/tests/test_loop_defaults_by_type.py +159 -0
  63. specfuse_loop-0.2.0/tests/test_loop_effort.py +94 -0
  64. specfuse_loop-0.2.0/tests/test_loop_failure_note_cap.py +35 -0
  65. specfuse_loop-0.2.0/tests/test_loop_files_changed_guard.py +495 -0
  66. specfuse_loop-0.2.0/tests/test_loop_gate_budget.py +293 -0
  67. specfuse_loop-0.2.0/tests/test_loop_model_alias.py +200 -0
  68. specfuse_loop-0.2.0/tests/test_loop_orchestration.py +853 -0
  69. specfuse_loop-0.2.0/tests/test_loop_post_pass_invariant.py +316 -0
  70. specfuse_loop-0.2.0/tests/test_loop_reset_preserving_events.py +142 -0
  71. specfuse_loop-0.2.0/tests/test_loop_smoke_runner.py +390 -0
  72. specfuse_loop-0.2.0/tests/test_loop_unsandboxed.py +166 -0
  73. specfuse_loop-0.2.0/tests/test_loop_zero_token_guard.py +277 -0
  74. specfuse_loop-0.2.0/tests/test_miniyaml_equivalence.py +205 -0
  75. specfuse_loop-0.2.0/tests/test_miniyaml_negative.py +334 -0
  76. specfuse_loop-0.2.0/tests/test_planned_cost_lint.py +218 -0
  77. specfuse_loop-0.2.0/tests/test_produces_field.py +206 -0
  78. specfuse_loop-0.2.0/tests/test_result_block.py +267 -0
  79. specfuse_loop-0.2.0/tests/test_roadmap_add_skill.py +535 -0
  80. specfuse_loop-0.2.0/tests/test_roadmap_archive_skill.py +244 -0
  81. specfuse_loop-0.2.0/tests/test_roadmap_row_parser.py +193 -0
  82. specfuse_loop-0.2.0/tests/test_squash_commit_hook_crash.py +99 -0
  83. specfuse_loop-0.2.0/tests/test_template_closing_shapes.py +117 -0
  84. specfuse_loop-0.2.0/tests/test_terminal_flip_ownership.py +215 -0
  85. specfuse_loop-0.2.0/tests/test_terminal_flips.py +360 -0
  86. specfuse_loop-0.2.0/tests/test_validate_event.py +700 -0
  87. specfuse_loop-0.2.0/tests/test_verdict_coupling.py +325 -0
  88. specfuse_loop-0.2.0/tests/test_verify_empty_gate_set.py +102 -0
  89. specfuse_loop-0.2.0/tests/test_version_skew.py +95 -0
@@ -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 Derivative
95
+ 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 [yyyy] [name of copyright owner]
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,6 @@
1
+ Specfuse Loop
2
+ Copyright 2026 Specfuse contributors
3
+
4
+ This product is part of the Specfuse methodology suite
5
+ (https://github.com/specfuse). It is licensed under the Apache License,
6
+ Version 2.0. See the LICENSE file for the full text.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: specfuse-loop
3
+ Version: 0.2.0
4
+ Summary: Local-first executor for the Specfuse Plan + Work Unit gate-cycle methodology.
5
+ Author: Specfuse contributors
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/specfuse/loop
8
+ Project-URL: Source, https://github.com/specfuse/loop
9
+ Keywords: specfuse,agents,planning,ralph,gate-cycle
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Topic :: Software Development
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: NOTICE
22
+ Provides-Extra: dev
23
+ Requires-Dist: PyYAML>=6.0; extra == "dev"
24
+ Requires-Dist: ruff>=0.6; extra == "dev"
25
+ Requires-Dist: bandit>=1.7; extra == "dev"
26
+ Requires-Dist: coverage>=7.0; extra == "dev"
27
+ Requires-Dist: jsonschema>=4.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # Specfuse Loop
31
+
32
+ **For engineers using AI coding agents** — a local-first driver that structures features as verified, work-unit sequences so each agent session runs focused on one task instead of accumulating context drift.
33
+
34
+ A small, local-first executor for the **Plan + Work Unit** pattern in a single
35
+ repository. You plan a feature as a sequence of *gates*, each a batch of
36
+ self-contained *work units* with explicit acceptance criteria and verification.
37
+ The loop dispatches each work unit to a fresh agent session, verifies the result
38
+ itself, commits one squashed commit per unit, and stops at each gate so you can
39
+ reflect — with the next gate already drafted and waiting for your review.
40
+
41
+ Specfuse Loop is one of three independently-adoptable projects under the Specfuse
42
+ methodology suite:
43
+
44
+ - **`specfuse/codegen`** — deterministic source code from OpenAPI / AsyncAPI /
45
+ Arazzo specifications.
46
+ - **`specfuse/loop`** — *this project*. Single-repo, spec-optional, lightweight.
47
+ You author the task graph directly; no specification and no agent-coordination
48
+ overhead are required.
49
+ - **`specfuse/orchestrator`** — multi-repo, spec-first, agent coordination across
50
+ many component repositories.
51
+
52
+ Use any one without the others. The loop and the orchestrator share the same
53
+ gate-cycle methodology (see [`docs/methodology.md`](docs/methodology.md)); the
54
+ loop is the lightweight surface for work that lives in one repo and may have no
55
+ formal specification.
56
+
57
+ ## Why it exists
58
+
59
+ AI coding agents do well on narrow, well-scoped work and poorly on large, vague
60
+ work. The loop's bet is that the leverage is in the *planning*: if you remove
61
+ ambiguity up front — crisp work units with hard boundaries and machine-checkable
62
+ verification — then execution can run with a fresh agent per unit, re-grounding
63
+ from durable files each time rather than accumulating context drift. It is the
64
+ [Ralph loop](docs/concepts/ralph-lineage.md) idea applied at work-unit granularity, with
65
+ the planning rigor Ralph's bare task list lacks.
66
+
67
+ ## How it works (in one minute)
68
+
69
+ - A **feature** lives in `.specfuse/features/FEAT-YYYY-NNNN-slug/`, with a
70
+ `PLAN.md` (the task graph: gate order, work-unit membership, dependencies),
71
+ one `GATE-NN.md` per gate, and one `WU-*.md` per work unit (frontmatter + the
72
+ prompt body a fresh session receives). The loop also handles *orchestrated*
73
+ features dispatched by the Specfuse Orchestrator, identified by
74
+ `INIT-YYYY-NNNN/FNN` IDs — the loop treats both namespaces identically; only
75
+ the ID root differs. Use `.specfuse/scripts/gh_features.py` to discover a
76
+ target repo's open `specfuse:feature` issues as feature candidates; use
77
+ `.specfuse/scripts/adopt_feature.py <repo> <issue-number>` (or the
78
+ interactive `/adopt-feature` skill) to scaffold a dispatchable feature
79
+ folder from a picked issue.
80
+ - The **driver** (`.specfuse/scripts/loop.py`) walks the current gate's ready
81
+ work units, dispatches each as a fresh `claude -p` session, runs the unit's
82
+ verification itself as the exit oracle, and commits one squashed,
83
+ trailer-carrying commit per unit. A failed gate is retried with a fresh
84
+ session carrying the failure evidence, up to three attempts, then escalated.
85
+ - Each gate ends with a **closing sequence** so reflection, a durable
86
+ cross-feature `LEARNINGS.md`, documentation, and *drafting the next gate* all
87
+ happen systematically. Non-terminal gates use a two-WU form
88
+ (`close-intermediate` + `plan-next`); the terminal gate uses a single `close`
89
+ WU. A legacy four-WU form (`retrospective → lessons → docs → plan-next`) is
90
+ accepted but emits a lint warning.
91
+ - The gate is the **human boundary.** The driver runs unattended within a gate
92
+ and stops at it; you review the next gate's draft and arm it. (Under automatic
93
+ mode, safe gates can self-arm; the dangerous edges always pull you back in —
94
+ see the methodology doc.)
95
+
96
+ ## Quickstart
97
+
98
+ In a target single-repo project:
99
+
100
+ **Contributing to this repo?** Run `./scripts/install-hooks.sh` once after
101
+ cloning to enable the pre-push hook (runs `scripts/smoke-test.sh` — same
102
+ checks CI runs — before each `git push`). Bypass with `git push --no-verify`.
103
+
104
+ The driver installs from PyPI and the skills from the Claude Code marketplace:
105
+
106
+ ```bash
107
+ pip install specfuse-loop # the driver: `specfuse-loop` on PATH
108
+ # in Claude Code: skills under the /specfuse: namespace
109
+ # /plugin marketplace add specfuse/specfuse
110
+ # /plugin install specfuse@specfuse
111
+
112
+ # scaffold a target repo's .specfuse/ state (templates, rules, verification.yml)
113
+ ./init.sh /path/to/your-project # legacy installer (v1.0; removed in v1.1)
114
+
115
+ cd /path/to/your-project
116
+ $EDITOR .specfuse/verification.yml # match the `code` gates to your stack
117
+ # author your first feature folder under .specfuse/features/ from .specfuse/templates/
118
+ specfuse-loop --dry-run # or: python .specfuse/scripts/loop.py --dry-run
119
+ specfuse-loop
120
+ ```
121
+
122
+ > **Distribution (FEAT-2026-0019).** Code ships via pip (`specfuse-loop`), the
123
+ > `specfuse` umbrella CLI bridges pip ↔ plugin (`specfuse upgrade`), and Claude
124
+ > assets ship via the [`specfuse/specfuse`](https://github.com/specfuse/specfuse)
125
+ > marketplace. `init.sh` remains the scaffold bootstrap (laying down `.specfuse/`
126
+ > state) until pip-native scaffolding lands; it prints a deprecation banner.
127
+
128
+ > **One driver per working tree.** The driver holds an exclusive advisory lock on
129
+ > `.specfuse/.loop.lock` for the duration of a run; a second driver targeting the
130
+ > same checkout exits immediately with a clear error message. To run two features
131
+ > in parallel, use separate `git worktree` checkouts — each gets its own lock.
132
+ > `--dry-run` is exempt and may run alongside a live driver.
133
+
134
+ This repository is also a **self-demonstrating reference installation**: its own
135
+ `.specfuse/` contains a worked example feature
136
+ (`features/FEAT-2026-0001-health-endpoint/`). From the repo root you can run:
137
+
138
+ ```bash
139
+ python .specfuse/scripts/lint_plan.py .specfuse/features/FEAT-2026-0001-health-endpoint
140
+ python .specfuse/scripts/loop.py --dry-run
141
+ ```
142
+
143
+ ## Layout
144
+
145
+ ```
146
+ specfuse-loop/
147
+ ├── LICENSE NOTICE CONTRIBUTING.md README.md .gitignore
148
+ ├── init.sh scaffold .specfuse/ into a target repo
149
+ ├── docs/
150
+ │ ├── getting-started.md narrated first-feature + operator walkthrough
151
+ │ ├── methodology.md the gate-cycle contract (shared with the orchestrator)
152
+ │ ├── skills.md the skills catalog, ordered by lifecycle phase
153
+ │ ├── concepts/ why it exists; orchestrator mapping
154
+ │ │ ├── ralph-lineage.md the Ralph / Gas Town lineage
155
+ │ │ └── architecture-addendum-gates-and-iterative-planning.md
156
+ │ └── dev/ internal working notes (not user-facing)
157
+ └── .specfuse/ canonical scaffold + worked example
158
+ ├── README.md
159
+ ├── roadmap.template.md verification.yml.example LEARNINGS.md
160
+ ├── rules/result-contract.md
161
+ ├── skills/verification/SKILL.md
162
+ ├── scripts/{loop.py, lint_plan.py, gh_features.py, adopt_feature.py, gh_backend.py}
163
+ ├── templates/{PLAN,GATE,WU}.template.md
164
+ └── features/FEAT-2026-0001-health-endpoint/ (the worked example)
165
+ ```
166
+
167
+ `init.sh` also ships the durable docs — `methodology.md`, `skills.md`, and
168
+ `concepts/` — into a target's `.specfuse/docs/`, so an initialized repo is
169
+ self-documenting without this checkout.
170
+
171
+ ## Status
172
+
173
+ Early but exercised. The driver, linter, parsing, dependency ordering, draft/arm
174
+ gating, the deterministic auto-close predicate, and verification wiring are all
175
+ tested, and the loop dogfoods itself — its own `.specfuse/features/` holds 20+
176
+ features taken through the full gate cycle, including multi-gate features whose
177
+ forward-design model (each gate's `plan-next` drafts the next) has held across
178
+ four consecutive gates.
179
+
180
+ What works today: single-feature and orchestrator-dispatched features; adopting a
181
+ GitHub `specfuse:feature` issue into a dispatchable folder; GitHub issue-label
182
+ state transitions for adopted features; per-gate auto-close on clean runs with a
183
+ full-ceremony fallback when a gate goes off-plan; and a single-driver working-tree
184
+ lock so two drivers can't corrupt one checkout.
185
+
186
+ Expect rough edges. The interfaces (WU contract, RESULT block, correlation-ID
187
+ scheme, `verification.yml` shape) are stable; tooling around them is still
188
+ hardening.
189
+
190
+ ## License
191
+
192
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,163 @@
1
+ # Specfuse Loop
2
+
3
+ **For engineers using AI coding agents** — a local-first driver that structures features as verified, work-unit sequences so each agent session runs focused on one task instead of accumulating context drift.
4
+
5
+ A small, local-first executor for the **Plan + Work Unit** pattern in a single
6
+ repository. You plan a feature as a sequence of *gates*, each a batch of
7
+ self-contained *work units* with explicit acceptance criteria and verification.
8
+ The loop dispatches each work unit to a fresh agent session, verifies the result
9
+ itself, commits one squashed commit per unit, and stops at each gate so you can
10
+ reflect — with the next gate already drafted and waiting for your review.
11
+
12
+ Specfuse Loop is one of three independently-adoptable projects under the Specfuse
13
+ methodology suite:
14
+
15
+ - **`specfuse/codegen`** — deterministic source code from OpenAPI / AsyncAPI /
16
+ Arazzo specifications.
17
+ - **`specfuse/loop`** — *this project*. Single-repo, spec-optional, lightweight.
18
+ You author the task graph directly; no specification and no agent-coordination
19
+ overhead are required.
20
+ - **`specfuse/orchestrator`** — multi-repo, spec-first, agent coordination across
21
+ many component repositories.
22
+
23
+ Use any one without the others. The loop and the orchestrator share the same
24
+ gate-cycle methodology (see [`docs/methodology.md`](docs/methodology.md)); the
25
+ loop is the lightweight surface for work that lives in one repo and may have no
26
+ formal specification.
27
+
28
+ ## Why it exists
29
+
30
+ AI coding agents do well on narrow, well-scoped work and poorly on large, vague
31
+ work. The loop's bet is that the leverage is in the *planning*: if you remove
32
+ ambiguity up front — crisp work units with hard boundaries and machine-checkable
33
+ verification — then execution can run with a fresh agent per unit, re-grounding
34
+ from durable files each time rather than accumulating context drift. It is the
35
+ [Ralph loop](docs/concepts/ralph-lineage.md) idea applied at work-unit granularity, with
36
+ the planning rigor Ralph's bare task list lacks.
37
+
38
+ ## How it works (in one minute)
39
+
40
+ - A **feature** lives in `.specfuse/features/FEAT-YYYY-NNNN-slug/`, with a
41
+ `PLAN.md` (the task graph: gate order, work-unit membership, dependencies),
42
+ one `GATE-NN.md` per gate, and one `WU-*.md` per work unit (frontmatter + the
43
+ prompt body a fresh session receives). The loop also handles *orchestrated*
44
+ features dispatched by the Specfuse Orchestrator, identified by
45
+ `INIT-YYYY-NNNN/FNN` IDs — the loop treats both namespaces identically; only
46
+ the ID root differs. Use `.specfuse/scripts/gh_features.py` to discover a
47
+ target repo's open `specfuse:feature` issues as feature candidates; use
48
+ `.specfuse/scripts/adopt_feature.py <repo> <issue-number>` (or the
49
+ interactive `/adopt-feature` skill) to scaffold a dispatchable feature
50
+ folder from a picked issue.
51
+ - The **driver** (`.specfuse/scripts/loop.py`) walks the current gate's ready
52
+ work units, dispatches each as a fresh `claude -p` session, runs the unit's
53
+ verification itself as the exit oracle, and commits one squashed,
54
+ trailer-carrying commit per unit. A failed gate is retried with a fresh
55
+ session carrying the failure evidence, up to three attempts, then escalated.
56
+ - Each gate ends with a **closing sequence** so reflection, a durable
57
+ cross-feature `LEARNINGS.md`, documentation, and *drafting the next gate* all
58
+ happen systematically. Non-terminal gates use a two-WU form
59
+ (`close-intermediate` + `plan-next`); the terminal gate uses a single `close`
60
+ WU. A legacy four-WU form (`retrospective → lessons → docs → plan-next`) is
61
+ accepted but emits a lint warning.
62
+ - The gate is the **human boundary.** The driver runs unattended within a gate
63
+ and stops at it; you review the next gate's draft and arm it. (Under automatic
64
+ mode, safe gates can self-arm; the dangerous edges always pull you back in —
65
+ see the methodology doc.)
66
+
67
+ ## Quickstart
68
+
69
+ In a target single-repo project:
70
+
71
+ **Contributing to this repo?** Run `./scripts/install-hooks.sh` once after
72
+ cloning to enable the pre-push hook (runs `scripts/smoke-test.sh` — same
73
+ checks CI runs — before each `git push`). Bypass with `git push --no-verify`.
74
+
75
+ The driver installs from PyPI and the skills from the Claude Code marketplace:
76
+
77
+ ```bash
78
+ pip install specfuse-loop # the driver: `specfuse-loop` on PATH
79
+ # in Claude Code: skills under the /specfuse: namespace
80
+ # /plugin marketplace add specfuse/specfuse
81
+ # /plugin install specfuse@specfuse
82
+
83
+ # scaffold a target repo's .specfuse/ state (templates, rules, verification.yml)
84
+ ./init.sh /path/to/your-project # legacy installer (v1.0; removed in v1.1)
85
+
86
+ cd /path/to/your-project
87
+ $EDITOR .specfuse/verification.yml # match the `code` gates to your stack
88
+ # author your first feature folder under .specfuse/features/ from .specfuse/templates/
89
+ specfuse-loop --dry-run # or: python .specfuse/scripts/loop.py --dry-run
90
+ specfuse-loop
91
+ ```
92
+
93
+ > **Distribution (FEAT-2026-0019).** Code ships via pip (`specfuse-loop`), the
94
+ > `specfuse` umbrella CLI bridges pip ↔ plugin (`specfuse upgrade`), and Claude
95
+ > assets ship via the [`specfuse/specfuse`](https://github.com/specfuse/specfuse)
96
+ > marketplace. `init.sh` remains the scaffold bootstrap (laying down `.specfuse/`
97
+ > state) until pip-native scaffolding lands; it prints a deprecation banner.
98
+
99
+ > **One driver per working tree.** The driver holds an exclusive advisory lock on
100
+ > `.specfuse/.loop.lock` for the duration of a run; a second driver targeting the
101
+ > same checkout exits immediately with a clear error message. To run two features
102
+ > in parallel, use separate `git worktree` checkouts — each gets its own lock.
103
+ > `--dry-run` is exempt and may run alongside a live driver.
104
+
105
+ This repository is also a **self-demonstrating reference installation**: its own
106
+ `.specfuse/` contains a worked example feature
107
+ (`features/FEAT-2026-0001-health-endpoint/`). From the repo root you can run:
108
+
109
+ ```bash
110
+ python .specfuse/scripts/lint_plan.py .specfuse/features/FEAT-2026-0001-health-endpoint
111
+ python .specfuse/scripts/loop.py --dry-run
112
+ ```
113
+
114
+ ## Layout
115
+
116
+ ```
117
+ specfuse-loop/
118
+ ├── LICENSE NOTICE CONTRIBUTING.md README.md .gitignore
119
+ ├── init.sh scaffold .specfuse/ into a target repo
120
+ ├── docs/
121
+ │ ├── getting-started.md narrated first-feature + operator walkthrough
122
+ │ ├── methodology.md the gate-cycle contract (shared with the orchestrator)
123
+ │ ├── skills.md the skills catalog, ordered by lifecycle phase
124
+ │ ├── concepts/ why it exists; orchestrator mapping
125
+ │ │ ├── ralph-lineage.md the Ralph / Gas Town lineage
126
+ │ │ └── architecture-addendum-gates-and-iterative-planning.md
127
+ │ └── dev/ internal working notes (not user-facing)
128
+ └── .specfuse/ canonical scaffold + worked example
129
+ ├── README.md
130
+ ├── roadmap.template.md verification.yml.example LEARNINGS.md
131
+ ├── rules/result-contract.md
132
+ ├── skills/verification/SKILL.md
133
+ ├── scripts/{loop.py, lint_plan.py, gh_features.py, adopt_feature.py, gh_backend.py}
134
+ ├── templates/{PLAN,GATE,WU}.template.md
135
+ └── features/FEAT-2026-0001-health-endpoint/ (the worked example)
136
+ ```
137
+
138
+ `init.sh` also ships the durable docs — `methodology.md`, `skills.md`, and
139
+ `concepts/` — into a target's `.specfuse/docs/`, so an initialized repo is
140
+ self-documenting without this checkout.
141
+
142
+ ## Status
143
+
144
+ Early but exercised. The driver, linter, parsing, dependency ordering, draft/arm
145
+ gating, the deterministic auto-close predicate, and verification wiring are all
146
+ tested, and the loop dogfoods itself — its own `.specfuse/features/` holds 20+
147
+ features taken through the full gate cycle, including multi-gate features whose
148
+ forward-design model (each gate's `plan-next` drafts the next) has held across
149
+ four consecutive gates.
150
+
151
+ What works today: single-feature and orchestrator-dispatched features; adopting a
152
+ GitHub `specfuse:feature` issue into a dispatchable folder; GitHub issue-label
153
+ state transitions for adopted features; per-gate auto-close on clean runs with a
154
+ full-ceremony fallback when a gate goes off-plan; and a single-driver working-tree
155
+ lock so two drivers can't corrupt one checkout.
156
+
157
+ Expect rough edges. The interfaces (WU contract, RESULT block, correlation-ID
158
+ scheme, `verification.yml` shape) are stable; tooling around them is still
159
+ hardening.
160
+
161
+ ## License
162
+
163
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,63 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "specfuse-loop"
7
+ version = "0.2.0"
8
+ description = "Local-first executor for the Specfuse Plan + Work Unit gate-cycle methodology."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [
13
+ { name = "Specfuse contributors" },
14
+ ]
15
+ keywords = ["specfuse", "agents", "planning", "ralph", "gate-cycle"]
16
+ classifiers = [
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Intended Audience :: Developers",
24
+ "Topic :: Software Development",
25
+ ]
26
+ # The loop driver and linter have no runtime dependencies — YAML parsing is
27
+ # done by .specfuse/scripts/_miniyaml.py against the documented subset, using
28
+ # only the Python 3 standard library.
29
+ dependencies = []
30
+
31
+ # Dev tooling for this repo's own `code` gates (see .specfuse/verification.yml
32
+ # and scripts/smoke-test.sh). PyYAML is dev-only: the equivalence tests for
33
+ # _miniyaml compare its output against yaml.safe_load on every real file.
34
+ # ruff/bandit/coverage are for the reference implementation's own gates.
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "PyYAML>=6.0",
38
+ "ruff>=0.6",
39
+ "bandit>=1.7",
40
+ "coverage>=7.0",
41
+ "jsonschema>=4.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/specfuse/loop"
46
+ Source = "https://github.com/specfuse/loop"
47
+
48
+ # Minimal ruff config — keep defaults (E + F). Target the loop's actual
49
+ # minimum Python (matches pyproject's `requires-python`).
50
+ [tool.ruff]
51
+ target-version = "py310"
52
+
53
+ [project.scripts]
54
+ specfuse-loop = "specfuse.loop.loop:main"
55
+ specfuse-lint = "specfuse.loop.lint_plan:main"
56
+
57
+ [tool.setuptools.packages.find]
58
+ # Ship ONLY the specfuse namespace package. Without this scope, setuptools'
59
+ # auto-discovery sweeps tests/, docs/, and scripts/ into the wheel. The driver's
60
+ # data (templates, rules, features) lives in the consumer's `.specfuse/`, not in
61
+ # the wheel, so the package is pure code.
62
+ include = ["specfuse*"]
63
+ namespaces = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ #
2
+ # Copyright 2026 Specfuse Contributors
3
+ # Licensed under the Apache License, Version 2.0. See LICENSE.
4
+ #
5
+ """specfuse.loop — the Specfuse loop driver package."""