@productbrain/cli 0.1.0-beta.8141 → 0.1.0-beta.8143

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.
Files changed (73) hide show
  1. package/dist/__tests__/handshake-augment.test.js +2 -16
  2. package/dist/__tests__/handshake-augment.test.js.map +1 -1
  3. package/dist/__tests__/handshake-preview.test.js +2 -9
  4. package/dist/__tests__/handshake-preview.test.js.map +1 -1
  5. package/dist/__tests__/handshake-session-threading.test.js +2 -9
  6. package/dist/__tests__/handshake-session-threading.test.js.map +1 -1
  7. package/dist/commands/admin/seedRegistryEntries.generated.js +1 -1
  8. package/dist/commands/admin/seedRegistryEntries.generated.js.map +1 -1
  9. package/dist/commands/handshake.d.ts +0 -2
  10. package/dist/commands/handshake.d.ts.map +1 -1
  11. package/dist/commands/handshake.js +21 -38
  12. package/dist/commands/handshake.js.map +1 -1
  13. package/dist/formatters/handshake.d.ts +0 -5
  14. package/dist/formatters/handshake.d.ts.map +1 -1
  15. package/dist/formatters/handshake.js +0 -9
  16. package/dist/formatters/handshake.js.map +1 -1
  17. package/dist/generators/adapters.d.ts +1 -1
  18. package/dist/generators/adapters.d.ts.map +1 -1
  19. package/dist/generators/adapters.js +9 -2
  20. package/dist/generators/adapters.js.map +1 -1
  21. package/dist/generators/everyone-rules-md.d.ts +10 -0
  22. package/dist/generators/everyone-rules-md.d.ts.map +1 -0
  23. package/dist/generators/everyone-rules-md.js +27 -0
  24. package/dist/generators/everyone-rules-md.js.map +1 -0
  25. package/dist/generators/retired-projections.d.ts +14 -0
  26. package/dist/generators/retired-projections.d.ts.map +1 -0
  27. package/dist/generators/retired-projections.js +79 -0
  28. package/dist/generators/retired-projections.js.map +1 -0
  29. package/dist/generators/retired-projections.test.d.ts +2 -0
  30. package/dist/generators/retired-projections.test.d.ts.map +1 -0
  31. package/dist/generators/retired-projections.test.js +62 -0
  32. package/dist/generators/retired-projections.test.js.map +1 -0
  33. package/dist/index.js +1 -2
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/generators/archetypes.d.ts +0 -52
  37. package/dist/generators/archetypes.d.ts.map +0 -1
  38. package/dist/generators/archetypes.js +0 -190
  39. package/dist/generators/archetypes.js.map +0 -1
  40. package/dist/generators/archetypes.test.d.ts +0 -2
  41. package/dist/generators/archetypes.test.d.ts.map +0 -1
  42. package/dist/generators/archetypes.test.js +0 -272
  43. package/dist/generators/archetypes.test.js.map +0 -1
  44. package/dist/generators/chain-classifier-kernel-client-drift.test.d.ts +0 -2
  45. package/dist/generators/chain-classifier-kernel-client-drift.test.d.ts.map +0 -1
  46. package/dist/generators/chain-classifier-kernel-client-drift.test.js +0 -41
  47. package/dist/generators/chain-classifier-kernel-client-drift.test.js.map +0 -1
  48. package/dist/generators/chain-classifier.d.ts +0 -102
  49. package/dist/generators/chain-classifier.d.ts.map +0 -1
  50. package/dist/generators/chain-classifier.js +0 -52
  51. package/dist/generators/chain-classifier.js.map +0 -1
  52. package/dist/generators/chain-rules.d.ts +0 -42
  53. package/dist/generators/chain-rules.d.ts.map +0 -1
  54. package/dist/generators/chain-rules.js +0 -256
  55. package/dist/generators/chain-rules.js.map +0 -1
  56. package/dist/generators/chain-rules.test.d.ts +0 -2
  57. package/dist/generators/chain-rules.test.d.ts.map +0 -1
  58. package/dist/generators/chain-rules.test.js +0 -448
  59. package/dist/generators/chain-rules.test.js.map +0 -1
  60. package/dist/generators/handshake-diff.d.ts +0 -67
  61. package/dist/generators/handshake-diff.d.ts.map +0 -1
  62. package/dist/generators/handshake-diff.js +0 -183
  63. package/dist/generators/handshake-diff.js.map +0 -1
  64. package/dist/generators/handshake-diff.test.d.ts +0 -2
  65. package/dist/generators/handshake-diff.test.d.ts.map +0 -1
  66. package/dist/generators/handshake-diff.test.js +0 -264
  67. package/dist/generators/handshake-diff.test.js.map +0 -1
  68. package/templates/archetypes/boundary.md +0 -23
  69. package/templates/archetypes/constraint.md +0 -23
  70. package/templates/archetypes/convention.md +0 -23
  71. package/templates/archetypes/policy.md +0 -23
  72. package/templates/archetypes/quality-gate.md +0 -23
  73. package/templates/archetypes/workflow.md +0 -23
