Skip to content

Add custom source for muse-code (stable) - #789

Open
connortreacy wants to merge 3 commits into
agentclientprotocol:mainfrom
connortreacy:muse-code-auto-update
Open

connortreacy wants to merge 3 commits into
agentclientprotocol:mainfrom
connortreacy:muse-code-auto-update

Conversation

@connortreacy

@connortreacy connortreacy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds a custom_agent_sources entry for muse-code, as offered in #755, so the hourly updater bumps Muse Code instead of someone opening a PR by hand.

Source

Muse Code doesn't publish to npm, PyPI or GitHub Releases. It ships through a release channel, the same one its own launcher uses to update installed copies:

  1. https://api.meta.ai/muse-code/channels/muse-stable names the current build (for example 1.4.24-R9131.1) and its manifest URL. This is a public, unauthenticated endpoint for exactly this purpose. It serves only externally released builds, and nothing for revoked ones.
  2. The manifest lists each platform's raw binary with its URL, sha256 and size.

The registry version is the build's x.y.z part. cmd, args and env are never touched.

Behaviour

Modelled on Muse's launcher, plus the checks from antigravity.py and the review of #657:

  • No change, one request. If the channel's version matches agent.json, the source stops after reading the channel, as the launcher does. An hourly check costs about what one Muse install's launcher already sends. It still checks that agent.json points at the channel's exact build (see the known limit below).
  • Rollbacks are followed within a major version. Muse pulls a bad build by revoking it. The channel then names the highest remaining release, which is lower, and installed clients follow it. The pulled build's download URLs start returning 410 Gone, so refusing downgrades would leave the registry entry pointing at downloads that no longer work. A new major version, in either direction, returns an UpdateError for a person to review.
  • Allowlisted fetches, no redirects. The manifest URL and every binary URL must exactly match https://lookaside.facebook.com/lookaside/muse/download/?channel=muse&version=<build>&file=<expected name>, so a feed can't swap platforms or point somewhere else. Requests go through strict_http.py, a shared opener that never follows redirects. antigravity.py now uses it too.
  • Consistent metadata. These checks match the launcher's:
    • The channel must be muse-stable with state: public.
    • The build must match x.y.z-R<n>[.<n>].
    • The manifest's build must match the channel's, and the checksum algorithm must be sha256.
    • Every checksum must be 64 hex characters and every size a positive integer.
  • Binary check. Before accepting a release, each binary gets a HEAD request, which must return 200 application/octet-stream with the manifest's size. Without this, a missing file would show up as a 404 HTML page.
  • Complete or nothing. Any platform in agent.json that's missing from the manifest fails the whole check.

Known limit: the registry version is x.y.z, so a rebuild of the same version (new -R suffix) can't be applied automatically. It could leave the entry on a revoked build whose downloads return 410 Gone, so it returns an UpdateError asking for a manual bump.

Verification

  • tests/test_muse_code_source.py (35 tests) covers:
    • a full update;
    • rollbacks within a major version;
    • the single-request no-op at the current version;
    • a same-version rebuild, which is reported;
    • 27 rejection cases, each asserting its own error message;
    • requests going through strict_http.
  • tests/test_strict_http.py (12 tests) runs a local server and checks that 301, 302, 303, 307 and 308 raise for GET and HEAD and that the redirect target is never requested.
  • Each of the 20 guards in muse_code.py was removed in turn, and every removal fails at least one test.
  • The full suite passes (344 tests), and ruff check and ruff format --check are clean.
  • Live run against the real channel (before the review changes): on the 1.4.14 entry, update_versions.py --agents muse-code --apply produced a file byte-for-byte identical to the manual bump in Update muse-code to 1.4.24 #788. Run again at 1.4.24, it reports OK (1.4.24).

benbrandt pushed a commit that referenced this pull request Nov 19, 2026
Updates Muse Code from 1.4.14 to 1.4.24, the current build on its stable
channel (`1.4.24-R9131.1`).

Only `version` and each platform's `archive` and `sha256` change. The
URLs and checksums come from the build's release manifest. `cmd`, `args`
and `env` are unchanged. `muse acp` is now on by default, but
`MUSE_EXPERIMENTAL_ACP=on` still overrides a remote config that turns it
off, so it stays.

## Verification

- `build_registry.py --agents muse-code` passes.
- `verify_agents.py --auth-check --agent muse-code` on darwin-aarch64:
SHA-256 verified, `Auth OK: muse-login(agent)`.

#789 adds a custom source so future Muse Code releases are picked up by
the hourly updater.
raise _FeedError(f"channel version {version} is not a {current[0]}.x release")
if latest == current:
# Like Muse's own launcher, stop after the channel read when nothing changed.
return LatestRelease(version, "binary", CHANNEL_URL, "")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem: if Muse pulls a build and replaces it with a rebuild of the same x.y.z, the updater reports OK while the registry entry points at dead downloads.

How it happens:

  1. agent.json is at 1.4.25, with archives for 1.4.25-R9361.1.
  2. Muse revokes R9361.1, and the channel now names 1.4.25-R9400.1. The old URLs start returning 410 Gone, as the PR description says.
  3. latest == current, so this branch returns before it looks at the build, and the run reports no change.

