Skip to content

Plan the remote: login, clone, push, and a read-through cache - #168

Merged
ninjudd merged 2 commits into
mainfrom
claude/remote-plan
Sep 7, 2026
Merged

ninjudd merged 2 commits into
mainfrom
claude/remote-plan

Conversation

@ninjudd

@ninjudd ninjudd commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

The audiofield.io plan in okamnesiac/audiofield (audiofield-io.md §6, PR #14 there) specifies the CLI verbs the site needs from Field and asks for a plan here to own them. This adds docs/projects/remote/readme.md as a draft at priority: next: field login/logout over a device-code flow, field clone <owner>/<project> that expands the short name and warms the cache, field push/pull that follow Git with a content-addressed artifact offer, a read-through remote cache in field build, an optional license: key in field.yaml, and --json on explain and arrangement.

The plan is grounded against main at 7c84226 rather than against the site's assumptions. The cache is five private functions in src/graph/build.ts and the hook point is the miss branch of buildNode right after readAction; CAS reads are never verified today, so a fetched blob has to be hashed before it lands at casPath(), which the tamper-guard comment in the same function already argues for. The remote client is injected where GeneratorRunner is, explain() consults it too so field explain cannot lie about what build would fetch, and Node 24's global fetch keeps the dependency list at three. The manifest is z.strictObject, so license: is a schema arm plus a projectOrder entry plus a diagnostic beside verifyAssetHashes, and the plan says how it relates to the per-asset license: that splice.md already designs. Eleven decisions carry their rejected alternatives; ten open questions are listed for the sync on the site plan, the first being priority against recording and ui.

Nothing here reopens V1 scope: a read-through cache and a push are neither cloud collaboration nor remote rendering, and the plan says so.

Testing

From the repository root:

project list
project check
project show remote | head -20

project list prints remote under next as draft beside ui, project check prints Project plans are valid., and show prints the frontmatter, the title and the goal. Before this change project show remote fails with no such project. The change is a plan only, so pnpm typecheck and pnpm test are unaffected and were not run.

https://claude.ai/code/session_01GMG3KG8YX7mAp7dKrgPQQq

audiofield.io's plan (okamnesiac/audiofield, audiofield-io.md §6)
specifies the CLI verbs it needs from Field and asks for a plan here
to own them. This records that plan as a draft: four verbs over Git,
a build that asks the remote for an artifact before rendering one,
a license key in the manifest, and --json on explain and arrangement.

The remote is a second action cache keyed by the action key that
already exists, never a second source of truth, and nothing in it
renders remotely or collaborates in the cloud, which docs/README.md
keeps out of V1. The decisions are grounded against main at 7c84226:
the cache is five private functions in build.ts with an unverified
CAS read, the runner is injected and the remote client should be,
the manifest is strict, nothing prints JSON, and every temp-project
test already spawns git through init().

Claude-Session: https://claude.ai/code/session_01GMG3KG8YX7mAp7dKrgPQQq

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔭 Projector review · model claude-opus-5[1m] · effort xhigh · CHANGES REQUESTED · took 3m 16s

1 finding thread: 0 resolved, 1 open — this review opens it.

The readiness gate does not apply here, and I want that visible rather than assumed. The plan is status: draft / priority: next, which makes no executable-readiness claim, so §9's ten open questions — priority against recording and ui, keychain versus ~/.field/credentials, push as verb or hook, reads on by default, missing git-lfs, recipe-only clones, the name, --json scope, what pull does to .field/out, and project against asset licenses — do not withhold anything. priority: next schedules the work and is not a readiness claim either. project check passes.

§2 is the part of this plan that will be trusted, so I checked all of it rather than sampling. Thirteen of fourteen claims are exact against main at 7c84226, which is the commit the section says it verified against:

  • init.ts lines 68–73 really are the git init throw and the git lfs install --local warn-and-continue, on those lines.
  • version.ts:73 is the spawnSync inside the function-local git closure.
  • cacheDir, casPath, actionPath, readAction, writeAction are all private, all in build.ts; buildNode is at 180 and explain at 347, both as cited.
  • ActionEntry is { rule: string; outputs: { sha256: string; bytes: number }[] } and build(project, graph, nodes, runner = defaultRunner, signal?) — both quoted correctly.
  • readAction really does check only existence (plus a corrupt-JSON path that self-heals), so "checks that each output exists and nothing else" is fair.
  • The tamper-guard sentence is quoted verbatim from build.ts:251-254.
  • BuildOutcome carries cached: boolean and committed?: boolean, and the comment there makes exactly the distinction §2 attributes to it.
  • projectSchema is z.strictObject({ field: z.literal(1), name: slug, sample_rate }), character for character, and loadFile is at project.ts:290.
  • splice/readme.md exists and does design a per-asset license.

The fourteenth is the finding below.

Citations resolve, including the awkward one. Every in-repo plan reference — bloom-in-tree.md §2 and §3, plugin-hosting.md §2, project-core.md §5 — points at a section that exists. audiofield-io.md is cited nine times and has no plan here, which is the shape of a silently broken citation; it is not one, because line 15 names the repository and the path inside it (okamnesiac/audiofield, docs/projects/audiofield-io/readme.md there) before using the short form. Worth saying explicitly since a reader grepping this repo for it will find nothing and should know that is expected.

All eleven decisions in §5 carry the alternative they beat, which is what this repo asks of a (DECIDED) record. Two of them state it as prose rather than a "Rejected:" clause — decision 1's "The alternative was a release upload…" and decision 6's contrast between refusing on clone and warning on init — so a grep for the keyword undercounts; reading them, both are complete.

Not filed, but worth flagging for §6's sequencing: decision 11 puts the remote client at the same injection seam as the runner, and #163 (ui/first) is still open against a graph.ts and build.ts that have since moved twice under it. Nothing in this plan depends on that, but whichever lands second pays for it.

Comment thread docs/projects/remote/readme.md Resolved
Review on #168 (minjudd) caught the one wrong claim in section 2:
materialize() in src/graph/build.ts is a copy-to-temp plus rename,
with a comment explaining that an in-place copy would truncate the
artifact a playing pass is streaming (watch.md 1.6). The plan called
it a bare copyFileSync, which invited an implementer adding the hash
check to write hash-then-copy-in-place and reintroduce exactly that
truncation. The point stands: CAS reads are unverified and a fetched
output must be hashed before it lands. The section now says where
that check goes, on the fetch path, and what the swap protects.

Claude-Session: https://claude.ai/code/session_01GMG3KG8YX7mAp7dKrgPQQq

@minjudd minjudd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔭 Projector review · model claude-opus-5[1m] · effort xhigh · APPROVED · took 1m 28s

1 finding thread: 1 resolved, 0 open.

2ad7a93 is clean. The one finding is fixed, and fixed better than I asked for.

I suggested wording that kept §2's point while carrying the constraint. The replacement does that and then adds the part I had left implicit — where the hash check belongs:

materialize() copies from the CAS without hashing (copy-to-temp plus rename, never in place, so a playing pass is not truncated under its reader — watch.md §1.6). … a fetched output must be hashed before it lands at casPath(), and the hash check belongs on the fetch path, not inside materialize, whose swap is the constraint to keep.

That last clause is what actually closes the hazard. My concern was not the wording itself but that an implementer would edit materialize to add hashing and drop the swap while doing it; naming the fetch path as the right seam says so directly, rather than leaving the reader to infer it from a parenthetical.

The diff is confined to that bullet — eleven insertions and seven deletions in one file, nothing else touched. Frontmatter is unchanged at status: draft / priority: next, so the readiness gate still does not apply and §9's ten open questions still withhold nothing. project check passes. Every in-repo citation still resolves — bloom-in-tree.md §2 and §3, plugin-hosting.md §2, project-core.md §5 — and the nine audiofield-io.md references remain the deliberate cross-repo ones disclosed at line 15.

One note on the new citation, which is not a finding. watch.md §1.6 is copied verbatim from the comment it is describing (build.ts:238 on main), so it is not this diff's invention, and it does resolve in substance: watch.md §1 is a six-item decision list whose decision 6 is "Slow rebuilds don't glitch. Builds land atomically in the CAS", which is exactly the atomic-swap point being made. It is worth knowing that the contraction is not greppable — watch.md has no heading 1.6, and this repo's usual spelling for that is the longer form this plan's own decision 6 uses, bloom-in-tree.md §2 decision 3. Nothing to change here; if it is ever worth normalising, the code comment is where it starts.

Merging is still yours.

@ninjudd
ninjudd merged commit 24b7499 into main Sep 7, 2026
1 check passed
@ninjudd
ninjudd deleted the claude/remote-plan branch September 7, 2026 23:51
ninjudd added a commit that referenced this pull request Sep 8, 2026
…ote (remote.md chunks 2–3, clone half of 4) (#171)

The CLI half of audiofield.io begins here, per `remote.md` (#168): the
remote is a second action cache keyed by the action key that already
exists, never a second source of truth, and nothing in Field renders
remotely or edits collaboratively. This lands chunks 2 and 3 and the
`clone` half of chunk 4 together, because the warm *is* the read-through
with `git clone` in front of it and `login` is what makes a private
clone possible, so none of the three was verifiable without the others.
Chunk 1 (`--json`, `license`) and `push`/`pull` remain; the plan's §10
records the split.

## What is here

- **`src/git.ts`** (decision 10): one way to spawn Git, throwing Git's
own stderr as the message. `init` and `version` move onto it; they had
disagreed on whether a failure throws or returns `undefined`.
- **`src/remote/`**: `protocol.ts` carries `REMOTE_API_VERSION = 1`, the
paths, and the request and response shapes as zod schemas so the site's
tests can import the same file; `client.ts` is one request per method
over Node's global `fetch` with a hello checked once per client and four
error kinds; `credentials.ts` is the keychain store through `security`
on macOS and `~/.field/credentials` (mode `0600`) elsewhere, behind one
interface with the `security` call injected; `origin.ts` reads the
remote from Git; `cache.ts` is the read policy the engine sees.
- **The read-through in `build()` and `explain()`** (§3.4): a local miss
asks the remote, a hit downloads each output to a temp file, hashes it,
compares against the entry's hash and size, and only then renames it
into the CAS and writes the entry. The build says `fetched` where it
said `cached`; `explain` reports the same. A miss is silent; an
unreachable remote, a refused token, or a protocol skew prints one line
on stderr once per build and the remote is not asked again that build; a
download whose hash disagrees is discarded and reported. `--no-remote`
skips it for one build or explain. `play` and `export` read through;
`--watch` and the live session do not (decision 15, §9.12).
- **`login`, `logout`, `git-credential`** (§3.1): the RFC 8628 device
flow, the token stored per remote and never printed, `FIELD_TOKEN` as
the override that is read and never written, `--version` growing a line
that names the remote, where its URL came from, and whether a token is
held. The hidden `git-credential` command answers Git's `get` for a
`git.<site>` host with the token filed under `<site>`.
- **`clone <owner>/<project> [dir]`** (§3.2): refuses before touching
the network without `git-lfs`, resolves the short name through the API,
clones with `http.proactiveAuth=basic` and the credential helper
configured in the new checkout (only for an audiofield git host), then
warms every song's `main` and every rule node beneath it — the index as
well as the bytes, because `readAction` is what makes a hit and a key is
computed from its dependencies' output hashes. A full URL is accepted
anywhere a short name is. The warm writes only under `.field/`, so a
warmed checkout is a clean one.
- **Docs**: `docs/remote.md` is new and linked from the README,
`AGENTS.md`, `architecture.md`, and `build-graph.md`. The plan flips to
`in-progress` at `priority: now`, gains decisions 12–15 in §5, the path
table in §4, an answer under each §9 question, two new questions (§9.11,
§9.12), and a §10 progress log.

## Decisions this PR makes, for the record

**Which remote** (decision 12): the origin's host `git.<site>` implies
the API at `<site>`, and the last two path segments name the project.
`FIELD_REMOTE` replaces the API base and nothing else, which is what
lets a test clone from a bare repository at
`/remotes/howlo/chemicals.git` and talk to an in-process stub about
`howlo/chemicals`. `FIELD_REMOTE=off` disables reads. An origin Field
does not recognize has no remote, so nothing about an ordinary project
changes.

**The engine's default is no remote** (decision 14, refining 11):
`build()` and `explain()` take a `RemoteReads` and do nothing without
one; `remoteReads()` in `src/commands/build.ts` is the command layer's
resolution. The alternative would have had every build test spawn `git
remote get-url`.

**A recipe-only song cannot be warmed** (§9.11, the one question for the
sync): a generative request with no takes mints no node, so nothing
above it has an action key and the remote cannot be asked. `clone`
reports it per song in the words `build` uses (`tall-grass: not warmed —
//songs/tall-grass/gen:topline has no takes yet`). Decision 9 assumed
the remote could answer for such a project; by key it cannot, and by
label it would need a `play` that skips the graph walk. The honest v1
answer is `field generate`, which is what bloom-in-tree.md §7 already
says.

**Priority** (§9.1): set to `now` because implementation began the night
the plan merged, at Justin's ask; flip it back if that is wrong, the
plan notes why it moved.

**Git's side of the token, after the live host and a second read**
(decisions 6 and 13 amended, plan §10): `clone` persists no
`http.proactiveAuth` — with it set and no credential, Git asks for a
username before its first request, so an anonymous clone or any checkout
after `logout` would prompt; `push` and `pull` will pass it per
invocation. The credential helper is registered behind an empty value
that resets the helper list for the host, so a global osxkeychain helper
never caches a copy of the token, and it answers `FIELD_TOKEN` or the
`FIELD_REMOTE` token only for the remote the shell points at, never for
some other `git.*` host it happens to be asked about. Every clone
carries the LFS filters as `-c` config and runs `git lfs install
--local`, so pointer files cannot land even where `git lfs install` was
never run globally. The client bounds every request (15 s) and download
(30 s idle), refuses to follow an API redirect, and surfaces a 400's
message. A failed warm reports `not warmed — <reason>` per song;
`FIELD_REMOTE=off` refuses to expand a short name; the destination check
runs before any request.

## What this does not do yet

The site does not serve the API: against `audiofield.io` today every
verb says `https://audiofield.io is not an audiofield remote (no
/api/hello)` and stops, which is the protocol check refusing rather than
a crash. Every path is tested against an in-process `node:http` stub
(`src/testing/fake-remote.ts`) and a real bare Git repository. `push`,
`pull`, the artifact offer, `--json`, and `license` are the next PRs.
The `security add-generic-password` call takes the secret on argv,
visible to `ps` for the instant of the call; the tool has no stdin form,
and a native binding was what decision 5 declined.

## Testing

From the checkout, on this branch:

```
pnpm install --frozen-lockfile
pnpm typecheck
pnpm build
pnpm test
```

`pnpm build` makes the `field` on your PATH current. `pnpm test` runs
781 tests (721 on main); the daemon tests need `field-audiod` built
(`pnpm build:native`) or `FIELD_AUDIOD` pointing at one, which is
unchanged by this PR. The new files alone:

```
pnpm vitest run src/remote src/commands/login.test.ts src/commands/clone.test.ts src/graph/remote-cache.test.ts src/commands/version.test.ts
```

The one to watch is `src/commands/clone.test.ts`: it builds a project
with a fake runner, commits it (LFS audio included), pushes to a bare
repository under a temp directory, serves the short name from the stub,
clones through `field clone`, and then builds the clone with a runner
that throws if anything renders. `src/graph/remote-cache.test.ts` has
the tamper test the plan asks for: a blob whose bytes disagree with its
entry never appears under `.field/cache/cas/`. The clone test also
asserts the LFS audio arrived intact through the `file://` remote
wherever the `git-lfs` binary exists, since the clone carries its own
filters; only a runner with no `git-lfs` at all prints `clone.test:
git-lfs is not installed here; skipping the LFS transfer assertion` —
the CI log for this PR says which.

The version line, in the example project:

```
cd examples/bloom
field --version
```

The third line is new: `remote https://audiofield.io (default) not
logged in`. Before this PR there was no such line. `FIELD_REMOTE=off
field --version` says `remote off (FIELD_REMOTE=off)`, and
`FIELD_TOKEN=x field --version` says `token from FIELD_TOKEN` without
printing `x`.

The verbs against the site as it stands, from any directory:

```
field clone howlo/chemicals
field login
```

Both stop at the protocol check and exit 1, and `clone` creates no
directory. Today the apex redirects every path to field.one, so the line
is `https://audiofield.io redirects /api/hello to
https://field.one/api/hello — the API must be served directly`; once the
redirect is gone and before the API lands it becomes
`https://audiofield.io is not an audiofield remote (no /api/hello)`.
`FIELD_REMOTE=http://127.0.0.1:1 field login` prints `http://127.0.0.1:1
is unreachable`. If either hangs or creates a `chemicals` directory,
that is the bug. `FIELD_REMOTE=http://staging.example field login` is
refused before any request: `refusing to send a token in the clear to
http://staging.example — a remote must be https (plain http is allowed
only for localhost)`; before `5b206c1` it would have tried to connect.

Unchanged behaviour to confirm: in `examples/bloom`, `field explain
//songs/creek/track:drums` prints what it did before with no `remote:`
line, because the example's origin is GitHub and Field has no remote for
it, and `field check` still says `ok`. `field build --help` and `field
explain --help` each list `--no-remote`; `field --help` lists `login`,
`logout` and `clone` and does not list `git-credential`, which is hidden
because only Git calls it.

Nothing here writes outside the checkout unless a site answers a `field
login`, which none does yet; the tests write only under temp
directories.

https://claude.ai/code/session_015bwFCc1p8PvPiykdhhCWVs
ninjudd added a commit that referenced this pull request Oct 10, 2026
docs/projects/README.md asks for a settled decision to carry the
(DECIDED) marker, and AGENTS.md tells agents not to reopen one that
does. §3 records each choice with the alternatives it beat but carried
no marker, so the agents building chunks 1 to 3 had no signal that it
is settled. The heading now reads (DECIDED, 2026-10-10), as the remote
plan's did in the pull request that proposed it (#168).

The sclang bullet said the voice host's code builds chunk 4's NRT
score, which §7 question 3 leaves open, so it now says the code can.
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