Files
gstack/test/ground-rules.test.ts
T
Garry Tanandcapy-ai[bot] 28822af38c Load the never-print-secrets rule in every skill on every host, with the commands it missed (GST-2753) (#4382)
* Load the never-print-secrets rule in every skill on every host, with the commands it missed (GST-2753)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Point the shared CI-wait rule at gstack-pr-wait and name the missed secret-printing commands

The Ground Rules section told every skill to wait with gh pr checks --watch, which spends the shared GitHub GraphQL quota gstack moved off; it now names gstack-pr-wait. The banned list also covers ps aux and ps -ef, set -x, git config -l and an export $(...) that expands to a bare export. Size caps raised to the measured +70 bytes.

Review-Finding: p1/red-team#1 reader=red-team
Review-Finding: p1/red-team#2 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Say which skills carry the new rule in its release note

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-11-16 02:57:22 +00:00

44 lines
1.9 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
import {
GROUND_RULES_HEADING,
GROUND_RULES_MAX_BYTES,
generateGroundRules,
} from '../scripts/resolvers/preamble/generate-ground-rules';
const ROOT = path.resolve(import.meta.dir, '..');
const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf-8');
describe('Ground Rules preamble section', () => {
const block = generateGroundRules();
test('stays within its byte budget', () => {
expect(Buffer.byteLength(block)).toBeLessThanOrEqual(GROUND_RULES_MAX_BYTES);
});
test('names every command that prints a whole environment, git config or process table, and the by-name alternative', () => {
for (const cmd of ['`env`', 'bare `printenv`', '`set` or `export`', '`export $(...)`', '`export -p`/`-n`', '`declare -p`/`-x`', '`typeset -p`', '`set -x`', '`git config --list`/`-l`', 'any `ps` with full args (`aux`, `-ef`, `-o args`)', '`docker top ... args`', '`docker inspect` Env']) {
expect(block).toContain(cmd);
}
expect(block).toContain('`git config --get <name>`');
expect(block).toContain('`[ -n "${NAME:-}" ] && echo set`');
});
test('tells agents to wait on CI with gstack-pr-wait, not a polling loop or the GraphQL-spending gh watcher', () => {
expect(block).toContain('`gstack-pr-wait <n> --until green`');
expect(block).toContain('never a poll loop or `gh pr checks --watch`');
});
test('renders inline in a tier 1 skill and in the shared preamble tier 2+ skills read', () => {
expect(read('browse/SKILL.md')).toContain(block);
expect(read('review/sections/preamble.md')).toContain(block);
});
test('is pinned, so no model loadout can drop it', () => {
const loadouts = JSON.parse(read('modules/loadouts.json'));
expect(loadouts.pinned).toContain('preamble:ground-rules');
expect(block.startsWith(GROUND_RULES_HEADING)).toBe(true);
});
});