test(gbrain-sync): stub pgrep so the pin case is hermetic - #2689
Open
szsunyuan wants to merge 2 commits into
Open
test(gbrain-sync): stub pgrep so the pin case is hermetic#2689szsunyuan wants to merge 2 commits into
szsunyuan wants to merge 2 commits into
Conversation
The only non-dry-run --code-only child hits garrytan#1734's PATH-resolved autopilot probe. A live host daemon is a correct refuse; the test cannot inject processRunning. Neutralize pgrep in the fixture bindir instead of adding a production env hatch. Co-authored-by: Cursor <cursoragent@cursor.com>
Lock paths are checked before pgrep. Spreading process.env let a runner GBRAIN_HOME with a live lock refuse the case before the stub ran. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
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.
Why (in your own words)
keeps a symlink-equivalent pinned source registered as-isis supposed to pin the symlink path, not the operator's daemon. It is the only non---dry-run--code-onlychild intest/gstack-gbrain-sync.test.ts, so it hits#1734'sdetectAutopilot()→pgrep -f "gbrain autopilot". If autopilot is up, the child correctly exits 1:refused: gbrain autopilot active (process:gbrain autopilot). The test only assertsr.status === 0, so it looks like a symlink/pin failure. CI is green because CI has no daemon. The refuse is correct. The test never neutralized the probe.The fixture already prepends
bindirtoPATHand stubsgbrain.defaultProcessRunninginvokes barepgrep, which is PATH-resolved. Drop apgrepthat exits 1 into that samebindir. BlankGBRAIN_HOMEso an inherited lock under$GBRAIN_HOME/.gbraincannot refuse before pgrep. The child cannot injectprocessRunningthe waytest/gbrain-guards.test.tsdoes.This is a test-isolation fix, not a product fix. Real
/sync-gbrainstill refuses while autopilot is live.Fixes #2685.
Why this shape
Author offered the stub or an env hatch. Stub is the smaller blast radius. An env override on
detectAutopilotwould weaken a data-loss guard. Skip-if-autopilot would hide the pin case on the machines that follow the documented setup. Did not editlib/gbrain-guards.ts.What it does
itwrites an executablepgrepstub (exit 1) next to the existinggbrainstub, and blanksGBRAIN_HOMEon the child.What it deliberately does not do
detectAutopilotpgrepin other tests in this file (they are--dry-runor--no-code)pgrepintest/gbrain-sync-skip.test.ts(sibling--code-onlyfile; those cases do not assertexitCode === 0, so they false-pass on a refuse instead of going red)VERSION/CHANGELOG//shipAI was used for assistance.
Live evidence
Temp
HOME/GSTACK_HOMEonly. Neverrm'd real~/.gbrain. Did not start realgbrain autopilot(that daemon can race a destructive walk). Recreated the author's process signal with a dummy whose argv containsgbrain autopilot. Host/usr/bin/pgrep -f "gbrain autopilot"went to exit 0. Then the same namedit:Tip (
ad84005, no stub), dummy up — the issue:Same fixture without
--quiet:This branch, dummy still up — the fix:
Quiet machine (no dummy,
pgrepexit 1,GBRAIN_HOMEunset): tip is already green. That is why this laptop looked fine until we planted the signal. Author's red is machine-specific; CI has no daemon. After the dummy was killed, hostpgrepwas exit 1 again.On this Bun, child
os.homedir()honorsHOME, so operator~/.gbrain/autopilot.lockis not visible to the child. The remaining lock residual was inheritedGBRAIN_HOME; the child now blanks it.Scope
test/gstack-gbrain-sync.test.ts(oneit)pgrepmatch);bun test test/gstack-gbrain-sync.test.ts(42 pass).gbrain autopilot --install. A live lock under an operatorGBRAIN_HOME(child now blanks it). Paid evals. Fullbun run test.Liveness proof (required)
GSTACK PRtyped live into the browser address bar:Checklist
GSTACK PRtyped live into a real surface (not edited onto the image)Test plan
itpasses (no signal)gbrain autopilot, tip, no stub → nameditfails, status 1itpassesbun test test/gstack-gbrain-sync.test.ts→ 42 passpgrepexit 1 againFork PRs do not get eval secrets; the free file above is the gate.