# Engineering Rules ## Startup Tools - On startup, procure the latest version of each required CRAP, mutation, and DRY tool for the project language directly from the listed `github.com/unclebob/...` repositories and get each one ready to run. - Resolve each listed repository at its latest available upstream version before installing or building it. - Do not rely on stale cached, vendored, or preinstalled copies when a fresh GitHub install/build is possible in the current environment. - Language tool table: - Go: install with `go install`; mutation `github.com/unclebob/mutate4go`, CRAP `github.com/unclebob/crap4go`, DRY `github.com/unclebob/dry4go`. - Clojure: install with Clojure CLI/deps.edn; mutation `github.com/unclebob/clj-mutate`, CRAP `github.com/unclebob/crap4clj`, DRY `github.com/unclebob/dry4clj`. - Java: install with Maven (`mvn`); mutation `github.com/unclebob/mutate4java`, CRAP `github.com/unclebob/crap4java`, DRY `github.com/unclebob/dry4java`. ## Language Defaults - For Clojure projects, prefer Babashka where possible. - For Clojure or Babashka projects, write Speclj specs, not `clojure.test`. - Install Speclj with `swarm_tool.sh require speclj`. If missing, `swarm_tool.sh ensure speclj`. - If a Speclj spec file changed, run `swarm_tool.sh require speclj-structure-check` (ensure if missing) and check the spec file before running tests. - For Java projects, avoid using Maven to run tests; build dedicated test runners and run those instead. ## Design And Testability - Work in small, reviewable increments. - Prefer the simplest design that supports the current behavior and leaves clear options for the next step. - Keep tests close to the behavior being changed. - Separate testable modules from environmentally unsuitable modules that open GUIs, depend on external devices, throw environment errors, emit system errors, or hang under automated tests. Maximize testable code and minimize the unsuitable boundary. - IO-near modules must not reimplement a domain question. If a high-level module already answers it, call that module and translate the result. Walking the same facts again is a defect even when the dependency arrow already points inward. - Only testable modules should participate in tools that run tests, including unit tests, acceptance tests, coverage, mutation testing, CRAP analysis, DRY analysis that invokes tests, and property tests. - Keep property tests separate from normal verification. Do not include property-test tags in normal unit coverage, Gherkin acceptance mutation, language mutation tools, CRAP, or coverage commands unless the role owns property-test verification or the user explicitly asks for property tests. ## Acceptance Pipeline - Use github.com/unclebob/Acceptance-Pipeline-Specification for Gherkin acceptance tests. - The Acceptance Pipeline Specification supplies `gherkin-parser`, `ir-dry-checker`, and `gherkin-mutator`. Install them with the project-local helper; do not search `$HOME` or run `find` for binaries. - At Tool Startup, for each required APS tool, run `swarm_tool.sh require `. If it is missing, run exactly `swarm_tool.sh ensure `. - Two-arg forms: - `gherkin-parser ./tmp/.json` - `ir-dry-checker ./tmp/.dry.json` - Prefer the Babashka APS tools for `gherkin-parser`, `ir-dry-checker`, `gherkin-mutator`, and related APS support commands. - Use Go-based APS tools only if the Babashka APS tools do not work in the current project environment. - Project-specific acceptance pipeline components are the acceptance entrypoint generator, acceptance runtime, project step handlers, runner adapter, and convenience scripts. - Gherkin acceptance mutation means running `gherkin-mutator` to mutate Gherkin example values. - Gherkin acceptance mutation runs must report periodic progress/status so agents can distinguish normal long-running work from a hang. ## Verification - Before running language, build, or test commands, prefer project-local cache/configuration paths inside the assigned worktree. Avoid default cache locations that write outside the project and may trigger sandbox or permission restrictions. - Run constitution tools one at a time. Do not run CRAP, DRY, coverage, language mutation, Gherkin mutation, or structure-check concurrently. - Tools that take a worker limit must use `--max-workers 4` or `--workers 4`. - Function mutation is differential against the source manifest. Do not pass `--mutate-all`. - Scan changed and new source files with the language mutation tool's scan/count mode as a hint that a module may mix jobs. Split a source file when it has more than one job. Do not split a one-job module to chase a mutation-site count. Preserve mutation manifests across the split; do not hand-edit them. - Gherkin mutation is differential against the feature manifest (`--level hard`). Do not pass `--level full`. - Run acceptance generation and acceptance tests sequentially. - Avoid running whole-suite language test commands concurrently with acceptance generation. - Run the relevant local verification command before handoff whenever the project has one. ## Guardrails - Do not invent project-local CRAP, DRY, mutation, or coverage proxies. Install and run the constitution tools (`crap4clj` with cloverage, `dry4clj`, `clj-mutate`, speclj, or the language table). Do not treat a homegrown `bb crap` / `bb coverage` / `bb mutation-count` task as those tools. - Do not edit mutation testing or Gherkin acceptance mutation manifests by hand; allow approved mutation tools to update those manifests as part of their normal runs. - Do not commit unrelated local changes or generated artifacts unless required for the task. - Before relying on an unfamiliar command, inspect local help or project documentation.