'use strict'; /** * Governance tests for the msd-core repository root layout. * * Invariant: the repository root must not contain ad-hoc AI instruction files * (such as AGENTS.md) that would become an untracked source of truth running * in parallel with the canonical CONTEXT.md and docs/adr/ records. * * Context: historically bin/install.js (the since-retired local install * path, issue #786) wrote an AGENTS.md to process.cwd() when run inside a repo * checkout. If such a file is ever committed, editors and AI tools that auto-load * repo-root instruction files will silently pick up an installer-generated * stub rather than the authoritative documentation. This test ensures that * artefact never lands in source control. */ const test = require('node:test'); const assert = require('node:assert/strict'); const path = require('path'); const { runGit } = require('./helpers/process-seam.cjs'); const { GIT_TIMEOUT_MS } = require('./helpers/timeouts.cjs'); const ROOT = path.resolve(__dirname, '..'); test('repo-layout: root AGENTS.md is not git-tracked — no ad-hoc AI instruction file committed alongside CONTEXT.md', () => { // An installer-generated AGENTS.md may exist on disk after a local install // (historically a retired install path, issue #786). What must NOT happen is // committing it to git, where editors and AI tools would silently pick up // the installer-generated stub instead of CONTEXT.md. const r = runGit(['ls-files', '--error-unmatch', 'AGENTS.md'], { cwd: ROOT, timeoutMs: GIT_TIMEOUT_MS, }); const tracked = r.exitCode === 0; assert.equal( tracked, false, [ 'root AGENTS.md must not be git-tracked.', 'Installer-generated instruction stubs (historically issue #786) may land on disk', 'when the installer runs inside a repo checkout — their presence on disk is fine,', 'but they must never be committed.', 'The repository source of truth for architecture and contributor guidance is', 'CONTEXT.md and docs/adr/ — not an installer-generated instruction stub.', 'Run `git rm --cached AGENTS.md` to untrack it if accidentally staged.', ].join(' '), ); }); // ──────────────────────────────────────────────────────────────────────── // Folded from tests/enh-191-retire-sdk-package.test.cjs — consolidation epic #1969 (B5 #1974) // ──────────────────────────────────────────────────────────────────────── { const { describe: __foldDescribe } = require('node:test'); __foldDescribe("folded:enh-191-retire-sdk-package (consolidation epic #1969 B5 #1974)", () => { 'use strict'; const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('fs'); const path = require('path'); const ROOT = path.resolve(__dirname, '..'); const PKG_PATH = path.join(ROOT, 'package.json'); const INSTALL_PATH = path.join(ROOT, 'bin', 'install.js'); const ACTIVE_GUIDANCE_PATHS = [ 'docs/contributing/bootstrap.md', ]; function readPackageJson() { return JSON.parse(fs.readFileSync(PKG_PATH, 'utf8')); } test('enhancement #191: sdk package artifacts are removed from repository layout', () => { const sdkDir = path.join(ROOT, 'sdk'); const shimPath = path.join(ROOT, 'bin', 'msd-sdk.js'); assert.equal(fs.existsSync(sdkDir), false, 'sdk/ directory must be deleted'); assert.equal(fs.existsSync(shimPath), false, 'bin/msd-sdk.js must be deleted'); }); test('enhancement #191: published package no longer exposes msd-sdk artifacts', () => { const pkg = readPackageJson(); assert.equal(Object.prototype.hasOwnProperty.call(pkg.bin || {}, 'msd-sdk'), false, 'package.json bin must not expose msd-sdk'); assert.equal(pkg.bin && pkg.bin['msd-tools'], 'msd-core/bin/msd-tools.cjs', 'package.json bin.msd-tools must point to msd-core/bin/msd-tools.cjs'); const publishedFiles = Array.isArray(pkg.files) ? pkg.files : []; const hasSdkPublishedPaths = publishedFiles.some((entry) => String(entry).startsWith('sdk')); assert.equal(hasSdkPublishedPaths, false, 'package.json files must not include sdk artifacts'); }); test('enhancement #191: installer does not maintain msd-sdk shim compatibility path', () => { // allow-test-rule: structural-regression-guard (#3545) — asserting the // ABSENCE of a retired flag/function reference from install.js is a source // structure fact (dead-code regression), not something observable by // exercising the installer's runtime behavior. const installJs = fs.readFileSync(INSTALL_PATH, 'utf8'); assert.equal(/\b--sdk\b/.test(installJs), false, 'bin/install.js must not expose --sdk flag'); assert.equal(/\b--no-sdk\b/.test(installJs), false, 'bin/install.js must not expose --no-sdk flag'); assert.equal(/installSdkIfNeeded\(\{/.test(installJs), false, 'bin/install.js must not run installSdkIfNeeded during installation'); }); test('enhancement #191: active contributor guidance does not reference retired SDK build steps', () => { for (const relPath of ACTIVE_GUIDANCE_PATHS) { const body = fs.readFileSync(path.join(ROOT, relPath), 'utf8'); assert.equal( /\bbuild:sdk\b|\bcd sdk\b|\bsdk\/dist\b|\bsdk\/src\b/.test(body), false, `${relPath} must not direct contributors or agents to use the retired SDK package workflow`, ); } }); }); }