* docs(#3883): correct section 8.3 against the tree
I wrote this section in Phase 0 stating rules I had not executed against the
tree. Measured at 832dcbb75, three statements are wrong.
The slug count is 11 across 5 files, not 13; two of the thirteen were an
unrelated tokenizer regex. The divergence is real and reproduced.
resolveRuntime reads no install marker at all and has no cache; PR #3382,
cited as prior art for that rung, is closed unmerged.
The Codex sandbox is still a hand-maintained subset map with a silent
read-only fallback, and validate agents checks file presence only -- both
halves of that claim are false.
The shortFormToId rule is accurate. The guard roster names no casualty for
this rule.
Section 8.3 is therefore a work list, not a conformance check.
Refs #3883
* test(#3883): failing-first rows for slug re-implementation divergence
Refs #3883
* feat(#3883): route every slug call site through its canonical owner
Migrated commands.cts:209, init.cts:176/1935/1957/3109, phase-id.cts:229/380, phase-locator.cts:269, workstream-name-policy.cts:75 to generateSlugInternal (core-utils.cts:107).
Declared different: gsd2-import.cts:97 (no truncation), active-workstream-store.cts:97 (fixed ASCII env-key domain, already matches).
Fixed a latent circular-require bug: core-utils.cts top-level destructured comparePhaseNum/scopeToPhase from phase-id.cjs; switched both sides of the new circular require to lazy function-body requires.
Refs #3883
* fix(#3883): restore per-site truncation contracts broken by the slug consolidation
Refs #3883
* fix(#3883): close review findings — changeset, miscounts, loose rows, cyclic destructure
Refs #3883
* docs(#3883): correct the same slug miscount in the Context table
Section 8.3's rule text was corrected to 11 copies across 7 files; the Context
table above it still carried the original 13 across 5. Same wrong claim, second
location, both mine.
Refs #3883
* chore(#3883): backfill changeset PR number
Refs #3883
* test(#3883): keep the core-utils mutation shard inside its time budget
PR #3896's Stryker (core-utils) shard was cancelled at the 15-minute
shard cap. Stryker's command-runner bills one `node --test <file>`
invocation as a single unit costing whatever the file's slowest run
costs, re-run once per mutant (documented in
tests/state-contract.test.cjs's header, #2790 precedent). A3/A5 drove
every CLI-reachable slug site through runGsdTools (a real child-process
spawn per call, ~85-170ms each across ~70 calls), accounting for ~7.1s
of the file's ~7.9s wall time.
commands.cts:cmdGenerateSlug and init.cts:cmdInitExecutePhase/
cmdInitPhaseOp/cmdInitProgress are plain functions reachable in-process
from the built gsd-core/bin/lib/*.cjs, so this calls them directly
instead of spawning gsd-tools, capturing their fd-1 JSON output with the
bug #1008 fs.writeSync-mock pattern already used in tests/io.test.cjs
and tests/init.test.cjs. A hermetic-env helper reproduces the isolation
runGsdTools's { HOME: tmpDir } + testEnvBase() gave the child process.
File wall time drops from ~7.97s to ~1.1s (246/246 passing, same
coverage), well inside the 15-minute cap even at hundreds of mutants.
Refs #3883
---------
Co-authored-by: sim <sim@local>
69 lines
2.8 KiB
JavaScript
69 lines
2.8 KiB
JavaScript
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const {
|
|
normalizeWorkstreamNameInput,
|
|
validateActiveWorkstreamName,
|
|
assertValidActiveWorkstreamName,
|
|
isValidActiveWorkstreamName,
|
|
toWorkstreamSlug,
|
|
INVALID_ACTIVE_WORKSTREAM_NAME_MESSAGE,
|
|
} = require('../gsd-core/bin/lib/workstream-name-policy.cjs');
|
|
const { escapeRegex } = require('../gsd-core/bin/lib/pattern.cjs');
|
|
|
|
describe('workstream-name-policy', () => {
|
|
test('normalizeWorkstreamNameInput trims and nulls empty input', () => {
|
|
assert.equal(normalizeWorkstreamNameInput(' alpha '), 'alpha');
|
|
assert.equal(normalizeWorkstreamNameInput(' '), null);
|
|
assert.equal(normalizeWorkstreamNameInput(null), null);
|
|
});
|
|
|
|
test('validateActiveWorkstreamName returns structured validation', () => {
|
|
assert.deepEqual(
|
|
validateActiveWorkstreamName('alpha_1'),
|
|
{ ok: true, reason: null, value: 'alpha_1' }
|
|
);
|
|
assert.deepEqual(
|
|
validateActiveWorkstreamName('alpha beta'),
|
|
{ ok: false, reason: 'invalid', value: 'alpha beta' }
|
|
);
|
|
assert.deepEqual(
|
|
validateActiveWorkstreamName('../alpha'),
|
|
{ ok: false, reason: 'invalid', value: '../alpha' }
|
|
);
|
|
assert.deepEqual(
|
|
validateActiveWorkstreamName(' '),
|
|
{ ok: false, reason: 'empty', value: null }
|
|
);
|
|
});
|
|
|
|
test('assertValidActiveWorkstreamName returns normalized value and throws canonical error', () => {
|
|
assert.equal(assertValidActiveWorkstreamName(' alpha '), 'alpha');
|
|
assert.throws(
|
|
() => assertValidActiveWorkstreamName('alpha/beta'),
|
|
new RegExp(escapeRegex(INVALID_ACTIVE_WORKSTREAM_NAME_MESSAGE))
|
|
);
|
|
});
|
|
|
|
test('isValidActiveWorkstreamName accepts canonical and rejects invalid names', () => {
|
|
assert.equal(isValidActiveWorkstreamName('alpha-1'), true);
|
|
assert.equal(isValidActiveWorkstreamName('ws..traversal'), false);
|
|
assert.equal(isValidActiveWorkstreamName('alpha beta'), false);
|
|
});
|
|
|
|
// #3883 regression: the slug consolidation (01cc283da) routed
|
|
// toWorkstreamSlug through generateSlugInternal's hard-coded 60-char cap,
|
|
// which this site never had. Two distinct >60-char names collapsed onto
|
|
// the identical slug, so `workstream create` on the second name silently
|
|
// wrote into (or reported already_exists for) the first name's directory.
|
|
test('toWorkstreamSlug does not truncate — distinct long names stay distinct', () => {
|
|
const nameA = `${'a'.repeat(60)}alpha`;
|
|
const nameB = `${'a'.repeat(60)}beta`;
|
|
const slugA = toWorkstreamSlug(nameA);
|
|
const slugB = toWorkstreamSlug(nameB);
|
|
assert.notEqual(slugA, slugB, 'distinct >60-char workstream names must not collide on slug');
|
|
assert.equal(slugA, `${'a'.repeat(60)}alpha`);
|
|
assert.equal(slugB, `${'a'.repeat(60)}beta`);
|
|
});
|
|
});
|