Files
openhuman/scripts/review/fix.sh
T
c59b4289f1 refactor(config): extract env lookup seam for testability (#792)
## Summary

- Introduce an `EnvLookup` seam in `src/openhuman/config/schema/load.rs`.
- Route env-overlay reads through `EnvLookup`/`ProcessEnv` while preserving existing precedence and runtime behavior.
- Add focused parallel-safe unit coverage for config env overlay behavior without mutating process env.

## Problem

- `Config::apply_env_overrides` mixed environment access, override logic, and global side effects.
- That made precedence and parsing behavior harder to unit test in isolation and forced reliance on process-env mutation.

## Solution

- Add `pub(crate) trait EnvLookup` with `get`, `contains`, and `get_any`, plus a production `ProcessEnv` implementation.
- Delegate overlay logic through `apply_env_overlay_with(&ProcessEnv)` and keep side effects in the small wrapper.
- Add focused tests covering precedence, parsing, defaults, and legacy-migration interactions with no global env mutation.

## Submission Checklist

- [x] **Unit tests** — Targeted Rust config tests added and broader related module suites passed
- [ ] **E2E / integration** — Not applicable; this refactor preserves existing behavior and improves unit-level testability
- [x] **N/A** — E2E is not applicable because no user-visible or cross-process flow changed
- [ ] **Doc comments** — Not applicable; internal refactor in existing module only
- [ ] **Inline comments** — Not applicable; logic remains local and test coverage documents behavior

## Impact

- No intended runtime behavior change; refactor keeps config precedence intact.
- Improves maintainability and makes future config/workspace resolution seams easier to test safely.

## Related

- Issue(s):
- Follow-up PR(s)/TODOs: thread `EnvLookup` through runtime config directory resolution helpers

Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
2026-04-23 13:42:02 -07:00

53 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# fix.sh <pr-number> [--executor-llm <tool>] [extra-prompt]
# Sync the PR, run pr-reviewer to identify issues and apply fixes, then hand
# off to pr-manager-lite to run the quality suite, commit, and push.
#
# --executor-llm picks the CLI that drives the agent. Default: claude.
# A trailing positional <extra-prompt> (any free-form text) is appended to the
# executor's prompt verbatim.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib.sh
source "$here/lib.sh"
require git gh jq
require_pr_number "${1:-}"
pr="$1"
executor_llm="claude"
extra_prompt=""
shift
while [ $# -gt 0 ]; do
case "$1" in
--executor-llm) executor_llm="${2:?--executor-llm requires a value}"; shift 2 ;;
--executor-llm=*) executor_llm="${1#*=}"; shift ;;
*)
if [ -n "$extra_prompt" ]; then
echo "[review] unexpected extra arg: $1 (extra-prompt already set)" >&2
exit 1
fi
extra_prompt="$1"; shift
;;
esac
done
require "$executor_llm"
sync_pr "$pr"
prompt="I've already checked out branch pr/$REVIEW_PR with main \
merged in and upstream tracking set (repo: $REVIEW_REPO_RESOLVED). Use the \
pr-reviewer agent to review PR #$REVIEW_PR and fix the issues it finds. Then \
use the pr-manager-lite agent to run the quality suite, commit, and push the \
changes back to the PR branch."
if [ -n "$extra_prompt" ]; then
prompt="${prompt}
Additional instructions from the user:
${extra_prompt}"
fi
"$executor_llm" "$prompt"