@ikon85/agent-workflow-kit 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PROVENANCE.md CHANGED
@@ -32,8 +32,8 @@ carries Chase's `THIRD-PARTY-NOTICES.md`.
32
32
  ## Own work (MIT, Copyright (c) 2026 Niko (iKon85))
33
33
 
34
34
  retro, wrapup, spec-self-critique, board-to-waves, verify-spike, decision-gate,
35
- codex-adapter-sync, setup-pre-commit, code-review, orchestrate-wave — covered by
36
- the root LICENSE.
35
+ codex-adapter-sync, setup-pre-commit, code-review, orchestrate-wave,
36
+ census-update — covered by the root LICENSE.
37
37
  `setup-pre-commit` was rewritten from Matt Pocock's husky-based skill to a
38
38
  zero-dep native git `core.hooksPath` scaffold; nothing of the original
39
39
  mechanic remains (courtesy attribution).
package/README.md CHANGED
@@ -332,6 +332,20 @@ still reference. Flags: `--force` (overwrite pre-existing files on `init`),
332
332
 
333
333
  ## Release notes
334
334
 
335
+ ### 0.16.0
336
+
337
+ - added: `.agents/skills/setup-workflow/census.md`
338
+ - added: `.claude/skills/setup-workflow/census.md`
339
+ - changed: `.agents/skills/setup-workflow/SKILL.md`
340
+ - changed: `.claude/skills/setup-workflow/SKILL.md`
341
+
342
+ ### 0.15.0
343
+
344
+ - added: `.agents/skills/census-update/SKILL.md`
345
+ - added: `.claude/skills/census-update/SKILL.md`
346
+ - changed: `.agents/skills/setup-workflow/workflow-overview.md`
347
+ - changed: `.claude/skills/setup-workflow/workflow-overview.md`
348
+
335
349
  ### 0.14.0
336
350
 
337
351
  - added: `scripts/census/delta.mjs`
@@ -1,5 +1,5 @@
1
1
  {
2
- "kitVersion": "0.14.0",
2
+ "kitVersion": "0.16.0",
3
3
  "files": [
4
4
  {
5
5
  "path": ".agents/skills/ask-matt/SKILL.md",
@@ -37,6 +37,15 @@
37
37
  "mode": 420,
38
38
  "origin": "kit"
39
39
  },
40
+ {
41
+ "path": ".agents/skills/census-update/SKILL.md",
42
+ "kind": "skill",
43
+ "ownerSkill": "census-update",
44
+ "surface": "codex",
45
+ "sha256": "3a04a2667005cae51cfad7952ff85fe43ba1ae390458b4ce746e23f6e872b3fb",
46
+ "mode": 420,
47
+ "origin": "kit"
48
+ },
40
49
  {
41
50
  "path": ".agents/skills/code-review/SKILL.md",
42
51
  "kind": "skill",
@@ -478,6 +487,15 @@
478
487
  "mode": 420,
479
488
  "origin": "kit"
480
489
  },
490
+ {
491
+ "path": ".agents/skills/setup-workflow/census.md",
492
+ "kind": "skill",
493
+ "ownerSkill": "setup-workflow",
494
+ "surface": "codex",
495
+ "sha256": "ec80f4ad36073e0c7c903434fa098d24f31b9d9a46ce55623782173ddba2e5f9",
496
+ "mode": 420,
497
+ "origin": "kit"
498
+ },
481
499
  {
482
500
  "path": ".agents/skills/setup-workflow/code-review.md",
483
501
  "kind": "skill",
@@ -537,7 +555,7 @@
537
555
  "kind": "skill",
538
556
  "ownerSkill": "setup-workflow",
539
557
  "surface": "codex",
540
- "sha256": "efc7818d98158a85a79f3a652787d2e557552fa5175b32b24916c894388b9b74",
558
+ "sha256": "91ba30cc08206204c83d189274579471366221ccfe8f2abdf36957ad85ae136b",
541
559
  "mode": 420,
542
560
  "origin": "kit"
543
561
  },
@@ -582,7 +600,7 @@
582
600
  "kind": "skill",
583
601
  "ownerSkill": "setup-workflow",
584
602
  "surface": "codex",
585
- "sha256": "6ce3954e4f94d112801cba0d145e4d3b6f101aca5e50e6b1f9794aa0288881a9",
603
+ "sha256": "b83fa87dc0226f21e01d31c91840b78d1ccad0a92e646de203fc3c003e9098f3",
586
604
  "mode": 420,
587
605
  "origin": "kit"
588
606
  },
@@ -893,6 +911,15 @@
893
911
  "mode": 420,
894
912
  "origin": "kit"
895
913
  },
