Skip to content

fix(factory): resolve generated service endpoints and preserve current runtime - #128

Merged
antoinetoussaint-byte merged 8 commits into
mainfrom
scaffold/resolve-its-own-address
Oct 27, 2026
Merged

antoinetoussaint-byte merged 8 commits into
mainfrom
scaffold/resolve-its-own-address

Conversation

@antoinetoussaint-byte

@antoinetoussaint-byte antoinetoussaint-byte commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Generated Go services declare a private HTTP endpoint, initialize the SDK and bind the host and port assigned by the composition. The server refuses startup when the SDK cannot resolve an address (including a missing carrier with no local composition workspace); Runtime and Builder Load reject malformed declared endpoint contracts.

This is a fix at the generic Go-agent owner. It reuses Core's endpoint declaration/configuration flow and the SDK resolver. It introduces no port allocator, endpoint resolver or executable-path reconstruction. Factory source is locked in base/; templates are regenerated with codefly agent generate --service .. The accidental compiled scaffold is removed. Generated services use released Core v0.19.6 and SDK v0.4.3 with Go 1.27.3.

Reconciled against main 27a0b551 (v0.0.73). The native-executable reporting work superseded by a1aa009 (#146) is removed from this PR's delta, including the obsolete duplicate test. Main's HostExecutable() reporting, failed-start diagnostics and lifecycle tests are preserved. This remains one self-contained PR.

The two requested maintenance fixes remain at their existing owners: the APK refresher tries Docker's configured HTTPS registry mirror while preserving the exact pinned Go image digest, retaining daemon-owned HTTP transport and fallback after a failed direct pull; the Go-version policy checks the executable go version | grep -F smoke assertion, so a matching comment cannot hide a stale check. No runtime image bytes or lock digest change.

Documentation: AGENTS.md describes the scaffold lock and endpoint behavior; base/GETTING_STARTED.md generates the getting-started guide; BUILD-RECIPES.md describes mirror resolution and smoke-assertion enforcement.

Validation so far: go build ./..., go vet ./..., go test -count=1 -timeout 240s ./..., template regeneration and git diff --check pass. The real Builder gRPC/process test proves declared private endpoint, successful health at an allocated loopback address and refusal without a carrier. The APK check passes through the configured mirror. Mutating the workflow smoke command to the old Go version while retaining the correct version in a comment makes the policy test fail (exit 1).

Fresh independent architecture/elegance review accepted the endpoint design and found two corrections: preserve HTTP-mirror transport/daemon fallback, and qualify the missing-carrier rule to match the SDK's supported local-workspace fallback. Both corrections are committed at 47cfb21 and independently verified closed by a fresh focused reviewer. Focused scaffold/contract race tests, real native/cross-CGO packaging and deterministic manifest renders pass. Nix integration explicitly skips because the sibling Core fixture is absent.

CI at 8dc3499 and 47cfb21: build and runtime-image checks pass. The shared manifest scanner falsely classified transitive test-dependency checksums as GitHub ownership. The owner fix is merged as codefly-dev/.github#11 (26878febb40fd24fd130ed6b7a4bde00710b716a) after independent review and full scanner/conformance checks. Full pin-upgrade review also caught missing Go variable/inline-field detection in an earlier owner change. The owning follow-up codefly-dev/.github#12 restores those declarations while preserving punctuated comment prose, and fresh F3/F4 review verifies closure. This PR consumes final reviewed owner commit aa2b11b43d815ce1195ca881e686f5475c19362a; its merged tree equals reviewed candidate 3a1e906. The old scanner fails on the exact tracked candidate; the corrected scanner passes, while generated Git/GitHub/Argo code remains rejected. No checksum was removed, generated file hand-edited, or consumer bypass added. All required hosted checks pass at final head a10665c: build and runtime-image in run 40576759520, manifest-guard in run 40576760331. Independent endpoint, mirror/SDK finding closure, full pin-adoption and scanner F3/F4 closure reviews are complete; no remaining scoped finding blocks merge. Cloud/product deployment and Nix execution are not claimed by these local tests.

…omposition

It shipped `Addr: ":8080"`. A hardcoded port is wrong the moment two services
want it, and it ignores what the composition assigned this endpoint -- the
service listens where nothing is looking. Nothing caught it because NO test
runs the service this agent generates.

It now resolves, and refuses to start when it cannot:

    instance, err := codefly.For(ctx).API(standards.HTTP).ResolveNetworkInstance()
    if err != nil {
        panic(fmt.Errorf("cannot resolve this service's %s address: %w", standards.HTTP, err))
    }

ResolveNetworkInstance, never NetworkInstance: the latter returns nil on
failure, so reading .Port off it panics with nothing to read and the only
symptom is a port that never accepts -- the exact failure that cost a session
in service-go-grpc.

Adds `base/` as the canonical fixture, the way service-go-grpc has one: a real
service that compiles, from which the factory templates are GENERATED with
`codefly agent generate --service .`. The templates are output, not source.

Two tests, each proven to fail without its fix:
  * TestFactoryTemplatesRenderToBase -- the templates render byte-for-byte to
    base/code, so a hand-edit or a stale lock cannot pass;
  * TestGeneratedServiceResolvesItsAddress -- the scaffold resolves and does
    not hardcode.

AGENTS.md carries both rules: base/ is a lock and the regeneration command,
and the address comes from the composition. Neither was written down.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
antoinetoussaint-byte added a commit to codefly-dev/sdk-go that referenced this pull request Oct 8, 2026
Every service that imported `codefly` to resolve its own address also linked
a GitHub API client and an HTTP artifact downloader it never calls:

    codefly-base -> sdk-go -> core/composition -> go-github/v89

The whole reason was fixture.go, 98 lines in the ROOT package, needing
core/composition for three types -- and composition carries GitHubResolver,
which downloads release artifacts. Resolving a seeded identity by role is a
TEST-time concern; a service binary has no business carrying the code that
fetches release assets from GitHub.

It moves to sdk-go/fixture: FixtureSelection becomes fixture.Selection,
codefly.Fixture() becomes fixture.Selected(), codefly.WithFixture() becomes
fixture.With(). Nothing is lost.

Breaking, and safe: a search across codefly-dev and obin-ai finds NO consumer
of the fixture API outside sdk-go's own test.

Proven, not assumed -- in a generated service, `go list -deps .` (the packages
the BINARY links) now matches neither core/composition nor go-github, while
core/resources is still linked for address resolution. The generated service's
go.mod no longer names go-github at all, which is what service-go's
manifest-guard refuses (codefly-dev/service-go#128).

Co-authored-by: Antoine Toussaint <312536060+antoinetoussaint-byte@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antoinetoussaint-byte antoinetoussaint-byte changed the title feat(factory)!: the generated service resolves its address from the composition fix(runtime): report native executables and create address-resolved Go services Oct 14, 2026
@antoinetoussaint-byte antoinetoussaint-byte changed the title fix(runtime): report native executables and create address-resolved Go services fix(factory): resolve generated service endpoints and preserve current runtime Oct 27, 2026
@antoinetoussaint-byte
antoinetoussaint-byte merged commit e61979d into main Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant