Skip to content

Route a voice recipe through field generate - #61

Merged
ninjudd merged 4 commits into
mainfrom
voice/cli-seam
Aug 8, 2026
Merged

ninjudd merged 4 commits into
mainfrom
voice/cli-seam

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Chunk 1 of voice-generation.md ends here: one verb over two generators, with --prompt reaching field-aced and --text reaching field-voiced. The recipe's model: records which one ran, which is what §1.7 settled the naming on.

The kind split is checked before anything spawns. The schema already rejects a voice recipe carrying duration_seconds, but it does so on the way to disk, after the model has run; the CLI says --bars is a music option first, next to the namespace pre-flight that exists for the same reason.

voice_ref resolves through the project model's own lookup rather than a copy of it. Both #58 findings were two readings of "which asset is this" disagreeing — a name resolved in the wrong namespace, and a hash that pinned nothing. There is one reading now: lookupAsset, used by validate to diagnose a ref, by verifyAssetHashes to compare its hash, and by generate to turn it into the bytes the worker reads. It also reports how many ledger rows answer to a name, because a schema-valid ledger can hold two, and generation that picks the first is generation from an arbitrary voice.

A hash pins bytes, not a filename. Hashing the recording and handing the worker its path is a promise about one instant — the worker reads minutes later, after daemon start and a weights download — and re-hashing afterwards does not close the gap, since an edit undone before the run ends compares equal at both ends. So the reference is snapshotted first, and the snapshot is what gets hashed and what the worker reads.

field setup became a gate rather than a label. uv run syncs by default, so "explicit, never automatic" described the command and not the behaviour: a fresh checkout installed torch and Chatterbox as a side effect of the first generate. Starting a worker now uses --no-sync, and an unusable environment is diagnosed before the spawn instead of surfacing as a sixty-second connect timeout. Getting that check right took three passes — a .venv directory turned out to prove nothing, since uv sync --only-group dev creates one, and uv sync --check turned out to download a CPython interpreter when it cannot find one, which made the gate against automatic installation perform one. It asks for the console script uv installs with the project, then for uv sync --check --frozen --no-python-downloads, and it detects uv itself with a question that names no project. ace-generation.md §6 records all three passes.

Tested through a stub worker that the FIELD_*_PYTHON override lets stand in for a daemon: real client, real socket, real framing, no model. It holds at two points, before the reference read and after it, so a test can swap the recording under the worker and restore it before generate returns — the sequence that distinguishes the snapshot from a post-generation re-hash. Every property was checked by mutation, including against the fixes that look right and are not.

Nothing here has loaded Chatterbox. Everything verifiable without weights is verified, and the rest — that the model produces audio, at 24 kHz, wanting a normalize wrapper at the project rate — is chunk 2's first act.

Chunk 1 of voice-generation.md ends here: one verb over two generators, with `--prompt` reaching field-aced and `--text` reaching field-voiced. The recipe's `model:` records which one ran, which is what §1.7 settled the naming on.

Three things the seam needed, and each is a refusal rather than a repair.

The kind split is checked before anything spawns. The schema already rejects a voice recipe carrying `duration_seconds`, but it does so on the way to disk, after the model has run; the CLI says `--bars is a music option` first, next to the namespace pre-flight that exists for the same reason.

`voice_ref` resolves through the project model's own lookup rather than a copy of it. Both #58 findings were two readings of "which asset is this" disagreeing — a name resolved in the wrong namespace, and a hash that pinned nothing. There is one reading now: `lookupAsset`, used by validate to diagnose a ref, by `verifyAssetHashes` to compare its hash, and by generate to turn it into the path the worker reads. The per-song scoping that #58 fixed on the verify side is now the same function on the write side, not the same rule written twice.

A written hash is the hash of the bytes that were read. This is the first code in field that writes a content hash into a committed file rather than checking one somebody else wrote, so generate hashes the recording it is about to hand the model and refuses outright when that disagrees with the ledger. Recording the ledger's value instead would have been one line shorter and would have left a check-green recipe describing bytes the model never heard.

