feat(linkedin-studio): RE-R2a — item→store capture bridge + publishedAt persistence (schema v1→v2, lossless migrate) [skip-docs]
Closes the research-engine capture loop RE-R1 deferred:
- itemToInput(item, capturedAt): pure envelope→TrendInput bridge in item.ts —
injects capturedAt, carries publishedAt verbatim; no id, no re-validate
- publishedAt persisted: TrendRecord/TrendInput gain it; addTrend conditional-spread,
first-sight kept on re-capture (no back-fill). SCHEMA_VERSION 1→2 with a lossless
forward migrate-on-load: Math.max(onDisk, current) + numeric-typeof coercion
(string/NaN/absent → current; non-array trends coercion preserved verbatim)
- `capture` CLI: stdin raw item|batch → normalize → bridge → addTrend → saveStore once;
tally {added,duplicates,merged,errors} from AddResult; content-invalid → errors[],
exit 2 only on bad stdin; --json summary
- wiring: trend-spotter.md Step 4.5 N×`add` → one normalizing `capture` batch; README
add/capture framing corrected; test-runner Section 16h (capture wiring, unconditional)
+ floors bumped (trends 62→79, ASSERT 87→90)
TDD: 17 new tests (12 genuinely-RED logic-RED + 5 regression guards), tsc clean,
gate 105/0/0. 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_01VmHCQjJHUyWwxGAVVjNLgp
This commit is contained in:
parent
b4e500fad4
commit
7a158030b6
10 changed files with 465 additions and 31 deletions
|
|
@ -35,7 +35,8 @@ interface TrendRecord {
|
|||
title: string; // headline, verbatim
|
||||
url: string; // source URL, verbatim
|
||||
source: string; // "tavily" | "websearch" | "manual" | <mcp-name>
|
||||
capturedAt: string; // ISO-8601 date
|
||||
capturedAt: string; // ISO-8601 date — when WE captured it
|
||||
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
|
||||
}
|
||||
|
|
@ -47,7 +48,16 @@ slice without breaking the shape.
|
|||
## CLI
|
||||
|
||||
```bash
|
||||
# Capture a freshly-polled trend (dedupes on title+url; unions topics on re-capture)
|
||||
# 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}.
|
||||
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."}]' \
|
||||
| node --import tsx src/cli.ts capture [--store <path>] [--json]
|
||||
|
||||
# Add a SINGLE trend MANUALLY — raw flags, no normalization, publish-date-free:
|
||||
node --import tsx src/cli.ts add \
|
||||
--title "Agentic workflows hit production" \
|
||||
--url "https://example.com/agentic" \
|
||||
|
|
@ -61,7 +71,8 @@ node --import tsx src/cli.ts query --topics "agents,engineering" [--json]
|
|||
node --import tsx src/cli.ts list [--since 2026-06-01] [--limit 10] [--json]
|
||||
```
|
||||
|
||||
Re-running `add` with the same title+url never appends a duplicate.
|
||||
Both `capture` and `add` dedupe on normalized title+url — re-capturing the same trend
|
||||
never appends a duplicate, it only unions any new topics in.
|
||||
|
||||
## Tests
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue