Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Conversation

@akalia25
Copy link
Contributor

@akalia25 akalia25 commented May 7, 2025

This PR adds PCW (Percentage of Code Written by Cody) tests for CharactersLogger. More info on PCW metric herehttps://sourcegraph.com/docs/analytics/pcw

  • Creates three focused test cases:
    • Base PCW calculation when both human and Cody contribute code
    • PCW updates when human deletes Cody-generated code
    • PCW updates when Cody deletes its own code

Test plan

Existing tests pass + all new test scenarios have been verified to pass with correct PCW calculations.

@akalia25 akalia25 marked this pull request as ready for review May 7, 2025 18:24
@akalia25 akalia25 changed the title Improve CharactersLogger tests for PCW calculation Add CharactersLogger tests for PCW calculation May 7, 2025
@akalia25 akalia25 changed the title Add CharactersLogger tests for PCW calculation Add PCW validation in CharactersLogger tests May 7, 2025
@akalia25 akalia25 requested review from sagtanih and valerybugakov May 7, 2025 18:35
@akalia25
Copy link
Contributor Author

@hitesh-1997 / @valerybugakov, any chance I could get a review or suggestions on how I could make this PCW test better? 🙏 Thanks!

return { humanCode, codyCode }
}

function calculateHumanInsertions(flushEvent: any): number {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cross checking if flushEvent should have any type apart from any

): number {
// PCW = (Cody code written - Cody code removed) / Total code written
const codyNetContribution = codyInsertions - codyDeletions
const totalCodeWritten = humanInsertions + codyInsertions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cross checking if totalCodeWritten should be totalCodeWritten = humanNetContribution + codyNetContribution
where netContribution = insertions - deletions.

Not related to this PR but thinking out loud and cross checking if this makes sense in general:
do you think instead of percentage of code written, percent of code editable is a better metrics. for example, in case of code cleaning, deletions are good contribution and although netContribution could be negative b/c deletions are more than insertion but overall this highlights a better contribution if it makes to the final commit.

}

// Calculate true PCW using all events
const PCW = totalCodyInsertions / (totalHumanInsertions + totalCodyInsertions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cross checking since its insertion, we are not taking deletions into account no

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants