feat(linkedin-studio): RE-R3e — brief history + day-over-day diff (surfaced: frontmatter + Nytt siden sist) [skip-docs]
Closes hull #7 ("ingen brief-historikk"). Each morning brief now records the trend ids it showed into its own YAML frontmatter (surfaced: <id-csv> = surfacedIds(ranking)) and renders a day-over-day diff against the most recent prior brief — a "## Nytt siden sist (<prior-date>)" section that leads the ranked list, plus a " N nye siden sist." marker on the one-line summary the SessionStart hook surfaces (no hook change). - brief.ts: BRIEF_SCHEMA_VERSION 1->2 (artifact frontmatter gained surfaced:; the store's SCHEMA_VERSION stays 4 — no store field). Three PURE helpers (diffSurfaced / parseSurfacedFrontmatter / selectPriorBriefFile) + the surfaced: emit + the section + the summary marker. No fs/clock in brief.ts. - cli.ts: the brief handler discovers the prior dated file (existsSync-guarded readdirSync -> selectPriorBriefFile, strict < today so a same-day re-run is byte-identical), parses its surfaced: line, computes the diff, threads it into renderBrief AND the shared briefSummary(ranking, diff) (one-source: file frontmatter == --json summary, cli.test one-source invariant). --json gains a diff:{priorDate,added,carried,dropped} counts object; the console line appends the delta. Any fs error degrades to the empty-prior (first-brief) path. TDD two-phase: stubs -> 17 value-RED (no module-not-found) -> GREEN. Trends suite 216 -> 245 (brief +27, cli +2), 0 fail. New unconditional gate Section 16n (6 checks); ASSERT_BASELINE_FLOOR 117 -> 123; TRENDS_TESTS_FLOOR -> 245. Full gate FAIL=0; hook suite 139/139 + R3c schedule/run-daily green untouched. Behavioural: real two-day rename-real-write diff + same-day byte-identity confirmed. Counts 29/19/27 unchanged; no version bump (additive, v0.5.2 dev). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011vmzxpsFpc8q19LaogAWLD
This commit is contained in:
parent
ddedb3d1de
commit
5b51b4baeb
7 changed files with 462 additions and 18 deletions
|
|
@ -173,6 +173,31 @@ tier, never overriding relevance. Prior-day surfacings exclude today (via `lastS
|
|||
same-day re-render is byte-identical. Tune per run with `--first-mover-days N` / `--saturation-at N`
|
||||
(the scheduled nightly run uses the defaults).
|
||||
|
||||
## Brief history + diff (RE-R3e)
|
||||
|
||||
Each brief records the trend ids it showed into its own frontmatter — one `surfaced: <id-csv>` line
|
||||
= `surfacedIds(ranking)` (the cohort the brief surfaced). This bumps the **artifact** schema
|
||||
`BRIEF_SCHEMA_VERSION` **1 → 2**; the store's `SCHEMA_VERSION` stays **4** (no store field — the
|
||||
membership lives in the artifact, the diff is derived at the CLI edge).
|
||||
|
||||
When a brief is written, the CLI discovers the most recent **prior** dated file
|
||||
(`selectPriorBriefFile`: the greatest `YYYY-MM-DD.md` strictly `< today`, so a same-day re-run diffs
|
||||
against the true previous day and stays byte-identical), parses its `surfaced:` line
|
||||
(`parseSurfacedFrontmatter`, degrading to "empty prior" on any absent/blank/malformed/pre-R3e file),
|
||||
and computes the symmetric set difference (`diffSurfaced`):
|
||||
|
||||
- **added** — in today, not in the prior brief: the headline "what's new", rendered with titles
|
||||
resolved from the ranking under a `## 🆕 Nytt siden sist (<prior-date>)` section that **leads** the
|
||||
ranked list.
|
||||
- **carried** / **dropped** — in both / in the prior only: a one-line count (`N båret over, M ikke
|
||||
vist i dag`). Framed "ikke vist i dag" (not "resolved") — a count cannot prove why a trend left.
|
||||
|
||||
A ` N nye siden sist.` marker is appended to the one-line `summary:` the SessionStart hook surfaces,
|
||||
so the delta shows **without opening the file** (no hook change). The three helpers are **pure**
|
||||
(string/array in, value out); the directory + file reads live at the `cli.ts` edge, so `brief.ts`
|
||||
stays fs-free. `--no-mark` is unaffected (it governs only the store seen-log; `surfaced:` always
|
||||
records what the brief showed).
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue