Skip to content

feat(scoring): simulate open-pr pressure scenarios - #348

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
Lobster-0429:feat/open-pr-pressure-scenarios
Jun 3, 2026
Merged

feat(scoring): simulate open-pr pressure scenarios#348
JSONbored merged 2 commits into
JSONbored:mainfrom
Lobster-0429:feat/open-pr-pressure-scenarios

Conversation

@Lobster-0429

Copy link
Copy Markdown
Contributor

Summary

Scope

  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck — clean
  • npm run test:coverage locally — 788 pass (1 skipped); pre-existing Windows failures confirmed on main before this branch; coverage stays above 97%
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • UI/MCP/worker checks not applicable — this PR adds one pure simulation service plus its unit test; no UI, MCP, or worker surface changed

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics — a test asserts no payout/reward/score claims appear.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (not applicable)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (simulator is pure; wiring into surfaces is out of scope)
  • Visible UI changes include screenshots or a short recording. (not applicable)
  • Public docs/changelogs are updated where needed. (not applicable)

Notes

OpenPrPressureSimulation shape:

Field Meaning
lane contributor or maintainer (from RoleContext.maintainerLane)
queuePressure low / medium / high / critical, or unknown when queueHealth is null
recommendedOption the rank-1 option
scenarios[] each option with rank, recommended, facts, assumptions, tradeoffs, blockers
summary one-sentence public-safe recommendation

Contributor-lane ranking:

Own open PRs Pressure Order (rank 1 → 3)
> 0 high/critical/unknown cleanup_first, wait, open_new_work
> 0 low/medium cleanup_first, open_new_work, wait
0 high/critical/unknown wait, open_new_work, cleanup_first
0 low/medium open_new_work, wait, cleanup_first

cleanup_first carries a blocker ("no open PR(s)… nothing to clean up") when the contributor has no open PRs.

Maintainer-lane ranking: open_new_work by default (maintainer work is repo-health work, not outside-contributor queue load), switching to cleanup_first (queue triage) under critical pressure. Maintainers are never penalized for their own concurrent PRs (no blocker emitted).

Facts vs assumptions: facts are observed queue signals (open PR/issue counts, stale PRs, the contributor's own open PR count); assumptions are projections (e.g. "opening another PR would add to the current high pressure"). Missing-signal repos mark these as estimates and recommend a conservative wait.

Test structure (16 tests): four repo fixtures (low/high/maintainer/missing-signal) asserting recommended option, full ranking order, facts, assumptions, and blockers; a facts-vs-assumptions separation check; and two sanitizer tests confirming every field passes sanitizePublicComment and no payout/reward/score language appears.

Adds src/services/open-pr-pressure-scenarios.ts, a pure simulator that
models how opening another PR affects repo queue pressure and contributor
strategy. Compares three options — open new work, wait, or clean up
existing work first — using repo queue health and maintainer-lane signals.
Advisory only; no payout/reward/score claims and no GitHub actions.

simulateOpenPrPressure({ queueHealth, roleContext, contributorOpenPrCount })
returns a ranked OpenPrPressureSimulation:
- queuePressure: low/medium/high/critical, or "unknown" when queueHealth
  is null (missing-signal repos).
- lane: "maintainer" when roleContext.maintainerLane, else "contributor",
  ranked by separate heuristics.
- scenarios: each option carries rank, recommended flag, known facts
  (observed queue counts/state), assumptions (projections), tradeoffs,
  and blockers — facts and assumptions are kept in distinct fields.
- recommendedOption + summary.

Contributor ranking: own open PRs + heavy pressure -> cleanup_first;
own PRs + light pressure -> cleanup_first; no own PRs + heavy pressure
-> wait; otherwise open_new_work. cleanup_first carries a blocker when
the contributor has no open PRs to clean. Maintainer ranking: open_new_work
by default, cleanup_first (queue triage) under critical pressure; maintainers
are never penalized for their own concurrent PRs.

Scope is open-PR pressure only; linked-issue eligibility and duplicate/
stale blockers are handled by separate services (JSONbored#288/JSONbored#289). All public
text runs through sanitizePublicComment.

test/unit/open-pr-pressure-scenarios.test.ts (new, 16 tests):
- Fixtures for low-pressure, high-pressure, maintainer-lane, and
  missing-signal repos, asserting recommended option, ranking order,
  facts, assumptions, and blockers.
- Facts-vs-assumptions separation check.
- Public sanitizer tests: every scenario field across all fixtures passes
  sanitizePublicComment; no payout/reward/score claims appear.

@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.

@web-dev0521 this is a focused addition and the shape looks right.

A few notes:

  • Keeping the scenario math isolated makes this easy to validate before wiring it into higher-level planning surfaces.
  • The tests cover the pressure cases directly instead of only checking a happy path.
  • The PR description has the issue and validation evidence needed for review.

No code changes requested.

Validation expected:

  • Keep the current CI suite green through merge.

@dosubot dosubot Bot added the lgtm label Jun 3, 2026
@JSONbored
JSONbored merged commit fab16a8 into JSONbored:main Jun 3, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 3, 2026
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed feature labels Jun 10, 2026
oktofeesh1 added a commit to oktofeesh1/loopover-oktofeesh1 that referenced this pull request Jun 19, 2026
…o summary (JSONbored#348)

`simulateOpenPrPressure` (open-pr-pressure-scenarios.ts, JSONbored#348) and the
`renderPublicScenarioSummary` `options`/headline rendering for it were both
implemented and tested, but the only production caller —
buildLocalBranchAnalysis — never built or passed `pressureSimulation`. As a
result `scenarioSummary.options` was ALWAYS empty in analyze-branch / preflight
/ local-diff, and the strategy guidance (open new work / wait / clean up first)
never reached contributors.

Build the simulation at the call site (roleContext is already in scope; derive
queueHealth via buildCollisionReport + buildQueueHealth, and the contributor's
own open-PR count) and pass it through. Pure/read-only and public-safe — the
renderer already sanitizes every line.

Test: local-branch.test.ts now asserts scenarioSummary.options is populated
(3 ranked options, exactly one recommended, non-empty label + nextStep).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JSONbored added a commit that referenced this pull request Jun 20, 2026
…o summary (#348) (#923)

`simulateOpenPrPressure` (open-pr-pressure-scenarios.ts, #348) and the
`renderPublicScenarioSummary` `options`/headline rendering for it were both
implemented and tested, but the only production caller —
buildLocalBranchAnalysis — never built or passed `pressureSimulation`. As a
result `scenarioSummary.options` was ALWAYS empty in analyze-branch / preflight
/ local-diff, and the strategy guidance (open new work / wait / clean up first)
never reached contributors.

Build the simulation at the call site (roleContext is already in scope; derive
queueHealth via buildCollisionReport + buildQueueHealth, and the contributor's
own open-PR count) and pass it through. Pure/read-only and public-safe — the
renderer already sanitizes every line.

Test: local-branch.test.ts now asserts scenarioSummary.options is populated
(3 ranked options, exactly one recommended, non-empty label + nextStep).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: ghost <49853598+JSONbored@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jun 20, 2026
12 tasks
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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

feat(scoring): simulate open-pr pressure scenarios

2 participants