ben
|
fe5508228f
|
fix: 修复多 backend 并行日志 PID 混乱并移除包装格式 (#74) (#76)
* fix(logger): 修复多 backend 并行日志 PID 混乱并移除包装格式
**问题:**
- logger.go:288 使用 os.Getpid() 导致并行任务日志 PID 混乱
- 日志文件添加时间戳/PID/级别前缀包装,应输出 backend 原始内容
**修复:**
1. Logger 结构体添加 pid 字段,创建时捕获 PID
2. 日志写入使用固定 l.pid 替代 os.Getpid()
3. 移除日志输出格式包装,直接写入原始消息
4. 添加内存缓存 ERROR/WARN 条目,ExtractRecentErrors 从缓存读取
5. 优化 executor.go context 初始化顺序,避免重复创建 logger
**测试:**
- 所有测试通过(23.7s)
- 更新相关测试用例匹配新格式
Closes #74
* fix(logger): 增强并发日志隔离和 task ID 清理
## 核心修复
### 1. Task ID Sanitization (logger.go)
- 新增 sanitizeLogSuffix(): 清理非法字符 (/, \, :, 等)
- 新增 fallbackLogSuffix(): 为空/非法 ID 生成唯一后备名
- 新增 isSafeLogRune(): 仅允许 [A-Za-z0-9._-]
- 路径穿越防护: ../../../etc/passwd → etc-passwd-{hash}.log
- 超长 ID 处理: 截断到 64 字符 + hash 确保唯一性
- 自动创建 TMPDIR (MkdirAll)
### 2. 共享日志标识 (executor.go)
- 新增 taskLoggerHandle 结构: 封装 logger、路径、共享标志
- 新增 newTaskLoggerHandle(): 统一处理 logger 创建和回退
- printTaskStart(): 显示 "Log (shared)" 标识
- generateFinalOutput(): 在 summary 中标记共享日志
- 并发失败时明确标识所有任务使用共享主日志
### 3. 内部标志 (config.go)
- TaskResult.sharedLog: 非导出字段,标识共享日志状态
### 4. Race Detector 修复 (logger.go:209-219)
- Close() 在关闭 channel 前先等待 pendingWG
- 消除 Logger.Close() 与 Logger.log() 之间的竞态条件
## 测试覆盖
### 新增测试 (logger_suffix_test.go)
- TestLoggerWithSuffixSanitizesUnsafeSuffix: 非法字符清理
- TestLoggerWithSuffixReturnsErrorWhenTempDirNotWritable: 只读目录处理
### 新增测试 (executor_concurrent_test.go)
- TestConcurrentTaskLoggerFailure: 多任务失败时共享日志标识
- TestSanitizeTaskID: 并发场景下 task ID 清理验证
## 验证结果
✅ 所有单元测试通过
✅ Race detector 无竞态 (65.4s)
✅ 路径穿越攻击防护
✅ 并发日志完全隔离
✅ 边界情况正确处理
Resolves: PR #76 review feedback
Co-Authored-By: Codex Review <codex@anthropic.ai>
Generated with swe-agent-bot
Co-Authored-By: swe-agent-bot <agent@swe-agent.ai>
* fix(logger): 修复关键 bug 并优化日志系统 (v5.2.5)
修复 P0 级别问题:
- sanitizeLogSuffix 的 trim 碰撞(防止多 task 日志文件名冲突)
- ExtractRecentErrors 边界检查(防止 slice 越界)
- Logger.Close 阻塞风险(新增可配置超时机制)
代码质量改进:
- 删除无用字段 Logger.pid 和 logEntry.level
- 优化 sharedLog 标记绑定到最终 LogPath
- 移除日志前缀,直接输出 backend 原始内容
测试覆盖增强:
- 新增 4 个测试用例(碰撞防护、边界检查、缓存上限、shared 判定)
- 优化测试注释和逻辑
版本更新:5.2.4 → 5.2.5
Generated with swe-agent-bot
Co-Authored-By: swe-agent-bot <agent@swe-agent.ai>
---------
Co-authored-by: swe-agent-bot <agent@swe-agent.ai>
|
2025-12-17 10:33:38 +08:00 |
|
swe-agent[bot]
|
e1ad08fcc1
|
feat(codeagent-wrapper): 完整多后端支持与安全优化
修复 PR #53 中发现的问题,实现完整的多后端功能:
**多后端功能完整性**
- Claude/Gemini 后端支持 workdir (-C) 和 resume (--session-id) 参数
- 并行模式支持全局 --backend 参数和任务级 backend 配置
- 后端参数映射统一,支持 new/resume 两种模式
**安全控制**
- Claude 后端默认启用 --dangerously-skip-permissions 以支持自动化
- 通过 CODEAGENT_SKIP_PERMISSIONS 环境变量控制权限检查
- 不同后端行为区分:Claude 默认跳过,Codex/Gemini 默认启用
**并发控制**
- 新增 CODEAGENT_MAX_PARALLEL_WORKERS 环境变量限制并发数
- 实现 fail-fast context 取消机制
- Worker pool 防止资源耗尽,支持并发监控日志
**向后兼容**
- 版本号统一管理,提供 codex-wrapper 兼容脚本
- 所有默认行为保持不变
- 支持渐进式迁移
**测试覆盖**
- 总体覆盖率 93.4%(超过 90% 要求)
- 新增后端参数、并行模式、并发控制测试用例
- 核心模块覆盖率:backend.go 100%, config.go 97.8%, executor.go 96.4%
**文档更新**
- 更新 skills/codeagent/SKILL.md 反映多后端和安全控制
- 添加 CHANGELOG.md 记录重要变更
- 更新 README 版本说明和安装脚本
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-11 16:09:33 +08:00 |
|
swe-agent[bot]
|
3ef288bfaa
|
feat: implement enterprise workflow with multi-backend support
## Overview
Complete implementation of enterprise-level workflow features including
multi-backend execution (Codex/Claude/Gemini), GitHub issue-to-PR automation,
hooks system, and comprehensive documentation.
## Major Changes
### 1. Multi-Backend Support (codeagent-wrapper)
- Renamed codex-wrapper → codeagent-wrapper
- Backend interface with Codex/Claude/Gemini implementations
- Multi-format JSON stream parser (auto-detects backend)
- CLI flag: --backend codex|claude|gemini (default: codex)
- Test coverage: 89.2%
**Files:**
- codeagent-wrapper/backend.go - Backend interface
- codeagent-wrapper/parser.go - Multi-format parser
- codeagent-wrapper/config.go - CLI parsing with backend selection
- codeagent-wrapper/executor.go - Process execution
- codeagent-wrapper/logger.go - Async logging
- codeagent-wrapper/utils.go - Utilities
### 2. GitHub Workflow Commands
- /gh-create-issue - Create structured issues via guided dialogue
- /gh-implement - Issue-to-PR automation with full dev lifecycle
**Files:**
- github-workflow/commands/gh-create-issue.md
- github-workflow/commands/gh-implement.md
- skills/codeagent/SKILL.md
### 3. Hooks System
- UserPromptSubmit hook for skill activation
- Pre-commit example with code quality checks
- merge_json operation in install.py for settings.json merging
**Files:**
- hooks/skill-activation-prompt.sh|.js
- hooks/pre-commit.sh
- hooks/hooks-config.json
- hooks/test-skill-activation.sh
### 4. Skills System
- skill-rules.json for auto-activation
- codeagent skill for multi-backend wrapper
**Files:**
- skills/skill-rules.json
- skills/codeagent/SKILL.md
- skills/codex/SKILL.md (updated)
### 5. Installation System
- install.py: Added merge_json operation
- config.json: Added "gh" module
- config.schema.json: Added op_merge_json schema
### 6. CI/CD
- GitHub Actions workflow for testing and building
**Files:**
- .github/workflows/ci.yml
### 7. Comprehensive Documentation
- Architecture overview with ASCII diagrams
- Codeagent-wrapper complete usage guide
- GitHub workflow detailed examples
- Hooks customization guide
**Files:**
- docs/architecture.md (21KB)
- docs/CODEAGENT-WRAPPER.md (9KB)
- docs/GITHUB-WORKFLOW.md (9KB)
- docs/HOOKS.md (4KB)
- docs/enterprise-workflow-ideas.md
- README.md (updated with doc links)
## Test Results
- All tests passing ✅
- Coverage: 89.2%
- Security scan: 0 issues (gosec)
## Breaking Changes
- codex-wrapper renamed to codeagent-wrapper
- Default backend: codex (documented in README)
## Migration Guide
Users with codex-wrapper installed should:
1. Run: python3 install.py --module dev --force
2. Update shell aliases if any
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
2025-12-09 15:53:31 +08:00 |
|