mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-27 23:21:53 +02:00
* fix(memory-ingest): --scan-secrets scans the rendered page and fails closed --scan-secrets ran gitleaks on the raw transcript .jsonl, then imported a page rendered from it. gitleaks' assignment rules don't match across a JSON-escaped quote (KEY=\"v\" on disk), so a secret the rendered page shows as KEY="v" was imported unflagged. And the gate skipped a file only on scanner "gitleaks" with findings, so a scan that errored (non-zero exit, 16MB maxBuffer overflow on a file with many findings, unparseable report) or could not run (gitleaks missing, slow-probe cooldown) imported the file unscanned. Scan the rendered page body, the exact bytes writeStaged() writes, via a new secretScanText() helper, and skip the file whenever the scan did not complete. Skipped files stay out of the state file, so the next run retries them. Reword the helper warnings and setup-gbrain/memory.md, which described the fail-open as intended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(test): reconcile Bun failure markers and footer counts * fix(sync-gbrain): verify source-scoped reads without mutation * fix(test): recognize grounded TTHW target choices structurally * fix(aside): make the readiness probe work under zsh and report why it failed The probe built its deadline into `_T` and expanded it unquoted, so `$_T aside repl …` only worked in a shell that word-splits. zsh does not: it looked for a command literally named "gtimeout 30", the probe answered ASIDE_NOT_RUNNING with Aside installed and ready, and every browsing skill fell back to the bundled Chromium in silence. zsh is the macOS default and Aside is macOS-only, so on a stock Mac the probe could never report READY. The deadline becomes a function, `_gs_d`. It receives the command as "$@", already split, so sh, bash and zsh all behave the same, and the gtimeout → timeout → perl alarm chain is unchanged. A 4th arm runs the call unbounded when none of the three is present, which is what the empty `_T` did before. Not `eval`: it re-parses the string, so the parens and `;` of the perl arm become syntax and that arm dies in bash *and* zsh — on a stock Mac, the arm that actually runs. On failure the probe now prints the CLI's reason after ASIDE_NOT_RUNNING:, the shape gstack-render already uses: the first line that starts with a capital letter, i.e. the CLI's own sentence or Node's `Error:` line below its loader frame. "Not running" covers states with different fixes — no window open for the profile, a NODE_OPTIONS preload that kills the CLI — and a bare verdict sent all of them to "open the Aside app". The BROWSER SETUP prose quotes that reason before asking the user to open the app. The text pin asserted the broken invocation verbatim, so it now pins the function and asserts neither `$_T aside repl` nor an eval form comes back. A second test executes the rendered probe in sh, bash and zsh on each of the four deadline arms with stubbed binaries on a narrowed PATH, plus two failing CLIs: one that prints its own sentence, one that crashes like Node with the useful line below the frame. The deadline function costs zero bytes against the lines it replaces; the reason costs 53 per copy of the probe (44 where the reworded BROWSER SETUP line gives 9 back). That moves four guards by the measured amount: plan-devex-review's skeleton cap to 68,550 (measured 68,544), plan-ceo-review's skeleton cap to 80,150 (measured 80,111) and union ratio to 1.081 (measured 1.0803), and plan-eng-review's union ratio to 1.151 (measured 1.1504). Fixes #2842, #2941. * Clarify engineering review startup and decision flow * Fix Windows readiness fixture PATH and command shim * fix(test): recognize grounded TTHW target choices structurally * Clarify engineering review startup and decision flow * fix(test): restrict QA-only fixture tools to its no-Edit contract * v1.90.0.0 fix(sync-gbrain): guard readiness verdicts and refresh metadata * fix(browse): validate canonical upload targets * fix(gbrain): classify structured PGLite busy response * fix(browse): preserve native extension runtime APIs * Fix displayless browser handoff ownership * Accept unique installed autoplan methodology aliases * fix(skills): preserve positional literals during installation * fix(browse): checksum installer contents through stdin * fix(test): normalize Windows checksum fixture paths * test: emulate unavailable shasum in Windows checksum fixture * fix(investigate): preserve owned freeze lifecycle * fix(review): preserve N+1 retry and Red Team completion * fix: bound Aside readiness and preserve safe fallback * test: exercise setup and Chromium on native ARM * fix: preserve install ownership and ARM browser selection * Fix gbrain ingest scan boundaries and seed observation * Refresh managed ship hooks and supervise expanded paid census * Reject resumed gbrain pages excluded by current policy * Recover zombie agent locks safely and enable CI Python venv * Repair paid actor declarations and Aside pitch assertions * Bump consolidated wave to next free minor release * Clarify CEO review admin choices and option tradeoffs * Preserve CEO mode handoff anchors in clarified workflow * Make Windows portability fixtures use shell-native paths * Restore ARM Bun alias and clarify ship review gates * Refresh ship workflow golden snapshots * Fix Windows DX documentation controls without piped stdin * Decode Codex child pipes without Bun's encoded-stream stall * Bound DX pre-review audit before product questions * Clarify trusted review-start read in paid revalidation * Bump consolidated wave to next free minor release * Clarify CEO review admin choices and option tradeoffs * Preserve CEO mode handoff anchors in clarified workflow * Make Windows portability fixtures use shell-native paths * Restore ARM Bun alias and clarify ship review gates * Refresh ship workflow golden snapshots * Fix Windows DX documentation controls without piped stdin * Decode Codex child pipes without Bun's encoded-stream stall * Bound DX pre-review audit before product questions * Clarify trusted review-start read in paid revalidation * Reconcile new main planning flow and paid judge census * fix: reconcile rebased planning and source-bound validation * test: pin cookie workflow judge to scored Sonnet model * fix: keep terminal agent boot out of module imports * fix: preserve pending-question uncertainty in engineering review * fix: stabilize Windows reliability-wave fixtures * fix: clarify design consultation research workflow * fix: preserve independent design consultation inputs * fix: resolve design taste scope and browser research guidance * fix: make consultation opt-in preflight unambiguous * test: await native Edge owner readiness or terminal result --------- Co-authored-by: Bruce Krysiak <brucek@alum.mit.edu> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Antonio Vitalic <antoninte99@gmail.com>
211 lines
15 KiB
TypeScript
211 lines
15 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { readFileSync } from 'node:fs';
|
|
import { ALL_HOST_CONFIGS } from '../hosts';
|
|
import { HOST_PATHS, type TemplateContext } from '../scripts/resolvers/types';
|
|
import { generateDesignOutsideVoices, generateOverusedFonts, generateDesignShotgunLoop, generateTasteProfile, generateDesignMdCheck, generateDesignSetup } from '../scripts/resolvers/design';
|
|
import { generateBrowseFallback } from '../scripts/resolvers/browse';
|
|
import { generateAsideSetup, generateAsideResearch } from '../scripts/resolvers/aside';
|
|
import { outsideVoiceInvocation } from '../scripts/resolvers/outside-voice';
|
|
import { validateOutsideReview } from '../lib/outside-review-result';
|
|
|
|
const context = (host: string, skillName = 'design-consultation'): TemplateContext => ({ host, skillName, tmplPath: `${skillName}/SKILL.md.tmpl`, paths: HOST_PATHS[host] });
|
|
for (const { name: host } of ALL_HOST_CONFIGS) {
|
|
test(`${host}: proposal prompt requests the same completion marker that dispatch validates`, () => {
|
|
const text = generateDesignOutsideVoices(context(host));
|
|
const prompt = text.match(/"(Given this product context, propose a complete design direction:[\s\S]*?)"\n/)!;
|
|
expect(prompt).not.toBeNull();
|
|
expect(prompt[1]).toContain('Recommendation: <direction> because <product-specific reason>');
|
|
expect(validateOutsideReview('Recommendation: use a compact triage table because operators compare many incident rows.', 'review').completed).toBe(true);
|
|
expect(validateOutsideReview('A compact table sounds nice.', 'review').completed).toBe(false);
|
|
const preparation = outsideVoiceInvocation(context(host), { timeoutMs: 300000, purpose: 'design-direction' });
|
|
expect(preparation).toContain('missing Recommendation marker');
|
|
expect(preparation).not.toMatch(/severity|no.findings|clean\/PASS/i);
|
|
expect(preparation.includes('Claude Code has no tools, git or path access')).toBe(host === 'codex');
|
|
expect(preparation).toContain('including actual plan/spec/source');
|
|
expect(text).toContain('outside_status="unavailable"');
|
|
expect(text).toContain('otherwise \"none\"');
|
|
expect(text).toContain('run the command twice: one record for each voice, including any unavailable voice');
|
|
expect(text).toContain('Both records carry the actual CLI outcome');
|
|
expect(text).toContain('| User declined both (one record) | skipped | none | skipped |');
|
|
expect(text).toContain('| Native subagent completed | clean or issues_found | in-host | actual');
|
|
expect(text).toContain('substitute its shell-quoted absolute path for the literal <prepared-prompt-file>');
|
|
expect(text).toContain('every completed proposal (two, one, or none)');
|
|
expect(text).toContain('Do not choose a direction here');
|
|
expect(text).toContain('Q2 compares these proposals with your earlier draft');
|
|
expect(text).not.toContain('continuing with primary review');
|
|
expect(text).not.toContain('[single-model]');
|
|
});
|
|
}
|
|
|
|
test('creative wording leaves the review and scoring gates intact', () => {
|
|
const ctx = context('codex');
|
|
expect(outsideVoiceInvocation(ctx, { timeoutMs: 300000 })).toContain('explicit no-findings rationale');
|
|
expect(outsideVoiceInvocation(ctx, { timeoutMs: 300000, gate: 'structured' })).toContain('severity-tagged findings');
|
|
expect(outsideVoiceInvocation(ctx, { timeoutMs: 300000, gate: 'spec' })).toContain('SCORE: N');
|
|
});
|
|
|
|
test('preview paths retain verified fonts and select their own token source', () => {
|
|
const section = readFileSync(new URL('../design-consultation/sections/proposal-and-preview.md.tmpl', import.meta.url), 'utf8');
|
|
expect(section).toContain('Skipping competitive research does not waive font verification');
|
|
expect(section).toContain('mark font selection as pending verification');
|
|
expect(section).toContain('defer the preview until fonts can be verified');
|
|
expect(section).toContain("For Path B, use the approved HTML preview's CSS values");
|
|
expect(section).toContain('Only Path A invokes `$D extract`');
|
|
expect(section).not.toContain('## Approved Design Direction');
|
|
expect(section).toContain('approved mockup paths/tokens into Phase 6\'s "## Proposed DESIGN.md" plan section');
|
|
expect(section).toContain('Its Q-final approval governs saving that content');
|
|
expect(section).toContain('Only A permits the writes below');
|
|
expect(section).toContain('Prepare the complete DESIGN.md contents below');
|
|
expect(section).toContain('show the exact CLAUDE.md guidance');
|
|
expect(generateOverusedFonts(context('claude'))).toContain('font-verification fallback');
|
|
expect(generateOverusedFonts(context('claude', 'design-shotgun'))).not.toContain('font-verification fallback');
|
|
const loop = generateDesignShotgunLoop(context('claude'));
|
|
expect(loop).toContain('Read captured stderr for the startup marker');
|
|
expect(loop).toContain('a PID is not readiness');
|
|
expect(loop).toContain('the product page depicted by the chosen mockup');
|
|
});
|
|
|
|
|
|
test('consultation drafts before independent dispatch and compares completed input at Q2', () => {
|
|
const root = readFileSync(new URL('../design-consultation/SKILL.md.tmpl', import.meta.url), 'utf8');
|
|
const section = readFileSync(new URL('../design-consultation/sections/proposal-and-preview.md.tmpl', import.meta.url), 'utf8');
|
|
expect(root).not.toContain('{{DESIGN_OUTSIDE_VOICES}}');
|
|
expect(root).not.toContain('Draft your own direction');
|
|
expect(root.indexOf('{{SECTION:proposal-and-preview}}')).toBeGreaterThan(root.indexOf('## Phase 2: Research'));
|
|
const ordered = ['### Your Design Knowledge', '**Choosing faces:', '{{OVERUSED_FONTS}}', '{{DESIGN_SLOP_BULLETS}}', 'Draft your own direction', '{{DESIGN_OUTSIDE_VOICES}}', '**AskUserQuestion Q2'];
|
|
for (let i = 0; i < ordered.length; i++) {
|
|
expect(section.indexOf(ordered[i])).toBeGreaterThan(i === 0 ? -1 : section.indexOf(ordered[i - 1]));
|
|
}
|
|
expect(section).toContain("Keep that draft out of both reviewers' prompts");
|
|
expect(root).toContain('The optional outside-voices choice below still applies');
|
|
const question = section.slice(section.indexOf('**AskUserQuestion Q2'), section.indexOf('## Phase 4'));
|
|
expect(question).toContain('completed/unavailable/skipped voices');
|
|
expect(question).toContain('agreements, differences, ideas adopted and product-specific reasons');
|
|
expect(question).toContain('omit comparisons if none completed');
|
|
expect(section).toContain('Do not count agreement as a vote or invent a missing proposal');
|
|
expect(section).toContain('Verify any newly suggested fonts before adopting them');
|
|
expect(section).toContain('official Google Fonts/Fontshare listing');
|
|
expect(section).toContain('Carry the selected adjustment into the full Q2 proposal');
|
|
expect(section).toContain('label old proposals stale');
|
|
});
|
|
|
|
test('consultation opt-in probes the CLI without a disabled branch and rechecks its spawn', () => {
|
|
const text = generateDesignOutsideVoices(context('claude'));
|
|
const accepted = text.indexOf('**If accepted:**');
|
|
const availability = text.indexOf('**Check Codex availability:**');
|
|
const invocation = text.indexOf('1. **Codex design voice**');
|
|
expect(availability).toBeGreaterThan(accepted);
|
|
expect(invocation).toBeGreaterThan(availability);
|
|
const preflight = text.slice(availability, invocation);
|
|
expect(preflight).not.toContain('_OUTSIDE_CFG=enabled');
|
|
expect(preflight).not.toContain('CODEX_MODE: disabled');
|
|
expect(preflight).toContain('CODEX_MODE: under_current_harness');
|
|
expect(preflight).toContain('exit 78');
|
|
expect(text.slice(invocation)).toContain('exit 78');
|
|
});
|
|
|
|
test('optional browser research has one unavailable branch and reuses its readiness probe', () => {
|
|
const ctx = context('claude');
|
|
const fallback = generateBrowseFallback(ctx);
|
|
expect(fallback).toContain('Do not offer or run a build');
|
|
expect(fallback).toContain('skip Phase 2 Step 2; Step 1 still uses WebSearch');
|
|
expect(fallback).not.toContain('OK to proceed?');
|
|
const root = readFileSync(new URL('../design-consultation/SKILL.md.tmpl', import.meta.url), 'utf8');
|
|
expect(root).toContain('do not build or offer a build');
|
|
expect(root).toContain('count its retained `sessions` entries');
|
|
expect(root).toContain('Phase 2 findings with source URLs or an explicit declined/unavailable status');
|
|
expect(generateBrowseFallback(context('claude', 'qa'))).toContain('OK to proceed?');
|
|
const research = generateAsideResearch(ctx);
|
|
expect(research).toContain('Reuse the Phase 0 BROWSER SETUP result');
|
|
expect((generateAsideSetup(ctx) + research).match(/console\.log\("ASIDE_READY /g)).toHaveLength(1);
|
|
expect(research.toLowerCase()).toContain('read-only: do not sign in, submit, or change anything');
|
|
expect(research).toContain('Sanitize every query before it leaves the machine');
|
|
});
|
|
|
|
test('existing-system choices reach their matching final format without early writes', () => {
|
|
const root = readFileSync(new URL('../design-consultation/SKILL.md.tmpl', import.meta.url), 'utf8');
|
|
const section = readFileSync(new URL('../design-consultation/sections/proposal-and-preview.md.tmpl', import.meta.url), 'utf8');
|
|
expect(root).toContain('**Cancel:** STOP the skill now, with no file changes or further probes');
|
|
expect(root).toContain('**Update:** carry the existing decisions into Q1 as constraints');
|
|
expect(root).toContain('**Start fresh:** set aside prior visual choices');
|
|
expect(root).toContain('All conversion, marker and design writes wait for Q-final');
|
|
const format = generateDesignMdCheck(context('claude'));
|
|
expect(format).toContain('convert`, without `--write`');
|
|
expect(format).toContain('After Q-final approval outside plan mode');
|
|
expect(format).toContain('In plan mode, record the chosen format in Proposed DESIGN.md instead');
|
|
expect(section).toContain('Never convert a kept file just to make validation say spec');
|
|
expect(section).toContain('Any subsequent token, font or direction change invalidates that approval');
|
|
expect(section).toContain('E) Skip the preview — proceed to Phase 6\'s Q-final, not straight to writing');
|
|
});
|
|
|
|
test.each(ALL_HOST_CONFIGS.map(({ name }) => name))('%s: only Update with DESIGN.md enters the entire format-check block', host => {
|
|
const root = readFileSync(new URL('../design-consultation/SKILL.md.tmpl', import.meta.url), 'utf8');
|
|
const format = generateDesignMdCheck(context(host));
|
|
const gate = format.indexOf('**Update-only gate:**');
|
|
const command = format.indexOf('```bash');
|
|
const end = format.indexOf('**End of Update-only format check.**');
|
|
expect(gate).toBeGreaterThan(-1);
|
|
expect(command).toBeGreaterThan(gate);
|
|
expect(end).toBeGreaterThan(format.indexOf('**A) Convert**'));
|
|
expect(format.slice(gate, command)).toContain('Only **Update** with DESIGN.md enters this block (command and all result branches)');
|
|
expect(format.slice(gate, command)).toContain('**Start fresh**, **No existing file**, or a lone design-system.md: skip to **Gather product context from the codebase**');
|
|
expect(format.slice(gate, command)).toContain('**Cancel** has already stopped the skill');
|
|
expect(root.indexOf('**Gather product context from the codebase:**')).toBeGreaterThan(root.indexOf('{{DESIGN_MD_CHECK}}'));
|
|
expect(root).toContain('**Cancel:** STOP the skill now, with no file changes or further probes');
|
|
expect(generateDesignMdCheck(context(host, 'design-review'), ['calibrate'])).not.toContain('Update-only');
|
|
});
|
|
|
|
test('design command guidance carries session, extraction and quality-check side effects', () => {
|
|
const setup = generateDesignSetup(context('claude'));
|
|
const section = readFileSync(new URL('../design-consultation/sections/proposal-and-preview.md.tmpl', import.meta.url), 'utf8');
|
|
expect(setup).toContain('$D extract --image /absolute/path.png');
|
|
expect(setup).toContain('automatically update DESIGN.md');
|
|
expect(setup).toContain('`variants` returns `paths` but creates no session');
|
|
expect(section).toContain('`pass: false` means regenerate');
|
|
expect(section).toContain('`pass: true` with an unavailable/skipped warning is missing automated coverage');
|
|
expect(section).toContain('run it only in a fresh non-repository scratch directory');
|
|
expect(section).toContain('Empty arrays, an "Unable to extract" mood or command failure');
|
|
for (const command of (section + generateDesignShotgunLoop(context('claude'))).matchAll(/\$D iterate[^`\n]+/g)) {
|
|
expect(command[0]).toContain('--session');
|
|
}
|
|
});
|
|
|
|
test('board feedback distinguishes sessionless regeneration, final choice and missing input', () => {
|
|
const loop = generateDesignShotgunLoop(context('claude'));
|
|
const examples = [...loop.matchAll(/```json\n([\s\S]*?)```/g)].map(match => JSON.parse(match[1]));
|
|
expect(examples.find(value => value.regenerated === false)).toMatchObject({ preferred: 'A' });
|
|
expect(examples.find(value => value.regenerated === true)).toMatchObject({ regenerateAction: 'more_like_B' });
|
|
expect(loop).toContain('it does not emit a required `remixSpec`');
|
|
expect(loop).toContain('Archive this round\'s feedback files');
|
|
expect(loop).toContain('revisions regenerate; a final choice needs summary confirmation');
|
|
expect(loop).toContain('never infer approval from a missing file');
|
|
expect(loop).toContain('publishes to a persistent daemon, opens the board and exits');
|
|
expect(loop).toContain('Re-run the quality check and visual self-gate on every new image');
|
|
});
|
|
|
|
test('taste context has defined count and bounded legacy and malformed-profile fallbacks', () => {
|
|
const text = generateTasteProfile(context('claude'));
|
|
expect(text).not.toContain('SESSION_COUNT');
|
|
expect(text).not.toContain('head -200');
|
|
expect(text).toContain('Count retained sessions (at most 50, not lifetime)');
|
|
expect(text).toContain('malformed/unreadable uses the legacy fallback');
|
|
expect(text).toContain('Glob `~/.gstack/projects/$SLUG/designs/**/approved.json`');
|
|
expect(text).toContain('Read the five newest');
|
|
expect(text).toContain('No usable files: continue without a taste profile');
|
|
expect(text).toContain('never infer fonts/colors from variant letters');
|
|
expect(text).toContain('do not rewrite the file while reading');
|
|
});
|
|
|
|
test('board fallback names the same launch command and does not poll a failed server', () => {
|
|
const text = generateDesignShotgunLoop(context('claude'));
|
|
expect(text).toContain('$D compare --images');
|
|
expect(text).toContain('Nonzero exit or no readiness marker: show each variant inline');
|
|
expect(text).not.toContain('$D serve');
|
|
expect(text).not.toContain('POLLING FALLBACK');
|
|
expect(text).toContain('Exit 0 with `BOARD_URL` means the daemon is serving');
|
|
const fallback = text.slice(text.indexOf('**SERVER FALLBACK:**'), text.indexOf('**After receiving feedback'));
|
|
expect(fallback).not.toContain('In that case');
|
|
expect(fallback).not.toContain('means the daemon is serving');
|
|
expect(fallback).toContain('The comparison board server failed to start');
|
|
});
|