@skyramp/mcp 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/build/prompts/test-recommendation/diffExecutionPlan.js +40 -9
  2. package/build/prompts/test-recommendation/fullRepoCatalog.js +3 -2
  3. package/build/prompts/test-recommendation/recommendationSections.js +3 -3
  4. package/build/prompts/test-recommendation/scopeAssessment.d.ts +2 -2
  5. package/build/prompts/test-recommendation/scopeAssessment.js +58 -76
  6. package/build/prompts/test-recommendation/test-recommendation-prompt.js +14 -1
  7. package/build/prompts/testbot/testbot-prompts.js +25 -8
  8. package/build/recommendation/budgeters/diversityBalancedBudgeter.js +39 -5
  9. package/build/recommendation/budgeters/shared.d.ts +21 -8
  10. package/build/recommendation/budgeters/shared.js +134 -56
  11. package/build/recommendation/planRanker.d.ts +5 -3
  12. package/build/recommendation/planRanker.js +1 -1
  13. package/build/tools/submitReportTool.js +6 -1
  14. package/build/tools/test-management/registerTestPlanTool.d.ts +3 -3
  15. package/build/tools/test-management/registerTestPlanTool.js +29 -8
  16. package/build/types/RepositoryAnalysis.d.ts +10 -10
  17. package/build/types/TestRecommendation.d.ts +11 -1
  18. package/build/types/TestRecommendation.js +34 -0
  19. package/build/utils/pathSignatures.d.ts +4 -1
  20. package/build/utils/pathSignatures.js +14 -2
  21. package/build/utils/planOnlyMode.d.ts +33 -0
  22. package/build/utils/planOnlyMode.js +40 -0
  23. package/build/utils/reportVerification.d.ts +5 -0
  24. package/build/utils/reportVerification.js +7 -2
  25. package/build/utils/scenarioDrafting.d.ts +1 -1
  26. package/build/utils/scenarioDrafting.js +1 -1
  27. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { logger } from "../../utils/logger.js";
3
3
  import { AnalyticsService } from "../../services/AnalyticsService.js";
4
4
  import { MAX_TESTS_TO_GENERATE, MAX_RECOMMENDATIONS, MAX_CRITICAL_TESTS, PATH_PARAM_UUID_GUIDANCE, AUTH_CONFLICT_ERROR_MSG, } from "../test-recommendation/recommendationSections.js";
5
5
  import { setReportLanguage } from "../../utils/reportLanguage.js";
6
+ import { setPlanOnlyMode } from "../../utils/planOnlyMode.js";
6
7
  import { TASK_ANALYZE_MAINTAIN, TASK_GENERATE, TASK_SUBMIT, taskRef, } from "../test-recommendation/recommendationShared.js";
7
8
  import { getTraceRecordingPromptText } from "../../playwright/traceRecordingPrompt.js";
8
9
  import { isContractConsumerModeEnabled, isPomReuseEnabled, isUtilsReuseEnabled, } from "../../utils/featureFlags.js";
@@ -119,6 +120,13 @@ export function getTestbotPrompt(opts) {
119
120
  // en/argless render disarms a language captured earlier in a long-lived
120
121
  // server process instead of falsely rejecting an English report.
121
122
  setReportLanguage(language && language !== "en" ? language : undefined);
123
+ // SKYR-4250: same capture point, same last-render-wins rule, for the
124
+ // plan-only lane. skyramp_submit_report's SKYR-3883 guard
125
+ // (findUnchangedFileClaims) verifies newTestsCreated against the working
126
+ // tree; a plan-only run writes no files, so without this every declaration
127
+ // is unchanged-file-flagged and the agent is forced to demote it to
128
+ // additionalRecommendations.
129
+ setPlanOnlyMode(planOnly);
122
130
  let reportLanguageBlock = "";
123
131
  if (language && language !== "en") {
124
132
  const reportLanguageName = new Intl.DisplayNames(["en"], { type: "language" }).of(language) ??
@@ -222,6 +230,9 @@ ${maintenanceBeforeExecStep}
222
230
  - Incorrect arithmetic in business logic (discount calculations, price aggregation)
223
231
  Log each finding in \`issuesFound\` with a \`severity\` (critical/high/medium/low). These bugs should inform your test design in Task 2.
224
232
 
233
+ **Requirement check — does the code do what the PR says it does?** Read the \`<TITLE>\` and \`<DESCRIPTION>\` above as a statement of *intended* behavior and check the diff against it, requirement by requirement. The description is not outranked by the code: when the two disagree, that is a \`requirement_conflict\`, not a case of "the description loses". Detection, the requirements-file rules, the four false-red pre-checks and the promotion ordering are specified in the Code Review step of the Execution Plan \`skyramp_analyze_changes\` returned — follow them there rather than improvising; read any requirements file the description names from \`${repositoryPath}\`.
234
+ - **On a mismatch, do both.** (a) Add an \`issuesFound\` entry at severity \`high\` or \`critical\` — never \`medium\` or below — quoting the requirement and naming the file and line that contradicts it. (b) Carry it into Task 2 as a \`requirement_conflict\` candidate: a test asserting **what the description requires**, which therefore FAILS on the current code. Where no such test is recordable, record the Execution Plan's VERIFY-style entry in \`additionalRecommendations\` instead — never resolve the disagreement by asserting what the code does.
235
+
225
236
  4. **Blueprint Citation Invariant** (UI test recommendations only). Every named UI element in your recommendation must correspond to an element actually captured in one of the blueprints you captured from the UI Blueprint Capture section of \`skyramp_analyze_changes\`. For **every** UI recommendation — both \`newTestsCreated[]\` entries (tests you generated) AND \`additionalRecommendations[]\` entries (deferred tests) with \`testType: "ui"\` — populate **four** fields: \`description\`, \`reasoning\`, \`targetElements\`, and \`pageContext\`. \`description\` and \`reasoning\` carry different roles — fill BOTH (see Field 4 below). The structured fields (\`targetElements\`, \`pageContext\`) are required on UI recs in BOTH arrays; non-UI recs (contract / integration / e2e / batch-scenario) MUST omit them.
226
237
 
227
238
  **Field 1 — \`targetElements\`** (the elements the test targets — array, length 1+):
@@ -431,7 +442,7 @@ ${maintenanceBeforeExecStep}
431
442
  **Self-check before calling \`skyramp_submit_report\`:** count your final GENERATE list, then confirm \`newTestsCreated\` has exactly that many entries — one per GENERATE item. A GENERATE item always goes in \`newTestsCreated\` (even though no file was generated in this run — the declaration IS the deliverable); \`additionalRecommendations\` holds ONLY candidates that are NOT in the GENERATE list. Reporting a GENERATE item as a recommendation instead of a declaration is the single most common plan-only reporting error — recheck the placement before submitting.`;
432
443
  }
433
444
  else {
434
- task3CountRule = `Otherwise (your Budget Plan is non-zero): in \`newTestsCreated\`, you must have exactly as many budget-counting new tests as your committed Budget Plan's generate count (at most ${maxGenerate}). Only new files (ADD) created for the planned GENERATE items count toward this target — GENERATE items converted to UPDATE do not. You may also include at most one additional discovered-scenario file in \`newTestsCreated\` (the bug-catching test generated after all planned items); that extra test does **not** count against the budget. If you have fewer budget-counting new tests than your generate count, backfill from the remaining ADDITIONAL candidates before proceeding. Only proceed with fewer if all candidates failed after retry AND the fallback single-contract test also failed.`;
445
+ task3CountRule = `Otherwise (your Budget Plan is non-zero): in \`newTestsCreated\`, you must have exactly as many budget-counting new tests as your committed Budget Plan's generate count (at most ${maxGenerate}). Only new files (ADD) created for the planned GENERATE items count toward this target — GENERATE items converted to UPDATE do not. You may also include at most one additional discovered-scenario file in \`newTestsCreated\` (the bug-catching test generated after all planned items); that extra test does **not** count against the budget. If you have fewer budget-counting new tests than your generate count, backfill from the remaining ADDITIONAL candidates before proceeding. Only proceed with fewer if every remaining candidate failed after retry and, on a PR with backend changes, the fallback single-contract test also failed. A frontend-only PR has no backend fallback: its exhausted candidates go to \`additionalRecommendations\` with the failure reason.`;
435
446
  }
436
447
  // Task 2 branches wholesale in plan-only eval runs (SKYR-3879 plan-only
437
448
  // lane): the standard task mandates generation and execution, which a
@@ -443,9 +454,9 @@ ${maintenanceBeforeExecStep}
443
454
 
444
455
  This is a plan-only evaluation run: the application under test is NOT running, and this run evaluates test SELECTION only. Nothing is generated or executed in this task.
445
456
 
446
- - Draft your complete candidate list exactly as the Execution Plan directs — every API test (contract / integration / batch-scenario) you would generate OR recommend for this PR, grounded in the analysis output and the diff. Favor tests that would FAIL if the changed logic were buggy, not just tests that exercise the new surface.
457
+ - Draft your complete candidate list exactly as the Execution Plan directs — every test you would generate OR recommend for this PR, grounded in the analysis output and the diff. Favor tests that would FAIL if the changed logic were buggy, not just tests that exercise the new surface.
447
458
  - If a tool named \`skyramp_register_test_plan\` is available, call it with the full candidate union — include a \`discriminator\` claim \`{kind, changedCodeAnchor}\` for every candidate that probes changed logic — and treat its returned GENERATE list as your final selection. If that tool is not available, commit to your Budget Plan's GENERATE selection (at most ${maxGenerate}).
448
- - Skip UI and E2E candidates entirely with no running app there are no blueprints to ground them, and this lane evaluates API test selection only.
459
+ - Include UI and E2E candidates on the same footing as the API types. The app is not running, so you cannot capture a blueprint — plan them ungrounded rather than drop them. For every UI entry, set \`targetElements: null\`, omit \`pageContext\`, and prefix BOTH \`description\` and \`reasoning\` with \`[no-blueprint-data]\`. Describe the page or feature the test would exercise; do not name an element you have not seen. This lane is the one case where you fall back without attempting a capture first, so do NOT log the fallback in \`issuesFound\` — capture was never applicable here, and nothing failed.
449
460
  - Take no other actions in this task: no test generation tools, no browser traces or blueprint captures, no test files written, no test executions. Proceed directly to ${taskRef(TASK_SUBMIT)}.`;
450
461
  }
