kotoba 0.1.3

GP2-based Graph Rewriting Language - ISO GQL-compliant queries, MVCC+Merkle persistence, and distributed execution
Documentation
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
{
  // Kotobaライブラリ設定 - 実行可能なコンポーネント定義
  // dag.jsonnetのプロセスネットワークを実際に実行可能な形で構成

  // ==========================================
  // ライブラリ設定
  // ==========================================

  library: {
    name: 'kotoba',
    version: '0.1.0',
    description: 'GP2系グラフ書換え言語 - ISO GQL準拠クエリ、MVCC+Merkle永続、分散実行まで一貫させたグラフ処理システム',
    authors: ['jun784'],
    license: 'MIT',
    repository: 'https://github.com/jun784/kotoba',
    keywords: ['graph', 'database', 'query', 'rewrite', 'gql', 'gp2'],
  },

  // ==========================================
  // 実行可能コンポーネント定義
  // ==========================================

  executables: {
    // メインCLIツール
    'kotoba-cli': {
      name: 'kotoba-cli',
      description: 'Kotobaコマンドラインインターフェース',
      source: 'src/main.rs',
      dependencies: ['kotoba-lib'],
      features: ['cli', 'serde', 'tokio'],
    },

    // テスト実行可能ファイル
    'kotoba-test': {
      name: 'kotoba-test',
      description: 'Kotoba統合テスト実行ツール',
      source: 'src/bin/test.rs',
      dependencies: ['kotoba-lib'],
      features: ['test', 'serde', 'tokio'],
    },

    // ベンチマークツール
    'kotoba-bench': {
      name: 'kotoba-bench',
      description: 'Kotobaベンチマーク実行ツール',
      source: 'src/bin/bench.rs',
      dependencies: ['kotoba-lib'],
      features: ['bench', 'serde', 'tokio', 'criterion'],
    },
  },

  // ==========================================
  // ライブラリコンポーネント定義
  // ==========================================

  components: {
    // コアライブラリ
    'kotoba-core': {
      name: 'kotoba-core',
      description: 'Kotobaコアライブラリ',
      source: 'src/lib.rs',
      type: 'rlib',
      features: {
        default: ['types', 'ir', 'graph'],
        full: ['types', 'ir', 'graph', 'storage', 'execution', 'planner', 'rewrite'],
        types: [],
        ir: ['types'],
        graph: ['types', 'ir'],
        storage: ['types', 'graph'],
        execution: ['types', 'ir', 'graph', 'storage'],
        planner: ['types', 'ir', 'graph'],
        rewrite: ['types', 'ir', 'graph', 'storage'],
      },
    },

    // プラグインシステム
    'kotoba-plugins': {
      name: 'kotoba-plugins',
      description: 'Kotobaプラグインシステム',
      source: 'src/plugins/mod.rs',
      type: 'rlib',
      dependencies: ['kotoba-core'],
      features: ['plugin-loader'],
    },

    // FFIバインディング
    'kotoba-ffi': {
      name: 'kotoba-ffi',
      description: 'Kotoba FFIバインディング',
      source: 'src/ffi/mod.rs',
      type: 'cdylib',
      dependencies: ['kotoba-core'],
      features: ['ffi'],
    },

    // WASMバインディング
    'kotoba-wasm': {
      name: 'kotoba-wasm',
      description: 'Kotoba WebAssemblyバインディング',
      source: 'src/wasm/mod.rs',
      type: 'cdylib',
      dependencies: ['kotoba-core'],
      features: ['wasm'],
      target: 'wasm32-unknown-unknown',
    },
  },

  // ==========================================
  // 依存関係設定
  // ==========================================

  dependencies: {
    // ランタイム依存
    runtime: {
      'serde': { version: '1.0', features: ['derive'] },
      'serde_json': '1.0',
      'uuid': { version: '1.0', features: ['v4', 'serde'] },
      'sha2': '0.10',
      'thiserror': '2.0',
      'tokio': { version: '1.0', features: ['full'] },
      'parking_lot': '0.12',
      'dashmap': '6.0',
      'anyhow': '1.0',
      'log': '0.4',
      'env_logger': '0.11',
    },

    // 開発時依存
    dev: {
      'criterion': { version: '0.5', features: ['html_reports'] },
      'proptest': '1.0',
      'quickcheck': '1.0',
      'rand': '0.8',
    },

    // ビルド時依存
    build: {
      'cc': '1.0',
      'bindgen': '0.69',
    },

    // ドキュメント生成依存
    docs: {
      'rustdoc': 'nightly',
    },
  },

  // ==========================================
  // ビルド設定
  // ==========================================

  build: {
    // Rust設定
    rust: {
      edition: '2021',
      version: '>=1.70.0',
    },

    // ターゲット設定
    targets: [
      'x86_64-unknown-linux-gnu',
      'x86_64-apple-darwin',
      'x86_64-pc-windows-msvc',
      'aarch64-apple-darwin',
      'wasm32-unknown-unknown',
    ],

    // 最適化設定
    optimization: {
      release: {
        opt_level: 3,
        debug: false,
        lto: true,
        codegen_units: 1,
        panic: 'abort',
      },
      debug: {
        opt_level: 0,
        debug: true,
        overflow_checks: true,
      },
    },

    // リンカー設定
    linker: {
      rpath: true,
      strip: true,
    },
  },

  // ==========================================
  // テスト設定
  // ==========================================

  tests: {
    // ユニットテスト
    unit: {
      pattern: 'src/**/*.rs',
      exclude: ['src/bin/**', 'src/main.rs'],
      features: ['test'],
    },

    // 統合テスト
    integration: {
      pattern: 'tests/**/*.rs',
      features: ['test', 'integration'],
    },

    // ベンチマーク
    benchmarks: {
      pattern: 'benches/**/*.rs',
      features: ['bench'],
    },

    // ドクトest
    doctest: {
      enabled: true,
      features: ['doc'],
    },
  },

  // ==========================================
  // パッケージング設定
  // ==========================================

  packaging: {
    // Debianパッケージ
    debian: {
      name: 'kotoba',
      version: '0.1.0',
      architecture: 'amd64',
      description: 'GP2系グラフ書換え言語',
      maintainer: 'jun784 <jun784@example.com>',
      depends: ['libc6 (>= 2.15)'],
      files: {
        '/usr/bin/kotoba-cli': 'target/release/kotoba-cli',
        '/usr/lib/libkotoba.so': 'target/release/libkotoba.so',
        '/usr/share/doc/kotoba/': 'README.md LICENSE',
      },
    },

    // Dockerイメージ
    docker: {
      base_image: 'rust:1.70-slim',
      build_stages: [
        {
          name: 'build',
          commands: [
            'apt-get update',
            'apt-get install -y build-essential pkg-config',
            'cargo build --release',
          ],
        },
        {
          name: 'runtime',
          from: 'debian:stable-slim',
          commands: [
            'apt-get update',
            'apt-get install -y ca-certificates',
            'useradd -r -s /bin/false kotoba',
            'mkdir -p /var/lib/kotoba',
            'chown kotoba:kotoba /var/lib/kotoba',
          ],
        },
      ],
      exposed_ports: [8080, 8443],
      volumes: ['/var/lib/kotoba'],
      healthcheck: {
        test: ['CMD', 'curl', '-f', 'http://localhost:8080/health'],
        interval: '30s',
        timeout: '10s',
        retries: 3,
      },
    },

    // Homebrew Formula
    homebrew: {
      name: 'kotoba',
      desc: 'GP2系グラフ書換え言語',
      homepage: 'https://github.com/jun784/kotoba',
      url: 'https://github.com/jun784/kotoba/releases/download/v0.1.0/kotoba-0.1.0.tar.gz',
      sha256: 'PLACEHOLDER_SHA256',
      install: [
        'system "cargo", "install", "--root", prefix, "--path", "."',
        'bin.install "target/release/kotoba-cli"',
        'lib.install "target/release/libkotoba.dylib"',
      ],
      depends_on: [
        'rust' => ':build',
      ],
    },
  },

  // ==========================================
  // CI/CD設定
  // ==========================================

  ci: {
    // GitHub Actions
    github_actions: {
      workflows: {
        'ci.yml': {
          triggers: ['push', 'pull_request'],
          jobs: {
            test: {
              'runs-on': 'ubuntu-latest',
              steps: [
                { uses: 'actions/checkout@v3' },
                { uses: 'dtolnay/rust-toolchain@stable' },
                { run: 'cargo test' },
                { run: 'cargo test --doc' },
              ],
            },
            build: {
              'runs-on': 'ubuntu-latest',
              steps: [
                { uses: 'actions/checkout@v3' },
                { uses: 'dtolnay/rust-toolchain@stable' },
                { run: 'cargo build --release' },
                { run: 'cargo build --release --target wasm32-unknown-unknown' },
              ],
            },
            lint: {
              'runs-on': 'ubuntu-latest',
              steps: [
                { uses: 'actions/checkout@v3' },
                { uses: 'dtolnay/rust-toolchain@stable' },
                { run: 'cargo clippy -- -D warnings' },
                { run: 'cargo fmt --check' },
              ],
            },
          },
        },
        'release.yml': {
          triggers: [{ release: { types: ['published'] } }],
          jobs: {
            release: {
              'runs-on': 'ubuntu-latest',
              steps: [
                { uses: 'actions/checkout@v3' },
                { uses: 'dtolnay/rust-toolchain@stable' },
                { run: 'cargo build --release' },
                { uses: 'softprops/action-gh-release@v1', with: { files: 'target/release/kotoba-cli' } },
              ],
            },
          },
        },
      },
    },

    // GitLab CI
    gitlab_ci: {
      stages: ['test', 'build', 'deploy'],
      jobs: {
        test: {
          stage: 'test',
          image: 'rust:latest',
          script: ['cargo test', 'cargo test --doc'],
        },
        build: {
          stage: 'build',
          image: 'rust:latest',
          script: ['cargo build --release'],
          artifacts: {
            paths: ['target/release/kotoba-cli'],
            expire_in: '1 week',
          },
        },
        deploy: {
          stage: 'deploy',
          image: 'alpine:latest',
          script: ['echo "Deploying..."'],
          only: ['tags'],
        },
      },
    },
  },

  // ==========================================
  // ドキュメント設定
  // ==========================================

  documentation: {
    // Rustdoc設定
    rustdoc: {
      output_dir: 'target/doc',
      features: ['doc'],
      additional_args: [
        '--document-private-items',
        '--enable-index-page',
        '-Zunstable-options',
        '--generate-link-to-definition',
      ],
    },

    // MkDocs設定
    mkdocs: {
      site_name: 'Kotoba',
      site_description: 'GP2系グラフ書換え言語',
      site_author: 'jun784',
      site_url: 'https://kotoba.jun784.dev',
      theme: 'material',
      pages: [
        { Home: 'index.md' },
        { 'Getting Started': 'getting-started.md' },
        { API: 'api.md' },
        { Examples: 'examples.md' },
        { 'Contributing': 'contributing.md' },
      ],
      plugins: ['search', 'minify'],
    },
  },

  // ==========================================
  // ユーティリティ関数
  // ==========================================

  // 特定のターゲットの設定を取得
  get_target_config(target)::
    if std.objectHas(self.build.targets, target) then
      self.build.targets[target]
    else
      error 'Unsupported target: ' + target,

  // 特定のコンポーネントの設定を取得
  get_component_config(name)::
    if std.objectHas(self.components, name) then
      self.components[name]
    else
      error 'Component not found: ' + name,

  // 依存関係を解決
  resolve_dependencies(component, features)::
    local comp = self.get_component_config(component);
    local deps = if std.objectHas(comp, 'dependencies') then comp.dependencies else [];
    local resolved_features = if std.objectHas(comp.features, 'default') then
      comp.features.default
    else
      [];
    local all_features = std.set(features + resolved_features);
    {
      dependencies: deps,
      features: all_features,
    },

  // 設定の検証
  validate_config()::
    local components = std.objectValues(self.components);
    local executables = std.objectValues(self.executables);
    local all_names = [c.name for c in components] + [e.name for e in executables];
    local unique_names = std.set(all_names);
    if std.length(all_names) != std.length(unique_names) then
      error 'Duplicate component/executable names found'
    else
      'Configuration is valid',
}