-
Notifications
You must be signed in to change notification settings - Fork 7
feat(backup): add verified opt-in iCloud leg #821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
435fe81
0b7ad0f
528b087
78a30c1
dbba956
ed20229
ed40d8c
9e5feb7
81299ed
9e482db
3cf494c
0b1b645
72a1b61
7d046e3
cee6fe3
2c12fe5
d662cc7
3742ef5
454bb36
0cb037e
fcb5ad0
fbdc01f
f566466
177b61e
a958bfe
0a78ab4
0d7ddd0
5ae8e0b
1094047
f70fcd9
74a77ac
bbc8764
966ff50
e735ae2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,9 @@ | |
| </array> | ||
| <key>ProgramArguments</key> | ||
| <array> | ||
| <string>/usr/bin/env</string> | ||
| <string>python3</string> | ||
| <!-- Rendered through hook_python.resolve_hook_python so ARM and Intel Homebrew | ||
| prefixes both use the keg interpreter and never resolve Python through PATH. --> | ||
| <string>__BRAINLAYER_PYTHON__</string> | ||
|
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the job is installed through AGENTS.md reference: AGENTS.md:L152-L158 Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in — brainlayerCodex-e2cecfb5 (worker) · codex/gpt-5.6-sol |
||
| <string>-m</string> | ||
| <string>brainlayer.jsonl_backup</string> | ||
| </array> | ||
|
|
@@ -30,8 +31,6 @@ | |
| <dict> | ||
| <key>PATH</key> | ||
| <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:__HOME__/.local/bin</string> | ||
| <key>PYTHONPATH</key> | ||
| <string>__BRAINLAYER_DIR__/src</string> | ||
| <key>BRAINLAYER_BACKUP_TIMEOUT_SECONDS</key> | ||
| <string>1800</string> | ||
| <key>BRAINLAYER_JSONL_BACKUP_DRIVE_FOLDER</key> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,11 +138,45 @@ fi | |
| # PATH happens to front. On the M4 that is the framework Python's `brainlayer`, and installing from a | ||
| # source checkout fronts `~/Gits/brainlayer/.venv/bin/brainlayer` -- neither of which any release moves. | ||
| BRAINLAYER_BIN="$(stable_brainlayer_path "${BRAINLAYER_BIN:-${BRAINLAYER_KEG_CLI:-$(which brainlayer 2>/dev/null || echo "$HOME/.local/bin/brainlayer")}}")" | ||
| # Capture only caller intent before PYTHON_BIN receives its legacy PATH fallback. | ||
| BRAINLAYER_PYTHON_REQUESTED="${BRAINLAYER_PYTHON:-}" | ||
| # In a keg, an unset PYTHON_BIN must NOT fall through to `command -v python3`: on a Mac whose PATH | ||
| # puts /Library/Frameworks/Python.framework first, that renders a framework interpreter that never | ||
| # sees the keg's site-packages, and no release can move it. An explicit override still wins. | ||
| PYTHON_BIN="$(stable_brainlayer_path "${PYTHON_BIN:-${BRAINLAYER_KEG_PYTHON:-$(command -v python3)}}")" | ||
| # The backup wrappers import BrainLayer itself, so a source install must not inherit | ||
| # `command -v python3`: on the M4 that is the framework interpreter whose global | ||
| # .pth injects the mutable root checkout. Explicit overrides remain explicit; a keg | ||
| # uses its stable opt/ path; otherwise reuse hook_python's ARM/Intel-aware resolver | ||
| # and fail closed when neither Homebrew prefix exists. | ||
| BRAINLAYER_PYTHON="$(stable_brainlayer_path "${BRAINLAYER_PYTHON:-$PYTHON_BIN}")" | ||
|
|
||
| resolve_jsonl_backup_python() { | ||
| if [ -n "$BRAINLAYER_KEG_PYTHON" ] && [ -z "$BRAINLAYER_PYTHON_REQUESTED" ] && [ -z "${BRAINLAYER_HOOK_PYTHON:-}" ]; then | ||
| BRAINLAYER_PYTHON="$(stable_brainlayer_path "$BRAINLAYER_KEG_PYTHON")" | ||
| return 0 | ||
| fi | ||
|
|
||
| HOOK_PYTHON_RESOLVER="$BRAINLAYER_DIR/src/brainlayer/hook_python.py" | ||
| if [ ! -f "$HOOK_PYTHON_RESOLVER" ]; then | ||
| HOOK_PYTHON_RESOLVER="$BRAINLAYER_DIR/brainlayer/hook_python.py" | ||
| fi | ||
| if [ ! -f "$HOOK_PYTHON_RESOLVER" ]; then | ||
| echo "ERROR: hook_python.py not found; refusing a PATH-derived BrainLayer interpreter" >&2 | ||
| return 1 | ||
| fi | ||
|
|
||
| # `python hook_python.py` would put brainlayer/ itself on sys.path, where | ||
| # brainlayer/types.py shadows the stdlib `types` module under Apple's Python. | ||
| # run_path keeps the resolver executable as a standalone stdlib-only script | ||
| # without adding its package directory to import resolution. | ||
| if [ -n "$BRAINLAYER_PYTHON_REQUESTED" ]; then | ||
| BRAINLAYER_PYTHON="$(BRAINLAYER_HOOK_PYTHON="$BRAINLAYER_PYTHON_REQUESTED" /usr/bin/python3 -c 'import runpy, sys; path = sys.argv.pop(1); runpy.run_path(path, run_name="__main__")' "$HOOK_PYTHON_RESOLVER" --print-interpreter)" || return 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High Both branches execute 🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disproved against the exact source and host interpreter: — brainlayerCodex-e2cecfb5 (worker) · codex/gpt-5.6-sol |
||
| else | ||
| BRAINLAYER_PYTHON="$(/usr/bin/python3 -c 'import runpy, sys; path = sys.argv.pop(1); runpy.run_path(path, run_name="__main__")' "$HOOK_PYTHON_RESOLVER" --print-interpreter)" || return 1 | ||
|
Comment on lines
+173
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an accepted explicit interpreter path contains a legal filename character such as AGENTS.md reference: AGENTS.md:L33-L36 Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in — brainlayerCodex-e2cecfb5 (worker) · codex/gpt-5.6-sol
Comment on lines
+173
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an explicit Useful? React with 👍 / 👎.
Comment on lines
+173
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When installing Useful? React with 👍 / 👎. |
||
| fi | ||
| BRAINLAYER_PYTHON="$(stable_brainlayer_path "$BRAINLAYER_PYTHON")" | ||
| } | ||
| BRAINLAYER_ENV_FILE="${BRAINLAYER_ENV_FILE:-$HOME/.config/brainlayer/brainlayer.env}" | ||
| BRAINLAYER_ENV_RUN="$BRAINLAYER_LIB_DIR/brainlayer-env-run.sh" | ||
| TIER0_WATCHDOG_DST="$BRAINLAYER_LIB_DIR/tier0-watchdog.sh" | ||
|
|
@@ -622,14 +656,21 @@ install_plist() { | |
| verify_gemini_env_file || return 1 | ||
| fi | ||
|
|
||
| # XML-escape the interpreter path, then escape sed replacement metacharacters. | ||
| # `&` is legal in a filename but means "the matched placeholder" to sed. | ||
| local brainlayer_python_xml | ||
| local brainlayer_python_sed | ||
| brainlayer_python_xml="$(printf '%s' "$BRAINLAYER_PYTHON" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g')" || return 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Reject XML 1.0-forbidden characters before rendering. When 🤖 Prompt for AI Agents |
||
| brainlayer_python_sed="$(printf '%s' "$brainlayer_python_xml" | sed -e 's/[\\&|]/\\&/g')" || return 1 | ||
|
|
||
| # Replace placeholders | ||
| sed \ | ||
| -e "s|__HOME__|$HOME|g" \ | ||
| -e "s|__BRAINLAYER_BIN__|$BRAINLAYER_BIN|g" \ | ||
| -e "s|__BRAINLAYER_DIR__|$BRAINLAYER_DIR|g" \ | ||
| -e "s|__BRAINLAYER_LAUNCHD_DIR__|$BRAINLAYER_LAUNCHD_DIR|g" \ | ||
| -e "s|__PYTHON_BIN__|$PYTHON_BIN|g" \ | ||
| -e "s|__BRAINLAYER_PYTHON__|$BRAINLAYER_PYTHON|g" \ | ||
| -e "s|__BRAINLAYER_PYTHON__|$brainlayer_python_sed|g" \ | ||
| -e "s|__REPO_ROOT__|$BRAINLAYER_DIR|g" \ | ||
| -e "s|__BRAINLAYER_ENV_FILE__|$BRAINLAYER_ENV_FILE|g" \ | ||
| -e "s|__BRAINLAYER_ENV_RUN__|$BRAINLAYER_ENV_RUN|g" \ | ||
|
|
@@ -692,6 +733,8 @@ install_jsonl_backup_script() { | |
| return 1 | ||
| fi | ||
|
|
||
| resolve_jsonl_backup_python || return 1 | ||
|
|
||
| escaped_brainlayer_dir="$(printf '%s' "$BRAINLAYER_DIR" | sed 's/[\\&|]/\\&/g')" || return 1 | ||
| sed \ | ||
| -e "s|__BRAINLAYER_DIR_VALUE__|$escaped_brainlayer_dir|g" \ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,7 @@ export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:$HOME/.local/bin" | |
| export PYTHONUNBUFFERED=1 | ||
| : "${BRAINLAYER_BACKUP_TIMEOUT_SECONDS:=1800}" | ||
| export BRAINLAYER_BACKUP_TIMEOUT_SECONDS | ||
| BRAINLAYER_DIR="${BRAINLAYER_DIR:-__BRAINLAYER_DIR_VALUE__}" | ||
| case "$BRAINLAYER_DIR" in | ||
| __BRAINLAYER_DIR_*) BRAINLAYER_DIR="$HOME/Gits/brainlayer" ;; | ||
| esac | ||
| export PYTHONPATH="$BRAINLAYER_DIR/src${PYTHONPATH:+:$PYTHONPATH}" | ||
| : "${BRAINLAYER_PYTHON:?installer must render the prefix-aware keg interpreter}" | ||
| unset PYTHONPATH | ||
|
|
||
| exec "${BRAINLAYER_PYTHON:-python3}" -m brainlayer.jsonl_backup | ||
| exec "$BRAINLAYER_PYTHON" -m brainlayer.jsonl_backup | ||
|
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L152-L158 Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in The JSONL backup interpreter no longer inherits the installer's Verification: focused lane — brainlayerCodex-e2cecfb5 (worker) · codex/gpt-5.6-sol
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L152-L158 Useful? React with 👍 / 👎. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository-wide launchd search shows
scripts/launchd/install.sh::install_plistreads onlyscripts/launchd/com.brainlayer.jsonl-backup.plist, not this template orrender_launchd_plist. That deployed template still invokesscripts/launchd/jsonl-backup.sh, which exports$BRAINLAYER_DIR/srcthroughPYTHONPATH; therefore even its keg interpreter imports the live checkout, and these changes do not protect the installed backup job from stale or agent-edited root code. Apply the change to the deployed template/wrapper and its actual rendering path.AGENTS.md reference: AGENTS.md:L152-L158
Useful? React with 👍 / 👎.