Files
readme.txt
naut
----

an experimental tangled knot that runs on cloudflare workers
and artifacts.

the knot is one cloudflare worker. each repository is an
artifacts repository with its own did:plc, and the knot is
that did's atproto pds. a durable object keeps the list of
repositories, each repository's records (its manifest, its
refs, its collaborators, and the issues, pulls, comments,
reactions, labels and artifacts people contribute) under a
commit signed by the knot, and the firehose
(com.atproto.sync.subscribeRepos) that indexers follow.
attachments live in an r2 bucket.

git traffic goes through the worker to the artifacts
remote. this very repository is hosted and served from a CF
artifact!

  $ git clone https://tangled.org/oppi.li/naut
  Cloning into 'naut'...



build
-----

the dev shell is supplied by nix:

  nix develop
  cd worker
  worker-build --release

the build output goes into `worker/build`.




usage
-----

to run your own knot:

1. copy worker/wrangler.jsonc to a new file in worker.


2. set KNOT_HOSTNAME to the hostname of the worker, set
   KNOT_ADMINS to the dids of the knot admins and set the
   artifacts `namespace`. put your did first in `KNOT_ADMINS`.
   the first did is the owner of the knot.


3. add the knot's signing key as a secret:

     openssl rand -hex 32 > signing-key.hex
     npx wrangler secret put KNOT_SIGNING_KEY --config <your config> < signing-key.hex

   keep a copy of the key in a safe location.


4. create the r2 bucket that holds attachments and artifacts
   (the `r2_buckets` entry in the config names it):

     npx wrangler r2 bucket create knot-blobs


5. set KNOT_CRAWLERS to the indexers that should follow the
   knot's firehose (tangled's is https://index.tangled.network).
   the knot asks them to crawl it whenever a repository is
   created.


6. deploy:

     npx wrangler deploy --config <your config>


7. add the knot on tangled in settings


a knot that was running before repositories got their own
atproto records needs its repositories moved over once:

1. add an admin secret:

     openssl rand -hex 32 | npx wrangler secret put KNOT_ADMIN_SECRET --config <your config>


2. run the upgrade, which points every repository's did
   document at the knot as its pds and opens its records
   (manifest, refs, and the collaborators it had):

     curl -X POST -H "Authorization: Bearer <secret>" https://<hostname>/_admin/upgrade

   it is safe to run again; repositories that are already
   moved are left alone. each owner still has to publish an
   org.tangled.repo.declaration record for their repository.


once you have a knot running, you can push over http:

1. log in with goat[0]:

     goat account login -u <your handle> -p <app password>


2. tell git to use `scripts/git-credential-knot`:

     git config credential.https://<hostname>.helper ""
     git config --add credential.https://<hostname>.helper \
       "!/naut/scripts/git-credential-knot"


3. push:

     git push https://<hostname>/<repo did> main




limitations
-----------

running up against some limitations of CF artifacts on
tangled:

- artifacts don't support arbitrary git filters,
  `--filter:tree:0` fails
- artifacts don't support objects >30M, so i am unable to
  work on larger repositories, or run the gitmirror service
  entirely on CF

[0]: https://github.com/bluesky-social/goat