Skip to content

fix(test): isolate memlab harness daemon runtime - #2197

Open
astandrik wants to merge 1 commit into
DeusData:mainfrom
astandrik:fix/1696-memlab-runtime-isolation
Open

fix(test): isolate memlab harness daemon runtime#2197
astandrik wants to merge 1 commit into
DeusData:mainfrom
astandrik:fix/1696-memlab-runtime-isolation

Conversation

@astandrik

Copy link
Copy Markdown
Contributor

What does this PR do?

Part of #1696 (audit ledger), follow-up to #1691/#1695.

scripts/memlab.sh gave the profiled run a private CBM_CACHE_DIR only, so the
process joined the operator's account daemon (refused with a cache-root conflict
when one was live; otherwise left as the account daemon while cleanup() removed
its cache underneath it).

  • scripts/memlab.sh sources scripts/test-runtime.sh, calls
    cbm_test_runtime_init and runs cbm_test_runtime_cleanup "$BINARY" before
    removing its work directory (the native-Windows copy of the binary lives there).
    Off native Windows the helper's cache is the cache; the log fold-in reads from it.
  • tests/test_memlab_runtime_isolation_contract.sh: memlab launches the product
    through its Python driver, which passes the environment through unchanged
    (memlab-drive.py uses no env=; the test pins that), so the contract shims
    python3 and records the environment at the driver boundary. This keeps it
    deterministic on Windows CI, where the native Python cannot exec a shell fixture.
    Fails on main with FAIL: memlab exposed the caller CBM_RUNTIME_DIR to the product; passes with this change. Wired as Step 0g2 in scripts/test.sh.

Observation, not changed here: scripts/memlab.sh is tracked without an executable
bit although its usage line invokes it directly; the contract runs it through bash.

Checklist

  • Every commit is signed off (git commit -s)
  • Tests pass locally (make -f Makefile.cbm test) — shell-only change; the new
    contract plus test_venue_parity_contract and test_runtime_isolation_contract
    were run; the full C suite was not run on this host
  • Lint passes (make -f Makefile.cbm lint-ci) — no C changes
  • New behavior is covered by a test (reproduce-first for bug fixes)

scripts/memlab.sh gave the profiled run a private CBM_CACHE_DIR only, so
the process joined the operator's account daemon and cleanup removed the
cache without stopping any daemon. Source scripts/test-runtime.sh for a
harness-owned runtime and cache, and stop the private daemon before the
work directory is removed.

Add tests/test_memlab_runtime_isolation_contract.sh, which fails before
this change, and wire it into scripts/test.sh.

Part of DeusData#1696.

Signed-off-by: Anton Standrik <astandrik@yandex-team.ru>
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Fixes memlab harness runtime isolation so profiled runs don’t attach to (or disrupt) the operator’s daemon, and adds a contract test to prevent regressions.

Changes:

  • Initialize/cleanup an isolated test runtime (runtime dir + cache) in scripts/memlab.sh.
  • Adjust memlab log folding to read logs from the isolated cache location.
  • Add a deterministic contract test and wire it into scripts/test.sh.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
scripts/memlab.sh Uses shared runtime helper to isolate daemon rendezvous/cache and updates log collection pathing.
tests/test_memlab_runtime_isolation_contract.sh New contract test that asserts memlab doesn’t leak caller runtime/cache into the launched environment.
scripts/test.sh Runs the new contract test as part of the shell test steps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/memlab.sh
CACHE_HOST="$WORK/cache"
else
export CBM_CACHE_DIR="$WORK/cache"
CACHE_HOST="$CBM_TEST_CACHE_DIR_HOST"
Comment thread scripts/memlab.sh
# With CBM_CACHE_DIR set the process logs to its own file rather than stderr,
# so fold that in or the census series is invisible.
cat "$WORK"/cache/logs/*.log >> "$RUN_LOG" 2>/dev/null || true
cat "$CACHE_HOST"/logs/*.log >> "$RUN_LOG" 2>/dev/null || true
Comment thread scripts/memlab.sh
Comment on lines +33 to 37
source "$(dirname "$0")/test-runtime.sh"
cbm_test_runtime_init || exit 1
trap 'cbm_test_runtime_cleanup "$BINARY"' EXIT

WORK=$(mktemp -d 2>/dev/null || mktemp -d -t memlab)
Comment thread scripts/memlab.sh
Comment on lines +88 to 94
cleanup() {
# The helper probes with $BINARY, whose native-Windows copy lives in $WORK.
cbm_test_runtime_cleanup "$BINARY"
rm -rf "$WORK" 2>/dev/null || true
rm -rf "${WIN_ROOT:-}" 2>/dev/null || true
}
trap cleanup EXIT
Comment on lines +37 to +38
if grep -q 'env=' "$ROOT/scripts/memlab-drive.py"; then
fail "memlab-drive.py no longer passes the harness environment through unchanged"
Comment on lines +73 to +76
private_root=""
while IFS=$'\t' read -r child_cache_raw child_runtime_raw; do
child_cache=$(normalize_path "$child_cache_raw")
child_runtime=$(normalize_path "$child_runtime_raw")
"${child_runtime##*/}" != "runtime" || "${child_cache##*/}" != "cache" ]]; then
fail "memlab runtime/cache were not isolated beneath one private root"
fi
private_root="${child_runtime%/*}"
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.

2 participants