Repository navigation
Extract the worker lifecycle so voice can be the second client - #59
Merged
Merged
Conversation
field-aced's main.py was 230 lines of daemon-lite lifecycle — flock ownership, NDJSON framing, the single-flight generation gate, idle-exit-but-never-mid-generation, the SIGTERM unlink — of which exactly two things were ACE's: the job shape and the pipeline. Copying it for field-voiced would have duplicated all of that, including the stale-socket bug its own comments record finding live, into two files that must then be fixed twice. ace-generation.md §3 said the protocol was built so ACE would be "the first client, not a special case". This is that claim being cashed rather than restated: field_worker owns the lifecycle, a worker supplies a Backend (parse_job, generate, loaded), and field_aced is now 25 lines plus its own job and adapter. The extraction is verifiable rather than hopeful. src/aced/client.test.ts spawns the real Python daemon and exercises spawn, handshake, request validation and quit; it passes unchanged against the refactored daemon, which is what says behaviour was preserved. Both packages are pyright strict with zero errors — field_worker ships a py.typed marker, without which pyright rejects it as untyped at the aced boundary. field_worker is deliberately dependency-free: socket, framing and lifetime, nothing else. That is what lets it install into any worker's environment without a model stack, and it is the same property that lets the protocol tests run on a bare interpreter. Also generalised the venv ignore to python/*/.venv/ — uv self-ignores inside the venv, but the repo's own rule named aced specifically and there is about to be a third worker.
…t declares #59 review, both findings confirmed by reproducing CI's exact commands against a wiped venv — 15 errors, the reviewer's count. The Linux job runs `uv sync --only-group dev` deliberately: the model environment is far too heavy to install for a type check. That excludes every production dependency, and field-worker had just become one, so pyright could not import it. It is now resolved by extraPaths instead — the cheap install stays, and the real source is what gets checked, which is what the protocol tests already do with PYTHONPATH. The second finding is the one worth keeping. field-worker's pyproject declares typeCheckingMode = "strict" and nothing ran it, so the gate existed only in the file that asked for it. CI now checks both packages; field-worker has no production dependencies at all, so its sync is trivial. I ran pyright locally before opening the PR and it passed, because I had just synced the package by hand. A green check in a dirty environment says nothing about a clean one, which is the whole reason the Linux job exists.
ninjudd
commented
Aug 8, 2026
ninjudd
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed current head 1f7bbf6 against main: no findings.
I inspected the lifecycle extraction and its ACE call sites, then verified the new head after the clean-Linux fix: both dev-only uv sync + strict pyright commands pass with zero errors, the live Python-daemon protocol tests pass (spawn, handshake, invalid request, quit), pnpm typecheck and diff checks pass, and both GitHub jobs are green. The current head also gates python/worker separately, so the new package’s strict config is enforced rather than declarative only.
ninjudd
added a commit
that referenced
this pull request
Aug 8, 2026
`field-voiced` — voice as the second client of the lifecycle #59 extracted. Worker, protocol, adapter, TS client, live protocol tests. No CLI wiring yet; that is the next slice. ## The adapter is wired against the wheel, not the README I downloaded and read `chatterbox-tts` 0.1.7 rather than working from documentation, and three things that reading settled are recorded in the adapter's docstring: - **`from_pretrained` handles the MPS-unavailable fallback itself**, so we pass a device preference rather than probing for one. - **`conds.pt` ships as a builtin voice.** That is what makes `audio_prompt_path=None` a genuine default voice rather than an error path — the configuration bloom is about to use, now confirmed to exist rather than assumed. - **`model.sr` is 24000.** A voice variant is therefore at no project rate, so creek will wrap it in a `normalize` sound — the rule chunk 5 just rebuilt around our own resampler. The bloom half depends on work that already shipped. ## The client extraction was a trigger, not a preference `src/aced/client.ts` carried this: *"The deliberate duplication with audiod/client.ts is small and tolerated until a third daemon argues for a shared base."* `field-voiced` is the third daemon. Copying 226 lines while that sentence sat in the file would have been the same shape of defect the last several reviews kept finding — a claim written down and then not honoured. What was aced-specific turned out to be **seven strings and a job type**. The generate *response* is shared too, since `GenerationOutput` became shared in #59. **`audiod`'s client stays where it is**, deliberately: it spawns a C++ binary rather than a uv project, and its vocabulary is transport rather than generation. Framing is all it shares, and sharing framing alone would tangle both sides more than either is now. ## The existing harness paid for itself again The first draft of `connectTo` built a base `WorkerClient` and cast it to the subclass. That typechecks; at runtime it dies with `generate is not a function`. The live aced tests caught it on the first run, and the constructor is threaded through now. That is the second time on this branch — the first was the lazy-import constraint those tests imply, which I learned from #59's review rather than from planning. ## Verification 360 tests. `field-voiced` gets the same live harness as `field-aced`: spawn, handshake, unknown op, job validation, all against the real Python daemon **with no torch installed**. It is also what would notice if a future edit imported chatterbox at module scope, which would silently cost that coverage. Both Python packages are pyright strict and CI gates all three — `worker`, `aced`, `voiced`. Adding a package that declares strict typing with nothing running it is exactly what #59's review caught, and doing it a third time silently would have been worse. ## What is not here No `field generate` routing yet, and no real model run: proving the default voice end to end means downloading ~2 GB of weights, which belongs to the first real run rather than to CI. What is proven is that the job parses, the daemon serves, and the API the adapter calls is the API the wheel exposes. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New long-lived daemon with model loading and file I/O, but it mirrors the proven aced worker pattern with lazy imports and a quarantined adapter boundary. > > **Overview** > Adds **`field-voiced`**, a new Python uv worker that plugs into the shared **`field_worker`** daemon lifecycle (same NDJSON socket pattern as **`field-aced`**). > > The worker defines a **`VoiceJob`** wire shape (`text`, `seed`, `variants`, `output_dir`, optional **`voice_ref`**) and a **`Pipeline`** that lazily loads **Chatterbox TTS 0.1.7**, generates numbered WAV variants with per-variant seeds, and returns shared **`GenerationOutput`**. Untyped Chatterbox/torch imports are quarantined in **`adapter.py`** so pyright stays strict elsewhere and CI can run without torch. > > CI now runs pyright on **`python/voiced`** alongside **`worker`** and **`aced`** (`uv sync --only-group dev`). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ff1b2c1. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
ninjudd
added a commit
that referenced
this pull request
Aug 8, 2026
A worker that parses a job by reading the keys it knows will ignore the rest, which is the friendliest possible failure and the wrong one here. Dropping an unrecognised field *succeeds* — and the recipe written afterwards then records an input the model never received, which is the provenance-that-lies failure the whole commit-the-output design exists to prevent. Found by living it earlier today. `field generate --exaggeration 0.3` reached a field-voiced daemon started before #65 taught it the field. Nothing was malformed, so it generated at default pacing, and only killing the process stopped a take landing in bloom under a recipe claiming 0.3. The daemon-lite lifecycle exists so a model loads once and the process outlives many jobs, which means the long-lived daemon is by construction the one most likely to be older than the CLI talking to it — "it was already running" is the normal case, not an edge one. `reject_unknown` refuses any request key the job spec does not declare. That is render-pipeline.md decision 6's fail-closed rule applied to the wire instead of to plans, and both workers inherit it from the shared lifecycle — the third thing #59's extraction has paid for. The allowed set derives from the job dataclass's own fields rather than sitting beside them as a list. On both workers the field names *are* the wire keys, so a field added to the spec cannot be forgotten here, and this check can never become the reason a valid request is refused. That is load-bearing rather than tidy: mutating it to a hardcoded set makes the existing delivery-knobs test fail, because `exaggeration` stops being allowed. What it cannot fix: a daemon predating this change still ignores what it does not know, since the code that would refuse is the code it lacks. This protects every field added from here on, which is the half that was going to bite us again. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes wire validation for both generation workers; behavior is fail-closed on unknown keys (good for provenance) but can break clients that sent extra fields that were previously ignored. > > **Overview** > Workers no longer **silently ignore** request keys outside the job dataclass spec. **`reject_unknown`** in shared `field_worker.protocol` compares the wire payload to dataclass field names plus `id`/`op`, and **`ValueError`** rejects anything extra before generation runs—so recipes cannot record parameters the model never saw (e.g. **`exaggeration`** on an older field-voiced daemon). > > **field-aced** and **field-voiced** call it at the start of **`GenerateJob.from_request`** / **`VoiceJob.from_request`**. Live client tests assert refusal for **`guidance_scale`** and **`temperature`** while the daemon keeps serving. > > Docs add ace-generation.md §7 on the provenance failure and that already-running daemons without this code are unchanged. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dc23bcd. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for
field-voiced. No voice code yet — this is the refactor that decides whether there will be one worker's worth of lifecycle in the repo or two.The choice
field-aced'smain.pywas 230 lines, of which exactly two things were ACE's: the job shape and the pipeline. Everything else — flock ownership, NDJSON framing, the single-flight generation gate, idle-exit-but-never-mid-generation, the SIGTERM unlink — is what any generation worker needs.Copying it for voice would duplicate all of that, including the stale-socket bug its own comments record finding live ("a pkill during development left a stale socket a client then raced"), into two files that must then be fixed twice. That is the parity seam render-pipeline.md decision 1 rejected in the DSP, arriving by a different door.
ace-generation.md §3 said the protocol was built so ACE would be "the first client, not a special case". This is that claim being cashed rather than restated.
The shape
field_workerowns the lifecycle. A worker supplies aBackend:field_aced/main.pyis now 25 lines.field-voicedwill be its own job dataclass and a Chatterbox adapter, and nothing else.field_workeris deliberately dependency-free — socket, framing and lifetime. That is what lets it install into any worker's environment without dragging a model stack behind it, and it is the same property that lets the protocol tests run on a bare interpreter.Why this is verifiable rather than hopeful
src/aced/client.test.tsspawns the real Python daemon and exercises spawn, handshake, request validation and quit — ACE's imports are lazy, so no model environment is needed. It passes unchanged against the refactored daemon, which is what says behaviour was preserved rather than merely rearranged.That harness also set a constraint on the voice adapter I would otherwise have found late: Chatterbox's imports must be lazy too, or
field-voicedloses the same coverage.Verification
346 tests pass. Both Python packages are pyright strict, zero errors —
field_workerships apy.typedmarker, without which pyright rejects it as untyped at thefield_acedboundary.pnpm typecheckclean.Also generalised the venv ignore to
python/*/.venv/: uv self-ignores inside the venv, but the repo's own rule namedacedspecifically and there is about to be a third worker.Note
Medium Risk
Refactors the ACE daemon’s socket and concurrency lifecycle into shared code; behavior should be equivalent but any regression affects all future workers, not just ACE.
Overview
Introduces a new dependency-free
field-workerpackage that owns the shared generation-daemon lifecycle (unix socket flock, NDJSON framing, single-flight generate gate, idle exit, SIGTERM socket cleanup) and a genericBackendprotocol plusserve()entrypoint.field-acedis slimmed to ACE-specific pieces:GenerateJobparsing, the ACE-StepPipeline, and amain()that callsserve()withPipeline(). Shared wire types (GenerationOutput,ok_response/error_response, request field helpers) move from aced intofield_worker.protocol; the adapter gainsparse_job()soPipelinesatisfiesBackend.Tooling / tests:
field-aceddepends on the path-localfield-workerpackage;.gitignorebroadens venv ignores topython/*/.venv/. TS aced client tests andFIELD_ACED_PYTHONdocs addpython/worker/srconPYTHONPATHalongside aced sources so live daemon tests still run without a model env.Reviewed by Cursor Bugbot for commit 11dd584. Configure here.