914
+ {
915
+ "path": ".claude/skills/census-update/SKILL.md",
916
+ "kind": "skill",
917
+ "ownerSkill": "census-update",
918
+ "surface": "claude",
919
+ "sha256": "3a04a2667005cae51cfad7952ff85fe43ba1ae390458b4ce746e23f6e872b3fb",
920
+ "mode": 420,
921
+ "origin": "kit"
922
+ },
896
923
  {
897
924
  "path": ".claude/skills/code-review/SKILL.md",
898
925
  "kind": "skill",
@@ -1460,6 +1487,15 @@
1460
1487
  "mode": 420,
1461
1488
  "origin": "kit"
1462
1489
  },
1490
+ {
1491
+ "path": ".claude/skills/setup-workflow/census.md",
1492
+ "kind": "skill",
1493
+ "ownerSkill": "setup-workflow",
1494
+ "surface": "claude",
1495
+ "sha256": "ec80f4ad36073e0c7c903434fa098d24f31b9d9a46ce55623782173ddba2e5f9",
1496
+ "mode": 420,
1497
+ "origin": "kit"
1498
+ },
1463
1499
  {
1464
1500
  "path": ".claude/skills/setup-workflow/code-review.md",
1465
1501
  "kind": "skill",
@@ -1519,7 +1555,7 @@
1519
1555
  "kind": "skill",
1520
1556
  "ownerSkill": "setup-workflow",
1521
1557
  "surface": "claude",
1522
- "sha256": "efc7818d98158a85a79f3a652787d2e557552fa5175b32b24916c894388b9b74",
1558
+ "sha256": "91ba30cc08206204c83d189274579471366221ccfe8f2abdf36957ad85ae136b",
1523
1559
  "mode": 420,
1524
1560
  "origin": "kit"
1525
1561
  },
@@ -1564,7 +1600,7 @@
1564
1600
  "kind": "skill",
1565
1601
  "ownerSkill": "setup-workflow",
1566
1602
  "surface": "claude",
1567
- "sha256": "6ce3954e4f94d112801cba0d145e4d3b6f101aca5e50e6b1f9794aa0288881a9",
1603
+ "sha256": "b83fa87dc0226f21e01d31c91840b78d1ccad0a92e646de203fc3c003e9098f3",
1568
1604
  "mode": 420,
1569
1605
  "origin": "kit"
