From e6ad4996829d2a0dc3c0c8a342ee147c4110bd37 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 23:37:40 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20agent:=20refuse=20symlinked=20Co?= =?UTF-8?q?pilot=20transcripts=20in=20every=20reader=20and=20fix=20repeat-?= =?UTF-8?q?failure=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-14811-transcript-symlink.md | 1 + src/crux/agent/busy_visibility_test.go | 18 ++++++++++++++ src/crux/agent/kick_transcript_test.go | 24 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 changelog.d/fixed-14811-transcript-symlink.md diff --git a/changelog.d/fixed-14811-transcript-symlink.md b/changelog.d/fixed-14811-transcript-symlink.md new file mode 100644 index 0000000000..0f28602727 --- /dev/null +++ b/changelog.d/fixed-14811-transcript-symlink.md @@ -0,0 +1 @@ +- Refuse symlinked Copilot session logs when archiving kick transcripts and judging busy visibility (#14811) diff --git a/src/crux/agent/busy_visibility_test.go b/src/crux/agent/busy_visibility_test.go index c104f86b41..5605686221 100644 --- a/src/crux/agent/busy_visibility_test.go +++ b/src/crux/agent/busy_visibility_test.go @@ -587,3 +587,21 @@ func TestScanTranscriptActivityWalksAgentsConcurrently(t *testing.T) { } } } + +func TestNewestCopilotTranscriptActivityIgnoresSymlinkedEvents(t *testing.T) { + home := t.TempDir() + target := filepath.Join(t.TempDir(), "events.jsonl") + if err := os.WriteFile(target, []byte("{}\n"), 0o644); err != nil { + t.Fatal(err) + } + dir := filepath.Join(home, ".copilot", "session-state", "linked") + if err := os.MkdirAll(dir, 0o755); err != nil { + t.Fatal(err) + } + if err := os.Symlink(target, filepath.Join(dir, "events.jsonl")); err != nil { + t.Fatal(err) + } + if got, ok := newestCopilotTranscriptActivity(home); ok { + t.Fatalf("symlinked events.jsonl counted as activity: %v", got) + } +} diff --git a/src/crux/agent/kick_transcript_test.go b/src/crux/agent/kick_transcript_test.go index 9db3b510e5..0b9e771635 100644 --- a/src/crux/agent/kick_transcript_test.go +++ b/src/crux/agent/kick_transcript_test.go @@ -409,3 +409,27 @@ func TestListKickLogs_ReportsHeaderSource(t *testing.T) { t.Errorf("missing file source = %q", got) } } + +// A symlink planted at events.jsonl is refused: the archive falls back to the +// scrollback rather than reading through the link. +func TestArchiveKickLog_RefusesSymlinkedTranscript(t *testing.T) { + m, agent, dir, home := transcriptTestManager(t, "copilot", kickLogSourceAuto) + path := writeTestTranscript(t, home, "copilot", "") + target := filepath.Join(t.TempDir(), "secret.jsonl") + if err := os.WriteFile(target, []byte(readTranscriptFixture(t, "copilot_events.jsonl")), 0o600); err != nil { + t.Fatal(err) + } + if err := os.Remove(path); err != nil { + t.Fatal(err) + } + if err := os.Symlink(target, path); err != nil { + t.Fatal(err) + } + if !m.archiveKickLogLocked(agent, "kick") { + t.Fatal("archive not written") + } + body := newestArchiveBody(t, m, dir) + if !strings.Contains(body, "source: scrollback\n") || strings.Contains(body, "fix issue 42") { + t.Errorf("symlinked transcript was read:\n%s", body) + } +}