Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(ci): keep the fd-0 stdin idiom pinned by R4; repoint the spend off-switch source pins at the consent-gate shape (C2)
garrytan540f113468e6
diff --git a/src/core/interaction.ts b/src/core/interaction.tsindex f1f1924265..02ea35aea9 100644--- a/src/core/interaction.ts+++ b/src/core/interaction.ts@@ -214,7 +214,7 @@ function readStdinFd(maxBytes: number, withRaw: boolean): StdinRead | null {const st = fstatSync(0);if (st.isFIFO() || st.isSocket() || process.stdin.isTTY) return null;if (st.isFile() && st.size > maxBytes) return tooLarge(maxBytes, 0);- const raw = readFileSync(0);+ const raw = readFileSync(0, { encoding: null });if (raw.length > maxBytes) return tooLarge(maxBytes, raw.length);return raw.length ? { kind: 'data', text: raw.toString('utf-8'), ...(withRaw ? { raw } : {}) } : { kind: 'empty' };} catch (e) {diff --git a/test/spend-off-switch.test.ts b/test/spend-off-switch.test.tsindex 2eb40c1dde..c242081198 100644--- a/test/spend-off-switch.test.ts+++ b/test/spend-off-switch.test.ts@@ -31,9 +31,11 @@ describe('enrich parseArgs — --max-usd off → uncapped (Infinity sentinel)',describe('reindex / onboard off-switch dispatch (regression guards)', () => {test('reindex-code: --max-cost off proceeds past the confirmation gate', async () => {const src = await Bun.file(new URL('../src/commands/reindex-code.ts', import.meta.url)).text();- // off sets maxCostOff and the gate proceeds when (tokenmax || maxCostOff).+ // off sets maxCostOff and proceeds without asking; tokenmax authorizes+ // through requireConsent and stays uncapped (C2: tokenmaxUncappedEnv).expect(src).toMatch(/maxCostOff\s*=\s*true/);- expect(src).toMatch(/posture === 'tokenmax' \|\| maxCostOff/);+ expect(src).toMatch(/if \(maxCostOff\) \{/);+ expect(src).toMatch(/tokenmaxUncappedEnv\(engine/);});test('onboard: --max-usd off lifts the --auto missing-cap refusal', async () => {@@ -48,6 +50,8 @@ describe('reindex / onboard off-switch dispatch (regression guards)', () => {// The sentinel must become `undefined` at the tracker (never raw Infinity,// which serializes to null in audit rows).expect(src).toMatch(/opts\.maxCostUsd === Infinity \? undefined/);- expect(src).toMatch(/uncapped \? Infinity : parsed\.maxCostUsd/);+ // C2: `--max-usd off` (Infinity) skips consent; tokenmax keeps Infinity via tokenmaxUncappedEnv.+ expect(src).toMatch(/const uncapped = !parsed\.dryRun && maxCostUsd === Infinity/);+ expect(src).toMatch(/tokenmaxUncappedEnv\(engine/);});});