hawdb 0.41.0

An embedded Rust graph database for local data-plane workloads
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
name: Native Bindings

on:
  schedule:
    # Daily default-branch qualification at 02:17 Asia/Singapore.
    - cron: "17 18 * * *"
  workflow_dispatch:
    inputs:
      windows_abandonment_qualification:
        description: "Run only the complete Windows abandonment GC power-loss qualification"
        type: boolean
        default: false
      boundary_comparison:
        description: "Run the manual Linux ordinary-boundary comparison instead of binding tests"
        type: boolean
        default: false
      benchmark_sizes:
        description: "Comma-separated row counts; default is the complete three-size matrix"
        type: string
        default: "1000,100000,1000000"
      benchmark_cases:
        description: "Comma-separated workload cases"
        type: string
        default: "select,point,fill,fill_bulk,wide"
      benchmark_samples:
        description: "Measured iterations, in addition to one discarded iteration"
        type: string
        default: "3"
      benchmark_layers:
        description: "Comma-separated language layers; select a shard without changing its workload"
        type: string
        default: "rust,python,go"
      benchmark_backends:
        description: "Comma-separated storage backends"
        type: string
        default: "memory,file"
      rabitq_baseline:
        description: "Run the manual RaBitQ baseline instead of binding checks"
        type: boolean
        default: false
      canonical_vector_lifecycle:
        description: "Run only the fixed 100k canonical DiskANN CRUD/MVCC matrix"
        type: boolean
        default: false
      windows_power_loss_test_threads:
        description: "Parallel Windows GC fault groups (repository uses its variable or 4)"
        type: choice
        default: "repository"
        options: ["repository", "1", "2", "4", "8"]
  pull_request:
    paths:
      - "src/**"
      - "crates/**"
      - "Cargo.toml"
      - "Cargo.lock"
      - "rust-toolchain.toml"
      - "scripts/cargo-test-required.sh"
      - "scripts/run-windows-native-bazel.sh"
      - "scripts/run-windows-native-bazel.test.sh"
      - "scripts/vector_recovery_cases.py"
      - "scripts/automatic_checkpoint_cases.py"
      - "scripts/branch-power-loss-shard.py"
      - "scripts/branch-power-loss-shard.test.py"
      - "scripts/check-windows-native-features.py"
      - "windows_native_features.bzl"
      - ".github/actions/windows-bazel/**"
      - "tests/in_memory_portable.rs"
      - "tests/branch_project_open.rs"
      - "bindings/ffi/**"
      - "bindings/bun/**"
      - "bindings/go/**"
      - "bindings/moonbit/**"
      - "bindings/swift/**"
      - "Package.swift"
      - "MODULE.bazel"
      - "BUILD.bazel"
      - ".bazelrc"
      - ".cargo/**"
      - ".bazelversion"
      - ".github/workflows/native-bindings.yml"
  push:
    branches: [main]
    paths:
      - "src/**"
      - "crates/**"
      - "Cargo.toml"
      - "Cargo.lock"
      - "rust-toolchain.toml"
      - "scripts/cargo-test-required.sh"
      - "scripts/run-windows-native-bazel.sh"
      - "scripts/run-windows-native-bazel.test.sh"
      - "scripts/vector_recovery_cases.py"
      - "scripts/automatic_checkpoint_cases.py"
      - "scripts/branch-power-loss-shard.py"
      - "scripts/branch-power-loss-shard.test.py"
      - "scripts/check-windows-native-features.py"
      - "windows_native_features.bzl"
      - ".github/actions/windows-bazel/**"
      - "tests/in_memory_portable.rs"
      - "tests/branch_project_open.rs"
      - "bindings/ffi/**"
      - "bindings/bun/**"
      - "bindings/go/**"
      - "bindings/moonbit/**"
      - "bindings/swift/**"
      - "Package.swift"
      - "MODULE.bazel"
      - "BUILD.bazel"
      - ".bazelrc"
      - ".cargo/**"
      - ".bazelversion"
      - ".github/workflows/native-bindings.yml"

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-${{ inputs.windows_abandonment_qualification }}-${{ inputs.boundary_comparison }}-${{ inputs.benchmark_sizes }}-${{ inputs.benchmark_cases }}-${{ inputs.benchmark_layers }}-${{ inputs.benchmark_backends }}-${{ inputs.benchmark_samples }}-${{ inputs.canonical_vector_lifecycle }}
  cancel-in-progress: true

