4ef6a5f7db
Status sincronizado con master: - 0001 chat con Claude -> shipped como panel Echo - 0003 enricher web -> shipped (0028 + 0028b) - 0026 sistema de jobs -> shipped - 0027 tipo Webpage -> shipped - 0028 fetch_webpage -> shipped - 0028b extract trio -> shipped - 0031 layout estable -> shipped Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.8 KiB
2.8 KiB
id, title, status, priority, created, depends_on
| id | title | status | priority | created | depends_on | ||
|---|---|---|---|---|---|---|---|
| 0028 | Enricher fetch_webpage (MVP end-to-end) | pending | high | 2026-05-01 |
|
Objetivo
Primer enricher real sobre el sistema de jobs (0026). Right-click sobre
un nodo Url o Webpage → "Fetch web page". Descarga el HTML, lo
convierte a markdown, guarda los blobs en cache, actualiza el nodo
(o lo convierte a Webpage si era Url) y crea el nodo Domain con
relacion BELONGS_TO.
Este enricher valida el contrato entero. Los siguientes (0028b) reusan exactamente el mismo wire protocol.
Archivos
apps/graph_explorer/enrichers/fetch_webpage/
manifest.yaml
run.py
manifest.yaml
id: fetch_webpage
name: "Fetch web page"
description: "Descarga HTML, extrae markdown limpio y guarda en cache."
applies_to: [Webpage, Url]
emits: [Domain]
relations: [BELONGS_TO]
params:
- { name: timeout_s, type: int, default: 15 }
run.py
Logica:
- Lee JSON de stdin.
- Saca
urldemetadata.url(ometadata.addresssi es Url legacy). PROGRESS:0.05 normalize—normalize_url_py_cybersecurity.PROGRESS:0.20 fetching— descarga viarequests.get(url, timeout=N).PROGRESS:0.60 parsing—html_to_markdown_py_corecon readabilipy.PROGRESS:0.85 writing— calcula sha256(url), escribecache/<sha[0:2]>/<sha>.htmly.md.- Emite stdout JSON:
node_updates: cambia type a Webpage si era Url, anade title/status_code/content_type/fetched_at/html_path/markdown_path/text_length.entities:{type: Domain, name: <dominio>, metadata: {}}.relations:from_id: <node_id>, to_name: <dominio>, to_type: Domain, kind: BELONGS_TO.
Funciones del registry usadas
normalize_url_py_cybersecurity— limpia tracking params.html_to_markdown_py_core— readabilipy + markdownify.extract_domainse hace inline en el enricher (regex trivial sobre la URL parseada).
Manejo de errores
- HTTP error (4xx/5xx) → escribe status_code en metadata pero NO marca el job como error (el nodo guarda evidencia del fallo).
- Timeout / DNS error / etc → exit con error JSON en stdout:
{"error": "...", "node_updates": [], "entities": [], "relations": []}. - Si el enricher levanta excepcion, sale con codigo != 0 y stderr capturado va a
jobs.error.
Definicion de hecho
- Crear nodo Url con
https://example.com→ click derecho → "Fetch web page". - En segundos aparece en panel Jobs como
runningcon progress. - Al terminar:
- El nodo cambia a tipo
Webpagecon iconoti-file-text. - El inspector muestra title, status_code, html_path, markdown_path.
- Aparece nodo
Domain"example.com" conectado porBELONGS_TO. - El archivo
cache/<sha>.mdexiste en disco.
- El nodo cambia a tipo
- El job aparece en panel Jobs como
doneconentities_added=1, relations_added=1. - Tirar la red (sin internet) → el job acaba en
errorcon mensaje claro.