Skip to content

fix(codex): add invocation-scoped monitor lifecycle - #907

Open
GigiTiti-Kai wants to merge 12 commits into
fujibee:mainfrom
GigiTiti-Kai:feat/codex-session-scope
Open

fix(codex): add invocation-scoped monitor lifecycle#907
GigiTiti-Kai wants to merge 12 commits into
fujibee:mainfrom
GigiTiti-Kai:feat/codex-session-scope

Conversation

@GigiTiti-Kai

Copy link
Copy Markdown

Summary

  • add an opt-in --invocation-scope TOKEN monitor mode with a fresh app-server record and CAS lease per physical project/scope
  • supervise and reap only the captured Codex TUI, app-server, and bridge-launcher jobs while preserving argv, exit status, and legacy no-scope reuse
  • route hooks to the exact scoped server while keeping request, dispatcher, role, and child locks project-singleton
  • make scoped dispatcher/role handoff exact-server-bounded and reject inherited scope state in nested no-scope launches
  • document the lifecycle and fail-closed SIGKILL limitation

Related to #149.

Safety boundaries

  • no daemon, dependency, process inventory, or worktree deletion code
  • raw invocation tokens never enter paths or logs
  • pidfiles are never signal authority; only direct shell jobs captured through $! are signalled
  • different scopes remain isolated; a duplicate live scope fails closed
  • remote/role descendant readiness remains the caller's responsibility

Verification

  • focused monitor/launcher/resume/delivery: 259/259 passed (3 expected platform skips)
  • scoped regression set: 5/5 passed
  • spawn FD guard: 4/4 passed
  • enforced-assertion baseline: 638/638
  • Bash syntax, diff checks, and changed-diff gitleaks: passed
  • whole local Bats aggregation reached 1644/1645; the only failure was the unrelated intermittent test_remote_engine_start_refusal.bats .config.lock race, which also reproduced in isolation (8/9). Required Linux/macOS sharded CI remains the merge gate.

Review

  • task-by-task implementation and independent reviews completed
  • final whole-branch review found and verified fixes for physical-path aliasing and inherited nested no-scope routing

- cleanup失敗時もTUI終了statusとlease解放を保持
- supervisorへのTERMでcaptured TUIとscope子processをreap
- lifecycle testにfailure injectionとready barrierを追加

🤖 Generated with Codex
テストteardownでpidfile由来のTUI PIDをsignal対象にせず、fixture所有の
gateとexit markerを使って失敗時にも安全にfake TUIを終了する。

🤖 Generated with Codex
No-key duplicate dispatchers now keep the legacy immediate CAS-exit behavior. Scoped dispatchers continue bounded standby and takeover while their exact server remains alive.

🤖 Generated with Codex
Canonicalize project paths physically before scoped keys and dispatcher routing, and clear inherited scoped server routing for legacy launches. Document the scope option and cover symlink aliases and nested no-scope sessions with regressions.

🤖 Generated with Codex
@GigiTiti-Kai
GigiTiti-Kai marked this pull request as ready for review August 20, 2026 22:47
@GigiTiti-Kai

Copy link
Copy Markdown
Author

Ready for review. The final head is 66e13f6 and all 22 required checks are green, including all four Ubuntu and all four macOS Bats shards plus the native Windows leg.

The second CI run exposed a macOS-only fixture mismatch (/var/... vs physical /private/var/...). The production monitor was already correctly canonicalizing project identity; the fix canonicalizes the test fixture once. A symlink-path reproduction passes 24/24 monitor tests, and the native macOS shard now passes as well.

Could you review and squash-merge this when ready?

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.

1 participant