Skip to content

test(version-check): scrub BRAINLAYER_VERSION_CHECK_* from the subprocess env, and pin the mirror sibling case (XS) - #772

Merged
EtanHey merged 3 commits into
mainfrom
fix/version-check-env-scrub
Sep 5, 2026
Merged

test(version-check): scrub BRAINLAYER_VERSION_CHECK_* from the subprocess env, and pin the mirror sibling case (XS)#772
EtanHey merged 3 commits into
mainfrom
fix/version-check-env-scrub

Conversation

@EtanHey

@EtanHey EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner

What forced this PR

tests/test_version_consistency.py ran scripts/brainlayer-version-check.sh in a subprocess with
the inherited environment. A release operator has BRAINLAYER_VERSION_CHECK_CASK_LAG_REASON
exported — they need it for the real release check — so pre-push → pytest → the script saw that
reason, allowed the cask lag, and returned 0. The two tests that assert the script fails on a
lagging or drifting cask without a stated reason then went RED for a change that had nothing to
do with them:

  • test_version_check_fails_loudly_when_cask_version_drifts (cask 0.0.0)
  • test_version_check_still_fails_for_a_lagging_cask_without_a_reason (cask 1.5.9)

Loud, not silent — but it is the same non-hermetic-env class the sibling
tests/test_run_tests_script.py::_script_env() already solves for BRAINLAYER_CHANGED_FILES.

The change

  1. One helper, _script_env(), builds the subprocess env from a scrubbed copy of os.environ, and
    every subprocess call in the file goes through it (it replaces _clean_git_env()).
  2. The scrub is by prefix, not by the one variable that bit us: BRAINLAYER_VERSION_CHECK_*
    alongside the existing GIT_*. REPO_ROOT, TAP_ROOT and GIT_TAG are the script's other
    knobs and would steer these fixtures elsewhere in exactly the same way — scrubbing only the lag
    reason just queues up the next instance. Tests that want a knob still pass it explicitly via
    extra_env / git_tag, which override the scrubbed base.
  3. Adds the missing import pytest. pytest.MonkeyPatch was already referenced in an annotation
    and survived only because from __future__ import annotations never evaluates it.

No change to scripts/brainlayer-version-check.sh.

Folded in: the mirror sibling case from the #762 round-1 review

The round-1 review on #762 asked for the missing-sibling regression and got the test_build_sha.py
half. Nothing pinned the other direction, so a mapping that kept mapped=1 when only
test_build_sha.py existed would still have looked covered — import path gated, the six version
sites and the cask-lag reason not gated at all.
test_changed_only_scope_escalates_when_the_version_consistency_sibling_is_missing pins it.

The script is already correct in both directions; only one direction was tested. Verified by
mutation rather than asserted: narrowing the src/brainlayer/__init__.py case to build-sha alone
turns the new test RED (1 failed, 1 passed) while the existing build-sha-sibling test stays
green — they cover different directions. Script restored, git diff scripts/run_tests.sh empty.

Evidence

  • RED first. BRAINLAYER_VERSION_CHECK_CASK_LAG_REASON="operator export" pytest tests/test_version_consistency.py4 failed / 12 passed (the two pre-existing tests
    reproducing the reported defect, plus both new ones). After the fix: 16 passed, with the var
    exported and without it.
  • tests/test_version_consistency.py + tests/test_run_tests_script.py39 passed.
  • ruff check clean; ruff format --check tests/ src/ → 482 files already formatted.
  • Scoped pre-push gate on this branch, green: BRAINLAYER_PREPUSH_SCOPE=changed-only with
    BRAINLAYER_CHANGED_FILES naming both touched files — 39 passed, registration, isolated 40
    passed, bun 1 pass, fts5 determinism shell → "BrainLayer test gate passed."

Size

XS — tests only: 2 test files, 1 helper rename + prefix scrub, 3 new tests.

@coderabbitai review


Opened by brainlayerClaude-19a28f09 running claude-opus-5.


Note

Low Risk
Tests-only changes that improve subprocess env isolation and pre-push mapping coverage; no production script or runtime behavior changes.

Overview
Fixes non-hermetic version-check tests that inherited a release operator’s BRAINLAYER_VERSION_CHECK_* exports (especially cask-lag reason), which could make “must fail without a reason” cases pass spuriously.

In test_version_consistency.py, _clean_git_env() becomes _script_env(), stripping GIT_* and BRAINLAYER_VERSION_CHECK_* by prefix before every subprocess; fixtures still pass knobs via extra_env / git_tag. Adds regressions for inherited lag reason and full prefix scrub, plus import pytest for MonkeyPatch.

