fix: creating and generated writes go through the brain root (#188, #158 part A) (#189)
CI / Lint / Test / Vet (push) Failing after 1m2s
CI / Mirror to GitHub (push) Skipped

New brainfs PutRegular (create or replace), CreateRegular (create only), AppendRegular, Remove and RealParent: missing parents created one component at a time through the root, every existing component a real directory, new files created with O_EXCL and confirmed before writing. brain_write, promote/reject (O_EXCL create, source kept on refusal), StampProvenanceFile, BuildWingIndex, RebuildIndex, AppendLog and the tunnel candidate log use them; provenance.ApplyFile removed.

Fixes #188. Refs #158. Adversarial review: BLOCKED, BLOCKED, PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mathias <mthbqv@gmail.com>
This commit was merged in pull request #189.
This commit is contained in:
2026-10-05 21:25:54 +00:00
committed by mathias
co-authored by Claude Opus 5.5
parent bd989f887f
commit f4636c7ef0
15 changed files with 645 additions and 82 deletions
+7 -8
View File
@@ -3,8 +3,7 @@ package wiki
import (
"fmt"
"os"
"path/filepath"
"github.com/mathiasbq/hyperguild/ingestion/internal/brainfs"
"strings"
)
@@ -27,14 +26,14 @@ func AppendLog(brainDir, source string, pages, warnings []string, date string) e
}
sb.WriteString("\n")
logPath := filepath.Join(brainDir, "log.md")
f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
// Appended through the brain root, never through a symlink (#158).
bfs, err := brainfs.Open(brainDir)
if err != nil {
return fmt.Errorf("open log: %w", err)
return fmt.Errorf("open brain: %w", err)
}
if _, err = f.WriteString(sb.String()); err != nil {
f.Close() //nolint:errcheck
defer func() { _ = bfs.Close() }()
if err := bfs.AppendRegular("log.md", []byte(sb.String())); err != nil {
return fmt.Errorf("write log: %w", err)
}
return f.Close()
return nil
}