Tested through a stub worker that the `FIELD_*_PYTHON` override lets stand in for a daemon: real client, real socket, real framing, no model. It observes what generate sends and what it writes, while the live-daemon tests observe the protocol itself, so neither test asserts against its own fixture. Every property was checked by mutation; the one surviving mutant was equivalent, an explicit `undefined` that `JSON.stringify` drops.

Nothing here has loaded Chatterbox. Everything verifiable without weights is verified, and the rest — that the model produces audio, at 24 kHz, wanting a `normalize` wrapper at the project rate — is chunk 2's first act.
Comment thread src/commands/generate.ts Resolved
Comment thread src/model/project.ts Resolved
Comment thread src/cli.ts Resolved
Comment thread docs/projects/now.md Resolved
Four #61 review findings, three of which are the same mistake in different clothes: a check that describes an instant, presented as a guarantee about a run.

The reference is snapshotted before the worker starts, and the snapshot is what gets hashed and what the worker reads. Hashing the recording and handing over its path left minutes of daemon start and weights download in between, and a recording edited in that window was generated from while the recipe pinned what it used to be. Re-hashing afterwards does not close that — an edit undone before the run ends compares equal at both ends — which is how the review reproduced it, ending check-green with audio from other bytes. So the window is gone rather than watched.

An ambiguous name is refused. Two ledger rows called `ref-voice` make a project check-red, but generation never read diagnostics, so it took whichever row came first and wrote that arbitrary choice down as provenance. `lookupAsset` now reports how many rows answer to the name — a lookup can say a name is ambiguous, not resolve it — and generation stops.

`field setup` is a gate rather than a label. `uv run` syncs by default, so "explicit, never automatic" described the command and not the behaviour: a fresh checkout installed torch and Chatterbox as a side effect of the first generate. `--no-sync` makes starting a daemon only ever use an environment, and a check before the spawn names the setup command, because otherwise the refusal costs a sixty-second connect timeout to say "did not start".

The Now entry is one sentence again.

Tested through the stub worker, which now holds at two points — before the read and after it — so a test can swap the recording under the worker and put it back before generate returns. That sequence is what distinguishes the fix from the plausible one: replacing the snapshot with a post-generation re-hash still fails, because the test asserts on the bytes the worker read rather than the file's state afterwards.
Comment thread src/workers/client.ts Resolved
Comment thread docs/projects/all/ace-generation.md Resolved
The gate added for the previous round tested for a `.venv` directory, which `uv sync --only-group dev` also creates — and that is precisely what CI builds for the pyright step, so a normal checkout has one for every worker and none of them can launch. The gate passed and the sixty-second connect timeout came back, which is the thing it was added to remove.

It now asks for the console script uv installs with the project, `.venv/bin/<script>` — what `uv run` spawns, and what a dev-only sync omits — and then for `uv sync --check`, because installed is not the same as current. Both markers were checked against uv rather than reasoned about: a full sync of a project with a `[project.scripts]` entry writes the script and reports `--check` clean; `--only-group dev` writes neither.

uv's own absence is now diagnosed here too, and before the environment, since `field setup` runs `uv sync` and recommending it to someone without uv is advice that cannot work. That ordering was the one mutation that survived until a test covered both being missing at once — which is a fresh clone, and is also CI, where `pnpm test` runs before setup-uv.

The branching is a pure function over a three-fact probe. Everything about this decision is environment-shaped, so reading the checkout to test it would produce assertions that pass or fail by accident of where they ran; the probe is the only part that touches the machine.

Also renumbers the appended ace-generation.md record from §8 to §6. The plan has five sections and has never had more, so the gap was mine and would have made every later citation misleading.
@ninjudd

ninjudd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Starting review of 0590efd.

Comment thread src/workers/client.ts Resolved
`uv sync --check` leaves the project environment alone, but uv downloads a compatible CPython when it cannot find one — and the probe ran it before looking at anything else. On a machine with uv and no suitable Python, the gate against automatic installation completed a 24 MB interpreter install on its way to reporting that the worker was not installed. Reproduced against an empty managed-Python directory: the download finishes, it is not merely attempted.