test_kg_judge.py replaces a brittle substring guard with _drops_inherited_git_env (parametrized) so git-shellout tests must drop GIT_* (including tuple-based scrubbers that still lead with GIT_) and may use _script_env alongside the existing clean-env helpers.

test_run_tests_script.py adds the mirror of the missing test_build_sha.py case: changed-only scope on src/brainlayer/__init__.py must escalate to the full suite when test_version_consistency.py is absent.

Production brainlayer-version-check.sh is unchanged; only test isolation and coverage.

Reviewed by Cursor Bugbot for commit 260d431. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Scrub BRAINLAYER_VERSION_CHECK_* from test subprocess env and pin version-consistency sibling escalation case

  • Renames the git-only env helper to _script_env in test_version_consistency.py and broadens it to strip both GIT_- and BRAINLAYER_VERSION_CHECK_-prefixed variables from all fixture subprocess environments, including version-check invocations via _run, repo git lookups, and repo init fixtures.
  • Adds a _drops_inherited_git_env source-text predicate and guard tests in test_kg_judge.py to ensure git-shellout fixtures actually drop inherited GIT_ variables in either direct or tuple-based filter form, and to recognize the _script_env helper name.
  • Adds a regression test in test_run_tests_script.py verifying that changed-only pre-push execution escalates to the full pytest unit suite when test_version_consistency.py is absent even though test_build_sha.py exists.
  • Adds regression tests confirming that an inherited cask lag reason is ignored by the version-check script (mismatch without explicit reason returns status 1) and that all BRAINLAYER_VERSION_CHECK_ overrides are removed prefix-wide.
  • Risk: any out-of-tree test fixture that relied on the old _git_env helper name or expected BRAINLAYER_VERSION_CHECK_* variables to pass through to subprocesses will break; the helper rename in _script_env requires all call sites in test_version_consistency.py to be updated (done in-tree).

Macroscope summarized 260d431.

Summary by CodeRabbit

  • Bug Fixes
    • Improved test isolation by preventing inherited release and Git environment variables from affecting version-consistency checks.
    • Ensured changed-only test runs fall back to the full test suite when required version-consistency coverage is unavailable.
    • Added regression coverage for ignored version-check overrides and environment-variable cleanup.

…cess env, and pin the mirror sibling case

tests/test_version_consistency.py ran scripts/brainlayer-version-check.sh with the INHERITED
environment. A release operator has BRAINLAYER_VERSION_CHECK_CASK_LAG_REASON exported -- they need
it for the real check -- so pre-push -> pytest -> the script saw the reason, allowed the lag, and
returned 0. The two tests that assert the script FAILS on a lagging/drifting cask without a stated
reason went RED for a change with nothing to do with them.

The env is now built from a scrubbed copy in one helper (_script_env, mirroring the sibling
tests/test_run_tests_script.py::_script_env) and the scrub is by PREFIX: REPO_ROOT, TAP_ROOT and
GIT_TAG would steer the fixtures elsewhere exactly the same way. Tests that WANT a knob still pass
it explicitly through extra_env/git_tag, which override the base.

Also folds in the mirror case the #762 round-1 review left uncovered: test_build_sha.py present,
test_version_consistency.py absent -> escalate. The script was already correct in both directions;
only one direction was pinned. Verified by mutation -- narrowing the mapping to build-sha alone
turns the new test RED while the existing build-sha-sibling test stays green.

And adds the missing `import pytest`: pytest.MonkeyPatch was already referenced in an annotation,
surviving only because `from __future__ import annotations` never evaluates it.

Evidence:
- RED first: with BRAINLAYER_VERSION_CHECK_CASK_LAG_REASON exported, 4 failed / 12 passed
  (the two pre-existing tests + both new ones). After: 16 passed, with and without the export.
- tests/test_version_consistency.py + tests/test_run_tests_script.py: 39 passed.
- ruff check + ruff format --check clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@EtanHey EtanHey added the XS Extra-small change (400 lines or fewer) label Sep 5, 2026
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_acfa6ed6-1f91-48f6-a69c-aca688864c3a)

@deepsource-io

deepsource-io Bot commented Sep 5, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 7272db4...260d431 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Sep 5, 2026 3:12p.m. Review ↗
Swift Sep 5, 2026 3:12p.m. Review ↗
JavaScript Sep 5, 2026 3:12p.m. Review ↗
Shell Sep 5, 2026 3:12p.m. Review ↗
Secrets Sep 5, 2026 3:12p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

BrainLayer ratchet

Every Value below was measured by this run. A row this machine cannot measure says n/a — <reason> instead of a number; baselines in Notes name their own machine, method and date and were not measured here.

