The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Name the project in the trace summary and relate a handed-off share
Claude61110647f8de
diff --git a/cli/beacon/internal/endpoint/dashboard/history_store.go b/cli/beacon/internal/endpoint/dashboard/history_store.goindex 0ad29018..cdfcf46a 100644--- a/cli/beacon/internal/endpoint/dashboard/history_store.go+++ b/cli/beacon/internal/endpoint/dashboard/history_store.go@@ -41,7 +41,7 @@ const (// historyDerivationVersion covers everything computed from a stored line: trace keys, event// numbers, types, summaries and search text. Bump it when that projection changes; the next// catch-up recomputes it from the stored lines, so history survives the change.- historyDerivationVersion = 5 // 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: agent.response is an agent message+ historyDerivationVersion = 6 // 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: agent.response is an agent message; 6: the summary names its projectdefaultHistoryRetentionDays = 90// maxHistoryRetentionDays is 100 years: a retention this long or longer means nothing expires.diff --git a/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md b/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.mdindex d4b22190..18f60209 100644--- a/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md+++ b/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md@@ -103,7 +103,8 @@ trace view uses. Its main parts:- `trace.summary`: title, `started_at`/`ended_at`, `event_count`, `harness`(`name`, `version`, `collection_methods`), `session`, `repository`,- `model`, `token_usage`, and `content.retention`.+ `project` (`name`: the project directory's name, never a path), `model`,+ `token_usage`, and `content.retention`.- `trace.events[]`, in order. Each event has `id`, `number` (1-basedposition), `timestamp`, `type`, `action`, and optional `category`,`fidelity` (`observed` | `inferred`), `actor`, `title`, `summary`,diff --git a/pkg/asymptoteobserve/share.go b/pkg/asymptoteobserve/share.goindex 99905ad0..51c19c00 100644--- a/pkg/asymptoteobserve/share.go+++ b/pkg/asymptoteobserve/share.go@@ -61,6 +61,31 @@ type ShareTraceV1 struct {Title string `json:"title,omitempty"`Source string `json:"source,omitempty"`Provenance TraceProvenanceV1 `json:"provenance"`+ // RelatedTo is the external id of the trace this one continues, and RelationshipType how+ // (ShareRelationshipHandoff). Both are empty for a trace with no known origin.+ RelatedTo string `json:"related_to,omitempty"`+ RelationshipType string `json:"relationship_type,omitempty"`+}++// ShareRelationshipHandoff relates a trace to the session it was handed off from: the session's+// first prompt carried the handoff marker (session.handoff).+const ShareRelationshipHandoff = "handoff"++// ShareRelation is the trace a session continues, from its first session.handoff event: the source+// session's ShareExternalID and ShareRelationshipHandoff, or two empty strings. The handoff is the+// claim the marker made, not a verified identity, which is all related_to asserts.+func ShareRelation(events []Event) (relatedTo, relationshipType string) {+ for _, event := range events {+ if event.Handoff == nil {+ continue+ }+ harness := strings.TrimSpace(event.Handoff.SourceHarness)+ session := strings.TrimSpace(event.Handoff.SourceSessionID)+ if harness != "" && session != "" {+ return ShareExternalID(harness, session), ShareRelationshipHandoff+ }+ }+ return "", ""}// ShareTraceResultV1 is the response of PUT /v1/traces/{external_id}.@@ -197,8 +222,8 @@ func ShareEventID(event Event) string {// once. Each event's ID is ShareEventID, so re-sharing upserts rather than duplicates.//// The summary is folded from the carried events, as the dashboard folds a trace, with these-// differences for publication: session.working_directory is dropped, repository.path is the-// project's directory name rather than a path (never the home directory's name, which is the local+// differences for publication: session.working_directory and repository.path are dropped,+// project.name is the project's directory name (never the home directory's name, which is the local// account's), and repository.remote_url and ref come from the session's commit links and CI run,// with credentials removed (ShareRemoteURL). Token usage is the plain sum of the carried events'// usage, as in the local view.@@ -355,11 +380,17 @@ func shareSummaryForPublication(summary *TraceSummaryV1, events []Event, opts Shif project == "" {project = shareProjectName(workDir, home)}+ if project = traceProjectName(project); project != "" {+ summary.Project = &TraceProjectV1{Name: project}+ } else {+ summary.Project = nil+ }repo := summary.Repositoryif repo == nil {repo = &TraceRepositoryV1{}}- repo.Path = project+ // A local path, even rewritten, names nothing a reader elsewhere can open.+ repo.Path = ""repo.Branch = ShareBranch(repo.Branch)if repo.Branch == "" {repo.Branch = branchdiff --git a/pkg/asymptoteobserve/share_test.go b/pkg/asymptoteobserve/share_test.goindex ddfd264c..5098be7d 100644--- a/pkg/asymptoteobserve/share_test.go+++ b/pkg/asymptoteobserve/share_test.go@@ -377,10 +377,13 @@ func TestShareBundleSummary(t *testing.T) {if summary.TokenUsage == nil || *summary.TokenUsage != want {t.Fatalf("usage = %+v", summary.TokenUsage)}- wantRepo := TraceRepositoryV1{RemoteURL: "https://github.com/acme/repo.git", Branch: "main", Ref: "abc123def", Path: "repo"}+ wantRepo := TraceRepositoryV1{RemoteURL: "https://github.com/acme/repo.git", Branch: "main", Ref: "abc123def"}if summary.Repository == nil || *summary.Repository != wantRepo {t.Fatalf("repository = %+v", summary.Repository)}+ if summary.Project == nil || summary.Project.Name != "repo" {+ t.Fatalf("project = %+v", summary.Project)+ }if summary.Session == nil || summary.Session.ID != "sess-1" || summary.Session.WorkingDirectory != "" {t.Fatalf("session = %+v", summary.Session)}@@ -487,8 +490,8 @@ func TestShareWireTypesRoundTrip(t *testing.T) {events := shareFieldEvents()bundle := BuildShareBundle(events, shareTestOpts)for name, value := range map[string]interface{}{- "trace": NewShareTrace(bundle, ShareVisibilityPublic),- "batch": ShareEventsBatchV1{Events: bundle.Events},+ "trace": NewShareTrace(bundle, ShareVisibilityPublic),+ "batch": ShareEventsBatchV1{Events: bundle.Events},"bundle": bundle,} {data, err := json.Marshal(value)@@ -515,13 +518,17 @@ func TestShareSummaryLeavesOutDetachedHeadAndTheHomeDirectoryName(t *testing.T)event.Repository = "/home/dev"event.Branch = "HEAD"event.Prompt = &PromptInfo{Text: "hi"}- if repo := BuildShareBundle([]Event{event}, shareTestOpts).Summary.Repository; repo != nil {- t.Fatalf("repository = %+v", repo)+ if summary := BuildShareBundle([]Event{event}, shareTestOpts).Summary; summary.Repository != nil || summary.Project != nil {+ t.Fatalf("repository = %+v, project = %+v", summary.Repository, summary.Project)}event.Session.WorkingDirectory = "/home/dev/src/app"event.Repository = "/home/dev/src/app"- if repo := BuildShareBundle([]Event{event}, shareTestOpts).Summary.Repository; repo == nil || repo.Path != "app" || repo.Branch != "" {- t.Fatalf("repository = %+v", repo)+ summary := BuildShareBundle([]Event{event}, shareTestOpts).Summary+ if summary.Repository != nil {+ t.Fatalf("repository = %+v", summary.Repository)+ }+ if summary.Project == nil || summary.Project.Name != "app" {+ t.Fatalf("project = %+v", summary.Project)}}@@ -776,9 +783,12 @@ func TestShareBundleScrubsEveryFieldType(t *testing.T) {t.Errorf("%s = %q, want %q", name, got, w)}}- if repo := bundle.Summary.Repository; repo == nil || repo.Path != "app" {+ if repo := bundle.Summary.Repository; repo != nil && repo.Path != "" {t.Errorf("repository = %+v", repo)}+ if project := bundle.Summary.Project; project == nil || project.Name != "app" {+ t.Errorf("project = %+v", project)+ }// The caller's events are not rewritten.if events[1].Command.Command != "cat /home/dev/.config/app.toml" || events[2].File.Path != "/home/dev/src/app/main.go" ||events[3].GenAI.Tool.Call.Arguments.(map[string]interface{})["path"] != "/home/dev/secret.txt" {@@ -970,3 +980,37 @@ func TestShareEventIDAndBundleLeaveTheCallersTraceAlone(t *testing.T) {t.Fatalf("spans = %+v", bundle.Spans)}}++func TestShareRelationComesFromTheHandoff(t *testing.T) {+ plain := shareEventAt("2026-10-01T10:00:00Z", "claude_code", CollectionMethodHook, "prompt.submitted", "prompt")+ if related, kind := ShareRelation([]Event{plain}); related != "" || kind != "" {+ t.Fatalf("relation = %q %q", related, kind)+ }+ handoff := shareEventAt("2026-10-01T10:00:01Z", "claude_code", CollectionMethodHook, "session.handoff", "session")+ handoff.Handoff = &HandoffInfo{SourceHarness: "codex", SourceSessionID: "sess-9"}+ related, kind := ShareRelation([]Event{plain, handoff})+ if related != ShareExternalID("codex", "sess-9") || kind != ShareRelationshipHandoff {+ t.Fatalf("relation = %q %q", related, kind)+ }+ trace := ShareTraceV1{RelatedTo: related, RelationshipType: kind}+ data, _ := json.Marshal(trace)+ if !strings.Contains(string(data), `"related_to":"codex_cli:sess-9","relationship_type":"handoff"`) {+ t.Fatalf("wire = %s", data)+ }+}++func TestTraceBuilderNamesTheProject(t *testing.T) {+ event := shareEventAt("2026-10-01T10:00:00Z", "claude_code", CollectionMethodHook, "prompt.submitted", "prompt")+ event.Session.WorkingDirectory = "/home/dev/src/app/sub"+ b := NewTraceBuilder("t", event)+ b.Add(event, TraceEventFromEvent(event, "e1", 0))+ if p := b.Summary().Project; p == nil || p.Name != "sub" {+ t.Fatalf("project = %+v", p)+ }+ event.Repository = "/home/dev/src/app"+ b = NewTraceBuilder("t", event)+ b.Add(event, TraceEventFromEvent(event, "e1", 0))+ if p := b.Summary().Project; p == nil || p.Name != "app" {+ t.Fatalf("project = %+v", p)+ }+}diff --git a/pkg/asymptoteobserve/trace.go b/pkg/asymptoteobserve/trace.goindex 6d7dbe37..bae3b007 100644--- a/pkg/asymptoteobserve/trace.go+++ b/pkg/asymptoteobserve/trace.go@@ -35,6 +35,7 @@ type TraceSummaryV1 struct {Session *TraceSessionV1 `json:"session,omitempty"`Trace *TraceIdentityV1 `json:"trace,omitempty"`Repository *TraceRepositoryV1 `json:"repository,omitempty"`+ Project *TraceProjectV1 `json:"project,omitempty"`Namespace *TraceNamespaceV1 `json:"namespace,omitempty"`Model *TraceModelV1 `json:"model,omitempty"`TokenUsage *TraceUsageV1 `json:"token_usage,omitempty"`@@ -66,6 +67,12 @@ type TraceRepositoryV1 struct {Path string `json:"path,omitempty"`}+// TraceProjectV1 names the project a trace worked in: the name of its directory (the repository's+// root, or else the session's working directory), never a path.+type TraceProjectV1 struct {+ Name string `json:"name,omitempty"`+}+type TraceNamespaceV1 struct {ID string `json:"id,omitempty"`Slug string `json:"slug,omitempty"`diff --git a/pkg/asymptoteobserve/tracebuild.go b/pkg/asymptoteobserve/tracebuild.goindex c3066bd2..2e87216f 100644--- a/pkg/asymptoteobserve/tracebuild.go+++ b/pkg/asymptoteobserve/tracebuild.go@@ -513,6 +513,15 @@ func (b *TraceBuilder) Fold(event Event, traceEvent TraceEventV1) {a.summary.Repository.Branch = event.Branch}}+ if a.summary.Project == nil {+ dir := strings.TrimSpace(event.Repository)+ if dir == "" && event.Session != nil {+ dir = strings.TrimSpace(event.Session.WorkingDirectory)+ }+ if name := traceProjectName(dir); name != "" {+ a.summary.Project = &TraceProjectV1{Name: name}+ }+ }if event.Model != "" {model := NormalizeModelName(event.Model)if model != "" {@@ -593,6 +602,17 @@ func newTraceSummary(id string, event Event) TraceSummaryV1 {return summary}+// traceProjectName is the last segment of a directory, or "" for a path with no name of its own+// (a root, ".", "~").+func traceProjectName(dir string) string {+ name := lastPathSegment(dir)+ switch name {+ case "", ".", "..", "~":+ return ""+ }+ return name+}+func (b *TraceBuilder) updateRawMetadata(raw map[string]interface{}) {if raw == nil {returndiff --git a/spec/lenses/SPEC.md b/spec/lenses/SPEC.mdindex d4b22190..18f60209 100644--- a/spec/lenses/SPEC.md+++ b/spec/lenses/SPEC.md@@ -103,7 +103,8 @@ trace view uses. Its main parts:- `trace.summary`: title, `started_at`/`ended_at`, `event_count`, `harness`(`name`, `version`, `collection_methods`), `session`, `repository`,- `model`, `token_usage`, and `content.retention`.+ `project` (`name`: the project directory's name, never a path), `model`,+ `token_usage`, and `content.retention`.- `trace.events[]`, in order. Each event has `id`, `number` (1-basedposition), `timestamp`, `type`, `action`, and optional `category`,`fidelity` (`observed` | `inferred`), `actor`, `title`, `summary`,