approval-log.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | import assert from 'node:assert/strict'; |
| 2 | import { test } from 'node:test'; |
| 3 | import { |
| 4 | approvalLogRelativePath, |
| 5 | isApprovalLogPath, |
| 6 | filterHitsByContentScope, |
| 7 | buildApprovalLogWrite, |
| 8 | resolveSearchFolderForContentScope, |
| 9 | } from '../lib/approval-log.mjs'; |
| 10 | |
| 11 | test('isApprovalLogPath', () => { |
| 12 | assert.equal(isApprovalLogPath('approvals/2026-03-30-abc.md'), true); |
| 13 | assert.equal(isApprovalLogPath('inbox/x.md'), false); |
| 14 | }); |
| 15 | |
| 16 | test('approvalLogRelativePath is stable for uuid', () => { |
| 17 | const p = approvalLogRelativePath('550e8400-e29b-41d4-a716-446655440000', '2026-03-30T12:00:00.000Z'); |
| 18 | assert.equal(p, 'approvals/2026-03-30-550e8400-e29b-41d4-a716-446655440000.md'); |
| 19 | }); |
| 20 | |
| 21 | test('filterHitsByContentScope', () => { |
| 22 | const hits = [{ path: 'inbox/a.md' }, { path: 'approvals/2026-03-30-x.md' }]; |
| 23 | assert.equal(filterHitsByContentScope(hits, 'notes').length, 1); |
| 24 | assert.equal(filterHitsByContentScope(hits, 'approval_logs').length, 1); |
| 25 | assert.equal(filterHitsByContentScope(hits, 'all').length, 2); |
| 26 | }); |
| 27 | |
| 28 | test('buildApprovalLogWrite shapes frontmatter', () => { |
| 29 | const w = buildApprovalLogWrite({ |
| 30 | proposalId: 'pid-1', |
| 31 | targetPath: 'inbox/foo.md', |
| 32 | approvedAt: '2026-03-30T00:00:00.000Z', |
| 33 | approvedBy: 'user-1', |
| 34 | intent: 'fix typo', |
| 35 | }); |
| 36 | assert.match(w.relativePath, /^approvals\/2026-03-30-pid-1\.md$/); |
| 37 | assert.equal(w.frontmatter.kind, 'approval_log'); |
| 38 | assert.equal(w.frontmatter.target_path, 'inbox/foo.md'); |
| 39 | assert.ok(w.body.includes('inbox/foo.md')); |
| 40 | }); |
| 41 | |
| 42 | test('buildApprovalLogWrite appends proposedBodyExcerpt for search', () => { |
| 43 | const w = buildApprovalLogWrite({ |
| 44 | proposalId: 'pid-2', |
| 45 | targetPath: 'x.md', |
| 46 | approvedAt: '2026-03-30T00:00:00.000Z', |
| 47 | proposedBodyExcerpt: 'embeddings and indexing test', |
| 48 | }); |
| 49 | assert.ok(w.body.includes('Proposal excerpt')); |
| 50 | assert.ok(w.body.includes('embeddings')); |
| 51 | }); |
| 52 | |
| 53 | test('resolveSearchFolderForContentScope approval_logs uses approvals prefix', () => { |
| 54 | const r = resolveSearchFolderForContentScope('approval_logs', undefined); |
| 55 | assert.equal(r.impossible, false); |
| 56 | assert.equal(r.folder, 'approvals'); |
| 57 | assert.equal(r.wideNotesFetch, false); |
| 58 | }); |
| 59 | |
| 60 | test('resolveSearchFolderForContentScope approval_logs conflicts with other folder', () => { |
| 61 | const r = resolveSearchFolderForContentScope('approval_logs', 'projects/foo'); |
| 62 | assert.equal(r.impossible, true); |
| 63 | }); |
| 64 | |
| 65 | test('resolveSearchFolderForContentScope notes requests wide fetch', () => { |
| 66 | const r = resolveSearchFolderForContentScope('notes', ''); |
| 67 | assert.equal(r.wideNotesFetch, true); |
| 68 | }); |
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