1570
1606
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikon85/agent-workflow-kit",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Portable AI-agent workflow skills (plan → execute → land → learn) for Claude Code & Codex — grilling, TDD, diagnosis, two-axis code review, cross-model Codex review, design & domain-modeling, plus a skill router (ask-matt). npx init/update/diff/uninstall.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,440 @@
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { execFile } from 'node:child_process';
4
+ import { promisify } from 'node:util';
5
+ import { access, lstat, mkdtemp, mkdir, readFile, realpath, rm, stat, symlink, writeFile } from 'node:fs/promises';
6
+ import { tmpdir } from 'node:os';
7
+ import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path';
8
+ import { pathToFileURL } from 'node:url';
9
+ import {
10
+ CENSUS_VERDICTS,
11
+ activateCensus,
12
+ diffCensus,
13
+ fingerprintCensus,
14
+ resolveCensusState,
15
+ scanCensus,
16
+ serializeCensus,
17
+ } from './census/index.mjs';
18
+
19
+ const ROOT = new URL('../', import.meta.url);
20
+ const exec = promisify(execFile);
21
+
22
+ async function text(path) {
23
+ return readFile(new URL(path, ROOT), 'utf8');
24
+ }
25
+
26
+ async function makeBrownfield() {
27
+ const root = await mkdtemp(join(tmpdir(), 'awk-census-update-'));
28
+ await mkdir(join(root, 'apps/api/src'), { recursive: true });
29
+ await mkdir(join(root, 'apps/web/src'), { recursive: true });
30
+ await writeFile(join(root, 'package.json'), '{"name":"brownfield","type":"module"}\n');
31
+ await writeFile(join(root, 'apps/api/src/index.mjs'), 'export const api = true;\n');
32
+ await writeFile(join(root, 'apps/web/src/index.mjs'), 'export const web = true;\n');
33
+ await exec('git', ['init', '--quiet'], { cwd: root });
34
+ await exec('git', ['add', '.'], { cwd: root });
35
+ return root;
36
+ }
37
+
38
+ const PROFILE_RELATIVE_PATH = '.census/profile.json';
39
+ const ACTIVE_RELATIVE_PATH = '.census/active.json';
40
+
41
+ async function readJson(path) {
42
+ return JSON.parse(await readFile(path, 'utf8'));
43
+ }
44
+
45
+ function profileBehaviorFamilies(profile) {
46
+ return profile.decisions.map(({ family, status }) => ({ name: family, status }));
47
+ }
48
+
49
+ async function containedRegularPath(root, localPath) {
50
+ if (typeof localPath !== 'string' || !localPath || isAbsolute(localPath)) return null;
51
+ const target = resolve(root, localPath);
52
+ const lexical = relative(resolve(root), target);
53
+ if (lexical === '..' || lexical.startsWith(`..${sep}`) || isAbsolute(lexical)) return null;
54
+ const stats = await lstat(target);
55
+ if (!stats.isFile() || stats.isSymbolicLink()) return null;
56
+ const canonicalRoot = await realpath(root);
57
+ const canonical = await realpath(target);
58
+ const canonicalRelative = relative(canonicalRoot, canonical);
59
+ if (canonicalRelative === '..' || canonicalRelative.startsWith(`..${sep}`)
60
+ || isAbsolute(canonicalRelative)) return null;
61
+ return target;
62
+ }
63
+
64
+ async function runLocalScannerProof(root, record) {
65
+ const modulePath = await containedRegularPath(root, record.module);
66
+ const testPath = await containedRegularPath(root, record.test);
67
+ if (!modulePath || !testPath) return false;
68
+ await exec('node', ['--test', record.test], { cwd: root });
69
+ const scanner = await import(`${pathToFileURL(modulePath).href}?proof=${Date.now()}`);
70
+ return scanner[record.export]().includes(record.surface);
71
+ }
72
+
73
+ async function runConsumerCensus(root) {
74
+ const profilePath = join(root, PROFILE_RELATIVE_PATH);
75
+ const activePath = join(root, ACTIVE_RELATIVE_PATH);
76
+ const profile = await readJson(profilePath);
77
+ let previous = null;
78
+ try {
79
+ previous = await readJson(activePath);
80
+ } catch (error) {
81
+ if (error.code !== 'ENOENT') throw error;
82
+ }
83
+
84
+ const scan = await scanCensus({
85
+ repoRoot: root,
86
+ enabled: profile.enabled,
87
+ hasActive: previous !== null,
88
+ behaviorFamilies: profileBehaviorFamilies(profile),
89
+ });
90
+ const previousSurfaces = new Set(previous?.families.surfaces.map(({ name }) => name) ?? []);
91
+ const unexpected = previous === null
92
+ ? []
93
+ : scan.families.surfaces.filter(({ name }) => !previousSurfaces.has(name));
94
+ const scannerBySurface = new Map(profile.localScanners.map((record) => [record.surface, record]));
95
+ const missingScanner = unexpected.some(({ name }) => !scannerBySurface.has(name));
96
+ const hasOpen = missingScanner || [...scan.families.surfaces, ...scan.families.behaviors]
97
+ .some(({ status }) => status === CENSUS_VERDICTS.open);
98
+ const candidate = {
99
+ ...scan,
100
+ profileReport: {
101
+ decisions: profile.decisions,
102
+ localScanners: profile.localScanners,
103
+ overrides: profile.overrides,
104
+ },
105
+ state: resolveCensusState({ enabled: profile.enabled, hasActive: true, hasOpen }),
106
+ };
107
+
108
+ if (previous !== null && serializeCensus(candidate) === serializeCensus(previous)) {
109
+ return { activated: false, activePath, candidate, profilePath };
110
+ }
111
+
112
+ await activateCensus({
113
+ activePath,
114
+ candidate,
115
+ verify: async (staged) => {
116
+ if (staged.state !== 'current') return false;
117
+ for (const { name } of unexpected) {
118
+ const record = scannerBySurface.get(name);
119
+ if (!record || !await runLocalScannerProof(root, record)) return false;
120
+ }
121
+ return staged.profileReport.decisions.every((decision) => (
122
+ decision.status !== CENSUS_VERDICTS.notRelevant || Boolean(decision.justification)
123
+ ));
124
+ },
125
+ });
126
+ return { activated: true, activePath, candidate, profilePath };
127
+ }
128
+
129
+ test('census-update is a published dual-surface own-work entry point', async () => {
130
+ const [source, mirror, manifestText, provenance, claudeOverview, codexOverview] = await Promise.all([
131
+ text('.claude/skills/census-update/SKILL.md'),
132
+ text('.agents/skills/census-update/SKILL.md'),
133
+ text('.claude/skills/skill-manifest.json'),
134
+ text('PROVENANCE.md'),
135
+ text('.claude/skills/setup-workflow/workflow-overview.md'),
136
+ text('.agents/skills/setup-workflow/workflow-overview.md'),
137
+ ]);
138
+ const entry = JSON.parse(manifestText).skills['census-update'];
139
+
140
+ assert.deepEqual(entry, {
141
+ class: 'generic',
142
+ publish: true,
143
+ entryPoint: true,
144
+ surfaces: ['claude', 'codex'],
145
+ provenance: 'own',
146
+ });
147
+ assert.equal(source, mirror);
148
+ assert.match(provenance, /Own work[\s\S]*census-update/);
149
+ assert.match(claudeOverview, /`census-update`/);
150
+ assert.match(codexOverview, /`census-update`/);
151
+ });
152
+
153
+ test('census-update coordinates the stable foundation API without a second engine', async () => {
154
+ const skill = await text('.claude/skills/census-update/SKILL.md');
155
+ for (const name of [
156
+ 'scanCensus', 'serializeCensus', 'fingerprintCensus', 'CENSUS_BUILDER_VERSION',
157
+ 'diffCensus', 'CENSUS_STATES', 'CENSUS_VERDICTS', 'resolveCensusState',
158
+ 'activateCensus', 'CensusTransactionError',
159
+ ]) {
160
+ assert.match(skill, new RegExp(`\\b${name}\\b`), `${name} must remain the public mechanism`);
161
+ }
162
+ assert.match(skill, /do not copy, rename, or reimplement/i);
163
+ assert.match(skill, /Never ask the user which files, paths, or\s+patterns exist/i);
164
+ assert.match(skill, /recommendation and the evidence/i);
165
+ assert.match(skill, /`nicht relevant` requires a durable justification/i);
166
+ assert.match(skill, /override[\s\S]*must not[\s\S]*alter scanner facts/i);
167
+ assert.match(skill, /Work only in the current repository/i);
168
+ assert.match(skill, /Never[\s\S]*propose an upstream kit change/i);
169
+ assert.match(skill, /\.census\/profile\.json/);
170
+ assert.match(skill, /\.census\/active\.json/);
171
+ assert.match(skill, /schemaVersion/);
172
+ });
173
+
174
+ test('brownfield bootstrap activates real surface coverage with a separate behavior overview', async () => {
175
+ const root = await makeBrownfield();
176
+ const profilePath = join(root, PROFILE_RELATIVE_PATH);
177
+ try {
178
+ await assert.rejects(access(profilePath), (error) => error.code === 'ENOENT');
179
+ const facts = await scanCensus({ repoRoot: root, enabled: true });
180
+ assert.equal(facts.state, 'bootstrap');
181
+ await mkdir(join(root, '.census'), { recursive: true });
182
+ await writeFile(profilePath, `${JSON.stringify({
183
+ schemaVersion: 1,
184
+ enabled: true,
185
+ decisions: [
186
+ { family: 'authentication', status: CENSUS_VERDICTS.covered, evidence: 'apps/api/src' },
187
+ {
188
+ family: 'email-delivery',
189
+ status: CENSUS_VERDICTS.notRelevant,
190
+ justification: 'The product sends no email.',
191
+ },
192
+ ],
193
+ localScanners: [],
194
+ overrides: [],
195
+ })}\n`);
196
+
197
+ const { activePath, candidate } = await runConsumerCensus(root);
198
+ const persisted = await readJson(activePath);
199
+ const covered = persisted.families.surfaces
200
+ .filter(({ status }) => status === CENSUS_VERDICTS.covered).length;
201
+
202
+ assert.equal(candidate.state, 'current');
203
+ assert.equal(persisted.state, 'current');
204
+ assert.equal(`${covered} of ${persisted.families.surfaces.length}`, '3 of 3');
205
+ assert.deepEqual(persisted.families.behaviors, [
206
+ { name: 'authentication', status: 'abgedeckt', type: 'behavior' },
207
+ { name: 'email-delivery', status: 'nicht relevant', type: 'behavior' },
208
+ ]);
209
+ assert.equal(persisted.profileReport.decisions[1].justification, 'The product sends no email.');
210
+ } finally {
211
+ await rm(root, { recursive: true, force: true });
212
+ }
213
+ });
214
+
215
+ test('a second unchanged current run performs no activation write', async () => {
216
+ const root = await makeBrownfield();
217
+ try {
218
+ await mkdir(join(root, '.census'), { recursive: true });
219
+ await writeFile(join(root, PROFILE_RELATIVE_PATH), `${JSON.stringify({
220
+ schemaVersion: 1,
221
+ enabled: true,
222
+ decisions: [],
223
+ localScanners: [],
224
+ overrides: [],
225
+ })}\n`);
226
+ const first = await runConsumerCensus(root);
227
+ assert.equal(first.activated, true);
228
+ const { activePath } = first;
229
+ const beforeBytes = await readFile(activePath, 'utf8');
230
+ const beforeStat = await stat(activePath);
231
+
232
+ const second = await runConsumerCensus(root);
233
+
234
+ assert.equal(second.activated, false);
235
+ assert.equal(await readFile(activePath, 'utf8'), beforeBytes);
236
+ assert.equal((await stat(activePath)).mtimeMs, beforeStat.mtimeMs);
237
+ } finally {
238
+ await rm(root, { recursive: true, force: true });
239
+ }
240
+ });
241
+
242
+ test('an unexpected surface stays open despite not-relevant decisions and a change-local override', async () => {
243
+ const root = await makeBrownfield();
244
+ try {
245
+ await mkdir(join(root, '.census'), { recursive: true });
246
+ await writeFile(join(root, PROFILE_RELATIVE_PATH), `${JSON.stringify({
247
+ schemaVersion: 1,
248
+ enabled: true,
249
+ decisions: [{
250
+ family: 'postal-delivery',
251
+ justification: 'The product sends no physical mail.',
252
+ status: CENSUS_VERDICTS.notRelevant,
253
+ }],
254
+ localScanners: [],
255
+ overrides: [{ reason: 'Known formatting-only path delta.', scope: 'this change' }],
256
+ })}\n`);
257
+ await runConsumerCensus(root);
258
+ await mkdir(join(root, 'services/payments/src'), { recursive: true });
259
+ await writeFile(join(root, 'services/payments/src/index.mjs'), 'export const payments = true;\n');
260
+ await exec('git', ['add', 'services'], { cwd: root });
261
+ const before = await readJson(join(root, ACTIVE_RELATIVE_PATH));
262
+
263
+ await assert.rejects(runConsumerCensus(root), (error) => error.state === 'failed');
264
+ const after = await readJson(join(root, ACTIVE_RELATIVE_PATH));
265
+ assert.equal(serializeCensus(after), serializeCensus(before));
266
+ assert.equal(after.profileReport.decisions[0].status, 'nicht relevant');
267
+ assert.equal(after.profileReport.decisions[0].justification, 'The product sends no physical mail.');
268
+ assert.equal(after.profileReport.overrides[0].scope, 'this change');
269
+ } finally {
270
+ await rm(root, { recursive: true, force: true });
271
+ }
272
+ });
273
+
274
+ test('a changed repository yields only compact path deltas and never reads a foreign repository', async () => {
275
+ const root = await makeBrownfield();
276
+ const foreign = await makeBrownfield();
277
+ try {
278
+ const reads = [];
279
+ const before = await scanCensus({ repoRoot: root });
280
+ await writeFile(join(root, 'apps/api/src/index.mjs'), 'export const api = "changed";\n');
281
+ const after = await scanCensus({
282
+ repoRoot: root,
283
+ readText: async (path) => {
284
+ reads.push(path);
285
+ return readFile(path, 'utf8');
286
+ },
287
+ });
288
+
289
+ assert.deepEqual(diffCensus(before, after), {
290
+ added: [],
291
+ changed: ['apps/api/src/index.mjs'],
292
+ open: [],
293
+ removed: [],
294
+ });
295
+ assert.ok(reads.length > 0);
296
+ assert.ok(reads.every((path) => path.startsWith(`${root}/`)));
297
+ assert.ok(reads.every((path) => !path.startsWith(`${foreign}/`)));
298
+ } finally {
299
+ await rm(root, { recursive: true, force: true });
300
+ await rm(foreign, { recursive: true, force: true });
301
+ }
302
+ });
303
+
304
+ test('an injected activation failure byte-preserves the active census', async () => {
305
+ const root = await makeBrownfield();
306
+ const activePath = join(root, '.census/active.json');
307
+ const previous = '{"generation":"known-good"}\n';
308
+ try {
309
+ await mkdir(join(root, '.census'), { recursive: true });
310
+ await writeFile(activePath, previous);
311
+ const candidate = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
312
+
313
+ await assert.rejects(
314
+ activateCensus({
315
+ activePath,
316
+ candidate,
317
+ verify: async () => true,
318
+ renameCandidate: async () => { throw new Error('injected swap failure'); },
319
+ }),
320
+ (error) => error.state === 'failed',
321
+ );
322
+ assert.equal(await readFile(activePath, 'utf8'), previous);
323
+ } finally {
324
+ await rm(root, { recursive: true, force: true });
325
+ }
326
+ });
327
+
328
+ test('an unknown pattern activates only after a repository-local scanner test passes', async () => {
329
+ const root = await makeBrownfield();
330
+ try {
331
+ await mkdir(join(root, '.census'), { recursive: true });
332
+ const profilePath = join(root, PROFILE_RELATIVE_PATH);
333
+ await writeFile(profilePath, `${JSON.stringify({
334
+ schemaVersion: 1,
335
+ enabled: true,
336
+ decisions: [],
337
+ localScanners: [],
338
+ overrides: [],
339
+ })}\n`);
340
+ const { activePath } = await runConsumerCensus(root);
341
+ const previous = await readFile(activePath, 'utf8');
342
+ await mkdir(join(root, 'services/payments/src'), { recursive: true });
343
+ await writeFile(join(root, 'services/payments/src/index.mjs'), 'export const payments = true;\n');
344
+ await exec('git', ['add', 'services'], { cwd: root });
345
+
346
+ await assert.rejects(runConsumerCensus(root), (error) => error.state === 'failed');
347
+ assert.equal(await readFile(activePath, 'utf8'), previous);
348
+
349
+ await mkdir(join(root, 'scripts/census-local'), { recursive: true });
350
+ await mkdir(join(root, 'test'), { recursive: true });
351
+ await writeFile(
352
+ join(root, 'scripts/census-local/scan-services.mjs'),
353
+ "export const scanServices = () => ['services/payments/src'];\n",
354
+ );
355
+ await writeFile(
356
+ join(root, 'test/census-services.test.mjs'),
357
+ "import { test } from 'node:test';\n"
358
+ + "import assert from 'node:assert/strict';\n"
359
+ + "import { scanServices } from '../scripts/census-local/scan-services.mjs';\n"
360
+ + "test('service scanner recognizes payments', () => {\n"
361
+ + " assert.deepEqual(scanServices(), ['services/payments/src']);\n"
362
+ + "});\n",
363
+ );
364
+ await exec('git', ['add', 'services', 'scripts/census-local', 'test/census-services.test.mjs'], { cwd: root });
365
+ const withScanner = await readJson(profilePath);
366
+ withScanner.localScanners.push({
367
+ surface: 'services/payments/src',
368
+ module: 'scripts/census-local/scan-services.mjs',
369
+ export: 'scanServices',
370
+ test: 'test/census-services.test.mjs',
371
+ });
372
+ await writeFile(profilePath, `${JSON.stringify(withScanner)}\n`);
373
+
374
+ const { candidate } = await runConsumerCensus(root);
375
+ const activated = await readJson(activePath);
376
+ assert.equal(candidate.state, 'current');
377
+ assert.equal(activated.profileReport.localScanners[0].test, 'test/census-services.test.mjs');
378
+ assert.notEqual(await readFile(activePath, 'utf8'), previous);
379
+
380
+ const fingerprintBeforeOverride = fingerprintCensus(activated);
381
+ withScanner.overrides.push({ reason: 'display only', scope: 'this change' });
382
+ await writeFile(profilePath, `${JSON.stringify(withScanner)}\n`);
383
+ const raw = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
384
+ assert.deepEqual(fingerprintCensus(raw), fingerprintBeforeOverride);
385
+ } finally {
386
+ await rm(root, { recursive: true, force: true });
387
+ }
388
+ });
389
+
390
+ test('local scanner proof rejects absolute, escaping, and symlinked paths', async () => {
391
+ const root = await makeBrownfield();
392
+ const foreign = await mkdtemp(join(tmpdir(), 'awk-foreign-census-proof-'));
393
+ try {
394
+ await mkdir(join(root, '.census'), { recursive: true });
395
+ const profilePath = join(root, PROFILE_RELATIVE_PATH);
396
+ const profile = {
397
+ schemaVersion: 1,
398
+ enabled: true,
399
+ decisions: [],
400
+ localScanners: [],
401
+ overrides: [],
402
+ };
403
+ await writeFile(profilePath, `${JSON.stringify(profile)}\n`);
404
+ const { activePath } = await runConsumerCensus(root);
405
+ const previous = await readFile(activePath, 'utf8');
406
+ await mkdir(join(root, 'services/payments/src'), { recursive: true });
407
+ await writeFile(join(root, 'services/payments/src/index.mjs'), 'export const payments = true;\n');
408
+ await exec('git', ['add', 'services'], { cwd: root });
409
+
410
+ await writeFile(join(foreign, 'scanner.mjs'), "export const scanServices = () => ['services/payments/src'];\n");
411
+ await writeFile(
412
+ join(foreign, 'scanner.test.mjs'),
413
+ "import { test } from 'node:test'; test('foreign proof', () => {});\n",
414
+ );
415
+ const records = [
416
+ { module: join(foreign, 'scanner.mjs'), test: join(foreign, 'scanner.test.mjs') },
417
+ {
418
+ module: `../${basename(foreign)}/scanner.mjs`,
419
+ test: `../${basename(foreign)}/scanner.test.mjs`,
420
+ },
421
+ ];
422
+ await symlink(join(foreign, 'scanner.mjs'), join(root, 'scanner-link.mjs'));
423
+ await symlink(join(foreign, 'scanner.test.mjs'), join(root, 'scanner-link.test.mjs'));
424
+ records.push({ module: 'scanner-link.mjs', test: 'scanner-link.test.mjs' });
425
+
426
+ for (const record of records) {
427
+ profile.localScanners = [{
428
+ surface: 'services/payments/src',
429
+ export: 'scanServices',
430
+ ...record,
431
+ }];
432
+ await writeFile(profilePath, `${JSON.stringify(profile)}\n`);
433
+ await assert.rejects(runConsumerCensus(root), (error) => error.state === 'failed');
434
+ assert.equal(await readFile(activePath, 'utf8'), previous);
435
+ }
436
+ } finally {
437
+ await rm(root, { recursive: true, force: true });
438
+ await rm(foreign, { recursive: true, force: true });
439
+ }
440
+ });