jobs:
  bazel:
    if: >-
      github.event_name != 'schedule' &&
      (github.event_name != 'workflow_dispatch' ||
       (!inputs.windows_abandonment_qualification && !inputs.boundary_comparison && !inputs.rabitq_baseline && !inputs.canonical_vector_lifecycle))
    name: Bazel native bindings (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-24.04, macos-latest]
        include:
          - os: ubuntu-24.04
            library: libhawdb_ffi.so
          - os: macos-latest
            library: libhawdb_ffi.dylib
    env:
      USE_BAZEL_VERSION: "9.3.1"
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install Bazel
        uses: bazel-contrib/setup-bazel@0.19.2
        with:
          bazelisk-cache: true
          disk-cache: ${{ github.workflow }}-${{ github.job }}
          repository-cache: true
          external-cache: true

      - name: Build the C ABI libraries and Go package
        run: |
          bazel build //bindings/ffi:hawdb_ffi //bindings/ffi:hawdb_ffi_static //bindings/go:hawdb
          # Later profile changes retarget the bazel-bin convenience symlink.
          library_path="$(bazel info bazel-bin)/bindings/ffi/${{ matrix.library }}"
          test -f "$library_path"
          printf 'HAWDB_LIBRARY=%s\n' "$library_path" >> "$GITHUB_ENV"

      - name: Test Go against the Bazel-built C ABI
        run: bazel test --test_output=errors --test_arg=-test.v //bindings/go:hawdb_go_tests

      - name: Install Swift on Linux
        if: runner.os == 'Linux'
        uses: swift-actions/setup-swift@v2
        with:
          swift-version: "6.0.3"

      - name: Test Swift against the Bazel-built C ABI
        run: |
          swift --version
          library_dir="$(dirname "$HAWDB_LIBRARY")"
          swift test -j 2 -Xswiftc -warnings-as-errors \
            -Xlinker -L -Xlinker "$library_dir" \
            -Xlinker -rpath -Xlinker "$library_dir"
          swift run --package-path bindings/swift/Tests/Consumer -j 2 \
            -Xswiftc -warnings-as-errors \
            -Xlinker -L -Xlinker "$library_dir" \
            -Xlinker -rpath -Xlinker "$library_dir"

      - name: Install Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: 1.4.3

      - name: Test Bun against the Bazel-built C ABI
        working-directory: bindings/bun
        run: |
          bun install --frozen-lockfile
          bun run typecheck
          bun test

      - name: Test original generation spool ownership
        run: >-
          bazel test --test_output=errors --test_arg=generation_spool
          //crates/search:hawdb_search_tests

      - name: Test consumer publication and reopen on Unix
        run: >-
          bazel test --test_output=errors
          //:hawdb_search_projection_consumer_tests
          //:hawdb_search_projection_consumer_minimal_tests

      - name: Test the retained C ABI contract
        run: bazel test --test_output=errors //bindings/ffi:hawdb_ffi_tests

      # Compiles the MoonBit adapter against the Bazel-built HawDB facade on
      # every engine change. It needs no MoonBit toolchain; the executable
      # conformance suite runs in the MoonBit Native SDK workflow.
      - name: Test the MoonBit native adapter
        run: bazel test --test_output=errors //bindings/moonbit/native:hawdb_moonbit_rust_tests

      - name: Test query observer under the repository release profile
        if: matrix.os == 'ubuntu-24.04'
        run: >-
          bazel test --config=release --test_output=errors
          //crates/executor:hawdb_query_observer_release_tests

      - name: Install Go for the race detector
        uses: actions/setup-go@v7
        with:
          go-version-file: bindings/go/go.mod
          cache-dependency-path: bindings/go/go.sum

      - name: Check retained read and close concurrency with the race detector
        working-directory: bindings/go
        env:
          # The race runtime needs cgo; the production package stays purego.
          CGO_ENABLED: "1"
        # The Go test cache does not qualify the newly built dynamic library.
        run: go test -race -count=1 -run '^TestRetained' ./...

  windows-bazel-contracts:
    if: >-
      github.event_name != 'schedule' &&
      (github.event_name != 'workflow_dispatch' ||
       (!inputs.windows_abandonment_qualification && !inputs.boundary_comparison && !inputs.rabitq_baseline && !inputs.canonical_vector_lifecycle))
    name: Windows Bazel (${{ matrix.shard }})
    runs-on: windows-2025
    timeout-minutes: 120
    strategy:
      fail-fast: false
      matrix:
        shard: [transactions, storage, search, consumers, identities, snapshots, bindings,
                consumers-recovery-births, consumers-recovery-unselected,
                consumers-recovery-selected, consumers-recovery-lost-sql-link,
                consumers-recovery-lost-sql-selector, consumers-recovery-lost-nodes-link,
                consumers-recovery-lost-nodes-selector, consumers-publication-artifacts,
                consumers-publication-selectors, consumers-publication-barriers]
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 2
      - name: Restore native Bazel toolchain and caches
        id: bazel
        uses: ./.github/actions/windows-bazel
        with:
          cache-scope: ${{ matrix.shard }}
      - name: Record exact native source and cache configuration
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p windows-native-results
          git log -1 --format='%H%n%T%n%P' > windows-native-results/source.txt
          rustc --version --verbose > windows-native-results/toolchain.txt
          bazel version > windows-native-results/bazel-version.txt
          bazel info > windows-native-results/bazel-info.txt
          python scripts/check-windows-native-features.py | tee windows-native-results/feature-inventory.txt
      - name: Run fresh native contract selections
        shell: bash
        run: bash scripts/run-windows-native-bazel.sh '${{ matrix.shard }}'
      - name: Preserve Windows shard evidence
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: windows-native-${{ matrix.shard }}-${{ github.sha }}-${{ github.run_attempt }}
          path: windows-native-results
          if-no-files-found: error
      - name: Save updated disk actions for this source
        if: always() && steps.bazel.outputs.disk-cache-key != '' && steps.bazel.outputs.disk-cache-hit != 'true'
        uses: actions/cache/save@v6
        with:
          path: D:/hawdb-bazel-disk
          key: ${{ steps.bazel.outputs.disk-cache-key }}

  windows-native-clippy:
    if: >-
      github.event_name != 'schedule' &&
      (github.event_name != 'workflow_dispatch' ||
       (!inputs.windows_abandonment_qualification && !inputs.boundary_comparison && !inputs.rabitq_baseline && !inputs.canonical_vector_lifecycle))
    name: Windows native Clippy
    runs-on: windows-2025
    timeout-minutes: 120
    env:
      CARGO_TARGET_DIR: D:/hawdb-clippy-target
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 2
      - name: Install Rust
        uses: dtolnay/rust-toolchain@1.99.1
        with:
          components: clippy
      - name: Restore native Clippy dependencies
        uses: actions/cache@v6
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            D:/hawdb-clippy-target
          key: Windows-${{ runner.arch }}-clippy-v1-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml', '.cargo/config.toml') }}-${{ github.sha }}
          restore-keys: |
            Windows-${{ runner.arch }}-clippy-v1-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml', '.cargo/config.toml') }}-
            Windows-${{ runner.arch }}-clippy-v1-
      - name: Validate native runner failure controls and feature inventory
        shell: bash
        run: |
          set -euo pipefail
          python scripts/check-windows-native-features.py
          bash scripts/run-windows-native-bazel.test.sh
          python scripts/branch-power-loss-shard.test.py
      - name: Run unchanged strict native Windows Clippy
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p windows-native-results
          git log -1 --format='%H%n%T%n%P' > windows-native-results/source.txt
          rustc --version --verbose > windows-native-results/toolchain.txt
          cargo clippy --locked --workspace --all-targets --all-features -- -D warnings \
            2>&1 | tee windows-native-results/clippy.txt
      - name: Preserve native Clippy evidence
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: windows-native-clippy-${{ github.sha }}-${{ github.run_attempt }}
          path: windows-native-results
          if-no-files-found: error

  windows-native-contracts:
    if: >-
      always() && github.event_name != 'schedule' &&
      (github.event_name != 'workflow_dispatch' ||
       (!inputs.windows_abandonment_qualification && !inputs.boundary_comparison && !inputs.rabitq_baseline && !inputs.canonical_vector_lifecycle))
    name: Windows native contracts
    runs-on: ubuntu-24.04
    needs: [windows-bazel-contracts, windows-native-clippy]
    steps:
      - name: Require every Windows shard and native lint
        env:
          CONTRACTS_RESULT: ${{ needs.windows-bazel-contracts.result }}
          CLIPPY_RESULT: ${{ needs.windows-native-clippy.result }}
        run: |
          test "$CONTRACTS_RESULT" = success
          test "$CLIPPY_RESULT" = success

  windows-abandonment-qualification:
    if: >-
      github.event_name == 'schedule' ||
      (github.event_name == 'workflow_dispatch' && inputs.windows_abandonment_qualification)
    name: Windows abandonment GC power-loss qualification
    runs-on: windows-2025
    timeout-minutes: 120
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 2

      - name: Restore native Bazel toolchain and caches
        id: bazel
        uses: ./.github/actions/windows-bazel
        with:
          cache-scope: abandonment

      - name: Record tested source and toolchain
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p windows-abandonment-results
          git log -1 --format='%H%n%T%n%P' > windows-abandonment-results/source.txt
          rustc --version --verbose > windows-abandonment-results/toolchain.txt
          bazel version > windows-abandonment-results/bazel-version.txt
          python scripts/check-windows-native-features.py > windows-abandonment-results/feature-inventory.txt

      - name: Test abandonment GC power-loss cuts
        shell: bash
        env:
          POWER_LOSS_TEST_THREADS: ${{ inputs.windows_power_loss_test_threads != 'repository' && inputs.windows_power_loss_test_threads || vars.HAWDB_WINDOWS_POWER_LOSS_TEST_THREADS || '4' }}
        run: |
          set -euo pipefail
          case "$POWER_LOSS_TEST_THREADS" in
            1|2|4|8) ;;
            *) echo "Windows power-loss test threads must be 1, 2, 4, or 8" >&2; exit 1 ;;
          esac
          echo "power_loss_test_threads=$POWER_LOSS_TEST_THREADS" \
            | tee windows-abandonment-results/abandonment-config.txt
          WINDOWS_NATIVE_RESULTS=windows-abandonment-results \
            bash scripts/run-windows-native-bazel.sh abandonment

      - name: Preserve Windows abandonment qualification evidence
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: windows-abandonment-gc-${{ github.sha }}-${{ github.run_attempt }}
          path: windows-abandonment-results
          if-no-files-found: error

      - name: Save updated abandonment disk actions
        if: always() && steps.bazel.outputs.disk-cache-key != '' && steps.bazel.outputs.disk-cache-hit != 'true'
        uses: actions/cache/save@v6
        with:
          path: D:/hawdb-bazel-disk
          key: ${{ steps.bazel.outputs.disk-cache-key }}

  boundary-comparison:
    if: github.event_name == 'workflow_dispatch' && !inputs.windows_abandonment_qualification && !inputs.canonical_vector_lifecycle && inputs.boundary_comparison
    name: Manual ordinary-boundary comparison (Linux)
    runs-on: ubuntu-24.04
    timeout-minutes: 360
    env:
      USE_BAZEL_VERSION: "9.3.1"
      BENCHMARK_SIZES: ${{ inputs.benchmark_sizes }}
      BENCHMARK_CASES: ${{ inputs.benchmark_cases }}
      BENCHMARK_SAMPLES: ${{ inputs.benchmark_samples }}
      BENCHMARK_LAYERS: ${{ inputs.benchmark_layers }}
      BENCHMARK_BACKENDS: ${{ inputs.benchmark_backends }}
    steps:
      - name: Checkout the candidate
        uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Install Bazel
        uses: bazel-contrib/setup-bazel@0.19.2
        with:
          bazelisk-cache: true
          disk-cache: ${{ github.workflow }}-${{ github.job }}
          repository-cache: true
          external-cache: true

      - name: Install Go for provenance
        uses: actions/setup-go@v7
        with:
          go-version-file: bindings/go/go.mod
          cache-dependency-path: bindings/go/go.sum

      - name: Compare frozen ordinary producers with unchanged defaults
        run: |
          python3 -B bindings/benchmarks/compare.py \
            --output "$RUNNER_TEMP/hawdb-boundary-comparison" \
            --sizes "$BENCHMARK_SIZES" --cases "$BENCHMARK_CASES" \
            --layers "$BENCHMARK_LAYERS" --backends "$BENCHMARK_BACKENDS" \
            --samples "$BENCHMARK_SAMPLES"

      - name: Preserve complete or partial evidence, including failed outcomes
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: ordinary-boundary-comparison-${{ github.sha }}
          path: ${{ runner.temp }}/hawdb-boundary-comparison/evidence
          if-no-files-found: error

  rabitq-baseline:
    if: github.event_name == 'workflow_dispatch' && !inputs.windows_abandonment_qualification && !inputs.canonical_vector_lifecycle && inputs.rabitq_baseline
    name: Manual RaBitQ baseline (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    timeout-minutes: 90
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-24.04
            architecture: x86_64
          - os: macos-latest
            architecture: arm64
    env:
      HAWDB_RABITQ_BENCH_BUILD: "1"
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@1.99.1
        with:
          components: clippy

      - name: Record native environment
        shell: bash
        run: |
          set -euo pipefail
          test "$(uname -m)" = "${{ matrix.architecture }}"
          mkdir -p "$RUNNER_TEMP/rabitq-baseline"
          git log -1 --format='%H%n%T%n%P' > "$RUNNER_TEMP/rabitq-baseline/source.txt"
          rustc --version --verbose > "$RUNNER_TEMP/rabitq-baseline/toolchain.txt"
          uname -a > "$RUNNER_TEMP/rabitq-baseline/system.txt"
          df -h "$RUNNER_TEMP" >> "$RUNNER_TEMP/rabitq-baseline/system.txt"
          if [ "$(uname -s)" = "Darwin" ]; then
            for key in machdep.cpu.brand_string hw.logicalcpu hw.physicalcpu hw.memsize hw.l1dcachesize hw.l2cachesize hw.l3cachesize; do
              sysctl "$key" >> "$RUNNER_TEMP/rabitq-baseline/cpu.txt" 2>&1 || true
            done
          else
            lscpu > "$RUNNER_TEMP/rabitq-baseline/cpu.txt"
            cat /proc/meminfo >> "$RUNNER_TEMP/rabitq-baseline/system.txt"
          fi

      - name: Check the native benchmark code
        run: cargo clippy --locked -p hawdb-vector-projection --all-targets --features storage-io -- -D warnings

      - name: Record the complete scalar matrix
        shell: bash
        env:
          HAWDB_RABITQ_BENCH_ARTIFACTS: ${{ runner.temp }}/rabitq-baseline/artifacts
          HAWDB_RABITQ_BENCH_OUTPUT: ${{ runner.temp }}/rabitq-baseline/samples.jsonl
        run: |
          set -euo pipefail
          cargo test --locked --release -p hawdb-vector-projection --features storage-io \
            kernel::benchmark::candidate_scan_matrix -- --exact --ignored --nocapture --test-threads=1 \
            2>&1 | tee "$RUNNER_TEMP/rabitq-baseline/run.log"
          python3 scripts/summarize-rabitq-baseline.py \
            "$HAWDB_RABITQ_BENCH_OUTPUT" "$RUNNER_TEMP/rabitq-baseline/audit.json"

      - name: Preserve raw measurements and checksummed artifacts
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: rabitq-baseline-${{ matrix.os }}-${{ github.sha }}
          path: ${{ runner.temp }}/rabitq-baseline
          if-no-files-found: error
          compression-level: 0
          retention-days: 14

  canonical-vector-lifecycle:
    if: github.event_name == 'workflow_dispatch' && !inputs.windows_abandonment_qualification && inputs.canonical_vector_lifecycle
    name: Manual canonical vector lifecycle (Linux, ${{ matrix.mode }}, rate${{ matrix.rate }})
    runs-on: ubuntu-24.04
    timeout-minutes: 180
    strategy:
      fail-fast: false
      matrix:
        mode: [plain, lsg]
        rate: [10, 100]
    env:
      CARGO_TARGET_DIR: target/canonical-vector-lifecycle
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@1.99.1

      - name: Record exact source and compile with the repository profile
        shell: bash
        run: |
          set -euo pipefail
          evidence="$RUNNER_TEMP/canonical-vector-lifecycle"
          mkdir -p "$evidence"
          git log -1 --format='%H%n%T%n%P' > "$evidence/source.txt"
          rustc --version --verbose > "$evidence/toolchain.txt"
          cp .cargo/config.toml "$evidence/cargo-config.toml"
          lscpu > "$evidence/cpu.txt"
          cat /proc/meminfo > "$evidence/memory.txt"
          /usr/bin/time -v -o "$evidence/compilation.time.txt" \
            cargo build --locked --all-features --example filtered_diskann_qualification \
            > "$evidence/compilation.log" 2>&1
          sha256sum "$CARGO_TARGET_DIR/debug/examples/filtered_diskann_qualification" \
            > "$evidence/binary.sha256"

      - name: Qualify the complete canonical lifecycle
        shell: bash
        run: |
          set -euo pipefail
          evidence="$RUNNER_TEMP/canonical-vector-lifecycle"
          mode="${{ matrix.mode }}"
          rate="${{ matrix.rate }}"
          status=0
          name="canonical-100000-128-$mode-rate$rate"
          if /usr/bin/time -v -o "$evidence/$name.time.txt" \
            "$CARGO_TARGET_DIR/debug/examples/filtered_diskann_qualification" canonical \
            "$RUNNER_TEMP/$name" 100000 128 320 "$mode" "$rate" 16 \
            > "$evidence/$name.jsonl" 2> "$evidence/$name.stderr.txt"; then
            printf '%s PASS\n' "$name" | tee -a "$evidence/status.txt"
          else
            printf '%s FAIL\n' "$name" | tee -a "$evidence/status.txt"
            status=1
          fi
          exit "$status"

      - name: Preserve complete or partial source-bound measurements
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: canonical-vector-lifecycle-${{ github.sha }}-${{ matrix.mode }}-rate${{ matrix.rate }}
          path: ${{ runner.temp }}/canonical-vector-lifecycle
          if-no-files-found: error
          retention-days: 14