Fase 7: raccolta, collegamento e primo giudizio delle notizie, con il classificatore ONNX #97

Merged
Alby96 merged 5 commits from fase-7 into main 2026-11-15 15:34:41 +01:00
Owner

Primo pezzo della Fase 7: le notizie entrano nel bot, pulite, raggruppate, collegate e giudicate in locale. Le scelte sono nell'ADR 0014.

Raccolta (#56)

  • Il lavoro "notizie" legge ogni 2 minuti le 14 fonti di SPEC 4.4. Le richieste sono condizionate (ETag, If-Modified-Since), con un secondo di pausa tra una fonte e l'altra. Una fonte che sbaglia si riprova dopo 2, 4, 8… minuti, al massimo ogni ora, e l'errore resta scritto.

  • RSS 2.0, RSS 1.0 e Atom si leggono senza DTD né entità: un feed ostile non legge il disco.

  • Un articolo con un indirizzo già visto, tolti i parametri di tracciamento, è un doppione.

  • Le riprese dello stesso fatto entro 48 ore diventano una storia. La storia conta le fonti indipendenti per dominio e dice se almeno una è affidabile.

  • Collegamenti:

    • agli strumenti: simboli della fonte, $TICKER, (NASDAQ: X), sigle delle crypto, nomi delle società e delle monete;
    • alle classi o al mercato: temi come banche centrali, inflazione, criptovalute, Wall Street;
    • se non si trova niente, all'argomento della fonte.

    I nomi comuni (Target, Visa…) contano solo con il ticker.

Primo giudizio (#57)

  • Casi gravi con parole chiave in inglese e italiano: attacco informatico, sospensione, frode, fallimento, indagine, revoca dalla quotazione.
  • Tono in cinque gradi con le soglie di 10.2.
  • Importanza: 4 ai casi gravi, 3 alle notizie negative, 2 a quelle collegate a uno strumento, 1 al resto.
  • Classificatore ONNX (ADR 0014, punto 8):
    • il modello è onnx/model_quantized.onnx di Xenova, revisione e6953e30, 83 MB, SHA-256 8fcf4873…48ec;
    • il bot lo scarica in sottofondo nella cartella models dei dati, controlla dimensione e hash, e se qualcosa va storto riprova dopo 6 ore;
    • finché manca, giudicano le sole parole chiave.
  • Il tokenizzatore BPE di RoBERTa sta nella DLL e non riconosce token speciali nel testo.
    • CodeGenTokenizer.Create è scartato perché aggiunge identificativi che il modello rifiuta.
  • Pacchetti dall'elenco dell'ADR 0004: Microsoft.ML.OnnxRuntime 1.31.1 e Microsoft.ML.Tokenizers 2.0.1, più Google.Protobuf 3.30.2 come dipendenza indiretta.
  • Anubis e Anubis.Server dichiarano il runtime win-x64: lo zip per Windows non cambia più i file di blocco. Lo zip passa da 3,4 a 10,7 MB per la libreria nativa di ONNX Runtime.

Prove

  • NewsTests: 11 test sull'archivio sintetico tests/Anubis.Tests/Fixtures/news/, nel formato reale di ogni fonte. Verdi su SQLite e PostgreSQL.
  • ToneModelTests:
    • gli identificativi coincidono con l'originale su 14 titoli con accenti, simboli e spazi;
    • un modello con l'hash sbagliato non si usa mai;
    • col modello vero, positivi e negativi chiari sono letti bene, a 23–24 ms per titolo su un thread. Gira dove il modello è già scaricato (ANUBIS_TEST_MODEL_DIR), quindi in CI risulta ignorato.
  • In locale:
    • tasks check: 371 superati, 2 ignorati;
    • tutta la suite su PostgreSQL 18, col modello: 371 superati, 2 ignorati (quelli solo per SQLite e la guardia).

refs #56 #57

🤖 Generated with Claude Code

Primo pezzo della Fase 7: le notizie entrano nel bot, pulite, raggruppate, collegate e giudicate in locale. Le scelte sono nell'ADR 0014. ## Raccolta (#56) - Il lavoro "notizie" legge ogni 2 minuti le 14 fonti di SPEC 4.4. Le richieste sono condizionate (ETag, If-Modified-Since), con un secondo di pausa tra una fonte e l'altra. Una fonte che sbaglia si riprova dopo 2, 4, 8… minuti, al massimo ogni ora, e l'errore resta scritto. - RSS 2.0, RSS 1.0 e Atom si leggono senza DTD né entità: un feed ostile non legge il disco. - Un articolo con un indirizzo già visto, tolti i parametri di tracciamento, è un doppione. - Le riprese dello stesso fatto entro 48 ore diventano una storia. La storia conta le fonti indipendenti per dominio e dice se almeno una è affidabile. - Collegamenti: - agli strumenti: simboli della fonte, `$TICKER`, `(NASDAQ: X)`, sigle delle crypto, nomi delle società e delle monete; - alle classi o al mercato: temi come banche centrali, inflazione, criptovalute, Wall Street; - se non si trova niente, all'argomento della fonte. I nomi comuni (Target, Visa…) contano solo con il ticker. ## Primo giudizio (#57) - Casi gravi con parole chiave in inglese e italiano: attacco informatico, sospensione, frode, fallimento, indagine, revoca dalla quotazione. - Tono in cinque gradi con le soglie di 10.2. - Importanza: 4 ai casi gravi, 3 alle notizie negative, 2 a quelle collegate a uno strumento, 1 al resto. - **Classificatore ONNX** (ADR 0014, punto 8): - il modello è `onnx/model_quantized.onnx` di Xenova, revisione `e6953e30`, 83 MB, SHA-256 `8fcf4873…48ec`; - il bot lo scarica in sottofondo nella cartella `models` dei dati, controlla dimensione e hash, e se qualcosa va storto riprova dopo 6 ore; - finché manca, giudicano le sole parole chiave. - Il tokenizzatore BPE di RoBERTa sta nella DLL e non riconosce token speciali nel testo. - `CodeGenTokenizer.Create` è scartato perché aggiunge identificativi che il modello rifiuta. - Pacchetti dall'elenco dell'ADR 0004: `Microsoft.ML.OnnxRuntime` 1.31.1 e `Microsoft.ML.Tokenizers` 2.0.1, più `Google.Protobuf` 3.30.2 come dipendenza indiretta. - `Anubis` e `Anubis.Server` dichiarano il runtime `win-x64`: lo zip per Windows non cambia più i file di blocco. Lo zip passa da 3,4 a 10,7 MB per la libreria nativa di ONNX Runtime. ## Prove - `NewsTests`: 11 test sull'archivio sintetico `tests/Anubis.Tests/Fixtures/news/`, nel formato reale di ogni fonte. Verdi su SQLite e PostgreSQL. - `ToneModelTests`: - gli identificativi coincidono con l'originale su 14 titoli con accenti, simboli e spazi; - un modello con l'hash sbagliato non si usa mai; - col modello vero, positivi e negativi chiari sono letti bene, a 23–24 ms per titolo su un thread. Gira dove il modello è già scaricato (`ANUBIS_TEST_MODEL_DIR`), quindi in CI risulta ignorato. - In locale: - `tasks check`: 371 superati, 2 ignorati; - tutta la suite su PostgreSQL 18, col modello: 371 superati, 2 ignorati (quelli solo per SQLite e la guardia). refs #56 #57 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added this to the Fase 7 — Notizie milestone 2026-11-14 18:58:06 +01:00
Alby96 added 3 commits 2026-11-14 18:58:07 +01:00
News is the first input of Phase 7. Every two minutes the "notizie" job asks each
enabled feed conditionally and backs off a failing one up to an hour.

- Parsing: RSS 2.0, RSS 1.0 and Atom are read without DTDs or entity expansion, so a
  hostile feed reads nothing from disk.
- Deduplication: articles are deduplicated by canonical URL.
- Grouping: retold titles join one story by word similarity within 48 hours, and
  independent publishers are counted by registrable domain.
- Linking: stories are linked to instruments by source symbols, cashtags, exchange
  tickers, coin tickers and capitalised company names; to the crypto or equity class
  or to the market by theme; to the source topic as a fallback.

ADR 0014 records the thresholds. The tests read a synthetic archive in each source's
real format and run on both engines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This is the first judgement of SPEC 10.2 point 4, without a language model.

- Serious cases: cyberattack, suspension, fraud, bankruptcy, investigation and
  delisting are found by whole-word phrases in English and Italian, so an
  Italian headline still counts.
- Tone: the five tone grades follow the bounds of the specification.
- Importance: 4 for a serious case, 3 for a negative tone, 2 when the article is
  linked to an instrument, otherwise 1.
- Classifier: it sits behind IToneClassifier and is asked only for English
  titles. The ONNX model plugs in there; without it the tone stays unknown and
  everything else works.

Every article stores its score, case and importance. Each story keeps the mean
score, the case and the highest importance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the news collection and the first judgement in the project state (refs #56 #57)
ci / test (postgres) (pull_request) Successful in 9m37s
ci / test (sqlite) (pull_request) Successful in 4m20s
ci / image (pull_request) Successful in 2m32s
ci / test (sqlite) (push) Successful in 4m24s
ci / test (postgres) (push) Failing after 9m18s
ci / image (push) Skipped
5f0ce6b172
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-15 12:02:56 +01:00
Read the tone of English headlines with the pinned ONNX model of SPEC 4.5 (refs #57)
ci / test (postgres) (push) Failing after 6m20s
ci / test (sqlite) (push) Failing after 5m59s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Failing after 4m51s
ci / test (sqlite) (pull_request) Successful in 5m29s
ci / image (pull_request) Skipped
78e77818eb
The classifier is distilroberta-finetuned-financial-news-sentiment-analysis in
Xenova's quantized ONNX export, pinned at revision e6953e30 and checked by size and
SHA-256.

- Model download: the model is not in the repository. The news job downloads it in
  the background into the models folder of the data directory, the first time, and
  retries after 6 hours if that fails. Until then the keywords judge alone, as
  SPEC 10.3 requires.
- Tokenizer: RoBERTa's byte-level BPE travels inside the DLL, read with
  BpeTokenizer and the RoBERTa pre-tokenizer. CodeGenTokenizer.Create adds ids for
  runs of spaces that the model rejects. No special tokens are recognised in
  untrusted text.
- Token check: the test compares the ids on 14 headlines with an independent copy
  of the GPT-2 encoder run on the same files.
- Model test: it reads the tone of clear headlines at 23-24 ms per title on one
  thread. It runs where the model is already downloaded and is skipped in CI.

Microsoft.ML.OnnxRuntime 1.31.1 and Microsoft.ML.Tokenizers 2.0.1 come from the
ADR 0004 list. Google.Protobuf joins the known indirect dependencies.

Anubis and Anubis.Server now declare win-x64 among their runtime identifiers, so
their lock files hold the Windows native packages. Publishing the Windows zip no
longer rewrites the lock files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 changed title from Fase 7: raccolta, collegamento e primo giudizio delle notizie to Fase 7: raccolta, collegamento e primo giudizio delle notizie, con il classificatore ONNX 2026-11-15 12:03:20 +01:00
Alby96 added 1 commit 2026-11-15 12:47:43 +01:00
Let the server test accept the news feeds and the pinned model host (refs #57)
ci / test (postgres) (push) Successful in 11m31s
ci / test (sqlite) (push) Successful in 5m26s
ci / test (postgres) (pull_request) Successful in 10m7s
ci / test (sqlite) (pull_request) Successful in 5m13s
ci / image (push) Successful in 3m12s
ci / image (pull_request) Successful in 1m46s
1aede2fc1c
The news collector runs alongside the market data in the server test, so its
feeds and the Hugging Face download of the classifier can reach the fake network
before the assertion: they are the hosts the code declares, nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 merged commit a66e3439d8 into main 2026-11-15 15:34:41 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BalboSoft/Anubis#97