Skip to content

fix(leyline): public ley-line-open download + version pin [mache-9051f0]#388

Merged
jamestexas merged 2 commits into
feat/evolve-coverage-trunkfrom
evolve/mache-9051f0
May 19, 2026
Merged

fix(leyline): public ley-line-open download + version pin [mache-9051f0]#388
jamestexas merged 2 commits into
feat/evolve-coverage-trunkfrom
evolve/mache-9051f0

Conversation

@jamestexas
Copy link
Copy Markdown
Contributor

Summary

Closes bead mache-9051f0. The auto-download URL in internal/leyline/socket.go had two problems that together produced silent breakage on fresh-clone machines:

  1. Private repo: URL pointed at agentic-research/ley-line (private). Anything without a checkout token got 404s.
  2. Floating /releases/latest/: Even with the public repo, latest pulls whatever LLO tagged most recently — no relationship to the leyline-schema v0.4.1 pin in go.mod. A daemon at the wrong schema produces wire-format decode errors that are very hard to diagnose.

Changes

OLD: https://github.com/agentic-research/ley-line/releases/latest/download/leyline-{os}-{arch}
NEW: https://github.com/agentic-research/ley-line-open/releases/download/v0.4.1/leyline-{os}-{arch}
  • New leylineBinaryVersion = "v0.4.1" const beside the URL template (Option A from the bead — simplest, no extra build infra). The const must mirror the leyline-schema pin in go.mod; comment block documents the bump discipline.
  • URL template switched to /releases/download/%s/%s and downloadLeyline now substitutes both version and asset name.
  • 404 error message updated to mention the pinned version so logs show exactly which tag was missing.
  • Forward pointer to mache-8kif (startup version handshake with the daemon) noted in the comment as the eventual hardening.

Files

ONE production file + ONE test file, as required:

  • internal/leyline/socket.go — const + URL template + 404 message
  • internal/leyline/socket_test.go — new TestLeylineReleaseURL_IncludesVersion; existing TestLeylineReleaseURL_PointsAtPublicRepo still passes unchanged (it only asserts on the repo path).

Test plan

  • go test -run 'TestLeyline|TestDownload|TestDiscover' -v ./internal/leyline/ — all pass
  • task check — gofumpt, vet, golangci-lint, full test sweep, docs lint all pass
  • No network calls in tests — verified by inspection (fmt.Sprintf only on the rendered URL)
  • MACHE_NO_LEYLINE=1 short-circuit path (TestDiscoverOrStart_NoLeylineEnv_SkipsDownload) still gates the download as before

…n pin [mache-9051f0]

The auto-download URL in internal/leyline/socket.go had two problems that
together produced silent breakage on fresh-clone machines:

1. Private repo. The URL referenced agentic-research/ley-line (private),
   so any CI runner or dev machine without an actions/checkout-style token
   got a 404 on every download attempt. The public counterpart is
   agentic-research/ley-line-open; switch to that.

2. Floating `/releases/latest/`. Even with the public repo, /latest/ pulls
   whatever LLO tagged most recently — which has no guaranteed relationship
   to the schema-client version pinned in mache's go.mod
   (github.com/agentic-research/ley-line-open/clients/go/leyline-schema v0.4.1).
   A floating fetch can hand mache a daemon binary whose wire format the
   Go schema-client can't decode, producing errors that are very hard to
   diagnose from the consumer side.

Fix: introduce a `leylineBinaryVersion` const (Option A from the bead) that
mirrors the go.mod schema-client pin and bake the version into the URL:

  OLD: https://github.com/agentic-research/ley-line/releases/latest/download/leyline-{os}-{arch}
  NEW: https://github.com/agentic-research/ley-line-open/releases/download/v0.4.1/leyline-{os}-{arch}

The const lives next to the URL template at internal/leyline/socket.go with
a "BUMP THIS WHEN UPDATING leyline-schema in go.mod" comment so future
schema upgrades catch the version-pin requirement at edit time. The 404
error message is also updated to mention the pinned version so logs show
exactly which tag was missing, and a forward pointer to mache-8kif
documents the eventual hardening (startup version handshake with the daemon).

Tests updated together with the code:
- TestLeylineReleaseURL_PointsAtPublicRepo: existing test passed against
  the new URL with no change (it asserts on the repo path only).
- TestLeylineReleaseURL_IncludesVersion: new test, asserts the rendered
  URL contains the pinned version, uses /releases/download/<tag>/ form,
  and never falls back to /releases/latest/. Pure-Go fmt.Sprintf — no
  network calls.

ONE production file + ONE test file, as required.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

find_smells (advisory)

Scoped to files changed in this PR. Rules below run on the standalone (no-LLO) cross-ref tables; _ast rules (cyclomatic_complexity, long_function, long_file, magic_int_in_comparison) are not exercised here.

