* test(#4378): regression tests for collision-free seed ids * fix(#4378): mint collision-free SEED-YYMMDD-xxx ids, not a shared count plant-seed derived the next seed id from 'ls .planning/seeds/SEED-*.md | wc -l'. .planning/seeds/ is shared but each worktree only sees what has merged, so two workstreams planting before either merges computed the same id and git merged both files silently. The id is now the local date plus a 3-char random base36 suffix -- the shape .planning/quick/ already uses -- computed from knowledge one worktree has alone, with a same-day regen guard. deriveSeedIdentity learns the new canonical grammar alongside legacy SEED-NNN (whose parsing never changes), the --enrich parser and the filename-prefix fallback keep the full new-format id, and the docs that state the filename shape move to it. The prefix fallback previously truncated any non-pure-numeric id at 'SEED-<digits>' -- the same one-id-two-answers ambiguity the issue reports, reproduced one level down. * fix(#4378): harden seed id generation per adversarial review - parse-idea: anchor the --enrich extractor to the flag and capture the complete id, uppercase-tolerant; a leftmost 'SEED-[0-9]+' truncated an uppercase or malformed suffix to its date and enriched an arbitrary same-day seed via head -1. Ambiguous and unmatched targets now fail closed instead. - generate-seed-id: tolerate the expected SIGPIPE under pipefail, abort loudly when the suffix cannot be drawn (an empty suffix would collapse every seed's id to the bare date), and run the same-day regen guard as a find existence test (the 'ls <glob>' shape trips the #3409 drift guard and degenerates under a stray nullglob). - deriveSeedIdentity: document the theoretical legacy/new grammar ambiguity (6-digit counter + 3-char base36 slug, no frontmatter). - changeset: state the residual same-day collision bound instead of implying zero. Emitted-Drift-Ack-Growth: plant-seed.md — the counting step became hardened date+random generation with explicit failure modes; growth is the failure handling, not duplicated logic * fix(#4378): address standards and spec review findings - tests: move the allow-test-rule marker to its suppression site (the file-header placement was inert per CONTRIBUTING site-scoping); add width-boundary coverage (5/7-digit dates, 2/4-char suffixes pin the documented branch behavior); add a writer-to-reader parity property that parses the mint widths out of the shipped workflow so the two grammar owners cannot drift; cover uppercase ids end-to-end in the reader. - plant-seed.md: draw/retry restructured as one loop with a loud terminal failure; SEED_SUFX renamed SEED_SUFFIX; regen guard drops the redundant head -1; the ambiguity error no longer advises an impossible 'complete id' for duplicate legacy ids. - commands.cts: refresh the cmdListSeeds comment still describing SEED-NNN as the only canonical form. - changeset: drop the audit claim the spec axis showed to be an overstatement (audit's id display is filename-derived, pre-existing). - remove a stray untracked artifact file swept into the tree. * test(#4378): correct boundary expectations to the module's real branch behavior The first matrix run on the boundary tests caught my hand-trace of the regex branches, not a module defect: the slug regex's alternation backtracks to the legacy branch whenever the canonical branch cannot complete (so the slug is the remainder after the legacy numeric prefix), and the 7-digit case fails the canonical branch at its 7th digit before the dash. Pin the verified values. * docs(#4378): backfill changeset PR number * fix(#4378): audit seed identity uses the canonical grammar Review of this PR found the audit surface publishing a fused filename stem (SEED-081-region for SEED-081-region.md) where list-seeds reports the canonical id -- one id, two answers across surfaces, the same ambiguity class the issue files. scanSeeds now derives identity through the SAME deriveSeedIdentity the list-seeds gate uses (frontmatter id, then filename id-prefix, then stem), and audit-open acknowledge resolves --seed-id by scanning for the derived identity, falling back to the literal stem so callers scripted against pre-canonical output keep working. Roll-in per the fix-inline rule: found during this PR's review, same seed-identity seam. RED probe: pre-fix audit published seed_id SEED-081-region-becomes / slug 081-region-becomes for a legacy seeded file; post-fix SEED-081 / region-becomes, matching list-seeds. * test(#4378): probe timeout uses the class norm after windows-lane timeout The windows conformance shard failed its bounded sh -c probes at the local 5000ms bound (cold sh.exe spawn under shard load) while the identical code passed this PR's two earlier windows waves. The probe now uses PROBE_TIMEOUT_MS from the class-norm module instead of a local override, per the helpers/timeouts.cjs convention. --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -2567,3 +2567,107 @@ describe('bug #950: quick-task SUMMARY must carry status: complete', () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// #4378 — audit seed identity agrees with list-seeds; acknowledge resolves
|
||||
// by canonical id (legacy stems still resolve for back-compat).
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
{
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
|
||||
function readJson4546(result) {
|
||||
assert.ok(result.success, `command must succeed. stdout: ${result.output}\nstderr: ${result.error}`);
|
||||
return JSON.parse(result.output);
|
||||
}
|
||||
|
||||
function auditJson(tmpDir) {
|
||||
return readJson4546(runGsdTools(['audit-open', '--json'], tmpDir));
|
||||
}
|
||||
|
||||
function ack4546(tmpDir, args) {
|
||||
return runGsdTools(['audit-open', 'acknowledge', ...args, '--json'], tmpDir);
|
||||
}
|
||||
|
||||
describe('audit seed identity agrees with list-seeds (#4378)', () => {
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => { tmpDir = createTempProject('gsd-4378-seedident-'); });
|
||||
afterEach(() => { cleanup(tmpDir); });
|
||||
|
||||
function planningPath(...segs) {
|
||||
return path.join(tmpDir, '.planning', ...segs);
|
||||
}
|
||||
|
||||
function seedItem(output, seedId) {
|
||||
const item = output.items.seeds.find((s) => s.seed_id === seedId);
|
||||
assert.ok(item, `expected a seed item with seed_id ${seedId}; got: ${JSON.stringify(output.items.seeds.map((s) => s.seed_id))}`);
|
||||
return item;
|
||||
}
|
||||
|
||||
test('legacy seed publishes the canonical frontmatter id, not the fused filename stem', () => {
|
||||
const seedsDir = planningPath('seeds');
|
||||
fs.mkdirSync(seedsDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(seedsDir, 'SEED-081-region-becomes.md'),
|
||||
'---\nid: SEED-081\nstatus: dormant\n---\n# SEED-081: region idea\n', 'utf8');
|
||||
|
||||
const output = auditJson(tmpDir);
|
||||
const item = seedItem(output, 'SEED-081');
|
||||
assert.strictEqual(item.slug, 'region-becomes',
|
||||
'slug is the remainder after the canonical id, matching list-seeds');
|
||||
assert.ok(!output.items.seeds.some((s) => s.seed_id === 'SEED-081-region-becomes'),
|
||||
'the fused filename stem must not resurface as a second id');
|
||||
});
|
||||
|
||||
test('date-suffixed seed publishes its full id (never truncated at the date prefix)', () => {
|
||||
const seedsDir = planningPath('seeds');
|
||||
fs.mkdirSync(seedsDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(seedsDir, 'SEED-260914-k3x-my-slug.md'),
|
||||
'---\nid: SEED-260914-k3x\nstatus: dormant\n---\n# SEED-260914-k3x: idea\n', 'utf8');
|
||||
|
||||
const output = auditJson(tmpDir);
|
||||
const item = seedItem(output, 'SEED-260914-k3x');
|
||||
assert.strictEqual(item.slug, 'my-slug');
|
||||
});
|
||||
|
||||
test('acknowledge resolves the canonical id to the real file and writes the marker', () => {
|
||||
const seedsDir = planningPath('seeds');
|
||||
fs.mkdirSync(seedsDir, { recursive: true });
|
||||
const legacyFile = path.join(seedsDir, 'SEED-081-region-becomes.md');
|
||||
fs.writeFileSync(legacyFile,
|
||||
'---\nid: SEED-081\nstatus: dormant\n---\n# SEED-081: region idea\n', 'utf8');
|
||||
|
||||
const result = ack4546(tmpDir, ['--category', 'seeds', '--seed-id', 'SEED-081', '--milestone', 'v1.0', '--at', '2026-09-15']);
|
||||
assert.ok(result.success, `acknowledge by canonical id must succeed. stderr: ${result.error}`);
|
||||
assert.match(fs.readFileSync(legacyFile, 'utf-8'), /^status: dormant$/m,
|
||||
'verdict-preserving: the seed status line must be unchanged');
|
||||
|
||||
const after = auditJson(tmpDir);
|
||||
assert.equal(after.counts.seeds, 0, 'acknowledged seed drops out of counts');
|
||||
});
|
||||
|
||||
test('full filename stem still resolves (back-compat with pre-canonical callers)', () => {
|
||||
const seedsDir = planningPath('seeds');
|
||||
fs.mkdirSync(seedsDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(seedsDir, 'SEED-081-region-becomes.md'),
|
||||
'---\nid: SEED-081\nstatus: dormant\n---\nbody\n', 'utf8');
|
||||
|
||||
const result = ack4546(tmpDir, ['--category', 'seeds', '--seed-id', 'SEED-081-region-becomes', '--milestone', 'v1.0', '--at', '2026-09-15']);
|
||||
assert.ok(result.success, `acknowledge by legacy stem must succeed. stderr: ${result.error}`);
|
||||
});
|
||||
|
||||
test('an unknown seed id still fails with the file-not-found error', () => {
|
||||
const seedsDir = planningPath('seeds');
|
||||
fs.mkdirSync(seedsDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(seedsDir, 'SEED-081-region-becomes.md'),
|
||||
'---\nid: SEED-081\nstatus: dormant\n---\nbody\n', 'utf8');
|
||||
|
||||
const result = ack4546(tmpDir, ['--category', 'seeds', '--seed-id', 'SEED-999', '--milestone', 'v1.0', '--at', '2026-09-15']);
|
||||
assert.equal(result.success, false, 'an unresolvable id must fail');
|
||||
assert.match(String(result.error), /file not found: seeds\/SEED-999\.md/,
|
||||
'the error names the unresolvable id exactly as before');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user