| generate_proposals_from_telemetry |
go |
infra |
0.1.0 |
impure |
function |
Genera proposals automaticas para registry.db.proposals a partir de telemetria de call_monitor.operations.db. Aplica 4 reglas MVP: copy_detected, orphan, bug, wrapper_skip. IDs deterministas (sha1 truncado) garantizan idempotencia. Cierra la fase MEJORAR del bucle reactivo. Issue 0085h. |
| audit |
| reactive-loop |
| monitoring |
| proposals |
| registry |
|
func GenerateProposalsFromTelemetry(registryRoot string) ([]ProposalDraft, error) |
error_go_core |
false |
| name |
desc |
| registryRoot |
Path absoluto a raiz del fn_registry (contiene registry.db y projects/fn_monitoring/apps/call_monitor/operations.db). |
|
|
Lista de ProposalDraft con kind, target_id, title, description, rule_id, evidence. NO escribe a DB — usar PersistProposalDrafts para persistir. |
|
|
| crypto/sha1 |
| database/sql |
| encoding/json |
| fmt |
| path/filepath |
| strings |
| time |
| github.com/mattn/go-sqlite3 |
|
import "fn-registry/functions/infra"
drafts, err := infra.GenerateProposalsFromTelemetry("$HOME/fn_registry")
if err != nil { ... }
inserted, total, err := infra.PersistProposalDrafts("$HOME/fn_registry", drafts)
fmt.Printf("%d/%d proposals nuevas\n", inserted, total)
|
functions/infra/generate_proposals_from_telemetry.go |
false |
Reglas MVP implementadas:
| Regla | Threshold | Proposal |
|---|---|---|
| copy_detected | match en copied_code | improve_function (target = registry_id matched) |
| orphan | calls_90d=0 AND writes_count=0 AND no upstream consumer | deprecate_function |
| bug | error_rate>0.1 AND calls_total>3 | improve_function |
| wrapper_skip | violations.function_id COUNT > 3 | improve_function |
Reglas pendientes (sin data aun):
- perf_regression: requiere p95 (no almacenado todavia).
- test_flaky: requiere test_runs poblado.
- e2e_blast_radius: requiere e2e_runs_fn poblado.
- pattern_inline: requiere patterns clustering (0085f).
Idempotencia: cada proposal tiene `id = auto_{rule}_{sha1-10}` deterministico
sobre (rule_id, target_id, extra). PersistProposalDrafts usa INSERT OR IGNORE
para no sobreescribir proposals ya revisadas (approved/rejected).
created_by='reactive_loop' para distinguir de proposals manuales.
Filtrado orphan: cruza con `uses_functions` JSON arrays de functions/apps/
analysis. Si alguien declara la funcion como dependencia, no se marca orfana
aunque tenga calls_90d=0 (uso intencional, no instrumentado por telemetria).
|