pmacs/src
Levi Neuwirth 689fb8333d
feat(workers): a required purpose on every job and process — worker identity Stage 1
`COHERENCE.md` §9 grades the worker model "mechanism without identity",
and §0 names step 11 (background-work ownership) as one of the two
remaining thin ends of the golden journey. The mechanism half is solid —
cancellation, supersession, streaming, frame-aware draining, `*workers*`.
The identity half was absent: `PendingJob` carried no description of what
it was doing, `pmacs.workers.dispatch` discarded the registered handler
name three layers above anything that takes one, and §9's "no progress
indicator exists anywhere" was checkable and true.

Framing: `docs/worker-identity-framing.md` (revision 4, approved).

What lands:

**A required `purpose`, on the job and on the process.** Non-optional,
with no `Default`, so the compiler — not a test — is what proves every
dispatcher supplied one. `allocate` / `allocate_with_resource` collapse
into ONE private `JobSpec`-taking funnel (Q#W-1): the two-function split
existed only because one prior lane needed one extra parameter, and a
second lane doing the same produces `allocate_with_resource_and_identity`.
`register_external` gains a `purpose` parameter rather than deriving one,
because its `JobKind` is `McpRequest`/`LspRequest` for every method — a
category, not a description.

**A dispatch-name ambient (Q#W-2), read at that same single funnel.** The
capture point is Rust, not the Lua wrapper layer, because a handler
reaching straight for `pmacs._async._dispatch_*` bypasses the wrappers
entirely — and those are precisely the callers attribution exists for.
Seven rules; the ones that decide whether it is honest:

- **Rule 1 — the extent is NON-YIELDABLE, and that is ENFORCED.** Both
  supported yield APIs refuse inside it, modelled on the `commit_to`
  refusal already in `async.lua`. The guards reject BEFORE parking and
  reject UNCONDITIONALLY: one placed after `_is_complete` would fire only
  when a yield really occurred, passing under test and failing
  intermittently in production.
- **A raw `coroutine.yield` is NOT covered, and nothing here claims it
  is.** R46 is a convention, and the scheduler inspects the yielded value
  only after `coroutine.resume` returns — by which point the coroutine has
  already suspended — so no refusal sited in a yield helper is ever
  consulted. The residual is recorded in the framing §2 and in the
  suite's module docs rather than papered over with a test that would
  imply coverage this design lacks.
- **Rule 5 — unwind-safe.** A raising handler still pops. A version that
  did not would let one failure poison every later dispatch in the session
  with a stale name: the feature would stop failing loudly and start lying
  silently. The bracketing also has to preserve the tail call it replaced:
  `dispatch` was `return handler(args, opts)` and propagated EVERY return
  value, so the pop/rethrow runs behind a varargs boundary rather than a
  `local ok, result = pcall(...)` that would silently truncate a
  multi-value handler. Varargs rather than `table.pack`, because that is
  Lua 5.2 surface and LuaJIT is this project's default backend.
- **Rule 6 — compose, do not replace.** `"<name>: <purpose>"`, because
  letting the dispatcher's purpose win loses the third party again and
  letting the name win discards the only description of the actual work.

**A statusline activity indicator** — the fourth `pmacs.statusline.register`
adopter, after `mode`, `terminal` and `lsp`. A count plus the OLDEST
in-flight job's purpose ("busiest" is not a defined quantity; jobs carry
no cost estimate), and **absent entirely** when idle rather than a
zero-width segment that costs modeline width forever to say nothing is
happening. Gated by one setting, `ui.activity-indicator` (boolean, default
true, Q#W-6) — a permanently-visible modeline element is a preference
someone genuinely holds on day one. No setting for purpose capture
itself: that is substrate.

**NO WIRE CHANGE.** The indicator rides the existing `StatuslineSegments`
vector, so a fourth provider adds an element, not a variant.
`PROTOCOL_VERSION` and `ADVERTISED_PROTOCOL_VERSION` are untouched — which
is the property that lets this run beside the two lanes holding the bump
slot.

**Q#W-7 — a pre-existing defect, repaired here, and NOT one anybody has
observed.** `Handle:await()` refuses inside `pmacs.window.commit_to`
precisely so a coroutine cannot park with the frontend scope pushed
(Journey Stage 1a, Q#JR14b). But `pmacs.async.yield_to_next_tick()` also
yields, is public, and carried no such refusal — so that invariant had a
second entrance, and a coroutine could produce exactly the misrouting the
`await` guard exists to prevent. It gains both refusals here: the same
supported yield helper, the same invariant, the same edit family, so
splitting it would have preserved a known hole without reducing
integration risk.

**Reachability by a real caller is UNPROVEN.** This was found by reading
the guard family while scouting rule 1, not by reproducing a fault. No
production caller is known to yield through that door inside a commit,
and the test pins the guard rather than reproducing a user-visible bug.
Nobody should later cite this commit as evidence the bug was observed in
the wild. Its witness is a PAIR, like rule 1's: the refusal fires **and**
the commit scope is restored afterwards — a guard that raises while
leaving the scope pushed converts a silent fault into a loud one and
fixes neither.

`journey_acceptance` carries the established `commit_to` pins —
forged-destination refusal, scope-and-restore on normal return and on
raise, the await refusal, delivery to the requesting frontend. It passes
**untouched**, which is what says this closed a gap in Journey Stage 1a's
semantics rather than altering them.

What is deliberately NOT here, and why it is worth saying:

- **No `owner`, in any spelling** — not `origin`, not `subsystem` (§3).
  Populated from static per-subsystem constants it would be an origin,
  not an owner, and would confidently misattribute third-party work to a
  builtin at exactly the point §9 wants attribution. A field that asserts
  a falsehood is worse than an absent one. The slot stays empty until P3
  can fill it with a real package signal.
- **No `parent`** (Q#W-5). An unpopulated field renders as `None`
  everywhere and reads as "this job has no parent" rather than "this
  system does not track parents". Stage 3 builds the lifetime model and
  the field together.

Consequences worth recording:

- `ProcessSpec::new` takes a third argument. The 40-odd call sites are
  almost all tests; the three production ones (LSP, MCP, terminal) supply
  real descriptions. `pmacs.process.spawn`'s Lua surface keeps `purpose`
  OPTIONAL, falling back to the label — requiring it there would break
  every existing caller for no coverage the compiler is not already
  providing, and a caller's own label is not a fabrication.
- `pmacs.process.list` gains a `purpose` KEY on each row and enumerates
  exactly the same processes (Q#W-4). Terminal PTYs stay hidden: three
  acceptance suites use `#pmacs.process.list()` as a leak baseline, and
  widening the accessor would inflate all three. Stage 2's unified view
  owns that decision.
- `statusline_segments_acceptance`'s builtin-provider inventory grows to
  `["activity", "mode", "terminal", "lsp"]`. That assertion exists to
  grow when a builtin provider is added.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bqGA6s9tTUFzYpbeW3tai
2026-08-10 14:51:54 +02:00
..
audit
bin fix(lsp): close review round 1 on the resource-op delete guard 2026-07-29 11:45:43 -04:00
lua_bindings feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
packages
terminal feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
ansi.rs
async_runtime.rs feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
attach.rs feat(release): binaries on tag — Distribution Stage 1 2026-08-01 14:40:47 -04:00
attach_dispatch.rs
attach_reconnect.rs
autosave.rs
bootstrap.rs feat(bootstrap): make the ambient storage roots a parameter 2026-07-31 18:48:07 -04:00
buffer.rs wip(stage2a): name provenance plus the View rename hook 2026-07-29 17:38:21 -04:00
buffer_mirror.rs
buffer_registry.rs
builtin_packages.rs
cell.rs
code_action.rs
command.rs fix(discovery): clip command descriptions at the single-row surfaces 2026-08-10 13:52:32 +02:00
completion.rs feat(fold): Stage 2 — grid (daemon-rendered) collapse 2026-07-23 19:24:07 -04:00
completion_framework.rs
config.rs
config_registry.rs test: the report itself, at a real PTY — and §1.1 was wrong 2026-08-07 19:37:46 +02:00
crdt.rs fix(buffer): fan out generated writes, and clear the history that exists 2026-07-26 13:43:22 -04:00
daemon.rs feat(discovery): M-x rows carry descriptions — protocol v22 -> v23 2026-08-10 13:52:32 +02:00
daemon_attach.rs
definition.rs
desktop.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
diag.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
display_width.rs feat(render): unify tab-width projection 2026-07-22 15:03:30 -04:00
document_highlight.rs
editor.rs fix(discovery): clip command descriptions at the single-row surfaces 2026-08-10 13:52:32 +02:00
editor_core.rs feat(view): wrap-aware coordinates, breaking in and additive out 2026-08-07 13:07:54 +02:00
file_io.rs
fold.rs fix(fold): address PR #142 review round 1 2026-07-23 13:42:20 -04:00
fold_view.rs feat(fold): Stage 2 — grid (daemon-rendered) collapse 2026-07-23 19:24:07 -04:00
font_pref.rs
formatting.rs
frontend.rs feat(discovery): M-x rows carry descriptions — protocol v22 -> v23 2026-08-10 13:52:32 +02:00
fs.rs fix(dired): address PR #165 review round 1 2026-07-25 15:21:26 -04:00
hash.rs
help.rs feat: wire major modes through key dispatch 2026-07-21 20:25:48 -04:00
highlight.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
hook.rs
hover.rs feat(fold): Stage 2 — grid (daemon-rendered) collapse 2026-07-23 19:24:07 -04:00
inlay_hint.rs
instance_buffer.rs
instance_render.rs test(vterm): prove Stage 2 TUI integration 2026-07-21 20:16:23 -04:00
key.rs
keymap_stack.rs feat: wire major modes through key dispatch 2026-07-21 20:25:48 -04:00
keymap_tree.rs
lib.rs feat(bootstrap): make the ambient storage roots a parameter 2026-07-31 18:48:07 -04:00
locations.rs
lockfile.rs
lsp.rs feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
lsp_status.rs
lua.rs
lua_isolation.rs
main.rs docs: absorb the v1.1.0 release, and correct what it made stale 2026-08-01 18:09:59 -04:00
mcp.rs feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
menu.rs feat(fold): Stage 2 — grid (daemon-rendered) collapse 2026-07-23 19:24:07 -04:00
message_bus.rs
minibuffer.rs
optimistic.rs
overlay.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
overlay_color.rs
overlay_paint.rs feat(view): wrap-aware coordinates, breaking in and additive out 2026-08-07 13:07:54 +02:00
prepare_rename.rs
presence.rs
process.rs feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00
project.rs
project_index.rs
protocol.rs feat(discovery): M-x rows carry descriptions — protocol v22 -> v23 2026-08-10 13:52:32 +02:00
rename.rs
rope.rs
search.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
semantic_client.rs
semantic_render.rs fix(discovery): clip command descriptions at the single-row surfaces 2026-08-10 13:52:32 +02:00
semantic_tokens.rs
signature.rs feat(fold): Stage 2 — grid (daemon-rendered) collapse 2026-07-23 19:24:07 -04:00
socket_path.rs
state.rs
statusline.rs fix(panel): close Stage 2A review round 2 (2 P1, 1 P2) 2026-07-26 10:38:21 -04:00
symbol.rs
syntax.rs feat(lean4): editing surface + Stage 1 acceptance (Q#LN5, LN6, LN17) 2026-07-25 09:59:48 -04:00
text_view.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
transport.rs
view.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
window.rs feat(view): horizontal scroll, text and decorations together 2026-08-07 22:43:17 +02:00
worker.rs
workers_buffer.rs feat(workers): a required purpose on every job and process — worker identity Stage 1 2026-08-10 14:51:54 +02:00