Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ split-debuginfo = "unpacked"
t = "nextest run --no-capture"
qt = "nextest run --no-fail-fast --no-capture"
ci = "nextest run --profile ci --no-capture"
c = "clippy --all-targets"
c = "clippy --all-targets --features tokio,json"
b = "build --all-targets"
2 changes: 1 addition & 1 deletion .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Quick Commands

```bash
cargo fmt && cargo clippy --all-targets && cargo nextest run
cargo fmt && cargo clippy --all-targets --features tokio,json && cargo nextest run

# Or use the convenient aliases defined in .cargo/config.toml
cargo c && cargo t
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/welcome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo ""
echo " Auditing & Quality:"
echo " cargo audit # Security vulnerability check"
echo " cargo deny check # License/dependency check"
echo " cargo clippy --all-targets # Linting"
echo " cargo clippy --all-targets --features tokio,json # Linting"
echo " cargo shear # Unused dependency detection"
echo " cargo spellcheck # Documentation spelling"
echo " cargo geiger # Unsafe code audit"
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- No `panic!()` or `todo!()`
- All fallible operations return `Result`
- [ ] I have added tests that prove my fix is effective or my feature works
- [ ] I have run `cargo fmt && cargo clippy --all-targets` with no warnings
- [ ] I have run `cargo fmt && cargo clippy --all-targets --features tokio,json` with no warnings
- [ ] I have run `cargo nextest run` and all tests pass

### If Applicable
Expand Down
32 changes: 6 additions & 26 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ on:
- '**.rs'
- 'docs/**'
- 'wiki/**'
- 'scripts/sync-wiki.py'
- 'scripts/check-wiki-consistency.py'
- 'scripts/validate-wiki-output.py'
- 'scripts/tests/test_sync_wiki.py'
- 'scripts/tests/test_check_wiki_consistency.py'
- 'scripts/**'
- '.markdownlint.json'
- '.markdown-link-check.json'
- '.lychee.toml'
- '.vale.ini'
- '.vale/**'
- 'scripts/check-links.sh'
- 'scripts/verify-markdown-code.sh'
- 'scripts/check-code-fence-syntax.sh'
- '.github/workflows/ci-docs.yml'
pull_request:
branches: [main]
Expand All @@ -29,19 +22,12 @@ on:
- '**.rs'
- 'docs/**'
- 'wiki/**'
- 'scripts/sync-wiki.py'
- 'scripts/check-wiki-consistency.py'
- 'scripts/validate-wiki-output.py'
- 'scripts/tests/test_sync_wiki.py'
- 'scripts/tests/test_check_wiki_consistency.py'
- 'scripts/**'
- '.markdownlint.json'
- '.markdown-link-check.json'
- '.lychee.toml'
- '.vale.ini'
- '.vale/**'
- 'scripts/check-links.sh'
- 'scripts/verify-markdown-code.sh'
- 'scripts/check-code-fence-syntax.sh'
- '.github/workflows/ci-docs.yml'
workflow_dispatch:

Expand Down Expand Up @@ -174,10 +160,10 @@ jobs:
run: python scripts/check-wiki-consistency.py

# ============================================================================
# WIKI SYNC DRY-RUN - Validate wiki generation on PRs
# SCRIPT TESTS & WIKI DRY-RUN - Run all script tests and validate wiki generation
# ============================================================================
wiki-sync-dry-run:
name: Wiki Sync Dry-Run
name: Script Tests & Wiki Dry-Run
runs-on: ubuntu-latest

steps:
Expand All @@ -191,14 +177,8 @@ jobs:
- name: Install pytest
run: pip install pytest
Comment thread
wallstop marked this conversation as resolved.
Outdated

- name: Run wiki sync tests
run: python -m pytest scripts/tests/test_sync_wiki.py -v

- name: Run wiki validation tests
run: python -m pytest scripts/tests/test_validate_wiki_output.py -v

- name: Run wiki consistency tests
run: python -m pytest scripts/tests/test_check_wiki_consistency.py -v
- name: Run script tests
run: python -m pytest scripts/tests/ -v

- name: Generate wiki (dry-run)
run: python scripts/sync-wiki.py --dest wiki-test-output
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
run: cargo fmt --check

- name: Run clippy
run: cargo clippy --all-targets -- -D warnings
run: cargo clippy --all-targets --features tokio,json -- -D warnings

# Miri undefined behavior check (cross-platform, optimized)
#
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-safety.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
# Run clippy with nursery lints enabled
# These are experimental but useful for catching additional issues
# Lints from Cargo.toml are already applied; here we add nursery
cargo clippy --all-targets -- \
cargo clippy --all-targets --features tokio,json -- \
-D warnings \
-W clippy::nursery \
-A clippy::significant_drop_tightening \
Expand Down Expand Up @@ -462,7 +462,7 @@ jobs:
# - clippy::unimplemented: unimplemented!() macros
# - clippy::unreachable: unreachable!() macros
# - clippy::indexing_slicing: unchecked array/slice indexing
if cargo clippy --lib -- \
if cargo clippy --lib --features tokio,json -- \
-D clippy::panic \
-D clippy::unwrap_used \
-D clippy::expect_used \
Expand Down Expand Up @@ -552,7 +552,7 @@ jobs:
echo "- Review any warnings in the individual job logs"
echo "- Replace \`.unwrap()\` with proper error handling where possible"
echo "- Ensure all \`panic!\` calls are intentional and documented"
echo "- Run \`cargo clippy --all-targets\` locally before pushing"
echo "- Run \`cargo clippy --all-targets --features tokio,json\` locally before pushing"
} >> "$GITHUB_STEP_SUMMARY"

- name: Check for critical failures
Expand Down
10 changes: 5 additions & 5 deletions .llm/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## Quick Commands

```bash
cargo fmt && cargo clippy --all-targets && cargo nextest run --no-capture # Pre-commit
cargo fmt && cargo clippy --all-targets --features tokio,json && cargo nextest run --no-capture # Pre-commit
cargo c && cargo t # Aliases from .cargo/config.toml
typos # Spell check (CI enforced)
cargo test --features z3-verification -- --nocapture # Z3 proofs (slow)
Expand Down Expand Up @@ -197,15 +197,15 @@ Consolidate integration tests into a single crate (`tests/it/main.rs`). Anti-pat

