Skip to content

inject x-defang-llm on model services, convert fixup snapshots to YAML#2152

Merged
lionello merged 3 commits into
mainfrom
jordan/x-defang-llm-model-runner
Jun 24, 2026
Merged

inject x-defang-llm on model services, convert fixup snapshots to YAML#2152
lionello merged 3 commits into
mainfrom
jordan/x-defang-llm-model-runner

Conversation

@jordanstephens

@jordanstephens jordanstephens commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sets x-defang-llm: true on services derived from the compose models: top-level block (in addition to the existing x-defang-llm extension path)
  • Converts TestFixup snapshots from JSON to YAML so that compose extensions (x-defang-llm, etc.) are visible in snapshots — compose-go tags Extensions as json:"-", making all extension changes invisible to the previous JSON-based snapshots

Blocks DefangLabs/samples#647

Test plan

  • TestFixup passes and the regenerated snapshots show x-defang-llm: true on model services
  • Verify x-defang-llm appears correctly on services generated from models: entries in a real compose file

Summary by CodeRabbit

  • New Features

    • Compose fixup output now uses YAML across fixtures and comparisons, matching the expected compose format more closely.
    • Services generated from model-based configurations now include the appropriate x-defang-llm metadata.
  • Bug Fixes

    • Removed unnecessary null fields from generated compose output, producing cleaner and more consistent results.
    • Preserved service settings such as images, builds, ports, networks, and environment values while improving output formatting.

jordanstephens and others added 3 commits June 24, 2026 11:23
Switches TestFixup from json.MarshalIndent to yaml.Marshal so that
compose extensions (x-defang-llm, etc.) are included in snapshots —
extensions have json:"-" in compose-go's types and were invisible to the
JSON-based snapshots.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordanstephens jordanstephens requested a review from lionello as a code owner June 24, 2026 18:45
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Compose fixup generation now serializes fixtures as YAML, and generated model services receive x-defang-llm. The fixture corpus was rewritten from JSON-like output to YAML across basic service cases, orchestration cases, and extension-heavy cases.

Changes

Compose fixup YAML migration

Layer / File(s) Summary
YAML serializer and model tagging
src/go.mod, src/pkg/cli/compose/fixup.go, src/pkg/cli/compose/fixup_test.go
FixupServices now adds x-defang-llm to generated model services, and the fixup test marshals fixture comparisons as YAML.
Small fixture rewrites
src/testdata/Fancy-Proj_Dir/compose.yaml.fixup, src/testdata/empty/compose.yaml.fixup, src/testdata/noprojname/compose.yaml.fixup, src/testdata/alttestproj/compose.yaml.fixup, src/testdata/base-image/compose.yaml.fixup, src/testdata/build-image/compose.yaml.fixup, src/testdata/build/compose.yaml.fixup, src/testdata/bun-in-compose/compose.yaml.fixup, src/testdata/bun-in-dockerfile/compose.yaml.fixup, src/testdata/compose-go-warn/compose.yaml.fixup, src/testdata/configdetection/compose.yaml.fixup, src/testdata/configoverride/compose.yaml.fixup, src/testdata/debugproj/compose.yaml.fixup, src/testdata/longname/compose.yaml.fixup, src/testdata/platforms/compose.yaml.fixup, src/testdata/provider/compose.yaml.fixup, src/testdata/secretname/compose.yaml.fixup, src/testdata/toomany/compose.yaml.fixup, src/testdata/toomany/docker-compose.yml.fixup
Several small fixture cases were rewritten to YAML while keeping images, builds, networks, and other simple service fields, and dropping explicit command/entrypoint nulls.
Multi-service fixture rewrites
src/testdata/ambiguous-strings/compose.yaml.fixup, src/testdata/build/compose.yaml.fixup, src/testdata/emptyenv/compose.yaml.fixup, src/testdata/extends/compose.yaml.fixup, src/testdata/interpolate/compose.yaml.fixup, src/testdata/profiles/compose.yaml.fixup, src/testdata/railpack/compose.yaml.fixup, src/testdata/testproj/compose.yaml.fixup
Multi-service fixtures for builds, extends, environments, profiles, and service definitions were rewritten to YAML while preserving the same service keys and values.
Ports, networks, and lifecycle fixtures
src/testdata/dependson/compose.yaml.fixup, src/testdata/dockerfile-validation-errors/compose.yaml.fixup, src/testdata/healthcheck/compose.yaml.fixup, src/testdata/heroku/compose.yaml.fixup, src/testdata/networks/compose.yaml.fixup, src/testdata/ports/compose.yaml.fixup, src/testdata/postgres/compose.yaml.fixup, src/testdata/replicas/compose.yaml.fixup, src/testdata/sanity/compose.yaml.fixup, src/testdata/fixupenv/compose.yaml.fixup, src/testdata/gpu/compose.yaml.fixup
Fixtures covering depends_on, ports, healthchecks, networks, replicas, and other orchestration settings were rewritten to YAML with the same retained values.
Extension fixtures
src/testdata/llm/compose.yaml.fixup, src/testdata/models/compose.yaml.fixup, src/testdata/mongo/compose.yaml.fixup, src/testdata/redis/compose.yaml.fixup, src/testdata/static-files/compose.yaml.fixup
LLM, MongoDB, PostgreSQL, Redis, and static-files fixtures now use YAML output and the updated extension metadata where present.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • DefangLabs/defang#1698: Both PRs modify src/pkg/cli/compose/fixup.go’s FixupServices logic around compose service generation.
  • DefangLabs/defang#2012: Both PRs touch the model/provider compose fixup path and the generated service shape for LLM-related services.

Suggested labels

go, high

Suggested reviewers

  • lionello

Poem

A YAML sprout grew in my burrow today,
with x-defang-llm tucked in bright and gay.
I hopped past ports and networks too,
and fixtures sang a tidy tune.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main changes: injecting x-defang-llm on model services and converting fixup snapshots to YAML.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jordan/x-defang-llm-model-runner

Comment @coderabbitai help to get the list of available commands.

Comment thread src/pkg/cli/compose/fixup_test.go
@lionello lionello merged commit f769311 into main Jun 24, 2026
14 of 15 checks passed
@lionello lionello deleted the jordan/x-defang-llm-model-runner branch June 24, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants