fix(operations): per-project git sync + completion receipts in brief (S2, S3)

Brief.Git was a single GitSync read from ORCHESTRA_DATA (never a git
checkout), and completions were counted but discarded their report_ref/
receipt. Brief.Git is now keyed by project ID and built from each
project's real repo; GitSync gained Ahead/Behind vs upstream; Brief now
carries Receipts pulled from each TaskCompleted payload.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1rkJ2hBMybnJctPbcy4tT
This commit is contained in:
kami
2026-07-27 23:25:01 +04:00
parent 1f46a34afb
commit 5fb88724bd
5 changed files with 97 additions and 13 deletions
+9 -2
View File
@@ -12,11 +12,18 @@ import (
func TestBuildBrief(t *testing.T) {
now := time.Now()
p, _ := json.Marshal(map[string]any{"harness_id": "cc", "consumed": 12})
es := []domain.Event{{Type: "TaskCompleted", At: now}, {Type: "TaskFailed", At: now}, {Type: "ApprovalRequested", At: now}, {Type: "QuotaReported", At: now, Payload: p}}
b := BuildBrief(es, now.Add(-time.Minute), now.Add(time.Minute), GitSync{Status: "clean"})
completed, _ := json.Marshal(map[string]any{"report_ref": "sha256:abc", "receipt": map[string]any{"numerator": 42.0}})
es := []domain.Event{{TaskID: "t1", Type: "TaskCompleted", At: now, Payload: completed}, {Type: "TaskFailed", At: now}, {Type: "ApprovalRequested", At: now}, {Type: "QuotaReported", At: now, Payload: p}}
b := BuildBrief(es, now.Add(-time.Minute), now.Add(time.Minute), map[string]GitSync{"proj": {Status: "clean"}})
if b.Completed != 1 || b.Failed != 1 || len(b.NeedsAttention) != 2 || b.Quota["cc"] != 12 {
t.Fatalf("unexpected brief: %+v", b)
}
if len(b.Receipts) != 1 || b.Receipts[0].TaskID != "t1" || b.Receipts[0].ReportRef != "sha256:abc" || b.Receipts[0].Receipt["numerator"] != 42.0 {
t.Fatalf("unexpected receipts: %+v", b.Receipts)
}
if b.Git["proj"].Status != "clean" {
t.Fatalf("unexpected git: %+v", b.Git)
}
}
func TestAggregateQuotaSumsRotationsAndWindows(t *testing.T) {