Skill站外收录 @skilllib/skill-2014279400097787906
session-execution
支持命令的可靠执行与输出分离,通过前台和后台两种模式管理 shell 进程状态,利用临时文件和 FIFO 实现 stdout 与 stderr 的精确捕获,并确保跨会话操作的隔离性及退出状态的原子性传递。
效率工具 AI 技能
Skills.MD
# Session Execution
Read `docs/SESSION_EXECUTION.md` before working in this area. It explains the architecture for reliable command execution with stdout/stderr separation.
## Key Concepts
**Two execution modes:**
- **Foreground (exec)**: Runs in main shell, state persists. Uses temp files for output capture.
- **Background (execStream/startProcess)**: Runs in subshell via FIFOs. Labelers prefix output in background.
**Binary prefix contract:**
- Stdout: `\x01\x01\x01` prefix per line
- Stderr: `\x02\x02\x02` prefix per line
- Log parser reconstructs streams from these prefixes
**Completion signaling:**
- Exit code written to `<id>.exit` file via atomic `tmp` + `mv`
- Hybrid fs.watch + polling detects completion (robust on tmpfs/overlayfs)
- Background mode uses `labelers.done` marker to ensure output is fully captured
## When Developing
- Understand why foreground uses temp files (bash waits for redirects to complete)
- Understand why background uses FIFOs (concurrent streaming without blocking shell)
- Test silent commands (cd, variable assignment) - these historically caused hangs
- Test large output - buffering issues can cause incomplete logs
## When Reviewing
**Correctness checks:**
- Verify exit code handling is atomic (write to .tmp then mv)
- Check FIFO cleanup in error paths
- Ensure labelers.done is awaited before reading final output (background mode)
**Race condition analysis:**
Session execution has a mutex that serializes command execution per session. Before flagging race conditions:
1. Check if operations happen within the same session (mutex protects)
2. Check if operations are per-session vs cross-session (cross-session races are real)
3. Refer to `docs/CONCURRENCY.md` for the full concurrency model
**Common false positives:**
- "Concurrent reads/writes to session state" - mutex serializes these
- "FIFO operations might race" - labelers are per-command, not shared
**Actual concerns to watch for:**
- Cross-session operations without proper isolation
- Cleanup operations that might affect still-running commands
- File operations outside the mutex-protected section
## Key Files
- `packages/sandbox-container/src/session.ts` - Session class with exec/execStream
- `packages/sandbox-container/src/managers/SessionManager.ts` - Mutex and lifecycle
- `packages/sandbox/src/clients/CommandClient.ts` - SDK interface to session commands
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「session-execution」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次