fix(engine/runtime): enforce run ownership locking and scrub inherited stage contract env#56
Conversation
(cherry picked from commit a66b4f39f10f6c2ac53d44598c2544148356c19b)
(cherry picked from commit 05947fb09f9f187f0d3f080cd132c7d510b3cc83)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bd275275f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if stale { | ||
| if removeErr := os.Remove(lockPath); removeErr != nil && !errors.Is(removeErr, os.ErrNotExist) { |
There was a problem hiding this comment.
Stop deleting unreadable lock files on short age threshold
Deleting run.lock.json as soon as it has been unreadable for 250ms can break mutual exclusion: if the current owner creates the file and is delayed before writing JSON (e.g., scheduler pause, slow filesystem, process stop/continue), a second process will remove the still-valid lock and acquire ownership, so both runs can execute concurrently against the same logs_root and race on checkpoints/artifacts.
Useful? React with 👍 / 👎.
|
Addressed Codex review finding in commit c194cfd.
Validation run: go test ./internal/attractor/engine -run "TestAcquireRunOwnership|TestRun_OwnershipConflict" -count=1. |
Summary
Hardens runtime safety by enforcing run ownership locks and preventing inherited stage contract env leakage.
Problem
Why This Change
Run ownership must be explicit and recoverable under stale lock conditions, and per-stage contract env should not leak across boundaries.
What Changed
User-Visible Behavior
Risk
Validation
gofmtandgo vet ./...go test ./internal/attractor/engine -run 'TestAcquireRunOwnership_|TestReleaseRunOwnership_|TestBuildBaseNodeEnv_StripsKilroyContractEnvKeys|TestInputManifestContract_' -count=1