Skip to content

feat(advisor): planning advisor with severity taxonomy, opportunity factors, and eligibility-gap view - #834

Closed
YB0y wants to merge 10 commits into
JSONbored:mainfrom
YB0y:feat/planning-advisor-816
Closed

feat(advisor): planning advisor with severity taxonomy, opportunity factors, and eligibility-gap view #834
YB0y wants to merge 10 commits into
JSONbored:mainfrom
YB0y:feat/planning-advisor-816

Conversation

@YB0y

@YB0y YB0y commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the three pillars of the planning advisor requested in #816:

  1. Severity taxonomy — Every repo analysis now produces a structured advisoryAdvice: AdvisoryAdviceItem[] list with four machine-readable levels (CRITICAL / WARNING / TIP / INFO) and stable code slugs, replacing the existing plain-text scoreBlockers: string[] with a richer parallel structure that consumers can sort, filter, and render by severity.
  2. Opportunity factors — Two new numeric signals are added to RepoRewardRisk.rewardUpside:
    • competitionFactor (0–1): fraction of open issues that have no competing open PR linked. 1.0 = zero competition; 0.0 = every open issue already has a PR working on it.
    • freshnessFactor (0–1): exponential decay of the median age of open issues over a 90-day half-life. 1.0 = very fresh issue queue; approaches 0.0 for stale repos.
  3. Eligibility-gap viewContributorRewardRiskStrategy gains eligibilityGap: EligibilityGapEntry[], a cross-repo surface that surfaces repos where the contributor is just 1–5 open PRs away from dropping back under the scoring threshold. The same view is exposed on ContributorDecisionPack as eligibilityGapRepos, derived from the decision pack's existing scoreBlockers. Both lists are sorted ascending by prsNeededToUnlock so the quickest wins appear first.

Related Issue

Closes: #816

Change Type

  • New feature
  • Enhancement to existing feature
  • Bug fix
  • Refactor
  • Tests added / updated
  • Breaking change

Real Behavior Proof

Advisory severity taxonomy

// repo with open PRs over threshold and low credibility
advisoryAdvice: [
  { level: "CRITICAL", code: "open_pr_threshold_exceeded",
    message: "Open PR count (5) exceeds the scoring threshold (2)." },
  { level: "CRITICAL", code: "credibility_below_floor",
    message: "Credibility (0.5) is below the floor (0.8)." },
  { level: "WARNING",  code: "high_closed_pr_rate",
    message: "Closed PR rate of 40% creates credibility risk." }
]

Opportunity factors

// repo with 2 of 4 open issues competed, median issue age 30 days
rewardUpside: {
  ...existing fields...,
  competitionFactor: 0.5,          // half of issues have a competing PR
  freshnessFactor: 0.7165          // exp(-30/90) ≈ 0.72
}

Eligibility-gap view (strategy level)

// contributor has 3 open PRs in owner/repo-a (threshold 2) and 7 in owner/repo-b (threshold 2)
eligibilityGap: [
  { repoFullName: "owner/repo-a", currentOpenPrCount: 3,
    openPrThreshold: 2, prsNeededToUnlock: 1 },   // closes 1 PR → scoreable
  // owner/repo-b excluded: 5 PRs needed > 5 limit
]

Eligibility-gap view (decision pack level)

// contributor has 5 open PRs in owner/repo (threshold 4)
eligibilityGapRepos: [
  { repoFullName: "owner/repo", currentOpenPrCount: 5,
    openPrThreshold: 4, prsNeededToUnlock: 1 }
]

Checklist

  • npm run typecheck passes with 0 errors
  • npm run test:unit — 1987 tests pass, 0 failures
  • 34 new unit tests added covering all new helpers
  • No breaking changes to existing types (additive fields only)
  • Existing scoreBlockers: string[] in RepoRewardRisk preserved — advisoryAdvice is a parallel structured enrichment, not a replacement
  • Eligibility-gap threshold in decision-pack.ts (4) is consistent with the existing scoreBlockersFor trigger point (openPullRequests >= 5)
  • All new helper functions exposed via __rewardRiskInternals / __decisionPackInternals for test access — no production-test coupling
  • No UI changes, no migrations, no schema changes

