Skip to content

Commit b8c0fb0

Browse files
fix(parser): preserve positron composite metadata
Roborev job 2737 caught that the Positron shadow parity test compared against raw parser metadata instead of the legacy sync path, which includes workspace.json in source size, mtime, and hash. Carry provider fingerprint size and mtime into parsed Positron sessions alongside the composite hash, and update the shadow test to compute the same workspace-aware metadata as processPositron. Validation: go test -tags "fts5" ./internal/parser ./internal/sync -run 'Test(PositronProvider|ObserveProviderSourceMatchesPositronLegacyParser)' -count=1; go fmt ./...; go vet ./...; git diff --check
1 parent 0601c2a commit b8c0fb0

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

internal/parser/positron_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ func (p *positronProvider) Parse(
9898
SkipReason: SkipNoSession,
9999
}, nil
100100
}
101+
if req.Fingerprint.Size > 0 {
102+
sess.File.Size = req.Fingerprint.Size
103+
}
104+
if req.Fingerprint.MTimeNS > 0 {
105+
sess.File.Mtime = req.Fingerprint.MTimeNS
106+
}
101107
if req.Fingerprint.Hash != "" {
102108
sess.File.Hash = req.Fingerprint.Hash
103109
}

internal/sync/provider_shadow_positron_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package sync
22

33
import (
44
"context"
5+
"os"
56
"path/filepath"
7+
"strings"
68
"testing"
79

810
"github.com/stretchr/testify/assert"
@@ -17,9 +19,10 @@ func TestObserveProviderSourceMatchesPositronLegacyParser(t *testing.T) {
1719
hashDir := filepath.Join(root, "workspaceStorage", "workspace-hash")
1820
chatDir := filepath.Join(hashDir, "chatSessions")
1921
sourcePath := filepath.Join(chatDir, sessionID+".jsonl")
22+
workspacePath := filepath.Join(hashDir, "workspace.json")
2023
writeProviderShadowSourceFile(
2124
t,
22-
filepath.Join(hashDir, "workspace.json"),
25+
workspacePath,
2326
`{"folder":"file:///Users/alice/code/positron-app"}`,
2427
)
2528
writeProviderShadowSourceFile(t, sourcePath, vscodeCopilotShadowFixture(sessionID))
@@ -45,10 +48,30 @@ func TestObserveProviderSourceMatchesPositronLegacyParser(t *testing.T) {
4548
})
4649
require.NoError(t, err)
4750
require.Len(t, observation.Results, 1)
48-
legacySession.File.Hash = observation.Fingerprint.Hash
51+
info, err := os.Stat(sourcePath)
52+
require.NoError(t, err)
53+
effectiveInfo := positronEffectiveInfo(sourcePath, info)
54+
legacySession.File.Size = effectiveInfo.Size()
55+
legacySession.File.Mtime = effectiveInfo.ModTime().UnixNano()
56+
expectedHash := positronShadowCompositeHash(t, sourcePath, workspacePath)
57+
assert.Equal(t, expectedHash, observation.Fingerprint.Hash)
58+
legacySession.File.Hash = expectedHash
4959

5060
assert.Equal(t, *legacySession, observation.Results[0].Session)
5161
assert.Equal(t, legacyMessages, observation.Results[0].Messages)
5262
assert.Equal(t, []string{legacySession.ID}, observation.Planned.DataVersionSessionIDs())
5363
assert.Empty(t, observation.Planned.Diagnostics)
5464
}
65+
66+
func positronShadowCompositeHash(t *testing.T, sourcePath, workspacePath string) string {
67+
t.Helper()
68+
chatHash, err := ComputeFileHash(sourcePath)
69+
require.NoError(t, err)
70+
workspaceHash, err := ComputeFileHash(workspacePath)
71+
require.NoError(t, err)
72+
hash, err := ComputeHash(strings.NewReader(
73+
"chat\x00" + chatHash + "\x00workspace\x00" + workspaceHash,
74+
))
75+
require.NoError(t, err)
76+
return hash
77+
}

0 commit comments

Comments
 (0)