跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

systematic-debugging

Methodology for debugging non-trivial problems systematically. This skill should be used automatically when investigating bugs, test failures, or unexpected behavior that isn't immediately obvious. Emphasizes hypothesis formation, parallel investigation with subagents, and avoiding common anti-patterns like jumping to conclusions or weakening tests.

freenet · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add freenet/freenet-agent-skills --skill systematic-debugging

技能说明


name: systematic-debugging description: Methodology for debugging non-trivial problems systematically. This skill should be used automatically when investigating bugs, test failures, or unexpected behavior that isn't immediately obvious. Emphasizes hypothesis formation, parallel investigation with subagents, and avoiding common anti-patterns like jumping to conclusions or weakening tests. license: LGPL-3.0

Systematic Debugging

When to Use

Invoke this methodology automatically when:

  • A test fails and the cause isn't immediately obvious
  • Unexpected behavior occurs in production or development
  • An error message doesn't directly point to the fix
  • Multiple potential causes exist

Core Principles

  1. Hypothesize before acting - Form explicit hypotheses about root cause before changing code
  2. Test hypotheses systematically - Validate or eliminate each hypothesis with evidence
  3. Parallelize investigation - Use subagents for concurrent readonly exploration
  4. Preserve test integrity - Never weaken tests to make them pass

Debugging Scope Ladder

Always prefer the smallest, most reproducible scope that demonstrates the bug. Work up the ladder only when the smaller scope can't reproduce or doesn't apply:

PriorityScopeWhen to UseCommand
1Unit testLogic errors, algorithm bugs, single-function issuescargo test -p freenet -- specific_test
2Mocked unit testTransport/ring logic needing isolationUnit test with MockNetworkBridge / MockRing
3Simulation testMulti-node behavior, state machines, race conditionscargo test -p freenet --test simulation_integration -- --test-threads=1
4SimNetwork + FaultConfigFault tolerance, message loss, network partitionsSimNetwork with configured fault injection
5fdev single-processQuick multi-peer CI validationcargo run -p fdev -- test --seed 42 single-process
6freenet-test-network20+ peer large-scale behaviorDocker-based freenet-test-network
7Real networkIssues that only manifest with real UDP/NAT/latencyManual multi-peer test across machines

Why this order matters:

  • Lower scopes are faster, deterministic, and reproducible by anyone
  • Higher scopes require more infrastructure, time, and may not be accessible to all contributors
  • Gateway logs, aggregate telemetry, and production metrics are not available to every developer — don't assume access to these when designing reproduction steps

Debugging Workflow

Phase 0: Claim the Issue

If you're working on a GitHub issue, check if it's already assigned before starting. If someone else is assigned, stop and inform the user — don't duplicate effort. If unassigned, assign it to yourself so others know it's being worked on:

gh issue view <ISSUE> --repo freenet/<REPO>  # Check assignees
gh issue edit <ISSUE> --repo freenet/<REPO> --add-assignee @me

Phase 1: Reproduce and Isolate

  1. Reproduce the failure — Confirm the bug exists and is reproducible
  2. Use the scope ladder — Start at the smallest scope that can demonstrate the bug:
    • Can you write a unit test? Try that first
    • Needs multiple nodes? Use the simulation framework with a deterministic seed
    • Only happens under fault conditions? Use SimNetwork with FaultConfig
    • Can't reproduce in simulation? Then escalate to real network testing
  3. Record the seed — When using simulation tests, always record the seed value for reproducibility
  4. Gather initial evidence — Read error messages, logs, stack traces

Simulation-first approach for distributed bugs:

# Run simulation tests deterministically
cargo test -p freenet --features simulation_tests --test sim_network -- --test-threads=1

# With logging to observe event sequences
RUST_LOG=info cargo test -p freenet --features simulation_tests --test sim_network -- --nocapture --test-threads=1

# Reproduce with a specific seed
cargo run -p fdev -- test --seed 0xDEADBEEF single-process

Phase 1b: When the Bug Is Reported from the Live Network

When a bug comes from production observations (user reports, telemetry, monitoring), the goal is to translate the network observation into a local reproduction as fast as possible. Live-network debugging has the slowest feedback loop — adding telemetry, redeploying, waiting — so minimize time spent there.

The workflow:

  1. Constrain the problem from network data — What operation type? Which peers? What hop count? What timing pattern? Use telemetry or user reports to narrow this down.
  2. Translate constraints into simulation parameters:
Network ObservationSimulation Translation
"GET times out at hop 3"#[freenet_test] with 4+ nodes, specific node_locations matching topology
"Peer X never responds"Node configured to drop/delay messages via FaultConfig
"73% timeout rate"FaultConfig { message_loss_rate: 0.7, .. } or unresponsive target node
"Works for PUT but not GET"Test both operations — likely incomplete wiring in dispatch path
"Rapid connect/disconnect cycles"Simulation with transport-level fault injection
"Messages dropped after acknowledgement"FaultConfig with selective message loss after initial handshake
  1. Write the simulation test — Start with #[freenet_test] or SimNetwork + FaultConfig. Use a deterministic seed.
  2. Debug locally — Now iterate with full control: add tracing, assertions, state inspection. No redeployment needed.
  3. Validate — Optionally confirm via telemetry that the deployed fix improves live behavior.

If a telemetry-monitor skill is available (project-local, not part of this plugin), use it to query the centralized OpenTelemetry collector for constraining the problem. But treat telemetry as input to simulation desig

阅读完整来源 ↗