[ticket-063] fix(cli): re-exec after pip self-update to avoid mixed-version runs - #106
Conversation
…ersion runs pip rewrites package files under the running process, so lazy imports could load new modules while goal.cli stayed old. Restart via `python -m goal` with GOAL_SELF_UPDATED guard after a successful update. Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Koru Agent <agent@coru.dev> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Deterministic Validator approval for exact head e6bb481fd1970fe1fb1f83504b79ae37ef171e17.
Ticket: ticket-063
Correlation ID: goal-pr-106-ticket-063
Model: openrouter/z-ai/glm-5.2
Reviewed diff chunks: 2
Advisory LLM verdict: APPROVE
Advisory summary: Reviewed all 2 diff chunk(s). The PR implements a re-exec mechanism after pip self-update in the CLI to prevent mixed-version module imports. The implementation uses a one-shot environment variable guard (GOAL_SELF_UPDATED) to prevent infinite re-exec loops and handles OSError gracefully. The logic is sound: os.execv replaces the process, so _reexec_after_self_update() does not return on success. The guard check in _maybe_self_update() prevents loops if the update landed somewhere not on sys.path. Tests pass on Python 3.12 and 3.13, and governance checks pass. | This chunk adds tests covering CLI self-update re-exec behavior after a successful update, suppression of repeated updates following re-exec, and loud failure when re-exec is impossible. Tests use monkeypatching for execv and environment variables and assert expected behavior. CI checks pass.
Advisory findings: none
The LLM output above is advisory and was not used as the approval trust root.
Merge will be attempted after this approval when explicitly authorized.
Decision record (recomputable)
DECISION D-063-7284
TICKET ticket-063
HEAD_SHA e6bb481fd1970fe1fb1f83504b79ae37ef171e17
CORRELATION_ID goal-pr-106-ticket-063
ACTOR agent:ifuri-validator-agent[bot]
APPLIED_RULE P-CORE-015
INPUT author_login = "tom-sapletta-com"
INPUT observed_checks = ["test (3.12)=PASS","test (3.13)=PASS","governance / remote lifecycle=PASS"]
INPUT required_checks = ["test (3.12)","test (3.13)"]
INPUT required_checks_source = "protected registry (env/request)"
INPUT reviewer_login = "ifuri-validator-agent[bot]"
VERDICT APPROVE AUTHORITY DETERMINISTIC
REJECTED REQUEST_CHANGES BECAUSE NO_UNSAFE_CHANGE_REASON_FOUND
ADVISORY llm_verdict = "APPROVE" MODEL "openrouter/z-ai/glm-5.2"
ASSERT VERDICT_AUTHORITY != "ADVISORY"
Created by governed goal -a pull-request delivery.