## Mandatory Linting

- **After Rust changes:** `cargo fmt && cargo clippy --all-targets` (or `cargo c`)
- **After Rust changes:** `cargo fmt && cargo clippy --all-targets --features tokio,json` (or `cargo c`)
- **After workflow changes:** `actionlint` (no exceptions)
- **After doc changes:** `cargo doc --no-deps`
- **After markdown changes:** `npx markdownlint 'file.md' --config .markdownlint.json --fix`
- **After `.llm/` changes:** All `.md` files under `.llm/` must be **300 lines or fewer** (enforced by pre-commit hook `llm-line-limit`)
- **Link validation:** `./scripts/check-links.sh`
- **Spell check:** `typos`
- **Vale (advisory):** `vale docs/` -- checks prose quality, non-blocking in CI
- **Full pre-commit:** `cargo fmt && cargo clippy --all-targets && cargo nextest run --no-capture`
- **Full pre-commit:** `cargo fmt && cargo clippy --all-targets --features tokio,json && cargo nextest run --no-capture`

## Skill Code Examples

Expand Down Expand Up @@ -236,7 +236,7 @@ When changing public APIs, update: rustdoc comments (source of truth), README.md
## Quality Checklist

- [ ] `cargo fmt` run
- [ ] `cargo clippy --all-targets` passes
- [ ] `cargo clippy --all-targets --features tokio,json` passes
- [ ] All tests pass (`cargo nextest run`)
- [ ] Tests for new functionality included
- [ ] Rustdoc comments with examples
Expand All @@ -248,7 +248,7 @@ When changing public APIs, update: rustdoc comments (source of truth), README.md

## For Agents

When spawning sub-agents or using Task tools: the sub-agent MUST run `cargo fmt` and verify `cargo clippy --all-targets` passes on any modified files. If the sub-agent cannot run these, the parent agent must run them after receiving changes.
When spawning sub-agents or using Task tools: the sub-agent MUST run `cargo fmt` and verify `cargo clippy --all-targets --features tokio,json` passes on any modified files. If the sub-agent cannot run these, the parent agent must run them after receiving changes.

---

Expand Down
1 change: 1 addition & 0 deletions .llm/skills/async-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Use bounded channels (`mpsc::channel(100)`) to prevent memory exhaustion. Never

