Loading...
Loading...
Generates before/after verification pairs for loom plans. Proves a stage actually changed system behavior by capturing state before and after implementation. Use for delta-proof verification — proving new commands, endpoints, modules, or bug fixes work by comparing system state.
npx skill4agent add cosmix/loom before-after# Stage: Add user authentication
truths:
- "cargo test" # All tests pass# Stage: Add user authentication
description: |
Implement JWT-based user authentication.
BEFORE: curl -f localhost:8080/api/protected returns 200 (no auth required)
AFTER: curl -f localhost:8080/api/protected returns 401 (auth now required)
AFTER: curl -f -H "Authorization: Bearer <token>" localhost:8080/api/protected returns 200
truths:
- "curl -sf localhost:8080/api/protected | grep -q 401"
- "curl -sf -H 'Authorization: Bearer fake' localhost:8080/api/protected && exit 1 || exit 0"
wiring:
- source: "src/middleware/auth.rs"
pattern: "pub fn require_auth"
description: "Authentication middleware registered"- id: add-verify-command
name: "Add loom verify command"
stage_type: standard
working_dir: "loom"
description: |
Implement the `loom verify <stage-id>` CLI command.
DELTA PROOF:
- BEFORE: `loom verify --help` fails (command not registered)
- AFTER: `loom verify --help` succeeds
- AFTER: `loom verify test-stage` runs verification logic
truths:
- "loom verify --help"
- "loom verify nonexistent-stage 2>&1 | grep -q 'Stage not found'"
wiring:
- source: "src/main.rs"
pattern: "verify"
description: "Verify command registered in CLI"
- source: "src/commands/verify.rs"
pattern: "pub fn execute"
description: "Verify command implementation exists"
artifacts:
- "src/commands/verify.rs"- id: add-status-endpoint
name: "Add /api/status endpoint"
stage_type: standard
working_dir: "."
description: |
Implement GET /api/status endpoint returning system health.
DELTA PROOF:
- BEFORE: curl localhost:8080/api/status returns 404
- AFTER: curl localhost:8080/api/status returns 200 with JSON health data
truths:
- "curl -sf localhost:8080/api/status | jq -e '.healthy'"
- "curl -sf -o /dev/null -w '%{http_code}' localhost:8080/api/status | grep -q 200"
wiring:
- source: "src/routes/mod.rs"
pattern: "/api/status"
description: "Status endpoint registered in router"
- source: "src/handlers/status.rs"
pattern: "pub async fn status_handler"
description: "Status handler implementation"
artifacts:
- "src/handlers/status.rs"- id: add-retry-module
name: "Add retry module"
stage_type: standard
working_dir: "loom"
description: |
Create retry module with exponential backoff.
DELTA PROOF:
- BEFORE: `use crate::retry::RetryPolicy;` would fail (module doesn't exist)
- AFTER: Module compiles, exports are available
truths:
- "cargo check"
- "cargo test --lib retry"
wiring:
- source: "src/lib.rs"
pattern: "pub mod retry"
description: "Retry module exported from lib.rs"
- source: "src/orchestrator/core/orchestrator.rs"
pattern: "use crate::retry"
description: "Retry module imported in orchestrator"
artifacts:
- "src/retry.rs"
- "tests/retry_tests.rs"- id: fix-crash-on-empty-plan
name: "Fix crash when plan has no stages"
stage_type: standard
working_dir: "loom"
description: |
Fix crash when initializing empty plan.
DELTA PROOF (NOTE: Before/after are inverted for bugs):
- BEFORE: Empty plan causes panic (bug reproducer succeeds at finding the bug)
- AFTER: Empty plan returns error gracefully (bug reproducer fails to find the bug)
Verification approach:
1. Create test case that reproduces the crash
2. Test should PASS after fix (catches the crash gracefully)
3. The bug is proven fixed when the panic no longer occurs
truths:
- "cargo test test_empty_plan_no_crash"
- "cargo test --lib plan::parser"
wiring:
- source: "src/plan/parser.rs"
pattern: "if stages.is_empty()"
description: "Empty stage list check added"
- source: "src/plan/parser.rs"
pattern: 'Err.*"Plan must contain at least one stage"'
description: "Error returned instead of panic"
artifacts:
- "tests/empty_plan_tests.rs"# Adding a new user registration endpoint
truths:
- "cargo test" # Too broad - doesn't prove endpoint existstruths:
- "curl -sf -X POST localhost:8080/api/register -d '{\"email\":\"test@example.com\"}' | jq -e '.user_id'"# Adding command output
truths:
- "loom status" # Just checks it runstruths:
- "loom status | grep -q 'Active Plan:'"
- "loom status | grep -q 'Executing:'"# Just adding a config file
description: |
BEFORE: config.toml doesn't exist
AFTER: config.toml exists
truths:
- "test -f config.toml"artifacts:
- "config.toml"# Fix infinite loop bug
description: |
BEFORE: Test passes
AFTER: Test fails demonstrating the bug# Fix infinite loop bug
description: |
BEFORE: Code enters infinite loop (bug exists)
AFTER: Code completes successfully (bug fixed)
truths:
- "timeout 5s cargo test test_no_infinite_loop"before_stageafter_stagebefore_stageafter_stageloom stage completebefore_stage:
- command: "cargo test test_feature"
exit_code: 1
description: "Feature test fails before implementation"
after_stage:
- command: "cargo test test_feature"
exit_code: 0
description: "Feature test passes after implementation"commandexit_codedescriptionstdout_containsstdout_not_containsstderr_emptytruths:
- "command that proves feature works"
- "test that validates behavior"wiring:
- source: "src/main.rs"
pattern: "register_feature"
description: "Feature registered in main entry point"artifacts:
- "src/feature/implementation.rs"
- "tests/feature_tests.rs"description: |
Implement feature X.
DELTA PROOF:
- BEFORE: <what's true before this stage>
- AFTER: <what should be true after this stage>
[Implementation details...]- id: add-metrics-endpoint
name: "Add /metrics endpoint"
stage_type: standard
working_dir: "."
description: |
Add Prometheus-compatible /metrics endpoint.
DELTA PROOF:
- BEFORE: curl localhost:8080/metrics returns 404
- AFTER: curl localhost:8080/metrics returns Prometheus format
- AFTER: Metrics include request_count, response_time
Implementation:
- Create metrics middleware
- Register /metrics endpoint
- Export request_count and response_time gauges
dependencies: ["add-middleware-support"]
before_stage:
- command: "curl -sf localhost:8080/metrics"
exit_code: 1
description: "Metrics endpoint does not exist yet"
after_stage:
- command: "curl -sf localhost:8080/metrics | grep -q 'request_count'"
exit_code: 0
description: "Metrics endpoint returns request_count"
- command: "curl -sf localhost:8080/metrics | grep -q 'response_time'"
exit_code: 0
description: "Metrics endpoint returns response_time"
truths:
- "curl -sf localhost:8080/metrics | grep -q 'request_count'"
- "curl -sf localhost:8080/metrics | grep -q 'response_time'"
- "curl -sf localhost:8080/metrics | grep -q 'TYPE request_count counter'"
wiring:
- source: "src/routes/mod.rs"
pattern: "Router.*metrics"
description: "Metrics endpoint registered"
- source: "src/middleware/metrics.rs"
pattern: "pub fn track_metrics"
description: "Metrics middleware implemented"
artifacts:
- "src/middleware/metrics.rs"
- "src/routes/metrics.rs"
acceptance:
- "cargo test"
- "cargo clippy -- -D warnings"description: |
[One-line summary of what this stage does]
DELTA PROOF:
- BEFORE: [State before this stage - expected to fail/pass]
- AFTER: [State after this stage - expected to pass/fail]
[Detailed implementation guidance]
EXECUTION PLAN:
[If using subagents, describe parallel work]| Verification Type | Use When | Proves |
|---|---|---|
| Behavior is observable via shell commands | Feature works at runtime |
| Feature must integrate with existing code | Code is connected/registered |
| New files must exist | Files were created |
| Standard checks (build, test, lint) | Code compiles and tests pass |
truthswiring- id: add-stage-complete-command
name: "Add loom stage complete command"
stage_type: standard
working_dir: "loom"
description: |
Implement `loom stage complete <stage-id>` command to mark stages as complete.
DELTA PROOF:
- BEFORE: `loom stage complete --help` fails (command doesn't exist)
- AFTER: `loom stage complete --help` shows usage
- AFTER: `loom stage complete test-stage` transitions stage to Completed state
Implementation:
- Add StageComplete command to CLI
- Implement state transition logic
- Add validation for stage existence
- Update stage file with completion timestamp
dependencies: ["knowledge-bootstrap"]
truths:
- "loom stage complete --help"
- "loom stage list | grep -q complete"
wiring:
- source: "src/main.rs"
pattern: "Commands::StageComplete"
description: "StageComplete command registered in CLI"
- source: "src/commands/stage.rs"
pattern: "pub fn complete"
description: "Stage complete implementation exists"
- source: "src/models/stage/transitions.rs"
pattern: "fn transition_to_completed"
description: "State transition logic implemented"
artifacts:
- "src/commands/stage.rs"
acceptance:
- "cargo test"
- "cargo test stage_complete"
- "cargo clippy -- -D warnings"working_dirworking_dir: "loom" # Commands execute from loom/ directory
truths:
- "cargo test" # Runs in loom/ (where Cargo.toml lives)
artifacts:
- "src/commands/verify.rs" # Resolves to loom/src/commands/verify.rs
wiring:
- source: "src/main.rs" # Resolves to loom/src/main.rsworking_dir: "."before_stageafter_stagetruthswiringartifacts