@@ -1,448 +0,0 @@
1
- /**
2
- * chain-rules — unit tests.
3
- * BET-286 Slice 3: chain rules assembler.
4
- */
5
- import { describe, expect, it, vi } from 'vitest';
6
- import { generateChainRules } from './chain-rules.js';
7
- // ── Helpers ────────────────────────────────────────────────────────────
8
- function makeEntry(overrides) {
9
- return {
10
- status: 'active',
11
- verificationStatus: 'verified',
12
- data: null,
13
- relations: [],
14
- ...overrides,
15
- };
16
- }
17
- function makeManualRule(name) {
18
- return {
19
- name,
20
- description: 'Manual rule',
21
- body: 'Manual rule body',
22
- sourcePath: `.productbrain/rules/${name}.md`,
23
- autoApply: true,
24
- level: 'core',
25
- scope: undefined,
26
- targets: undefined,
27
- };
28
- }
29
- const COLLECTIONS = [
30
- { slug: 'standards', governanceFunction: 'constraint' },
31
- { slug: 'business-rules', governanceFunction: 'constraint' },
32
- { slug: 'architecture', governanceFunction: 'boundary' },
33
- { slug: 'decisions', governanceFunction: 'convention' },
34
- { slug: 'policies', governanceFunction: 'policy' },
35
- { slug: 'flows', governanceFunction: 'workflow' },
36
- ];
37
- /**
38
- * Minimal test-double for the served `chain.classifyGovernance` route (WP-488 Slice 4,
39
- * FEAT-1378, TEN-2733). The real scorer now lives in kernel/governance/classifyGovernance.ts
40
- * and is exercised by its own parity-snapshot test there — packages/cli cannot import it
41
- * directly (same `rootDir: "src"` + `moduleResolution: "NodeNext"` failure documented in
42
- * chain-rules.ts / chain-classifier.ts, verified in WP-488 Slice 3 for the identical class
43
- * of failure, and this applies to test files too since tsconfig's `include` covers them).
44
- * This double reproduces only the collection-metadata lookup these tests actually exercise
45
- * — not the full weighted signal/relation-boost scorer — sufficient for asserting which
46
- * governanceFunction bucket an entry lands in.
47
- */
48
- function mockClassifyGovernance(entries, collections) {
49
- return entries
50
- .filter((e) => e.entryId !== null)
51
- .map((e) => {
52
- const collection = collections.find((c) => c.slug === e.collectionSlug);
53
- const governanceFunction = collection?.governanceFunction ?? 'unclassified';
54
- return {
55
- entryId: e.entryId,
56
- name: e.name,
57
- collectionSlug: e.collectionSlug,
58
- governanceFunction,
59
- confidence: collection?.governanceFunction ? 0.5 : 0,
60
- matchedSignals: collection?.governanceFunction
61
- ? [`collection metadata '${e.collectionSlug}' → ${governanceFunction}`]
62
- : [],
63
- data: e.data,
64
- relations: e.relations,
65
- };
66
- });
67
- }
68
- /** Mock kernelCall that returns the given entries wrapped in the Convex response shape. */
69
- function mockMcpSuccess(entries, collections = COLLECTIONS) {
70
- return vi.fn((name) => {
71
- if (name === 'chain.getGovernanceWithRelations') {
72
- return Promise.resolve({ entries, total: entries.length });
73
- }
74
- if (name === 'chain.listCollections') {
75
- return Promise.resolve(collections);
76
- }
77
- if (name === 'chain.classifyGovernance') {
78
- return Promise.resolve(mockClassifyGovernance(entries, collections));
79
- }
80
- return Promise.resolve(null);
81
- });
82
- }
83
- /** Mock kernelCall that throws. */
84
- function mockMcpFailure(error = new Error('Network error')) {
85
- return vi.fn().mockRejectedValue(error);
86
- }
87
- // ── Tests ──────────────────────────────────────────────────────────────
88
- describe('generateChainRules', () => {
89
- it('happy path: produces rules from classified entries', async () => {
90
- const entries = [
91
- makeEntry({ entryId: 'STD-1', name: 'No direct Convex imports', collectionSlug: 'standards' }),
92
- makeEntry({ entryId: 'STD-2', name: 'Auth check on all routes', collectionSlug: 'business-rules' }),
93
- makeEntry({ entryId: 'ARCH-1', name: 'Domain boundary rules', collectionSlug: 'architecture' }),
94
- ];
95
- const mcpFn = mockMcpSuccess(entries);
96
- const result = await generateChainRules(mcpFn, []);
97
- expect(mcpFn).toHaveBeenCalledWith('chain.getGovernanceWithRelations', {});
98
- expect(mcpFn).toHaveBeenCalledWith('chain.listCollections', {});
99
- expect(result.sentinel).toBeNull();
100
- expect(result.rules.length).toBeGreaterThan(0);
101
- // All generated rules must have chain:// sourcePath
102
- for (const rule of result.rules) {
103
- expect(rule.sourcePath).toMatch(/^chain:\/\//);
104
- }
105
- expect(result.stats.totalEntries).toBe(3);
106
- expect(result.stats.classifiedEntries).toBe(3);
107
- });
108
- it('projects entries before sending to classify — drops fields the served route does not accept (PR #378 P1)', async () => {
109
- // Simulate the REAL runtime shape of chain.getGovernanceWithRelations's response
110
- // (GovernanceEntry, convex/agentKnowledge/governanceQuery.ts) which carries
111
- // `attestation` + `verifiedBy` on top of the narrower GovernanceEntryInput fields.
112
- // kernelCallFn<T> is a compile-time type assertion, not a runtime projection, so the
113
- // CLI's own `entries: GovernanceEntryInput[]` annotation does not guarantee these
114
- // extra fields are absent at runtime — this is exactly the gap the fix closes.
115
- const wideEntry = {
116
- ...makeEntry({ entryId: 'STD-1', name: 'No direct imports', collectionSlug: 'standards' }),
117
- attestation: { verified: false, legs: [] },
118
- verifiedBy: null,
119
- };
120
- const mcpFn = vi.fn((name, _args) => {
121
- if (name === 'chain.getGovernanceWithRelations') {
122
- return Promise.resolve({ entries: [wideEntry], total: 1 });
123
- }
124
- if (name === 'chain.listCollections') {
125
- return Promise.resolve(COLLECTIONS);
126
- }
127
- if (name === 'chain.classifyGovernance') {
128
- return Promise.resolve([]);
129
- }
130
- return Promise.resolve(null);
131
- });
132
- await generateChainRules(mcpFn, []);
133
- const classifyCall = mcpFn.mock.calls.find(([fn]) => fn === 'chain.classifyGovernance');
134
- expect(classifyCall).toBeDefined();
135
- const sentEntries = classifyCall[1].entries;
136
- expect(sentEntries).toHaveLength(1);
137
- expect(Object.keys(sentEntries[0]).sort()).toEqual(['collectionSlug', 'data', 'entryId', 'name', 'relations', 'status', 'verificationStatus'].sort());
138
- expect(sentEntries[0]).not.toHaveProperty('attestation');
139
- expect(sentEntries[0]).not.toHaveProperty('verifiedBy');
140
- });
141
- it('projects collections before sending to classify — sends only fields the kernel judge reads (PR #378 Copilot + Codex follow-up)', async () => {
142
- // Simulate the REAL runtime shape of chain.listCollections's response
143
- // (convex/agentKnowledge/collections.ts:listCollections returns `{ ...c,
144
- // descriptionFieldKey }` — the full DB row plus an overlay field), PLUS a long
145
- // `description` (as a real workspace collection can carry, up to the MCP tool's 20KB
146
- // allowance) to prove it is dropped rather than truncated — kernel/governance/
147
- // classifyGovernance.ts never reads `description` at all, so there is nothing to
148
- // truncate; the honest fix is to not send it.
149
- const wideCollection = {
150
- _id: 'col_abc123',
151
- _creationTime: 1700000000000,
152
- workspaceId: 'ws_abc123',
153
- descriptionFieldKey: 'assumptions',
154
- slug: 'standards',
155
- name: 'Standards',
156
- description: 'x'.repeat(15_000), // longer than the AKI gateway's 10KB per-string cap
157
- purpose: 'Rules and standards',
158
- usageGuidance: 'Use for binding standards.',
159
- classificationCheck: 'contains "must" or "shall"',
160
- defaultCanonicalKey: 'standard',
161
- governanceRole: 'binding',
162
- thinkingLayer: 'execution',
163
- governanceFunction: 'constraint',
164
- };
165
- const entries = [makeEntry({ entryId: 'STD-1', name: 'No direct imports', collectionSlug: 'standards' })];
166
- const mcpFn = vi.fn((name, _args) => {
167
- if (name === 'chain.getGovernanceWithRelations') {
168
- return Promise.resolve({ entries, total: entries.length });
169
- }
170
- if (name === 'chain.listCollections') {
171
- return Promise.resolve([wideCollection]);
172
- }
173
- if (name === 'chain.classifyGovernance') {
174
- return Promise.resolve([]);
175
- }
176
- return Promise.resolve(null);
177
- });
178
- await generateChainRules(mcpFn, []);
179
- const classifyCall = mcpFn.mock.calls.find(([fn]) => fn === 'chain.classifyGovernance');
180
- expect(classifyCall).toBeDefined();
181
- const sentCollections = classifyCall[1].collections;
182
- expect(sentCollections).toHaveLength(1);
183
- // Only the 3 fields the kernel judge actually reads survive — everything else,
184
- // including the 15KB `description`, is dropped entirely (not truncated).
185
- expect(Object.keys(sentCollections[0]).sort()).toEqual(['classificationSignals', 'governanceFunction', 'slug'].sort());
186
- for (const key of Object.keys(sentCollections[0])) {
187
- expect(['slug', 'classificationSignals', 'governanceFunction']).toContain(key);
188
- }
189
- expect(sentCollections[0]).not.toHaveProperty('_id');
190
- expect(sentCollections[0]).not.toHaveProperty('_creationTime');
191
- expect(sentCollections[0]).not.toHaveProperty('workspaceId');
192
- expect(sentCollections[0]).not.toHaveProperty('descriptionFieldKey');
193
- expect(sentCollections[0]).not.toHaveProperty('description');
194
- expect(sentCollections[0]).not.toHaveProperty('purpose');
195
- expect(sentCollections[0]).not.toHaveProperty('usageGuidance');
196
- expect(sentCollections[0]).not.toHaveProperty('classificationCheck');
197
- expect(sentCollections[0]).not.toHaveProperty('defaultCanonicalKey');
198
- expect(sentCollections[0]).not.toHaveProperty('governanceRole');
199
- expect(sentCollections[0]).not.toHaveProperty('thinkingLayer');
200
- expect(sentCollections[0]).not.toHaveProperty('name');
201
- expect(sentCollections[0].slug).toBe('standards');
202
- expect(sentCollections[0].governanceFunction).toBe('constraint');
203
- // Total payload for this one collection stays far below the gateway's 10KB
204
- // per-string cap even though the source row carried a 15KB description.
205
- expect(new TextEncoder().encode(JSON.stringify(sentCollections[0])).length).toBeLessThan(200);
206
- });
207
- it('classify failure: returns degraded sentinel, not a silent-empty rules array (PR #378 P1)', async () => {
208
- // Fetch steps succeed; only the classify call fails. Before this fix, the classify
209
- // catch block silently produced `classified = []` and let the function continue,
210
- // reporting success with 0 rules — indistinguishable from a genuinely empty
211
- // workspace. A classify failure means NO rules can be derived at all, so it must get
212
- // the same degraded-sentinel treatment as the two fetch failures.
213
- const entries = [makeEntry({ entryId: 'STD-1', name: 'No direct imports', collectionSlug: 'standards' })];
214
- const mcpFn = vi.fn((name) => {
215
- if (name === 'chain.getGovernanceWithRelations') {
216
- return Promise.resolve({ entries, total: entries.length });
217
- }
218
- if (name === 'chain.listCollections') {
219
- return Promise.resolve(COLLECTIONS);
220
- }
221
- if (name === 'chain.classifyGovernance') {
222
- return Promise.reject(new Error('classify network error'));
223
- }
224
- return Promise.resolve(null);
225
- });
226
- const result = await generateChainRules(mcpFn, []);
227
- expect(result.rules).toHaveLength(0);
228
- expect(result.sentinel).not.toBeNull();
229
- expect(result.sentinel.name).toBe('_chain_degraded');
230
- expect(result.classified).toHaveLength(0);
231
- });
232
- it('MCP failure: returns sentinel rule and empty rules array', async () => {
233
- const mcpFn = mockMcpFailure();
234
- const result = await generateChainRules(mcpFn, []);
235
- expect(result.rules).toHaveLength(0);
236
- expect(result.sentinel).not.toBeNull();
237
- expect(result.sentinel.name).toBe('_chain_degraded');
238
- expect(result.sentinel.level).toBe('core');
239
- expect(result.sentinel.sourcePath).toBe('chain://_sentinel');
240
- expect(result.sentinel.autoApply).toBe(true);
241
- expect(result.gaps).toHaveLength(0);
242
- expect(result.stats.totalEntries).toBe(0);
243
- });
244
- it('manual suppression: existing manual rule suppresses generated rule', async () => {
245
- // 'chain-constraints' is the archetype name for 'constraint' function
246
- const entries = [
247
- makeEntry({ entryId: 'STD-1', name: 'No direct imports', collectionSlug: 'standards' }),
248
- ];
249
- const mcpFn = mockMcpSuccess(entries);
250
- const manualRules = [makeManualRule('chain-constraints')];
251
- const result = await generateChainRules(mcpFn, manualRules);
252
- // The constraint archetype should be suppressed since manual rule with same name exists
253
- const constraintRule = result.rules.find((r) => r.sourcePath === 'chain://constraint');
254
- expect(constraintRule).toBeUndefined();
255
- expect(result.stats.suppressedByManual).toBeGreaterThan(0);
256
- });
257
- it('zero entries: function with no matching entries appears in gaps', async () => {
258
- // Only provide boundary entries — all other functions should gap
259
- const entries = [
260
- makeEntry({ entryId: 'ARCH-1', name: 'Domain layers', collectionSlug: 'architecture' }),
261
- ];
262
- const mcpFn = mockMcpSuccess(entries);
263
- const result = await generateChainRules(mcpFn, []);
264
- // boundary gets a rule; others go to gaps
265
- expect(result.gaps.length).toBeGreaterThan(0);
266
- // 'workflow', 'convention', 'policy', 'quality-gate', 'constraint' should be in gaps
267
- expect(result.gaps).toContain('workflow');
268
- expect(result.gaps).toContain('constraint');
269
- expect(result.stats.suppressedByZeroEntries).toBe(result.gaps.length);
270
- });
271
- it('caps at 8 rules: 9+ entries across functions → only top 8', async () => {
272
- // Provide entries for all 6 functions — but we only have 6 functions so need
273
- // to test with all 6 populated. The cap of 8 means all 6 pass through here.
274
- // To test capping we need to produce more than 8. Since we only have 6
275
- // governance functions, 6 is the max. So we verify the cap does not drop below 6.
276
- // The cap only fires when a future function count exceeds 8.
277
- // We still verify that when fewer than 8 rules exist, all are returned.
278
- const entries = [
279
- makeEntry({ entryId: 'STD-1', name: 'Import rule', collectionSlug: 'standards' }),
280
- makeEntry({ entryId: 'ARCH-1', name: 'Domain layers', collectionSlug: 'architecture' }),
281
- makeEntry({ entryId: 'DEC-1', name: 'Deploy convention', collectionSlug: 'decisions' }),
282
- makeEntry({ entryId: 'POL-1', name: 'Auth policy', collectionSlug: 'policies' }),
283
- makeEntry({ entryId: 'FLO-1', name: 'Capture flow', collectionSlug: 'flows' }),
284
- ];
285
- const mcpFn = mockMcpSuccess(entries);
286
- const result = await generateChainRules(mcpFn, []);
287
- // 5 entries across different functions → at most 5 rules, well under the cap of 8
288
- expect(result.rules.length).toBeLessThanOrEqual(8);
289
- });
290
- it('cap at 8 rules enforced when more than 8 rules would be generated', async () => {
291
- // We cannot generate more than 6 rules (only 6 functions), so we test the
292
- // ranking/sorting logic and confirm the result is <= 8.
293
- // Provide entries with dense relations to test ranking path.
294
- const entries = [
295
- makeEntry({
296
- entryId: 'STD-1',
297
- name: 'Import constraint',
298
- collectionSlug: 'standards',
299
- relations: [
300
- { type: 'constrains', direction: 'outgoing', otherEntryId: 'BET-1', otherName: 'BET-1', otherCollectionSlug: 'bets' },
301
- { type: 'constrains', direction: 'outgoing', otherEntryId: 'BET-2', otherName: 'BET-2', otherCollectionSlug: 'bets' },
302
- ],
303
- }),
304
- makeEntry({
305
- entryId: 'ARCH-1',
306
- name: 'Layer boundaries',
307
- collectionSlug: 'architecture',
308
- relations: [
309
- { type: 'informed_by', direction: 'incoming', otherEntryId: 'DEC-1', otherName: 'DEC-1', otherCollectionSlug: 'architecture' },
310
- ],
311
- }),
312
- ];
313
- const mcpFn = mockMcpSuccess(entries);
314
- const result = await generateChainRules(mcpFn, []);
315
- expect(result.rules.length).toBeLessThanOrEqual(8);
316
- // Rules are sorted — verify stable output
317
- for (const rule of result.rules) {
318
- expect(rule.sourcePath).toMatch(/^chain:\/\//);
319
- }
320
- });
321
- it('empty workspace: no governance entries → empty rules, all functions in gaps', async () => {
322
- const mcpFn = mockMcpSuccess([]);
323
- const result = await generateChainRules(mcpFn, []);
324
- expect(result.rules).toHaveLength(0);
325
- expect(result.sentinel).toBeNull();
326
- expect(result.gaps).toHaveLength(6); // all 6 functions gap
327
- expect(result.gaps).toContain('constraint');
328
- expect(result.gaps).toContain('boundary');
329
- expect(result.gaps).toContain('convention');
330
- expect(result.gaps).toContain('policy');
331
- expect(result.gaps).toContain('workflow');
332
- expect(result.gaps).toContain('quality-gate');
333
- expect(result.stats.totalEntries).toBe(0);
334
- expect(result.stats.classifiedEntries).toBe(0);
335
- expect(result.stats.generatedRules).toBe(0);
336
- expect(result.stats.suppressedByZeroEntries).toBe(6);
337
- });
338
- it('stats are accurate: counts match actual outcomes', async () => {
339
- const entries = [
340
- makeEntry({ entryId: 'STD-1', name: 'Import rule', collectionSlug: 'standards' }),
341
- makeEntry({ entryId: 'STD-2', name: 'Null check rule', collectionSlug: 'standards' }),
342
- ];
343
- const mcpFn = mockMcpSuccess(entries);
344
- const result = await generateChainRules(mcpFn, []);
345
- expect(result.stats.totalEntries).toBe(2);
346
- expect(result.stats.classifiedEntries).toBe(2);
347
- // generatedRules + suppressedByManual + suppressedByZeroEntries = 6 (total governance functions)
348
- const total = result.stats.generatedRules + result.stats.suppressedByManual + result.stats.suppressedByZeroEntries;
349
- expect(total).toBe(6);
350
- // gaps length equals suppressedByZeroEntries
351
- expect(result.gaps.length).toBe(result.stats.suppressedByZeroEntries);
352
- });
353
- it('classifies custom collection slugs from collection metadata', async () => {
354
- const entries = [
355
- makeEntry({ entryId: 'WA-1', name: 'Working agreement', collectionSlug: 'working-agreements' }),
356
- makeEntry({ entryId: 'SYS-1', name: 'Boundary note', collectionSlug: 'system-shape' }),
357
- ];
358
- const mcpFn = mockMcpSuccess(entries, [
359
- { slug: 'working-agreements', governanceFunction: 'constraint' },
360
- { slug: 'system-shape', governanceFunction: 'boundary' },
361
- ]);
362
- const result = await generateChainRules(mcpFn, []);
363
- expect(result.classified.map((entry) => [entry.collectionSlug, entry.governanceFunction])).toEqual([
364
- ['working-agreements', 'constraint'],
365
- ['system-shape', 'boundary'],
366
- ]);
367
- });
368
- it('chunks classification below the Convex argument ceiling at SCALE_TIERS.xl (PR #378 Codex follow-up)', async () => {
369
- // Mirrors convex/lib/scaleTiers.ts's `xl` tier — ~4,000 governance entries, 3
370
- // relations each — the production-scale shape Codex's finding cited. A single
371
- // `chain.classifyGovernance` call with the whole corpus as one Convex argument (echoed
372
- // back in the response too) risks the platform's <1MB function-argument/value ceiling
373
- // (convex/http.ts:1816-1819). This test proves: (a) more than one batch is actually
374
- // sent (batching engages, it isn't a no-op at this volume), (b) no single batch's
375
- // `entries` payload exceeds a generous ceiling well under 1MB, and (c) every entry's
376
- // classification survives the round trip (merge is lossless).
377
- const XL_ENTRY_COUNT = 4000;
378
- const XL_RELATIONS_PER_ENTRY = 3;
379
- const xlEntries = Array.from({ length: XL_ENTRY_COUNT }, (_, i) => makeEntry({
380
- entryId: `STD-${i}`,
381
- name: `Synthetic xl-scale standard #${i} — mirrors production entry name length`,
382
- collectionSlug: 'standards',
383
- data: { note: `Synthetic body text for entry ${i}, representative of a real entry's data payload size.` },
384
- relations: Array.from({ length: XL_RELATIONS_PER_ENTRY }, (_, r) => ({
385
- type: 'constrains',
386
- direction: 'outgoing',
387
- otherEntryId: `BET-${i}-${r}`,
388
- otherName: `Related bet ${i}-${r}`,
389
- otherCollectionSlug: 'bets',
390
- })),
391
- }));
392
- const CONVEX_ARG_CEILING_BYTES = 1_000_000; // the platform ceiling the fix stays under
393
- const batchByteSizes = [];
394
- let classifyCallCount = 0;
395
- const mcpFn = vi.fn((name, args) => {
396
- if (name === 'chain.getGovernanceWithRelations') {
397
- return Promise.resolve({ entries: xlEntries, total: xlEntries.length });
398
- }
399
- if (name === 'chain.listCollections') {
400
- return Promise.resolve(COLLECTIONS);
401
- }
402
- if (name === 'chain.classifyGovernance') {
403
- classifyCallCount += 1;
404
- const batchEntries = args.entries;
405
- batchByteSizes.push(new TextEncoder().encode(JSON.stringify(batchEntries)).length);
406
- return Promise.resolve(mockClassifyGovernance(batchEntries, COLLECTIONS));
407
- }
408
- return Promise.resolve(null);
409
- });
410
- const result = await generateChainRules(mcpFn, []);
411
- expect(classifyCallCount).toBeGreaterThan(1); // batching actually engaged at this volume
412
- for (const size of batchByteSizes) {
413
- expect(size).toBeLessThan(CONVEX_ARG_CEILING_BYTES);
414
- }
415
- // Merge is lossless: every entry classified exactly once.
416
- expect(result.classified).toHaveLength(XL_ENTRY_COUNT);
417
- expect(new Set(result.classified.map((c) => c.entryId)).size).toBe(XL_ENTRY_COUNT);
418
- expect(result.sentinel).toBeNull();
419
- });
420
- it('tolerates a stale governanceFunction on one collection — no degraded sentinel for a single bad row (PR #378 Codex follow-up P2)', async () => {
421
- // `collections` schema declares governanceFunction as `v.optional(v.string())`
422
- // (convex/schema.ts:585, :4142) — any string is legal in the DB. Before the fix, the
423
- // served route's strict 7-literal validator rejected the WHOLE classify call the
424
- // moment any one collection carried a stale/legacy value (e.g. a value from before a
425
- // GovernanceFunction taxonomy change), degrading every rule — not just the one
426
- // affected collection's entries. The kernel's normalizeGovernanceFunction already
427
- // tolerates this per-item (falls to 'unclassified' for just that collection); this
428
- // test proves the route no longer blocks it from ever reaching that logic.
429
- const entries = [
430
- makeEntry({ entryId: 'STD-1', name: 'Normal standard', collectionSlug: 'standards' }),
431
- makeEntry({ entryId: 'X-1', name: 'Entry in stale collection', collectionSlug: 'legacy-collection' }),
432
- ];
433
- const collectionsWithStaleValue = [
434
- ...COLLECTIONS,
435
- // Not one of the 7 GovernanceFunction literals — simulates a stale/legacy DB value.
436
- { slug: 'legacy-collection', governanceFunction: 'deprecated-taxonomy-value' },
437
- ];
438
- const mcpFn = mockMcpSuccess(entries, collectionsWithStaleValue);
439
- const result = await generateChainRules(mcpFn, []);
440
- // The whole call must NOT degrade — STD-1's own collection is perfectly valid.
441
- expect(result.sentinel).toBeNull();
442
- expect(result.stats.totalEntries).toBe(2);
443
- expect(result.stats.classifiedEntries).toBe(2);
444
- const std1 = result.classified.find((c) => c.entryId === 'STD-1');
445
- expect(std1?.governanceFunction).toBe('constraint');
446
- });
447
- });
448
- //# sourceMappingURL=chain-rules.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chain-rules.test.js","sourceRoot":"","sources":["../../src/generators/chain-rules.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,0EAA0E;AAE1E,SAAS,SAAS,CAAC,SAAoG;IACrH,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,kBAAkB,EAAE,UAAU;QAC9B,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,EAAE;QACb,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE,uBAAuB,IAAI,KAAK;QAC5C,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,SAAS;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAgC;IAC/C,EAAE,IAAI,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE;IACvD,EAAE,IAAI,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE;IAC5D,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;QAClE,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,67 +0,0 @@
1
- /**
2
- * Handshake Diff — BET-286 Slice 4
3
- *
4
- * Persists handshake --generate state between runs and produces a diff
5
- * showing what changed (added, removed, changed rules) since the last run.
6
- *
7
- * Chain: BET-286 (Chain-Derived Agent Configuration)
8
- */
9
- import type { CanonicalRule } from './portable-knowledge.js';
10
- import type { ClassifiedGovernance } from './chain-classifier.js';
11
- /** Persisted record of a single generated rule from a handshake --generate run. */
12
- export interface HandshakeStateRule {
13
- name: string;
14
- /** Governance function key, e.g. 'constraint', 'boundary' */
15
- functionKey: string;
16
- /** Source path, always 'chain://<functionKey>' for generated rules */
17
- sourcePath: string;
18
- /** Classifier confidence for the winning function (averaged across contributing entries) */
19
- confidence: number;
20
- /** Entry IDs that contributed to this rule */
21
- entryIds: string[];
22
- }
23
- /** Persisted state written after each handshake --generate run. */
24
- export interface HandshakeState {
25
- timestamp: string;
26
- rules: HandshakeStateRule[];
27
- }
28
- /** A single rule change detected by diffHandshakeState(). */
29
- export interface RuleDiff {
30
- name: string;
31
- change: 'added' | 'removed' | 'changed';
32
- /** Human-readable change detail, e.g. "confidence: 0.7 → 0.9" or "entries: +STD-22, -STD-7" */
33
- details?: string;
34
- }
35
- /** Full diff result comparing current state to previous state. */
36
- export interface HandshakeDiff {
37
- added: RuleDiff[];
38
- removed: RuleDiff[];
39
- changed: RuleDiff[];
40
- isFirstRun: boolean;
41
- }
42
- /**
43
- * Build a HandshakeState in memory from rules and classified entries.
44
- * Only includes chain:// sourced rules (ignores manual rules).
45
- * Filters out the sentinel rule (chain://_sentinel) to avoid diff noise.
46
- */
47
- export declare function buildCurrentState(rules: CanonicalRule[], classified: ClassifiedGovernance[]): HandshakeState;
48
- /**
49
- * Save current handshake state to .productbrain/.handshake-state.json.
50
- * Only persists chain:// sourced rules (ignores manual rules and sentinel).
51
- */
52
- export declare function saveHandshakeState(pbDir: string, rules: CanonicalRule[], classified: ClassifiedGovernance[]): void;
53
- /**
54
- * Load previous handshake state from .productbrain/.handshake-state.json.
55
- * Returns null if no previous state exists or the file cannot be parsed.
56
- */
57
- export declare function loadPreviousState(pbDir: string): HandshakeState | null;
58
- /**
59
- * Compare current rules against previous state and produce a diff.
60
- * When previous is null, all current rules are reported as added (first run).
61
- */
62
- export declare function diffHandshakeState(current: HandshakeState, previous: HandshakeState | null): HandshakeDiff;
63
- /**
64
- * Format a HandshakeDiff for console output.
65
- */
66
- export declare function formatDiff(diff: HandshakeDiff): string;
67
- //# sourceMappingURL=handshake-diff.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handshake-diff.d.ts","sourceRoot":"","sources":["../../src/generators/handshake-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,mEAAmE;AACnE,MA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