Skip to content

feat: build healer meta-layer observer inside daemon loop#49

Merged
fazxes merged 2 commits intomainfrom
feat/healer-observer
Apr 5, 2026
Merged

feat: build healer meta-layer observer inside daemon loop#49
fazxes merged 2 commits intomainfrom
feat/healer-observer

Conversation

@fazxes
Copy link
Copy Markdown
Member

@fazxes fazxes commented Apr 5, 2026

Summary

  • Build the Healer (task docs: add task #0043 — agent-to-agent CONTRIBUTING.md #46, urgent) -- a lightweight agent call in the builder daemon that runs between sessions to observe system health
  • Healer reads last handoff, session index, task queue, vision tracker, and learnings to identify patterns, trends, and upcoming problems
  • Writes observations to docs/healer/log.md and creates follow-up tasks in docs/tasks/ using .next-id
  • Persists outputs via persist_healer_changes() (branch+PR+merge workflow)
  • Protected by prompt guard (healer.md added to PROMPT_GUARD_FILES)
  • 9 new tests, 659 total passing, all checks green

Test plan

  • make check passes (659 tests, ruff, mypy, dry-run, shell syntax, ASCII check, install refs)
  • Shell syntax validated (bash -n scripts/daemon.sh, bash -n scripts/lib-agent.sh)
  • Tests verify: prompt exists, required sections present, boundaries defined, log exists, daemon references healer, healer runs before prompt guard, prompt guard includes healer.md, persist function defined, max-turns <= 20
  • First real daemon run will validate end-to-end behavior

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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/daemon.sh
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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread scripts/daemon.sh
echo " Healer done."
persist_healer_changes "$SESSION_ID"
else
echo " Healer exited with code $HEALER_EXIT (non-fatal, continuing)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
@fazxes fazxes merged commit ef79193 into main Apr 5, 2026
@fazxes fazxes deleted the feat/healer-observer branch April 5, 2026 04:59
fazxes added a commit that referenced this pull request Apr 5, 2026
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.
fazxes added a commit that referenced this pull request Apr 5, 2026
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.

1 participant