Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: give older installs the current security-audit skill template

Adam Eivy5f8d25ce8ee5
diff --git a/scripts/migrations/431-security-audit-skill-trust-model.js b/scripts/migrations/431-security-audit-skill-trust-model.js
new file mode 100644
index 0000000000..ef24e02408
--- /dev/null
+++ b/scripts/migrations/431-security-audit-skill-trust-model.js
@@ -0,0 +1,51 @@
+/**
+ * Upgrade the shipped `security-audit` CoS skill template to the trust-model
+ * version from #9875.
+ *
+ * `promptSections/instructions.js` reads `data/prompts/skills/security-audit.md`
+ * verbatim into every security task's agent prompt, and `setup-data.js` copies
+ * only missing files. #9875 rewrote the shipped body without a migration, so
+ * every install seeded before v2.86 still hands its security agents the generic
+ * OWASP checklist, which tells them to flag permissive CORS and missing rate
+ * limits — exemptions the security model documents — and says nothing about
+ * delegated agent authority.
+ *
+ * Only an untouched copy of the pre-#9875 shipped body is replaced; an edited
+ * template is kept and reported.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// The only body shipped before #9875 (unchanged from its introduction).
+export const ACCEPTED_OLD_MD5 = {
+ 'security-audit.md': ['4b6d257ff6c4b4bd36b5044338eb7634'],
+};
+
+export const NEW_SHIPPED_MD5 = {
+ 'security-audit.md': 'cd2380a3363c6db68566bc26cb68c603',
+};
+
+// A CoS skill template, not a stage prompt.
+export const DRIFT_SUBDIRS = {
+ 'security-audit.md': 'skills',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ subdirs: DRIFT_SUBDIRS,
+ label: 'security-audit skill trust model',
+ customizedHint: (filename) =>
+ ` To upgrade it manually, diff:\n` +
+ ` data.reference/prompts/skills/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/skills/${filename}\n` +
+ ` and merge the "Establish the actual threat model" section.`,
+ skipFooter: (count) =>
+ `⚠️ ${count} security-audit skill template(s) could not be auto-updated because\n` +
+ ` they were customized. Security agents will keep the old checklist until you\n` +
+ ` merge data.reference/prompts/skills/security-audit.md.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/431-security-audit-skill-trust-model.test.js b/scripts/migrations/431-security-audit-skill-trust-model.test.js
new file mode 100644
index 0000000000..c34dce8c8c
--- /dev/null
+++ b/scripts/migrations/431-security-audit-skill-trust-model.test.js
@@ -0,0 +1,51 @@
+import { describe, it, expect } from 'vitest';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import { runPromptMigrationTests, sampleBody, md5 } from './_testHelpers.js';
+import migration, {
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ DRIFT_SUBDIRS,
+} from './431-security-audit-skill-trust-model.js';
+
+const FILENAME = 'security-audit.md';
+
+describe('migration 431 — security-audit skill trust model', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-431-',
+ subdir: 'skills',
+ });
+
+ // The prompt-replace family defaults to prompts/stages/, so a missing
+ // DRIFT_SUBDIRS entry would leave every install's skill untouched.
+ it('upgrades the skill template, not a same-named stage prompt', async () => {
+ expect(DRIFT_SUBDIRS[FILENAME]).toBe('skills');
+ const rootDir = mkdtempSync(join(tmpdir(), 'migration-431-routing-'));
+ const skillsDir = join(rootDir, 'data', 'prompts', 'skills');
+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');
+ const sampleDir = join(rootDir, 'data.reference', 'prompts', 'skills');
+ for (const dir of [skillsDir, stagesDir, sampleDir]) mkdirSync(dir, { recursive: true });
+ writeFileSync(join(sampleDir, FILENAME), sampleBody(FILENAME, 'skills'));
+ const staleBody = '# synthetic pre-#9875 skill\n';
+ writeFileSync(join(skillsDir, FILENAME), staleBody);
+ writeFileSync(join(stagesDir, FILENAME), staleBody);
+
+ const result = await applyMigration({
+ rootDir,
+ accepted: { [FILENAME]: [md5(staleBody)] },
+ current: { [FILENAME]: md5(sampleBody(FILENAME, 'skills')) },
+ });
+
+ expect(result).toMatchObject({ updated: 1, skipped: 0 });
+ expect(readFileSync(join(skillsDir, FILENAME), 'utf-8')).toBe(sampleBody(FILENAME, 'skills'));
+ expect(readFileSync(join(stagesDir, FILENAME), 'utf-8')).toBe(staleBody);
+ rmSync(rootDir, { recursive: true, force: true });
+ });
+});