feat: build healer meta-layer observer inside daemon loop#49
Conversation
Add a lightweight agent call between sessions in the builder daemon that observes system health, identifies patterns and trends, and creates follow-up tasks. The healer reads the last handoff, session index, task queue, vision tracker, and learnings to spot problems that no single builder session would catch. - docs/prompt/healer.md: self-contained healer prompt - docs/healer/log.md: observation journal - scripts/daemon.sh: healer call between housekeeping and builder - scripts/lib-agent.sh: persist_healer_changes() for branch+PR+merge of healer outputs, healer.md added to PROMPT_GUARD_FILES - 9 new tests validating healer infrastructure wiring - Task #46 done. 659 tests passing.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bfd96be2e
ℹ️ 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".
| HEALER_LOG="$LOG_DIR/${SESSION_ID}-healer.log" | ||
| HEALER_MAX_TURNS=15 | ||
| echo " Running healer (max ${HEALER_MAX_TURNS} turns)..." | ||
| run_agent "$AGENT" "$(cat "$HEALER_PROMPT_FILE")" "$HEALER_LOG" "$HEALER_MAX_TURNS" |
There was a problem hiding this comment.
Capture prompt snapshots before invoking healer
The healer agent is executed before save_prompt_snapshots, so the prompt guard baseline is taken only after an untrusted agent has already had write access. If healer modifies any guarded control file (for example CLAUDE.md or files under docs/prompt/ due prompt drift or a partial failure), check_prompt_integrity will compare against the already-mutated snapshot and miss the tampering, allowing those changes to silently affect the subsequent builder run.
Useful? React with 👍 / 👎.
| echo " Healer done." | ||
| persist_healer_changes "$SESSION_ID" | ||
| else | ||
| echo " Healer exited with code $HEALER_EXIT (non-fatal, continuing)" |
There was a problem hiding this comment.
Clean working tree after healer non-zero exit
On healer failure, the daemon logs and continues without restoring the repository state. Because an agent can make file edits before returning a non-zero code, the builder phase can start from a dirty tree and accidentally include partial healer output (or other unintended edits) in its own session, making results nondeterministic whenever healer exits non-zero.
Useful? React with 👍 / 👎.
…asks Address code review Issue 1 from PR #49: gh pr merge now receives the explicit PR number extracted from gh pr create output, avoiding a race condition where the PR might not be indexed yet. Follow-up tasks from review: - #54: Document healer in OPERATIONS.md - #55: Add healer log rotation - #56: Harden persist error paths
Build nightshift/evaluation.py that scores nightshift runs across 10 dimensions (Startup, Discovery, Fix quality, Shift log, State file, Verification, Guard rails, Clean state, Breadth, Usefulness). Pure-function scorer pattern: each scorer takes ShiftArtifacts and returns DimensionScore with no I/O. All external interaction (clone, run shift, parse artifacts) happens at the boundary functions. Daemon integration via should_evaluate() and run_evaluation() in lib-agent.sh, wired into daemon.sh after cost tracking. Configurable via .nightshift.json (eval_frequency, eval_target_repo). Also fixes: validate-docs.sh now accounts for weighted partial progress from In Progress items in tracker percentage checks. Previously only counted Done items, causing false failures on sections with partial work. 66 new tests (880 total). Task #49.
Summary
docs/healer/log.mdand creates follow-up tasks indocs/tasks/using.next-idpersist_healer_changes()(branch+PR+merge workflow)Test plan
make checkpasses (659 tests, ruff, mypy, dry-run, shell syntax, ASCII check, install refs)bash -n scripts/daemon.sh,bash -n scripts/lib-agent.sh)