@@ -12,6 +12,7 @@ import (
1212
1313 "go.kenn.io/agentsview/internal/db"
1414 duckdbsync "go.kenn.io/agentsview/internal/duckdb"
15+ "go.kenn.io/agentsview/internal/export"
1516 "go.kenn.io/agentsview/internal/money"
1617)
1718
@@ -119,6 +120,12 @@ func main() {
119120 log .Fatalf ("creating recent-edits fixture: %v" , err )
120121 }
121122
123+ if err := createProjectReclassificationFixture (
124+ database , base .Add (120 * time .Hour ),
125+ ); err != nil {
126+ log .Fatalf ("creating project-reclassification fixture: %v" , err )
127+ }
128+
122129 fmt .Printf ("Fixture DB written to %s\n " , * out )
123130 if * duckDBOut != "" {
124131 if err := writeDuckDBMirror (database , * duckDBOut ); err != nil {
@@ -128,6 +135,80 @@ func main() {
128135 }
129136}
130137
138+ func createProjectReclassificationFixture (
139+ database * db.DB , start time.Time ,
140+ ) error {
141+ const (
142+ machine = "remote-example-host"
143+ project = "wrong_branch_label"
144+ worktreeRoot = "/srv/worktrees/github.com/example-org/sample-service/example-worktree"
145+ model = "claude-sonnet-4-20250514"
146+ )
147+ cwds := []struct {
148+ suffix string
149+ cwd string
150+ }{
151+ {suffix : "root" , cwd : worktreeRoot },
152+ {suffix : "nested" , cwd : worktreeRoot + "/cmd/server" },
153+ }
154+ ctx := context .Background ()
155+ for index , item := range cwds {
156+ sessionID := "test-session-project-reclassification-" + item .suffix
157+ startedAt := start .Add (time .Duration (index ) * time .Hour )
158+ endedAt := startedAt .Add (12 * time .Minute )
159+ firstMessage := "Inspect the sample service worktree."
160+ session := db.Session {
161+ ID : sessionID ,
162+ Project : project ,
163+ Machine : machine ,
164+ Agent : "claude" ,
165+ StartedAt : new (startedAt.Format (time.RFC3339Nano )),
166+ EndedAt : new (endedAt.Format (time.RFC3339Nano )),
167+ MessageCount : 2 ,
168+ UserMessageCount : 1 ,
169+ FirstMessage : new (firstMessage ),
170+ Cwd : item .cwd ,
171+ }
172+ if err := database .UpsertSession (session ); err != nil {
173+ return fmt .Errorf (
174+ "upserting project-reclassification session: %w" , err ,
175+ )
176+ }
177+ if err := database .InsertMessages (generateMessages (
178+ sessionID , session .MessageCount , startedAt , model ,
179+ )); err != nil {
180+ return fmt .Errorf (
181+ "inserting project-reclassification messages: %w" , err ,
182+ )
183+ }
184+ if err := database .UpsertProjectIdentityObservation (
185+ ctx ,
186+ export.ProjectIdentityObservation {
187+ SessionID : sessionID ,
188+ Project : project ,
189+ Machine : machine ,
190+ RootPath : worktreeRoot ,
191+ RepositoryPath : "/srv/worktrees/github.com/example-org/sample-service" ,
192+ WorktreeName : "example-worktree" ,
193+ WorktreeRootPath : worktreeRoot ,
194+ WorktreeRelationship : export .WorktreeLinked ,
195+ CheckoutState : export .CheckoutBranch ,
196+ GitBranch : "example-worktree" ,
197+ ObservedAt : startedAt ,
198+ },
199+ ); err != nil {
200+ return fmt .Errorf (
201+ "upserting project-reclassification identity: %w" , err ,
202+ )
203+ }
204+ fmt .Printf (
205+ " %s: %d messages (project reclassification)\n " ,
206+ sessionID , session .MessageCount ,
207+ )
208+ }
209+ return nil
210+ }
211+
131212func writeDuckDBMirror (database * db.DB , path string ) error {
132213 if err := os .Remove (path ); err != nil &&
133214 ! errors .Is (err , os .ErrNotExist ) {
0 commit comments