uv is now detected with `--version`, a question that names no project and so cannot resolve, download or build anything. The project is only mentioned when the answer is not already decided — with uv missing or the worker not installed, the verdict is settled and the subprocess is one nobody reads. When it is asked, it carries `--no-python-downloads` and `--frozen`, so the probe can neither install an interpreter nor rewrite `uv.lock`. `--frozen` costs something worth stating: staleness is measured against the lockfile rather than against pyproject, so a lock that is itself behind reads as current. `field setup` re-locks, and a probe that writes to the repo to find out whether it may run is the worse trade.

The tests were in the wrong place, which is the part worth keeping. The verdict had been made a pure function so it could be tested exhaustively, and it was — every combination of the three facts it reads. The defect lived in the two lines that produce those facts, where a subprocess with a side effect returns a perfectly correct boolean. So the probe takes its runner as a parameter now, and the tests assert on the commands: which arguments, in which order, and which are never issued.
@ninjudd

ninjudd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Starting review of 1100627.

@ninjudd
ninjudd merged commit 90a5762 into main Aug 8, 2026
2 checks passed
ninjudd added a commit that referenced this pull request Aug 8, 2026
Check the lockfile with --locked, not --frozen

Follow-up to #61, which merged before this was caught.

The availability probe passed `--frozen` to keep itself from writing to
the repo while deciding whether a worker may start. That works, but it
is the wrong flag for the question: `--frozen` means "sync without
updating the lock", which is permission to proceed on a stale one.
`--locked` means "assert `uv.lock` will remain unchanged", which is a
check that it is current — and it is equally read-only. So a worker
whose environment matches a lockfile that no longer matches pyproject
passed the gate, launched with `--no-sync`, and failed later on the
dependency it never got, instead of being sent to `field setup`.

#61 recorded a deliberate cost for `--frozen`: staleness measured
against the lockfile rather than against pyproject. That was not a cost
of the goal, it was a cost of the wrong flag, and the record in
ace-generation.md §6 now says so.

The regression test asks real uv, because uv's semantics are the thing
under test. It syncs a project, moves pyproject past the lock without
touching the environment, and asserts the probe reports stale and the
lockfile is byte-identical afterwards. Two details it needs, both of
which cost me four failed reproductions before I understood them: the
project must be one uv does not reinstall on every pyproject edit,
because that reinstall masks the divergence and makes both flags look
identical, and the console script is placed by hand because the probe
only asks uv anything once the worker looks installed.

CI installs uv before `pnpm test` now, on both lanes. It was installed
after, so that test would have skipped in CI and run only on my machine
— which is the failure mode this gate has already produced twice.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes worker launch gating and uv probe semantics; incorrect
behavior could block valid workers or allow stale envs, but the change
aligns the gate with documented “explicit setup” intent and adds CI
coverage for the regression test.
> 
> **Overview**
> The worker **availability probe** now passes **`--locked`** to `uv
sync --check` instead of **`--frozen`**. Both flags keep the probe from
writing `uv.lock`, but only **`--locked`** treats a lockfile that no
longer matches `pyproject.toml` as out of date—so workers are refused
with “run `field setup`” instead of starting with **`--no-sync`** and
failing later on missing deps.
> 
> **`lockfile.test.ts`** exercises this against real `uv` (skipped when
`uv` is absent). **`setup.test.ts`** asserts the probe argv includes
**`--locked`** and never **`--frozen`**. **`ace-generation.md`** §6 is
updated to record that the old “staleness vs lockfile” tradeoff was from
the wrong flag, not the design goal.
> 
> **CI** runs **`astral-sh/setup-uv`** **before** **`pnpm test`** on
Linux and macOS so the new test is not unconditionally skipped in CI (it
was only running locally when `uv` was installed after tests).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
daf9e29. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@ninjudd
ninjudd deleted the voice/cli-seam branch August 8, 2026 06:04
ninjudd added a commit that referenced this pull request Aug 8, 2026
Make field-voiced work against the actual model

Five merged pull requests built this worker and every one of them said,
accurately, that nothing had loaded Chatterbox yet. Generating creek's
line is the first time anything did, and it found three things — two of
them mine.

