|
| 1 | +# RULES — tools and procedures for a development agent |
| 2 | + |
| 3 | +**Generic** rules (valid for any Julia package in the control-toolbox ecosystem, with |
| 4 | +no reference to a specific package's code). They describe *how to work*: run tests, |
| 5 | +build docs, handle git, capture output. For *how to design*, see |
| 6 | +[`philosophy/`](philosophy/PHILOSOPHY.md). |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## 1. Running tests — via the `ct-dev-mcp` MCP server |
| 11 | + |
| 12 | +Do not invent the test command. Use the MCP server that provides it and can parse the |
| 13 | +result. |
| 14 | + |
| 15 | +1. **Get the command**: call the `get_test_command` tool with: |
| 16 | + - `cwd` = package root (where `Project.toml` lives) — **required**; |
| 17 | + - `test_args` = scope (empty = everything; `["test/suite/<group>"]`; a single file; |
| 18 | + a glob `["test/suite/*/*_flow*"]` passed **quoted** — TestRunner expands it, not |
| 19 | + the shell). |
| 20 | +2. **Run** the returned command verbatim. It already includes |
| 21 | + `… 2>&1 | tee /tmp/ct-dev-mcp/<pkg>_<scope>_<id>.log`. |
| 22 | +3. **Analyze**: call `generate_report(<log_file>)` on the returned log for a structured |
| 23 | + Markdown report (summary, first failures, compilation errors). |
| 24 | + |
| 25 | +Rules: |
| 26 | +- **Always `tee` the full log**; never truncate with `tail -N` live — the first error |
| 27 | + (often a compilation error) is usually *above* and would be lost, forcing a rerun. |
| 28 | +- Inspect the saved log afterwards with `grep`/`rg`/`tail`/`less`, without rerunning. |
| 29 | +- Logs go under `/tmp/…`; **never** commit them. |
| 30 | +- Run the **targeted** suite first (fast iteration), then the **full** suite before |
| 31 | + considering a phase done (regression check). |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## 2. Building documentation — "draft first" workflow |
| 36 | + |
| 37 | +`docs/make.jl` exposes a `draft` switch. In **draft mode**, the Julia code in |
| 38 | +`@example`/`@setup` blocks is **not executed**: the build is fast and validates the |
| 39 | +structure, the `@ref`/`@extref` links and the paths. In non-draft mode everything runs |
| 40 | +(slow but actually checks the examples). |
| 41 | + |
| 42 | +```julia |
| 43 | +# docs/make.jl |
| 44 | +draft = true # does not execute Julia cells |
| 45 | +``` |
| 46 | + |
| 47 | +A **single file** can also be forced to non-draft via a meta block, keeping the rest in |
| 48 | +draft — to debug one file quickly: |
| 49 | + |
| 50 | +````markdown |
| 51 | +```@meta |
| 52 | +Draft = false |
| 53 | +``` |
| 54 | +```` |
| 55 | + |
| 56 | +**Recommended procedure**: |
| 57 | + |
| 58 | +1. **`draft = true`** (global) → build once. Fix all broken **links** (`@ref`/`@extref`) |
| 59 | + and paths. Fast. |
| 60 | +2. **File by file**: set one file to `Draft = false` (meta block), rebuild, debug its |
| 61 | + `@example` blocks, fix. Repeat per page. Faster than running everything each time. |
| 62 | +3. **`draft = false`** (global) → final full build, zero execution warnings. |
| 63 | + |
| 64 | +On every build, **`tee`** the output to `/tmp/…` and filter (`grep -E |
| 65 | +"Error|Warning.*failed|MethodError|UndefVar"`). |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 3. Git & commits |
| 70 | + |
| 71 | +- **Never commit or push without explicit user approval.** Even after validated work, |
| 72 | + ask before `git commit`/`git push`. |
| 73 | +- Do not commit on the default branch: branch off the correct base. |
| 74 | +- Interactive flags (`-i`) are not supported in this environment. |
| 75 | +- Prefer the `gh` CLI for GitHub operations (PRs, issues). |
| 76 | +- End commit messages with the required `Co-Authored-By` trailer; end PR bodies with |
| 77 | + the required generation note. |
| 78 | +- Do not commit transient files (`/tmp/*.log`, doc-build artifacts). |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## 4. Editing files |
| 83 | + |
| 84 | +- Prefer the **dedicated tools** (read/edit/write) over `cat`/`sed`/`awk`/`echo` in the |
| 85 | + shell for reading or modifying files. |
| 86 | +- **Read before editing**; do not overwrite a file you have not read. |
| 87 | +- An edit should match the surrounding code (style, naming, comment density). |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## 5. Capturing long output |
| 92 | + |
| 93 | +- Any verbose command (tests, doc build): `… 2>&1 | tee /tmp/<pkg>_<scope>.log`. |
| 94 | +- Name the log by package + scope to avoid collisions between sessions. |
| 95 | +- Filter the log *afterwards*; do not rerun just to get more context. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 6. Ask vs proceed |
| 100 | + |
| 101 | +- **Ask** before any hard-to-reverse or outward-facing action (commit, push, sending to |
| 102 | + an external service, deleting/overwriting files you did not create). |
| 103 | +- **Proceed** on choices with an obvious default (style, conventional location), |
| 104 | + stating it, rather than blocking on a question. |
| 105 | +- Report outcomes faithfully: if tests fail, say so with the output; if a step was |
| 106 | + skipped, say that. |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Quick checklist |
| 111 | + |
| 112 | +- [ ] Tests run via `ct-dev-mcp` (`get_test_command` → run+`tee` → `generate_report`). |
| 113 | +- [ ] Targeted suite green, then full suite green. |
| 114 | +- [ ] Docs built in draft (links OK), then per file, then full. |
| 115 | +- [ ] No git action without explicit approval. |
| 116 | +- [ ] Dedicated file tools used; files read before editing. |
| 117 | +- [ ] Long output captured via `tee` under `/tmp`. |
0 commit comments