Closes #144 (audit line per tools/call) and #145 (origin/written_by stamped on every model-reachable write, surfaced in brain_query/brain_get). Passed pr-gatekeeper after four rounds of adversarial review, verified by execution: #147 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Mathias <mthbqv@gmail.com>
22 lines
810 B
Go
22 lines
810 B
Go
package api
|
|
|
|
import (
|
|
"github.com/mathiasbq/hyperguild/ingestion/internal/provenance"
|
|
)
|
|
|
|
// StampProvenance applies server-owned provenance (hyperguild#145) to note
|
|
// content. See package provenance for the rule; an error means the stamped
|
|
// note would not read back as stamped, and the write must be refused.
|
|
func StampProvenance(content, origin, writtenBy string) (string, error) {
|
|
return provenance.Apply(content, provenance.Stamp{Origin: origin, WrittenBy: writtenBy})
|
|
}
|
|
|
|
// StampProvenanceFile applies StampProvenance to a brain-relative note path.
|
|
func StampProvenanceFile(brainDir, relPath, origin, writtenBy string) error {
|
|
_, abs, err := resolveWithin(brainDir, relPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return provenance.ApplyFile(abs, provenance.Stamp{Origin: origin, WrittenBy: writtenBy})
|
|
}
|