988e901066
Añade campos params y output al frontmatter YAML de las 506 funciones del registry. Cada parámetro tiene descripción semántica (qué representa, unidades, rango típico) y cada función describe qué produce su output. Permite a agentes razonar sobre cadenas de composición (ej: prices → log_return → sharpe_ratio) sin leer código.
2.4 KiB
2.4 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| diff_entities | function | go | datascience | 1.0.0 | pure | func DiffEntities(before, after []map[string]any, key string, ignoreFields []string) map[string]any | Compara dos snapshots de entities y devuelve diferencias campo a campo. Detecta añadidas, eliminadas, modificadas e inalteradas. Ignora created_at y updated_at por defecto (pasar nil para usar defaults). |
|
false |
|
|
mapa con 'summary', 'added', 'removed', 'modified', 'unchanged' - análisis completo de diferencias | true |
|
functions/datascience/diff_entities_test.go | functions/datascience/diff_entities.go |
Ejemplo
before := []map[string]any{
{"id": "1", "name": "Alice", "status": "active"},
{"id": "2", "name": "Bob"},
}
after := []map[string]any{
{"id": "1", "name": "Alice", "status": "inactive"},
{"id": "3", "name": "Carol"},
}
result := DiffEntities(before, after, "id", nil)
// result["summary"] = "1 added, 1 removed, 1 modified, 0 unchanged"
// result["added"] = [{"id": "3", "name": "Carol"}]
// result["removed"] = [{"id": "2", "name": "Bob"}]
// result["modified"] = [{"key": "1", "changes": {"status": {"old": "active", "new": "inactive"}}}]
Notas
Funcion pura. Compara valores con fmt.Sprintf("%v", ...) para manejar tipos heterogeneos en map[string]any. ignoreFields nil usa los defaults ["created_at", "updated_at"]. Para no ignorar ningun campo, pasar []string{}. Semantica identica a diff_entities_py_datascience, permite comparar resultados entre ejecuciones del mismo pipeline.