Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apps/ui/src/live/adapt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ describe("adaptPullRequest", () => {
url: "https://github.com/x/42",
headRef: "feat/x",
baseRef: "main",
agent: { agentHandle: "cook" },
agent: { agentHandle: "cook", ownerHandle: "matt" },
forgeAccount: "matt",
draft: true,
changed: { files: 3, additions: 10, deletions: 2 },
Expand Down Expand Up @@ -827,11 +827,10 @@ describe("adaptPullRequest", () => {
expect(r.url).toBe("https://github.com/x/42");
expect(r.headRef).toBe("feat/x");
expect(r.baseRef).toBe("main");
// The wire attribution carries only agentHandle; ownerHandle/verified have
// no wire source and take honest hedged defaults.
// The wire attribution carries both handles; verified remains hedged.
expect(r.agent).toEqual({
agentHandle: "cook",
ownerHandle: "",
ownerHandle: "matt",
verified: false,
});
expect(r.forgeAccount).toBe("matt");
Expand Down Expand Up @@ -880,7 +879,7 @@ describe("adaptIssue", () => {
body: "stripped",
forgeState: "open",
url: "https://linear.app/RIG-1729",
agent: { agentHandle: "cook" },
agent: { agentHandle: "cook", ownerHandle: "matt" },
forgeAccount: "matt",
labels: ["p1", "ui"],
state: IssueState.IN_PROGRESS,
Expand Down Expand Up @@ -913,7 +912,7 @@ describe("adaptIssue", () => {
expect(r.url).toBe("https://linear.app/RIG-1729");
expect(r.agent).toEqual({
agentHandle: "cook",
ownerHandle: "",
ownerHandle: "matt",
verified: false,
});
expect(r.forgeAccount).toBe("matt");
Expand Down
14 changes: 8 additions & 6 deletions apps/ui/src/live/adapt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,17 @@ function adaptForgeRef(w: WireForgeRef | undefined): DomainForgeRef {
};
}

/** Map a wire AgentAttribution to the domain one. The current wire shape carries
* only `agentHandle` (DL-094 burned owner_handle/verified as reserved); the
* domain's `ownerHandle`/`verified` have no wire source, so they take honest
* hedged defaults (`""` / `false` — an unverified claim with no owner) rather
* than a fabricated value. */
/** Map a wire AgentAttribution to the domain one. The owner handle is carried
* from the same stamped header parse (DL-339); verification remains an honest
* hedge because attribution is not a trust claim (DL-094). */
function adaptAgentAttribution(
w: WireAgentAttribution,
): DomainAgentAttribution {
return { agentHandle: w.agentHandle, ownerHandle: "", verified: false };
return {
agentHandle: w.agentHandle,
ownerHandle: w.ownerHandle,
verified: false,
};
}

/** Map a wire ChangedStats to the domain diffstat — verbatim scalars. */
Expand Down
21 changes: 13 additions & 8 deletions go/gen/compass/v1/compass.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/internal/forge/githubapp_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,5 @@ func stripBodyToRef(raw string) (string, *compassv1.AgentAttribution) {
if !ok {
return clean, nil
}
return clean, &compassv1.AgentAttribution{AgentHandle: author.AgentHandle}
return clean, &compassv1.AgentAttribution{AgentHandle: author.AgentHandle, OwnerHandle: author.OwnerHandle}
}
3 changes: 3 additions & 0 deletions go/internal/forge/githubapp_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,7 @@ func TestParseGitHubEvent_StripsOwner(t *testing.T) {
if ev.Comment.GetAgent().GetAgentHandle() != "agent-x" {
t.Errorf("agent claim = %q, want agent-x", ev.Comment.GetAgent().GetAgentHandle())
}
if got := ev.Comment.GetAgent().GetOwnerHandle(); got != "owner-y" {
t.Errorf("owner claim = %q, want owner-y", got)
}
}
2 changes: 1 addition & 1 deletion go/internal/ingest/notify_detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func detectArtifact(prev *ArtifactSnapshot, fetched FetchedArtifact) (ArtifactSn
clean, author, ok := forge.StripOwner(c.Body)
ref := &compassv1internal.CommentRef{Url: c.URL, CommentKey: c.Key, Body: clean, ForgeAccount: c.ForgeAccount}
if ok {
ref.Agent = &compassv1.AgentAttribution{AgentHandle: author.AgentHandle}
ref.Agent = &compassv1.AgentAttribution{AgentHandle: author.AgentHandle, OwnerHandle: author.OwnerHandle}
}
changes = append(changes, forge.ForgeEvent{
Provider: fetched.Provider, Host: fetched.Host, Repo: fetched.Repo,
Expand Down
21 changes: 21 additions & 0 deletions go/internal/ingest/notify_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,27 @@ func TestCrossProducerLinearCommentNoPhantomDiff(t *testing.T) {
}
}

func TestDetectChangesCommentAttributionIncludesOwner(t *testing.T) {
body, err := forge.StampOwner("real body", forge.Author{AgentHandle: "agent-x", OwnerHandle: "owner-y", SessionID: "sess-1"}, 0)
if err != nil {
t.Fatalf("stamp: %v", err)
}
prev := &ArtifactSnapshot{Comments: map[string]SnapshotComment{}}
fetched := FetchedArtifact{
Provider: compassv1.ForgeProvider_FORGE_PROVIDER_GITHUB,
Host: "github.com", Repo: "owner/repo", Kind: kindIssue, Number: 7,
Comments: []forge.Comment{{Key: "comment-1", URL: "https://github.com/owner/repo/issues/7#comment-1", Body: body}},
}
changes, _, _ := DetectChanges(prev, fetched)
if len(changes) != 1 {
t.Fatalf("changes = %d, want 1", len(changes))
}
got := changes[0].Comment.GetAgent()
if got.GetAgentHandle() != "agent-x" || got.GetOwnerHandle() != "owner-y" {
t.Errorf("attribution = %v, want agent-x/owner-y", got)
}
}

func mustJSON(t *testing.T, v any) []byte {
t.Helper()
b, err := json.Marshal(v)
Expand Down
2 changes: 1 addition & 1 deletion go/internal/linearagent/data_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func linearCommentRef(d dataPayload) *compassv1internal.CommentRef {
ForgeAccount: linearAccount(d.User),
}
if ok {
ref.Agent = &compassv1.AgentAttribution{AgentHandle: author.AgentHandle}
ref.Agent = &compassv1.AgentAttribution{AgentHandle: author.AgentHandle, OwnerHandle: author.OwnerHandle}
}
return ref
}
Expand Down
3 changes: 3 additions & 0 deletions go/internal/linearagent/data_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func TestParseLinearDataEvent_Comment(t *testing.T) {
if ev.Comment.GetAgent().GetAgentHandle() != "agent-x" {
t.Errorf("agent claim = %q, want agent-x", ev.Comment.GetAgent().GetAgentHandle())
}
if got := ev.Comment.GetAgent().GetOwnerHandle(); got != "owner-y" {
t.Errorf("owner claim = %q, want owner-y", got)
}
if ev.Comment.GetForgeAccount() != "Alice" {
t.Errorf("forge_account = %q, want Alice", ev.Comment.GetForgeAccount())
}
Expand Down
Loading