feat(linkedin-studio): RE-R1 — item-schema (B1) + triage-scorer (B2) as tested code behind CLI seam [skip-docs]

Lift the research engine's deterministic core out of agents/trend-spotter.md prose
into pure, tested TypeScript under scripts/trends/, behind a CLI seam the agent calls.

- B1 src/item.ts: TrendItem ingress envelope + normalizeItem/normalizeItems
  (required-field validation, topic normalize+dedupe via store's normalizeField,
  optional publishedAt ISO-validate). No id (store derives it); no store bridge
  (capturedAt injection is R2).
- B2 src/score.ts: per-mode weight consts mirroring the SSOT
  (references/trend-scoring-modes.md), composite (weighted sum, [1,10] guard),
  band (5-band map + exact SSOT action strings), triage (keep>=threshold, rank desc,
  annotate composite+band). Owns ONLY the arithmetic; the five judgment scores stay
  model-side.
- CLI normalize/score: JSON payload on STDIN, JSON to stdout (the existing --json
  output toggle is untouched); exit 2 on bad invocation, 0 otherwise.
- Wire trend-spotter.md to name 'src/cli.ts score' as the deterministic-step owner
  (prose pointer; the agent still supplies the five scores). Domain-general.
- Gate: TRENDS_TESTS_FLOOR 24->62; new unconditional Section 16g (score.ts both-mode
  weight-sets + trend-spotter scorer-pointer + non-vacuity self-test);
  ASSERT_BASELINE_FLOOR 84->87.

TDD: logic-RED proven (33/34 item+score fail on assertions, not module-not-found),
then GREEN (trends suite 62/62); CLI RED 2/4 -> GREEN 4/4. Full gate 102/0/0.
No store-schema change (SCHEMA_VERSION stays 1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmHCQjJHUyWwxGAVVjNLgp
This commit is contained in:
Kjell Tore Guttormsen 2026-06-24 10:09:45 +02:00
commit 24775f4493
8 changed files with 793 additions and 10 deletions

View file

@ -131,10 +131,13 @@ query bank: target a source or topic from the list (`"[Tier-1 source] latest"`,
invoked from `/linkedin:newsletter`) or asks for it explicitly. Depth potential enters at 25 %
and timing drops to 10 % — a chronicle rewards substance and a durable angle over speed.
Score each candidate's five dimensions 110 per the mode's table, take the weighted composite
(both modes stay on the same 010 scale), and rank highest-first. The composite→action bands
(Immediate / High / Medium / Low / Skip) live in that same reference — use them; do not restate
the thresholds here.
Score each candidate's five dimensions 110 per the mode's table — that qualitative judgment is
yours. The deterministic step that follows is NOT: pipe the scored candidates (JSON on stdin) to the
scorer CLI `${CLAUDE_PLUGIN_ROOT}/scripts/trends/src/cli.ts score` (`--mode kortform|long-form
[--threshold N]`), the single owner of the weighted composite, the composite→action bands
(Immediate / High / Medium / Low / Skip), and the keep/drop threshold. It returns the kept candidates
ranked highest-first, each annotated with its composite + band. Do not recompute the composite or
restate the band thresholds here — supply the five judgment scores and let the scorer rank and triage.
## Trend Opportunity Assessment