const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const repositoryRoot = path.resolve(__dirname, '..'); const validForm = '`work/fix//`'; const invalidForm = '`work//fix/`'; const documents = [ { file: 'AGENTS.md', approved: '- A targeted repair uses a clean, isolated `work/fix//` branch and worktree from the taskmaster-verified current `main`. Do not use `work//fix/`: the persistent `work/` ref already occupies that Git ref prefix.' }, { file: 'README.md', approved: 'For a targeted repair, create a clean isolated branch and worktree from the\ntaskmaster-verified current `main` named\n`work/fix//`. Do not nest it as\n`work//fix/`: the persistent `work/` ref already\nuses that Git ref prefix.' }, { file: 'DEVELOPMENT.md', approved: 'For a targeted repair, start a clean worktree from the taskmaster-verified\ncurrent `main` on `work/fix//`. Keep it separate from the\nfive persistent `work/` branches. Do not use\n`work//fix/` because the persistent `work/` ref\nalready occupies that Git ref prefix.' }, { file: 'TESTING.md', approved: 'Run that check from the clean targeted-fix branch named\n`work/fix//` when repairing one feature. Do not use\n`work//fix/`: a persistent `work/` ref already\noccupies that Git ref prefix. Record the expected RED and the matching GREEN\nshell output in the evidence record.' }, { file: 'docs/superpowers/specs/2026-08-15-access-navigation-icon-intern-picker-design.md', approved: 'Use `work/fix//` for each targeted repair. Create its clean,\nisolated worktree from the taskmaster-verified current `main`. The ``\nsegment identifies the owning persistent area; it does not nest below that\npersistent branch.\n\nThe forbidden form is `work//fix/`. A repair owner preserves\nother worktrees, records RED and GREEN evidence, commits locally, and does not\npush or merge without separate authority.' }, { file: 'docs/superpowers/plans/2026-08-15-access-navigation-icon-intern-picker.md', approved: '2. Add one branch rule to contributor guides, design records, plans, and tracked\n coordination authority: `work/fix//` from verified\n `main`.\n3. State why `work//fix/` is invalid while its persistent\n `work/` ref exists.' } ]; /** Validates that every tracked guide contains only its approved branch wording. */ function validate(contents) { const failures = []; for (const {file, approved} of documents) { const content = contents.get(file); if (count(content, validForm) !== 1) failures.push(`${file} must contain ${validForm} exactly once`); if (!content.includes(approved)) failures.push(`${file} is missing its approved branch workflow statement`); const outsideApprovedStatement = content.replace(approved, ''); if (outsideApprovedStatement.includes(validForm) || outsideApprovedStatement.includes(invalidForm)) { failures.push(`${file} contains an unapproved branch-form reference`); } } if (failures.length) throw new Error(failures.join('\n')); } function count(content, value) { return content.split(value).length - 1; } function readContents() { return new Map(documents.map(({file}) => [file, fs.readFileSync(path.join(repositoryRoot, file), 'utf8')])); } const contents = readContents(); validate(contents); if (process.argv.includes('--self-test')) { for (const {file} of documents) { const positiveRecommendation = new Map(contents); positiveRecommendation.set(file, `${contents.get(file)}\nUse ${invalidForm} for a targeted repair.\n`); assert.throws( () => validate(positiveRecommendation), (error) => error instanceof Error && error.message.includes(`${file} contains an unapproved branch-form reference`) ); } } console.log(`Fix-branch workflow documentation: ${documents.length} approved statements validated`); if (process.argv.includes('--self-test')) { console.log(`Positive nested branch recommendations: ${documents.length}/${documents.length} rejected`); }