Skip to content

feat(moshpit): actually resolve Moshpit names in the browser, and park unpointed ones - #52

Merged
ralyodio merged 2 commits into
mainfrom
feat-moshpit-wiring
Jul 31, 2026
Merged

feat(moshpit): actually resolve Moshpit names in the browser, and park unpointed ones#52
ralyodio merged 2 commits into
mainfrom
feat-moshpit-wiring

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

The problem

Moshpit was UI and dead code, end to end:

  • The options page wrote moshpitConfig to chrome.storagenothing read it. Setting the registry to pit.moshcode.sh had literally no effect.
  • The resolution policy lived in apps/desktop/src/moshpit-resolve.ts — TypeScript the extension cannot import (plain JS, no build step), with zero callers anywhere in the repo.

So https://california.oranges/ died on ERR_NAME_NOT_RESOLVED, and no setting could change that.

What this adds

moshpit.js — the policy ported into the extension. moshpit-resolve.ts stays the reference implementation; a test runs both over the same input space and requires identical answers, because a port that silently drifts is worse than no port.

background.js — two webNavigation hooks, because "does clearnet answer for this name?" is only knowable at two moments:

hook when active in
onErrorOccurred DNS came up empty (ERR_NAME_NOT_RESOLVED) both modes — the backfill path
onBeforeNavigate before navigating only moshpit mode, where a registered name beats clearnet

The default mode never pre-empts a working domain, and never costs a registry round-trip on ordinary browsing.

Parking — a name inside the namespace shouldn't dead-end on a DNS error. Unclaimed, or claimed but not pointed at an address yet, now lands on moshcoding.com/parking?name=….

Two guardrails on it:

  • Only where clearnet has nothing. A working domain is never replaced by a parking page — same rule the override obeys.
  • A registry that was unreachable still degrades to clearnet. Parking a name we merely failed to look up would be a lie about its status.

Manifest — adds webNavigation, and makes the service worker a module for the import.

No redirect loops: every destination (pit.moshcode.sh/n/…, app.moshcode.sh/pit, moshcoding.com/parking) has three labels, so parseRegistryName rejects it on the way back through. Explicitly tested.

Assumption to confirm

The parking URL shape is moshcoding.com/parking?name=<name> — from "at moshcoding.com parking". Query param over path segment so an endpoint that doesn't parse ?name= still lands somewhere real. Say the word if the actual route differs.

Verification

  • apps/desktop79 tests pass, incl. 11 cross-implementation parity tests and the new parking cases
  • pnpm -r build / pnpm -r test / pnpm lint — all exit 0

Still missing (separate work)

This is browser-only. It cannot make curl https://california.oranges/ work on a VPS, because it's an extension redirecting tabs — not DNS. Serving these names to non-browser clients needs a real resolver on the machine (moshcode CLI writing a systemd-resolved / dnsmasq stanza pointed at pit.moshcode.sh). Happy to take that next — it's a different layer, not an extension change.

🤖 Generated with Claude Code

…k unpointed ones

The Moshpit settings on the options page were written to chrome.storage and
never read by anything. The resolution policy lived in apps/desktop/src as
TypeScript that the extension cannot import and that had no callers. So
setting a registry did nothing and `california.oranges` died on
ERR_NAME_NOT_RESOLVED — the feature was UI and dead code, end to end.

- moshpit.js: a port of the policy into the extension (plain JS, no build
  step). moshpit-resolve.ts stays the reference implementation; a test runs
  BOTH over the same input space and requires identical answers, because a
  port that silently drifts is worse than no port.
- background.js: two webNavigation hooks, because "does clearnet answer?" is
  only knowable at two moments. onErrorOccurred (DNS came up empty) is the
  backfill path and the only one active in the default mode, so nothing that
  already works is touched. onBeforeNavigate runs only in 'moshpit' mode,
  where a registered name is meant to beat clearnet.
- Parking: a name in the namespace should not dead-end on a DNS error.
  Unclaimed, or claimed but not pointed at an address yet, now lands on
  moshcoding.com/parking?name=… — but only where clearnet has nothing, so a
  working domain is never replaced by a parking page. A registry that was
  unreachable still degrades to clearnet rather than lying with a parking
  page for a name it merely failed to look up.
- Manifest: webNavigation permission, and a module service worker for the
  import.

No redirect loops: every destination has three labels, so parseRegistryName
rejects it on the way back through.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

Probing the live registry showed the payload is richer than the code assumed:

  california.oranges -> {registered:true, name_registered:true, target:null,
                         resolved:'california.oranges', mode, prefer, aliased}

`resolved` echoes the name whether or not it points anywhere, so testing it
marked every claimed name as live — nothing would have parked, and the exact
case this was built for would have gone to the gateway. `target` is the
address, and null is what 'not pointed at an IP yet' actually looks like.

Also read name_registered (is THIS name claimed) in preference to registered
(is the TLD claimed), falling back for older registry builds.

Covered by a test using the verbatim california.oranges response.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 04619f5 into main Jul 31, 2026
7 checks passed
@ralyodio ralyodio mentioned this pull request Jul 31, 2026
@ralyodio
ralyodio deleted the feat-moshpit-wiring branch July 31, 2026 05:13
ralyodio added a commit that referenced this pull request Jul 31, 2026
Ships Moshpit name resolution actually working in the browser (#52): the
settings were written to storage and never read, and the policy module had no
callers, so no registry setting could make california.oranges resolve.
Unclaimed and unpointed names now park instead of dead-ending on a DNS error.

Also mosh.<tld> opening the Pit for that TLD (#51).

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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