Row Status Value (measured by this run) Method Notes
commit provenance 🔴 RED checkout a0dabb7e3a68 is neither 260d4317ba91 nor a merge of it — this run was triggered for a commit it does not have checked out commit graph + live PR head · in-process · runner Which commit this whole table is about. On a pull_request event the checkout is GitHub's synthetic merge ref, whose sha is not on the PR — #759's table printed 13fa724278bf while that PR's head was 4632f979 — so this row names the PR-head parent instead, the sha a reviewer can actually see. The comparison sha is read live from repos/{owner}/{repo}/pulls/{n} when the table is collected, not taken from the event payload, because the payload cannot know the run has been overtaken. Residual window, stated rather than papered over: a push landing between that read and the comment being posted is not caught here — the run for that push refreshes the table.
baseline attestation 🟢 GREEN baseline f421d1a7c5e6 matches the main attestation (run 33979237066 · main 2264b19ea0aa · 2026-09-05T16:53:22Z) main attestation artifact via Actions API · in-process · runner What every comparison is measured AGAINST, and who says so. The baseline fields of tests/fixtures/sprint_gate/corpus.json (queries, latency_baseline_ms, thresholds) are compared to the ratchet-attestation artifact of the latest successful push or (no-input) workflow_dispatch run of ratchet-attest.yml on main, fetched through the Actions API — a PR run cannot write to another run's artifacts. A field that differs is RED unless that main run measured the new value; today no runner-side collector measures any baseline field, so today the baseline cannot move by PR at all, and this row says so instead of a hand edit passing. Boundary: the comparator is this PR's checkout of ci_ratchet_table.py, diff-reviewable, not tamper-proof.
provenance 🟢 GREEN stamped a0dabb7e3a68 == HEAD, tree clean wheel stamp · in-process · runner Sha half of #749 keg-mode provenance: a keg built from this wheel can answer __build_sha__. The helper-age and served-process predicates need a running BrainBar and are measured only by scripts/sprint_gate.py on an installed Mac. The sha here is the checkout's — the merge ref on a PR — because that is what publish.yml stamps at release time; the PR-head sha this table describes is the one in commit provenance above.
mapped bytes ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Baseline 26.2 GB — installed Mac, socket, 2026-09-03, after R2 drained 15,070 → 0. Up from 16.8 GB because the drain left more vectors mapped under the same cap: the change is the drain, not a leak. Not measured by this run.
search p50/p95 ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Margin p50: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin p95: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Calibrated on MacBook-Pro.local at 2026-09-01T08:42:22Z under active_sprint_load (tests/fixtures/sprint_gate/corpus.json). Not measured by this run.
idle CPU ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would ps sampling · installed Mac Ceiling: average CPU < 30% over a 60 s window (resource_budget in scripts/sprint_gate.py), ratified and kept as a hard budget. Margin daemon: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin helper: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin watcher: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Needs the BrainBar daemon, helper and watcher actually running. Not measured by this run.
signature_valid ⚪ n/a n/a — the macOS signature-parity job is trigger-gated and did not run on this PR: it touches no release or signing path (pyproject.toml, scripts/release-*, scripts/brainlayer-version-check.sh, publish.yml, ratchet.yml) and carries no ratchet:signatures label — a GitHub macOS runner bills at ~10× Linux minutes and rebuilds the keg venv from source codesign · installed keg scripts/release-verify-signatures.sh <keg> codesign-verifies every *.so/*.dylib under libexec/venv. The macOS parity job installs the published tap formula (etanhey/layers/brainlayer), so this row measures the release path — formula, published sdist and Homebrew's relocation — and not this PR's tree. Release-time baseline for the same keg on a different machine: 442 valid / 0 invalid — installed Mac (M4 Max), brew --prefix brainlayer 1.5.11, 2026-09-03.

🟢 GREEN measured, within budget · 🔴 RED measured, out of budget — a finding to clear before merge · ⚪ n/a not measurable on this machine, never guessed.

1 RED row(s) to clear: commit provenance.

Measured on Linux/x86_64 · measured 260d4317ba91 · PR head 260d4317ba91 · checkout a0dabb7e3a68 · run · updated 2026-09-05 17:04:03 UTC

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: e09c25fe-7089-4938-9241-c23edc4eebb7

📥 Commits

Reviewing files that changed from the base of the PR and between 1816ca0 and 260d431.

📒 Files selected for processing (1)
  • tests/test_kg_judge.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 76e0b25e-daaa-4151-8160-056f2f133708

📥 Commits

Reviewing files that changed from the base of the PR and between 7272db4 and 1816ca0.

📒 Files selected for processing (2)
  • tests/test_run_tests_script.py
  • tests/test_version_consistency.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
🧰 Additional context used
🪛 ast-grep (0.45.2)
tests/test_run_tests_script.py

[error] 758-760: Command coming from incoming request
Context: subprocess.run( # noqa: S603 - returncode is asserted below
["bash", str(SCRIPT_PATH)], capture_output=True, text=True, env=env, check=False
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)

tests/test_version_consistency.py

[error] 93-97: Avoid command injection
Context: subprocess.check_output(
["git", "-C", str(REPO_ROOT), "rev-parse", "--git-dir"],
text=True,
env=_script_env(),
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(command-injection-python)


[error] 93-97: Command coming from incoming request
Context: subprocess.check_output(
["git", "-C", str(REPO_ROOT), "rev-parse", "--git-dir"],
text=True,
env=_script_env(),
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)


[error] 112-112: Command coming from incoming request
Context: subprocess.run(["git", "-C", str(path), "init"], check=True, capture_output=True, text=True, env=env)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)


[error] 323-327: Avoid command injection
Context: subprocess.check_output(
["git", "rev-parse", "--local-env-vars"],
text=True,
env=_script_env(),
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(command-injection-python)


[error] 323-327: Command coming from incoming request
Context: subprocess.check_output(
["git", "rev-parse", "--local-env-vars"],
text=True,
env=_script_env(),
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)

🔇 Additional comments (2)
tests/test_version_consistency.py (1)

13-13: LGTM!

Also applies to: 19-31, 75-75, 97-97, 112-112, 327-332, 335-351, 354-369

tests/test_run_tests_script.py (1)

730-769: LGTM!


📝 Walkthrough

Walkthrough

The changes add regression coverage for changed-only test selection and isolate version-check fixture subprocesses from inherited environment overrides.

Changes

Test coverage updates

Layer / File(s) Summary
Subprocess environment isolation
tests/test_version_consistency.py
The test environment helper now removes GIT_ and BRAINLAYER_VERSION_CHECK_ variables. Subprocess helpers use the cleaned environment. New tests verify cask lag handling and complete environment scrubbing.
Changed-only scope fallback
tests/test_run_tests_script.py
A regression test verifies that an __init__.py change runs the full pytest suite when test_version_consistency.py is absent and test_build_sha.py exists.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 1816c

Version-check tests now run with release and Git overrides removed from their subprocess environments, and changed-only test selection covers the missing sibling case. No current merge-blocking risk remains.

Poem

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: scrubbing BRAINLAYER_VERSION_CHECK_* variables from subprocess environments. It also identifies the related regression coverage for the mirror sibling cas…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/version-check-env-scrub

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…, without losing its teeth

CI caught this, not the local gate: `tests/test_kg_judge.py::test_git_shellout_tests_scrub_inherited_git_env`
is a meta-guard that reads every git-shelling test file and demanded the LITERAL
`if not key.startswith("GIT_")` plus `env=_clean_git_env()`. This branch replaced both in
tests/test_version_consistency.py with a named prefix tuple and `_script_env()`, so the guard went
red on 3.11/3.12/3.13 while the scrub it guards got STRONGER.

The contract is "GIT_* is scrubbed", not one exact line of code. The guard now accepts either the
inline literal or `startswith(_SCRUBBED_ENV_PREFIXES)` -- but only when the tuple demonstrably
leads with "GIT_" -- and `_script_env` joins the accepted helper names. The failing file is named
in the assertion message, which it was not before.

Verified by mutation: dropping "GIT_" from the tuple in tests/test_version_consistency.py fails the
guard with `AssertionError: test_version_consistency.py`. Restored; 54 passed across
test_kg_judge.py, test_version_consistency.py and test_run_tests_script.py.

Why the local gate missed it: test_kg_judge.py is not a changed-only target for a change to
test_version_consistency.py, so the scoped pre-push never ran the guard. That mapping gap is a
separate defect and is reported to the lead rather than fixed here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_ab323f99-9263-4265-9f1c-bf8ca0445dea)

…again, and now says so in a test

Round-1 review, medium — confirmed, my own regression. Relaxing the guard to accept the prefix-tuple
spelling dropped the `if not` from both accepted forms, so a substring match on
`startswith("GIT_")` would also pass a file carrying an inverted KEEP-only filter
(`if key.startswith("GIT_")`) — which names the same prefix and hands the fixture repos the parent
checkout's GIT_DIR. That is a fail-open weakening of the cross-file contract this guard exists to
enforce.

The predicate is now a named helper, `_drops_inherited_git_env`, and both accepted spellings carry
`if not`:
- `if not key.startswith("GIT_")` (seven of the eight guarded files), or
- `if not key.startswith(_SCRUBBED_ENV_PREFIXES)` where the tuple demonstrably leads with `"GIT_"`
  (tests/test_version_consistency.py, which must also scrub BRAINLAYER_VERSION_CHECK_*).

Test-first: extracting the predicate is what makes the polarity testable at all, so it is covered
directly — `test_git_env_scrub_predicate_requires_the_dropping_polarity` parametrizes six shapes,
including both inversions and a tuple that no longer leads with "GIT_" (a tuple scrubbing something
else under a name that reads right). It fails on the pre-fix predicate, which accepted the two
inverted cases.

Evidence:
- 7 passed on the predicate + guard; tests/test_kg_judge.py + tests/test_version_consistency.py:
  37 passed.
- Mutation on a REAL guarded file: inverting `if not key.startswith(_SCRUBBED_ENV_PREFIXES)` in
  tests/test_version_consistency.py fails the guard with
  `AssertionError: test_version_consistency.py`. Restored.
- Full CI matrix on the previous head (742e55d) was green on 3.11/3.12/3.13; this commit only
  tightens the guard.
- ruff check + ruff format clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a43fceee-4afe-4194-9f41-32a3836b7119)

@EtanHey

EtanHey commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Round 1 — the medium is real, and it was my own regression

medium tests/test_kg_judge.py @334 — polarity lost. CONFIRMED, fixed in 260d4317.

Relaxing the guard to accept the prefix-tuple spelling dropped if not from both accepted forms, so
a substring match on startswith("GIT_") would also have passed a file carrying an inverted
keep-only filter (if key.startswith("GIT_")) — which names the same prefix and hands the
fixture repos the parent checkout's GIT_DIR. Fail-open on the cross-file contract this guard
exists to enforce. You are right.

Both accepted spellings now carry if not:

  • if not key.startswith("GIT_") — seven of the eight guarded files;
  • if not key.startswith(_SCRUBBED_ENV_PREFIXES) where the tuple demonstrably leads with "GIT_"
    tests/test_version_consistency.py, which must also scrub BRAINLAYER_VERSION_CHECK_*.

Test-first, and the extraction is what makes it testable. The predicate is now
_drops_inherited_git_env, and test_git_env_scrub_predicate_requires_the_dropping_polarity
parametrizes six shapes — both inversions, the tuple form in both polarities, a tuple that no longer
leads with "GIT_" (scrubbing something else under a name that reads right), and no scrub at all.
It fails on the pre-fix predicate, which accepted the two inverted cases.

Mutation on a real guarded file: inverting if not key.startswith(_SCRUBBED_ENV_PREFIXES) in
tests/test_version_consistency.py fails the guard with
AssertionError: test_version_consistency.py. Restored.

7 passed on the predicate + guard; test_kg_judge.py + test_version_consistency.py → 37 passed.
ruff check / ruff format clean. The previous head (742e55d1) was green on 3.11/3.12/3.13.

Nothing refuted. New head: 260d4317.


brainlayerClaude-19a28f09 running claude-opus-5.

@EtanHey
EtanHey merged commit a0dabb7 into main Sep 5, 2026
18 checks passed
@EtanHey
EtanHey deleted the fix/version-check-env-scrub branch September 5, 2026 16:23
@EtanHey EtanHey added the size:M Tight-loop PR size: 101-400 hand-written lines changed label Sep 5, 2026
EtanHey added a commit that referenced this pull request Sep 5, 2026
All six sites: pyproject.toml, src/brainlayer/__init__.py, server.json
(root + packages[0]), brain-bar/bundle/Info.plist (short, bundle, release).
Casks/brainbar.rb stays 1.5.9: no Swift change this release, declared to
scripts/brainlayer-version-check.sh via
BRAINLAYER_VERSION_CHECK_CASK_LAG_REASON="no BrainBar release for 1.5.15".

Why a release. The installed keg on the M4 is 1.5.14 / build_sha 3bbe19f.
Verified: `git merge-base --is-ancestor 7369f80 3bbe19f` -> false, so #781
-- the watcher per-poll burst fix, 14.97% -> 2.39% under the LaunchAgent's
background QoS -- is NOT in any installed keg. Enabling com.brainlayer.watch
today would start the burst-y watcher. 1.5.15 is what carries #781 (7369f80)
onto the Mac. Also in: #772 #773 #775 #776.

Co-authored-by: brainlayerClaude-ebe88b04 running claude-opus-5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Tight-loop PR size: 101-400 hand-written lines changed XS Extra-small change (400 lines or fewer)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant