Make mnemon reachable inside the sandbox via the opt-in EXTRA_* mechanism#4
Open
audreyt wants to merge 3 commits into
Open
Make mnemon reachable inside the sandbox via the opt-in EXTRA_* mechanism#4audreyt wants to merge 3 commits into
audreyt wants to merge 3 commits into
Conversation
…nism
The wrapper had a dedicated MNEMON_RULES carve-out block that allowlisted
omp's mnemon store (subpath read+write + $HOME-ancestor metadata stats)
unconditionally. On a real-dir-at-~/.mnemon setup this is functionally
redundant with the general OMP_SANDBOX_EXTRA_WRITE / EXTRA_READ opt-in:
both produce byte-identical (subpath "$HOME/.mnemon") rules, and the
per-ancestor stat() walk that justified the ancestor-literal lines only
applied in the symlink-into-~/.local era, which is gone (the store is now
a real dir at the default $HOME/.mnemon).
Remove the carve-out. mnemon is now opt-in: a user who wants recall (and
remember) inside the sandbox sets the same knob they use for any other
extra writable/readable path, e.g. in ~/.zshrc:
export OMP_SANDBOX_EXTRA_WRITE="$HOME/.mnemon"
export OMP_SANDBOX_EXTRA_READ="$HOME/.mnemon" # or inherit from WRITE
This is necessary, not stylistic: Seatbelt file-write* and file-read* are
independent classes — a path in EXTRA_WRITE but not EXTRA_READ is
write-allowed-yet-read-denied, which breaks SQLite WAL and
read-modify-write patterns. EXTRA_READ inheriting EXTRA_WRITE (the
~/.zshrc that ships this) is the safe default.
Drop the now-unused MNEMON_DATA_DIR env forward and NO_MNEMON opt-out: the
real-dir-at-default store needs neither (mnemon resolves ~/.mnemon itself
given $HOME, which the existing home-node metadata rule already covers).
Harden the self-test so this stays true. The previous "fold ~/.mnemon into
EXTRA_* then gen_profile" was a no-op in-process (EXTRA_RULES are computed
once at script entry; re-exporting the env var does not recompute the shell
var gen_profile interpolates), and test 15 only passed as a side effect of
test 13's clobber-then-restore of $PROFILE via a fresh --print-profile
subprocess — reorder the tests and it would silently break.
- Refactor EXTRA_RULES / EXTRA_READ_RULES build into a
_sbx_build_extra_rules() function (called at top level and again from
the self-test fold).
- Make test 15 self-contained: it generates its OWN profile via a fresh
"$0" --print-profile with EXTRA_*=~/.mnemon, then asserts recall
RETURNED a result (greps JSON for '"id"'), not just exit 0 — `mnemon
recall` can exit 0 with empty output on failure modes, which would
otherwise be a false pass.
- Capture the user's entry EXTRA_* so test 13's restore step restores
$PROFILE to the pre-canary state, no longer touching mnemon.
Verified in a truly clean env (env -i, no EXTRA_*):
- bash -n and /bin/bash -n (Apple stock 3.2): clean.
- --self-test: 21 PASS, lone FAIL is the pre-existing unrelated
--auto-approve omp-version issue.
- test 15 detects its defect: forced-no-mnemon profile -> FAIL; reordered
before test 13 -> still PASS (order-independent).
- production --print-profile + recall with EXTRA_*=~/.mnemon returns 1
real result; no phantom ~/.local/share/mnemon recreated.
- Permitted sandboxed processes to read the user's .bun directory alongside workspace and OMP data.
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
Makes mnemon (recall + remember) reachable inside the sandbox via the general opt-in
OMP_SANDBOX_EXTRA_WRITE/EXTRA_READmechanism — the same knob users already use for any other extra writable/readable path.On the real-dir-at-
~/.mnemonsetup (the symlink-into-~/.localera is over), the carve-out was functionally redundant withEXTRA_*: both produce byte-identical(subpath "$HOME/.mnemon")rules, and the per-$HOME-ancestorstat()walk that justified the ancestor-literal lines only applied to the symlink setup.Behavior change (intended, opt-in)
mnemon is no longer automatic. A user who wants recall/remember inside the sandbox sets:
EXTRA_READmust cover everyEXTRA_WRITEpath: Seatbeltfile-write*andfile-read*are independent classes — a path inEXTRA_WRITEbut notEXTRA_READis write-allowed-yet-read-denied, which breaks SQLite WAL and read-modify-write patterns. The~/.zshrcshipped with this repo setsEXTRA_READto inheritEXTRA_WRITE, which is the safe default.MNEMON_DATA_DIRenv forward and theOMP_SANDBOX_NO_MNEMONopt-out are dropped — neither is needed once the store is a real dir at the default path (mnemon resolves~/.mnemonitself given$HOME, which the existing home-node metadata rule already covers).Self-test hardening
The previous "fold
~/.mnemonintoEXTRA_*thengen_profile" was a no-op in-process (EXTRA_RULEScomputed once at script entry; re-exporting the env var does not recompute the shell vargen_profileinterpolates), and test 15 only passed as a side effect of test 13's clobber-then-restore of$PROFILEvia a fresh--print-profilesubprocess — reorder the tests and it would silently break._sbx_build_extra_rules()refactored into a function, called at top level and re-callable from the self-test."$0" --print-profilewithEXTRA_*=~/.mnemon, then asserts recall returned a result (greps JSON for"id"), not just exit 0 —mnemon recallcan exit 0 with empty output on failure modes, which would otherwise be a false pass.$PROFILEto the pre-canary entry state (captured_entry_x*), no longer touching mnemon.Verification (truly clean env —
env -i, noEXTRA_*)bash -nand/bin/bash -n(Apple stock bash 3.2): clean.--self-test: 21 PASS. Lone FAIL is the pre-existing, unrelated--auto-approve flag accepted by omp (clean env)(omp version issue, not mnemon).FAIL(no false pass).PASS.EXTRA_*=~/.mnemon):--print-profileshows~/.mnemonin write+read;mnemon recall jensenreturns 1 real result. No phantom~/.local/share/mnemonrecreated.Files
omp-sandboxed | 132 +-— refactor + self-test restructure + header comment refresh.README.md | +7— reframe write/read allowlist tables to "opt-in viaEXTRA_*"; add a mnemon example.Draft vs review
Marked ready for review.
maintainer_can_modifyis enabled so you can adjust on your end if needed.