Skip to content

fix(optimize): don't flag a young project's founding session as a cost outlier - #666

Merged
iamtoruk merged 1 commit into
mainfrom
fix/664-young-project-outlier
Jul 16, 2026
Merged

iamtoruk merged 1 commit into
mainfrom
fix/664-young-project-outlier

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Problem

detectSessionOutliers flags 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 outlierExclusions set. 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 (< 6 costed 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, bump YOUNG_PROJECT_SESSION_LIMIT. Easy to adjust.

Tests

tests/optimize.test.ts, exercised through scanAndDetect:

  • young project, expensive earliest session → not flagged (the reported bug)
  • young project, expensive later session → still flagged (no over-suppression)
  • mature project, expensive earliest session → still flagged (young-awareness, not a blanket "always exclude the earliest")

npx tsc --noEmit clean; npx vitest run tests/optimize.test.ts green (86 tests).

Fixes #664

…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
@iamtoruk
iamtoruk merged commit 4ef32c2 into main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optimize: session-outlier detector flags every project's founding/bootstrap session as waste

2 participants