Skip to content

fix(solve): preserve success after confirmed merge (#2117) - #2118

Open
konard wants to merge 8 commits into
mainfrom
issue-2117-6e9d64f44d8c
Open

fix(solve): preserve success after confirmed merge (#2117)#2118
konard wants to merge 8 commits into
mainfrom
issue-2117-6e9d64f44d8c

Conversation

@konard

@konard konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the lifecycle defect behind #2117, where GitHub had already merged the requested pull request but a later internal error could still make solve exit with code 1.

  • latch the first confirmed merge as a process-local terminal outcome before any post-merge await
  • preserve exit 0 for later internal log, cleanup, diagnostics, rejection, or exception failures while retaining best-effort diagnostics
  • skip misleading failure attachments, PR auto-close, and pre-exit failure notifications after the merge is confirmed
  • remove the duplicate pair of racing process-error listeners from solve
  • isolate final cleanup, log-reference, Sentry, and active-handle steps so one cannot block successful finalization
  • retain the Telegram split-outcome fallback for older deployments and genuinely external termination such as SIGKILL/OOM

Root cause and evidence boundary

GitHub records link-foundation/use-m#69 merged at 2026-07-30T06:38:12Z, and Hive Mind posted its merge-success comment one second later. The Telegram runner failure arrived afterward. Before this fix, merge success was only a return value; every exception/rejection/main-error path could still unconditionally request exit 1, and two handler pairs could race.

The exact historical statement that threw is not recoverable: the retained attached log ends almost three minutes before the merge, and the original container, final start-command footer, and Docker state are gone. The PR therefore fixes the concrete, reproducible lifecycle invariant that allowed any internal post-merge exception to contradict the durable GitHub result. Uncatchable host/container termination remains observable rather than being hidden.

The full evidence timeline and boundary audit are in docs/case-studies/issue-2117/README.md.

Reproduction

The new regression starts real Node child processes:

  1. before merge confirmation, safeExit(1) exits with status 1;
  2. after confirming the merge, the same safeExit(1) logs the late failure and exits with status 0;
  3. post-merge exception/rejection paths stay successful even when diagnostic logging fails;
  4. injected cleanup, Sentry, and active-handle failures still reach the successful final exit.

It also statically verifies that all four merge-success/already-merged branches latch before post-merge work and that solve no longer installs duplicate process-error handlers.

Tests

  • npm test — all 357 selected test files pass after merging current main
  • npm run lint
  • npm run format:check
  • node tests/test-issue-2117-post-merge-exit-guard.mjs — 16/16 on Node 20
  • npx --yes node@24 tests/test-issue-2117-post-merge-exit-guard.mjs — 16/16
  • node tests/test-issue-2117-merged-pr-exit.mjs — 10/10
  • related shutdown/finalization regressions — 103/103

Visual verification

Before After
Contradictory failure notification Split-outcome fallback notification

Fixes #2117

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #2117
@konard konard self-assigned this Jul 30, 2026
@konard konard changed the title [WIP] ❌ Work session failed (exit code: 1), yet pull request was merged at the same time fix(telegram): distinguish merged PR runner failures (#2117) Jul 30, 2026
@konard
konard marked this pull request as ready for review July 30, 2026 07:43
@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Implemented and finalized issue #2117.

  • Fixed Telegram reporting to distinguish a merged PR from a runner exiting non-zero.
  • Added verbose diagnostics, localization, regression tests, changeset, and complete case-study evidence.
  • All 355 default-suite test files passed on Node 24.
  • ESLint, Prettier, documentation validation, and current-head CI passed.
  • Branch is current with main, pushed, clean, and mergeable.
  • No outstanding review or issue comments.
  • PR is ready for review: link-assistant/hive-mind#2118

This summary was automatically extracted from the AI working session output.

@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $22.173839

📊 Context and tokens usage:

  • 432.6K / 200K (216%) input tokens, 44.3K / 128K (35%) output tokens

Total: (432.6K + 15.9M cached) input tokens, 44.3K output tokens, $22.173839 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: low (~7999 tokens)
  • Model: GPT 5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (6136KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Did we fix the root cause of exit code 1? We need to make sure that will never happen again.

@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
konard marked this pull request as draft July 30, 2026 07:49
@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 AI Work Session Started

Starting automated work session at 2026-07-30T07:49:26.906Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

@konard konard changed the title fix(telegram): distinguish merged PR runner failures (#2117) fix(solve): preserve success after confirmed merge (#2117) Jul 30, 2026
@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Yes—for the root failure class that allowed Hive Mind itself to turn a confirmed merge into exit code 1, this is now fixed in adb16e33.

The original implementation kept merge success only as a return value. Any later cleanup/logging/diagnostic exception could still reach an unconditional exit-1 handler, and solve had two pairs of process-error listeners that could race. The fix now:

  • latches the confirmed merge before the first post-merge await;
  • makes every later internal nonzero exit preserve status 0 and log the error;
  • skips failure side effects after that terminal success;
  • removes the duplicate handler pair; and
  • isolates each finalization step.

The regression uses real child processes: pre-merge safeExit(1) remains 1, post-merge safeExit(1) becomes 0, exception/rejection paths remain 0 even if diagnostic logging fails, and injected cleanup/Sentry/handle failures still reach success. It passes 16/16 on Node 20 and Node 24, and the current-main suite passes all 357 test files.

One evidence boundary is important: the retained historical log ends almost three minutes before the merge, and the original container/final outer log were gone, so the exact statement that threw in that 2026-07-30 run cannot be named honestly. The reproducible lifecycle defect that made the contradiction possible is closed. An uncatchable SIGKILL/OOM/host removal cannot be converted by Node code; those external events remain observable, with the Telegram fallback reporting both the merged PR and runner failure instead of claiming the whole task failed.

@konard
konard marked this pull request as ready for review July 30, 2026 09:42
@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $41.775664

📊 Context and tokens usage:

  • 763.9K / 200K (382%) input tokens, 76.3K / 128K (60%) output tokens

Total: (763.9K + 30.7M cached) input tokens, 76.3K output tokens, $41.775664 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT 5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (11425KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

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.

❌ Work session failed (exit code: 1), yet pull request was merged at the same time

1 participant