451
462
  else {
@@ -453,8 +464,8 @@ This is a plan-only evaluation run: the application under test is NOT running, a
453
464
 
454
465
  ${userPrompt ? "Generate only the tests that the user requested from the Additional Recommendations. The rules below still apply." : "Drift-based maintenance (Task 1) is complete. This step only processes the GENERATE list. Exception: if a GENERATE item targets a resource with an existing `[skyramp]` contract test, UPDATE that test file (see covered-resource handling below) — a new test case added to an existing file counts toward the budget and is reported in `newTestsCreated`."}
455
466
 
456
- - **MANDATORY — use the plan returned by \`skyramp_register_test_plan\` as-is**: Before generating anything, call \`skyramp_register_test_plan\` (\`stateFile\` required) with your complete candidate list — every test you would generate OR recommend, including the Execution Plan's own pre-ranked GENERATE/ADDITIONAL items and any candidate you drafted yourself, with a \`discriminator\` claim \`{kind, changedCodeAnchor}\` for candidates probing changed logic. Its returned GENERATE list — not the Execution Plan's raw pre-ranked GENERATE section — governs ADD actions from this point on. You MUST generate exactly those scenarios in the exact order listed, keeping each item's \`scenarioName\` exactly as registered — the generation tools match on it and reject renamed or substituted scenarios. If parameter grounding uncovers a distinct bug-catching scenario not already registered, generate it after all planned GENERATE items are complete and report it in \`newTestsCreated\` — this is an additional test driven by source-code analysis and does not count against the GENERATE budget.${hasRelatedRepos ? `\n - **Multi-repo exception:** this run has related repositories, so the per-repo GENERATE lists are NOT final — they are candidates re-selected by the cross-repo round-robin described in Task 1's "Cross-repo test generation". Register the pooled, type-distributed selection instead of any single repo's GENERATE list — call \`skyramp_register_test_plan\` ONCE for the whole run, with candidates from EVERY repo pooled into one list, including at least one UI candidate when any repo changed frontend files (the tool rejects a pooled registration without one). (In single-repo runs, register the GENERATE list exactly as-is.)` : ""}
457
- - **Do not fabricate tests outside the GENERATE list provided by \`skyramp_analyze_changes\`.** Changes that only modify, delete, or add fields to an EXISTING covered endpoint or component are maintenance: handle them in ${taskRef(TASK_ANALYZE_MAINTAIN)} by UPDATE/DELETE of the existing test, never by creating a new spec. If the GENERATE list is empty, create zero new tests and proceed to ${taskRef(TASK_SUBMIT)}.
467
+ - **MANDATORY — use the plan returned by \`skyramp_register_test_plan\` as-is**: Before generating anything, call \`skyramp_register_test_plan\` (\`stateFile\` required) with your complete candidate list — every test you would generate OR recommend, including the Execution Plan's own pre-ranked GENERATE/ADDITIONAL items and any candidate you drafted yourself, with a \`discriminator\` claim \`{kind, changedCodeAnchor}\` for candidates probing changed logic. Its returned GENERATE list — not the Execution Plan's raw pre-ranked GENERATE section — governs ADD actions from this point on. You MUST generate exactly those scenarios in the exact order listed, keeping each item's \`scenarioName\` exactly as registered — the generation tools match on it and reject renamed or substituted scenarios. If parameter grounding uncovers a distinct bug-catching scenario not already registered, generate it after all planned GENERATE items are complete and report it in \`newTestsCreated\` — this is an additional test driven by source-code analysis and does not count against the GENERATE budget. **Every \`requirement_conflict\` candidate from Task 1's requirement check belongs in this registration** — register it with category \`requirement_conflict\` so it ranks in the top tier and takes the first promoted slot rather than losing one to a bug-catching candidate; omitting it from the candidate list is how a stated requirement silently loses its test.${hasRelatedRepos ? `\n - **Multi-repo exception:** this run has related repositories, so the per-repo GENERATE lists are NOT final — they are candidates re-selected by the cross-repo round-robin described in Task 1's "Cross-repo test generation". Register the pooled, type-distributed selection instead of any single repo's GENERATE list — call \`skyramp_register_test_plan\` ONCE for the whole run, with candidates from EVERY repo pooled into one list, including at least one UI candidate when any repo changed frontend files (the tool rejects a pooled registration without one). (In single-repo runs, register the GENERATE list exactly as-is.)` : ""}
468
+ - **Do not fabricate tests outside the GENERATE list returned by \`skyramp_register_test_plan\`.** A change to an EXISTING covered endpoint or component is maintenance only where an existing test asserts the changed value: handle that in ${taskRef(TASK_ANALYZE_MAINTAIN)} by UPDATE/DELETE of the existing test. A changed value, option, or behavior that no existing test asserts is not maintenance — it is a candidate you register (GENERATE or ADDITIONAL), however small the change. If the GENERATE list is empty, create zero new tests and proceed to ${taskRef(TASK_SUBMIT)}.
458
469
  - Scenario JSON files are always new files — always generate them for new methods. Every generated scenario JSON must have a corresponding new integration test generated from it via \`skyramp_integration_test_generation\`.
459
470
  - Covered-resource handling (aligns with Execution Plan Step 0): When a GENERATE item targets a resource that already has an existing test file covering the same endpoint:
460
471
  - If the existing test source is \`[external]\`, skip the resource entirely — the external test already provides coverage. Do NOT UPDATE, REGENERATE, or DELETE external tests.
@@ -479,6 +490,9 @@ ${userPrompt ? "Generate only the tests that the user requested from the Additio
479
490
  - **Always generate a test for critical bugs, even if it will fail.** When a GENERATE-tagged item targets a page or endpoint with a known bug, do NOT skip it because you expect the test to fail — a failing test that documents a bug is more valuable than a text-only description. This applies within the existing GENERATE budget; do not add extra tests beyond the plan.
480
491
  - For UI rendering bugs: navigate to the broken page and add a \`browser_assert\` that verifies the page rendered its expected content (e.g. assert the page heading is visible). The assertion will fail on the broken page, which is the correct outcome — it documents the bug as a failing test.
481
492
  - The assertion MUST target the broken page itself, not a different page that works. If \`/orders/{id}/edit\` crashes, assert on \`/orders/{id}/edit\` (e.g. "Edit Order" heading visible), NOT on \`/orders\`.
493
+ - **The same rule covers a \`requirement_conflict\` from Task 1's requirement check — and it is promoted first.** Generate the test that asserts what the PR description requires, not what the code implements. It fails today; that is the deliverable, and it turns green when the code is fixed to match the description. Do NOT re-aim it at the implemented behavior to get a passing run, and do NOT drop it because a bug-catching test already occupies a slot — requirement conflicts take the first slots of the promotion bound, so the bug-catching tests yield to it, not the other way round.
494
+ - For a "should no longer be present" requirement: navigate to the page the description names, confirm from the capture that the element still renders, then assert its **absence**. The element name comes from the live capture, so the assertion is grounded; the failure is the conflict. Assert on the page the requirement is about — not a sibling page where the element is genuinely gone.
495
+ - For a "should now do X" requirement the code does not do: assert X. Same rule — the stated requirement is the expectation.
482
496
  - **Critical categories first**: At least 1 of the generated tests MUST be from a critical category (security_boundary, business_rule, data_integrity, breaking_change) if such candidates exist in the GENERATE set.
483
497
  - **Parallel generation (IMPORTANT for speed)**: Generate **independent tests in parallel** whenever possible. Tests targeting different endpoints with different output files can be generated concurrently in the same tool call batch. Specifically:
484
498
  - Call \`skyramp_batch_scenario_test_generation\` for ALL integration scenarios AND \`skyramp_contract_test_generation\` for ALL contract tests **in the same tool call batch**.
@@ -565,7 +579,6 @@ ${CONTRACT_MODE_GUIDANCE}
565
579
  - **\`browser_visual_snapshot\` — for visual/appearance checks**: when the instruction asks to take a screenshot, capture a baseline, or verify how a page/element/region *looks* (not its text or value), call \`browser_visual_snapshot\` — it records a \`toHaveScreenshot()\` assertion so the generated test pixel-compares against a baseline on every run. Do NOT use \`browser_take_screenshot\` for this: it captures a throwaway image that is dropped at export and never appears in the generated test (use it only to view the page yourself).
566
580
  - **Wait for stable state before the second capture**: After performing an action that affects computed fields (filling a discount, submitting a form, adding an item), check the current page state before calling the second \`browser_blueprint\` (the capture after the action). If a computed field — total, price, count, derived text — still shows its initial empty or zero value (e.g. \`$0.00\`, \`0\`, \`Loading...\`, empty string), that means async data hasn't finished loading yet. Use \`browser_wait_for\` to wait up to 10 seconds for the field to update to a real value (for example, wait for the total to show a non-zero amount like \`$799.99\` instead of \`$0.00\`). Once the field shows a real value, THEN call the second \`browser_blueprint\` to capture stable state. If after 10 seconds the field still hasn't updated, skip the assertion on that field — don't capture and assert a value that hasn't loaded.
567
581
  If \`browser_navigate\` fails (app not running / connection refused), apply skip condition (a) above: move the intended test to \`additionalRecommendations\` with the failure reason AND record the outage in \`issuesFound\`.
568
- Record at most 2-3 UI traces per run to stay within tool call budget. Quality over quantity: 1 great test is better than 3 mediocre ones — do not pad to reach the count.
569
582
  **Strategic assertions** — key checkpoints only, 3 to 5 per test:
570
583
  - **After the main action completes**: verify the outcome is visible (new item appears, form saves, confirmation shows)
571
584
  - **State transitions**: verify counts, totals, or status fields update correctly
@@ -631,6 +644,8 @@ If a test **execution** (\`skyramp_execute_test\`) fails for a newly generated t
631
644
  1. Read the error output to diagnose the root cause (4xx on prereq step, assertion mismatch, floating-point precision, 500 from app bug, timeout, etc.).
632
645
  2. **Expected failure check (no retry):** If the failure is an assertion error or HTTP error that matches the issue identified in the code analysis (e.g. the test was generated specifically to document a broken endpoint, a UI rendering bug, or a missing validation), then this is the **intended outcome** — the test is correctly catching the real bug. Report it immediately as \`status: "Fail"\` and move on. Do NOT retry.
633
646
 
647
+ **A \`requirement_conflict\` test failing is likewise the intended outcome.** It asserts what the PR description requires and the code does not do; a red result is the finding, so report \`status: "Fail"\` with the conflict named in \`issuesFound\` and move on. Do NOT retry it, do NOT relax the assertion toward the implemented behavior, and do NOT delete the test — either of those hides the disagreement the run exists to surface.
648
+
634
649
  This path also covers an assertion failure that application behavior outside this PR's diff explains — for example child records that survive the deletion of their parent, state inherited when an ID is recycled or reused, or a value that ignores a status the test set. Before you keep such a test red, confirm the cause in the source: read the handler, model, or query that should have done the work, and find the specific operation that is missing or wrong. If you find it, report the test as \`status: "Fail"\` and add an \`issuesFound\` entry for it. Do NOT retry.
635
650
 
636
651
  If you cannot point at the missing or wrong line in application code, the app is not at fault — shared or seeded data, parallel test workers, or setup the test itself never did explain the collision. Treat that as an infrastructure failure: fix it and retry once as in step 3.
@@ -683,7 +698,7 @@ If you skipped here due to non-application changes (per Task 1), submit with emp
683
698
 
684
699
  **If you generated zero new tests because the PR has no testable behavioral surface:**
685
700
  This applies when the diff contains ONLY changes with no observable API or UI behavior change. Examples:
686
- - Cosmetic/docs/style: JSDoc updates, CSS reformats, comment-only changes
701
+ - Docs/comments only: JSDoc updates, comment-only changes
687
702
  - Dependency-only: version bumps with no API surface change
688
703
  - Dead code / unintegrated utility or component: a new helper function, utility, or UI component added to the codebase but not imported, mounted, or rendered anywhere — use this classification only after confirming the new symbol does not appear as an import or render call in any other source file; do NOT classify as dead code based solely on the diff. For UI components specifically: an unintegrated component has no DOM node in the running app and cannot be browser-tested regardless of how complex its logic is
689
704
  - Config-only: linter rules, build config, environment variable additions with no runtime behavior change
@@ -694,6 +709,8 @@ In these cases:
694
709
  - \`businessCaseAnalysis\` must be a one-sentence summary of what the PR actually does (do NOT leave it blank)
695
710
  - \`additionalRecommendations\` must be \`[]\` — do NOT recommend tests for a no-surface PR
696
711
 
712
+ **This zero-test path does NOT apply when the requirement check found a \`requirement_conflict\`.** A requirement the PR description states and the diff did not implement is testable surface: report the conflict in \`issuesFound\` at severity \`high\` or above, and carry either the failing \`requirement_conflict\` test in \`newTestsCreated\` or its VERIFY-style entry in \`additionalRecommendations\`. Abstaining there hands the author back their own code as though it were the requirement.
713
+
697
714
  ${task3CountRule}
698
715
 
699
716
  ${reportLanguageBlock}Call \`skyramp_submit_report\` with \`stateFile\` (from \`skyramp_analyze_changes\` output) — the stateFile is required for execution outcome tracking, and the report is written beside it. Field names, types, and formats are defined in the tool's parameter schema — follow them exactly.
@@ -703,7 +720,7 @@ ${hasRelatedRepos
703
720
  - **MULTI-REPO attribution**: Set the \`repository\` field (\`owner/repo\`) on EVERY \`newTestsCreated\`, \`testResults\`, \`issuesFound\`, and \`additionalRecommendations\` item — including items about the PRIMARY repo — so each finding is unambiguously attributed. The primary repo's \`repository\` is \`${primaryRepo || "<the primary repo's owner/repo>"}\`; items derived from a related repo's diff (from the \`<related_repositories>\` analysis) carry that repo's \`repository\` value. In \`businessCaseAnalysis\`, include a short per-repo subsection and call out any cross-repo correlations you found.
704
721
  `
