Skip to content

Commit 3e20e15

Browse files
tbitcsoz-agent
andcommitted
feat: issues #55 #56 #58 #59 — RTD table fix, commands docs, H11/H12 rules, rate-limit pacing
- fix(#55): governance.md Modular Governance table rows 2-6 started with || instead of | (duplicate pipe from uppercase migration) - docs(#56): commands.md now covers all 40+ commands — previously only 13 of 40+ were documented; added exec/ps/abort, commit/push/sync, branch/pr, session-end, update, apply, migrate-project, release, verify-release, ledger, req, plugin, serve, credits limits - feat(#58): H11 (no unbounded loops/blocking I/O without deadline) and H12 (Windows .cmd files for multi-step automation) added to rules.md.j2 governance template; specsmith validate now scans .sh/.cmd/.ps1/.bash script files for infinite-loop patterns without a recognised deadline/timeout guard - feat(#59): BUILTIN_PROFILES constant ships conservative RPM/TPM defaults for OpenAI, Anthropic, Google (20 entries + wildcard fallbacks); new credits limits status and credits limits defaults CLI subcommands; RTD rate-limits.md page; README updated Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent 9ebb3c0 commit 3e20e15

13 files changed

Lines changed: 1920 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.2.2] - 2026-04-02
10+
### Fixed
11+
- **Governance RTD table rendering** (#55): rows 2–6 of the Modular Governance table in `docs/site/governance.md` started with `||` instead of `|`, breaking layout. Introduced during the uppercase filename migration.
12+
13+
### Added
14+
- **RTD commands page complete** (#56): `docs/site/commands.md` now documents all 40+ commands — previously 13 of 40+ were documented. Added sections for `exec`/`ps`/`abort`, `commit`/`push`/`sync`/`branch`/`pr`, `session-end`, `update`, `apply`, `migrate-project`, `release`, `verify-release`, `ledger add/list/stats`, `req list/add/trace/gaps/orphans`, `plugin`, `serve`, and `credits limits`.
15+
- **H11/H12 governance rules and blocking-loop enforcement** (#58): two new hard rules added to the `RULES.md` governance template. H11 requires every loop or blocking wait in agent-written scripts to have a deadline, fallback exit, and diagnostic message. H12 requires Windows multi-step automation to use `.cmd` files. `specsmith validate` now scans `.sh`/`.cmd`/`.ps1`/`.bash` files under `scripts/` and the project root and flags infinite-loop patterns without a recognised deadline/timeout guard.
16+
- **Proactive per-model rate-limit pacing** (#59): `BUILTIN_PROFILES` constant ships conservative RPM/TPM defaults for OpenAI (gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o1-mini, o3-mini, gpt-5.4, wildcard), Anthropic (claude-opus-4, claude-sonnet-4, claude-haiku-3-5, claude-3-5-sonnet, wildcard), and Google (gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash, gemini-2.5-pro, wildcard). Two new `credits limits` subcommands: `status` (rolling-window RPM/TPM/concurrency snapshot) and `defaults` (list or `--install` built-in profiles). Local overrides always take precedence over built-ins.
17+
- **Rate Limit Pacing RTD page**: new `docs/site/rate-limits.md` documents the scheduler model, built-in profiles table, CLI commands, persistent state, and the Python API.
18+
- **README updated**: new sections for Governance Rules (H11/H12) and Proactive Rate Limit Pacing with RTD links. Commands table expanded to all major command groups.
19+
20+
## [0.2.2]
1121

1222
### Fixed
1323
- **Upgrade auto-fixes AGENTS.md references**: when `upgrade` renames governance files (lowercase→uppercase), it now rewrites path references in AGENTS.md, CLAUDE.md, GEMINI.md, SKILL.md, and all agent config files automatically.

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,21 @@ Each type gets: tool-aware CI (correct lint/test/security/build tools), domain-s
8686
| `import` | Adopt an existing project (merge mode) |
8787
| `audit` | Drift detection and health checks (`--fix` to auto-repair) |
8888
| `architect` | Interactive architecture generation |
89-
| `validate` | Governance file consistency checks |
89+
| `validate` | Governance consistency + H11 blocking-loop detection |
9090
| `compress` | Archive old ledger entries |
9191
| `upgrade` | Update governance to new spec version |
9292
| `status` | CI/PR/alert status from VCS platform |
9393
| `diff` | Compare governance against templates |
9494
| `export` | Compliance report with REQ↔TEST coverage |
9595
| `doctor` | Check if verification tools are installed |
9696
| `self-update` | Update specsmith (channel-aware) |
97-
| `credits` | AI credit tracking, analysis, and budgets |
97+
| `credits` | AI credit tracking, analysis, budgets, and rate-limit pacing |
98+
| `exec` / `ps` / `abort` | Tracked process execution with PID tracking and timeout |
99+
| `commit` / `push` / `sync` | Governance-aware VCS operations |
100+
| `branch` / `pr` | Strategy-aware branching and PR creation |
101+
| `ledger` | Structured ledger add/list/stats |
102+
| `req` | Requirements list/add/trace/gaps/orphans |
103+
| `session-end` | End-of-session checklist |
98104

99105
## 7 Agent Integrations
100106

@@ -104,9 +110,36 @@ AGENTS.md (cross-platform standard), Warp/Oz, Claude Code, GitHub Copilot, Curso
104110

105111
GitHub Actions, GitLab CI, Bitbucket Pipelines — all with tool-aware CI generated from the verification tool registry. Dependabot/Renovate configured per language ecosystem.
106112

113+
## Governance Rules (H1–H12)
114+
115+
specsmith-governed projects enforce 12 hard rules. Two were added in v0.2.3 for agentic workflows:
116+
117+
- **H11** — Every loop or blocking wait in agent-written scripts must have a deadline, a fallback exit, and a diagnostic message on timeout. `specsmith validate` enforces this automatically.
118+
- **H12** — On Windows, multi-step automation goes into a `.cmd` file, not inline shell invocations or `.ps1` files.
119+
120+
See [Governance Model](https://specsmith.readthedocs.io/en/stable/governance/) for the full rule set.
121+
122+
## Proactive Rate Limit Pacing
123+
124+
specsmith ships a rolling-window scheduler that paces AI provider requests before dispatch:
125+
126+
- Built-in RPM/TPM profiles for OpenAI, Anthropic, and Google models (including wildcard fallbacks)
127+
- Pre-dispatch budget check: sleeps until the 60-second window refills instead of overshooting
128+
- Parses OpenAI-style `"Please try again in 10.793s"` messages and obeys them
129+
- Adaptive concurrency: halved after a 429, gradually restored after consecutive successes
130+
- Local overrides always take precedence over built-in defaults
131+
132+
```bash
133+
specsmith credits limits defaults # list built-in profiles
134+
specsmith credits limits defaults --install # merge into project config
135+
specsmith credits limits status --provider openai --model gpt-5.4
136+
```
137+
138+
See [Rate Limit Pacing](https://specsmith.readthedocs.io/en/stable/rate-limits/) for full details.
139+
107140
## Documentation
108141

109-
**[specsmith.readthedocs.io](https://specsmith.readthedocs.io)** — Full user manual with tutorials, command reference, project type details, tool registry, governance model, troubleshooting.
142+
**[specsmith.readthedocs.io](https://specsmith.readthedocs.io)** — Full user manual with tutorials, command reference, project type details, tool registry, governance model, rate-limit pacing, troubleshooting.
110143

111144
## Links
112145

docs/site/commands.md

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,268 @@ specsmith credits budget --cap 50 --alert-pct 80 # Set budget
208208

209209
Credit data stored locally at `.specsmith/credits.json` (gitignored).
210210

211+
## `specsmith exec`
212+
213+
Execute a command with PID tracking and timeout enforcement.
214+
215+
```bash
216+
specsmith exec "pytest tests/" --timeout 300
217+
specsmith exec "make build" --timeout 120 --project-dir ./my-project
218+
```
219+
220+
**Options:**
221+
222+
- `--timeout INT` — Maximum seconds to wait (default: 120). Process is killed when deadline fires.
223+
- `--project-dir PATH` — Project root (default: `.`). PID and log files go under `.specsmith/`.
224+
225+
Tracks the process in `.specsmith/pids/<pid>.json` and logs stdout/stderr to `.specsmith/logs/`. Works on Windows (taskkill), Linux, and macOS (SIGTERM → SIGKILL).
226+
227+
**Exit codes:** Mirrors the child process exit code. Returns 124 on timeout.
228+
229+
## `specsmith ps`
230+
231+
List tracked running processes.
232+
233+
```bash
234+
specsmith ps --project-dir ./my-project
235+
```
236+
237+
Shows PID, time remaining to timeout, and command for every tracked process. Prunes stale PID files for processes that already exited.
238+
239+
## `specsmith abort`
240+
241+
Kill tracked process(es).
242+
243+
```bash
244+
specsmith abort --pid 12345
245+
specsmith abort --all
246+
```
247+
248+
**Options:**
249+
250+
- `--pid INT` — Kill a specific tracked PID.
251+
- `--all` — Kill every tracked process.
252+
253+
Without `--pid` or `--all`, prints the current process list and instructions.
254+
255+
## `specsmith commit`
256+
257+
Governance-aware commit: checks ledger, optionally audits, then commits.
258+
259+
```bash
260+
specsmith commit -m "feat: add export command"
261+
specsmith commit --no-audit --auto-push
262+
```
263+
264+
**Options:**
265+
266+
- `-m / --message TEXT` — Override the commit message (default: last ledger entry heading).
267+
- `--no-audit` — Skip the pre-commit audit check.
268+
- `--auto-push` — Push after a successful commit.
269+
270+
Warns if `LEDGER.md` was not updated since the last commit.
271+
272+
## `specsmith push`
273+
274+
Push the current branch with safety checks.
275+
276+
```bash
277+
specsmith push
278+
specsmith push --force
279+
```
280+
281+
**Options:**
282+
283+
- `--force` — Skip branch-protection checks.
284+
285+
## `specsmith sync`
286+
287+
Pull latest and warn about governance conflicts.
288+
289+
```bash
290+
specsmith sync --project-dir ./my-project
291+
```
292+
293+
Runs `git pull` and checks for conflicts in governance files (AGENTS.md, LEDGER.md, docs/governance/*).
294+
295+
## `specsmith branch`
296+
297+
Strategy-aware branch management.
298+
299+
```bash
300+
specsmith branch create feature/my-feature
301+
specsmith branch list
302+
```
303+
304+
**Subcommands:**
305+
306+
- `create NAME` — Create a branch following the configured branching strategy (gitflow / trunk-based / GitHub Flow). Reads strategy from `scaffold.yml`.
307+
- `list` — List branches with their role annotation (main, develop, feature, hotfix, etc.).
308+
309+
## `specsmith pr`
310+
311+
Create a PR with governance context in the body.
312+
313+
```bash
314+
specsmith pr --title "Add export command"
315+
specsmith pr --draft
316+
```
317+
318+
**Options:**
319+
320+
- `--title TEXT` — PR title.
321+
- `--draft` — Create as a draft PR.
322+
323+
Appends the first 2000 characters of `specsmith export` output to the PR body. Requires `gh` (GitHub), `glab` (GitLab), or `bb` (Bitbucket) CLI.
324+
325+
## `specsmith session-end`
326+
327+
Run the end-of-session checklist.
328+
329+
```bash
330+
specsmith session-end --project-dir ./my-project
331+
```
332+
333+
Checks: uncommitted changes, ledger updated, open TODOs count, audit health. Reports items that need action before ending the session.
334+
335+
## `specsmith update`
336+
337+
Check for updates and optionally install the latest version + migrate the project.
338+
339+
```bash
340+
specsmith update
341+
specsmith update --check # Check only, don't install
342+
specsmith update --yes # Skip confirmation prompt
343+
```
344+
345+
**Options:**
346+
347+
- `--check` — Print available version and exit without installing.
348+
- `--yes` — Auto-confirm update and migration prompts.
349+
350+
Auto-detects channel (stable vs dev) from the installed version. Runs `migrate-project` if the project scaffold needs migration after the update.
351+
352+
## `specsmith apply`
353+
354+
Regenerate CI and agent integration files from the current `scaffold.yml`.
355+
356+
```bash
357+
specsmith apply --project-dir ./my-project
358+
```
359+
360+
Re-renders GitHub Actions / GitLab CI / Bitbucket Pipelines config and agent integration files (CLAUDE.md, GEMINI.md, `.warp/`, etc.). Safe: never overwrites AGENTS.md, LEDGER.md, or user-authored docs.
361+
362+
## `specsmith migrate-project`
363+
364+
Migrate project scaffold to the current specsmith version.
365+
366+
```bash
367+
specsmith migrate-project --project-dir ./my-project
368+
specsmith migrate-project --dry-run
369+
```
370+
371+
**Options:**
372+
373+
- `--dry-run` — Show what would change without writing.
374+
375+
## `specsmith release`
376+
377+
Bump the version string everywhere and scan for stale references.
378+
379+
```bash
380+
specsmith release 0.3.0
381+
specsmith release 0.3.0 --project-dir ./my-project
382+
```
383+
384+
Updates version in `pyproject.toml`, `Cargo.toml`, `package.json`, `src/**/__init__.py`, README badges, and CHANGELOG. Scans for references to the old version that may need updating. Prints the next manual steps (CHANGELOG, git tag, push).
385+
386+
## `specsmith verify-release`
387+
388+
Post-release smoke check: verify PyPI, RTD, and GitHub release are live.
389+
390+
```bash
391+
specsmith verify-release
392+
```
393+
394+
Checks that the installed version is published on PyPI, that the RTD site is reachable, and that the GitHub Release tag exists. Requires `gh` CLI for the GitHub check.
395+
396+
## `specsmith ledger`
397+
398+
Structured ledger management.
399+
400+
```bash
401+
specsmith ledger add "Implemented export command" --type feature --reqs REQ-CLI-005
402+
specsmith ledger list --since 2026-03-01
403+
specsmith ledger stats
404+
```
405+
406+
**Subcommands:**
407+
408+
- `add DESCRIPTION` — Append a structured entry. Options: `--type` (task/feature/fix/migration), `--author`, `--reqs` (comma-separated REQ IDs).
409+
- `list` — List ledger entries. Option: `--since YYYY-MM-DD`.
410+
- `stats` — Show entry count and per-author breakdown.
411+
412+
## `specsmith req`
413+
414+
Requirements management.
415+
416+
```bash
417+
specsmith req list
418+
specsmith req add REQ-CLI-010 --component cli --priority high --description "Add export"
419+
specsmith req trace
420+
specsmith req gaps
421+
specsmith req orphans
422+
```
423+
424+
**Subcommands:**
425+
426+
- `list` — List all requirements with status, priority, and description.
427+
- `add REQ_ID` — Add a new requirement stub to `docs/REQUIREMENTS.md`.
428+
- `trace` — Show REQ → TEST traceability matrix (which tests cover each requirement).
429+
- `gaps` — List requirements that have no test coverage.
430+
- `orphans` — List tests that reference non-existent requirement IDs.
431+
432+
## `specsmith plugin`
433+
434+
List installed specsmith plugins.
435+
436+
```bash
437+
specsmith plugin
438+
```
439+
440+
Plugins extend project types and tool registries. They register via `pyproject.toml` entry points under `specsmith.types`. Shows each plugin's load status and any import errors.
441+
442+
## `specsmith serve`
443+
444+
Start the local API server for the web dashboard (placeholder).
445+
446+
```bash
447+
specsmith serve --port 8910
448+
```
449+
450+
Not yet fully implemented. See project roadmap for the planned REST API.
451+
452+
## `specsmith credits limits`
453+
454+
Manage persisted per-model RPM/TPM rate-limit profiles.
455+
456+
```bash
457+
specsmith credits limits list
458+
specsmith credits limits set --provider openai --model gpt-4o --rpm 500 --tpm 30000000
459+
specsmith credits limits status --provider openai --model gpt-4o
460+
specsmith credits limits defaults
461+
specsmith credits limits defaults --install
462+
```
463+
464+
**Subcommands:**
465+
466+
- `list` — Print all locally saved profiles (provider, model, RPM, TPM, utilization target, concurrency).
467+
- `set` — Create or replace a local profile. Options: `--provider`, `--model`, `--rpm`, `--tpm`, `--target FLOAT` (default 0.70), `--concurrency INT` (default 1).
468+
- `status` — Show the rolling-window snapshot for a model: requests and tokens used in the current 60-second window, concurrency, moving averages.
469+
- `defaults` — List built-in profiles for common OpenAI, Anthropic, and Google models. Use `--install` to merge them into the local project config (existing overrides are preserved).
470+
471+
Profiles are stored at `.specsmith/model-rate-limits.json` (gitignored). The scheduler uses these to pace requests before dispatch and to apply exponential backoff after a 429.
472+
211473
## `specsmith --version`
212474

213475
```bash

docs/site/governance.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ When AGENTS.md is kept small (~100-150 lines), governance details are delegated
4646

4747
| File | Content | When Loaded |
4848
|------|---------|-------------|
49-
| `RULES.md` | Hard rules H1-H9, stop conditions | Every session start |
50-
|| `WORKFLOW.md` | Session lifecycle, proposal format, ledger format | Every session start |
51-
|| `ROLES.md` | Agent role boundaries, behavioral rules | Every session start |
52-
|| `CONTEXT-BUDGET.md` | Context management, credit optimization | Every session start |
53-
|| `VERIFICATION.md` | Verification standards, tools listing, acceptance criteria | When performing verification |
54-
|| `DRIFT-METRICS.md` | Drift detection, feedback loops, health signals | On audit or session start |
49+
| `RULES.md` | Hard rules H1-H11, stop conditions | Every session start |
50+
| `WORKFLOW.md` | Session lifecycle, proposal format, ledger format | Every session start |
51+
| `ROLES.md` | Agent role boundaries, behavioral rules | Every session start |
52+
| `CONTEXT-BUDGET.md` | Context management, credit optimization | Every session start |
53+
| `VERIFICATION.md` | Verification standards, tools listing, acceptance criteria | When performing verification |
54+
| `DRIFT-METRICS.md` | Drift detection, feedback loops, health signals | On audit or session start |
5555

5656
This lazy-loading approach minimizes token consumption — agents only load VERIFICATION.md when they're actually running tests, not at every session start.
5757

@@ -101,3 +101,19 @@ This is how context persists across sessions. When an agent starts with `resume`
101101
6. **Consistency** — Do AGENTS.md references resolve? Are requirement IDs unique?
102102

103103
`specsmith audit --fix` auto-repairs what it can: creates missing stubs, compresses oversized ledgers, regenerates CI configs.
104+
105+
## Hard Rules (H11 and H12)
106+
107+
Two rules were added in v0.2.3 specifically for long-running agentic workflows:
108+
109+
**H11 — No unbounded loops or blocking I/O without a deadline**
110+
111+
Every loop or blocking wait in agent-written scripts and automation must have an explicit deadline or iteration cap, a fallback exit path when the deadline fires, and a diagnostic message on timeout. Violating patterns include `while True:` / `while ($true)` / `for (;;)` with no deadline guard, I/O polling loops with no deadline, and `sleep` inside a loop with no termination condition.
112+
113+
`specsmith validate` enforces this by scanning `.sh`, `.cmd`, `.ps1`, and `.bash` files under `scripts/` and the project root for infinite-loop patterns without a recognised deadline/timeout guard.
114+
115+
**H12 — Windows multi-step automation via .cmd files**
116+
117+
On Windows, multi-step or heavily-quoted automation sequences must be written to a temporary `.cmd` file and executed from there. Inline multi-line quoting on Windows is fragile and causes avoidable hangs. Do not use `.ps1` files for this class of automation unless there is a concrete PowerShell-only requirement.
118+
119+
See `docs/governance/RULES.md` in any governed project for the full set of H1–H12 rules and stop conditions.

0 commit comments

Comments
 (0)