mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 00:21:14 +01:00
* feat: retire /investigate after a no-gain eval (GST-1717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(skill-start): core routing offer drops every non-core rule line (GST-1717)
The retired /investigate rule became 'Bugs/errors → fix them directly', which no
longer matches '→ invoke /', so proactive=core leaked it into the offered section.
Match any '- … → ' rule line.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* revert(review): keep review/checklist.md at its no-loss-pinned bytes (GST-1717)
The pin names replay GSTA-224 H1; a reviewer checklist edit merges only after a
passing no-loss replay (crew rule 15). The /investigate flake line stays until a
replayed repin.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test: repair free-suite fallout from retiring /investigate (GST-1717)
CI run 42340956269 at 83a8a9a: drop fixtures, ledger rows, allowlist entries and
counts for the retired skill and its deleted paid files; record the harness
change as non-behavioral; the test-of-test detector accepts path.join(ROOT, 'bin');
uncovered-prompt fixtures use a tracked prompt, since an untracked path now
reads as a deleted one.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(relink): back up a retired skill's real SKILL.md before cleaning it (GST-1717)
With the skill's source gone, the customized-file check never ran, so a
banner-carrying local copy of investigate/SKILL.md was deleted instead of moved
to the backup root (red-team review, pass 1).
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(qm): restore the review checklist's flake-line rewrite (GST-1717)
review/checklist.md keeps its pinned /investigate line, so the QM edition needs
its replaceText rule back; qm/ stays fresh against the generator.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): name the setup flag break, the relink backup and the pinned checklist line (GST-1717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(setup,relink): back up a retired skill's real SKILL.md instead of deleting it (GST-1717)
Scoped fix round under grant a-360dd62bd46a (outside-voice blocking finding and
adversarial #1, #4). setup's prune compares a copied host entry with the render
before removing that render, and backs up a copy that differs or whose render is
gone; relink no longer takes the marker's rm -rf for a skill whose source is
gone, so a real SKILL.md is backed up and the user's files stay. setup reports a
failed remove-source of the retired gate hooks on stderr.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(pr-profile): a changed prompt counts as deleted only when it is gone from disk (GST-1717)
An untracked prompt file on disk still needs prompt validation (targeted review
finding); harness change recorded as non-behavioral.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): exact backup wording, the hook-removal warning and GST-1744 (GST-1717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(setup): one backup folder per host for a retired skill's copies (GST-1717)
Under grant a-c95576b8b1f9 (fix-check#1): every copy host moved its
gstack-investigate/SKILL.md to the same backup path, so a later host's copy
overwrote an earlier host's edits. A sandboxed ./setup --host factory run showed
gen-skill-docs removes the retired render before the prune, so every real copy
is backed up; each host now gets its own folder.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): say exactly what setup backs up for a retired skill (GST-1717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(changelog): end the two colon sentences prose-lint flagged (GST-1717)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test(retired-skills): name plan-eng-review once behind a pregate-literal waiver (GST-1717)
pregate's literals check read the GSTACK_RETIRED_SKILLS change as an old
value still in the tests. plan-eng-review is still retired; investigate was
appended. The fixture names it once, with the waiver.
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>
213 lines
10 KiB
TypeScript
213 lines
10 KiB
TypeScript
/**
|
|
* AUQ format is ALWAYS-LOADED — the token-reduction safety net (gate, free).
|
|
*
|
|
* The anxiety this kills: carving a skill into a small skeleton + on-demand
|
|
* `sections/*.md` could strand the AskUserQuestion decision-brief format (or a
|
|
* per-skill AUQ rule) in a section that is NOT in context when a question
|
|
* fires. The user would then see an AUQ with no ELI10, no Recommendation, no
|
|
* Pros/Cons — exactly the degradation we must guarantee never happens.
|
|
*
|
|
* The guarantee, made mechanical and per-PR:
|
|
* 1. UNIVERSAL — every interactive skill (anything that ships the
|
|
* `## AskUserQuestion Format` block, i.e. preamble tier >= 2) carries the
|
|
* FULL format spec in its always-loaded `SKILL.md` skeleton, NOT only in a
|
|
* section. The preamble is always in context, so the format spec is present
|
|
* the instant ANY question fires — Step 0, mode select, or a review finding.
|
|
* Since the shared-preamble hoist (GSTA-96) a tier 2+ skill's startup is its
|
|
* SKILL.md plus the shared sections/preamble.md that its "load first" pointer
|
|
* requires before the start command (test/helpers/skill-startup.ts; the
|
|
* pointer's position and the hoist's no-change proof are in
|
|
* test/preamble-hoist.test.ts).
|
|
* 2. REGRESSION — a known roster of interactive skills MUST still ship the
|
|
* block. A botched carve that drops `{{PREAMBLE}}` from a skeleton fails
|
|
* here in milliseconds instead of surfacing as a garbled question weeks
|
|
* later.
|
|
* 3. CARVE-SAFETY — for skills that ARE carved (have a `sections/` dir), the
|
|
* format block must live in `SKILL.md`, and any per-skill review-cadence
|
|
* rule that moved into a section must still exist somewhere in the
|
|
* skeleton+sections union (dropped-entirely is the failure).
|
|
*
|
|
* This is deterministic and free, so it runs on every `bun test`. It is the
|
|
* floor under the paid behavioral/substance/consistency E2Es.
|
|
*/
|
|
import { describe, test, expect } from 'bun:test';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import { readSkillStartup, SHARED_PREAMBLE_FILE } from './helpers/skill-startup';
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
|
|
/** Mandatory elements of the AskUserQuestion decision-brief format. Each is a
|
|
* label/marker the preamble resolver emits (generate-ask-user-format.ts) and
|
|
* that the model needs in context to render a compliant question. */
|
|
const MANDATORY: Array<{ name: string; re: RegExp }> = [
|
|
{ name: '## AskUserQuestion Format header', re: /##\s*AskUserQuestion Format/i },
|
|
{ name: 'ELI10 label', re: /ELI10\s*:/i },
|
|
{ name: 'Stakes-if-we-pick-wrong line', re: /Stakes if we pick wrong/i },
|
|
{ name: 'Recommendation line (mandatory)', re: /Recommendation\s*:/i },
|
|
{ name: '(recommended) label', re: /\(recommended\)/i },
|
|
{ name: 'Pros / cons header', re: /Pros\s*\/\s*cons/i },
|
|
{ name: '✅ pro bullet', re: /✅/ },
|
|
{ name: '❌ con bullet', re: /❌/ },
|
|
{ name: 'Net: synthesis line', re: /Net\s*:/i },
|
|
{ name: 'Completeness coverage rule', re: /Completeness\s*:/i },
|
|
{ name: 'kind-vs-coverage rule', re: /options differ in kind/i },
|
|
{ name: 'Self-check checklist', re: /Self-check before emitting/i },
|
|
// The runtime-failure fallback must be ALWAYS-LOADED too: when an AUQ call errors
|
|
// mid-skill, the model needs the prose-fallback rule in context that instant, not
|
|
// stranded in an on-demand section. Same guarantee as the format spec above.
|
|
{ name: 'AUQ-failure fallback subsection', re: /When AskUserQuestion is unavailable or a call fails/i },
|
|
{ name: 'fallback SESSION_KIND branch', re: /SESSION_KIND/ },
|
|
];
|
|
|
|
/** Per-skill AUQ rules that govern review-finding cadence. A carve may move
|
|
* these into a section (they fire only once the section is loaded), but they
|
|
* must never be DROPPED. Asserted against the skeleton+sections union. */
|
|
const PER_SKILL_RULES: Record<string, RegExp[]> = {
|
|
'plan-ceo-review': [/One decision unit = one AskUserQuestion call/i],
|
|
'plan-eng-review': [/one\s+question object for one choice/i, /independently selectable changes separate IDs/i],
|
|
'plan-design-review': [/One issue = one AskUserQuestion call/i],
|
|
'plan-devex-review': [
|
|
/One new or reopened decision = one AskUserQuestion call/i,
|
|
/Never combine independent decisions, including in separate question tabs/i,
|
|
],
|
|
// /codex emits its recommendation as prose; the instruction must stay in the
|
|
// always-loaded skeleton because codex has no on-demand section.
|
|
codex: [/Synthesis recommendation/i, /Recommendation\s*:\s*<action>\s*because/i],
|
|
};
|
|
|
|
/** Discover every repo-root skill dir that ships a generated SKILL.md. */
|
|
function discoverSkills(): Array<{ skill: string; skillMd: string; sectionsDir: string | null }> {
|
|
return fs
|
|
.readdirSync(ROOT, { withFileTypes: true })
|
|
.filter(d => d.isDirectory())
|
|
.map(d => d.name)
|
|
.filter(skill => fs.existsSync(path.join(ROOT, skill, 'SKILL.md')))
|
|
.map(skill => {
|
|
const sectionsDir = path.join(ROOT, skill, 'sections');
|
|
// Carved means a section beyond the shared preamble every tier 2+ skill ships.
|
|
const carved = fs.existsSync(sectionsDir)
|
|
&& fs.readdirSync(sectionsDir).some(f => f.endsWith('.md') && f !== SHARED_PREAMBLE_FILE);
|
|
return {
|
|
skill,
|
|
skillMd: path.join(ROOT, skill, 'SKILL.md'),
|
|
sectionsDir: carved ? sectionsDir : null,
|
|
};
|
|
});
|
|
}
|
|
|
|
const skills = discoverSkills();
|
|
/** A skill is "interactive" if its always-loaded SKILL.md ships the format
|
|
* block. That is the population that must be fully compliant. */
|
|
const interactive = skills.filter(s =>
|
|
/##\s*AskUserQuestion Format/i.test(readSkillStartup(s.skillMd)),
|
|
);
|
|
|
|
/** Roster guard: these interactive skills MUST keep shipping the format block.
|
|
* If a carve/refactor drops it, this list still expects them and the membership
|
|
* test below fails. Derived from "fires AUQ at the user" — the plan/review/
|
|
* advisory skills plus codex. */
|
|
const EXPECTED_INTERACTIVE = [
|
|
'plan-ceo-review',
|
|
'plan-eng-review',
|
|
'plan-design-review',
|
|
'plan-devex-review',
|
|
'office-hours',
|
|
'ship',
|
|
'review',
|
|
'qa',
|
|
'qa-only',
|
|
'codex',
|
|
'autoplan',
|
|
// CSO uses a private startup and intentionally omits the shared PREAMBLE,
|
|
// including its generic AskUserQuestion formatting block.
|
|
'retro',
|
|
'design-review',
|
|
'design-consultation',
|
|
'spec',
|
|
'land-and-deploy',
|
|
];
|
|
|
|
describe('AUQ format is always-loaded (token-reduction safety net)', () => {
|
|
test('discovered a sane number of interactive skills', () => {
|
|
// Guards against a glob/path regression that would make the per-skill
|
|
// loop vacuously pass with zero skills.
|
|
expect(interactive.length).toBeGreaterThanOrEqual(15);
|
|
});
|
|
|
|
test('every expected interactive skill still ships the AUQ format block', () => {
|
|
const names = new Set(interactive.map(s => s.skill));
|
|
const missing = EXPECTED_INTERACTIVE.filter(s => !names.has(s));
|
|
if (missing.length > 0) {
|
|
throw new Error(
|
|
`These skills lost their always-loaded AskUserQuestion format block ` +
|
|
`(a carve or refactor likely dropped {{PREAMBLE}} from the skeleton):\n` +
|
|
missing.map(s => ` - ${s}/SKILL.md`).join('\n'),
|
|
);
|
|
}
|
|
});
|
|
|
|
for (const { skill, skillMd } of interactive) {
|
|
test(`${skill}: full AUQ format spec present in always-loaded SKILL.md`, () => {
|
|
const body = readSkillStartup(skillMd);
|
|
const gaps = MANDATORY.filter(m => !m.re.test(body));
|
|
if (gaps.length > 0) {
|
|
throw new Error(
|
|
`${skill}/SKILL.md (the always-loaded skeleton) is missing ${gaps.length} ` +
|
|
`mandatory AUQ format element(s) — a question firing here would degrade:\n` +
|
|
gaps.map(g => ` - ${g.name} (${g.re.source})`).join('\n'),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
// CARVE-SAFETY: for carved skills, the format block must be in the SKELETON,
|
|
// not only a section. (The per-skill loop above already reads SKILL.md, so
|
|
// this is an explicit, named guard for the exact failure mode.) Keyed on the
|
|
// skeleton+sections UNION shipping the block at all: tier-1 carves (browse)
|
|
// never render AUQ format by design, so they have nothing to guard — but a
|
|
// tier≥2 carve that wrongly moved the block into a section still trips here.
|
|
const shipsAuqInUnion = (s: { skillMd: string; sectionsDir: string | null }): boolean => {
|
|
let union = readSkillStartup(s.skillMd);
|
|
if (s.sectionsDir) {
|
|
for (const f of fs.readdirSync(s.sectionsDir).filter(f => f.endsWith('.md') && !f.endsWith('.md.tmpl'))) {
|
|
union += '\n' + fs.readFileSync(path.join(s.sectionsDir, f), 'utf-8');
|
|
}
|
|
}
|
|
return /##\s*AskUserQuestion Format/i.test(union);
|
|
};
|
|
for (const { skill, skillMd, sectionsDir } of skills.filter(s => s.sectionsDir && shipsAuqInUnion(s))) {
|
|
test(`${skill} (carved): AUQ format block lives in the skeleton, not only sections/`, () => {
|
|
const body = readSkillStartup(skillMd);
|
|
expect(body).toMatch(/##\s*AskUserQuestion Format/i);
|
|
expect(body).toMatch(/ELI10\s*:/i);
|
|
expect(body).toMatch(/Recommendation\s*:/i);
|
|
});
|
|
}
|
|
|
|
// PER-SKILL RULES: review-cadence rules may move into a section, but must
|
|
// never be dropped from the skeleton+sections union.
|
|
for (const [skill, rules] of Object.entries(PER_SKILL_RULES)) {
|
|
test(`${skill}: per-skill AUQ rules survive in skeleton+sections union`, () => {
|
|
const skillDir = path.join(ROOT, skill);
|
|
if (!fs.existsSync(path.join(skillDir, 'SKILL.md'))) {
|
|
throw new Error(`${skill}/SKILL.md not found — roster is stale`);
|
|
}
|
|
let union = readSkillStartup(path.join(skillDir, 'SKILL.md'));
|
|
const secDir = path.join(skillDir, 'sections');
|
|
if (fs.existsSync(secDir)) {
|
|
for (const f of fs.readdirSync(secDir).filter(f => f.endsWith('.md') && !f.endsWith('.md.tmpl'))) {
|
|
union += '\n' + fs.readFileSync(path.join(secDir, f), 'utf-8');
|
|
}
|
|
}
|
|
const dropped = rules.filter(re => !re.test(union));
|
|
if (dropped.length > 0) {
|
|
throw new Error(
|
|
`${skill}: per-skill AUQ rule(s) dropped from skeleton+sections union:\n` +
|
|
dropped.map(re => ` - ${re.source}`).join('\n'),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
});
|