Impact: build_registry.py checks every binary archive URL (validate_distribution_urls) on every build, so the registry build fails for all PRs and for publishing until someone notices and bumps Muse Code by hand. Nothing in the updater's output points at the cause. The PR lists the rebuild case as a known limit, but this is the same broken-download case the rollback logic exists to avoid, and here it goes unreported.

Fix: keep the single request, but compare the full build with the one agent.json pins, and report a mismatch so a person sees it:

if latest == current:
    archives = [t.get("archive", "") for t in agent_data.get("distribution", {}).get("binary", {}).values()]
    if not all(f"version={build}&" in a for a in archives):
        raise _FeedError(f"channel serves {build}, a rebuild of {version}; bump agent.json by hand")
    return None

Returning None here (as antigravity.py does when nothing is new) also avoids building a LatestRelease with no assets that only works because resolve_update drops equal versions. I tried this locally: a new test for the rebuild case passes. test_current_build_reads_only_the_channel then needs its fixture archives set to the current build's URLs instead of "old-url".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. Done as you suggested: at the current version it still makes one request, but it now checks that every archive in agent.json pins the channel's exact build. A rebuild returns an UpdateError ("channel serves 1.4.25-R9400.1, a rebuild of 1.4.25; update by hand"), and the no-change case returns None. I used a prefix match on …?channel=muse&version=<build>& rather than a substring. test_rebuild_of_current_version_is_reported is new, and the no-op test's fixture now pins the current build.

"""The channel is unreachable, or the channel or manifest is wrong."""


class _NoRedirect(urllib.request.HTTPRedirectHandler):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_FeedError, _NoRedirect, _OPENER, _open and _head are copied from custom_agent_sources/antigravity.py with small changes (no cache-busting, no 404-to-None). Since the no-redirect opener is what keeps the URL allowlist safe, it would be better to have it in one shared module next to jsonl_feed.py, for example strict_http.py with open_url(url, method) and head(url). Both sources would use it, and it would be tested once. That module's test should also check that the opener really refuses a 3xx. test_redirects_are_refused only checks that the handler method returns None, so it would still pass if _open stopped using _OPENER.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The opener is now in .github/workflows/strict_http.py (open_url(url, method, headers) and head(url, headers)), and both sources use it.

  • antigravity.py keeps its own _open wrapper for cache-busting and 404 → None, but it builds on strict_http.open_url. Its HTTP tests now patch strict_http._OPENER.
  • test_strict_http.py runs a local server. It checks that 301, 302, 303, 307 and 308 raise HTTPError for both GET and HEAD, and that the redirect target is never requested. Switching to a plain build_opener() fails 10 of those tests.
  • test_requests_go_through_strict_http covers the other gap you mentioned: if Muse's fetch stopped using the shared opener, it fails.

I also rebased onto main, which drops the opencode_v2 import, and added strict_http.py to the module list in AGENTS.md.

@EugeneTheDev EugeneTheDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good now. There's one small problem with the test that went unnoticed in the first review, please check

_break(fault, entry, channel, manifest)
_, update, error = check(entry, channel, manifest, tmp_path)
assert update is None
assert error is not None and error.agent_id == "muse-code"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem: test_rejects_unusable_feed only checks that some error comes back, so a fault can be caught by a later guard and the guard it targets goes untested. The PR description says "Removing any single guard makes at least one test fail", but that is not true for three guards in muse_code.py. I deleted each one and all 28 tests still passed:

  1. isinstance(size, bool): the "size" case sets size = True. Without the bool check it passes as 1, and the HEAD check then fails it because the length is not 1.
  2. size <= 0: no case uses a zero or negative size. The HEAD length check would catch it too.
  3. content_type != "application/octet-stream": the "html" case in test_rejects_binary_that_is_not_the_advertised_file (line 225) also sends a length of 0, so the size check catches it first.

Impact: tests only. Today the HEAD check stands in for these guards, so nothing broken gets through. But the tests would not notice if one of the guards were removed or broken.

Fix: give each fault the message it should produce and assert it, e.g. ("size", "size must be a positive int"), plus a ("zero_size", ...) case with size = 0. Use ("text/html", SIZE) for the html case so only the content type is wrong. I tried the size message check and the html change: the bool and content-type mutations then each fail one test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you're right, and the claim in the description was wrong. Every rejection case now asserts its own error message, and the html HEAD case uses the advertised size, so only the content type is wrong. I added zero_size and negative_size cases, and renamed size to bool_size.

Checking the rest of the guards the same way turned up four more that nothing pinned: artifacts not being an object, a non-string checksum, a string size, and a channel response that isn't a JSON object. Those have cases now too. I then removed each of the 20 guards in muse_code.py in turn, and every removal fails at least one test.

I also rebased onto main. That picks up the fast-agent quarantine from #804, which is why Auth (fast-agent) failed here.

- muse-code: at the current version, check agent.json pins the channel's
  exact build and report a rebuild instead of returning OK; return None
  when nothing changed.
- Move the no-redirect opener into strict_http.py, used by both the
  muse-code and antigravity sources, with tests against a local server.
Every rejection case now asserts the message its guard produces, so a
later check can't stand in for the one under test. Adds zero, negative,
string and bool sizes, a non-string checksum, non-object artifacts, and
non-object channel responses.
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