397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
2.2 KiB
JavaScript
44 lines
2.2 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { sealableArtifact, sealablePlan, judgedHashOf, sealArtifact, sealPlan } from './seal-orchestration.mjs';
|
|
import { contentHash } from './judge-seal-channel.mjs';
|
|
|
|
const specMd = '## Реш {#dec-a}\nтекст';
|
|
const planMd = '```steps-json\n[{"op":"Edit","object":"app/Foo.php","ref":"dec-a"}]\n```';
|
|
const KEY = 'k';
|
|
const goVerdict = (obj) => ({ wired: true, decision: 'GO', judged_hash: judgedHashOf(obj), verdict_id: 'v1' });
|
|
|
|
describe('seal-orchestration', () => {
|
|
it('judgedHashOf == contentHash of same sealable object (SD-1)', () => {
|
|
const a = sealableArtifact(specMd);
|
|
expect(judgedHashOf(a)).toBe(contentHash(a));
|
|
});
|
|
it('sealArtifact on real GO → sealed, verifiable', () => {
|
|
const a = sealableArtifact(specMd);
|
|
const r = sealArtifact({ md: specMd, verdict: goVerdict(a), key: KEY, judgeMode: 'live-block' });
|
|
expect(r.sealed).toBe(true);
|
|
expect(r.seal.sections['dec-a']).toBeTruthy();
|
|
expect(r.seal.judge_mode).toBe('live-block');
|
|
});
|
|
it('sealArtifact NOT sealed on degraded GO (wired:false, SE-3)', () => {
|
|
const a = sealableArtifact(specMd);
|
|
const r = sealArtifact({ md: specMd, verdict: { wired: false, decision: 'GO' }, key: KEY, judgeMode: 'shadow' });
|
|
expect(r.sealed).toBe(false);
|
|
});
|
|
it('sealArtifact NOT sealed on judged_hash mismatch (SD-1/TOCTOU)', () => {
|
|
const r = sealArtifact({ md: specMd, verdict: { wired: true, decision: 'GO', judged_hash: 'WRONG' }, key: KEY, judgeMode: 'live-block' });
|
|
expect(r.sealed).toBe(false);
|
|
});
|
|
it('sealPlan stamps artifact_id from current artifact (SD-3)', () => {
|
|
const planObj = sealablePlan(planMd);
|
|
const r = sealPlan({ md: planMd, currentArtifact: { artifact_id: 'AID' }, verdict: goVerdict(planObj), key: KEY, judgeMode: 'live-block' });
|
|
expect(r.sealed).toBe(true);
|
|
expect(r.seal.artifact_id).toBe('AID');
|
|
expect(r.seal.judge_mode).toBe('live-block');
|
|
});
|
|
it('sealPlan fail-CLOSE without current artifact (VA-1/SD-3)', () => {
|
|
const planObj = sealablePlan(planMd);
|
|
const r = sealPlan({ md: planMd, currentArtifact: null, verdict: goVerdict(planObj), key: KEY, judgeMode: 'live-block' });
|
|
expect(r.sealed).toBe(false);
|
|
});
|
|
});
|