Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef11864121 | ||
|
|
14b04a25cb | ||
|
|
66a9b8e725 | ||
|
|
9f8fb9c138 | ||
|
|
d39a18dd69 | ||
|
|
5288554338 | ||
|
|
2368564523 | ||
|
|
0e28b2125b |
@@ -369,6 +369,8 @@ func main() {
|
|||||||
mux.HandleFunc("POST /ingest-path", h.IngestPath)
|
mux.HandleFunc("POST /ingest-path", h.IngestPath)
|
||||||
mux.HandleFunc("POST /ingest-raw", h.IngestRaw)
|
mux.HandleFunc("POST /ingest-raw", h.IngestRaw)
|
||||||
mux.HandleFunc("POST /backfill-refs", h.BackfillRefs)
|
mux.HandleFunc("POST /backfill-refs", h.BackfillRefs)
|
||||||
|
mux.HandleFunc("GET /pending", h.Pending)
|
||||||
|
mux.HandleFunc("POST /promote", h.Promote)
|
||||||
mux.HandleFunc("POST /backfill-embeddings", h.BackfillEmbeddings)
|
mux.HandleFunc("POST /backfill-embeddings", h.BackfillEmbeddings)
|
||||||
mux.HandleFunc("GET /pass-rate", h.PassRate)
|
mux.HandleFunc("GET /pass-rate", h.PassRate)
|
||||||
jwtValidator, err := chassisauth.NewJWTValidator(ctx, os.Getenv("DEX_ISSUER_URL"), os.Getenv("MCP_AUDIENCE"))
|
jwtValidator, err := chassisauth.NewJWTValidator(ctx, os.Getenv("DEX_ISSUER_URL"), os.Getenv("MCP_AUDIENCE"))
|
||||||
@@ -410,8 +412,12 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
auditSink := buildAuditSink(ctx, brainDir, logger)
|
auditSink := buildAuditSink(ctx, brainDir, logger)
|
||||||
|
// The Gitea client also satisfies SummaryWriter (#66): session
|
||||||
|
// summaries are written to mathias/ai-sessions over the same API
|
||||||
|
// token. nil only if a future tracker impl lacks file writes.
|
||||||
|
summaryWriter, _ := tracker.(capture.SummaryWriter)
|
||||||
captureSvc := capture.NewService(
|
captureSvc := capture.NewService(
|
||||||
mcpSrv.BrainStore(), tracker, nil, classCfg, auditSink)
|
mcpSrv.BrainStore(), tracker, summaryWriter, classCfg, auditSink)
|
||||||
sovereign := splitList(os.Getenv("BRAIN_CAPTURE_SOVEREIGN_PRINCIPALS"))
|
sovereign := splitList(os.Getenv("BRAIN_CAPTURE_SOVEREIGN_PRINCIPALS"))
|
||||||
resolver := capturehttp.NewOriginResolver(sovereign)
|
resolver := capturehttp.NewOriginResolver(sovereign)
|
||||||
captureH := capturehttp.New(captureSvc, jwtValidator, mcpToken, "local-cli", resolver)
|
captureH := capturehttp.New(captureSvc, jwtValidator, mcpToken, "local-cli", resolver)
|
||||||
|
|||||||
@@ -483,6 +483,40 @@ func (h *Handler) BackfillRefs(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeJSON(w, map[string]int{"updated": n})
|
writeJSON(w, map[string]int{"updated": n})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pending handles GET /pending — list raw/ notes awaiting promotion.
|
||||||
|
func (h *Handler) Pending(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
pending, err := ListPending(h.brainDir)
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Error("pending failed", "err", err)
|
||||||
|
writeError(w, http.StatusInternalServerError, "pending error")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeJSON(w, map[string]any{"pending": pending})
|
||||||
|
}
|
||||||
|
|
||||||
|
type promoteRequest struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
Wing string `json:"wing"`
|
||||||
|
Hall string `json:"hall"`
|
||||||
|
Slug string `json:"slug,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Promote handles POST /promote — move a raw/ note into the wiki. A bad
|
||||||
|
// hall / collision / missing source is a 400 (caller error), not a 500.
|
||||||
|
func (h *Handler) Promote(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req promoteRequest
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, "invalid JSON")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rel, err := PromoteNote(h.brainDir, PromoteOptions(req))
|
||||||
|
if err != nil {
|
||||||
|
writeError(w, http.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeJSON(w, map[string]string{"path": rel})
|
||||||
|
}
|
||||||
|
|
||||||
func writeJSON(w http.ResponseWriter, v any) {
|
func writeJSON(w http.ResponseWriter, v any) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
json.NewEncoder(w).Encode(v) //nolint:errcheck
|
json.NewEncoder(w).Encode(v) //nolint:errcheck
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/mathiasbq/hyperguild/ingestion/internal/brain"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PendingNote describes a raw/ note awaiting human promotion to the wiki.
|
||||||
|
type PendingNote struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
CreatedAt string `json:"created_at"`
|
||||||
|
SizeBytes int64 `json:"size_bytes"`
|
||||||
|
Excerpt string `json:"excerpt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// datePrefix matches a leading YYYY-MM-DD- on a raw filename, stripped when
|
||||||
|
// deriving the default promoted slug.
|
||||||
|
var datePrefix = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}-`)
|
||||||
|
|
||||||
|
// ListPending returns the notes in brain/raw/ awaiting review, oldest-first
|
||||||
|
// (natural review order). An absent raw/ dir yields an empty slice, not an
|
||||||
|
// error. Only .md files are listed; tunnel-candidate files are skipped.
|
||||||
|
func ListPending(brainDir string) ([]PendingNote, error) {
|
||||||
|
dir := filepath.Join(brainDir, "raw")
|
||||||
|
entries, err := os.ReadDir(dir)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return []PendingNote{}, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("read raw dir: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
out := make([]PendingNote, 0, len(entries))
|
||||||
|
for _, e := range entries {
|
||||||
|
if e.IsDir() || !strings.HasSuffix(e.Name(), ".md") || strings.HasPrefix(e.Name(), "tunnel-candidates-") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
info, statErr := e.Info()
|
||||||
|
if statErr != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
raw, readErr := os.ReadFile(filepath.Join(dir, e.Name()))
|
||||||
|
if readErr != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fm, body := parseFrontmatter(string(raw))
|
||||||
|
created := fm.get("created_at")
|
||||||
|
if created == "" {
|
||||||
|
created = info.ModTime().UTC().Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
out = append(out, PendingNote{
|
||||||
|
Filename: e.Name(),
|
||||||
|
CreatedAt: created,
|
||||||
|
SizeBytes: info.Size(),
|
||||||
|
Excerpt: excerpt(body, 200),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
sort.SliceStable(out, func(i, j int) bool { return out[i].CreatedAt < out[j].CreatedAt })
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PromoteOptions identifies a raw note to promote and its wiki destination.
|
||||||
|
type PromoteOptions struct {
|
||||||
|
Filename string // basename in brain/raw/
|
||||||
|
Wing string
|
||||||
|
Hall string
|
||||||
|
Slug string // optional; defaults to Filename minus date prefix + .md
|
||||||
|
}
|
||||||
|
|
||||||
|
// PromoteNote moves a note from brain/raw/ into the structured wiki: it
|
||||||
|
// rewrites frontmatter (sets wing/hall/promoted_at, preserves created_at and
|
||||||
|
// any custom fields), writes to brain/wiki/<wing>/<hall>/<slug>.md, deletes
|
||||||
|
// the source, then rebuilds the wing index and runs auto-tunnel detection.
|
||||||
|
//
|
||||||
|
// It is atomic from the caller's view: validation (hall, wing, slug,
|
||||||
|
// collision) happens before any filesystem change, and the source is deleted
|
||||||
|
// only after the destination write succeeds (write-then-delete, never move).
|
||||||
|
// Returns the promoted note's path relative to brainDir.
|
||||||
|
func PromoteNote(brainDir string, opts PromoteOptions) (string, error) {
|
||||||
|
// Validate filename (basename only — no traversal) before touching fs.
|
||||||
|
base := filepath.Base(opts.Filename)
|
||||||
|
if base != opts.Filename || base == "." || base == ".." || strings.ContainsAny(opts.Filename, `/\`) {
|
||||||
|
return "", fmt.Errorf("invalid filename %q", opts.Filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
slug := opts.Slug
|
||||||
|
if slug == "" {
|
||||||
|
slug = datePrefix.ReplaceAllString(strings.TrimSuffix(base, ".md"), "")
|
||||||
|
}
|
||||||
|
// NotePath validates hall + wing + slug; do this before reading anything.
|
||||||
|
dest, err := brain.NotePath(brainDir, opts.Wing, opts.Hall, slug)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
src := filepath.Join(brainDir, "raw", base)
|
||||||
|
raw, err := os.ReadFile(src)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return "", fmt.Errorf("pending note %q does not exist in raw/", base)
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("read source: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collision: never silently overwrite an existing promoted note.
|
||||||
|
if _, statErr := os.Stat(dest); statErr == nil {
|
||||||
|
rel, _ := filepath.Rel(brainDir, dest)
|
||||||
|
return "", fmt.Errorf("target %s already exists; choose a different slug", filepath.ToSlash(rel))
|
||||||
|
}
|
||||||
|
|
||||||
|
fm, body := parseFrontmatter(string(raw))
|
||||||
|
now := time.Now().UTC().Format(time.RFC3339)
|
||||||
|
fm.set("wing", brain.Sanitise(opts.Wing))
|
||||||
|
fm.set("hall", opts.Hall)
|
||||||
|
if fm.get("created_at") == "" {
|
||||||
|
fm.set("created_at", now)
|
||||||
|
}
|
||||||
|
fm.set("promoted_at", now)
|
||||||
|
|
||||||
|
if err := os.MkdirAll(filepath.Dir(dest), 0o755); err != nil {
|
||||||
|
return "", fmt.Errorf("create wing dir: %w", err)
|
||||||
|
}
|
||||||
|
// Write-then-delete: the source survives any write failure.
|
||||||
|
if err := os.WriteFile(dest, []byte(fm.render()+body), 0o644); err != nil {
|
||||||
|
return "", fmt.Errorf("write promoted note: %w", err)
|
||||||
|
}
|
||||||
|
if err := os.Remove(src); err != nil {
|
||||||
|
return "", fmt.Errorf("promoted note written but source removal failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rel, _ := filepath.Rel(brainDir, dest)
|
||||||
|
relSlash := filepath.ToSlash(rel)
|
||||||
|
|
||||||
|
// Best-effort wiki upkeep — the note is already promoted.
|
||||||
|
_ = brain.BuildWingIndex(brainDir, opts.Wing)
|
||||||
|
_ = brain.AutoTunnel(brainDir, relSlash, body)
|
||||||
|
|
||||||
|
return relSlash, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// excerpt returns the first n runes of s, trimmed, single-spaced.
|
||||||
|
func excerpt(s string, n int) string {
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
r := []rune(s)
|
||||||
|
if len(r) > n {
|
||||||
|
r = r[:n]
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(r))
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func writeRaw(t *testing.T, brainDir, name, content string) {
|
||||||
|
t.Helper()
|
||||||
|
dir := filepath.Join(brainDir, "raw")
|
||||||
|
require.NoError(t, os.MkdirAll(dir, 0o755))
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(dir, name), []byte(content), 0o644))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListPendingEmptyWhenAbsent(t *testing.T) {
|
||||||
|
got, err := ListPending(t.TempDir())
|
||||||
|
require.NoError(t, err, "absent raw/ is not an error")
|
||||||
|
assert.Empty(t, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestListPendingReturnsOldestFirstWithExcerpt(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writeRaw(t, dir, "2026-06-02-newer.md", "---\ncreated_at: 2026-06-02T00:00:00Z\n---\nNewer body here.\n")
|
||||||
|
writeRaw(t, dir, "2026-06-01-older.md", "---\ncreated_at: 2026-06-01T00:00:00Z\n---\nOlder body content.\n")
|
||||||
|
// non-md ignored
|
||||||
|
writeRaw(t, dir, "notes.txt", "ignore me")
|
||||||
|
|
||||||
|
got, err := ListPending(dir)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, got, 2)
|
||||||
|
assert.Equal(t, "2026-06-01-older.md", got[0].Filename, "oldest first")
|
||||||
|
assert.Equal(t, "2026-06-02-newer.md", got[1].Filename)
|
||||||
|
assert.Contains(t, got[0].Excerpt, "Older body content")
|
||||||
|
assert.NotContains(t, got[0].Excerpt, "---", "excerpt is body, not frontmatter")
|
||||||
|
assert.Positive(t, got[0].SizeBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteHappyPath(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writeRaw(t, dir, "2026-06-01-lejpa-decision.md",
|
||||||
|
"---\ncreated_at: 2026-06-01T09:00:00Z\ncustom_field: keep-me\n---\n# LeJEPA\n\nbody.\n")
|
||||||
|
|
||||||
|
rel, err := PromoteNote(dir, PromoteOptions{
|
||||||
|
Filename: "2026-06-01-lejpa-decision.md", Wing: "jepa-fx", Hall: "decisions",
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "wiki/jepa-fx/decisions/lejpa-decision.md", rel, "slug defaults to filename minus date prefix")
|
||||||
|
|
||||||
|
// Source deleted.
|
||||||
|
_, statErr := os.Stat(filepath.Join(dir, "raw", "2026-06-01-lejpa-decision.md"))
|
||||||
|
assert.True(t, os.IsNotExist(statErr), "source removed after promote")
|
||||||
|
|
||||||
|
got, err := os.ReadFile(filepath.Join(dir, filepath.FromSlash(rel)))
|
||||||
|
require.NoError(t, err)
|
||||||
|
s := string(got)
|
||||||
|
assert.Contains(t, s, "wing: jepa-fx")
|
||||||
|
assert.Contains(t, s, "hall: decisions")
|
||||||
|
assert.Contains(t, s, "created_at: 2026-06-01T09:00:00Z", "original created_at preserved")
|
||||||
|
assert.Contains(t, s, "promoted_at:")
|
||||||
|
assert.Contains(t, s, "custom_field: keep-me", "custom frontmatter preserved")
|
||||||
|
assert.Contains(t, s, "# LeJEPA")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteExplicitSlug(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writeRaw(t, dir, "2026-06-01-x.md", "body\n")
|
||||||
|
rel, err := PromoteNote(dir, PromoteOptions{Filename: "2026-06-01-x.md", Wing: "a", Hall: "facts", Slug: "custom-slug"})
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "wiki/a/facts/custom-slug.md", rel)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteInvalidHallErrorsBeforeTouchingFS(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writeRaw(t, dir, "2026-06-01-x.md", "body\n")
|
||||||
|
_, err := PromoteNote(dir, PromoteOptions{Filename: "2026-06-01-x.md", Wing: "a", Hall: "garbage"})
|
||||||
|
require.Error(t, err)
|
||||||
|
// Source untouched.
|
||||||
|
_, statErr := os.Stat(filepath.Join(dir, "raw", "2026-06-01-x.md"))
|
||||||
|
assert.NoError(t, statErr, "invalid hall must not delete or move the source")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteMissingSourceErrors(t *testing.T) {
|
||||||
|
_, err := PromoteNote(t.TempDir(), PromoteOptions{Filename: "ghost.md", Wing: "a", Hall: "facts"})
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteSlugCollisionNoOverwrite(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
// Pre-existing target.
|
||||||
|
dest := filepath.Join(dir, "wiki", "a", "facts", "x.md")
|
||||||
|
require.NoError(t, os.MkdirAll(filepath.Dir(dest), 0o755))
|
||||||
|
require.NoError(t, os.WriteFile(dest, []byte("EXISTING\n"), 0o644))
|
||||||
|
writeRaw(t, dir, "2026-06-01-x.md", "NEW\n")
|
||||||
|
|
||||||
|
_, err := PromoteNote(dir, PromoteOptions{Filename: "2026-06-01-x.md", Wing: "a", Hall: "facts"})
|
||||||
|
require.Error(t, err, "collision must error, not overwrite")
|
||||||
|
|
||||||
|
got, _ := os.ReadFile(dest)
|
||||||
|
assert.Equal(t, "EXISTING\n", string(got), "target not overwritten")
|
||||||
|
_, statErr := os.Stat(filepath.Join(dir, "raw", "2026-06-01-x.md"))
|
||||||
|
assert.NoError(t, statErr, "source preserved on collision (atomic: no delete without write)")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteRejectsTraversalFilename(t *testing.T) {
|
||||||
|
_, err := PromoteNote(t.TempDir(), PromoteOptions{Filename: "../escape.md", Wing: "a", Hall: "facts"})
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPromoteRebuildsWingIndex(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
writeRaw(t, dir, "2026-06-01-x.md", "---\ntitle: X Note\n---\nbody\n")
|
||||||
|
_, err := PromoteNote(dir, PromoteOptions{Filename: "2026-06-01-x.md", Wing: "a", Hall: "facts"})
|
||||||
|
require.NoError(t, err)
|
||||||
|
idx, err := os.ReadFile(filepath.Join(dir, "wiki", "a", "_index.md"))
|
||||||
|
require.NoError(t, err, "wing _index regenerated")
|
||||||
|
assert.Contains(t, string(idx), "x", "promoted note appears in the index")
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ package gitea
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -93,37 +94,105 @@ func (c *Client) CloseIssue(ctx context.Context, repo string, number int, commen
|
|||||||
return capture.IssueRef{Repo: repo, Number: number, URL: out.HTMLURL}, nil
|
return capture.IssueRef{Repo: repo, Number: number, URL: out.HTMLURL}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// do performs a JSON request against the Gitea API and decodes the
|
// WriteFile creates or updates a file in repo at path via the Gitea
|
||||||
// response into out. Errors carry the status and a truncated body for
|
// contents API — the SummaryWriter port (#66). It upserts: a GET resolves
|
||||||
// diagnosis but never the token.
|
// the current blob sha (if any) so an existing file is updated rather than
|
||||||
func (c *Client) do(ctx context.Context, method, path string, payload any, out *issueResponse) error {
|
// rejected (the richer-fidelity-supersedes rule for re-captured sessions).
|
||||||
reqBody, err := json.Marshal(payload)
|
// Owner is the fixed const, like every other call.
|
||||||
if err != nil {
|
func (c *Client) WriteFile(ctx context.Context, repo, path, content string) error {
|
||||||
return fmt.Errorf("marshal request: %w", err)
|
cpath := fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", owner, repo, path)
|
||||||
}
|
sha, err := c.fileSHA(ctx, cpath)
|
||||||
req, err := http.NewRequestWithContext(ctx, method, c.baseURL+path, bytes.NewReader(reqBody))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
payload := map[string]any{
|
||||||
req.Header.Set("Accept", "application/json")
|
"message": "capture: " + path,
|
||||||
// Gitea's token scheme. Held here only; never logged.
|
"content": base64.StdEncoding.EncodeToString([]byte(content)),
|
||||||
req.Header.Set("Authorization", "token "+c.token)
|
}
|
||||||
|
// Gitea contents API: POST creates a new file, PUT updates an existing
|
||||||
resp, err := c.http.Do(req)
|
// one (PUT requires the current sha). Pick by whether the file exists.
|
||||||
|
method := http.MethodPost
|
||||||
|
if sha != "" {
|
||||||
|
method = http.MethodPut
|
||||||
|
payload["sha"] = sha
|
||||||
|
}
|
||||||
|
status, body, err := c.request(ctx, method, cpath, payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("gitea %s %s: %w", method, path, err)
|
return err
|
||||||
}
|
}
|
||||||
defer func() { _ = resp.Body.Close() }()
|
if status < 200 || status >= 300 {
|
||||||
|
return fmt.Errorf("gitea %s %s: status %d: %s", method, cpath, status, strings.TrimSpace(string(body)))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
|
// fileSHA returns the current blob sha for a contents path, or "" when the
|
||||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
// file does not exist (404). Any other non-2xx is an error.
|
||||||
return fmt.Errorf("gitea %s %s: status %d: %s", method, path, resp.StatusCode, strings.TrimSpace(string(respBody)))
|
func (c *Client) fileSHA(ctx context.Context, cpath string) (string, error) {
|
||||||
|
status, body, err := c.request(ctx, http.MethodGet, cpath, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
if out != nil && len(respBody) > 0 {
|
if status == http.StatusNotFound {
|
||||||
if err := json.Unmarshal(respBody, out); err != nil {
|
return "", nil
|
||||||
|
}
|
||||||
|
if status < 200 || status >= 300 {
|
||||||
|
return "", fmt.Errorf("gitea GET %s: status %d: %s", cpath, status, strings.TrimSpace(string(body)))
|
||||||
|
}
|
||||||
|
var meta struct {
|
||||||
|
SHA string `json:"sha"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(body, &meta); err != nil {
|
||||||
|
return "", fmt.Errorf("gitea GET %s: decode: %w", cpath, err)
|
||||||
|
}
|
||||||
|
return meta.SHA, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// do performs a JSON request against the Gitea API and decodes a 2xx
|
||||||
|
// response into out. Errors carry the status and a truncated body for
|
||||||
|
// diagnosis but never the token.
|
||||||
|
func (c *Client) do(ctx context.Context, method, path string, payload any, out *issueResponse) error {
|
||||||
|
status, body, err := c.request(ctx, method, path, payload)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if status < 200 || status >= 300 {
|
||||||
|
return fmt.Errorf("gitea %s %s: status %d: %s", method, path, status, strings.TrimSpace(string(body)))
|
||||||
|
}
|
||||||
|
if out != nil && len(body) > 0 {
|
||||||
|
if err := json.Unmarshal(body, out); err != nil {
|
||||||
return fmt.Errorf("gitea %s %s: decode response: %w", method, path, err)
|
return fmt.Errorf("gitea %s %s: decode response: %w", method, path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// request is the shared HTTP path: marshals an optional JSON payload,
|
||||||
|
// attaches auth (token only ever in the header), and returns the status +
|
||||||
|
// body so callers can branch on status (e.g. 404) without it being an
|
||||||
|
// error. Never logs the token.
|
||||||
|
func (c *Client) request(ctx context.Context, method, path string, payload any) (int, []byte, error) {
|
||||||
|
var reader io.Reader
|
||||||
|
if payload != nil {
|
||||||
|
reqBody, err := json.Marshal(payload)
|
||||||
|
if err != nil {
|
||||||
|
return 0, nil, fmt.Errorf("marshal request: %w", err)
|
||||||
|
}
|
||||||
|
reader = bytes.NewReader(reqBody)
|
||||||
|
}
|
||||||
|
req, err := http.NewRequestWithContext(ctx, method, c.baseURL+path, reader)
|
||||||
|
if err != nil {
|
||||||
|
return 0, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("Accept", "application/json")
|
||||||
|
req.Header.Set("Authorization", "token "+c.token)
|
||||||
|
|
||||||
|
resp, err := c.http.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return 0, nil, fmt.Errorf("gitea %s %s: %w", method, path, err)
|
||||||
|
}
|
||||||
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
body, _ := io.ReadAll(io.LimitReader(resp.Body, 8192))
|
||||||
|
return resp.StatusCode, body, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -115,3 +115,69 @@ func TestErrorPathDoesNotLeakToken(t *testing.T) {
|
|||||||
assert.NotContains(t, err.Error(), testToken, "token must never appear in an error message")
|
assert.NotContains(t, err.Error(), testToken, "token must never appear in an error message")
|
||||||
assert.Contains(t, err.Error(), "500")
|
assert.Contains(t, err.Error(), "500")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteFileCreatesNewFile(t *testing.T) {
|
||||||
|
var getPath, postPath, postBody string
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.Method {
|
||||||
|
case http.MethodGet:
|
||||||
|
getPath = r.URL.Path
|
||||||
|
w.WriteHeader(http.StatusNotFound) // file does not exist yet
|
||||||
|
case http.MethodPost: // gitea contents API: POST = create
|
||||||
|
postPath = r.URL.Path
|
||||||
|
b, _ := io.ReadAll(r.Body)
|
||||||
|
postBody = string(b)
|
||||||
|
w.WriteHeader(http.StatusCreated)
|
||||||
|
_ = json.NewEncoder(w).Encode(map[string]any{"content": map[string]any{"html_url": "https://git/x"}})
|
||||||
|
default:
|
||||||
|
t.Errorf("create must POST, got %s", r.Method)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
err := gitea.New(srv.URL, testToken).WriteFile(context.Background(),
|
||||||
|
"ai-sessions", "summaries/claude-code/2026-06/2026-06-23-x-abcd1234.md", "# Summary\n\nbody\n")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, "/api/v1/repos/mathias/ai-sessions/contents/summaries/claude-code/2026-06/2026-06-23-x-abcd1234.md", getPath)
|
||||||
|
assert.Equal(t, getPath, postPath)
|
||||||
|
// base64 of the content, no sha on create.
|
||||||
|
assert.Contains(t, postBody, "IyBTdW1tYXJ5") // base64("# Summary")
|
||||||
|
assert.NotContains(t, postBody, `"sha"`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteFileUpdatesExisting(t *testing.T) {
|
||||||
|
var putBody string
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
switch r.Method {
|
||||||
|
case http.MethodGet:
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
_ = json.NewEncoder(w).Encode(map[string]any{"sha": "deadbeef"})
|
||||||
|
case http.MethodPut:
|
||||||
|
b, _ := io.ReadAll(r.Body)
|
||||||
|
putBody = string(b)
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
_ = json.NewEncoder(w).Encode(map[string]any{"content": map[string]any{"html_url": "https://git/x"}})
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
|
||||||
|
err := gitea.New(srv.URL, testToken).WriteFile(context.Background(), "ai-sessions", "p/x.md", "new")
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Contains(t, putBody, `"sha":"deadbeef"`, "existing file → update with sha")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWriteFileErrorNoTokenLeak(t *testing.T) {
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method == http.MethodGet {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||||
|
_, _ = w.Write([]byte("bad"))
|
||||||
|
}))
|
||||||
|
defer srv.Close()
|
||||||
|
err := gitea.New(srv.URL, testToken).WriteFile(context.Background(), "ai-sessions", "p/x.md", "x")
|
||||||
|
require.Error(t, err)
|
||||||
|
assert.NotContains(t, err.Error(), testToken)
|
||||||
|
assert.Contains(t, err.Error(), "422")
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mathiasbq/hyperguild/ingestion/internal/api"
|
||||||
"github.com/mathiasbq/hyperguild/ingestion/internal/brain"
|
"github.com/mathiasbq/hyperguild/ingestion/internal/brain"
|
||||||
"github.com/mathiasbq/hyperguild/ingestion/internal/capture"
|
"github.com/mathiasbq/hyperguild/ingestion/internal/capture"
|
||||||
"github.com/mathiasbq/hyperguild/ingestion/internal/extract"
|
"github.com/mathiasbq/hyperguild/ingestion/internal/extract"
|
||||||
@@ -81,6 +82,21 @@ func (s *Server) tools() []map[string]any {
|
|||||||
"path": str("brain-relative path to the note; equivalent to id"),
|
"path": str("brain-relative path to the note; equivalent to id"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "brain_pending",
|
||||||
|
"description": "List notes in brain/raw/ awaiting human promotion to the wiki, oldest-first. Returns filename, created_at, size_bytes, excerpt. The human-review queue complement to brain_promote.",
|
||||||
|
"inputSchema": schema([]string{}, map[string]any{}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "brain_promote",
|
||||||
|
"description": "Promote a brain/raw/ note into brain/wiki/<wing>/<hall>/: rewrites frontmatter (sets wing/hall/promoted_at, preserves created_at + custom fields), deletes the source, rebuilds the wing index, runs auto-tunnel. Errors (without touching the fs) on invalid hall or a slug collision. Returns {path}.",
|
||||||
|
"inputSchema": schema([]string{"filename", "wing", "hall"}, map[string]any{
|
||||||
|
"filename": str("basename in brain/raw/, e.g. 2026-06-01-lejpa-decision.md"),
|
||||||
|
"wing": str("target wing, e.g. jepa-fx"),
|
||||||
|
"hall": enum("target hall", halls...),
|
||||||
|
"slug": str("optional target slug; defaults to filename minus date prefix"),
|
||||||
|
}),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "brain_tunnel",
|
"name": "brain_tunnel",
|
||||||
"description": "Create an explicit bidirectional [[wikilink]] between two notes in different wings. Idempotent.",
|
"description": "Create an explicit bidirectional [[wikilink]] between two notes in different wings. Idempotent.",
|
||||||
@@ -321,6 +337,40 @@ func (s *Server) brainGet(ctx context.Context, args json.RawMessage) (json.RawMe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// brainPending lists the raw/ review queue (oldest-first).
|
||||||
|
func (s *Server) brainPending(_ context.Context, _ json.RawMessage) (json.RawMessage, error) {
|
||||||
|
pending, err := api.ListPending(s.brainDir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return json.Marshal(map[string]any{"pending": pending})
|
||||||
|
}
|
||||||
|
|
||||||
|
type brainPromoteArgs struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
Wing string `json:"wing"`
|
||||||
|
Hall string `json:"hall"`
|
||||||
|
Slug string `json:"slug,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// brainPromote moves a raw/ note into the structured wiki (frontmatter
|
||||||
|
// rewrite + index + auto-tunnel, all owned by api.PromoteNote) and then
|
||||||
|
// re-indexes it into the graph. The human-facing complement to brain_write.
|
||||||
|
func (s *Server) brainPromote(ctx context.Context, args json.RawMessage) (json.RawMessage, error) {
|
||||||
|
var a brainPromoteArgs
|
||||||
|
if err := json.Unmarshal(args, &a); err != nil {
|
||||||
|
return nil, fmt.Errorf("parse args: %w", err)
|
||||||
|
}
|
||||||
|
relPath, err := api.PromoteNote(s.brainDir, api.PromoteOptions{
|
||||||
|
Filename: a.Filename, Wing: a.Wing, Hall: a.Hall, Slug: a.Slug,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s.indexInGraph(ctx, "brain_promote", relPath)
|
||||||
|
return json.Marshal(map[string]string{"path": relPath})
|
||||||
|
}
|
||||||
|
|
||||||
// indexInGraph is a best-effort wrapper around graphsync.IndexDoc that
|
// indexInGraph is a best-effort wrapper around graphsync.IndexDoc that
|
||||||
// logs failures but never propagates them — the underlying write/ingest
|
// logs failures but never propagates them — the underlying write/ingest
|
||||||
// has already succeeded and the graph is an augmentation, not a
|
// has already succeeded and the graph is an augmentation, not a
|
||||||
|
|||||||
@@ -332,3 +332,61 @@ func TestSessionLogRequiresSessionID(t *testing.T) {
|
|||||||
resp := toolCall(t, srv, "session_log", map[string]any{"skill": "tdd"})
|
resp := toolCall(t, srv, "session_log", map[string]any{"skill": "tdd"})
|
||||||
require.NotNil(t, resp["error"])
|
require.NotNil(t, resp["error"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBrainPendingListsRaw(t *testing.T) {
|
||||||
|
brainDir := t.TempDir()
|
||||||
|
raw := filepath.Join(brainDir, "raw")
|
||||||
|
require.NoError(t, os.MkdirAll(raw, 0o755))
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(raw, "2026-06-01-x.md"),
|
||||||
|
[]byte("---\ncreated_at: 2026-06-01T00:00:00Z\n---\npending body\n"), 0o644))
|
||||||
|
srv := mcp.NewServer(brainDir, nil, nil, nil)
|
||||||
|
|
||||||
|
resp := toolCall(t, srv, "brain_pending", map[string]any{})
|
||||||
|
require.Nil(t, resp["error"])
|
||||||
|
text := resp["result"].(map[string]any)["content"].([]any)[0].(map[string]any)["text"].(string)
|
||||||
|
assert.Contains(t, text, "2026-06-01-x.md")
|
||||||
|
assert.Contains(t, text, "pending body")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBrainPendingEmpty(t *testing.T) {
|
||||||
|
srv := mcp.NewServer(t.TempDir(), nil, nil, nil)
|
||||||
|
resp := toolCall(t, srv, "brain_pending", map[string]any{})
|
||||||
|
require.Nil(t, resp["error"])
|
||||||
|
text := resp["result"].(map[string]any)["content"].([]any)[0].(map[string]any)["text"].(string)
|
||||||
|
assert.Contains(t, text, `"pending":[]`)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBrainPromoteMovesToWiki(t *testing.T) {
|
||||||
|
brainDir := t.TempDir()
|
||||||
|
raw := filepath.Join(brainDir, "raw")
|
||||||
|
require.NoError(t, os.MkdirAll(raw, 0o755))
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(raw, "2026-06-01-decision.md"),
|
||||||
|
[]byte("---\ncreated_at: 2026-06-01T00:00:00Z\n---\n# D\n\nbody\n"), 0o644))
|
||||||
|
srv := mcp.NewServer(brainDir, nil, nil, nil)
|
||||||
|
|
||||||
|
resp := toolCall(t, srv, "brain_promote", map[string]any{
|
||||||
|
"filename": "2026-06-01-decision.md", "wing": "jepa-fx", "hall": "decisions",
|
||||||
|
})
|
||||||
|
require.Nil(t, resp["error"], "got: %v", resp["error"])
|
||||||
|
text := resp["result"].(map[string]any)["content"].([]any)[0].(map[string]any)["text"].(string)
|
||||||
|
assert.Contains(t, text, "wiki/jepa-fx/decisions/decision.md")
|
||||||
|
|
||||||
|
_, err := os.Stat(filepath.Join(brainDir, "wiki/jepa-fx/decisions/decision.md"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
_, srcErr := os.Stat(filepath.Join(raw, "2026-06-01-decision.md"))
|
||||||
|
assert.True(t, os.IsNotExist(srcErr), "source removed")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBrainPromoteInvalidHallErrors(t *testing.T) {
|
||||||
|
brainDir := t.TempDir()
|
||||||
|
raw := filepath.Join(brainDir, "raw")
|
||||||
|
require.NoError(t, os.MkdirAll(raw, 0o755))
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(raw, "x.md"), []byte("body\n"), 0o644))
|
||||||
|
srv := mcp.NewServer(brainDir, nil, nil, nil)
|
||||||
|
resp := toolCall(t, srv, "brain_promote", map[string]any{
|
||||||
|
"filename": "x.md", "wing": "a", "hall": "garbage",
|
||||||
|
})
|
||||||
|
require.NotNil(t, resp["error"])
|
||||||
|
_, srcErr := os.Stat(filepath.Join(raw, "x.md"))
|
||||||
|
assert.NoError(t, srcErr, "source untouched on validation error")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
// Package mcp implements an MCP HTTP handler for the ingestion service.
|
// Package mcp implements an MCP HTTP handler for the ingestion service.
|
||||||
// Exposed tools: brain_query, brain_write, brain_update, brain_get,
|
// Exposed tools: brain_query, brain_write, brain_update, brain_get,
|
||||||
// brain_index, brain_tunnel, brain_ingest, brain_ingest_raw,
|
// brain_pending, brain_promote, brain_index, brain_tunnel, brain_ingest,
|
||||||
// brain_answer, brain_classify, brain_graph, brain_context, session_log,
|
// brain_ingest_raw, brain_answer, brain_classify, brain_graph,
|
||||||
// and capture (the #55 relay tool, registered only when WithCapture is set).
|
// brain_context, session_log, and capture (the #55 relay tool, registered
|
||||||
|
// only when WithCapture is set).
|
||||||
package mcp
|
package mcp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -263,6 +264,10 @@ func (s *Server) handleCall(ctx context.Context, name string, args json.RawMessa
|
|||||||
return s.brainUpdate(ctx, args)
|
return s.brainUpdate(ctx, args)
|
||||||
case "brain_get":
|
case "brain_get":
|
||||||
return s.brainGet(ctx, args)
|
return s.brainGet(ctx, args)
|
||||||
|
case "brain_pending":
|
||||||
|
return s.brainPending(ctx, args)
|
||||||
|
case "brain_promote":
|
||||||
|
return s.brainPromote(ctx, args)
|
||||||
case "capture":
|
case "capture":
|
||||||
return s.brainCapture(ctx, args)
|
return s.brainCapture(ctx, args)
|
||||||
case "brain_index":
|
case "brain_index":
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ func TestServerToolsList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.ElementsMatch(t, []string{
|
assert.ElementsMatch(t, []string{
|
||||||
"brain_query", "brain_write", "brain_update", "brain_get",
|
"brain_query", "brain_write", "brain_update", "brain_get",
|
||||||
|
"brain_pending", "brain_promote",
|
||||||
"brain_index", "brain_tunnel",
|
"brain_index", "brain_tunnel",
|
||||||
"brain_ingest_raw", "brain_ingest",
|
"brain_ingest_raw", "brain_ingest",
|
||||||
"brain_answer", "brain_classify", "brain_graph", "brain_context",
|
"brain_answer", "brain_classify", "brain_graph", "brain_context",
|
||||||
|
|||||||
@@ -52,10 +52,11 @@ Persist the session via a **single `capture` call** (the `brain:capture` MCP too
|
|||||||
- **`context`** — `{harness: "claudeai-chat", session_ref: <chatid8-or-slug>, fidelity: "live-capture", actor: "mathias", classification: <see gate below>}`.
|
- **`context`** — `{harness: "claudeai-chat", session_ref: <chatid8-or-slug>, fidelity: "live-capture", actor: "mathias", classification: <see gate below>}`.
|
||||||
|
|
||||||
**THE CLASSIFICATION GATE (read before calling — this is where capture refuses).**
|
**THE CLASSIFICATION GATE (read before calling — this is where capture refuses).**
|
||||||
Capture computes an **effective classification = the strictest across EVERY target it touches** (each insight's `wing`, each ticket's `repo`, and every entry in `summary.repos_touched`), then refuses if that effective level is `confidential` and the origin is us-nexus (claude.ai is us-nexus). Server-derived defaults: `hyperguild`/`homelab` → internal; `client-*` → confidential; **anything untagged → confidential (fail-safe)**. There is no populated `classification.yaml` yet, so only these defaults apply.
|
Capture computes an **effective classification = the strictest across EVERY target it touches** (each insight's `wing`, each ticket's `repo`, and every entry in `summary.repos_touched`), then refuses if that effective level is `confidential` and the origin is us-nexus (claude.ai is us-nexus). Levels come from `classification.yaml` at the brain root (source of truth, #67), with the code defaults as the floor: `hyperguild`/`homelab` → internal; `client-*` → confidential; **anything untagged → confidential (fail-safe)**.
|
||||||
|
- **Tagged `internal` today** (safe through claude.ai): wings `hyperguild`, `homelab`; repos `brain`, `ai-sessions`, `infra`, `hyperguild`, `homelab`, `tapir`, `agentsquad`, `jepa-fx-risk`, `swedsl`. Treat `classification.yaml` as authoritative — this list is a hint, not gospel.
|
||||||
- Declare `context.classification: "internal"` for normal homelab work.
|
- Declare `context.classification: "internal"` for normal homelab work.
|
||||||
- **Keep `summary.repos_touched` to genuinely-central, internal-default repos** (e.g. `hyperguild`, `homelab`). Do NOT list untagged repos like `brain` or `ai-sessions` "for completeness" — each one escalates the whole capture to confidential and the gate will refuse via claude.ai. `repos_touched` is a classification INPUT, not free-form metadata. The same caution applies to insight `wing`s and ticket `repo`s: an untagged target escalates the whole call.
|
- `summary.repos_touched`, insight `wing`s, and ticket `repo`s are classification INPUTS, not free-form metadata — every target must resolve `internal` or the whole capture escalates to `confidential` and the gate refuses via claude.ai. Listing the central homelab repos (incl. `brain`/`ai-sessions`) is now fine; they're tagged. The summary always lands in `ai-sessions` (internal), so the summary path itself never escalates.
|
||||||
- If a session genuinely touched confidential/client material, it cannot be captured through claude.ai at all — note that in the verdict rather than trying to force it.
|
- If a session genuinely touched **`client-*` or otherwise-untagged** material, it cannot be captured through claude.ai — note that in the verdict rather than trying to force it.
|
||||||
|
|
||||||
**GATE — dry-run first, then execute.**
|
**GATE — dry-run first, then execute.**
|
||||||
1. Call `capture` with `dry_run: true`. It validates the whole payload and returns the would-be receipt + `effective_classification`, writing nothing.
|
1. Call `capture` with `dry_run: true`. It validates the whole payload and returns the would-be receipt + `effective_classification`, writing nothing.
|
||||||
|
|||||||
Reference in New Issue
Block a user