Skip to content

feat(agent): render public-safe scenario summaries - #416

Merged
JSONbored merged 14 commits into
JSONbored:mainfrom
claytonlin1110:feat/scenario-summary-render
Jun 12, 2026
Merged

feat(agent): render public-safe scenario summaries#416
JSONbored merged 14 commits into
JSONbored:mainfrom
claytonlin1110:feat/scenario-summary-render

Conversation

@claytonlin1110

Copy link
Copy Markdown
Contributor

Summary

  • Adds src/scenarios/scenario-summary.ts with renderPublicScenarioSummary(), converting outputs from the existing pressure, eligibility, and blocker simulators into a structured PublicScenarioSummary for MCP/API and control-panel consumers
  • All text fields pass through sanitizePublicComment with a final defensive guard rejecting any serialization still containing forbidden language (wallet, hotkey, score estimates, trust scores, private reviewability)
  • Adds test/unit/scenario-summary.test.ts with 28 tests covering ranked option rendering, eligibility notes, blocker notes, data classification, combined inputs, sanitizer fixtures, and advisory-only invariants
  • Closes feat(agent): add repo-specific scenario simulator #271

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
  • npm run test:coverage locally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)
  • 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:

  • The full npm run test:coverage suite has 3 pre-existing failures on Windows (mcp-cli.test.ts, github-type-label.test.ts, mcp-release.test.ts) caused by a libuv platform assertion unrelated to this PR. All 96 scenario-related tests pass. Remaining CI checks (actionlint, build:mcp, ui:*, audit) are left for CI to run.

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.
  • 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. (no API surface change; render layer is internal)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (not applicable — backend only)
  • Visible UI changes include screenshots or a short recording. (not applicable — no UI changes)
  • Public docs/changelogs are updated where needed. (not applicable)

Notes

  • renderPublicScenarioSummary() is composable: all inputs are optional, so callers can pass any subset of simulator outputs (pressure simulation, eligibility plan, blockers, scenario input) without requiring all of them.
  • The assertPublicSummaryClean guard at the end of the render function is a defensive belt-and-suspenders check; in practice all fields are already sanitized individually before reaching it.

@ghost

ghost commented Jun 5, 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 #416 is no longer open. No action.

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

@github-actions github-actions Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jun 6, 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.

Requesting changes. The current CI run #1238 fails the coverage gate at 96.99% branch coverage, and the new render input accepts pending PR scenario data without rendering it. No merge action taken.

Comment thread src/scenarios/scenario-summary.ts
@ghost ghost mentioned this pull request Jun 7, 2026
23 tasks
@superagent-security superagent-security Bot added the pr:verified PR passed security analysis. label Jun 8, 2026
@claytonlin1110
claytonlin1110 requested a review from JSONbored June 8, 2026 05:11

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

@claytonlin1110 the renderer itself is better now, including pending PR scenario output.

A few notes:

  • The remaining blocker is wiring: renderPublicScenarioSummary() is only referenced by its unit test.
  • #271 is a parent mini-epic and explicitly says not to implement the full simulator in one PR. This looks like the public-summary child slice, not a full close of #271.
  • A pure helper plus tests is not enough if no API, MCP, CLI, or control-panel path can use it.

Required changes:

  • Wire the renderer into the intended real runtime surface, or narrow the PR/issue claim to the exact child issue it completes.
  • Add tests for the production path that consumes the rendered summary.
  • Update the PR closing reference so it does not close the parent mini-epic unless the full epic is complete.

Validation expected:

  • Rerun scenario-summary tests plus the tests for the runtime surface you wire.

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

@claytonlin1110 this still should not merge as-is.

A few notes:

  • The public/private boundary inside the renderer is pointed in the right direction.
  • The blocker is that this is still an isolated renderer plus tests. renderPublicScenarioSummary is not wired into an API, MCP tool, agent path, UI route, or other production surface.
  • The PR also claims the parent scenario epic, but this only implements one helper-sized slice.

Required changes:

