Agent Skills
› spacedriveapp/spacebot
› async-state-safety
async-state-safety
GitHub防止异步和状态路径中的竞态回归,通过定义终端状态、转换守卫及幂等性来确保并发安全。提供竞态与实施检查清单,并执行针对性测试以验证状态收敛和防重复应用。
触发场景
worker生命周期变更
取消或重触发行为调整
状态机逻辑修改
超时或竞态条件处理
交付回执管理
安装
npx skills add spacedriveapp/spacebot --skill async-state-safety -g -y
SKILL.md
Frontmatter
{
"name": "async-state-safety",
"description": "This skill should be used when the user asks to change \"worker lifecycle\", \"cancellation\", \"retrigger behavior\", \"state machine\", \"delivery receipts\", \"timeouts\", or \"race conditions\". Enforces explicit async\/state invariants and targeted race-safe verification."
}
Async State Safety
Goal
Prevent race regressions in async and stateful paths.
Required Invariants
- Define valid terminal states before coding.
- Define allowed state transitions before coding.
- Keep terminal transitions idempotent.
- Ensure duplicate events cannot double-apply terminal effects.
- Ensure retries do not corrupt state.
Race Checklist
- Cancellation racing completion
- Timeout racing completion
- Retry racing ack/receipt update
- Concurrent updates to the same worker/channel record
- Missing-handle and stale-handle behavior
Implementation Checklist
- Add or update transition guards.
- Keep error handling explicit and structured.
- Preserve status/event emission on all terminal branches.
- Document why each race path converges safely.
Verification Checklist
- Run targeted tests for each touched race path.
- Add at least one negative-path test for terminal convergence.
- Add at least one idempotency test where applicable.
- Run broad gate checks after targeted checks pass.
Handoff Requirements
- Terminal states and transition matrix
- Race windows analyzed
- Targeted commands and outcomes
- Residual risks and follow-up tests
版本历史
- ac52277 当前 2026-07-05 14:56


