gabriel / muse public
hub.md markdown
310 lines 7.2 KB
Raw
sha256:18b983389ee1b55900fcd799bfbb496552d2e3ecded9d18cefbfef188947a12e chore: remove blob-debug test marker file Sonnet 4.6 1 day ago

muse hub — MuseHub Fabric Connection Reference

The hub is not just a remote. It is the primary identity fabric — the shared coordination layer where authentication, plugin discovery, and multi-agent state synchronisation come together.


Table of Contents

  1. Hub vs. Remote
  2. Commands
  3. HTTPS Enforcement
  4. Redirect Refusal
  5. Configuration
  6. Typical Setup Workflow

Hub vs. Remote

Muse uses two distinct concepts for network connections:

muse hub muse remote
Purpose Primary identity fabric Generic push/pull endpoint
Cardinality At most one per repo Many per repo
Manages Authentication, discovery, coordination Object transport
Config location [hub] url in .muse/config.toml [remotes.<name>] in .muse/config.toml
Credentials Stored in ~/.muse/identity.toml Inherited from hub identity
Commands connect, status, disconnect, ping add, remove, rename, list, get-url, set-url

A repository has at most one hub. It may have many remotes. When you muse push to a remote that lives on the same MuseHub instance as the configured hub, the hub's token is used automatically.


Commands

muse hub connect

Attach this repository to a MuseHub instance.

muse hub connect <URL>

Arguments:

Argument Description
URL MuseHub URL (e.g. https://musehub.ai or just musehub.ai).

What connect does:

  1. Normalises the URL (see HTTPS Enforcement).
  2. Warns if the repo is already connected to a different hub.
  3. Writes [hub] url = "<url>" to .muse/config.toml.
  4. If an identity already exists for this hub in ~/.muse/identity.toml, shows the stored name and type.
  5. If no identity exists, prompts to run muse auth register.

Does not modify ~/.muse/identity.toml — use muse auth register to authenticate after connecting.

Examples:

# With full HTTPS URL
muse hub connect https://musehub.ai

# Bare hostname — HTTPS added automatically
muse hub connect musehub.ai

# Switch hubs (warns before overwriting)
muse hub connect https://staging.musehub.ai

muse hub status

Show the hub connection and identity for this repository.

muse hub status [--json]

Options:

Flag Description
--json Emit JSON instead of human-readable output.

Human-readable output:

  Hub
    URL:       https://musehub.ai
    Type:      human
    Name:      Alice
    ID:        usr_abc123
    Token:     set (MSign ***)
    Caps:      read:* write:midi

JSON output (--json):

{
  "hub_url": "https://musehub.ai",
  "hostname": "musehub.ai",
  "authenticated": true,
  "identity_type": "human",
  "identity_name": "Alice",
  "identity_id": "usr_abc123"
}

When no identity is stored, authenticated is false and no identity fields appear.

Agent pattern:

muse hub status --json | jq .authenticated

muse hub disconnect

Remove the hub association from this repository.

muse hub disconnect

Removes [hub] url from .muse/config.toml. Credentials in ~/.muse/identity.toml are preserved — use muse auth logout to remove them as well.

Examples:

# Remove hub association only
muse hub disconnect

# Remove hub association + credentials
muse hub disconnect
muse auth logout --hub https://musehub.ai

muse hub ping

Test HTTP connectivity to the configured hub.

muse hub ping

Sends GET <hub_url>/health and reports the result.

Exit codes:

Code Meaning
0 Hub is reachable (2xx response)
Non-zero Hub is unreachable or returned an error

Examples:

muse hub ping
# Pinging musehub.ai… ✅ HTTP 200 OK

muse hub ping
# Pinging staging.musehub.ai… ❌ timed out

# Use in a healthcheck script
muse hub ping || notify-send "MuseHub unreachable"

HTTPS Enforcement

All hub URLs are required to use HTTPS. The _normalise_url() function:

  • Adds https:// when no scheme is present.
  • Raises ValueError (shown as a user-facing error) when an explicit http:// scheme is given.
# These are all equivalent
muse hub connect musehub.ai
muse hub connect https://musehub.ai
muse hub connect https://musehub.ai/

# This is rejected — signing identitys must not travel over cleartext HTTP
muse hub connect http://musehub.ai
# ❌ Insecure URL rejected: 'http://musehub.ai'
#    MuseHub requires HTTPS. Did you mean: https://musehub.ai

The HTTPS enforcement is a hard requirement, not a preference. Signing identitys are authentication credentials — sending them over cleartext HTTP exposes them to any network observer between the agent and the hub.


Redirect Refusal

The ping command uses a custom _NoRedirectHandler that refuses all HTTP redirects. When the hub returns a 3xx response:

❌ Redirect refused (301): hub redirected to 'https://other.host/'.
   Update the hub URL.

Why this matters:

A hub that silently redirects GET /health to a different host is misleading about what was actually reached. More importantly, allowing redirects on the push and fetch paths would cause the Authorization: MSign header to be forwarded to the redirect destination — potentially a different host entirely.

If your MuseHub instance redirects (e.g. from www.musehub.ai to musehub.ai), update the hub URL to the final destination:

muse hub connect musehub.ai  # not www.musehub.ai

Configuration

Hub connection state is stored in .muse/config.toml:

[hub]
url = "https://musehub.ai"

This file is per-repository and may be committed to version control — it contains only the hub URL, never any credentials. Credentials live in ~/.muse/identity.toml (see auth.md).


Typical Setup Workflow

New repository

# 1. Initialise
muse init --domain midi

# 2. Connect to hub
muse hub connect https://musehub.ai

# 3. Authenticate
muse auth register

# 4. Add the remote (MuseHub creates it on first push)
muse remote add origin https://musehub.ai/repos/my-song

# 5. First push
muse push origin -u

Cloned repository

muse clone sets the origin remote automatically. Connect the hub separately if you want muse hub status to work:

muse clone https://musehub.ai/repos/my-song
cd my-song
muse hub connect https://musehub.ai
muse auth register  # if not already logged in on this machine

CI/CD agent

# In the pipeline environment
muse hub connect https://musehub.ai
muse auth keygen --hub https://musehub.ai
muse auth register --hub https://musehub.ai --handle "ci-agent-${BUILD_NUMBER}" --agent
muse push origin

See also:

File History 7 commits
sha256:18b983389ee1b55900fcd799bfbb496552d2e3ecded9d18cefbfef188947a12e chore: remove blob-debug test marker file Sonnet 4.6 1 day ago
sha256:e452ad9a6ace6ccc6d875a35e06caf9da5576a970c1c36133b69a891ce5fefa8 chore: prebuild timing test Sonnet 4.6 8 days ago
sha256:0008ab6695e3e064b3e236b24fd19e538fef6a588eb0d211622f4466d919c0b1 merge: pull staging/dev — advance to 0.2.0rc12 Sonnet 4.6 patch 10 days ago
sha256:9c33d61749fff814c5226d5386aa2af7064c2c02788594a25fdd709358132eea fix: _PROPOSAL_PREFIX_RESOLVE_LIMIT 200 → 100 to match hub … Sonnet 4.6 22 days ago
sha256:36c3cb3e76619d4c30a6d9bf81b5ec4ff148e30dcfed913e3114ca7b43b81c7e fix: rename objects→blobs in push client and all stale test… Sonnet 4.6 patch 24 days ago
sha256:c06a9b9b9fee26c68ea725b44d54b2c0a171301ce9de746d5b656617b4463a9a fix: repair four test failures from post-migration audit Sonnet 4.6 patch 31 days ago
sha256:1900655993c83c4107067375548a7be823e471d2515830842f1a12cba4bd3cdf fix: unified object store migration — idempotent writes, JS… Sonnet 4.6 minor 31 days ago