Skip to content

feat: embed mint source for standalone binary - #1035

Merged
waynesun09 merged 3 commits into
mainfrom
embed-mint-source
May 15, 2026
Merged

feat: embed mint source for standalone binary#1035
waynesun09 merged 3 commits into
mainfrom
embed-mint-source

Conversation

@waynesun09

Copy link
Copy Markdown
Member

Summary

  • Embeds internal/mint/ source files (go.mod, go.sum, main.go) into the fullsend binary at build time using go:embed
  • bundleFunctionSource() falls back to the embedded copy when the filesystem path doesn't exist (e.g. running from a downloaded release binary)
  • Logs a warning when local mint source is used instead of the embedded version, so users know they're picking up local files
  • Adds a drift-detection test (TestEmbeddedMintSource_MatchesOriginal) that fails if the embedded copies diverge from the originals in internal/mint/

Problem: Running fullsend admin install from a release binary fails with open internal/mint: no such file or directory because the default source path only exists inside the repo checkout.

Approach: Files are stored with .embed suffix in mintsrc/ to avoid Go treating the directory as a separate module (since internal/mint/ has its own go.mod for Cloud Function deployment).

Test plan

  • go test ./internal/dispatch/gcf/ — all tests pass
  • go vet ./internal/dispatch/gcf/ — clean
  • go build ./cmd/fullsend/ — binary builds with embedded source (~34 KB larger)
  • Run binary from outside repo directory — should use embedded mint source without errors
  • Run binary from repo root — should log warning about using local source

When running the fullsend binary outside the repo checkout (e.g. from a
GitHub release), the default mint source path internal/mint/ doesn't
exist, causing install to fail. Embed the mint source files in the
binary at build time and fall back to the embedded copy when the
filesystem path is missing. Log a warning when local source is used
so the user knows they're not using the embedded version.

Includes a drift-detection test that compares the embedded copies
against the originals in internal/mint/.

Signed-off-by: Wayne Sun <gsun@redhat.com>
@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown

Site preview

Preview: https://76eb70a9-site.fullsend-ai.workers.dev

Commit: 581a1c1a370a56fa3ff86272ed6439ed1cafe8fe

@fullsend-ai-review

fullsend-ai-review Bot commented May 15, 2026

Copy link
Copy Markdown

Review

No findings.

Previous run

Review

Findings

Low

  • [docs-currency] docs/guides/admin/installation.md:86 — The guidance "Use --skip-mint-deploy when running from a machine without the function source code" is stale. With the embedded fallback, the binary always has mint source available. This sentence should be revised or removed to avoid suggesting users add an unnecessary flag.

  • [docs-currency] docs/ADRs/0033-per-repo-installation-mode.md:260 — The --skip-mint-deploy and --mint-source-dir flag descriptions don't mention the embedded source fallback. Consider adding a note that --mint-source-dir is only needed to override the embedded copy with local files.

Info

  • [resolved] internal/dispatch/gcf/provisioner.go — Prior medium finding (non-deterministic map iteration in bundleEmbeddedMintSource) has been resolved. Keys are now sorted before iteration, ensuring deterministic zip hashing.
Previous run (2)

Review

Findings

Medium

  • [correctness] internal/dispatch/gcf/provisioner.go:1293bundleEmbeddedMintSource iterates over embeddedMintFiles (a Go map), producing non-deterministic file order in the zip archive. Since needsCodeDeploy compares sha256Hex(sourceZip) against the deployed hash, each invocation from a release binary may compute a different hash for identical content, triggering an unnecessary Cloud Function redeployment every time fullsend admin install runs.
    Remediation: Sort the map keys before iterating, matching the deterministic ordering that os.ReadDir provides in the filesystem path. For example: collect keys into a slice, sort.Strings(keys), then iterate the slice.

Low

  • [docs-currency] docs/guides/admin/installation.md:86 — The guidance "Use --skip-mint-deploy when running from a machine without the function source code" is now stale. With the embedded fallback, the binary deploys the mint source automatically when the filesystem path is absent. This sentence should be updated or removed to avoid confusing users into adding an unnecessary flag.

@fullsend-ai-review fullsend-ai-review Bot added the requires-manual-review Review requires human judgment label May 15, 2026
- Use errors.Is(err, fs.ErrNotExist) instead of os.IsNotExist for
  proper error chain unwrapping
- Sort embedded file map keys before zip iteration for deterministic
  output (prevents spurious hash-based redeployments)
- Fix stale comment referencing "underscore names" (now .embed suffix)
- Improve drift detection test: check directory existence once before
  loop, detect new files added to internal/mint/ that are missing from
  the embed map, include full target path in assertion messages
- Add missing go.sum assertion in nonexistent-dir test

Signed-off-by: Wayne Sun <gsun@redhat.com>
Document that the downloaded binary includes embedded mint source and
works standalone. When running from a repo clone, local internal/mint/
is used instead (with a log message). Update --mint-source-dir flag
description and --skip-mint-deploy note accordingly.

Signed-off-by: Wayne Sun <gsun@redhat.com>
@waynesun09

Copy link
Copy Markdown
Member Author

/fs-review

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge and removed requires-manual-review Review requires human judgment labels May 15, 2026
@waynesun09
waynesun09 added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit c669e40 May 15, 2026
7 checks passed
@waynesun09
waynesun09 deleted the embed-mint-source branch May 15, 2026 22:14
ben-alkov pushed a commit to ben-alkov/fullsend that referenced this pull request May 18, 2026
The review agent can flag findings in files not changed by the PR
(e.g. stale docs). When these are posted as inline review comments,
GitHub returns 422 Unprocessable Entity because the API only allows
comments on files in the diff.

Fetch the PR's changed files before submitting the review and drop
inline comments that reference files outside the diff. The findings
still appear in the sticky comment body, so nothing is lost.

Fixes the 422 failure seen in fullsend-ai/.fullsend run 25942695364
where docs-currency findings targeted docs files outside PR fullsend-ai#1035's
diff.

Signed-off-by: Wayne Sun <gsun@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant