@ikon85/agent-workflow-kit 0.16.2 → 0.16.4

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.
@@ -38,6 +38,10 @@ Is the change **cross-cutting** (a new pattern OR a new data structure/domain di
38
38
 
39
39
  Never claim "complete" from plan/memory — count the denominator fresh, report `X of Y`. Substance, trigger threshold + guard template → the project convention file `docs/conventions/spec-completeness.md` (if present), §Cross-cutting fork.
40
40
 
41
+ ### Census preflight before plan-lock
42
+
43
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
44
+
41
45
  ## Plan-lock — writing PLAN.md
42
46
 
43
47
  Once all decisions are made (plan locked, before sign-off/handoff) and the session runs in a **worktree** → write the locked plan as `PLAN.md` to the worktree root (gitignored since, doesn't travel over git — consistent with CLAUDE.md "plan inside the worktree"). This way the locked plan survives a session cut and `to-prd` finds its default source. Continuing same-session work **without** a worktree stays allowed (conversation = source); but for a deliberate **session cut** before `to-prd`, `PLAN.md` is mandatory. (The `-codex` variant already writes `PLAN.md` anyway.)
@@ -16,6 +16,10 @@ Do not enact the plan until I confirm we have reached a shared understanding.
16
16
 
17
17
  </what-to-do>
18
18
 
19
+ ### Census preflight before plan-lock
20
+
21
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
22
+
19
23
  ## Related skills
20
24
 
21
25
  **No codebase/`CONTEXT.md` present, or a simpler case?** → `grill-me` is enough — same grill without the docs layer (CONTEXT.md/ADRs).
@@ -38,6 +38,10 @@ Is the change **cross-cutting** (a new pattern OR a new data structure/domain di
38
38
 
39
39
  Never claim "complete" from plan/memory — count the denominator fresh, report `X of Y`. Substance, trigger threshold + guard template → the project convention file `docs/conventions/spec-completeness.md` (if present), §Cross-cutting fork.
40
40
 
41
+ ### Census preflight before plan-lock
42
+
43
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
44
+
41
45
  ## Plan-lock — writing PLAN.md
42
46
 
43
47
  Once all decisions are made (plan locked, before sign-off/handoff) and the session runs in a **worktree** → write the locked plan as `PLAN.md` to the worktree root (gitignored since, doesn't travel over git — consistent with CLAUDE.md "plan inside the worktree"). This way the locked plan survives a session cut and `to-prd` finds its default source. Continuing same-session work **without** a worktree stays allowed (conversation = source); but for a deliberate **session cut** before `to-prd`, `PLAN.md` is mandatory. (The `-codex` variant already writes `PLAN.md` anyway.)
@@ -35,6 +35,10 @@ Is the change **cross-cutting** (a new pattern OR a new data structure/domain di
35
35
 
36
36
  Never claim "complete" from plan/memory — count the denominator fresh, report `X of Y`. Substance, trigger threshold + guard template → the project convention file `docs/conventions/spec-completeness.md` (if present), §Cross-cutting fork.
37
37
 
38
+ ### Census preflight before plan-lock
39
+
40
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
41
+
38
42
  When the decision tree is resolved and we're aligned, **write the agreed plan to `PLAN.md`** in this structure, then move to Act 2:
39
43
 
40
44
  > **Where to write it:** `PLAN.md` + `PLAN-REVIEW-LOG.md` are per-session scratch — write them in the working directory the implementing session will actually use, and run Codex from there (`-C <dir>` on the round-1 `exec`; `exec resume` rejects both `-C` and `-s`, so run resume from that cwd and force read-only via `-c sandbox_mode="read-only"`). A project may gitignore these files, so don't rely on git to carry them across checkouts/worktrees. In worktree-based repos, create the issue worktree BEFORE this write and plan inside it.
@@ -16,6 +16,10 @@ Do not enact the plan until I confirm we have reached a shared understanding.
16
16
 
17
17
  </what-to-do>
18
18
 
19
+ ### Census preflight before plan-lock
20
+
21
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
22
+
19
23
  ## Related skills
20
24
 
21
25
  **No codebase/`CONTEXT.md` present, or a simpler case?** → `grill-me` is enough — same grill without the docs layer (CONTEXT.md/ADRs).
@@ -117,6 +117,10 @@ Is the change **cross-cutting** (a new pattern OR a new data structure/domain di
117
117
 
118
118
  Never claim "complete" from plan/memory — count the denominator fresh, report `X of Y`. Substance, trigger threshold + guard template → the project convention file `docs/conventions/spec-completeness.md` (if present), §Cross-cutting fork.
119
119
 
120
+ ### Census preflight before plan-lock
121
+
122
+ For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.
123
+
120
124
  ### Handoff to Act 2
121
125
 
122
126
  When the decision tree is resolved, the glossary/ADRs are updated, and we're aligned, **write the agreed plan to `PLAN.md`** (use the canonical terms from `CONTEXT.md`), then run Act 2:
package/README.md CHANGED
@@ -332,6 +332,19 @@ still reference. Flags: `--force` (overwrite pre-existing files on `init`),
332
332
 
333
333
  ## Release notes
334
334
 
335
+ ### 0.16.4
336
+
337
+ - Metadata-only release.
338
+
339
+ ### 0.16.3
340
+
341
+ - changed: `.agents/skills/grill-me/SKILL.md`
342
+ - changed: `.agents/skills/grill-with-docs/SKILL.md`
343
+ - changed: `.claude/skills/grill-me-codex/SKILL.md`
344
+ - changed: `.claude/skills/grill-me/SKILL.md`
345
+ - changed: `.claude/skills/grill-with-docs-codex/SKILL.md`
346
+ - changed: `.claude/skills/grill-with-docs/SKILL.md`
347
+
335
348
  ### 0.16.2
336
349
 
337
350
  - Metadata-only release.
@@ -1,5 +1,5 @@
1
1
  {
2
- "kitVersion": "0.16.2",
2
+ "kitVersion": "0.16.4",
3
3
  "files": [
4
4
  {
5
5
  "path": ".agents/skills/ask-matt/SKILL.md",
@@ -186,7 +186,7 @@
186
186
  "kind": "skill",
187
187
  "ownerSkill": "grill-me",
188
188
  "surface": "codex",
189
- "sha256": "f50458c12f3d87d060495ff83c8950d81d1918d537eccfabbec8762f1982353b",
189
+ "sha256": "132cb0e6bf3e1b5b71575f4d2707880c7ffb844ccfa2c71a80270f891d04b724",
190
190
  "mode": 420,
191
191
  "origin": "kit"
192
192
  },
@@ -222,7 +222,7 @@
222
222
  "kind": "skill",
223
223
  "ownerSkill": "grill-with-docs",
224
224
  "surface": "codex",
225
- "sha256": "aebf5b7456ecc80d9c1d2e7ab611b736ed949bf5c464549bb462ca37b883e4c7",
225
+ "sha256": "06a68913f904ce9bb1b21c86f146a6738b401da07eb57fb3c97a4eec00b58de6",
226
226
  "mode": 420,
227
227
  "origin": "kit"
228
228
  },
@@ -1114,7 +1114,7 @@
1114
1114
  "kind": "skill",
1115
1115
  "ownerSkill": "grill-me-codex",
1116
1116
  "surface": "claude",
1117
- "sha256": "739a19b4bf176fb9e23479081e308941e77e207641a713f408fb6524c145b73d",
1117
+ "sha256": "ab73dd6b147e05837082db5d5ab68ab118e51e59767a717c8b7a0262cfbd07b5",
1118
1118
  "mode": 420,
1119
1119
  "origin": "kit"
1120
1120
  },
@@ -1132,7 +1132,7 @@
1132
1132
  "kind": "skill",
1133
1133
  "ownerSkill": "grill-me",
1134
1134
  "surface": "claude",
1135
- "sha256": "939592b2e4dc7fec77a61dc8d08f53fd93c62d8a8883fd83aa70773a9d00b975",
1135
+ "sha256": "01e95acd6abb396c4f4c3ec7980b79f81bbee22d45247e96f1fe130fea3f5dbe",
1136
1136
  "mode": 420,
1137
1137
  "origin": "kit"
1138
1138
  },
@@ -1168,7 +1168,7 @@
1168
1168
  "kind": "skill",
1169
1169
  "ownerSkill": "grill-with-docs-codex",
1170
1170
  "surface": "claude",
1171
- "sha256": "6704f3e0589f9c0527e4f02383ec7373bcf42ed159088eca331f9dcdebc22faa",
1171
+ "sha256": "5c7635bf31a3dc575762793ae80dfe7a26498aedcf7f1ce0513822ea1ebdb100",
1172
1172
  "mode": 420,
1173
1173
  "origin": "kit"
1174
1174
  },
@@ -1204,7 +1204,7 @@
1204
1204
  "kind": "skill",
1205
1205
  "ownerSkill": "grill-with-docs",
1206
1206
  "surface": "claude",
1207
- "sha256": "818272989fb59221cabb83f47b6e66c3b06e33b676a04579af9c3a4c9040ec9e",
1207
+ "sha256": "6250d2e64ba1248bbd40dd0c7018ab432eda4010ebc34f6c9eccefd514a1f22b",
1208
1208
  "mode": 420,
1209
1209
  "origin": "kit"
1210
1210
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikon85/agent-workflow-kit",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
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": {
@@ -9,6 +9,9 @@ import { execFileSync } from 'node:child_process';
9
9
  import { buildKit } from './build-kit.mjs';
10
10
 
11
11
  const REPO = join(dirname(fileURLToPath(import.meta.url)), '..');
12
+ const PUBLIC_CENSUS_UNIT = JSON.parse(await readFile(
13
+ join(REPO, 'test/fixtures/census-consumers/public-unit.json'), 'utf8',
14
+ )).paths;
12
15
  async function withBuild(fn) {
13
16
  const dist = await mkdtemp(join(tmpdir(), 'awkit-build-'));
14
17
  try { return await fn(dist, await buildKit({ repoRoot: REPO, distDir: dist })); }
@@ -43,6 +46,19 @@ test('current build contains post-tag public files and repository metadata', asy
43
46
  });
44
47
  });
45
48
 
49
+ test('current build contains the complete dual-surface census consumer unit', async () => {
50
+ await withBuild(async (dist, report) => {
51
+ const manifest = JSON.parse(await readFile(join(dist, 'agent-workflow-kit.package.json'), 'utf8'));
52
+ const paths = new Set(manifest.files.map(({ path }) => path));
53
+ assert.deepEqual(PUBLIC_CENSUS_UNIT.filter((path) => !paths.has(path)), []);
54
+ assert.equal(report.fileCount, manifest.files.length);
55
+ assert.equal(
56
+ await readFile(join(dist, '.claude/skills/census-update/SKILL.md'), 'utf8'),
57
+ await readFile(join(dist, '.agents/skills/census-update/SKILL.md'), 'utf8'),
58
+ );
59
+ });
60
+ });
61
+
46
62
  test('current build is self-contained and never reaches into a consumer checkout', async () => {
47
63
  const source = await readFile(join(REPO, 'scripts/build-kit.mjs'), 'utf8');
48
64
  assert.doesNotMatch(source, /testreporter|tools\/agent-workflow-kit/);
@@ -67,6 +83,9 @@ test('npm pack keeps product files but excludes runtime residue', async () => {
67
83
  assert.ok(files.includes('scripts/kit-update-pr.mjs'));
68
84
  assert.ok(files.includes('.claude/hooks/drift-guard.py'));
69
85
  assert.ok(files.includes('.claude/skills/tdd/SKILL.md'));
86
+ for (const path of PUBLIC_CENSUS_UNIT) {
87
+ assert.ok(files.includes(path), `pack missing ${path}`);
88
+ }
70
89
  assert.ok(files.every((path) => !path.startsWith('.claude/logs/')));
71
90
  assert.ok(files.every((path) => !path.includes('__pycache__') && !path.endsWith('.pyc')));
72
91
  const pkg = JSON.parse(execFileSync('node', ['-p', 'JSON.stringify(require("./package.json"))'], {
@@ -0,0 +1,227 @@
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 { cp, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
6
+ import { tmpdir } from 'node:os';
7
+ import { join } from 'node:path';
8
+ import { fileURLToPath, pathToFileURL } from 'node:url';
9
+ import {
10
+ CENSUS_BUILDER_VERSION,
11
+ activateCensus,
12
+ diffCensus,
13
+ scanCensus,
14
+ } from './census/index.mjs';
15
+
16
+ const exec = promisify(execFile);
17
+ const FIXTURES = new URL('../test/fixtures/census-consumers/', import.meta.url);
18
+ const REPO = fileURLToPath(new URL('../', import.meta.url));
19
+
20
+ async function consumer(name, tracked = ['.']) {
21
+ const root = await mkdtemp(join(tmpdir(), `awk-census-${name}-`));
22
+ await cp(new URL(`${name}/`, FIXTURES), root, { recursive: true });
23
+ await exec('git', ['init', '--quiet'], { cwd: root });
24
+ await exec('git', ['add', ...tracked], { cwd: root });
25
+ return root;
26
+ }
27
+
28
+ async function cleanup(root) {
29
+ await rm(root, { recursive: true, force: true });
30
+ }
31
+
32
+ async function json(path) {
33
+ return JSON.parse(await readFile(path, 'utf8'));
34
+ }
35
+
36
+ async function backstopStatus(root) {
37
+ const { stdout } = await exec('python3', [
38
+ join(REPO, '.claude/hooks/drift-guard.py'), '--census-status',
39
+ ], { cwd: root });
40
+ return JSON.parse(stdout);
41
+ }
42
+
43
+ test('brownfield reports real X of Y surfaces separately from behaviors', async () => {
44
+ const root = await consumer('brownfield');
45
+ try {
46
+ const profile = await json(join(root, '.census/profile.json'));
47
+ const census = await scanCensus({
48
+ repoRoot: root,
49
+ enabled: profile.enabled,
50
+ hasActive: true,
51
+ behaviorFamilies: profile.decisions.map(({ family, status }) => ({ name: family, status })),
52
+ });
53
+ const covered = census.families.surfaces.filter(({ status }) => status === 'abgedeckt').length;
54
+
55
+ assert.equal(census.state, 'current');
56
+ assert.equal(`${covered} of ${census.families.surfaces.length}`, '3 of 3');
57
+ assert.deepEqual(census.families.behaviors, [
58
+ { name: 'authentication', status: 'abgedeckt', type: 'behavior' },
59
+ { name: 'email-delivery', status: 'nicht relevant', type: 'behavior' },
60
+ ]);
61
+ assert.ok(census.families.surfaces.every(({ type }) => type === 'surface'));
62
+ } finally { await cleanup(root); }
63
+ });
64
+
65
+ test('greenfield without an active snapshot remains honest bootstrap', async () => {
66
+ const root = await consumer('greenfield');
67
+ try {
68
+ const census = await scanCensus({ repoRoot: root, enabled: true, hasActive: false });
69
+ assert.equal(census.state, 'bootstrap');
70
+ assert.ok(census.denominator.length > 0, 'bootstrap still reports discovered facts');
71
+ } finally { await cleanup(root); }
72
+ });
73
+
74
+ test('unknown pattern stays open until its repository-local scanner test passes', async () => {
75
+ const root = await consumer('unknown-pattern', ['package.json', 'src', '.census']);
76
+ try {
77
+ const activePath = join(root, '.census/active.json');
78
+ const profilePath = join(root, '.census/profile.json');
79
+ const surface = 'services/payments/src';
80
+ const scannerRecord = {
81
+ surface,
82
+ module: 'scripts/census-local/scan-services.mjs',
83
+ export: 'scanServices',
84
+ test: 'test/census-services.test.mjs',
85
+ };
86
+
87
+ const untracked = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
88
+ assert.equal(untracked.state, 'refresh_required');
89
+ assert.deepEqual(diffCensus(untracked, untracked).open, [surface]);
90
+
91
+ // Establish real active history before the repository grows the unknown surface.
92
+ await rm(join(root, 'services'), { recursive: true });
93
+ await rm(join(root, 'scripts'), { recursive: true });
94
+ await rm(join(root, 'test'), { recursive: true });
95
+ const known = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
96
+ await writeFile(activePath, `${JSON.stringify({
97
+ ...known,
98
+ profileReport: { decisions: [], localScanners: [], overrides: [] },
99
+ })}\n`);
100
+
101
+ await cp(new URL('unknown-pattern/services/', FIXTURES), join(root, 'services'), { recursive: true });
102
+ await exec('git', ['add', 'services'], { cwd: root });
103
+ const trackedOnly = await backstopStatus(root);
104
+ assert.equal(trackedOnly.state, 'refresh_required');
105
+ assert.ok(trackedOnly.reasons.includes('topology'));
106
+
107
+ const profile = await json(profilePath);
108
+ profile.localScanners.push(scannerRecord);
109
+ await writeFile(profilePath, `${JSON.stringify(profile)}\n`);
110
+ const missingProof = await backstopStatus(root);
111
+ assert.equal(missingProof.state, 'refresh_required');
112
+ assert.ok(missingProof.reasons.includes(`proof:${surface}`));
113
+
114
+ await cp(new URL('unknown-pattern/scripts/', FIXTURES), join(root, 'scripts'), { recursive: true });
115
+ await cp(new URL('unknown-pattern/test/', FIXTURES), join(root, 'test'), { recursive: true });
116
+ await writeFile(
117
+ join(root, scannerRecord.test),
118
+ "import { test } from 'node:test'; test('failing local proof', () => { throw new Error('no'); });\n",
119
+ );
120
+ await exec('git', ['add', 'scripts', 'test', '.census/profile.json'], { cwd: root });
121
+ const failedProof = await backstopStatus(root);
122
+ assert.equal(failedProof.state, 'refresh_required');
123
+ assert.ok(failedProof.reasons.includes(`proof:${surface}`));
124
+
125
+ await cp(
126
+ new URL('unknown-pattern/test/census-services.test.mjs', FIXTURES),
127
+ join(root, scannerRecord.test),
128
+ );
129
+ const candidate = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
130
+ assert.equal(candidate.state, 'current');
131
+ await activateCensus({
132
+ activePath,
133
+ candidate: {
134
+ ...candidate,
135
+ profileReport: { decisions: [], localScanners: [scannerRecord], overrides: [] },
136
+ },
137
+ verify: async () => {
138
+ await exec('node', ['--test', scannerRecord.test], { cwd: root });
139
+ const scanner = await import(`${pathToFileURL(join(root, scannerRecord.module)).href}?proof=${Date.now()}`);
140
+ return scanner[scannerRecord.export]().includes(surface);
141
+ },
142
+ });
143
+
144
+ const proven = await backstopStatus(root);
145
+ assert.equal(proven.state, 'current');
146
+ assert.deepEqual(proven.reasons, []);
147
+ const active = await json(activePath);
148
+ assert.equal(active.profileReport.localScanners[0].test, scannerRecord.test);
149
+ } finally { await cleanup(root); }
150
+ });
151
+
152
+ test('scan and compact delta do not overwrite a consumer-local modification', async () => {
153
+ const root = await consumer('local-modified');
154
+ try {
155
+ const sourcePath = join(root, 'src/index.mjs');
156
+ const activePath = join(root, '.census/active.json');
157
+ const sourceBefore = await readFile(sourcePath);
158
+ const activeBefore = await readFile(activePath);
159
+ const previous = { denominator: [], families: { surfaces: [], behaviors: [] } };
160
+ const current = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
161
+ const delta = diffCensus(previous, current);
162
+
163
+ assert.deepEqual(Object.keys(delta), ['added', 'changed', 'open', 'removed']);
164
+ assert.ok(JSON.stringify(delta).length < JSON.stringify(current).length);
165
+ assert.deepEqual(await readFile(sourcePath), sourceBefore);
166
+ assert.deepEqual(await readFile(activePath), activeBefore);
167
+ } finally { await cleanup(root); }
168
+ });
169
+
170
+ test('secret canary is absent from scan, delta, and file reads', async () => {
171
+ const root = await consumer('secret-canary');
172
+ try {
173
+ const reads = [];
174
+ const scan = await scanCensus({
175
+ repoRoot: root,
176
+ readText: async (path) => {
177
+ reads.push(path);
178
+ return readFile(path, 'utf8');
179
+ },
180
+ });
181
+ const output = JSON.stringify({ scan, delta: diffCensus({ denominator: [] }, scan) });
182
+ assert.doesNotMatch(output, /CENSUS_SECRET_CANARY/);
183
+ assert.ok(reads.every((path) => !path.includes('credentials')));
184
+ } finally { await cleanup(root); }
185
+ });
186
+
187
+ test('interrupted activation preserves the active census byte-for-byte', async () => {
188
+ const root = await consumer('interrupted');
189
+ try {
190
+ const activePath = join(root, '.census/active.json');
191
+ const before = await readFile(activePath);
192
+ const candidate = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
193
+ await assert.rejects(activateCensus({
194
+ activePath,
195
+ candidate,
196
+ verify: async () => true,
197
+ renameCandidate: async () => { throw new Error('fixture interruption'); },
198
+ }), (error) => error.state === 'failed');
199
+ assert.deepEqual(await readFile(activePath), before);
200
+ } finally { await cleanup(root); }
201
+ });
202
+
203
+ test('consumer update reports a newer builder without silently mutating its census', async () => {
204
+ const root = await consumer('consumer-update');
205
+ try {
206
+ const activePath = join(root, '.census/active.json');
207
+ const profilePath = join(root, '.census/profile.json');
208
+ const fresh = await scanCensus({ repoRoot: root, enabled: true, hasActive: true });
209
+ await writeFile(activePath, `${JSON.stringify({
210
+ ...fresh,
211
+ fingerprints: { ...fresh.fingerprints, builder: 'older-builder-fingerprint' },
212
+ profileReport: { decisions: [], localScanners: [], overrides: [] },
213
+ })}\n`);
214
+ const activeBefore = await readFile(activePath);
215
+ const profileBefore = await readFile(profilePath);
216
+ const { stdout } = await exec('python3', [
217
+ join(REPO, '.claude/hooks/drift-guard.py'), '--census-status',
218
+ ], { cwd: root });
219
+ const status = JSON.parse(stdout);
220
+
221
+ assert.equal(status.state, 'refresh_required');
222
+ assert.equal(status.detail, `builder ${CENSUS_BUILDER_VERSION}`);
223
+ assert.ok(status.reasons.includes('builder'));
224
+ assert.deepEqual(await readFile(activePath), activeBefore);
225
+ assert.deepEqual(await readFile(profilePath), profileBefore);
226
+ } finally { await cleanup(root); }
227
+ });
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { access, readFile } from 'node:fs/promises';
4
+ import { constants } from 'node:fs';
5
+ import { dirname, join } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ export const CENSUS_PREFLIGHT_INVOCATION =
9
+ 'python3 .claude/hooks/drift-guard.py --census-status';
10
+ export const CENSUS_PREFLIGHT_CONTRACT =
11
+ 'For a cross-cutting plan, run `python3 .claude/hooks/drift-guard.py --census-status` before locking it. When an activated census reports `block_handoff: true` (including stale or open surfaces), stop the lock, run `$census-update`, resolve the findings, and retry. When the census is disabled or not activated, keep the status visible and perform the existing manual surface walk; do not replace that walk with census guesses.';
12
+
13
+ const GRILL_FAMILY_NAME = /^grill-/;
14
+ const SURFACE_TREES = { claude: '.claude', codex: '.agents' };
15
+ const LOCAL_CENSUS_LOGIC = /\b(?:scanCensus|diffCensus|fingerprintCensus|resolveCensusState|activateCensus)\s*\(/;
16
+
17
+ async function exists(path) {
18
+ try {
19
+ await access(path, constants.R_OK);
20
+ return true;
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+
26
+ export async function auditGrillCensusWiring(repoRoot) {
27
+ const manifestPath = join(repoRoot, '.claude', 'skills', 'skill-manifest.json');
28
+ const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
29
+ const entries = Object.entries(manifest.skills ?? {})
30
+ .filter(([name]) => GRILL_FAMILY_NAME.test(name));
31
+ const problems = [];
32
+ const physical = [];
33
+
34
+ for (const [name, entry] of entries) {
35
+ if (!Array.isArray(entry.surfaces) || entry.surfaces.length === 0) {
36
+ problems.push(`manifest grill has no surfaces: ${name}`);
37
+ continue;
38
+ }
39
+ for (const surface of entry.surfaces) {
40
+ const tree = SURFACE_TREES[surface];
41
+ if (!tree) {
42
+ problems.push(`manifest names an unknown surface for ${name}: ${surface}`);
43
+ continue;
44
+ }
45
+ const path = join(repoRoot, tree, 'skills', name, 'SKILL.md');
46
+ physical.push({ name, surface, path });
47
+ if (!(await exists(path))) {
48
+ problems.push(`manifest surface has no skill file: ${surface}:${name}`);
49
+ continue;
50
+ }
51
+ const prose = await readFile(path, 'utf8');
52
+ const invocationCount = prose.split(CENSUS_PREFLIGHT_INVOCATION).length - 1;
53
+ if (invocationCount !== 1) {
54
+ problems.push(
55
+ invocationCount === 0
56
+ ? `missing census preflight invocation: ${surface}:${name}`
57
+ : `duplicate census preflight invocation: ${surface}:${name}`,
58
+ );
59
+ }
60
+ if (!prose.includes(CENSUS_PREFLIGHT_CONTRACT)) {
61
+ problems.push(`census preflight contract drifted: ${surface}:${name}`);
62
+ }
63
+ if (LOCAL_CENSUS_LOGIC.test(prose)) {
64
+ problems.push(`grill duplicates census engine logic: ${surface}:${name}`);
65
+ }
66
+ }
67
+ }
68
+
69
+ return {
70
+ counts: { logical: entries.length, physical: physical.length },
71
+ problems,
72
+ };
73
+ }
74
+
75
+ async function main() {
76
+ const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
77
+ const result = await auditGrillCensusWiring(repoRoot);
78
+ console.log(`grill census wiring: ${result.counts.logical} logical, ${result.counts.physical} physical`);
79
+ if (result.problems.length > 0) {
80
+ for (const problem of result.problems) console.error(`- ${problem}`);
81
+ process.exitCode = 1;
82
+ }
83
+ }
84
+
85
+ if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
86
+ await main();
87
+ }
@@ -0,0 +1,107 @@
1
+ import assert from 'node:assert/strict';
2
+ import { mkdtemp, mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { dirname, join } from 'node:path';
5
+ import test from 'node:test';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ import {
9
+ CENSUS_PREFLIGHT_CONTRACT,
10
+ auditGrillCensusWiring,
11
+ } from './grill-census-wiring-guard.mjs';
12
+
13
+ const REPO = join(dirname(fileURLToPath(import.meta.url)), '..');
14
+ const realManifest = JSON.parse(await readFile(
15
+ join(REPO, '.claude', 'skills', 'skill-manifest.json'),
16
+ 'utf8',
17
+ )).skills;
18
+ const baselineGrills = Object.fromEntries(
19
+ Object.entries(realManifest).filter(([name]) => name.startsWith('grill-')),
20
+ );
21
+ const baselineCounts = {
22
+ logical: Object.keys(baselineGrills).length,
23
+ physical: Object.values(baselineGrills)
24
+ .reduce((count, entry) => count + entry.surfaces.length, 0),
25
+ };
26
+ const [baselineName, baselineEntry] = Object.entries(baselineGrills)[0];
27
+ const baselineSurface = baselineEntry.surfaces[0];
28
+ let extraGrillName = 'grill-fixture-extra';
29
+ while (extraGrillName in baselineGrills) extraGrillName += '-next';
30
+
31
+ async function fixture({ manifest = baselineGrills, omitInvocation, omitFile } = {}) {
32
+ const root = await mkdtemp(join(tmpdir(), 'grill-census-guard-'));
33
+ await mkdir(join(root, '.claude', 'skills'), { recursive: true });
34
+ await writeFile(
35
+ join(root, '.claude', 'skills', 'skill-manifest.json'),
36
+ `${JSON.stringify({ skills: manifest })}\n`,
37
+ );
38
+ for (const [name, entry] of Object.entries(manifest)) {
39
+ for (const surface of entry.surfaces) {
40
+ const relative = `${surface}:${name}`;
41
+ if (relative === omitFile) continue;
42
+ const tree = surface === 'claude' ? '.claude' : '.agents';
43
+ const directory = join(root, tree, 'skills', name);
44
+ await mkdir(directory, { recursive: true });
45
+ const invocation = relative === omitInvocation ? '' : CENSUS_PREFLIGHT_CONTRACT;
46
+ await writeFile(join(directory, 'SKILL.md'), `# ${name}\n${invocation}\n`);
47
+ }
48
+ }
49
+ return root;
50
+ }
51
+
52
+ test('fixture wiring covers every grill and surface in the real manifest', async () => {
53
+ const result = await auditGrillCensusWiring(await fixture());
54
+
55
+ assert.deepEqual(result.counts, baselineCounts);
56
+ assert.deepEqual(result.problems, []);
57
+ });
58
+
59
+ test('a grill surface missing the shared preflight invocation is rejected', async () => {
60
+ const result = await auditGrillCensusWiring(await fixture({
61
+ omitInvocation: `${baselineSurface}:${baselineName}`,
62
+ }));
63
+
64
+ assert.match(
65
+ result.problems.join('\n'),
66
+ new RegExp(`missing census preflight invocation.*${baselineName}`, 'i'),
67
+ );
68
+ });
69
+
70
+ test('a dead manifest surface reference is rejected', async () => {
71
+ const result = await auditGrillCensusWiring(await fixture({
72
+ omitFile: `${baselineSurface}:${baselineName}`,
73
+ }));
74
+
75
+ assert.match(
76
+ result.problems.join('\n'),
77
+ new RegExp(`manifest surface has no skill file.*${baselineName}`, 'i'),
78
+ );
79
+ });
80
+
81
+ test('a newly manifested grill variant expands the family and cannot hide a missing surface', async () => {
82
+ const addedSurfaces = ['claude', 'codex'];
83
+ const manifest = {
84
+ ...baselineGrills,
85
+ [extraGrillName]: { surfaces: addedSurfaces },
86
+ };
87
+ const result = await auditGrillCensusWiring(await fixture({
88
+ manifest,
89
+ omitFile: `codex:${extraGrillName}`,
90
+ }));
91
+
92
+ assert.deepEqual(result.counts, {
93
+ logical: baselineCounts.logical + 1,
94
+ physical: baselineCounts.physical + addedSurfaces.length,
95
+ });
96
+ assert.match(
97
+ result.problems.join('\n'),
98
+ new RegExp(`manifest surface has no skill file.*${extraGrillName}`, 'i'),
99
+ );
100
+ });
101
+
102
+ test('the repository wiring covers the complete manifest-derived grill family', async () => {
103
+ const result = await auditGrillCensusWiring(REPO);
104
+
105
+ assert.deepEqual(result.counts, baselineCounts);
106
+ assert.deepEqual(result.problems, []);
107
+ });
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env python3
2
+ """Forward proof: a clean public checkout builds and serves census consumers."""
3
+ import json
4
+ import shutil
5
+ import subprocess
6
+ import tempfile
7
+ import unittest
8
+ from pathlib import Path
9
+
10
+ REPO = Path(__file__).resolve().parent.parent
11
+ PUBLIC_UNIT_RELATIVE = Path("test/fixtures/census-consumers/public-unit.json")
12
+ GREENFIELD_RELATIVE = Path("test/fixtures/census-consumers/greenfield")
13
+
14
+
15
+ class CensusForwardContract(unittest.TestCase):
16
+ def setUp(self):
17
+ self.tmp = Path(tempfile.mkdtemp(prefix="awk-census-forward-"))
18
+ self.addCleanup(shutil.rmtree, self.tmp, ignore_errors=True)
19
+ self.public = self.tmp / "public-kit"
20
+ self.public.mkdir()
21
+ source_root = REPO
22
+ self.forbidden_source_root = str(source_root)
23
+ archive = subprocess.Popen(
24
+ ["git", "archive", "HEAD"], cwd=source_root, stdout=subprocess.PIPE
25
+ )
26
+ unpack = subprocess.run(
27
+ ["tar", "-x", "-C", str(self.public)], stdin=archive.stdout,
28
+ capture_output=True, timeout=30,
29
+ )
30
+ archive.stdout.close()
31
+ archive_rc = archive.wait(timeout=30)
32
+ self.assertEqual((archive_rc, unpack.returncode), (0, 0), unpack.stderr.decode())
33
+ # From this boundary onward every executable, fixture, and assertion input
34
+ # is resolved inside the archived public checkout.
35
+ self.assertTrue((self.public / GREENFIELD_RELATIVE).is_dir())
36
+ self.assertTrue((self.public / PUBLIC_UNIT_RELATIVE).is_file())
37
+ build = subprocess.run(
38
+ ["node", "scripts/build-kit.mjs"], cwd=self.public,
39
+ capture_output=True, text=True, timeout=120,
40
+ )
41
+ self.assertEqual(build.returncode, 0, build.stderr)
42
+ self.dist = self.public / "dist-kit"
43
+
44
+ def test_built_public_checkout_exercises_both_surfaces_and_scanner(self):
45
+ claude = (self.dist / ".claude/skills/census-update/SKILL.md").read_text()
46
+ codex = (self.dist / ".agents/skills/census-update/SKILL.md").read_text()
47
+ self.assertEqual(claude, codex)
48
+ for public_export in ("scanCensus", "diffCensus", "activateCensus"):
49
+ self.assertIn(public_export, claude)
50
+
51
+ consumer = self.tmp / "consumer"
52
+ fixture = self.public / GREENFIELD_RELATIVE
53
+ self.assertTrue(fixture.is_relative_to(self.public))
54
+ shutil.copytree(fixture, consumer)
55
+ subprocess.run(["git", "init", "--quiet"], cwd=consumer, check=True)
56
+ subprocess.run(["git", "add", "."], cwd=consumer, check=True)
57
+ runner = (
58
+ "import { scanCensus } from "
59
+ + json.dumps((self.dist / "scripts/census/index.mjs").as_uri())
60
+ + "; const result = await scanCensus({repoRoot: process.argv[1], enabled:true});"
61
+ + "console.log(JSON.stringify({state:result.state,count:result.denominator.length}));"
62
+ )
63
+ run = subprocess.run(
64
+ ["node", "--input-type=module", "--eval", runner, str(consumer)],
65
+ cwd=self.public, capture_output=True, text=True, timeout=30,
66
+ )
67
+ self.assertEqual(run.returncode, 0, run.stderr)
68
+ self.assertEqual(json.loads(run.stdout), {"state": "bootstrap", "count": 2})
69
+ self.assertNotIn("testreporter", run.stdout.lower())
70
+ self.assertNotIn(self.forbidden_source_root, runner)
71
+ self.assertNotIn(self.forbidden_source_root, run.stdout)
72
+
73
+ def test_public_pack_contains_complete_census_unit_without_foreign_reach(self):
74
+ pack = subprocess.run(
75
+ ["npm", "pack", "--dry-run", "--json"], cwd=self.public,
76
+ capture_output=True, text=True, timeout=120,
77
+ )
78
+ self.assertEqual(pack.returncode, 0, pack.stderr)
79
+ paths = {entry["path"] for entry in json.loads(pack.stdout)[0]["files"]}
80
+ expected = set(json.loads(
81
+ (self.public / PUBLIC_UNIT_RELATIVE).read_text(encoding="utf-8")
82
+ )["paths"])
83
+ self.assertEqual(expected - paths, set())
84
+ for path in expected:
85
+ text = (self.public / path).read_text(encoding="utf-8")
86
+ self.assertNotIn("tools/agent-workflow-kit", text)
87
+ self.assertNotIn("testreporter", text.lower())
88
+
89
+
90
+ if __name__ == "__main__":
91
+ unittest.main(verbosity=2)
@@ -194,6 +194,27 @@ class DistKitValidateGraphSmoke(unittest.TestCase):
194
194
  "language (fields.status.roles / --status-role) instead:\n"
195
195
  + "\n".join(hits))
196
196
 
197
+ def test_shipped_census_runs_for_a_foreign_greenfield_on_both_surfaces(self):
198
+ consumer = self.tmp / "census-consumer"
199
+ shutil.copytree(REPO / "test/fixtures/census-consumers/greenfield", consumer)
200
+ subprocess.run(["git", "init", "--quiet"], cwd=consumer, check=True)
201
+ subprocess.run(["git", "add", "."], cwd=consumer, check=True)
202
+ claude = (DIST / ".claude/skills/census-update/SKILL.md").read_text()
203
+ codex = (DIST / ".agents/skills/census-update/SKILL.md").read_text()
204
+ self.assertEqual(claude, codex)
205
+ module = (DIST / "scripts/census/index.mjs").as_uri()
206
+ runner = (
207
+ f'import {{ scanCensus }} from {json.dumps(module)};'
208
+ "const r=await scanCensus({repoRoot:process.argv[1],enabled:true});"
209
+ "console.log(JSON.stringify({state:r.state,count:r.denominator.length}));"
210
+ )
211
+ result = subprocess.run(
212
+ ["node", "--input-type=module", "--eval", runner, str(consumer)],
213
+ cwd=DIST, capture_output=True, text=True, timeout=30,
214
+ )
215
+ self.assertEqual(result.returncode, 0, result.stderr)
216
+ self.assertEqual(json.loads(result.stdout), {"state": "bootstrap", "count": 2})
217
+
197
218
 
198
219
  if __name__ == "__main__":
199
220
  unittest.main(verbosity=2)
@@ -36,6 +36,9 @@ import unittest
36
36
  from pathlib import Path
37
37
 
38
38
  REPO = Path(__file__).resolve().parent.parent
39
+ PUBLIC_CENSUS_UNIT = json.loads(
40
+ (REPO / "test/fixtures/census-consumers/public-unit.json").read_text(encoding="utf-8")
41
+ )["paths"]
39
42
  PUBLIC_SLUG = "iKon85/agent-workflow-kit"
40
43
  CREDIT_FILES = {"LICENSE", "README.md", "PROVENANCE.md", "THIRD-PARTY-NOTICES.md"}
41
44
  PRIVATE_SKILLS = {
@@ -295,6 +298,19 @@ class RealDistKitIsClean(unittest.TestCase):
295
298
  violations = audit_dir(REPO / "dist-kit")
296
299
  self.assertEqual(violations, [], "\n".join(violations[:40]))
297
300
 
301
+ def test_built_dist_kit_contains_publishable_census_without_foreign_reach(self):
302
+ build = subprocess.run(
303
+ ["node", str(REPO / "scripts/build-kit.mjs")], cwd=REPO,
304
+ capture_output=True, text=True, timeout=120,
305
+ )
306
+ self.assertEqual(build.returncode, 0, build.stderr)
307
+ for rel in PUBLIC_CENSUS_UNIT:
308
+ path = REPO / "dist-kit" / rel
309
+ self.assertTrue(path.is_file(), f"missing published census resource: {rel}")
310
+ text = path.read_text(encoding="utf-8")
311
+ self.assertNotIn("tools/agent-workflow-kit", text)
312
+ self.assertNotIn("testreporter", text.lower())
313
+
298
314
 
299
315
  if __name__ == "__main__":
300
316
  unittest.main(verbosity=2)