`chatterbox-tts` needs `pkg_resources` and nothing in the graph asks for
it. Chatterbox watermarks every generation through `perth`, whose
`perth_net/__init__.py` imports `pkg_resources`; Python 3.12 no longer
ships it and uv does not install it unasked. perth catches that
ImportError and sets `PerthImplicitWatermarker = None`, so the failure
surfaced one layer up as `'NoneType' object is not callable` from
Chatterbox's constructor, naming neither perth nor setuptools. Declared
as `setuptools>=70,<81` — the upper bound is not decoration, since
setuptools removed `pkg_resources` itself and 83.0.0 satisfies a bare
`>=70` while leaving perth exactly as broken.

The #60 leak fix never worked. Restoring the builtin voice before each
unreferenced variant went through `copy.deepcopy(model.conds)`, and
torch refuses: "Only Tensors created explicitly by the user (graph
leaves) support the deepcopy protocol." Some of those tensors come out
of a forward pass. The fix was right about the leak and inoperative
against the model, and it was verified by reading `chatterbox/tts.py`
rather than by running it — which is precisely the distinction that
review round could not make, because loading the model was the one thing
the harness existed to avoid. `clone_conds` rebuilds the dataclass field
by field with each tensor detached, which is the same shape Chatterbox's
own `save`/`load` round-trip uses.

A model-side failure left no trace. The lifecycle turned every exception
into a one-line protocol error and logged nothing, so the first of these
presented as a single sentence with no stack anywhere, and diagnosing it
meant rebuilding the whole model load by hand outside the daemon. The
wire still carries one line; the daemon's log now also carries the
traceback that explains it.

The regression test for that last one gets its own interpreter rather
than the shared harness's. The existing one prefers
`python/voiced/.venv` when it exists, which after a real `field setup
voiced` contains Chatterbox — so a test wanting the backend to fail on
import would instead load a 2 GB model, and would do so only on machines
where setup had been run. Stating the precondition beats inheriting it;
that is the same ambient-state trap the environment gate hit twice in
#61 and #62.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes voice worker runtime dependencies, conditional cloning on
every default-voice variant, and error logging; no auth surface, but
incorrect cond cloning could still affect voice provenance.
> 
> **Overview**
> Fixes **field-voiced** so the first real Chatterbox load works:
**`setuptools>=70,<81`** is declared so **`perth`** can import
**`pkg_resources`** (otherwise **`'NoneType' object is not callable`**
with no useful name on the wire).
> 
> Replaces **`copy.deepcopy(model.conds)`** with **`clone_conds`**,
which rebuilds conditionals field-by-field with detached tensor
clones—the prior #60 leak fix failed on real tensors from the forward
pass.
> 
> The shared worker daemon now logs full tracebacks to stderr (the
voiced log) on request and generation failures while clients still get
one-line protocol errors.
> 
> Adds a Vitest block that uses a **bare** Python (no Chatterbox) so a
backend import failure is asserted to appear in **`voiced.log`**,
avoiding the main harness’s venv that would load the model.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b520227. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
ninjudd added a commit that referenced this pull request Aug 8, 2026
Reported from real use: with `field play --loop --watch`, the reload
swap at the wrap sometimes clicks when a rebuild replaces the file
mid-loop. watch.md §1.1 promised you always hear whole passes and it
delivers that — the defect is the seam between two of them, which the
decision never claimed to have solved and nobody has looked at since.

Recorded rather than fixed, and recorded honestly: it is intermittent,
reported from listening rather than from a test, and neither reproduced
nor diagnosed. A line that says so is worth more than one implying
somebody has already characterised it.

One sentence, per the list's own contract — the same thing the #61
review pulled me up on for `now.md`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only backlog note; no runtime or protocol changes.
> 
> **Overview**
> Adds a **Next** backlog item for an intermittent **audible loop
takeover** defect: with `field play --loop --watch`, the reload swap at
the loop wrap can **click** when a rebuild replaces the mix mid-loop, so
seamless `--loop --watch` is not fully achieved.
> 
> The entry points to `watch.md` §1.1 (whole-pass swap design) and
states the issue was **reported from use on 2026-08-08**, is **not yet
reproduced**, and is recorded honestly rather than implying diagnosis or
a fix.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9002f70. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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