section-source-transport-plan.test.mjs
131 lines 5.8 KB
Raw
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor ⚠ breaking 1 day ago
1 /**
2 * SectionSource Phase 1D transport planning tests.
3 *
4 * Phase 1D accepted future body-free CLI and self-hosted MCP surfaces only. It
5 * must not allow hosted MCP, Hub, search, persistence, Scooling runtime
6 * behavior, section bodies, snippets, summaries, PageIndex, OCR, LLM calls, or
7 * provider routing.
8 */
9 import { describe, it } from 'node:test';
10 import assert from 'node:assert/strict';
11 import fs from 'fs';
12 import path from 'path';
13 import { fileURLToPath } from 'url';
14
15 import { readSectionSource } from '../lib/section-source-note.mjs';
16
17 const __dirname = path.dirname(fileURLToPath(import.meta.url));
18 const repoRoot = path.dirname(__dirname);
19 const fixtureVault = path.join(__dirname, 'fixtures', 'vault-fs');
20 const planPath = path.join(repoRoot, 'docs', 'SECTION-SOURCE-TRANSPORT-PLAN.md');
21
22 function readRepoFile(relativePath) {
23 return fs.readFileSync(path.join(repoRoot, relativePath), 'utf8');
24 }
25
26 describe('SectionSource Phase 1D body-free transport plan', () => {
27 it('unit: plan covers the required transport decision areas', () => {
28 const plan = fs.readFileSync(planPath, 'utf8');
29 const requiredSections = [
30 '## Transport Decision',
31 '## Allowed Future Local CLI Shape',
32 '## Allowed Future Self-Hosted MCP Shape',
33 '## Hosted Transport Block',
34 '## Search And Persistence Block',
35 '## Scooling Boundary',
36 '## Seven-Tier Test Requirements',
37 '## Stop Conditions',
38 '## Acceptance Criteria',
39 ];
40
41 for (const section of requiredSections) {
42 assert.equal(plan.includes(section), true, `${section} is documented`);
43 }
44 assert.match(plan, /The local CLI and self-hosted MCP surfaces are now implemented/);
45 assert.match(plan, /This plan does not accept a hosted route, schema extension/);
46 });
47
48 it('integration: current SectionSource library output remains body-free after transport planning', () => {
49 const source = readSectionSource(fixtureVault, 'inbox/one.md');
50 const serialized = JSON.stringify(source);
51
52 assert.equal(source.sections.every((section) => section.body_returned === false), true);
53 assert.equal(source.sections.every((section) => section.snippet_returned === false), true);
54 assert.equal(Object.hasOwn(source, 'body'), false);
55 assert.equal(Object.hasOwn(source, 'snippet'), false);
56 assert.equal(Object.hasOwn(source, 'frontmatter'), false);
57 assert.equal(serialized.includes('Body of inbox one'), false);
58 assert.equal(serialized.includes('knowtation://'), false);
59 });
60
61 it('end-to-end: local CLI, self-hosted MCP, and hosted MCP are exposed while Hub remains blocked', () => {
62 const cliSource = readRepoFile('cli/index.mjs');
63 const selfHostedMcp = readRepoFile('mcp/create-server.mjs');
64 const hostedMcp = readRepoFile('hub/gateway/mcp-hosted-server.mjs');
65 const hostedAcl = readRepoFile('hub/gateway/mcp-tool-acl.mjs');
66 const hubServer = readRepoFile('hub/gateway/server.mjs');
67
68 assert.equal(cliSource.includes('get-section-source'), true);
69 assert.equal(cliSource.includes('readSectionSource'), true);
70 assert.equal(selfHostedMcp.includes('get_section_source'), true);
71 assert.equal(selfHostedMcp.includes('readSectionSource'), true);
72 assert.equal(hostedMcp.includes('get_section_source'), true);
73 assert.equal(hostedMcp.includes('buildSectionSource'), true);
74 assert.equal(hostedAcl.includes('get_section_source'), true);
75 assert.equal(hostedMcp.includes('readSectionSource'), false);
76 assert.equal(hubServer.includes('get_section_source'), false);
77 assert.equal(hubServer.includes('section_source/v0'), false);
78 });
79
80 it('stress: transport planning checks bounded files without scanning the vault', () => {
81 const started = Date.now();
82 const files = [
83 'docs/SECTION-SOURCE-TRANSPORT-PLAN.md',
84 'docs/SECTION-SOURCE-BODY-SNIPPET-POLICY.md',
85 'docs/SECTION-SOURCE-V0-SPEC.md',
86 'lib/section-source.mjs',
87 'lib/section-source-note.mjs',
88 ].map((relativePath) => readRepoFile(relativePath));
89 const elapsedMs = Date.now() - started;
90
91 assert.equal(files.length, 5);
92 assert.ok(elapsedMs < 200, `expected bounded plan check under 200ms, got ${elapsedMs}ms`);
93 });
94
95 it('data-integrity: transport planning adds no writes, sidecars, indexes, vectors, or summaries', () => {
96 const implementation = [
97 readRepoFile('lib/section-source.mjs'),
98 readRepoFile('lib/section-source-note.mjs'),
99 ].join('\n');
100
101 assert.doesNotMatch(implementation, /\bwriteFile(Sync)?\s*\(/);
102 assert.doesNotMatch(implementation, /\bappendFile(Sync)?\s*\(/);
103 assert.doesNotMatch(implementation, /\bsidecar[A-Za-z0-9_]*\s*=/);
104 assert.doesNotMatch(implementation, /\bvector[A-Za-z0-9_]*\s*=/);
105 assert.doesNotMatch(implementation, /\bsummary[A-Za-z0-9_]*\s*=/);
106 });
107
108 it('performance: plan keeps one-note transport bounded and provider-free', () => {
109 const plan = fs.readFileSync(planPath, 'utf8');
110
111 assert.match(plan, /One-note transport calls do not scan the whole vault/);
112 assert.match(plan, /No external provider calls occur/);
113 assert.match(plan, /Transport output size remains bounded by section count and text caps/);
114 });
115
116 it('security: plan blocks body, snippet, hosted, search, persistence, and Scooling exposure', () => {
117 const plan = fs.readFileSync(planPath, 'utf8');
118 const blockedPhrases = [
119 'No note body text in transport output.',
120 'No section body text in transport output.',
121 'No snippets in transport output.',
122 'Hosted MCP and Hub transport remain blocked.',
123 'Transport planning does not approve search or persistence.',
124 ];
125
126 for (const phrase of blockedPhrases) {
127 assert.equal(plan.includes(phrase), true, `${phrase} is documented`);
128 }
129 assert.match(plan, /Scooling remains blocked from live SectionSource runtime consumption until a separate\s+Scooling phase/);
130 });
131 });
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