snapkitty
agents
python
File size: 1,453 Bytes
662ceed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { buildReverseProof, verifyTraceability } from '../src/reverse-proof.js';

describe('reverse-proof', () => {
  it('verifies complete traceability', () => {
    const proof = buildReverseProof(
      ['server.ts'],
      { 'server.ts': 'build server' },
      { 'server.ts': 'Article III' },
      { 'server.ts': 'FORGE' },
      { 'server.ts': 'cold_boot' },
      { 'server.ts': 'ha_000001' }
    );
    assert.equal(proof.allVerified, true);
    assert.equal(proof.orphanArtifacts.length, 0);
  });

  it('detects orphan artifacts', () => {
    const proof = buildReverseProof(
      ['server.ts', 'orphan.ts'],
      { 'server.ts': 'build server' },
      { 'server.ts': 'Article III' },
      { 'server.ts': 'FORGE' },
      { 'server.ts': 'cold_boot' },
      { 'server.ts': 'ha_000001' }
    );
    assert.equal(proof.allVerified, false);
    assert.ok(proof.orphanArtifacts.includes('orphan.ts'));
  });

  it('verifyTraceability returns valid for complete proof', () => {
    const proof = buildReverseProof(
      ['a.ts'],
      { 'a.ts': 'instruction' },
      { 'a.ts': 'clause' },
      { 'a.ts': 'agent' },
      { 'a.ts': 'state' },
      { 'a.ts': 'worm' }
    );
    const result = verifyTraceability(proof);
    assert.equal(result.valid, true);
    assert.equal(result.orphans.length, 0);
  });
});