705
722
  : ""}
706
- - **additionalRecommendations**: AT MOST ${maxRecommendations - maxGenerate} items.
723
+ - **additionalRecommendations**: AT MOST ${maxRecommendations} minus the number of budget-counting tests in \`newTestsCreated\` — an unused generate slot becomes a recommendation slot. The one optional discovered-scenario test does not count against the budget, so it does not reduce this allowance either.
707
724
  - For \`testType: "contract"\` entries: **\`primaryEndpoint\` is required** (e.g. \`"GET /api/v1/users/{user_id}"\`). The tool will reject the submission without it — do not omit it or you will be forced to resubmit.
708
725
 
709
726
  ${getTraceRecordingPromptText({ outputDir: `${repositoryPath}/.skyramp`, modularize: false, modularizeViaGenerationResult: UI_UTILS_REUSE })}`;
@@ -27,16 +27,50 @@ function floorBalancedPick(items, count) {
27
27
  typesOrder.push(t);
28
28
  }
29
29
  }
30
- const maxProtected = Math.max(0, count - (typesOrder.length - 1));
30
+ // Two passes, because "protected" is broader than "is a caught bug".
31
+ //
32
+ // A `bug_caught` candidate may take a type-floor slot: a caught bug is the
33
+ // strongest thing a run produces, and it outranks type spread. Every OTHER
34
+ // protected candidate — anything else CRITICAL, and attack-surface
35
+ // security_boundary items — still yields to the floor, which is what stops
36
+ // the SKYR-3879 skew where three CRITICAL integration candidates took all
37
+ // three slots and no contract test was generated.
38
+ //
39
+ // The second pass replaces `maxProtected = count - (typesOrder.length - 1)`,
40
+ // a static cap computed from the whole pool. It reserved a slot for every
41
+ // other type whether or not the picks already covered it, so at the default
42
+ // budget of 3 with three types present it evaluated to 1. Counting the types
43
+ // still uncovered keeps the same floor and drops the arithmetic that made a
44
+ // second finding unreachable.
45
+ // The same bound the prompt states (`maxGen - 1`, and the whole budget only
46
+ // at a budget of 1). Without it the first pass took every caught bug up to
47
+ // `count`, which put the SKYR-3879 skew back: at the default budget of 3, two
48
+ // same-type bugs left no slot for the type floor, and a measured 9-20% of
49
+ // backend-only pools lost a test type. It also evicted attack-surface
50
+ // security_boundary items the prompt in this same branch says to preserve
51
+ // while any non-bug slot remains.
52
+ const bugSlots = count <= 1 ? count : count - 1;
31
53
  const selected = [];
