hosted-write-eval-kn-b-data-integrity.test.mjs
74 lines 2.7 KB
Raw
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 9 days ago
1 /**
2 * HOSTED-WRITE-EVAL-KN-b — Tier 5 data-integrity: path/body, audit fields, not left pending.
3 */
4 import { describe, it, beforeEach, afterEach } from 'node:test';
5 import assert from 'node:assert/strict';
6 import fs from 'node:fs';
7 import os from 'node:os';
8 import path from 'node:path';
9 import { createProposal, getProposal, updateProposalStatus } from '../hub/proposals-store.mjs';
10 import { augmentProposalCreateRequestBody } from '../lib/hub-proposal-create-augment.mjs';
11 import { SCOOLING_REVIEW_TRAY_INTENT } from '../lib/hub-proposal-personal-self-apply.mjs';
12 import { writeNote } from '../lib/write.mjs';
13 import { readNote } from '../lib/vault.mjs';
14
15 describe('HOSTED-WRITE-EVAL-KN-b data-integrity', () => {
16 /** @type {string} */
17 let dataDir;
18 /** @type {string} */
19 let vaultPath;
20
21 beforeEach(() => {
22 dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kt-hwe-di-'));
23 vaultPath = path.join(dataDir, 'vault');
24 fs.mkdirSync(vaultPath, { recursive: true });
25 });
26
27 afterEach(() => {
28 fs.rmSync(dataDir, { recursive: true, force: true });
29 });
30
31 it('applied note path/body match proposal; evaluated_by + external_ref preserved; not pending', async () => {
32 const actor = 'github:ops';
33 const notePath = 'reviewed/di-note.md';
34 const bodyText = 'integrity body';
35 const ext = 'scooling.review:di-note';
36 const augmented = augmentProposalCreateRequestBody(
37 {
38 path: notePath,
39 body: bodyText,
40 intent: SCOOLING_REVIEW_TRAY_INTENT,
41 external_ref: ext,
42 labels: [],
43 },
44 dataDir,
45 { evaluationRequired: true, evaluatedBy: actor },
46 );
47 assert.equal(augmented.evaluation_status, 'passed');
48
49 const proposal = createProposal(dataDir, {
50 path: notePath,
51 body: bodyText,
52 intent: SCOOLING_REVIEW_TRAY_INTENT,
53 external_ref: ext,
54 evaluationRequired: true,
55 proposed_by: actor,
56 });
57 assert.equal(proposal.evaluation_status, 'passed');
58 assert.equal(proposal.evaluated_by, actor);
59 assert.ok(proposal.evaluated_at);
60 assert.equal(proposal.external_ref, ext);
61
62 await writeNote(vaultPath, proposal.path, { body: proposal.body, frontmatter: {} });
63 updateProposalStatus(dataDir, proposal.proposal_id, 'approved', { external_ref: ext });
64
65 const disk = readNote(vaultPath, notePath);
66 assert.equal(disk.body.trimEnd(), bodyText.trimEnd());
67 const stored = getProposal(dataDir, proposal.proposal_id);
68 assert.equal(stored.status, 'approved');
69 assert.notEqual(stored.evaluation_status, 'pending');
70 assert.equal(stored.evaluation_status, 'passed');
71 assert.equal(stored.external_ref, ext);
72 assert.equal(stored.evaluated_by, actor);
73 });
74 });
File History 1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6 docs: record AIP-b SD-21 land (KN #308) Human 9 days ago