fix(pregate): a wtree failure is WTREE_UNAVAILABLE, not an unresolvable base (#3197)

The pregate consumers of the working-tree fingerprint (buildContext,
withFingerprint, verifyPregate) move to lib/script-invocation.ts's
{tree}|{error} form, and lib/regen.ts drops its string-returning wrapper.

- A fingerprint failure was reported as "policy source unavailable:
  origin/<base> is not a resolvable commit" with git fetch as the fix. It is
  now WTREE_UNAVAILABLE: a launch failure lists each Windows bash candidate
  with its rejection reason and names GSTACK_GIT_BASH; a gstack-wtree exit
  keeps the repair it printed (set TMPDIR to a writable directory).
- A fingerprint failing after a check is incomplete with that cause, not
  "working tree changed"; verify says the tree cannot be fingerprinted.
- #3190's gstack-config read (test_backend) goes through runScriptSync, so
  Windows reaches it through Git Bash. The tripwire learns the bin-constant
  shape that let it through.
- Under --json every context refusal is one envelope on stdout
  ({ok:false,status:'refused',code,detail,fix,docs}, exit 3); the run object
  carries ok and status too, and GSTACK_RESULT goes to stderr.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-10-16 23:53:22 +00:00
1 parent 4f8f805b82
commit 5edb880073
11 files changed
+267 -53

No files matched your search

+2 -4
View File
@@ -13,7 +13,6 @@ import {
bashCommandInvocation, resolveWindowsBash, resolveWindowsBashCached, runBashSync, runScriptSync, scriptInvocation, wtreeFingerprint,
type BashProbe,
} from '../lib/script-invocation';
import { wtreeFingerprint as regenWtreeFingerprint } from '../lib/regen';
const ROOT = path.resolve(import.meta.dir, '..');
const BIN = path.join(ROOT, 'bin');
@@ -183,12 +182,11 @@ describe('wtreeFingerprint', () => {
return dir;
};
test('a SHA-1 repository yields a 40-hex tree, and the regen compatibility wrapper returns the same string', () => {
test('a SHA-1 repository yields a 40-hex tree', () => {
const dir = repo();
try {
const r = wtreeFingerprint({ cwd: dir });
expect('tree' in r && r.tree).toMatch(/^[0-9a-f]{40}$/);
expect(regenWtreeFingerprint(dir)).toBe('tree' in r ? r.tree : 'missing');
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
});
@@ -209,7 +207,7 @@ describe('wtreeFingerprint', () => {
const exit = wtreeFingerprint({ cwd: dir, env: { ...process.env, TMPDIR: path.join(dir, 'no-such-dir') } });
expect(exit).toMatchObject({ kind: 'exit' });
expect('error' in exit && exit.error).toMatch(/^gstack-wtree exited 1: .*set TMPDIR to a writable directory/);
expect(regenWtreeFingerprint(path.join(os.tmpdir()))).toBeNull();
expect(wtreeFingerprint({ cwd: os.tmpdir() })).toMatchObject({ kind: 'exit' });
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
});