File size: 2,634 Bytes
0ed8124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { describe, expect, it } from 'vitest';
import {
  findManifestModel,
  orderedShardUrls,
  parseModelManifestV2,
  type ModelTierId,
} from './manifest';

const REVISION = '0123456789abcdef0123456789abcdef01234567';
const SHA = 'a'.repeat(64);

function rawModel(id: ModelTierId) {
  const is27b = id === '27b';
  const files = is27b
    ? [
      { path: '27b/Bonsai-00001-of-00002.gguf', bytes: 60, sha256: SHA },
      { path: '27b/Bonsai-00002-of-00002.gguf', bytes: 40, sha256: SHA },
    ]
    : [{ path: `${id}/Bonsai.gguf`, bytes: 100, sha256: SHA }];
  return {
    id,
    displayName: `Bonsai ${id}`,
    architecture: is27b ? 'qwen35' : 'qwen3',
    source: {
      repo: 'prism-ml/Bonsai',
      revision: REVISION,
      file: 'Bonsai.gguf',
      bytes: 100,
      sha256: SHA,
    },
    files,
    downloadBytes: 100,
    contextLength: 32768,
    defaultContext: 4096,
    cpuFallback: !is27b,
    largestTensorBytes: 64,
    requiredLimits: { maxStorageBufferBindingSize: 64 },
    chatTemplate: {
      bytes: 10,
      sha256: SHA,
      markers: { think: true, toolCall: true, toolResponse: true },
    },
    hybridDimensions: {},
    nextNTensorCount: 0,
    runtimePolicy: {
      flashAttention: false,
      tokenEmbeddingOnWebGPU: true,
      requireSingleWebGPUGraph: is27b,
    },
  };
}

function rawManifest() {
  return {
    schemaVersion: 2,
    repository: { id: 'WaveCut/Bonsai-web-GGUF', revision: REVISION },
    models: (['1_7b', '4b', '8b', '27b'] as const).map(rawModel),
  };
}

describe('model manifest v2', () => {
  it('preserves explicit shard order and derives commit-pinned URLs', () => {
    const manifest = parseModelManifestV2(rawManifest());
    const model = findManifestModel(manifest, '27b');

    expect(orderedShardUrls(manifest, model)).toEqual([
      `https://huggingface.co/WaveCut/Bonsai-web-GGUF/resolve/${REVISION}/27b/Bonsai-00001-of-00002.gguf`,
      `https://huggingface.co/WaveCut/Bonsai-web-GGUF/resolve/${REVISION}/27b/Bonsai-00002-of-00002.gguf`,
    ]);
  });

  it('rejects out-of-order shards', () => {
    const value = rawManifest();
    const model = value.models.find((candidate) => candidate.id === '27b')!;
    model.files.reverse();

    expect(() => parseModelManifestV2(value)).toThrow(/out of order/);
  });

  it('rejects an unpinned repository when a shard has no explicit URL', () => {
    const manifest = parseModelManifestV2(rawManifest());
    manifest.repository.revision = null;

    expect(() => orderedShardUrls(manifest, findManifestModel(manifest, '1_7b'))).toThrow(
      /repository\.revision is required/,
    );
  });
});