Repository navigation
fix(optimize): don't flag a young project's founding session as a cost outlier - #666
Merged
Merged
Conversation
…utlier detection A project's first/bootstrap session is a different kind of work (one-off scaffolding), not an expensive instance of routine work. While a project is still young its peer sample is thin, so the leave-one-out average is dominated by a few routine sessions and the founding session's legitimately high one-off cost trips the >2x outlier multiplier. Exclude each young project's earliest costed session from the outlier finding only; mature projects are unaffected so genuine outliers still surface. Young = fewer than 2x MIN_SESSIONS_FOR_OUTLIER costed sessions. Fixes #664
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
detectSessionOutliersflags a project's founding/bootstrap session as a "high-cost session outlier" (#664). A founding session is a different kind of work (one-off scaffolding: brainstorm → plan → build → promote), not an expensive instance of routine work. While a project is still young its peer sample is thin, so the leave-one-out average is dominated by a few routine sessions and the founding session's legitimately-high one-off cost trips the 2x multiplier. The finding's advice ("split into smaller sessions") is actively wrong for a normal project kickoff, and the pattern recurs for every new project's first session.Thanks @jnaysmithgit for the detailed report and the suggested approach.
Fix
Exclude each project's earliest costed session from the cost-outlier finding only while the project is still young, via the existing
outlierExclusionsset. The excluded session still counts toward the peer average — only its flagging is suppressed. Mature projects are unaffected, so genuine outliers still surface."Young" is measured by costed-session count, not wall-clock age: the category error is driven by peer-sample thinness, which is session count. A project with many sessions has a robust average even if created in a short span. Threshold:
YOUNG_PROJECT_SESSION_LIMIT = 2 * MIN_SESSIONS_FOR_OUTLIER(currently 6) — a project is treated as bootstrapping until it has twice the minimum sessions needed to evaluate outliers at all.Scoped to the outlier finding only (not low-worth / context-bloat). "Earliest" is by
firstTimestamp, not array order.Tuning note
The young/mature boundary (
< 6costed sessions) is a judgment call. At exactly 6 sessions the founding session's peer sample is 5; if you'd prefer to protect it a little longer, bumpYOUNG_PROJECT_SESSION_LIMIT. Easy to adjust.Tests
tests/optimize.test.ts, exercised throughscanAndDetect:npx tsc --noEmitclean;npx vitest run tests/optimize.test.tsgreen (86 tests).Fixes #664