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
|
|
@ -61,7 +61,10 @@
|
|||
# wiring guard (RE-R3d: scripts/trends/src/brief.ts has 'export function temporalSignal' AND the cmp
|
||||
# key 'b.temporal.rank' AND the '"first-mover"' tier, scripts/trends/src/cli.ts exposes the
|
||||
# 'first-mover-days' AND 'saturation-at' brief flags, with a non-vacuity self-test) in Section 16m;
|
||||
# the assertion-count anti-erosion floor (SC6) in Section 18. All
|
||||
# the trends-brief-history/diff wiring guard (RE-R3e: scripts/trends/src/brief.ts has
|
||||
# 'export function diffSurfaced' AND 'parseSurfacedFrontmatter' AND the 'Nytt siden sist' section AND
|
||||
# the 'surfaced: ' frontmatter emit, scripts/trends/src/cli.ts wires 'selectPriorBriefFile', with a
|
||||
# non-vacuity self-test) in Section 16n; the assertion-count anti-erosion floor (SC6) in Section 18. All
|
||||
# are live below (Sections 8–18).
|
||||
#
|
||||
# Usage: bash scripts/test-runner.sh
|
||||
|
|
@ -713,7 +716,7 @@ if [ -x "$TR_DIR/node_modules/.bin/tsx" ]; then
|
|||
TR_OUT=$( set +e; (cd "$TR_DIR" && npm test) 2>&1; echo "TR_EXIT:$?" )
|
||||
TR_EXIT=$(echo "$TR_OUT" | grep -oE 'TR_EXIT:[0-9]+' | grep -oE '[0-9]+' | head -1)
|
||||
TR_TESTS=$(echo "$TR_OUT" | grep -oE 'tests [0-9]+' | grep -oE '[0-9]+' | tail -1)
|
||||
TRENDS_TESTS_FLOOR=216 # store 24 + RE-R1: item 18 + score 16 + cli 4 + RE-R2a: store +9 + item +4 + cli +4 (capture bridge + publishedAt) + RE-R2b: brief +21 + cli +4 (morning-brief) + RE-R3a: score +6, item +12, store +6, brief +16, cli +2 (relevance score persist + rank) + RE-R3b: store +11, brief +8, cli +6 (lifecycle: re-score + status + seen-log) + RE-R3c: schedule +9, cli +8, run-daily +4 (scheduler + headless wrapper) + RE-R3d: brief +21, cli +3 (temporal overlay: first-mover + saturation)
|
||||
TRENDS_TESTS_FLOOR=245 # store 24 + RE-R1: item 18 + score 16 + cli 4 + RE-R2a: store +9 + item +4 + cli +4 (capture bridge + publishedAt) + RE-R2b: brief +21 + cli +4 (morning-brief) + RE-R3a: score +6, item +12, store +6, brief +16, cli +2 (relevance score persist + rank) + RE-R3b: store +11, brief +8, cli +6 (lifecycle: re-score + status + seen-log) + RE-R3c: schedule +9, cli +8, run-daily +4 (scheduler + headless wrapper) + RE-R3d: brief +21, cli +3 (temporal overlay: first-mover + saturation) + RE-R3e: brief +27, cli +2 (brief history + diff)
|
||||
if [ "$TR_EXIT" = "0" ] && [ -n "$TR_TESTS" ] && [ "$TR_TESTS" -ge "$TRENDS_TESTS_FLOOR" ]; then
|
||||
pass "trends-store suite green: $TR_TESTS tests pass (floor $TRENDS_TESTS_FLOOR)"
|
||||
else
|
||||
|
|
@ -1440,6 +1443,72 @@ fi
|
|||
|
||||
echo ""
|
||||
|
||||
# --- Section 16n: Trends Brief History / Diff (research-engine RE-R3e) ---
|
||||
echo "--- Trends Brief History / Diff ---"
|
||||
|
||||
# RE-R3e adds the day-over-day brief diff: a 'surfaced:' frontmatter record + three pure helpers
|
||||
# (diffSurfaced / parseSurfacedFrontmatter / selectPriorBriefFile) in brief.ts, wired at the cli.ts
|
||||
# edge, rendering a 'Nytt siden sist' section. Five literals must hold, grepped EXACT (grep -F),
|
||||
# deps-absent-safe (pure grep, no tsx); ASCII-only (bash 3.2 set -u — the section's emoji is NEVER
|
||||
# grepped, only its ASCII tail 'Nytt siden sist'):
|
||||
# (1) brief.ts exports the diff, by 'export function diffSurfaced';
|
||||
# (2) brief.ts parses the prior record, by 'parseSurfacedFrontmatter';
|
||||
# (3) brief.ts renders the section, by 'Nytt siden sist' (the ASCII header tail);
|
||||
# (4) cli.ts wires prior-discovery, by 'selectPriorBriefFile';
|
||||
# (5) brief.ts emits the membership record, by 'surfaced: ' (the frontmatter line).
|
||||
# Non-vacuity self-test mirrors Section 16m. Placed after Section 16m / before Section 18 (anti-erosion
|
||||
# must run last so it sees every prior check). UNCONDITIONAL (no tsx) -> counts toward ASSERT_BASELINE_FLOOR.
|
||||
DIFF_FN_LIT='export function diffSurfaced'
|
||||
DIFF_PARSE_LIT='parseSurfacedFrontmatter'
|
||||
DIFF_SECTION_LIT='Nytt siden sist'
|
||||
DIFF_SELECT_LIT='selectPriorBriefFile'
|
||||
DIFF_SURFACED_LIT='surfaced: '
|
||||
|
||||
I16N_SELFTEST_OK=1
|
||||
if ! echo 'a wired diff declares: export function diffSurfaced(currentIds, priorIds)' | grep -qF "$DIFF_FN_LIT"; then
|
||||
I16N_SELFTEST_OK=0; echo " non-vacuity FAIL: a wired brief-diff probe was not detected"
|
||||
fi
|
||||
if echo 'an unwired module computes no day-over-day diff at all' | grep -qF "$DIFF_FN_LIT"; then
|
||||
I16N_SELFTEST_OK=0; echo " false-positive FAIL: an unwired probe matched the brief-diff pointer"
|
||||
fi
|
||||
if [ "$I16N_SELFTEST_OK" -eq 1 ]; then
|
||||
pass "trends-brief-diff self-test: the diff pointer is detected, the no-diff form rejected"
|
||||
else
|
||||
fail "trends-brief-diff self-test failed — the brief-diff lint is vacuous or over-eager"
|
||||
fi
|
||||
|
||||
if grep -qF "$DIFF_FN_LIT" scripts/trends/src/brief.ts; then
|
||||
pass "brief.ts exports the day-over-day diff ('$DIFF_FN_LIT')"
|
||||
else
|
||||
fail "brief.ts has no diff — add '$DIFF_FN_LIT' (RE-R3e brief history)"
|
||||
fi
|
||||
|
||||
if grep -qF "$DIFF_PARSE_LIT" scripts/trends/src/brief.ts; then
|
||||
pass "brief.ts parses the prior surfaced record ('$DIFF_PARSE_LIT')"
|
||||
else
|
||||
fail "brief.ts cannot read a prior brief — add '$DIFF_PARSE_LIT' (RE-R3e)"
|
||||
fi
|
||||
|
||||
if grep -qF "$DIFF_SECTION_LIT" scripts/trends/src/brief.ts; then
|
||||
pass "brief.ts renders the diff section ('$DIFF_SECTION_LIT')"
|
||||
else
|
||||
fail "brief.ts has no diff section — add '$DIFF_SECTION_LIT' (RE-R3e section header)"
|
||||
fi
|
||||
|
||||
if grep -qF "$DIFF_SELECT_LIT" scripts/trends/src/cli.ts; then
|
||||
pass "cli.ts wires prior-brief discovery ('$DIFF_SELECT_LIT')"
|
||||
else
|
||||
fail "cli.ts does not discover the prior brief — add '$DIFF_SELECT_LIT' (RE-R3e wiring)"
|
||||
fi
|
||||
|
||||
if grep -qF "$DIFF_SURFACED_LIT" scripts/trends/src/brief.ts; then
|
||||
pass "brief.ts emits the surfaced: membership record ('$DIFF_SURFACED_LIT')"
|
||||
else
|
||||
fail "brief.ts records no membership — add the 'surfaced:' frontmatter line (RE-R3e)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# --- Section 18: Assertion-Count Anti-Erosion (SC6) ---
|
||||
# The lint self-modifies its own checks, so a green run could mask a silently dropped
|
||||
# assertion. Pin the total pass()+fail() invocations as a monotonic floor; the count
|
||||
|
|
@ -1465,12 +1534,15 @@ echo ""
|
|||
# run-daily.sh brief-invocation grep + run-daily.sh data-twin grep) = 111; +6 for RE-R3d's six
|
||||
# UNCONDITIONAL Section-16m checks (temporal self-test + brief.ts temporalSignal grep + brief.ts
|
||||
# b.temporal.rank cmp grep + brief.ts "first-mover" tier grep + cli.ts first-mover-days flag grep +
|
||||
# cli.ts saturation-at flag grep) = 117.
|
||||
# cli.ts saturation-at flag grep) = 117; +6 for RE-R3e's six UNCONDITIONAL Section-16n checks
|
||||
# (brief-diff self-test + brief.ts diffSurfaced grep + brief.ts parseSurfacedFrontmatter grep +
|
||||
# brief.ts 'Nytt siden sist' section grep + cli.ts selectPriorBriefFile wiring grep + brief.ts
|
||||
# 'surfaced: ' frontmatter grep) = 123.
|
||||
# NB: the floor tracks the deps-absent MINIMUM (conditional TS suites warn-skip and drop
|
||||
# the count), so it is bumped only by UNCONDITIONAL new checks — NOT pinned to the
|
||||
# deps-present TOTAL_CHECKS (that would zero the warn-skip margin and false-fail a fresh
|
||||
# clone). Runs last so TOTAL_CHECKS sees every prior check.
|
||||
ASSERT_BASELINE_FLOOR=117
|
||||
ASSERT_BASELINE_FLOOR=123
|
||||
TOTAL_CHECKS=$((PASS + FAIL))
|
||||
if [ "$TOTAL_CHECKS" -ge "$ASSERT_BASELINE_FLOOR" ]; then
|
||||
pass "assertion-count anti-erosion: $TOTAL_CHECKS checks >= baseline floor $ASSERT_BASELINE_FLOOR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue