test: repin ~70 assertions to the script contract — every literal gets a successor

Assertions that pinned inline-bash internals (update-check guard, _SESSIONS
reaping, telemetry start/end blocks, routing probe, repo-strip producer,
first-task gating, EXPLAIN_LEVEL/QUESTION_TUNING echoes, #2499 jq scope
resolution, Issue-8 CONDUCTOR gate) now pin the same invariants in their new
home: bin/gstack-skill-start / bin/gstack-skill-end file content for script
internals, the invocation fence + interpretation prose for render-side
behavior. No assertion deleted without a successor; live-execution tests
(routing probe, brain-sync jq) run against script bytes unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-25 15:37:00 +00:00
co-authored by Claude Fable 5
parent eb1607aaf8
commit 17bebe33ab
9 changed files with 280 additions and 109 deletions
+25 -7
View File
@@ -15,10 +15,20 @@
* - Tier-1 preamble does NOT include Writing Style section
*/
import { describe, test, expect } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
import type { TemplateContext } from '../scripts/resolvers/types';
import { HOST_PATHS } from '../scripts/resolvers/types';
import { generatePreamble } from '../scripts/resolvers/preamble';
// Token-reduction Phase 1: the EXPLAIN_LEVEL config read + echo moved from the
// inline preamble bash into bin/gstack-skill-start; the render keeps the
// interpretation prose that acts on the echoed key.
const SKILL_START_SCRIPT = fs.readFileSync(
path.join(import.meta.dir, '..', 'bin', 'gstack-skill-start'),
'utf-8',
);
function makeCtx(host: 'claude' | 'codex', tier: 1 | 2 | 3 | 4): TemplateContext {
return {
skillName: 'test-skill',
@@ -35,9 +45,12 @@ describe('Writing Style preamble section', () => {
expect(out).toContain('## Writing Style');
});
test('tier 2+ preamble includes EXPLAIN_LEVEL echo in bash', () => {
test('EXPLAIN_LEVEL is echoed by gstack-skill-start and read by tier 2+ prose', () => {
// The bash echo lives in the script the preamble fence invokes...
expect(SKILL_START_SCRIPT).toContain('_EXPLAIN_LEVEL=$(');
expect(SKILL_START_SCRIPT).toContain('echo "EXPLAIN_LEVEL: $_EXPLAIN_LEVEL"');
// ...and the tier-2+ render references the echoed key.
const out = generatePreamble(makeCtx('claude', 2));
expect(out).toContain('_EXPLAIN_LEVEL');
expect(out).toContain('EXPLAIN_LEVEL:');
});
@@ -70,13 +83,18 @@ describe('Writing Style preamble section', () => {
test('Codex tier-2 preamble uses host-aware path (no .claude/)', () => {
const out = generatePreamble(makeCtx('codex', 2));
// The Writing Style section shouldn't reference a Claude-specific bin path.
// Specifically check the EXPLAIN_LEVEL bash line.
const explainLine = out.split('\n').find(l => l.includes('_EXPLAIN_LEVEL='));
// The config read moved into gstack-skill-start, which resolves its bin
// dir $0-relative ($_BIN) — host-neutral by construction.
const explainLine = SKILL_START_SCRIPT.split('\n').find(l => l.includes('_EXPLAIN_LEVEL='));
expect(explainLine).toBeDefined();
expect(explainLine).not.toMatch(/~\/\.claude\//);
// Codex uses $GSTACK_BIN
expect(explainLine).toContain('$GSTACK_BIN');
expect(explainLine).toContain('$_BIN/');
// The Codex render's fence must reach the script via the host path, not
// a Claude-specific one.
const fenceLine = out.split('\n').find(l => l.includes('_SS='));
expect(fenceLine).toBeDefined();
expect(fenceLine).not.toMatch(/~\/\.claude\//);
expect(fenceLine).toContain('$GSTACK_BIN');
});
test('tier 1 preamble does NOT include Writing Style section', () => {