| Pitfall | Fix |
|---------|-----|
| `#[track_caller]` on `async fn` | Not supported; extract a sync helper or remove the attribute |
| `std::thread::sleep` in async | `tokio::time::sleep().await` |
| Forgetting to `.await` futures | Futures are lazy -- nothing happens without await |
| `std::sync::Mutex` held across `.await` | Use `tokio::sync::Mutex` or release before await |
Expand Down
4 changes: 2 additions & 2 deletions .llm/skills/ci-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| Error Pattern | Category | Quick Fix |
|---------------|----------|-----------|
| `cargo fmt --check` fails | Formatting | `cargo fmt` |
| Clippy warnings | Linting | `cargo clippy --fix --allow-dirty` |
| Clippy warnings | Linting | `cargo clippy --all-targets --features tokio,json --fix --allow-dirty` |
| Test assertion failures | Test logic | `RUST_BACKTRACE=1 cargo test name -- --nocapture` |
| `VERIFICATION RESULT: FAILURE` | Kani | Verify assertion matches impl; add `#[kani::unwind(N)]` |
| `linker cc not found` | Cross-compilation | Check Cross.toml, avoid unstable image tags |
Expand All @@ -34,7 +34,7 @@ cat .github/workflows/ci-*.yml | grep "run:"

# Common reproductions
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --features tokio,json -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
cargo nextest run test_name --no-capture
cargo kani --harness proof_function_name
Expand Down
6 changes: 3 additions & 3 deletions .llm/skills/refactoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

```bash
# Pre-refactoring
cargo nextest run && cargo clippy --all-targets
cargo nextest run && cargo clippy --all-targets --features tokio,json

# After each change
cargo check && cargo nextest run

# Post-refactoring
cargo fmt && cargo clippy --all-targets && cargo nextest run
cargo fmt && cargo clippy --all-targets --features tokio,json && cargo nextest run
rg "unwrap\(\)|expect\(|panic!\(|todo!\(" src/
```

Expand Down Expand Up @@ -77,7 +77,7 @@ rg "unwrap\(\)|expect\(|panic!\(|todo!\(" src/

### Pre-Refactoring
- [ ] Tests pass: `cargo nextest run`
- [ ] No clippy warnings: `cargo clippy --all-targets`
- [ ] No clippy warnings: `cargo clippy --all-targets --features tokio,json`
- [ ] Git commit current changes

### Post-Refactoring
Expand Down
5 changes: 5 additions & 0 deletions .llm/skills/rust-pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ Use `ok_or_else(|| ...)` when error construction allocates or is expensive. Use
- **`#[serde(default)]` on required fields:** Silently accepts missing data.
- **Enum representation:** Default serializes as `{"Active": null}`. Use `#[serde(rename_all = "snake_case")]`.

## Async Pitfalls

- **`#[track_caller]` on `async fn`:** Not supported by Rust. The attribute is silently ignored or triggers a clippy warning/error. Extract a sync helper that carries `#[track_caller]` and call it from the async fn, or remove the attribute entirely. A pre-commit grep hook catches this.

## Testing Pitfalls

- **Tests pass on panic:** Function panics before assertion is reached. Use `#[should_panic]` or `catch_unwind`.
Expand Down Expand Up @@ -135,3 +139,4 @@ Proofs must verify what they claim. If name says "independent", actually test mo
- [ ] `std::` types in loom tests
- [ ] `ok_or` vs `ok_or_else` for allocating errors
- [ ] Pattern matching: `match` not `if let` when fallback needs value
- [ ] `#[track_caller]` on async fn (not supported)
25 changes: 25 additions & 0 deletions .llm/skills/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@
- **Errors to stderr**: `print("ERROR: ...", file=sys.stderr)`
- **No `shell=True`** in subprocess calls

### Error Reporting in Lint Scripts

Lint hooks must use `{path}:{line_number}: {message}` format so editors
hyperlink to the correct location. When a violation spans multiple lines
(e.g., attribute on line A, target on line B), the `path:line` prefix
must point to the **violation site** (where the fix is needed), not the
trigger/detection line. Mention the trigger line in the message body:

```python
# Multi-line: prefix β†’ async fn line, body β†’ attribute line
f"{path}:{fn_line}: #[track_caller] (line {attr_line}) on async fn ..."
```

Never prefix issue lines with leading whitespace (e.g., `" {issue}"`) in
`main()` summary output -- leading spaces break the `path:line:` prefix
that editors rely on for hyperlinking.

