deciduous 1.0.2

Decision graph tooling for AI-assisted development. Track every goal, decision, and outcome. Survive context loss. Query your reasoning.
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
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      tag:
        description: 'Git tag or ref to validate (use a version tag when publishing)'
        required: true
        type: string
      publish:
        description: 'Publish the validated version tag to GitHub and crates.io'
        required: false
        default: false
        type: boolean

permissions:
  contents: read

jobs:
  validate-ref:
    name: Validate and pin the requested revision
    runs-on: ubuntu-latest
    outputs:
      ref: ${{ steps.revision.outputs.ref }}
      tag: ${{ steps.revision.outputs.tag }}
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ inputs.tag || github.ref }}
          fetch-depth: 0
          persist-credentials: false
      - name: Require an existing version tag for publishing
        id: revision
        env:
          REQUESTED_REF: ${{ inputs.tag || github.ref }}
          PUBLISH_REQUESTED: ${{ github.event_name == 'push' || inputs.publish == true }}
        run: |
          revision=$(git rev-parse HEAD)
          tag=
          if [ "$PUBLISH_REQUESTED" = true ]; then
            tag="${REQUESTED_REF#refs/tags/}"
            if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
              echo 'Publishing requires an existing vMAJOR.MINOR.PATCH version tag.' >&2
              exit 1
            fi
            if ! revision=$(git rev-parse --verify "refs/tags/${tag}^{commit}"); then
              echo "Publishing tag does not exist: $tag" >&2
              exit 1
            fi
          fi
          # Every build and test uses the same commit, even if a branch moves
          # or a branch and tag happen to have the same name.
          printf 'ref=%s\ntag=%s\n' "$revision" "$tag" >> "$GITHUB_OUTPUT"
      - name: Require both package versions to match the publishing tag
        if: github.event_name == 'push' || inputs.publish == true
        env:
          PINNED_REVISION: ${{ steps.revision.outputs.ref }}
          RELEASE_TAG: ${{ steps.revision.outputs.tag }}
        run: |
          python3 - <<'PY'
          import os
          import re
          import subprocess
          import sys
          import tomllib

          revision = os.environ["PINNED_REVISION"]
          tag = os.environ["RELEASE_TAG"]
          expected = tag.removeprefix("v")

          def read_manifest(path):
              return subprocess.check_output(
                  ["git", "show", f"{revision}:{path}"], text=True
              )

          try:
              cargo_version = tomllib.loads(read_manifest("Cargo.toml"))["package"]["version"]
              server_match = re.search(
                  r'(?m)^\s*version:\s*"([^"]+)"',
                  read_manifest("deciduous_mcp/mix.exs"),
              )
              if server_match is None:
                  raise ValueError("deciduous_mcp/mix.exs must declare a literal project version")
              versions = {
                  "Cargo.toml": cargo_version,
                  "deciduous_mcp/mix.exs": server_match.group(1),
              }
          except (KeyError, ValueError, subprocess.CalledProcessError) as error:
              sys.exit(f"Cannot verify package versions for {tag}: {error}")

          mismatches = [
              f"{path} declares {actual}; publishing tag {tag} requires {expected}"
              for path, actual in versions.items()
              if actual != expected
          ]
          if mismatches:
              sys.exit("Release version mismatch:\n" + "\n".join(mismatches))
          print(f"Both package versions match {tag} at {revision}")
          PY

  acceptance:
    needs: [validate-ref]
    uses: ./.github/workflows/release-acceptance.yml
    with:
      ref: ${{ needs.validate-ref.outputs.ref }}

  build:
    needs: [validate-ref]
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            name: linux-amd64
          - os: ubuntu-latest
            target: aarch64-unknown-linux-musl
            name: linux-arm64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            name: windows-amd64
            ext: .exe
          - os: macos-latest
            target: x86_64-apple-darwin
            name: darwin-amd64
          - os: macos-latest
            target: aarch64-apple-darwin
            name: darwin-arm64

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.validate-ref.outputs.ref }}

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install musl-tools (Linux x86_64)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: sudo apt-get update && sudo apt-get install -y musl-tools

      - name: Install cross-compilation tools (Linux ARM64)
        if: matrix.target == 'aarch64-unknown-linux-musl'
        run: |
          sudo apt-get update
          sudo apt-get install -y musl-tools
          # Install cross for ARM64 cross-compilation
          cargo install cross --git https://github.com/cross-rs/cross

      - name: Build (Linux x86_64)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: cargo build --release --target ${{ matrix.target }}

      - name: Build (Linux ARM64 with cross)
        if: matrix.target == 'aarch64-unknown-linux-musl'
        run: cross build --release --target ${{ matrix.target }}

      - name: Build (macOS/Windows)
        if: matrix.os != 'ubuntu-latest'
        run: cargo build --release --target ${{ matrix.target }}

      - name: Rename binary
        shell: bash
        run: |
          if [ "${{ matrix.os }}" = "windows-latest" ]; then
            cp target/${{ matrix.target }}/release/deciduous.exe deciduous-${{ matrix.name }}.exe
          else
            cp target/${{ matrix.target }}/release/deciduous deciduous-${{ matrix.name }}
          fi

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: deciduous-${{ matrix.name }}
          path: deciduous-${{ matrix.name }}${{ matrix.ext }}

  build-mcp-server:
    name: Build self-contained MCP server (${{ matrix.name }})
    needs: [validate-ref]
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: macos-latest
            name: darwin-arm64
            burrito_target: darwin_arm64
          - os: macos-latest
            name: darwin-amd64
            burrito_target: darwin_amd64
          - os: ubuntu-latest
            name: linux-arm64
            burrito_target: linux_arm64
          - os: ubuntu-latest
            name: linux-amd64
            burrito_target: linux_amd64
          - os: ubuntu-latest
            name: windows-amd64
            burrito_target: windows_amd64
            ext: .exe

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.validate-ref.outputs.ref }}

      - name: Install Erlang and Elixir for the build
        uses: erlef/setup-beam@v1
        with:
          otp-version: '28.3.3'
          elixir-version: '1.18.4'
          version-type: strict

      - name: Install Burrito build tools (Linux)
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y xz-utils p7zip-full

      - name: Install Burrito build tools (macOS)
        if: runner.os == 'macOS'
        run: brew install xz

      - name: Install Zig
        uses: mlugg/setup-zig@v2
        with:
          version: '0.16.0'
          cache-key: ${{ matrix.burrito_target }}

      - name: Build Burrito executable
        working-directory: deciduous_mcp
        env:
          MIX_ENV: prod
          BURRITO_TARGET: ${{ matrix.burrito_target }}
        run: |
          mix local.hex --force
          mix local.rebar --force
          mix deps.get --only prod
          mix hex.audit
          mix release deciduous_mcp --overwrite

      - name: Name release artifact
        shell: bash
        run: |
          cp "deciduous_mcp/burrito_out/deciduous_mcp_${{ matrix.burrito_target }}${{ matrix.ext }}" \
            "deciduous-mcp-${{ matrix.name }}${{ matrix.ext }}"

      - name: Upload self-contained MCP server
        uses: actions/upload-artifact@v4
        with:
          name: deciduous-mcp-${{ matrix.name }}
          path: deciduous-mcp-${{ matrix.name }}${{ matrix.ext }}
          if-no-files-found: error

  verify-mcp-binaries:
    name: Verify MCP executable (${{ matrix.name }})
    needs: [build-mcp-server, validate-ref]
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-24.04
            name: linux-amd64
          - os: ubuntu-24.04-arm
            name: linux-arm64
          - os: macos-15
            name: darwin-arm64
          - os: macos-15-intel
            name: darwin-amd64
          - os: windows-2025
            name: windows-amd64
            ext: .exe
    runs-on: ${{ matrix.os }}
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.validate-ref.outputs.ref }}
      - uses: actions/download-artifact@v4
        with:
          name: deciduous-mcp-${{ matrix.name }}
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - name: Boot embedded runtime without host Erlang or Elixir
        shell: bash
        run: |
          chmod +x "deciduous-mcp-${{ matrix.name }}${{ matrix.ext }}"
          python deciduous_mcp/test/release/native_smoke.py \
            "./deciduous-mcp-${{ matrix.name }}${{ matrix.ext }}"

  release:
    if: github.event_name == 'push' || inputs.publish == true
    needs: [build, verify-mcp-binaries, acceptance, validate-ref]
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.validate-ref.outputs.ref }}

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Display structure of downloaded files
        run: ls -la artifacts/*/

      - name: Stage Postgres bootstrap schema
        run: |
          mkdir -p artifacts/deciduous-mcp-structure
          cp deciduous_mcp/STRUCTURE.sql \
            artifacts/deciduous-mcp-structure/deciduous-mcp-structure.sql

      - name: Package Docker setup
        run: |
          mkdir -p artifacts/deciduous-mcp-docker
          bash deciduous_mcp/scripts/package-docker.sh \
            artifacts/deciduous-mcp-docker/deciduous-mcp-docker.tar.gz

      - name: Create checksums
        run: |
          : > checksums.txt
          for dir in artifacts/*/; do
            (cd "$dir" && sha256sum *) >> checksums.txt
          done
          sort -o checksums.txt checksums.txt
          cat checksums.txt

      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ needs.validate-ref.outputs.tag }}
          files: |
            artifacts/deciduous-linux-amd64/deciduous-linux-amd64
            artifacts/deciduous-linux-arm64/deciduous-linux-arm64
            artifacts/deciduous-darwin-amd64/deciduous-darwin-amd64
            artifacts/deciduous-darwin-arm64/deciduous-darwin-arm64
            artifacts/deciduous-windows-amd64/deciduous-windows-amd64.exe
            artifacts/deciduous-mcp-linux-amd64/deciduous-mcp-linux-amd64
            artifacts/deciduous-mcp-linux-arm64/deciduous-mcp-linux-arm64
            artifacts/deciduous-mcp-darwin-amd64/deciduous-mcp-darwin-amd64
            artifacts/deciduous-mcp-darwin-arm64/deciduous-mcp-darwin-arm64
            artifacts/deciduous-mcp-windows-amd64/deciduous-mcp-windows-amd64.exe
            artifacts/deciduous-mcp-structure/deciduous-mcp-structure.sql
            artifacts/deciduous-mcp-docker/deciduous-mcp-docker.tar.gz
            checksums.txt
          fail_on_unmatched_files: true
          generate_release_notes: true

  publish-crate:
    if: github.event_name == 'push' || inputs.publish == true
    needs: [build, verify-mcp-binaries, acceptance, validate-ref]
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.validate-ref.outputs.ref }}

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

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --no-verify

  # Homebrew formula update, folded INTO the release run (needs: release) rather
  # than a separate `on: release` workflow. Two reasons that matters:
  #  - A release created by GITHUB_TOKEN (the `release` job's action) does NOT
  #    trigger `on: release` workflows, so the old standalone update-homebrew.yml
  #    never fired for automated releases (0.15.0, 0.16.0 got no run at all).
  #  - Running after `release` guarantees checksums.txt is attached, so the
  #    download can't race the publish (which is what failed for 0.13.x/0.14.0).
  update-homebrew:
    needs: [release, validate-ref]
    runs-on: ubuntu-latest
    steps:
      - name: Resolve version + tag
        id: rel
        env:
          RELEASE_TAG: ${{ needs.validate-ref.outputs.tag }}
        run: |
          printf 'tag=%s\nversion=%s\n' "$RELEASE_TAG" "${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"

      - name: Download checksums
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release download "${{ steps.rel.outputs.tag }}" \
            --repo "${{ github.repository }}" --pattern "checksums.txt"
          cat checksums.txt

      - name: Parse checksums
        id: sums
        run: |
          for p in darwin-arm64 darwin-amd64 linux-arm64 linux-amd64; do
            key=$(echo "$p" | tr '-' '_')
            # The release also ships `deciduous-mcp-$p`; select the CLI asset
            # exactly so its checksum does not become a multi-line value.
            sum=$(awk -v asset="deciduous-${p}" '$2 == asset {print $1}' checksums.txt)
            test "${#sum}" -eq 64
            echo "${key}=${sum}" >> $GITHUB_OUTPUT
          done

      - name: Generate formula
        env:
          VERSION: ${{ steps.rel.outputs.version }}
          SHA_DARWIN_ARM64: ${{ steps.sums.outputs.darwin_arm64 }}
          SHA_DARWIN_AMD64: ${{ steps.sums.outputs.darwin_amd64 }}
          SHA_LINUX_ARM64: ${{ steps.sums.outputs.linux_arm64 }}
          SHA_LINUX_AMD64: ${{ steps.sums.outputs.linux_amd64 }}
        run: |
          cat > deciduous.rb << FORMULA
          class Deciduous < Formula
            desc "Decision graph tooling for AI-assisted development"
            homepage "https://notactuallytreyanastasio.github.io/deciduous/"
            version "${VERSION}"
            license "Apache-2.0"

            on_macos do
              on_arm do
                url "https://github.com/notactuallytreyanastasio/deciduous/releases/download/v#{version}/deciduous-darwin-arm64"
                sha256 "${SHA_DARWIN_ARM64}"
              end
              on_intel do
                url "https://github.com/notactuallytreyanastasio/deciduous/releases/download/v#{version}/deciduous-darwin-amd64"
                sha256 "${SHA_DARWIN_AMD64}"
              end
            end

            on_linux do
              on_arm do
                url "https://github.com/notactuallytreyanastasio/deciduous/releases/download/v#{version}/deciduous-linux-arm64"
                sha256 "${SHA_LINUX_ARM64}"
              end
              on_intel do
                url "https://github.com/notactuallytreyanastasio/deciduous/releases/download/v#{version}/deciduous-linux-amd64"
                sha256 "${SHA_LINUX_AMD64}"
              end
            end

            def install
              binary_name = Dir["deciduous-*"].first
              bin.install binary_name => "deciduous"
            end

            test do
              assert_match version.to_s, shell_output("#{bin}/deciduous --version")
            end
          end
          FORMULA
          cat deciduous.rb

      - name: Push formula to tap
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}" > ~/.ssh/deploy_key
          chmod 600 ~/.ssh/deploy_key
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no"
          git clone git@github.com:notactuallytreyanastasio/homebrew-tap.git tap
          cp deciduous.rb tap/Formula/deciduous.rb
          cd tap
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git config user.name "github-actions[bot]"
          git add Formula/deciduous.rb
          git diff --cached --quiet || git commit -m "deciduous ${{ steps.rel.outputs.version }}"
          git push