a802f59f55
- cmd/fn/doctor.go - cmd/fn/main.go - cpp/apps/primitives_gallery/playground/tables/CMakeLists.txt - cpp/apps/primitives_gallery/playground/tables/data_table.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.cpp - cpp/apps/primitives_gallery/playground/tables/data_table_logic.h - cpp/apps/primitives_gallery/playground/tables/self_test.cpp - cpp/apps/primitives_gallery/playground/tables/tql.cpp - cpp/apps/primitives_gallery/playground/tables/viz.cpp - cpp/apps/primitives_gallery/playground/tables/viz.h - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.8 KiB
Markdown
50 lines
1.8 KiB
Markdown
---
|
|
name: vault_diff
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: pure
|
|
signature: "func VaultDiff(prev, curr []VaultFile) VaultDiffReport"
|
|
description: "Computes the diff between two vault snapshots (slices of VaultFile). Returns Added, Removed, Changed and Unchanged counts. Pure and deterministic — no I/O."
|
|
tags: [vault, diff, comparison, pure]
|
|
uses_functions: []
|
|
uses_types: ["vault_file_go_infra"]
|
|
returns: []
|
|
returns_optional: false
|
|
error_type: ""
|
|
imports: ["sort"]
|
|
tested: true
|
|
tests:
|
|
- "TestVaultDiff_NoChanges"
|
|
- "TestVaultDiff_AllAdded"
|
|
- "TestVaultDiff_AllRemoved"
|
|
- "TestVaultDiff_ContentChanged"
|
|
- "TestVaultDiff_Mixed"
|
|
test_file_path: "functions/infra/vault_diff_test.go"
|
|
file_path: "functions/infra/vault_diff.go"
|
|
params:
|
|
- name: prev
|
|
desc: "Snapshot anterior — slice de VaultFile del estado previo del vault (puede ser nil para diff desde cero)."
|
|
- name: curr
|
|
desc: "Snapshot actual — slice de VaultFile del estado corriente del vault (puede ser nil para diff de borrado total)."
|
|
output: "VaultDiffReport con Added (nuevos), Removed (eliminados), Changed (mismo rel_path, sha256 distinto) y Unchanged (identicos). Todos los slices ordenados por RelPath ASC."
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
prev, _ := infra.VaultInventoryScan(oldPath, "my_vault_proj", "my_vault")
|
|
curr, _ := infra.VaultInventoryScan(newPath, "my_vault_proj", "my_vault")
|
|
report := infra.VaultDiff(prev, curr)
|
|
fmt.Printf("Added: %d, Removed: %d, Changed: %d, Unchanged: %d\n",
|
|
len(report.Added), len(report.Removed), len(report.Changed), report.Unchanged)
|
|
```
|
|
|
|
## Notas
|
|
|
|
- Usa `RelPath` como clave de identidad de archivo (no nombre, no sha256).
|
|
- Dos archivos con mismo `RelPath` pero diferente `Sha256` se consideran Changed.
|
|
- Los slices del report se ordenan por `RelPath` ASC para salida deterministica.
|
|
- Función pura: no toca disco ni BD.
|