hub-scope-filter.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | import { describe, it } from 'node:test'; |
| 2 | import assert from 'node:assert'; |
| 3 | import { |
| 4 | applyScopeFilterToNotes, |
| 5 | applyScopeFilterToProposals, |
| 6 | } from '../hub/lib/scope-filter.mjs'; |
| 7 | |
| 8 | describe('applyScopeFilterToProposals', () => { |
| 9 | it('returns all proposals when scope is empty', () => { |
| 10 | const ps = [{ path: 'inbox/a.md' }, { path: 'projects/foo/x.md' }]; |
| 11 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, null), ps); |
| 12 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, {}), ps); |
| 13 | }); |
| 14 | |
| 15 | it('filters by folder prefix like notes', () => { |
| 16 | const scope = { folders: ['inbox'] }; |
| 17 | const ps = [{ path: 'inbox/a.md' }, { path: 'other/b.md' }]; |
| 18 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'inbox/a.md' }]); |
| 19 | }); |
| 20 | |
| 21 | it('filters by project from path projects/slug/', () => { |
| 22 | const scope = { projects: ['foo'] }; |
| 23 | const ps = [{ path: 'projects/foo/note.md' }, { path: 'projects/bar/note.md' }]; |
| 24 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'projects/foo/note.md' }]); |
| 25 | }); |
| 26 | |
| 27 | it('filters by project from parsed frontmatter object', () => { |
| 28 | const scope = { projects: ['alpha'] }; |
| 29 | const ps = [ |
| 30 | { path: 'x.md', frontmatter: { project: 'alpha' } }, |
| 31 | { path: 'y.md', frontmatter: { project: 'beta' } }, |
| 32 | ]; |
| 33 | assert.deepStrictEqual(applyScopeFilterToProposals(ps, scope), [{ path: 'x.md', frontmatter: { project: 'alpha' } }]); |
| 34 | }); |
| 35 | |
| 36 | it('matches applyScopeFilterToNotes for same path set', () => { |
| 37 | const scope = { folders: ['inbox'], projects: ['p1'] }; |
| 38 | const notes = [ |
| 39 | { path: 'inbox/n.md', project: null }, |
| 40 | { path: 'deep/x.md', project: 'p1' }, |
| 41 | ]; |
| 42 | const proposals = [{ path: 'inbox/n.md' }, { path: 'deep/x.md', project: 'p1' }]; |
| 43 | const nf = applyScopeFilterToNotes(notes, scope).map((n) => n.path).sort(); |
| 44 | const pf = applyScopeFilterToProposals(proposals, scope).map((p) => p.path).sort(); |
| 45 | assert.deepStrictEqual(pf, nf); |
| 46 | }); |
| 47 | }); |
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