con un clic
fix-bug
// Debug and fix bugs in Syncpack using scientific debugging methodology. Use when a test is failing, unexpected behaviour occurs, or investigating issues. Covers hypothesis-driven debugging and TDD-based fixes.
// Debug and fix bugs in Syncpack using scientific debugging methodology. Use when a test is failing, unexpected behaviour occurs, or investigating issues. Covers hypothesis-driven debugging and TDD-based fixes.
Rust code style and conventions for Syncpack. Use when writing or modifying Rust code. Covers functional patterns, imports, naming, and quality standards.
Write tests for Syncpack using the TestBuilder pattern. Use when adding tests for commands, validation logic, or any new functionality. Covers TestBuilder API, assertion patterns, and common test scenarios.
Run coverage, inspect results, and identify missing test scenarios for a given source file. Use when analysing test coverage or finding untested branches.
Add new features to Syncpack including commands and validation logic. Use when implementing new CLI commands, adding InstanceState variants, or extending version group behaviour.
Add and update the documentation website for Syncpack. Use when making user-facing changes to the codebase.
Put the answer first, then context and details follow. Use when writing documentation, tutorials, error messages, or any communication where readers need to decide quickly if something is relevant to them.
| name | fix-bug |
| description | Debug and fix bugs in Syncpack using scientific debugging methodology. Use when a test is failing, unexpected behaviour occurs, or investigating issues. Covers hypothesis-driven debugging and TDD-based fixes. |
Guide for debugging and fixing bugs in Syncpack.
Gather information before changing code:
# Run the failing test with output
cargo test test_name -- --nocapture
# Run with backtrace
RUST_BACKTRACE=1 cargo test test_name
# Test against fixture
cd fixtures/fluid-framework
cargo run -- lint
Questions to answer:
Common root causes by symptom:
| Symptom | Likely Cause |
|---|---|
State is Unknown | visit_packages not called or instance skipped |
| Wrong state assigned | Validation logic order, earlier check overriding |
| Instance not found | Package/dependency name mismatch, location format |
| Command not running | Missing registration in cli.rs, main.rs, or commands.rs |
| Panic/unwrap failure | Unexpected None or Err value |
Add targeted debug output:
use log::debug;
debug!("Instance: {:#?}", instance);
debug!("State before: {:?}", instance.state.borrow());
Search for related code:
# Find where state is assigned
ast-grep -p 'InstanceState::fixable' src/visit_packages/
# Find similar patterns
ast-grep -p 'PATTERN' src/
Write a failing test FIRST (TDD):
#[test]
fn reproduces_the_bug() {
let ctx = TestBuilder::new()
.with_packages(vec![/* minimal reproduction */])
.build_and_visit_packages();
// Assert expected behaviour (will fail initially)
}
Then fix the code until the test passes.
just test # All tests pass
cargo clippy # No warnings
| Issue with... | Check... |
|---|---|
| CLI parsing | src/cli.rs |
| Config loading | src/config.rs, src/rcfile.rs |
| Package reading | src/packages.rs, src/package_json.rs |
| State assignment | src/visit_packages/*.rs |
| Command output | src/commands/*.rs, src/commands/ui/ |
| Version parsing | src/specifier/*.rs |
| Phase | What happens | Files |
|---|---|---|
| Create | Read config, packages, collect instances | context.rs, packages.rs |
| Inspect | Assign InstanceState | visit_packages.rs, visit_packages/*.rs |
| Run | Process instances, output/write | commands/*.rs |
Check:
visit_packages.rs?Check:
build_and_visit_packages() called (not just build())?"{dep} in {location} of {package}")Verify registration in all three places:
src/cli.rs — Subcommand enumsrc/main.rs — match armsrc/commands.rs — module declaration❌ Changing code without understanding the cause ❌ Removing code just to make tests pass ❌ Fixing symptoms instead of root cause ❌ Skipping the test-first step