- Wire renderPublicScenarioSummary into the real runtime surface that will emit or consume scenario summaries.
- Add behavior tests for that production path, not just the pure helper.
- Retarget the PR to the specific child issue/slice, or stop claiming that it closes the parent epic.

Validation expected:

- focused scenario-summary tests
- runtime-path tests proving the summary is actually used
- full validate

@dosubot dosubot Bot added size:XL and removed size:L labels Jun 8, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@superagent-security superagent-security Bot removed the pr:verified PR passed security analysis. label Jun 8, 2026
@dosubot dosubot Bot added size:L and removed size:XL labels Jun 9, 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.

@claytonlin1110 the implementation is much closer now, but the issue claim still needs to be corrected.

A few notes:

  • renderPublicScenarioSummary() is wired into buildLocalBranchAnalysis; this is no longer just dead helper code.
  • The sanitizer guard and scenario-summary tests are useful and aligned with the public-safe summary slice.
  • The blocker is issue integrity: #271 is a mini-epic and says not to implement the full simulator in one PR. This branch appears to complete the public-safe scenario summary child slice, not the whole parent epic.

Required changes:

  • Stop claiming Closes #271.
  • Retarget the PR body to the focused child issue it actually resolves, likely the public-safe scenario-summary slice, or explain the no-close rationale if that child issue is not the intended target.
  • Keep the parent epic open for the remaining simulator work.

Validation expected:

  • No new source validation required if only the PR body/linked issue claim changes.
  • If any code changes are made, rerun the focused scenario/local-branch tests and typecheck.

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

The implementation is in good shape now. renderPublicScenarioSummary is wired into a real runtime surface — buildLocalBranchAnalysis adds scenarioSummary to LocalBranchAnalysis and the new local-branch tests exercise it through that production path, so it is no longer an isolated helper. The public/private boundary is well handled: every text field passes sanitizePublicComment, the assertPublicSummaryClean guard rejects any serialization containing forbidden language, and there are forbidden-term assertions in both the scenario-summary and local-branch tests. Code-wise this is close to mergeable.

One required change remains — issue-claim integrity (no source change needed):

  • The PR body still says Closes #271, but #271 is the parent scenario mini-epic that explicitly says not to implement the full simulator in one PR. This branch implements only the public-safe scenario-summary child slice. Closing #271 on merge would prematurely close the epic and lose the remaining simulator work.
  • Please either retarget the closing reference to the specific child issue this resolves (the public-safe scenario-summary slice) or drop the Closes keyword and reference #271 with Refs #271, leaving the epic open.

No re-validation is required if only the PR body / linked-issue claim changes. If you touch source, rerun the focused scenario-summary and local-branch tests plus typecheck.

A couple of small, optional code notes for whenever you next push (not blocking):

  • In buildLocalBranchAnalysis, pendingDetectionForSummary always sets classified: [], so extractPendingPullRequests returns nothing on this path — intentional? If the per-PR list is meant to surface here, the classified entries need to be threaded in; if not, a one-line comment noting it is summary-notes-only would help future readers.
  • extractPendingScenarioNotes de-dupes via new Set, which is fine, but worth confirming note ordering is stable for the deterministic-output expectation.

@dosubot dosubot Bot added the size:L label Jun 11, 2026
@ghost

ghost commented Jun 11, 2026

Copy link
Copy Markdown

reviewbot · advisory review

Reviewed 4 changed file(s) — two independent AI reviewers.

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

Reviewer A · gpt-oss-120b — recommends 🛠️ request changes
The PR adds a robust public‑safe scenario summary renderer and integrates it into the local‑branch analysis, with accompanying unit tests. The implementation looks solid, but the newly added scenario‑summary.test.ts appears truncated, which will cause syntax errors and incomplete test coverage.

Suggestions

  • Complete the scenario-summary.test.ts file (ensure all describe/it blocks are closed and the file ends with a proper export).
  • Run the TypeScript compiler across the repo to confirm that adding the required scenarioSummary field does not break any existing LocalBranchAnalysis constructions.
  • Add a test verifying that renderPublicScenarioSummary throws when forbidden language slips through (edge case).

