hub-provenance.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * Hub provenance: reserved frontmatter keys are server-controlled. |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert'; |
| 6 | import { mergeProvenanceFrontmatter, stripReservedFrontmatterKeys } from '../lib/hub-provenance.mjs'; |
| 7 | |
| 8 | describe('hub-provenance', () => { |
| 9 | it('stripReservedFrontmatterKeys removes reserved keys', () => { |
| 10 | const out = stripReservedFrontmatterKeys({ |
| 11 | title: 'x', |
| 12 | knowtation_editor: 'fake', |
| 13 | author_kind: 'human', |
| 14 | }); |
| 15 | assert.strictEqual(out.title, 'x'); |
| 16 | assert.strictEqual(out.knowtation_editor, undefined); |
| 17 | assert.strictEqual(out.author_kind, undefined); |
| 18 | }); |
| 19 | |
| 20 | it('mergeProvenanceFrontmatter applies server values over client forgeries', () => { |
| 21 | const now = '2026-03-22T12:00:00.000Z'; |
| 22 | const merged = mergeProvenanceFrontmatter( |
| 23 | { |
| 24 | title: 'Note', |
| 25 | knowtation_editor: 'google:fake', |
| 26 | knowtation_edited_at: '1999-01-01', |
| 27 | author_kind: 'webhook', |
| 28 | }, |
| 29 | { sub: 'github:7612643', kind: 'human', now }, |
| 30 | ); |
| 31 | assert.strictEqual(merged.title, 'Note'); |
| 32 | assert.strictEqual(merged.knowtation_editor, 'github:7612643'); |
| 33 | assert.strictEqual(merged.knowtation_edited_at, now); |
| 34 | assert.strictEqual(merged.author_kind, 'human'); |
| 35 | }); |
| 36 | |
| 37 | it('webhook kind omits knowtation_editor when sub absent', () => { |
| 38 | const merged = mergeProvenanceFrontmatter({ source: 'slack' }, { kind: 'webhook', now: 't' }); |
| 39 | assert.strictEqual(merged.source, 'slack'); |
| 40 | assert.strictEqual(merged.author_kind, 'webhook'); |
| 41 | assert.strictEqual(merged.knowtation_editor, undefined); |
| 42 | }); |
| 43 | |
| 44 | it('mergeProvenanceFrontmatter parses JSON string frontmatter (Hub UI / gateway wire)', () => { |
| 45 | const now = '2026-03-26T20:00:00.000Z'; |
| 46 | const inner = JSON.stringify({ title: 'T', tags: 'alpha, beta', date: '2026-03-26' }); |
| 47 | const merged = mergeProvenanceFrontmatter(inner, { sub: 'google:1', kind: 'human', now }); |
| 48 | assert.strictEqual(merged.title, 'T'); |
| 49 | assert.strictEqual(merged.tags, 'alpha, beta'); |
| 50 | assert.strictEqual(merged.date, '2026-03-26'); |
| 51 | assert.strictEqual(merged.knowtation_editor, 'google:1'); |
| 52 | assert.strictEqual(merged.knowtation_edited_at, now); |
| 53 | }); |
| 54 | |
| 55 | it('agent approve merge includes proposed and approved', () => { |
| 56 | const merged = mergeProvenanceFrontmatter( |
| 57 | { project: 'launch' }, |
| 58 | { |
| 59 | sub: 'google:admin', |
| 60 | kind: 'agent', |
| 61 | now: 'n', |
| 62 | proposedBy: 'github:agent', |
| 63 | approvedBy: 'google:admin', |
| 64 | }, |
| 65 | ); |
| 66 | assert.strictEqual(merged.project, 'launch'); |
| 67 | assert.strictEqual(merged.knowtation_proposed_by, 'github:agent'); |
| 68 | assert.strictEqual(merged.knowtation_approved_by, 'google:admin'); |
| 69 | assert.strictEqual(merged.knowtation_editor, 'google:admin'); |
| 70 | assert.strictEqual(merged.author_kind, 'agent'); |
| 71 | }); |
| 72 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago