Repository navigation
Add custom source for muse-code (stable) - #789
connortreacy wants to merge 3 commits into
Conversation
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, "") |
There was a problem hiding this comment.
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:
agent.jsonis at1.4.25, with archives for1.4.25-R9361.1.- Muse revokes
R9361.1, and the channel now names1.4.25-R9400.1. The old URLs start returning410 Gone, as the PR description says. 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 NoneReturning 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".
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
_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.
There was a problem hiding this comment.
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.pykeeps its own_openwrapper for cache-busting and 404 →None, but it builds onstrict_http.open_url. Its HTTP tests now patchstrict_http._OPENER.test_strict_http.pyruns a local server. It checks that 301, 302, 303, 307 and 308 raiseHTTPErrorfor both GET and HEAD, and that the redirect target is never requested. Switching to a plainbuild_opener()fails 10 of those tests.test_requests_go_through_strict_httpcovers 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.
98e66ce to
02ee562
Compare
EugeneTheDev
left a comment
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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:
isinstance(size, bool): the"size"case setssize = True. Without the bool check it passes as1, and the HEAD check then fails it because the length is not 1.size <= 0: no case uses a zero or negative size. The HEAD length check would catch it too.content_type != "application/octet-stream": the"html"case intest_rejects_binary_that_is_not_the_advertised_file(line 225) also sends a length of0, 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.
There was a problem hiding this comment.
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.
02ee562 to
1a7f285
Compare
Adds a
custom_agent_sourcesentry formuse-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:
https://api.meta.ai/muse-code/channels/muse-stablenames the current build (for example1.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.The registry version is the build's
x.y.zpart.cmd,argsandenvare never touched.Behaviour
Modelled on Muse's launcher, plus the checks from
antigravity.pyand the review of #657: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 thatagent.jsonpoints at the channel's exact build (see the known limit below).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 anUpdateErrorfor a person to review.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 throughstrict_http.py, a shared opener that never follows redirects.antigravity.pynow uses it too.muse-stablewithstate: public.x.y.z-R<n>[.<n>].200 application/octet-streamwith the manifest's size. Without this, a missing file would show up as a 404 HTML page.agent.jsonthat'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-Rsuffix) can't be applied automatically. It could leave the entry on a revoked build whose downloads return410 Gone, so it returns anUpdateErrorasking for a manual bump.Verification
tests/test_muse_code_source.py(35 tests) covers: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.muse_code.pywas removed in turn, and every removal fails at least one test.ruff checkandruff format --checkare clean.update_versions.py --agents muse-code --applyproduced 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 reportsOK (1.4.24).