mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-11 07:29:00 +02:00
Specialist army findings, all quote-verified before fixing:
Security: careful force-push guard now catches git's plus-refspec force
syntax (git push origin +main carried force with no flag — silently allowed
before) and refspec-form targets (HEAD:main); default-branch matching is
tokenized FIXED-STRING comparison on the full branch path (slashed defaults
like release/2.0 work; no ERE interpolation), glob-safe via noglob. HIGH rm
tier is tokenized too: trailing long options (--no-preserve-root) and /* are
root-class. Stored evidence fingerprints are 40-hex re-validated before
reaching git argv. normalizeForDetection sweeps ALL Unicode format chars
(\p{Cf}: soft hyphens, bidi marks, tag chars) instead of five enumerated
zero-widths. The wiring scanner gains flagless gh pr/issue view patterns. The
release-body banner tripwire diffs against the fetched original so a hostile
pre-existing banner string can't permanently DoS doc updates. Ship/land
evidence checks now pass --expect-cmd (a green `echo ok` recorded under the
label can never mint FRESH); package.json stays allow-listed with the
residual documented.
Performance: gstack-wtree seeds its temp index by COPYING the real index
(stat cache preserved — measured 40x faster than read-tree seeding, identical
hash) with read-tree fallback; evidence uses findLast and one gstack-slug
spawn; the stream pump honors backpressure via drain; careful's pattern block
short-circuits before slug resolution when no pattern file exists.
Testing: the gh-failure envelope test was VACUOUS (killing PATH killed the
bun shebang before the code under test ran) — replaced with a PATH gh shim
that exercises the real branch, plus shimmed happy paths (issue/pr-body/
unparseable JSON); evidence check --all + empty ledger + non-numeric
--max-age (now a usage error, was silent fail-open) covered; HIGH-tier
variants pinned; hook analytics respect GSTACK_HOME so tests stop writing the
operator's real skill-usage.jsonl.
Maintainability: dead exit ternary removed; flagValue deduped into
bin-context; sentinel defusal derived from the banner constants (no invisible
literals — \u escapes only); scratch-repo git fixture extracted to
test/helpers/scratch-repo.ts (one hermetic incantation, three consumers);
shared gstack_hook_log_fire in hook-extract.sh; the dashboard/land diff-scoped
row lists are aligned (codex-review) and drift-pinned.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
73 lines
3.5 KiB
TypeScript
73 lines
3.5 KiB
TypeScript
import { describe, test, expect } from 'bun:test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/**
|
|
* Template-drift tripwire for the content-binding wave. The bins are
|
|
* code-enforced; the GRADING rules live as prose in rendered templates that
|
|
* agents follow. This test pins the load-bearing rule text in the GENERATED
|
|
* files so a template refactor can't silently drop a rule while the bins keep
|
|
* working. (Prompt-followed prose is honest tier-2 enforcement — this tripwire
|
|
* is what keeps it from being tier-3 vibes.)
|
|
*/
|
|
|
|
const ROOT = path.resolve(import.meta.dir, '..');
|
|
|
|
function rendered(rel: string): string {
|
|
return fs.readFileSync(path.join(ROOT, rel), 'utf-8');
|
|
}
|
|
|
|
describe('content-binding template drift', () => {
|
|
test('ship Step 16 carries the evidence check (mechanized IRON LAW)', () => {
|
|
const ship = rendered('ship/SKILL.md');
|
|
expect(ship).toMatch(/gstack-evidence check --label tests --expect-cmd '[^']+' --label vitest --expect-cmd '[^']+' --max-age 24 --allow-paths CHANGELOG\.md,VERSION,package\.json/);
|
|
expect(ship).toContain('a failed CHECK never blocks');
|
|
});
|
|
|
|
test('ship Step 5 lanes run wrapped with per-lane labels', () => {
|
|
const tests = rendered('ship/sections/tests.md');
|
|
expect(tests).toContain('gstack-evidence run --label tests');
|
|
expect(tests).toContain('gstack-evidence run --label vitest');
|
|
});
|
|
|
|
test('land-and-deploy grades staleness content-first (wtree rule) and checks evidence', () => {
|
|
const land = rendered('land-and-deploy/SKILL.md');
|
|
expect(land).toContain('wtree');
|
|
expect(land).toContain('---WTREE---');
|
|
expect(land).toMatch(/gstack-evidence check --label tests --expect-cmd '[^']+' --max-age 24/);
|
|
expect(land).toContain('UNKNOWN');
|
|
});
|
|
|
|
test('the review dashboard staleness rule is wtree-first for diff-scoped rows', () => {
|
|
// The dashboard text is generated into every skill that embeds
|
|
// {{REVIEW_DASHBOARD}}; ship is the canonical carrier.
|
|
const ship = rendered('ship/SKILL.md');
|
|
expect(ship).toContain('---WTREE---');
|
|
expect(ship).toContain('diff-scoped rows only');
|
|
expect(ship).toContain('grade UNKNOWN and treat as stale');
|
|
});
|
|
|
|
test('the diff-scoped row list is IDENTICAL in both grading surfaces (no drift)', () => {
|
|
// The resolver (dashboard) and land-and-deploy each carry the row list;
|
|
// they diverged once (codex-review present in one, missing in the other).
|
|
// Rendered dashboards escape backticks (template-literal origin), so match
|
|
// structurally: the three row names in order inside the rule sentence.
|
|
const rowList = /diff-scoped rows only:[\s\S]{0,80}?adversarial-review[\s\S]{0,80}?codex-review[\s\S]{0,80}?ship-stage entries/;
|
|
expect(rendered('ship/SKILL.md')).toMatch(rowList);
|
|
expect(rendered('land-and-deploy/SKILL.md')).toMatch(rowList);
|
|
});
|
|
|
|
test('release-body write side carries the banner tripwire', () => {
|
|
const body = rendered('document-release/sections/release-body.md');
|
|
expect(body).toContain('grep -c "UNTRUSTED TRACKER CONTENT" /tmp/gstack-pr-body-$$.md');
|
|
expect(body).toContain('grep -c "UNTRUSTED TRACKER CONTENT" /tmp/gstack-pr-body-orig-$$.md');
|
|
expect(body).toContain('banner tripwire clean');
|
|
});
|
|
|
|
test('greptile triage reads bodies through the guard (metadata/body split)', () => {
|
|
const triage = rendered('review/greptile-triage.md');
|
|
expect(triage).toContain('gstack-issue-guard --stdin --source greptile-line');
|
|
expect(triage).toContain('gstack-issue-guard --stdin --source greptile-replies');
|
|
});
|
|
});
|