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>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
// ingestion/internal/wiki/log.go
|
|
package wiki
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/mathiasbq/hyperguild/ingestion/internal/brainfs"
|
|
"strings"
|
|
)
|
|
|
|
// AppendLog appends one ingestion record to brain/log.md.
|
|
func AppendLog(brainDir, source string, pages, warnings []string, date string) error {
|
|
var sb strings.Builder
|
|
fmt.Fprintf(&sb, "## %s — ingest\n\n", date)
|
|
fmt.Fprintf(&sb, "- **Source:** %s\n", source)
|
|
if len(pages) > 0 {
|
|
sb.WriteString("- **Pages written:**\n")
|
|
for _, p := range pages {
|
|
fmt.Fprintf(&sb, " - %s\n", p)
|
|
}
|
|
}
|
|
if len(warnings) > 0 {
|
|
sb.WriteString("- **Warnings:**\n")
|
|
for _, w := range warnings {
|
|
fmt.Fprintf(&sb, " - %s\n", w)
|
|
}
|
|
}
|
|
sb.WriteString("\n")
|
|
|
|
// Appended through the brain root, never through a symlink (#158).
|
|
bfs, err := brainfs.Open(brainDir)
|
|
if err != nil {
|
|
return fmt.Errorf("open brain: %w", err)
|
|
}
|
|
defer func() { _ = bfs.Close() }()
|
|
if err := bfs.AppendRegular("log.md", []byte(sb.String())); err != nil {
|
|
return fmt.Errorf("write log: %w", err)
|
|
}
|
|
return nil
|
|
}
|