achieve: fix #0184 -- separate stdout/stderr in pick_session_role#179
Merged
achieve: fix #0184 -- separate stdout/stderr in pick_session_role#179
Conversation
Previously daemon.sh:83 merged pick-role.py stdout+stderr with 2>&1 and used tail -1 to extract SESSION_ROLE. Any unexpected stdout line (atexit handler, uncaught exception after sys.exit, future library print) would cause tail -1 to return the wrong line, silently corrupting SESSION_ROLE to an unknown string that falls through to the build default -- locking the daemon into BUILD-only mode indefinitely with no error. pick-role.py already writes reasoning to stderr and the role name to stdout. The fix honors that separation: mktemp captures stderr; stdout is captured cleanly; cat prints the reasoning log in controlled order. Also includes autonomy score correction: 81 -> 85 (task-gen and healer rescored 3->5 with evidence from session index and healer log). 2 new contract tests in TestPickSessionRoleStderrSeparation.
…llow-up) Code review (PR #179) flagged two advisory items: 1. mktemp failure under set -uo pipefail would abort the daemon; add || _pick_stderr="/dev/null" fallback so stderr is silently dropped rather than killing the role-selection flow. 2. Contract tests are static-only; add task #192 to track behavioral test for the stdout isolation guarantee.
fazxes
added a commit
that referenced
this pull request
Apr 7, 2026
…st tasks Queue cleanup after session #103 major restructuring: Closed (8): - #73: AGENTS.md exists (commit 38e1fe5) - #88: duplicate of #69 (auto-changelog) - #141: obsolete (docs/prompt/evolve.md deleted) - #157: obsolete (docs/prompt/feedback/ deleted) - #159: consolidated into #190 - #161: consolidated into #190 - #181: obsolete (docs/prompt/unified.md deleted) - #184: done (fixed by PR #179) Path updates (30+ tasks): - docs/ -> .recursive/ or Recursive/ops/ - scripts/daemon.sh -> Recursive/engine/daemon.sh - scripts/lib-agent.sh -> Recursive/engine/lib-agent.sh - .nightshift.json -> .recursive.json - nightshift/*.py -> nightshift/{core,owl,raven,infra}/*.py Pentest tasks created (4): - #194: budget limiter triple-failure (CONFIRMED) - #195: python3 -c path interpolation (CONFIRMED) - #196: .recursive.json prompt guard (THEORETICAL) - #197: costs.json negative value validation (THEORETICAL)
fazxes
added a commit
that referenced
this pull request
Apr 9, 2026
…one) Queue before: 72 pending + 9 wontfix-in-active-dir Queue after: 65 pending + 0 wontfix (all converted to done for archiving) Merged into primary tasks (5 closures): - #175 -> #174: both add tests to TestAuthFailureDetection, same PR - #163 -> #162: both are scoring module tests from PR #158 review, same PR - #124 -> #122: both validate doc snapshot consistency, same PR scope - #196 -> #173: both add entries to PROMPT_GUARD_FILES in lib-agent.sh - #180 -> #179: both touch _is_valid_eval_file() in pick-role.py, same PR Closed as obsolete (1): - #78: references non-existent "evolve.md Step 8" and the multi-agent review panel replaced by unified review in PR #107 Closed as low-value (1): - #230: _DELEGATION_ROLE_MAP covers all 8 current agent types; new agent types require major framework work making the map update obvious Converted wontfix -> done for archiving (9): - #77, #80, #107, #111, #115, #119, #127, #129, #134 All had wontfix status with rationale already documented; changed to done so daemon's archive_done_tasks() housekeeping removes them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pick_session_role()indaemon.shpreviously merged stdout and stderr frompick-role.pyvia2>&1, then usedtail -1to extractSESSION_ROLE. Any unexpected stdout line (atexit handler, uncaught exception aftersys.exit, future library print) would corruptSESSION_ROLEto garbage, silently falling back tobuildfor all subsequent cycles — losing OVERSEE, STRATEGIZE, and ACHIEVE scheduling until a human debugged it.pick-role.pyalready separates concerns: role name → stdout, reasoning log → stderr. The fix routes stderr throughmktempso stdout is clean.TestPickSessionRoleStderrSeparation._require_int()inconfig.pyrejects non-integereval_frequencybefore reaching the shell arithmetic.Changes
scripts/daemon.sh:pick_session_role()usesmktempinstead of2>&1tests/test_nightshift.py: 2 new contract testsdocs/autonomy/2026-04-07.md: Autonomy report with score, false-positive analysisdocs/changelog/v0.0.8.md: Entry for this fixdocs/learnings/2026-04-07-stdout-stderr-separation-role-selection.md: Learningdocs/handoffs/LATEST.md: Handoff for next sessionTest plan
make checkpasses: 1134 tests, all checkspython3 -m nightshift run --dry-run --agent codexOKpython3 -m nightshift run --dry-run --agent claudeOKtest_pick_session_role_does_not_merge_stderr_into_stdoutpassestest_pick_session_role_captures_stderr_via_temp_filepasses