feat(linkedin-studio): RE-R3a — persist relevance score on the store record + rank the morning brief on it [skip-docs]
R3 slice 1 (research-deepening). Stop discarding the relevance judgment the
trend-spotter already computes: persist a 4-field TrendScore {mode, dimensions,
composite, priority} on TrendRecord (schema v2->v3, additive lossless migrate),
computed by the existing score.ts composite()+band() (one owner, no new arithmetic),
threaded item->store; then rankForBrief sorts each bucket composite-first (sentinel
-1 for unscored) and renderBrief surfaces "· <priority> (<mode>)" per body entry
(briefSummary shows the band only). First-sight only; mode-blind ranking with the mode
shown so the operator can disambiguate instruments.
- score.ts: TrendScore + requiredDimensions(mode) (ordered) + scoreEnvelope (composes
composite+band; throws on bad dim by contract)
- types.ts: SCHEMA_VERSION 2->3; TrendRecord.score?
- store.ts: TrendInput.score?; addTrend persists first-sight (duplicate keeps it);
migrate comment v1->v2->v3 (logic unchanged, JSON.stringify preserves the field)
- item.ts: TrendItem.score?; normalizeItem validates (non-array score/dimensions + the
mode's five dims in [1,10]) -> structured error never throw, carries validated dims;
itemToInput -> scoreEnvelope (no throw on the capture path; direct call throws by contract)
- brief.ts: composite-primary comparator; band+mode render; exact ranking: descriptor
- cli.ts: capture persists score via itemToInput (doc-only); add/score paths unchanged
- agents/trend-spotter.md Step 4.5: capture batch carries the Step-2 dimensions
- gate: TRENDS_TESTS_FLOOR 104->146; new unconditional Section 16j; ASSERT floor 94->99
Tests: trends 146/146 (RED two-phase: logic-RED store/brief/cli; stub-first then
assertion-RED score/item). Gate green (Passed 114 / Failed 0; 113 checks >= 99).
Hook suite 139/139 untouched. Counts 27/19/29 unchanged. No new source file/agent/command.
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:
parent
4d3b9f4711
commit
e169c78710
14 changed files with 829 additions and 40 deletions
|
|
@ -39,22 +39,32 @@ interface TrendRecord {
|
|||
publishedAt?: string;// optional source publish date (ISO-8601); distinct from capturedAt, first-sight, never back-filled
|
||||
topics: string[]; // query tags; unioned across re-captures
|
||||
summary?: string; // optional, verbatim
|
||||
score?: TrendScore; // optional persisted relevance (RE-R3a): { mode, dimensions, composite, priority } — first-sight, never re-scored
|
||||
}
|
||||
```
|
||||
|
||||
Fields (relevance score, first-mover timing, status) can be added in a later
|
||||
slice without breaking the shape.
|
||||
`score` is the persisted relevance envelope (RE-R3a): a capture **item** carries the
|
||||
agent's **judgment** — `{ mode, dimensions }` (the five 1–10 dimension scores) — and the
|
||||
store turns that into the persisted `TrendScore` `{ mode, dimensions, composite, priority }`,
|
||||
computing the composite + band once via the single scorer owner (`src/score.ts`). It is
|
||||
set **first-sight** (never updated on re-capture); the score-free `add` manual path omits it.
|
||||
The morning brief ranks each bucket on `composite` first (schema v3). Further fields
|
||||
(first-mover timing, status) can still be added in a later slice without breaking the shape.
|
||||
|
||||
## CLI
|
||||
|
||||
```bash
|
||||
# Capture freshly-polled trends — the NORMALIZING BATCH path (the research agent's path):
|
||||
# raw items on stdin → validate+normalize each → dedupe on title+url → union topics on
|
||||
# re-capture → persist the source's publishedAt. Content-invalid items are reported in the
|
||||
# summary errors[], never fail the run; the summary is {added, duplicates, merged, errors}.
|
||||
# re-capture → persist the source's publishedAt → persist the relevance score (when carried).
|
||||
# Content-invalid items (incl. a malformed/out-of-range score) are reported in the summary
|
||||
# errors[], never fail the run; the summary is {added, duplicates, merged, errors}.
|
||||
# An item's "score" carries the agent's judgment (mode + the five 1–10 dimensions); the store
|
||||
# computes the composite + band and persists the full TrendScore first-sight.
|
||||
echo '[{"source":"tavily","title":"Agentic workflows hit production",
|
||||
"url":"https://example.com/agentic","topics":["agents","engineering"],
|
||||
"publishedAt":"2026-06-20","summary":"Teams ship multi-step agents past the demo stage."}]' \
|
||||
"publishedAt":"2026-06-20","summary":"Teams ship multi-step agents past the demo stage.",
|
||||
"score":{"mode":"kortform","dimensions":{"pillar":9,"audience":8,"timing":9,"angle":7,"authority":6}}}]' \
|
||||
| node --import tsx src/cli.ts capture [--store <path>] [--json]
|
||||
|
||||
# Add a SINGLE trend MANUALLY — raw flags, no normalization, publish-date-free:
|
||||
|
|
@ -91,9 +101,10 @@ ${LINKEDIN_STUDIO_DATA:-$HOME/.claude/linkedin-studio}/trends/morning-brief/YYYY
|
|||
```
|
||||
|
||||
The file's YAML frontmatter carries a single-line `summary` the SessionStart hook surfaces
|
||||
verbatim (zero-tsx — it reads the Markdown, never the TS CLI). Ranking uses only persisted
|
||||
fields; a persisted relevance score, an autonomous nightly trigger, and a seen-log freshness
|
||||
model are later slices.
|
||||
verbatim (zero-tsx — it reads the Markdown, never the TS CLI). As of RE-R3a the brief ranks
|
||||
each bucket on the persisted relevance **composite first** (then pillar-overlap, then recency);
|
||||
a scored entry shows `· <priority> (<mode>)` and the summary names the top entry's band. An
|
||||
autonomous nightly trigger and a seen-log freshness model remain later slices.
|
||||
|
||||
## Tests
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue