feat: HN upvotes + RAG visibility on reading ticks #105

Merged
joshtronic merged 1 commit from feat/hn-upvotes-and-rag-visibility into master 2026-05-22 21:58:26 +00:00
Owner

Two improvements to the reading loop, bundled because both touch
discretionary-read.sh.

  1. HN upvotes via Algolia API.
    Replaced the RSS-based discover_hn with a single Algolia query:

    https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=30

    Returns hits with .url AND .points (current upvote count).
    Algolia's response order = HN's front-page order so position
    still gives rank. Output is "rank|points|url" triples.

    Self-posts (Ask HN, Tell HN) have null .url and get filtered
    -- only external story URLs make it into the ledger.

    Ledger annotation extends: hn-points N stored alongside
    hn-rank N. Update rule: rank keeps LOWER number (highest
    position), points keep HIGHER number (peak upvotes Igor
    observed). A story that briefly hit 800 points stays
    annotated "800" even after it falls off and current count
    is moot.

    Picker change: sort candidates by points DESC, rank ASC as
    tiebreaker. So a 3-day-old 800-point story still beats
    today's 200-point #1 -- the controversial/interesting stuff
    bubbles up regardless of when Igor first saw it.

    New ledger_update_points helper mirrors ledger_update_rank
    but with reversed comparison (higher wins).

  2. RAG visibility on reading ticks.
    agent-read.sh DOES call rag_query before every API call --
    the build's stderr was just buried because discretionary-
    read.sh captured agent-read's stderr to a temp file and only
    displayed it on failure. So you'd see rag: flushed redis db / rag: collected N journal + M memory / rag: indexed ... on
    site-work and tier-1 ticks but never on reading ticks.

    Switched 2>"$err_file" to 2> >(tee "$err_file" >&2). stderr
    now streams through to journalctl in real time AND gets
    captured to err_file for the failure-tail. RAG progress
    (and any future stderr-noisy thing) surfaces.

Verified:

  • Algolia parse against the live API returns rank|points|url
    triples cleanly.
  • sort -k1nr -k2n orders 800@rank-3 > 800@rank-5 > 300 > 200.
  • ledger_update_points keeps the higher number; doesn't
    regress when given a lower one.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Two improvements to the reading loop, bundled because both touch discretionary-read.sh. 1. HN upvotes via Algolia API. Replaced the RSS-based discover_hn with a single Algolia query: https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=30 Returns hits with .url AND .points (current upvote count). Algolia's response order = HN's front-page order so position still gives rank. Output is "rank|points|url" triples. Self-posts (Ask HN, Tell HN) have null .url and get filtered -- only external story URLs make it into the ledger. Ledger annotation extends: hn-points N stored alongside hn-rank N. Update rule: rank keeps LOWER number (highest position), points keep HIGHER number (peak upvotes Igor observed). A story that briefly hit 800 points stays annotated "800" even after it falls off and current count is moot. Picker change: sort candidates by points DESC, rank ASC as tiebreaker. So a 3-day-old 800-point story still beats today's 200-point #1 -- the controversial/interesting stuff bubbles up regardless of when Igor first saw it. New ledger_update_points helper mirrors ledger_update_rank but with reversed comparison (higher wins). 2. RAG visibility on reading ticks. agent-read.sh DOES call rag_query before every API call -- the build's stderr was just buried because discretionary- read.sh captured agent-read's stderr to a temp file and only displayed it on failure. So you'd see `rag: flushed redis db / rag: collected N journal + M memory / rag: indexed ...` on site-work and tier-1 ticks but never on reading ticks. Switched 2>"$err_file" to 2> >(tee "$err_file" >&2). stderr now streams through to journalctl in real time AND gets captured to err_file for the failure-tail. RAG progress (and any future stderr-noisy thing) surfaces. Verified: - Algolia parse against the live API returns rank|points|url triples cleanly. - sort -k1nr -k2n orders 800@rank-3 > 800@rank-5 > 300 > 200. - ledger_update_points keeps the higher number; doesn't regress when given a lower one. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
feat: HN upvotes + RAG visibility on reading ticks
All checks were successful
Lint / check-sync (push) Successful in 4s
Lint / check-sync (pull_request) Successful in 4s
3ccfad566d
Two improvements to the reading loop, bundled because both touch
discretionary-read.sh.

1. HN upvotes via Algolia API.
   Replaced the RSS-based discover_hn with a single Algolia query:

     https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=30

   Returns hits with .url AND .points (current upvote count).
   Algolia's response order = HN's front-page order so position
   still gives rank. Output is "rank|points|url" triples.

   Self-posts (Ask HN, Tell HN) have null .url and get filtered
   -- only external story URLs make it into the ledger.

   Ledger annotation extends: hn-points N stored alongside
   hn-rank N. Update rule: rank keeps LOWER number (highest
   position), points keep HIGHER number (peak upvotes Igor
   observed). A story that briefly hit 800 points stays
   annotated "800" even after it falls off and current count
   is moot.

   Picker change: sort candidates by points DESC, rank ASC as
   tiebreaker. So a 3-day-old 800-point story still beats
   today's 200-point #1 -- the controversial/interesting stuff
   bubbles up regardless of when Igor first saw it.

   New ledger_update_points helper mirrors ledger_update_rank
   but with reversed comparison (higher wins).

2. RAG visibility on reading ticks.
   agent-read.sh DOES call rag_query before every API call --
   the build's stderr was just buried because discretionary-
   read.sh captured agent-read's stderr to a temp file and only
   displayed it on failure. So you'd see `rag: flushed redis db
   / rag: collected N journal + M memory / rag: indexed ...` on
   site-work and tier-1 ticks but never on reading ticks.

   Switched 2>"$err_file" to 2> >(tee "$err_file" >&2). stderr
   now streams through to journalctl in real time AND gets
   captured to err_file for the failure-tail. RAG progress
   (and any future stderr-noisy thing) surfaces.

Verified:
  - Algolia parse against the live API returns rank|points|url
    triples cleanly.
  - sort -k1nr -k2n orders 800@rank-3 > 800@rank-5 > 300 > 200.
  - ledger_update_points keeps the higher number; doesn't
    regress when given a lower one.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
joshtronic deleted branch feat/hn-upvotes-and-rag-visibility 2026-05-22 21:58:26 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joshtronic/igor!105
No description provided.