hub-provenance.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 days 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
4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b
fix(7C-L1b): route hosted delegation proposals through cani…
Human
minor
⚠
31 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
51 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
83 days ago