fan_out_skew — 1 finding(s) in changed files
Source Node Metric
internal/leyline/socket.go leyline/functions/DiscoverOrStart/source 24

Rules: see docs/ARCHITECTURE.md for the full registry. Advisory only — these are heuristics, not gates.

jamestexas added a commit that referenced this pull request May 19, 2026
Pure-stdlib Go CLI at tools/coverage-gate/ that gates trunk PRs on new-code coverage.

Contract:
- Input: a Go cover profile (go test -coverprofile=cover.out) + a unified diff
- Output: list of new/modified prod lines lacking coverage; exit 0 if clean, 1 if uncovered, 2 on error
- Skips _test.go, testdata/, non-Go files, comment-only lines, blank lines
- Supports // coverage:ignore single-line annotations
- Deterministic output (sorted by file, then by line, with collapsed ranges)

Demo run against PR #388 found 2 uncovered lines in downloadLeyline (L583, L605 — the httpGet + 404 paths). Demo run against PR #389 found 4 uncovered lines in DiscoverOrStart (L190-191 stale-managed reap, L256-257 pre-spawn liveness). Both are real, in-diff, uncovered prod lines — true positives.

15 self-tests covering profile parsing, diff parsing, intersection, overlap handling, comment-skip, test-file skip, testdata skip, coverage:ignore, exit codes, report formatting, and binary integration. All pass under -race -count=10.

Fresh-eyes audit recommendation: APPROVE — no false positives or false negatives detected. Production-ready as merge gate.

Closes part of mache-66d8df. The per-package ratchet baseline tracking is the natural Phase 2 (separate bead).

Lands on feat/evolve-coverage-trunk (PR #385). Once merged, the gate runs against every subsequent trunk PR + retroactively on already-merged commits.
…9051f0]

PR #388 added the version-pinned auto-download path in socket.go but
left two new-prod lines uncovered (coverage-gate flagged):

  - socket.go:583 — assetName / URL Sprintf line
  - socket.go:605 — http.StatusNotFound branch

Refactor (one-token):
  - Change leylineReleaseURLTemplate from const to var so hermetic
    tests can swap in an httptest server URL. Production code never
    mutates it; the swap is test-only via a small swapLeylineReleaseURLTemplate
    helper with t.Cleanup restore. Comment on the var documents the
    contract.

New tests (no real network):
  - TestDownloadLeyline_HappyPath — httptest.Server returns 200 +
    payload, asserts the downloaded file exists with the right bytes
    and an executable bit set, and that the server saw a request path
    of the form /releases/download/<version>/leyline-<os>-<arch>
    (exercises both flagged lines plus the io.Copy + chmod + rename
    tail of the function).
  - TestDownloadLeyline_NotFound — httptest.Server returns 404,
    asserts the error string contains 'no leyline release available'
    and the pinned version, plus a negative assertion that destPath
    was NOT created.

Verification:
  - go test -race -count=3 -run TestDownloadLeyline ./internal/leyline/ — PASS
  - coverage-gate on the PR diff exits 0 (down from 2 flagged lines)
  - task check — green
@jamestexas jamestexas merged commit 8f45ccf into feat/evolve-coverage-trunk May 19, 2026
1 check passed
@jamestexas jamestexas deleted the evolve/mache-9051f0 branch May 19, 2026 00:24
jamestexas added a commit that referenced this pull request May 19, 2026
Pure-stdlib Go CLI at tools/coverage-gate/ that gates trunk PRs on new-code coverage.

Contract:
- Input: a Go cover profile (go test -coverprofile=cover.out) + a unified diff
- Output: list of new/modified prod lines lacking coverage; exit 0 if clean, 1 if uncovered, 2 on error
- Skips _test.go, testdata/, non-Go files, comment-only lines, blank lines
- Supports // coverage:ignore single-line annotations
- Deterministic output (sorted by file, then by line, with collapsed ranges)

Demo run against PR #388 found 2 uncovered lines in downloadLeyline (L583, L605 — the httpGet + 404 paths). Demo run against PR #389 found 4 uncovered lines in DiscoverOrStart (L190-191 stale-managed reap, L256-257 pre-spawn liveness). Both are real, in-diff, uncovered prod lines — true positives.

15 self-tests covering profile parsing, diff parsing, intersection, overlap handling, comment-skip, test-file skip, testdata skip, coverage:ignore, exit codes, report formatting, and binary integration. All pass under -race -count=10.

Fresh-eyes audit recommendation: APPROVE — no false positives or false negatives detected. Production-ready as merge gate.

Closes part of mache-66d8df. The per-package ratchet baseline tracking is the natural Phase 2 (separate bead).

Lands on feat/evolve-coverage-trunk (PR #385). Once merged, the gate runs against every subsequent trunk PR + retroactively on already-merged commits.
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.

1 participant