Skip to content

[FEAT#532] pkg/agent/codex 골격 신설 — Codex CLI agent backend - #536

Open
juhy0987 wants to merge 2 commits into
mainfrom
feature/#532/codex-pool-skeleton
Open

juhy0987 wants to merge 2 commits into
mainfrom
feature/#532/codex-pool-skeleton

Conversation

@juhy0987

Copy link
Copy Markdown
Member

연관 이슈


구현 내용

메타 이슈 #462Sub 1pkg/agent/codex/ 4 파일 (+ prompt.go) 골격. claude 패턴 미러링 + codex 특화 조정.

컴파일 타임 인터페이스 만족

// pkg/agent/codex/pool.go
var (
    _ llmgen.SelectorExtractor = (*Pool)(nil)
    _ llmgen.EnrichedExtractor = (*Pool)(nil)
    _ agent.Agent              = (*Pool)(nil)
)

신설 파일 (5)

파일 역할
container.go ContainerRunner 인터페이스 + execContainerRunner (docker CLI 호출)
worker.go Worker + NewFromEnv / Start / Stop / ExtractEnriched + stage env 인지
pool.go Pool + PoolConfig = agent.PoolConfig alias + NewPoolFromConfig + round-robin
session.go RunSession (agent.Agent 구현) — generic primitive
prompt.go prompt builder (parser/codex/* template)

claude 와의 차이점

  • .codex.json sibling 마운트 제거 — codex 는 ~/.codex 단일 디렉토리만 사용
  • CLI 명령: codex exec --model <m> <prompt> (claude 의 claude -p 와 다름)
  • 권한/sandbox 플래그 미지정 — codex CLI 버전 진화 빈도 높아 운영 검증 후 후속 조정
  • 모델 default: gpt-5-codex
  • 이미지: issuetracker-codex:local (Sub 2 의 Dockerfile 빌드)

PR #531 의 agent 공용 인프라 활용

  • PoolConfig = agent.PoolConfig type alias
  • NewPoolFromConfigagent.NewStageEnv 사용 — stage prefix 우선순위 자동 적용
  • 다른 변경 없이 stage 별 풀 자동 작동

환경변수 (claude 와 1:1 대응)

CODEX_IMAGE / CODEX_MODEL / CODEX_AUTH_DIR / CODEX_CONTAINER_AUTH_PATH
CODEX_TIMEOUT / CODEX_WORKER_COUNT
# stage prefix:
PARSER_CODEX_* / ENRICH_CODEX_*

CI / 머지 게이트 점검

변경 영향 범위

  • 영향 패키지/모듈: pkg/agent/codex/ (신설만)
  • 위험도: Low — 신설 패키지, 기존 호출처 없음. main.go wiring 은 Sub 3 에서 추가 예정이라 본 PR 머지로 운영 동작 변경 없음.

Required Status Checks

  • Commit Lint / PR Title Lint / Linked Issue Check / Format Check / Build / Test / Lint

롤백 계획

신설 패키지만 추가하므로 본 PR revert 로 완전 롤백 가능. 외부 호출처 없음.


후속 sub-issue

🤖 Generated with Claude Code

메타 이슈 #462 의 Sub 1. agent.Agent + llmgen.SelectorExtractor + EnrichedExtractor
3개 인터페이스 컴파일 타임 만족. claude 패키지 패턴 미러링하되 codex 특화 조정.

신설 파일 (5):
- pkg/agent/codex/container.go — ContainerRunner 인터페이스 + execContainerRunner
- pkg/agent/codex/worker.go — Worker + NewFromEnv + Start/Stop + ExtractEnriched
- pkg/agent/codex/pool.go — Pool + PoolConfig (agent.PoolConfig alias) + NewPoolFromConfig + round-robin
- pkg/agent/codex/session.go — RunSession (agent.Agent 구현)
- pkg/agent/codex/prompt.go — prompt builder (parser/codex/* template)

claude 와의 차이점:
- .codex.json sibling 마운트 제거 — codex 는 ~/.codex 단일 디렉토리만 사용
- CLI 명령: `codex exec --model <m> <prompt>` (claude 의 `claude -p` 와 다름)
- 권한/sandbox 플래그 미지정 — codex CLI 버전 진화 빈도 높아 운영 검증 후 후속 조정
- 모델 default: gpt-5-codex (claude 의 claude-sonnet-4-6 대응)
- 이미지: issuetracker-codex:local (Sub 2 의 Dockerfile 빌드)

PR #531 의 agent 공용 인프라 활용:
- PoolConfig = agent.PoolConfig type alias
- NewPoolFromConfig 가 agent.NewStageEnv 사용
- stage prefix 우선순위 자동 적용 (<STAGE>_CODEX_* > CODEX_* > default)
- 다른 변경 없이 stage 별 풀 자동 작동

환경변수 (claude 와 1:1 대응):
- CODEX_IMAGE / CODEX_MODEL / CODEX_AUTH_DIR / CODEX_CONTAINER_AUTH_PATH
- CODEX_TIMEOUT / CODEX_WORKER_COUNT
- stage prefix: PARSER_CODEX_* / ENRICH_CODEX_*

후속 sub-issue:
- #533: Dockerfile + Makefile codex-build target
- #534: main.go wiring + PARSER/ENRICH_AGENT_BACKEND 선택 정책
- #535: 단위 테스트 (mock runner 기반)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 03:12
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@juhy0987, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 37 minutes and 36 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff832eb1-4ea0-4228-8e55-bdef1e7a659f

📥 Commits

Reviewing files that changed from the base of the PR and between d2ab231 and ddf38dc.

📒 Files selected for processing (5)
  • pkg/agent/codex/container.go
  • pkg/agent/codex/pool.go
  • pkg/agent/codex/prompt.go
  • pkg/agent/codex/session.go
  • pkg/agent/codex/worker.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#532/codex-pool-skeleton

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

이슈 #462 메타 작업의 Sub 1 — claude agent backend 패턴을 1:1 미러링한 pkg/agent/codex/ 패키지 골격을 신설합니다. PR #531 에서 도입한 agent.PoolConfig / agent.StageEnv 공용 인프라를 그대로 활용하여 stage 별 (parser/enrich) 풀 분리를 지원하며, llmgen.SelectorExtractor / llmgen.EnrichedExtractor / agent.Agent 세 인터페이스를 컴파일 타임에 만족시킵니다. 본 PR 단독으로는 main.go wiring 이 없어 운영 동작 변경은 없습니다 (Sub 3 에서 통합 예정).

Changes:

  • pkg/agent/codex/ 5개 파일 신설 — claude 패턴 미러링 (warm container + round-robin pool + session primitive)
  • codex CLI 차이 반영: codex exec 비대화 모드 / .codex.json sibling 마운트 제거 / gpt-5-codex default
  • stage prefix env 우선순위 자동 적용 (PARSER_CODEX_* / ENRICH_CODEX_*CODEX_* → default)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/agent/codex/container.go ContainerRunner 인터페이스 + docker CLI 호출 구현 (execContainerRunner)
pkg/agent/codex/worker.go Worker lifecycle, ExtractEnriched (parser 경로), env/auth 검증
pkg/agent/codex/pool.go Pool round-robin, NewPoolFromConfig, PoolConfig = agent.PoolConfig alias
pkg/agent/codex/session.go enrich 단계용 generic RunSession primitive (files + promptText → stdout)
pkg/agent/codex/prompt.go prompt builder, parser/codex/{list,page}.user 템플릿 로드

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a warm Docker container-based worker pool for the Codex agent, enabling concurrent, low-latency LLM-based selector extraction and session execution. Key feedback highlights a security vulnerability in session file path traversal checks, a bug where container cleanup fails on shutdown timeout due to using a cancelled context, and filesystem side-effects inside constructors that hinder unit testing. Additionally, minor issues were identified regarding incorrect truncation constant usage and missing imports for string validation.

Comment thread pkg/agent/codex/session.go
Comment thread pkg/agent/codex/session.go
Comment thread pkg/agent/codex/worker.go Outdated
Comment thread pkg/agent/codex/container.go
Comment thread pkg/agent/codex/worker.go
…e 일관성

gemini 5건 중 4건 본 PR 반영. 잔여 1건 (NewWithRunner 의 validateAuthDir DI 위반)
은 시그니처 변경 + claude 동등 적용 필요 → 별도 후속 이슈로 분리.

#3321915441 (Security-High) — path traversal 검증 강화:
- 기존: name != filepath.Base(name) 만 검증 → ".." / "." / 백슬래시 통과
- 변경: name == "" || name == "." || name == ".." || strings.ContainsAny(name, "/\\\\")
- 명시적 거부로 directory escape 차단

#3321915423 (Security-High) — strings 패키지 import 추가 (위 수정 의존).

#3321915451 (High) — Stop 의 cancelled ctx → docker rm 즉시 실패:
- ctx 가 이미 cancel 된 상태에서 StopContainer 호출 시 exec.CommandContext 가 즉시
  context canceled 로 실패 → 컨테이너 누수
- context.WithoutCancel(ctx) + 15s 별도 stopCtx 로 cleanup 보장

#3321915455 (Medium) — container.go stderr truncate 일관성:
- truncateStdoutLen (256) → truncateStderrLen (512)
- stderr 는 stderr-specific 길이 사용 (다른 함수와 일관)

본 수정 모두 claude 패키지에도 동일한 사전 issue 존재 — 별도 후속 이슈 (#530 의 graceful shutdown 일관성처럼) 로 분리하여 일관 적용 예정.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] pkg/agent/codex — Codex CLI Pool + Worker 골격 (agent.Agent 구현)

2 participants