feat(exec): add process replacement mode - #654
Conversation
Allow environment-only workloads to replace fnox while retaining the same PID and receiving signals directly. Prevent ambient age identities from leaking into the target process. Decision-Rationale: Process replacement is opt-in and limited to environment-only secrets because a successful exec leaves fnox no opportunity to clean up files or manage leases. Spawn-and-wait remains the default for workloads that require lifecycle management. Decision-Tags: exec, process-lifecycle, secrets
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Unix-only ChangesExec replacement
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ExecCommand
participant SecretResolver
participant TargetProcess
ExecCommand->>SecretResolver: Resolve configured secrets
SecretResolver-->>ExecCommand: Return environment values
ExecCommand->>ExecCommand: Scrub ambient age credentials
ExecCommand->>TargetProcess: Replace process with cmd.exec()
TargetProcess-->>ExecCommand: Return exec failure if startup fails
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Greptile SummaryAdds Unix process replacement support to
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "test(exec): wait for replacement before ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@fnox.usage.kdl`:
- Line 56: Make --replace platform-aware across fnox.usage.kdl: do not include
it in generic usage syntax, and describe it as Unix-only where appropriate.
Update docs/cli/commands.json (lines 250-275) and docs/cli/exec.md (lines 5-20)
to show the flag only for Unix or clearly separate Unix-only syntax from
portable fnox exec syntax; remove --replace from the platform-neutral command
index in docs/cli/index.md (line 65).
In `@test/exec_replace.bats`:
- Around line 209-213: Replace the one-time `ps -p "$REPLACEMENT_PID" -o comm=`
assertion in the replacement verification with a bounded polling loop that
repeatedly checks for `sleep`, allowing time for the target process to complete
`exec sleep 30` before failing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: c31b77c9-3ce3-489f-aa86-b25535b74baa
📒 Files selected for processing (8)
crates/fnox-core/src/error.rsdocs/cli/commands.jsondocs/cli/exec.mddocs/cli/index.mdfnox.usage.kdlsrc/commands/exec.rssrc/commands/mod.rstest/exec_replace.bats
Poll for the final sleep image before checking inherited signal dispositions, avoiding a race with the target script's final exec. Document the private pre-replacement signal helpers.
Summary
fnox exec --replaceon Linux, macOS, and other Unix-like systems so environment-only workloads can replace fnox while retaining the same PIDFNOX_AGE_KEYandFNOX_AGE_KEY_FILEvalues while allowing explicitly selected secrets with those namesSIGINTandSIGTERMdispositions and handle those signals during secret resolutionDiscussion: #652
This pull request was prepared with AI assistance and reviewed by the author.
Summary by CodeRabbit
fnox exec --replaceto run the command via process replacement, preserving the PID and enabling direct signal delivery.--replacescenarios (file-based secrets, credential leases, and signal setup failures) and missing secret failures.execCLI docs, command reference, and usage synopsis to document--replacebehavior and platform availability.