For file-level errors where no specific line number exists (e.g., cannot
read file), use a synthetic line number `:0:` to maintain the format:

```python
# File-level error: use :0: as synthetic line number
f"{path}:0: cannot read file: {exc}"
```

### Exception Handling

```python
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ repos:
types: [rust]
pass_filenames: false

- id: check-track-caller-async
name: check track_caller on async fn
entry: python scripts/hooks/check-track-caller-async.py
language: python
types: [rust]

Comment on lines +85 to +90
- id: cargo-clippy
name: cargo clippy
entry: python scripts/run-cargo-clippy.py
Expand Down Expand Up @@ -166,6 +172,16 @@ repos:
files: '(Dockerfile|devcontainer\.json)$'
pass_filenames: true

# ══════════════════════════════════════════════════════════════════════
# Hook quality
# ══════════════════════════════════════════════════════════════════════
- id: check-hook-output-format
name: check hook output format
entry: python scripts/hooks/check-hook-output-format.py
language: python
files: '^scripts/hooks/check-.*\.py$'
pass_filenames: true

# ══════════════════════════════════════════════════════════════════════
# CI validation (skip gracefully if tools not installed)
# ══════════════════════════════════════════════════════════════════════
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Critical Reminders

- **Zero-panic:** No `unwrap()`, `expect()`, `panic!()`, `todo!()` in production code
- **Pre-commit:** `cargo fmt && cargo clippy --all-targets && cargo nextest run --no-capture` (or `cargo c && cargo t`)
- **Pre-commit:** `cargo fmt && cargo clippy --all-targets --features tokio,json && cargo nextest run --no-capture` (or `cargo c && cargo t`)
- **Kani:** Always add `#[kani::unwind(N)]` to proofs; CI uses `--default-unwind 8` via `--quick` mode
- **Changelog:** Ask "Does this affect `pub` items or user-observable behavior?" β€” if yes, update `CHANGELOG.md`

Expand Down
8 changes: 4 additions & 4 deletions scripts/hooks/check-dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def check_file(filepath: Path) -> list[str]:
try:
lines = filepath.read_text(encoding="utf-8").splitlines()
except (OSError, UnicodeDecodeError) as exc:
print(f"Warning: skipping {filepath}: {exc}", file=sys.stderr)
print(f"{filepath}:0: cannot read file: {exc}", file=sys.stderr)
return []
Comment thread
wallstop marked this conversation as resolved.
Outdated

is_dockerfile = filepath.name.startswith("Dockerfile")
Expand Down Expand Up @@ -94,10 +94,10 @@ def main() -> int:
all_issues.extend(issues)

if all_issues:
print("Dockerfile anti-patterns detected:")
print("Dockerfile anti-patterns detected:", file=sys.stderr)
for issue in all_issues:
print(f" {issue}")
print(f"\n{len(all_issues)} issue(s) found.")
print(issue, file=sys.stderr)
print(f"\n{len(all_issues)} issue(s) found.", file=sys.stderr)
return 1

return 0
Expand Down
15 changes: 8 additions & 7 deletions scripts/hooks/check-empty-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def check_file(filepath: Path) -> list[str]:
try:
content = filepath.read_text(encoding="utf-8")
tree = ast.parse(content, filename=str(filepath))
except (SyntaxError, OSError, UnicodeDecodeError):
# SyntaxError: Let other tools catch syntax errors
# OSError: File not readable (permissions, deleted, etc.)
# UnicodeDecodeError: Non-UTF-8 files (rare for Python tests)
except SyntaxError:
# Let other tools catch syntax errors
return []
except (OSError, UnicodeDecodeError) as exc:
print(f"Warning: cannot read {filepath}: {exc}", file=sys.stderr)
return [f"{filepath}:0: cannot read file: {exc}"]

Comment thread
wallstop marked this conversation as resolved.
Outdated
# Collect all functions that are inside classes (methods)
methods_in_classes: set[int] = set()
Expand Down Expand Up @@ -112,10 +113,10 @@ def main() -> int:
all_errors.extend(errors)

if all_errors:
print("Empty test methods detected:")
print("Empty test methods detected:", file=sys.stderr)
for error in all_errors:
print(f" {error}")
print("\nTest methods must have at least one assertion or meaningful code.")
print(error, file=sys.stderr)
print("\nTest methods must have at least one assertion or meaningful code.", file=sys.stderr)
return 1

return 0
Expand Down
Loading
Loading