-
Notifications
You must be signed in to change notification settings - Fork 296
WIP #941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WIP #941
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,193 @@ | ||||||||||||||||||||||||||||
| package strategy | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||||||||
| "testing" | ||||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/agent/types" | ||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/checkpoint" | ||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/checkpoint/id" | ||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/paths" | ||||||||||||||||||||||||||||
| "github.com/entireio/cli/cmd/entire/cli/session" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| "github.com/go-git/go-git/v6" | ||||||||||||||||||||||||||||
| "github.com/go-git/go-git/v6/plumbing" | ||||||||||||||||||||||||||||
| "github.com/stretchr/testify/assert" | ||||||||||||||||||||||||||||
| "github.com/stretchr/testify/require" | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // fakeAgentWithTranscriptAnalyzer extends fakeExternalAgent with TranscriptAnalyzer | ||||||||||||||||||||||||||||
| // support. The modifiedFiles field controls what ExtractModifiedFilesFromOffset returns, | ||||||||||||||||||||||||||||
| // allowing tests to simulate "no new file modifications since last condensation." | ||||||||||||||||||||||||||||
| type fakeAgentWithTranscriptAnalyzer struct { | ||||||||||||||||||||||||||||
| fakeExternalAgent | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| transcript []byte | ||||||||||||||||||||||||||||
| modifiedFiles []string // files returned by ExtractModifiedFilesFromOffset | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func (f *fakeAgentWithTranscriptAnalyzer) ReadTranscript(_ string) ([]byte, error) { | ||||||||||||||||||||||||||||
| return f.transcript, nil | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func (f *fakeAgentWithTranscriptAnalyzer) GetTranscriptPosition(_ string) (int, error) { //nolint:unparam // interface conformance | ||||||||||||||||||||||||||||
| return len(f.transcript), nil | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func (f *fakeAgentWithTranscriptAnalyzer) ExtractModifiedFilesFromOffset(_ string, _ int) ([]string, int, error) { //nolint:unparam // interface conformance | ||||||||||||||||||||||||||||
| return f.modifiedFiles, 0, nil | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| return f.modifiedFiles, 0, nil | |
| return f.modifiedFiles, len(f.transcript), nil |
Copilot
AI
Apr 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agent.Register factories are expected to create a new agent instance, but this closure always returns the same shared *fakeAgentWithTranscriptAnalyzer pointer. If any code calls agent.Get/GetByAgentType multiple times (or tests run in parallel), this can introduce shared mutable state and data races; return a fresh fake instance from the factory (or clone the struct) instead.
| fakeAgent := &fakeAgentWithTranscriptAnalyzer{ | |
| fakeExternalAgent: fakeExternalAgent{name: agentBName, agentType: agentBType}, | |
| transcript: transcriptContent, | |
| modifiedFiles: nil, // No new file modifications since last condensation offset | |
| } | |
| agent.Register(agentBName, func() agent.Agent { return fakeAgent }) | |
| agent.Register(agentBName, func() agent.Agent { | |
| return &fakeAgentWithTranscriptAnalyzer{ | |
| fakeExternalAgent: fakeExternalAgent{name: agentBName, agentType: agentBType}, | |
| transcript: append([]byte(nil), transcriptContent...), | |
| modifiedFiles: nil, // No new file modifications since last condensation offset | |
| } | |
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetTranscriptPosition is expected to return a transcript position (line count for JSONL or message count for JSON), but this stub returns len(transcript) in bytes. That can make hasNewTranscriptWork/offset comparisons behave incorrectly if the fake is reused in other tests; consider counting JSONL lines (or delegating to the real parser) instead.