54
+ const deferred = [];
32
55
  const pool = [];
33
- let protectedTaken = 0;
56
+ let bugsTaken = 0;
34
57
  for (const it of items) {
58
+ if (it.scenario?.category === "bug_caught" && bugsTaken < bugSlots && selected.length < count) {
59
+ selected.push(it);
60
+ bugsTaken++;
61
+ }
62
+ else {
63
+ deferred.push(it);
64
+ }
65
+ }
66
+ const takenTypes = new Set(selected.map(typeOf));
67
+ for (const it of deferred) {
68
+ const stillUncovered = typesOrder.filter((t) => !takenTypes.has(t) && t !== typeOf(it)).length;
35
69
  if (isProtectedCandidate(it.priority, it.scenario) &&
36
- protectedTaken < maxProtected &&
37
- selected.length < count) {
70
+ selected.length < count &&
71
+ count - (selected.length + 1) >= stillUncovered) {
38
72
  selected.push(it);
39
- protectedTaken++;
73
+ takenTypes.add(typeOf(it));
40
74
  }
41
75
  else {
42
76
  pool.push(it);
@@ -1,13 +1,26 @@
1
1
  import { Candidate, BudgetContext, SelectionResult } from "../../types/Recommendation.js";
2
2
  /**
3
- * Backend GENERATE slot count:
4
- * - UI-only PR: 0 (all slots are UI placeholders)
5
- * - Mixed PR: maxGenerate - 1 (last slot reserved for a UI placeholder)
6
- * - Backend-only PR: maxGenerate
3
+ * What each PR class GUARANTEES in GENERATE (SKYR-4275). These are floors, not
4
+ * quotas: the slots above them are open to either kind, decided by `pick`.
5
+ * An open slot goes to whichever candidate `pick` chooses on rank, so a backend
6
+ * candidate takes one when it outranks the UI candidates, not merely because it
7
+ * exists. Measured against main on random mixed pools at `maxGenerate` 5 with no
8
+ * caught bugs: 35% get fewer backend tests than main did, average 3.53 to 3.24.
9
+ *
10
+ * Backend-only floors nothing on purpose: of 86 backend-only diffs in the eval
11
+ * corpus, ZERO generated a UI test, so a floor there would guarantee what
12
+ * already happens every time.
13
+ *
14
+ * At one slot there is no room for a floor plus an open slot, so each class
15
+ * keeps that slot for its own kind.
16
+ *
17
+ * The floors always sum to at most `maxGenerate`, which is what lets
18
+ * `applyFloors` satisfy both without one starving the other.
7
19
  */
8
- export declare function backendGenerateCount(ctx: BudgetContext): number;
9
- /** UI placeholder slots the render layer fills (UI-only → all; mixed → one). */
10
- export declare function reservedUISlots(ctx: BudgetContext): number;
20
+ export declare function generateFloors(ctx: BudgetContext): {
21
+ ui: number;
22
+ backend: number;
23
+ };
11
24
  /**
12
25
  * Shared budgeting pipeline. All Budgeters run the same external-dedup,
13
26
  * attack-surface prioritization, and ADDITIONAL set-difference; they differ
@@ -16,4 +29,4 @@ export declare function reservedUISlots(ctx: BudgetContext): number;
16
29
  * With `pick = roundRobinByType` this reproduces the pre-refactor selection in
17
30
  * diffExecutionPlan.ts exactly.
18
31
  */
19
- export declare function runBudget(ranked: Candidate[], ctx: BudgetContext, pick: (items: Candidate[], count: number) => Candidate[]): SelectionResult;
32
+ export declare function runBudget(ranked: Candidate[], rawCtx: BudgetContext, pick: (items: Candidate[], count: number) => Candidate[]): SelectionResult;
@@ -1,28 +1,76 @@
1
1
  import { TestType } from "../../types/TestTypes.js";
2
2
  import { inferScenarioType, prioritizeAttackSurfaceBundles } from "../diversity.js";
3
3
  import { externalDedupKeys, scenarioCoverageKeys, isAttackSurfaceSecurityBoundary, } from "../../prompts/test-recommendation/recommendationShared.js";
4
+ import { isFlawTargetingCategory } from "../../types/TestRecommendation.js";
4
5
  import { logger } from "../../utils/logger.js";
5
6
  /**
6
- * Backend GENERATE slot count:
7
- * - UI-only PR: 0 (all slots are UI placeholders)
8
- * - Mixed PR: maxGenerate - 1 (last slot reserved for a UI placeholder)
9
- * - Backend-only PR: maxGenerate
7
+ * What each PR class GUARANTEES in GENERATE (SKYR-4275). These are floors, not
8
+ * quotas: the slots above them are open to either kind, decided by `pick`.
9
+ * An open slot goes to whichever candidate `pick` chooses on rank, so a backend
10
+ * candidate takes one when it outranks the UI candidates, not merely because it
11
+ * exists. Measured against main on random mixed pools at `maxGenerate` 5 with no
12
+ * caught bugs: 35% get fewer backend tests than main did, average 3.53 to 3.24.
13
+ *
14
+ * Backend-only floors nothing on purpose: of 86 backend-only diffs in the eval
15
+ * corpus, ZERO generated a UI test, so a floor there would guarantee what
16
+ * already happens every time.
17
+ *
18
+ * At one slot there is no room for a floor plus an open slot, so each class
19
+ * keeps that slot for its own kind.
20
+ *
21
+ * The floors always sum to at most `maxGenerate`, which is what lets
22
+ * `applyFloors` satisfy both without one starving the other.
10
23
  */
11
- export function backendGenerateCount(ctx) {
24
+ export function generateFloors(ctx) {
25
+ // Number.isFinite, not Math.max: `Math.max(0, NaN)` is NaN, which compares
26
+ // false against 0 and would fall through to the class branches below.
27
+ const max = Number.isFinite(ctx.maxGenerate) ? Math.max(0, Math.floor(ctx.maxGenerate)) : 0;
28
+ if (max === 0)
29
+ return { ui: 0, backend: 0 };
12
30
  if (ctx.isUIOnlyPR)
13
- return 0;
14
- return ctx.hasFrontendChanges ? Math.max(0, ctx.maxGenerate - 1) : ctx.maxGenerate;
31
+ return { ui: max === 1 ? 1 : max - 1, backend: 0 };
32
+ if (ctx.hasFrontendChanges)
33
+ return max === 1 ? { ui: 1, backend: 0 } : { ui: 1, backend: 1 };
34
+ return { ui: 0, backend: 0 };
15
35
  }
16
- /** UI placeholder slots the render layer fills (UI-only → all; mixed → one). */
17
- export function reservedUISlots(ctx) {
18
- if (ctx.isUIOnlyPR)
19
- return ctx.maxGenerate;
20
- return ctx.hasFrontendChanges && ctx.maxGenerate > 0 ? 1 : 0;
36
+ /**
37
+ * Raise a chosen GENERATE set to meet the floors, by swapping rather than
38
+ * re-picking. `pick` runs ONCE over the whole pool, so its protected-first
39
+ * ordering, its one-slot-per-test-type coverage and attack-surface bundle
40
+ * adjacency are all settled before this runs. Picking each floor from its own
41
+ * slice instead would compute those guarantees per slice and collapse them —
42
+ * measured at 25% of mixed-PR inputs losing a test type, 8.3% losing contract
43
+ * coverage outright.
44
+ *
45
+ * A floor is raised only as far as the pool allows. Satisfying one floor cannot
46
+ * starve the other, because `generateFloors` never returns two that sum above
47
+ * the budget — `generateFloors.test.ts` pins that invariant.
48
+ */
49
+ function applyFloors(generate, slotOrdered, floors, isUI) {
50
+ const isBackend = (item) => !isUI(item);
51
+ const result = [...generate];
52
+ for (const [want, wanted] of [
53
+ [floors.ui, isUI],
54
+ [floors.backend, isBackend],
55
+ ]) {
56
+ const spare = slotOrdered.filter((item) => wanted(item) && !result.includes(item));
57
+ let shortfall = Math.min(want, result.filter(wanted).length + spare.length) - result.filter(wanted).length;
58
+ // Swap from the END: `pick` returns its slots in preference order, so the
59
+ // last one it chose is the one this PR class needs least.
60
+ for (let i = result.length - 1; i >= 0 && shortfall > 0; i--) {
61
+ if (wanted(result[i]))
62
+ continue;
63
+ result[i] = spare.shift();
64
+ shortfall--;
65
+ }
66
+ }
67
+ return result;
21
68
  }
22
69
  /**
23
70
  * Split candidates by whether an external test already covers them. Protected
24
- * `bug_caught` / attack-surface scenarios always count as uncovered — they
25
- * require semantic flaw coverage the external test may not provide.
71
+ * `bug_caught` / `requirement_conflict` / attack-surface scenarios always count
72
+ * as uncovered — they require semantic flaw coverage the external test may not
73
+ * provide.
26
74
  *
27
75
  * A candidate is covered only when the set holds EVERY one of its keys. One
28
76
  * match is not coverage: a scenario exercising two changed endpoints would lose
@@ -44,8 +92,8 @@ function partitionByExternalCoverage(ranked, externalCoverage) {
44
92
  uncovered.push(item);
45
93
  continue;
46
94
  }
47
- if (item.scenario.category === "bug_caught" || isAttackSurfaceSecurityBoundary(item.scenario)) {
48
- logger.info(`External dedup: preserving "${item.scenario.scenarioName}" (${keys.join(", ")}) — protected bug/attack-surface scenario requires semantic flaw coverage`);
95
+ if (isFlawTargetingCategory(item.scenario.category) || isAttackSurfaceSecurityBoundary(item.scenario)) {
96
+ logger.info(`External dedup: preserving "${item.scenario.scenarioName}" (${keys.join(", ")}) — protected bug/requirement-conflict/attack-surface scenario requires semantic flaw coverage`);
49
97
  uncovered.push(item);
50
98
  continue;
51
99
  }
@@ -62,36 +110,27 @@ function partitionByExternalCoverage(ranked, externalCoverage) {
62
110
  * With `pick = roundRobinByType` this reproduces the pre-refactor selection in
63
111
  * diffExecutionPlan.ts exactly.
64
112
  */
65
- export function runBudget(ranked, ctx, pick) {
113
+ export function runBudget(ranked, rawCtx, pick) {
114
+ // SKYR-4292: maxTotal is the budget; maxGenerate is how much of it to generate.
115
+ // Every producer clamps upstream (getTestbotPrompt, computeScoredCandidates,
116
+ // buildScopeAssessmentSection), but a state file is the tool boundary and can
117
+ // carry maxGenerate > maxTotal — the UI-only branch then reserved maxGenerate
118
+ // slots and planned more items than the total. Clamp once here so every
119
+ // budgeter agrees with the prompt. It must stay ABOVE generateFloors(ctx):
120
+ // the floors are computed from the clamped budget, and moving the clamp
121
+ // below them would let the floors sum past maxTotal again (review on #835).
122
+ const ctx = { ...rawCtx, maxGenerate: Math.min(rawCtx.maxGenerate, rawCtx.maxTotal) };
66
123
  const dropped = [];
67
- const backend = backendGenerateCount(ctx);
68
- const uiSlots = reservedUISlots(ctx);
124
+ const floors = generateFloors(ctx);
69
125
  const { uncovered, covered } = partitionByExternalCoverage(ranked, ctx.externalCoverage);
70
126
  const slotOrdered = prioritizeAttackSurfaceBundles(uncovered);
71
- // When UI slots are reserved, keep UI candidates out of the backend pick so the
72
- // reserved slot can always be filled below. Otherwise a high-ranked (e.g.
73
- // CRITICAL) UI candidate could be consumed by the backend pick on a mixed PR,
74
- // leaving the UI-promotion loop with nothing to promote and GENERATE short.
75
- const backendSource = uiSlots > 0
76
- ? slotOrdered.filter((item) => inferScenarioType(item.scenario) !== TestType.UI)
77
- : slotOrdered;
78
- const backendGenerate = pick(backendSource, Math.min(backend, backendSource.length));
79
- // Fill the reserved UI slots the `pick` step leaves empty: the backend count
80
- // is 0 on a UI-only PR (and maxGenerate-1 on a mixed PR), so UI candidates are
81
- // never chosen above even though reservedUISlots budgets for them. Promote the
82
- // top-ranked UI candidates not already chosen, up to the reserved count, so
83
- // GENERATE is complete instead of an empty list plus a dropped count.
84
- const chosen = new Set(backendGenerate);
85
- const uiGenerate = [];
86
- for (const item of slotOrdered) {
87
- if (uiGenerate.length >= uiSlots)
88
- break;
89
- if (chosen.has(item) || inferScenarioType(item.scenario) !== TestType.UI)
90
- continue;
91
- uiGenerate.push(item);
92
- chosen.add(item);
93
- }
94
- const generate = [...backendGenerate, ...uiGenerate];
127
+ const isUICandidate = (item) => inferScenarioType(item.scenario) === TestType.UI;
128
+ // ONE pick over the whole pool the shape the backend pick always had — so
129
+ // `pick` decides protected-first order, per-type coverage and bundle adjacency
130
+ // exactly once. `applyFloors` then corrects only the UI/backend mix.
131
+ const budget = Number.isFinite(ctx.maxGenerate) ? Math.max(0, Math.floor(ctx.maxGenerate)) : 0;
132
+ const picked = pick(slotOrdered, Math.min(budget, slotOrdered.length));
133
+ const generate = applyFloors(picked, slotOrdered, floors, isUICandidate);
95
134
  // SKYR-4024. A covered candidate is one an existing test already reaches, so
96
135
  // generating a second test for it is wrong — maintenance updates the existing
97
136
  // one. But dropping it outright removed it from the RECOMMENDATIONS too, and an
@@ -100,24 +139,50 @@ export function runBudget(ranked, ctx, pick) {
100
139
  // one UI candidate fills the reserved slot while every covered backend
101
140
  // candidate would otherwise vanish.
102
141
  //
103
- // Two conditions keep the reserve shut where recommending nothing is right.
104
- // Backend slots must exist, so a UI-only PR is left alone. And the PR must not
105
- // touch a test file of its own: coverage is read from the working tree, and a
106
- // test file without the Skyramp marker counts as external, so a PR that adds
107
- // its own tests would have that coverage used as grounds to recommend
108
- // duplicates of it.
109
- const spendReserve = backendGenerate.length === 0 && backend > 0 && covered.length > 0 && !ctx.diffChangesTestFiles;
142
+ // Three conditions keep the reserve shut where recommending nothing is right.
143
+ // A UI-only PR is left alone. A zero budget is an explicit abstention, so it
144
+ // must not be talked out of recommending nothing. And the PR must not touch a
145
+ // test file of its own: coverage is read from the working tree, and a test
146
+ // file without the Skyramp marker counts as external, so a PR that adds its
147
+ // own tests would have that coverage used as grounds to recommend duplicates
148
+ // of it.
149
+ //
150
+ // One pick over the whole pool leaves no "backend half" to count, so the
151
+ // emptiness test reproduces what that half used to mean per class. On a mixed
152
+ // PR the UI slot must not read as backend coverage, or a covered backend
153
+ // candidate vanishes behind it. On a backend-only PR the pick always drew from
154
+ // the whole pool, so a non-empty GENERATE closed the reserve even when every
155
+ // item was UI — keep that, or an all-UI pool opens a reserve it never opened.
156
+ const backendChosen = generate.filter((item) => !isUICandidate(item));
157
+ const backendHalfEmpty = ctx.hasFrontendChanges
158
+ ? backendChosen.length === 0
159
+ : generate.length === 0;
160
+ // One per-class behaviour DID change here, deliberately. On a mixed PR at a
161
+ // budget of 1 the old gate also required `backendGenerateCount > 0`, which is
162
+ // 0 for that class, so a covered backend candidate was dropped outright. The
163
+ // reserve exists because dropping removes a candidate from the
164
+ // RECOMMENDATIONS too (SKYR-4024), and a budget of 1 is the case where that
165
+ // costs most — there is no second slot to find it later. It is now
166
+ // recommended instead of dropped. `reserveOpensForMixedPRAtBudgetOne` in
167
+ // shared.test.ts pins it, so a future change has to mean it.
168
+ const spendReserve = backendHalfEmpty &&
169
+ !ctx.isUIOnlyPR &&
170
+ budget > 0 &&
171
+ covered.length > 0 &&
172
+ !ctx.diffChangesTestFiles;
110
173
  if (spendReserve) {
111
174
  logger.info(`External dedup: GENERATE empty after dedup — recommending ${covered.length} held-back candidate(s) as ADDITIONAL rather than approving an empty plan`);
112
175
  }
113
176
  else if (covered.length > 0) {
114
177
  // SKYR-4214. The reserve stayed shut, so these really are dropped — say so,
115
178
  // with the reason, instead of leaving the agent an unexplained short list.
116
- const reason = backendGenerate.length > 0
117
- ? `the backend half of GENERATE is filled (${backendGenerate.length})`
118
- : backend === 0
119
- ? "no backend slots (UI-only PR)"
120
- : "the PR changes test files of its own";
179
+ const reason = !backendHalfEmpty
180
+ ? `the backend half of GENERATE is filled (${backendChosen.length || generate.length})`
181
+ : ctx.isUIOnlyPR
182
+ ? "a UI-only PR keeps its slots for UI"
183
+ : budget === 0
184
+ ? "the budget is zero"
185
+ : "the PR changes test files of its own";
121
186
  logger.info(`External dedup: dropping ${covered.length} covered candidate(s) — reserve shut because ${reason}`);
122
187
  for (const { item, keys } of covered) {
123
188
  dropped.push({
@@ -142,6 +207,7 @@ export function runBudget(ranked, ctx, pick) {
142
207
  const additionalSource = spendReserve
143
208
  ? [...slotOrdered, ...prioritizeAttackSurfaceBundles(covered.map((c) => c.item))]
144
209
  : slotOrdered;
210
+ const chosen = new Set(generate);
145
211
  const notChosen = additionalSource.filter((it) => !chosen.has(it));
146
212
  const remainingBudget = Math.max(0, ctx.maxTotal - generate.length);
147
213
  const generatedCoverage = new Set(generate.flatMap((item) => scenarioCoverageKeys(item.scenario)));
@@ -149,6 +215,18 @@ export function runBudget(ranked, ctx, pick) {
149
215
  const keys = scenarioCoverageKeys(item.scenario);
150
216
  if (keys.length === 0 || !keys.every((key) => generatedCoverage.has(key)))
151
217
  return true;
218
+ // Same exemption the EXTERNAL dedup above already makes, for the same
219
+ // reason: a flaw-targeting scenario (a caught bug, or a requirement the code
220
+ // contradicts) or an attack-surface boundary asserts a specific defect, and
221
+ // sharing an endpoint with a GENERATE item is not evidence that the defect is
222
+ // covered. Without it a PR with two defects in one handler had its second one
223
+ // deleted here — the first took a GENERATE slot, and the key is method +
224
+ // resource + test type + interaction + status, which two tests on one
225
+ // endpoint share.
226
+ if (isFlawTargetingCategory(item.scenario.category) || isAttackSurfaceSecurityBoundary(item.scenario)) {
227
+ logger.info(`GENERATE dedup: preserving "${item.scenario.scenarioName}" (${keys.join(", ")}) — protected bug/requirement-conflict/attack-surface scenario requires semantic flaw coverage`);
228
+ return true;
229
+ }
152
230
  dropped.push({
153
231
  candidateId: item.candidateId,
154
232
  reason: `covered by GENERATE (${keys.join(", ")})`,
@@ -164,5 +242,5 @@ export function runBudget(ranked, ctx, pick) {
164
242
  }
165
243
  // Budgeting itself produces no demotions; the register-plan selection stage
166
244
  // (planRanker.selectPlan) fills this channel from discriminator verification.
167
- return { generate, additional, reservedUISlots: uiSlots, demotions: [], dropped };
245
+ return { generate, additional, reservedUISlots: floors.ui, demotions: [], dropped };
168
246
  }
@@ -4,8 +4,10 @@ import { ScenarioCategory } from "../types/TestRecommendation.js";
4
4
  export interface RankOptions {
5
5
  /**
6
6
  * Categories that take the top carve-out tier ahead of everything else.
7
- * Defaults to the `CATEGORY_PRIORITY === "CRITICAL"` categories (bug_caught only —
8
- * new_endpoint is MEDIUM, not carved out). Exposed so phase 2 can tune the carve-out
7
+ * Defaults to the `CATEGORY_PRIORITY === "CRITICAL"` categories (bug_caught and
8
+ * requirement_conflict — new_endpoint is MEDIUM, not carved out). The two CRITICAL
9
+ * categories are carved out independently, so a requirement conflict never competes
10
+ * with a code-review bug for one slot. Exposed so phase 2 can tune the carve-out
9
11
  * WITHOUT reintroducing the agent's priority tag as a ranking input.
10
12
  */
11
13
  carveOutCategories?: ScenarioCategory[];
@@ -32,7 +34,7 @@ export interface SelectPlanContext extends BudgetContext {
32
34
  * independent of input order (the final tiebreak is the stable `candidateId`).
33
35
  *
34
36
  * Ordering (highest first):
35
- * 1. Carve-out — CRITICAL-category scenarios (bug_caught), preserving the
37
+ * 1. Carve-out — CRITICAL-category scenarios (bug_caught, requirement_conflict), preserving the
36
38
  * protected-first convention of `roundRobinByType` /
37
39
  * `prioritizeAttackSurfaceBundles`.
38
40
  * 2. Verified discriminators — candidates whose declared discriminator survived
@@ -14,7 +14,7 @@ const DEFAULT_CARVE_OUT_CATEGORIES = Object.keys(CATEGORY_PRIORITY).filter((cate
14
14
  * independent of input order (the final tiebreak is the stable `candidateId`).
15
15
  *
16
16
  * Ordering (highest first):
17
- * 1. Carve-out — CRITICAL-category scenarios (bug_caught), preserving the
17
+ * 1. Carve-out — CRITICAL-category scenarios (bug_caught, requirement_conflict), preserving the
18
18
  * protected-first convention of `roundRobinByType` /
19
19
  * `prioritizeAttackSurfaceBundles`.
20
20
  * 2. Verified discriminators — candidates whose declared discriminator survived
@@ -13,6 +13,7 @@ import { toolError, testFileMatches } from "../utils/utils.js";
13
13
  import { matchesApprovedPlan } from "../utils/planMatchKeys.js";
14
14
  import { isTestbotEnabled } from "../utils/featureFlags.js";
15
15
  import { findInvalidSourceCitations, findUnchangedFileClaims, listChangedFiles, listChangedFilesAcross, listChangedFilesAbs, } from "../utils/reportVerification.js";
16
+ import { isPlanOnlyMode } from "../utils/planOnlyMode.js";
16
17
  import { getReportLanguage, isEnforcedReportLanguage, findLanguageViolations, findLanguageNearMisses, reportLanguageDisplayName, } from "../utils/reportLanguage.js";
17
18
  import { canonicalTestPath, findAssertionRecordByFileName, rederiveAssertionOutcome, } from "./code-refactor/assertion-state.js";
18
19
  import { rederiveReuseOutcome, reuseChainSkipped, samePath, } from "./code-refactor/reuse-state.js";
@@ -343,7 +344,8 @@ const issueFoundSchema = z
343
344
  .optional()
344
345
  .describe("Issue severity. critical = feature broken/unusable (e.g. page doesn't load, data corruption). " +
345
346
  "high = incorrect behavior (e.g. wrong calculation, stale data returned). " +
346
- "medium = minor functional gap. low = cosmetic or informational."),
347
+ "medium = minor functional gap. low = cosmetic or informational. " +
348
+ "Floor: a requirement conflict — the PR title/description (or a requirements file it references) states a requirement the implemented behavior contradicts — is 'high' or 'critical', never 'medium' or below."),
347
349
  category: z
348
350
  .nativeEnum(IssueFoundCategory)
349
351
  .describe("Issue classification. bug = a product/code defect, e.g. found by a test or in the diff. " +
@@ -1109,6 +1111,9 @@ export function registerSubmitReportTool(server) {
1109
1111
  newTests: dedupedNewTests,
1110
1112
  verdicts: stateData.maintenanceVerdicts ?? [],
1111
1113
  primaryRepository: fullState?.metadata?.repository,
1114
+ // SKYR-4250: captured at prompt-render time, since planOnly is a
1115
+ // prompt-only argument (mirrors the SKYR-4185 language capture).
1116
+ planOnly: isPlanOnlyMode(),
1112
1117
  });
1113
1118
  if (unbacked.length > 0) {
1114
1119
  // Offer the attribution-correction path explicitly and show what DID change:
@@ -6,7 +6,7 @@ import { ChangedRoute } from "../../utils/changedRoutes.js";
6
6
  declare const registerCandidateSchema: z.ZodObject<{
7
7
  scenarioName: z.ZodString;
8
8
  description: z.ZodString;
9
- category: z.ZodEnum<["new_endpoint", "bug_caught", "business_rule", "security_boundary", "data_integrity", "breaking_change", "auth", "error_handling", "workflow", "data_validation", "crud"]>;
9
+ category: z.ZodEnum<["new_endpoint", "bug_caught", "requirement_conflict", "business_rule", "security_boundary", "data_integrity", "breaking_change", "auth", "error_handling", "workflow", "data_validation", "crud"]>;
10
10
  priority: z.ZodEnum<["high", "medium", "low"]>;
11
11
  testType: z.ZodEffects<z.ZodNativeEnum<typeof TestType>, TestType, TestType>;
12
12
  steps: z.ZodArray<z.ZodObject<{
@@ -124,7 +124,7 @@ declare const registerCandidateSchema: z.ZodObject<{
124
124
  priority: "high" | "medium" | "low";
125
125
  testType: TestType;
126
126
  scenarioName: string;
127
- category: "new_endpoint" | "bug_caught" | "business_rule" | "security_boundary" | "data_integrity" | "breaking_change" | "auth" | "error_handling" | "workflow" | "data_validation" | "crud";
127
+ category: "new_endpoint" | "bug_caught" | "requirement_conflict" | "business_rule" | "security_boundary" | "data_integrity" | "breaking_change" | "auth" | "error_handling" | "workflow" | "data_validation" | "crud";
128
128
  steps: {
129
129
  path: string;
130
130
  method: HttpMethod;
@@ -160,7 +160,7 @@ declare const registerCandidateSchema: z.ZodObject<{
160
160
  priority: "high" | "medium" | "low";
161
161
  testType: TestType;
162
162
  scenarioName: string;
163
- category: "new_endpoint" | "bug_caught" | "business_rule" | "security_boundary" | "data_integrity" | "breaking_change" | "auth" | "error_handling" | "workflow" | "data_validation" | "crud";
163
+ category: "new_endpoint" | "bug_caught" | "requirement_conflict" | "business_rule" | "security_boundary" | "data_integrity" | "breaking_change" | "auth" | "error_handling" | "workflow" | "data_validation" | "crud";
164
164
  steps: {
165
165
  path: string;
166
166
  method: HttpMethod;