feat(linkedin-studio): RE-R3b — trend lifecycle (re-score on re-capture · status · seen-log) [skip-docs]
The lifecycle layer over the trend store: what happens to a trend AFTER first capture.
- re-score on re-capture (last-wins; addTrend duplicate branch, score the one mutable
field; provenance + lifecycle untouched; no false-merge via JSON compare). Reverses
R3a's first-sight D3 — that R3a test reconciled to the new behaviour.
- status new/acted/skipped (effectiveStatus/setStatus + act/skip/reset CLI verbs);
rankForBrief EXCLUDES handled trends (a work queue, not an archive).
- seen-log surfacedCount/lastSurfacedAt (markSurfaced, per-day idempotent); the brief
CLI records surfacing on the store AFTER the pure render, unless --no-mark.
- render: entry id in backticks (copy-paste for act/skip) + · sett Nx prior-day hint.
- schema v3→v4 (additive lossless); the R3a migration block reconciled to the bump,
the new R3b block committed against SCHEMA_VERSION (breaks the reconcile cycle).
score.ts + item.ts untouched (re-score reuses the R3a capture path). RED-first (two
phase: 16 logic-RED + 4 stub-RED). Gate: Section 16k (6 emitters), TRENDS_TESTS_FLOOR
146→171, ASSERT_BASELINE_FLOOR 99→105. trends 171/171, gate 120/0/0, hook suite 139/139.
Plan: docs/research-engine/{brief,plan}-re-r3b.md (light-Voyage hardened @ c40b937).
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
c40b937856
commit
b185db9a12
10 changed files with 661 additions and 44 deletions
|
|
@ -50,7 +50,11 @@
|
|||
# exports the 'export interface TrendScore' persist envelope, scripts/trends/src/types.ts carries
|
||||
# 'score?: TrendScore' on the record, agents/trend-spotter.md carries the judgment via '"dimensions"',
|
||||
# AND scripts/trends/src/brief.ts ranks on 'score?.composite', with a non-vacuity self-test) in
|
||||
# Section 16j; the assertion-count anti-erosion floor (SC6) in Section 18. All
|
||||
# Section 16j; the trends-lifecycle wiring guard (RE-R3b: scripts/trends/src/types.ts declares
|
||||
# 'export type TrendStatus' AND carries 'surfacedCount', scripts/trends/src/store.ts owns
|
||||
# 'export function markSurfaced', scripts/trends/src/brief.ts excludes handled via 'effectiveStatus',
|
||||
# AND scripts/trends/src/cli.ts exposes 'command === "act"', with a non-vacuity self-test) in
|
||||
# Section 16k; the assertion-count anti-erosion floor (SC6) in Section 18. All
|
||||
# are live below (Sections 8–18).
|
||||
#
|
||||
# Usage: bash scripts/test-runner.sh
|
||||
|
|
@ -702,7 +706,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=146 # 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)
|
||||
TRENDS_TESTS_FLOOR=171 # 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)
|
||||
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
|
||||
|
|
@ -1234,6 +1238,72 @@ fi
|
|||
|
||||
echo ""
|
||||
|
||||
# --- Section 16k: Trends Lifecycle Wiring (research-engine RE-R3b) ---
|
||||
echo "--- Trends Lifecycle Wiring ---"
|
||||
|
||||
# RE-R3b adds the trend lifecycle: re-score on re-capture, a status (new/acted/skipped) the brief
|
||||
# EXCLUDES, and a seen-log (surfacedCount/lastSurfacedAt) the brief records. Five literals must hold,
|
||||
# grepped EXACT (grep -F), deps-absent-safe (pure grep, no tsx):
|
||||
# (1) types.ts declares the status type, by 'export type TrendStatus';
|
||||
# (2) types.ts carries the seen-log field, by 'surfacedCount';
|
||||
# (3) store.ts owns the seen-log writer, by 'export function markSurfaced';
|
||||
# (4) brief.ts excludes handled trends, by 'effectiveStatus' (the filter is wired, not doc'd);
|
||||
# (5) cli.ts exposes the lifecycle verb, by 'command === "act"'.
|
||||
# Non-vacuity self-test mirrors Section 16j: the brief-filter predicate must accept a probe carrying
|
||||
# the effectiveStatus pointer and reject one without it. Placed after Section 16j / before Section 18
|
||||
# (anti-erosion must run last so it sees every prior check). UNCONDITIONAL (no tsx) -> counts toward
|
||||
# ASSERT_BASELINE_FLOOR.
|
||||
LIFECYCLE_STATUS_LIT='export type TrendStatus'
|
||||
LIFECYCLE_SEEN_LIT='surfacedCount'
|
||||
LIFECYCLE_MARK_LIT='export function markSurfaced'
|
||||
LIFECYCLE_FILTER_LIT='effectiveStatus'
|
||||
LIFECYCLE_VERB_LIT='command === "act"'
|
||||
|
||||
I16K_SELFTEST_OK=1
|
||||
if ! echo 'rankForBrief drops a trend when effectiveStatus(trend) !== "new"' | grep -qF "$LIFECYCLE_FILTER_LIT"; then
|
||||
I16K_SELFTEST_OK=0; echo " non-vacuity FAIL: a wired status-filter probe was not detected"
|
||||
fi
|
||||
if echo 'the brief shows every record regardless of status' | grep -qF "$LIFECYCLE_FILTER_LIT"; then
|
||||
I16K_SELFTEST_OK=0; echo " false-positive FAIL: an unwired probe matched the status-filter pointer"
|
||||
fi
|
||||
if [ "$I16K_SELFTEST_OK" -eq 1 ]; then
|
||||
pass "trends-lifecycle self-test: status-filter predicate detects wiring, rejects the unfiltered form"
|
||||
else
|
||||
fail "trends-lifecycle self-test failed — the lifecycle-wiring lint is vacuous or over-eager"
|
||||
fi
|
||||
|
||||
if grep -qF "$LIFECYCLE_STATUS_LIT" scripts/trends/src/types.ts; then
|
||||
pass "types.ts declares the lifecycle status type ('$LIFECYCLE_STATUS_LIT')"
|
||||
else
|
||||
fail "types.ts has no TrendStatus — add '$LIFECYCLE_STATUS_LIT' (RE-R3b lifecycle)"
|
||||
fi
|
||||
|
||||
if grep -qF "$LIFECYCLE_SEEN_LIT" scripts/trends/src/types.ts; then
|
||||
pass "types.ts carries the seen-log field ('$LIFECYCLE_SEEN_LIT')"
|
||||
else
|
||||
fail "types.ts does not carry the seen-log — add '$LIFECYCLE_SEEN_LIT' to TrendRecord (RE-R3b schema v4)"
|
||||
fi
|
||||
|
||||
if grep -qF "$LIFECYCLE_MARK_LIT" scripts/trends/src/store.ts; then
|
||||
pass "store.ts owns the seen-log writer ('$LIFECYCLE_MARK_LIT')"
|
||||
else
|
||||
fail "store.ts has no markSurfaced — add '$LIFECYCLE_MARK_LIT' (RE-R3b seen-log)"
|
||||
fi
|
||||
|
||||
if grep -qF "$LIFECYCLE_FILTER_LIT" scripts/trends/src/brief.ts; then
|
||||
pass "brief.ts excludes handled trends ('$LIFECYCLE_FILTER_LIT')"
|
||||
else
|
||||
fail "brief.ts does not exclude handled trends — wire '$LIFECYCLE_FILTER_LIT' into rankForBrief (RE-R3b)"
|
||||
fi
|
||||
|
||||
if grep -qF "$LIFECYCLE_VERB_LIT" scripts/trends/src/cli.ts; then
|
||||
pass "cli.ts exposes the lifecycle verb ('$LIFECYCLE_VERB_LIT')"
|
||||
else
|
||||
fail "cli.ts has no act/skip/reset — add '$LIFECYCLE_VERB_LIT' (RE-R3b lifecycle verbs)"
|
||||
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
|
||||
|
|
@ -1256,7 +1326,7 @@ echo ""
|
|||
# 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=99
|
||||
ASSERT_BASELINE_FLOOR=105
|
||||
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