…actors, and eligibility-gap view (JSONbored#816)

Co-Authored-By: YB0y <YB0y@users.noreply.github.com>
@YB0y
YB0y requested a review from JSONbored as a code owner June 17, 2026 16:44
@dosubot dosubot Bot added the size:L label Jun 17, 2026
@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #834 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@ghost ghost added the gittensory:reviewed label Jun 17, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

This comment has been minimized.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.61%. Comparing base (2973ff7) to head (5defc1e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #834      +/-   ##
==========================================
+ Coverage   96.60%   96.61%   +0.01%     
==========================================
  Files         109      109              
  Lines       14914    14966      +52     
  Branches     5390     5406      +16     
==========================================
+ Hits        14408    14460      +52     
  Misses        104      104              
  Partials      402      402              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jun 17, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good:

  • Useful planning-advisor shape: severity taxonomy, opportunity factors, eligibility-gap arrays.
  • Helper-level test coverage is broad.
  • Review bots found no direct logic/security blocker.

Bad:

  • Codecov patch/project fail.
  • Runtime payload adds new fields, but OpenAPI source/schema is unchanged.
  • Existing decision-pack snapshots are returned without defaulting advisoryAdvice/eligibilityGapRepos, despite the new type making them required.

Change requests:

  • Update OpenAPI schemas/generated public contract for new fields.
  • Default new arrays/factors on cached snapshot paths, or make them explicitly optional.
  • Fix Codecov patch/project failure.

@YB0y

YB0y commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@JSONbored Could you plz review my PR? Thanks!

@JSONbored
JSONbored self-requested a review June 18, 2026 23:49

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

PR #834 — feat(advisor): planning advisor (severity taxonomy, factors, eligibility-gap) [YB0y]
Action: CHANGES REQUESTED
Issue #816: PARTIALLY CI: pass

Good:

  • Severity taxonomy (CRITICAL/WARNING/TIP/INFO), competition+freshness opportunity factors, and a
    cross-repo eligibility-gap view, with a broad ~34-case helper test suite.

Flagged:

  1. advisoryAdvice / eligibilityGapRepos are added as REQUIRED fields but cached decision-pack snapshots
    are returned without defaulting them — runtime-shape risk on cached read paths. Default them or make optional.
  2. OpenAPI source/generated contract not updated for the new serialized fields.
  3. competition_factor is computed fresh, not reusing collision/duplicate detection as #816 specifies.
  4. Confirm reward/score-derived advisory fields stay off public surfaces.

@ghost

ghost commented Jun 19, 2026

Copy link
Copy Markdown

❌ Closed by the review gate

Not both reviewers approved (a change/close was recommended). Closed one-shot — address the notes and open a new focused PR.

🔍 Maintainer review

Reviewed 3 file(s) — ✅ all CI green.

Suggested action: 🛠️ Request changes. (reviewers split: merge / request changes) Address the suggestions below before merging.

Reviewer A · gpt-oss-120b — recommends ✅ merge
The changes introduce a comprehensive advisory system for private context‑risk analysis, adding new data fields, helper functions, and unit tests. Types are updated consistently, functions are implemented with proper guards, and no forbidden public terms or secret leakage are introduced. Tests cover the new logic thoroughly. No CI failures are reported.

Suggestions

  • Review any other places constructing ContributorDecisionPack to ensure the new required fields (advisoryAdvice, eligibilityGapRepos) are provided, or make them optional if future callers may omit them.
  • Update API documentation to describe the new advisoryAdvice and eligibilityGapRepos fields in the response schema.
  • Consider adding integration tests for the API endpoints that now include the new fields to verify serialization and access control.

Worth double-checking

  • Potential compile‑time breakage in modules that create ContributorDecisionPack literals without the new fields.
  • Exposure of advisory messages in any public API unintentionally; ensure they remain in private/internal endpoints.

Reviewer B · mistral-small-3.1-24b-instruct — recommends 🛠️ request changes
The PR introduces a new planning advisor feature with severity taxonomy, opportunity factors, and eligibility-gap view. The changes are well-documented and include comprehensive tests.

Suggestions

  • Ensure that the new advisory advice does not inadvertently leak forbidden terms into public output.
  • Review the new functions for potential security vulnerabilities, especially those involving external data.
  • Consider adding more edge-case tests for the new functions to ensure robustness.

Worth double-checking

  • Potential for new public output to leak forbidden terms.
  • Risk of regression in existing functionality due to the addition of new logic.
  • Possible security vulnerabilities in new functions handling external data.
    This repo uses one-shot review: a rejected PR is closed, not iterated in place. Please address the above and open a new focused PR.

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

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(planning): fold upstream-inspired advisor/scan ideas into gittensory miner planning

2 participants