Files
get-shit-done/tests/execute-phase-active-flags.test.cjs
Tom Boucher 2703422be8 refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md (#1675)
* refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md

- Replace require('node:assert') with require('node:assert/strict') across
  all 73 test files to enforce strict equality (no type coercion)
- Replace try/finally cleanup blocks with t.after() hooks in core.test.cjs
  and hooks-opt-in.test.cjs per the test lifecycle standards
- Utility functions in codex-config and security-scan retain try/finally
  as that is appropriate for per-function resource guards, not lifecycle hooks

Closes #1674

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* perf(tests): add --test-concurrency=4 to test runner for parallel file execution

Node.js --test-concurrency controls how many test files run as parallel child
processes. Set to 4 by default, configurable via TEST_CONCURRENCY env var.
Fixes tests at a known level rather than inheriting os.availableParallelism()
which varies across CI environments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(security): allowlist verify.test.cjs in prompt-injection scanner

tests/verify.test.cjs uses <human>...</human> as GSD phase task-type
XML (meaning "a human should verify this step"), which matches the
scanner's fake-message-boundary pattern for LLM APIs. This is a
false positive — add it to the allowlist alongside the other test files
that legitimately contain injection-adjacent patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 14:29:03 -04:00

63 lines
2.5 KiB
JavaScript

/**
* Execute-phase active flag prompt tests
*
* Guards against prompt wording that makes optional flags look active by default.
* This is especially important for weaker runtimes that may infer `--gaps-only`
* from the command docs instead of the literal user arguments.
*/
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const COMMAND_PATH = path.join(__dirname, '..', 'commands', 'gsd', 'execute-phase.md');
describe('execute-phase command: active flags are explicit', () => {
test('command file exists', () => {
assert.ok(fs.existsSync(COMMAND_PATH), 'commands/gsd/execute-phase.md should exist');
});
test('objective says documented flags are not implied active', () => {
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
const objectiveMatch = content.match(/<objective>([\s\S]*?)<\/objective>/);
assert.ok(objectiveMatch, 'should have <objective> section');
assert.ok(
objectiveMatch[1].includes('available behaviors, not implied active behaviors'),
'objective should state that documented flags are not automatically active'
);
assert.ok(
objectiveMatch[1].includes('appears in `$ARGUMENTS`'),
'objective should tie flag activation to literal $ARGUMENTS presence'
);
});
test('context separates available flags from active flags', () => {
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
assert.ok(
content.includes('Available optional flags (documentation only'),
'context should clearly label flags as documentation only'
);
assert.ok(
content.includes('Active flags must be derived from `$ARGUMENTS`'),
'context should have a separate active-flags section'
);
});
test('context explicitly warns against inferring inactive flags', () => {
const content = fs.readFileSync(COMMAND_PATH, 'utf-8');
assert.ok(
content.includes('Do not infer that a flag is active just because it is documented in this prompt'),
'context should forbid inferring flags from documentation alone'
);
assert.ok(
content.includes('`--interactive` is active only if the literal `--interactive` token is present in `$ARGUMENTS`'),
'context should apply the same active-flag rule to --interactive'
);
assert.ok(
content.includes('If none of these tokens appear, run the standard full-phase execution flow'),
'context should define the no-flags fallback behavior'
);
});
});