Phase 1 of #3464. Removes the `// allow-test-rule:` marker from 22 test files where it is provably vestigial, and tightens the ratchet ceiling in scripts/lint-allow-test-rule-refs.ceiling.json from 305 to 285. Eligibility is decided by two independent AST discriminators, both conservative (any doubt => keep): (a) Read-target type. Every readFileSync/readFile call in the file resolves statically to a prose/config extension (.md/.json/.yml/.yaml/.toml/.txt), or the file performs no reads at all. Any read of a source extension (.cjs/.js/.mjs/.ts/.cts/.mts/.jsx/.tsx), any dynamic/unresolvable path, and any other extension all disqualify the file. (b) Marker context. Every `allow-test-rule:` occurrence is a genuine comment node, never string- or template-literal payload. A marker that lives inside a RuleTester `code:` fixture is test DATA, not a suppression directive; stripping it corrupts the test. tests/eslint-rules.test.cjs is the one such fixture host and is deliberately untouched. An earlier attempt at this phase classified markers by "strip it and see if local/no-source-grep still passes" and was reverted in full before commit. That oracle is unsound: the rule only fires on a literal .cjs/.js/.ts path containing a quoted bin/lib/gsd-core/src segment, tracked one hop from the binding, so files that genuinely source-grep real JavaScript pass it silently -- tests/no-unbounded-spawn-allowlist.test.cjs (reads test sources through a listTestFiles() walk) and tests/claude-imperative-reference.test.cjs (matches bin/install.js through an intermediate variable) both cleared it while being real source-greps. The rule's implementation is narrower than its intent, so it cannot adjudicate whether an exemption is load-bearing. Scope is limited to comment deletions: the diff over the test tree is 100% line removals with zero insertions, and no executable line is altered. On the ceiling value. The measured count at this HEAD is 283, so 285 leaves 2 slack -- deliberate, and well inside the documented grace band of 3. Pinning the ceiling to the exact count makes this change effectively unmergeable: any concurrent PR that lands one marker-bearing test file re-reds it. That race fired twice while preparing this branch (once mid-rebase taking the count 304->305 on next, once between rebase and the verification run taking it 282->283), and it is the same race that broke next in #3461. A ceiling of actual+2 preserves a merge window while still ratcheting 305 -> 285. Known limit, disclosed rather than papered over: this clears 22 of 303 markers and does not reach #3464's trend-to-zero goal. Most of the remaining markers sit on dynamic-path reads, commonly a hoisted `const p = path.join(tmpDir, 'STATE.md')` whose target is prose but is unresolvable to this classifier. A stricter one-hop const resolution would flip an estimated 95 more; that is deliberately left to a follow-up so it can be reviewed on its own evidence. Marker discovery reads bytes rather than shelling out to grep: tests/security-prompt-injection.security.test.cjs carries a literal NUL byte (an intentional injection fixture) that makes grep treat it as binary and skip it, which is why the true marked-file count is 303 and not the 302 a shell scan reports. Closes #3465 Co-authored-by: sim <sim@local> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
109 lines
3.2 KiB
JavaScript
109 lines
3.2 KiB
JavaScript
'use strict';
|
|
|
|
// Reads .md/.json/.yml product files whose deployed text IS what the
|
|
// runtime loads — testing text content tests the deployed contract.
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
describe('thread session management (#2156)', () => {
|
|
const threadCmd = fs.readFileSync(
|
|
path.join(__dirname, '..', 'gsd-core', 'workflows', 'thread.md'),
|
|
'utf8'
|
|
);
|
|
|
|
test('thread command has list subcommand with status filter', () => {
|
|
assert.ok(
|
|
threadCmd.includes('list --open') || threadCmd.includes('LIST-OPEN'),
|
|
'missing list --open filter'
|
|
);
|
|
});
|
|
|
|
test('thread command has close subcommand', () => {
|
|
assert.ok(
|
|
threadCmd.includes('CLOSE') || threadCmd.includes('close <slug>'),
|
|
'missing close subcommand'
|
|
);
|
|
});
|
|
|
|
test('thread command has status subcommand', () => {
|
|
assert.ok(
|
|
threadCmd.includes('STATUS') || threadCmd.includes('status <slug>'),
|
|
'missing status subcommand'
|
|
);
|
|
});
|
|
|
|
test('thread command does not use heredoc', () => {
|
|
assert.ok(
|
|
!threadCmd.includes("<< 'EOF'") && !threadCmd.includes('<< EOF'),
|
|
'thread command still uses heredoc — injection risk'
|
|
);
|
|
});
|
|
|
|
test('thread template includes frontmatter status field', () => {
|
|
assert.ok(
|
|
threadCmd.includes('status: open') || threadCmd.includes('status:'),
|
|
'thread template missing frontmatter status field'
|
|
);
|
|
});
|
|
|
|
test('thread command has security_notes section', () => {
|
|
assert.ok(threadCmd.includes('security_notes'), 'missing security_notes section');
|
|
});
|
|
|
|
test('thread command has slug sanitization', () => {
|
|
assert.ok(
|
|
threadCmd.includes('sanitiz') || threadCmd.includes('[a-z0-9'),
|
|
'missing slug sanitization'
|
|
);
|
|
});
|
|
|
|
test('thread command uses Write tool for file creation', () => {
|
|
assert.ok(
|
|
threadCmd.includes('Write tool'),
|
|
'thread create mode should use the Write tool instead of heredoc'
|
|
);
|
|
});
|
|
|
|
test('thread command list reads frontmatter status', () => {
|
|
assert.ok(
|
|
threadCmd.includes('frontmatter get') || threadCmd.includes('frontmatter.get'),
|
|
'list mode should read status via frontmatter get / frontmatter.get'
|
|
);
|
|
});
|
|
|
|
test('thread command close updates status to resolved', () => {
|
|
assert.ok(
|
|
threadCmd.includes('resolved'),
|
|
'close mode should set status to resolved'
|
|
);
|
|
});
|
|
|
|
test('thread command list shows resolved filter option', () => {
|
|
assert.ok(
|
|
threadCmd.includes('list --resolved') || threadCmd.includes('LIST-RESOLVED'),
|
|
'missing list --resolved filter'
|
|
);
|
|
});
|
|
|
|
test('thread command rejects slugs with path traversal', () => {
|
|
assert.ok(
|
|
threadCmd.includes('..') && threadCmd.includes('reject'),
|
|
'missing path traversal rejection for slugs'
|
|
);
|
|
});
|
|
|
|
test('thread create uses frontmatter with slug title status created updated fields', () => {
|
|
assert.ok(
|
|
threadCmd.includes('slug:') &&
|
|
threadCmd.includes('title:') &&
|
|
threadCmd.includes('status:') &&
|
|
threadCmd.includes('created:') &&
|
|
threadCmd.includes('updated:'),
|
|
'thread template missing required frontmatter fields'
|
|
);
|
|
});
|
|
});
|