Worth double-checking

  • If other code constructs LocalBranchAnalysis without the new scenarioSummary field, compilation will fail.
  • The truncated test file will cause CI to error out.

Reviewer B · nemotron-3-120b-a12b — recommends ✅ merge
The PR adds a new feature to render public-safe scenario summaries for MCP/API clients and control-panel UIs. It introduces a new module (scenario-summary.ts) with types and a rendering function that excludes private data, integrates this into local-branch-analysis, and adds comprehensive unit tests. The changes are focused, well-documented, and include defensive checks against leaking sensitive information.

Suggestions

  • In src/scenarios/scenario-summary.ts, consider adding a comment explaining why 'repo_not_registered' and 'inactive_allocation' blockers are filtered out in extractBlockerNotes for future maintainers.
  • In extractEligibilityNotes, verify if plan.publicSummary already contains blocker or cleanup path details to avoid potential duplication (though current implementation appears intentional).

Worth double-checking

  • The addition of a required 'scenarioSummary' field to LocalBranchAnalysis is a breaking change for any external consumers of buildLocalBranchAnalysis. However, given the function's likely internal scope and updated tests, this risk is low.
  • The regex-based forbidden language check in assertPublicSummaryClean is defensive but could potentially miss edge cases (e.g., obfuscated terms). Current implementation covers the specified terms adequately.

@ghost

ghost commented Jun 12, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 4 changed file(s) — two independent AI reviewers.

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

Reviewer A · gpt-oss-120b — recommends 🛠️ request changes
This PR adds a new public‑safe scenario summary renderer and wires it into the local‑branch analysis, with accompanying unit tests. The implementation looks well‑structured and the defensive sanitisation is solid, but the diff for the new scenario‑summary.test.ts file is explicitly truncated, so we cannot verify that the test suite is complete or passes.

Suggestions

  • Provide the full contents of src/tests/unit/scenario-summary.test.ts (remove the truncation) so the test can be evaluated and run.
  • Run the TypeScript compiler locally to ensure the new imports (deriveEligibilityPlan, scenarioInputFromLocalBranchMetadata, renderPublicScenarioSummary) resolve correctly and that adding the scenarioSummary field does not break existing consumers of LocalBranchAnalysis.
  • Consider adding a test case for renderPublicScenarioSummary when no inputs (e.g., no pressureSimulation, eligibilityPlan, or pendingDetection) are provided, to verify the default headline and empty arrays.

Worth double-checking

  • If the truncated test file is incomplete, the CI may fail or miss coverage of edge cases.
  • Introducing the scenarioSummary property could cause type‑compatibility issues in parts of the codebase that construct or consume LocalBranchAnalysis.

Reviewer B · nemotron-3-120b-a12b — recommends ✅ merge
The PR adds a public-safe scenario summary feature to the local branch analysis. It introduces a new module (scenario-summary.ts) that renders sanitized advisory summaries excluding private data, updates local-branch.ts to include this summary in the analysis output, and adds comprehensive unit tests verifying the summary's correctness and absence of forbidden language. The implementation is well-structured, uses proper sanitization, and includes defensive checks.

Suggestions

  • Consider adding a fallback non-empty string for rationale in renderOptions when facts and tradeoffs are empty to avoid empty strings in output (though currently acceptable).
  • Add a comment in extractBlockerNotes explaining why repo_not_registered and inactive_allocation blockers are excluded from public summary for future maintainers.

Worth double-checking

  • The change adds a scenarioSummary field to LocalBranchAnalysis type - verify no external consumers rely on the exact shape without this new field (appears internal and tests updated).
  • Relies on sanitizePublicComment implementation elsewhere - ensure it's correctly maintained to prevent forbidden language leaks (mitigated by runtime assert and tests).

@ghost ghost added the gittensory-review label Jun 12, 2026
@dosubot dosubot Bot added the lgtm label Jun 12, 2026
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(agent): add repo-specific scenario simulator

2 participants