feat(linkedin-studio): N12 — editions-register CLI + phaseLog-telemetri (TDD) [skip-docs]

Two things were structurally invisible: WHICH editions are in flight (readable
only by opening every series folder's edition-state.json by hand) and HOW LONG an
edition takes (not recorded anywhere). At two editions a week both are
load-bearing — a production line cannot be dimensioned on numbers never collected.

Register (scripts/editions, new module beside distillate.ts): one row per edition
in ${LINKEDIN_STUDIO_DATA}/editions/register.json — series, edition, title, series
path, current phase, next action, slot, startedAt/completedAt. Data-dir placement
(M0) because the register spans ALL series; the distillate is per-series and stays
in the series root. Verbs: register-upsert / register-list / register-complete.

phaseLog: articles.NN.phaseLog[{phase, completedAt}] in edition-state, additive so
schemaVersion stays 1 — pre-N12 editions load unchanged and their absence reads as
"not measured", never as zero. Per-article, mirroring articles.NN.phase: lead time
is a property of an edition.

One call per transition, both writes: newsletter.md gains a phase-transition
protocol defined once beside the resumption table, and all 16 canonical phases
invoke it. register-upsert appends the phase-log entry AND mirrors the register
row. Deliberately one command, not two — telemetry the command layer must remember
to write separately is incomplete inside a week, and an incomplete log measures
nothing. Step 10 closes the row and prints the measured lead time.

Mirror discipline: resumption still reads edition-state.json and only that. Delete
the register and the next transition rebuilds it; a failed upsert is reported, never
a reason to stop the pipeline. startedAt is the one unrecoverable value, so it never
moves — re-upserting a completed edition reactivates the same row (what
/linkedin:pivot does), keeping the clock on real elapsed production time.

Deterministic: no clock in the core (now passed in, --at/--now at the edge, as the
distillate takes lockedAt). Idempotent where a re-run is legitimate (repeated
transition logs once; completing twice keeps the first completedAt), not where it is
real work (a phase recurring after another one is logged again — a pivot back through
cleared gates is production time that happened). Missing facts are refused at the
edge, not defaulted: a row naming the wrong phase is worse than no row.

TDD (Iron Law): all three test files written first and verified red before any
implementation existed (register.test.ts + editionState.test.ts failed on missing
modules, cli-register.test.ts on "unknown command: register-upsert").

Suites: editions 27 -> 72 (floor raised) · test-runner 173 -> 184 (Section 16s: 11
unconditional greps incl. a 16-phase coverage sweep + non-vacuity self-test;
anti-erosion floor 155 -> 166) · trends 300/0 · brain 134/0 · specifics-bank 45/0 ·
hooks 140/0 · tests 35/0 · render 60/0. tsc --noEmit clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxvWAjte7vPcF79QeSRvRJ
This commit is contained in:
Kjell Tore Guttormsen 2026-07-25 06:55:44 +02:00
commit 657539ef09
13 changed files with 1454 additions and 20 deletions

View file

@ -1,4 +1,10 @@
# editions — series-level memory for long-form (N11, serie-nivå-vern)
# editions — series-level memory for long-form
Two stores, one package, both about what a *series* knows rather than what an edition
knows: the **distillate** (N11) — what the reader has already been told — and the
**register** (N12) — what is in production right now and how long it is taking.
## 1. Series distillate (N11, serie-nivå-vern)
Every long-form gate agent sees **one** edition. At two editions a week the fastest-
growing defect class is not a bad edition — it is a **repeated** one: the anecdote, the
@ -67,6 +73,61 @@ unlike the binding gate's BLOCK. `2` on usage error.
- **A missing distillate is not an error.** A series' first edition compares against
nothing and is CLEAR.
## 2. Editions register (N12, A1-11 / A1-12)
Two things were structurally invisible before this: **which editions are in flight**
(readable only by opening every series folder's `edition-state.json` by hand) and **how
long an edition takes** (not recorded anywhere at all). At a two-editions-a-week cadence
both are load-bearing — you cannot dimension a production line on numbers you never
collected.
So every phase transition in `/linkedin:newsletter` runs **one** command that does two
writes: it appends `{phase, completedAt}` to `articles.NN.phaseLog` in the edition-state,
and mirrors the edition's row into the register.
```bash
# at EVERY phase transition (after currentPhase has been written)
node --import tsx src/cli.ts register-upsert \
--edition-state "<serie>/linkedin/edition-state.json" \
--next "Step 3a — spine prose" [--slot "2026-07-28 07:45"] [--path <series-root>]
# the week's work-in-progress, without opening a single series folder
node --import tsx src/cli.ts register-list [--all] [--json]
# at Step 10, once the edition is scheduled — prints the measured lead time
node --import tsx src/cli.ts register-complete --series seres --edition 05
```
### Where the register lives
`${LINKEDIN_STUDIO_DATA:-$HOME/.claude/linkedin-studio}/editions/register.json` — the
per-user data dir (M0 convention), because it spans *all* series and must survive plugin
upgrades and reinstalls. Contrast the distillate above, which is per-series and therefore
lives in the series root.
### Model
- **The register is a MIRROR, never a source of truth.** Every row is derived from an
`edition-state.json` at a transition. Resumption reads edition-state and nothing else;
delete the register and the next transition rebuilds the row. Losing it costs telemetry,
not an edition — so a failed `register-upsert` is reported, never a reason to stop the
pipeline.
- **One call, both writes.** A phase log the command layer had to remember to append
separately would be incomplete inside a week, and an incomplete log measures nothing.
- **No clock in the core.** Every mutation takes `now` as an argument (`--at` / `--now` at
the CLI edge), exactly like the distillate takes `lockedAt`. Deterministic tests, no
hidden timezone behaviour.
- **`startedAt` never moves.** It is the lead-time anchor: re-upserting a completed
edition *reactivates* the same row (that is what `/linkedin:pivot` does), so the measured
time reflects real elapsed production rather than restarting the clock.
- **Idempotent where a re-run is legitimate, not where it is real work.** Repeating the
same transition logs once; a phase that recurs *after* another one is logged again,
because a pivot back through cleared gates is production time that actually happened.
Completing twice keeps the first `completedAt`.
- **Missing facts are errors, not defaults.** A row naming the wrong phase is worse than
no row — the whole point is that the list can be trusted without opening files. Only the
title is allowed to be empty; it is telemetry, not a gate.
## Test
```bash