Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

2.7 KB
Raw Blame
import { describe, expect, test } from 'bun:test';
import { exampleProvenance } from './provenance.mjs';

describe('gallery attribution boundaries', () => {
  test('missing author records remain unknown rather than becoming clean-room evidence', () => {
    const p = exampleProvenance('const meta = {};');
    expect(p.attribution).toBe('Historical collection attribution; no model header');
    expect(p.sourceAccess).toBe('Not recorded');
    expect(p.humanIntervention).toBe('Not recorded');
  });
  test('preserves stated isolation and reviewer input without claiming an independent audit', () => {
    const p = exampleProvenance(
      '// Authored by: muse, via opencode.\n// No example asset or engine implementation was supplied as authoring context.\n// Refined by the same model using source references after reviewer feedback.\n// Geometry reviewed during authoring; material-faithful gallery render reviewed separately.',
    );
    expect(p.attribution).toBe('Source-header credit');
    expect(p.sourceAccess).toContain('declares');
    expect(p.humanIntervention).toContain('Reviewer');
    expect(p.reviewFidelity).toContain('Geometry');
  });
});

test('recorded gallery credit is bound to exact source bytes', async () => {
  const { recordedExampleCredit } = await import('./provenance.mjs');
  const { createHash } = await import('node:crypto');
  const code = 'const meta = {};';
  const record = {
    sourceHash: createHash('sha256').update(code).digest('hex'),
    model: 'GPT-6 Astra',
    harness: 'Codex',
    authoredDate: '2026-09-05',
    provenance: { attribution: 'Recorded model run' },
  };
  expect(recordedExampleCredit(code, record).model).toBe('GPT-6 Astra');
  expect(() => recordedExampleCredit(code + ' ', record)).toThrow('source');
});

test('recorded poster refuses a changed source or image, and ignores the artifact bytes', async () => {
  const { verifyRecordedPoster } = await import('./provenance.mjs');
  const { createHash } = await import('node:crypto');
  const hash = (x: string) => createHash('sha256').update(x).digest('hex');
  const r = { sourceHash: hash('source'), artifactHash: hash('glb'), imageHash: hash('png') };
  expect(() => verifyRecordedPoster(r, 'source', 'png')).not.toThrow();
  for (const bytes of [
    ['changed', 'png'],
    ['source', 'changed'],
  ])
    expect(() => verifyRecordedPoster(r, ...bytes)).toThrow('poster');
  // The point of the narrowing: a receipt whose recorded GLB bytes no longer
  // match anything this runner produces is still a valid receipt. Asserting them
  // is what pinned the gallery build to one operating system.
  expect(() => verifyRecordedPoster({ ...r, artifactHash: hash('other bytes') }, 'source', 'png')).not.toThrow();
});