@sedum-dev/core 0.1.0-alpha.21 → 0.1.0-alpha.22

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.
package/dist/index.d.ts CHANGED
@@ -2061,6 +2061,8 @@ interface RelevanceProvider {
2061
2061
  readonly calls: readonly ProviderCall[];
2062
2062
  /** Max over complete diff chunks, not a calibrated whole-PR probability. */
2063
2063
  readonly chunkCount?: number;
2064
+ /** Indexes of tests too large to score; the caller runs them. */
2065
+ readonly oversized?: readonly number[];
2064
2066
  }>;
2065
2067
  }
2066
2068
  interface ResolverDecision {
@@ -2590,11 +2592,17 @@ declare function buildRelevanceBatches<Request>(diff: string, tests: readonly Re
2590
2592
  pair: number;
2591
2593
  batch: number;
2592
2594
  questions: number;
2595
+ /** Pair bytes a test must leave for the diff, its metadata and markers. */
2596
+ minDiff: number;
2593
2597
  }): {
2594
- request: Request;
2595
- indexes: number[];
2596
- chunkIndex: number;
2597
- }[];
2598
+ batches: {
2599
+ request: Request;
2600
+ indexes: number[];
2601
+ chunkIndex: number;
2602
+ }[];
2603
+ /** Tests too large to score; callers run them rather than truncate them. */
2604
+ oversized: number[];
2605
+ };
2598
2606
 
2599
2607
  interface VisionObservation {
2600
2608
  readonly instruction: string;
package/dist/index.js CHANGED
@@ -3626,16 +3626,14 @@ function buildRelevanceBatches(diff, tests, makeRequest, limits) {
3626
3626
  const questions = tests.map(relevanceQuestion);
3627
3627
  const bytes = (request) => Buffer.byteLength(JSON.stringify(request));
3628
3628
  const pair = (text, index) => makeRequest(text, { [`test${index}`]: questions[index] });
3629
- for (const [index, test2] of tests.entries())
3630
- if (bytes(pair("", index)) >= limits.pair)
3631
- throw new ProviderError(
3632
- "invalid-input",
3633
- `Test ${JSON.stringify(test2.file)} exceeds the relevance context budget; input was not truncated. Run the full suite.`
3634
- );
3635
- if (!tests.length || !diff) return [];
3636
- const fits = (text) => tests.every((_, index) => bytes(pair(text, index)) <= limits.pair);
3637
- const diffs = fits(diff) ? [diff] : partition(diff, fits);
3629
+ const oversized = [];
3630
+ const scored = [];
3631
+ for (const index of tests.keys())
3632
+ (bytes(pair("", index)) > limits.pair - limits.minDiff ? oversized : scored).push(index);
3638
3633
  const output = [];
3634
+ if (!scored.length || !diff) return { batches: output, oversized };
3635
+ const fits = (text) => scored.every((index) => bytes(pair(text, index)) <= limits.pair);
3636
+ const diffs = fits(diff) ? [diff] : partition(diff, fits);
3639
3637
  const push = (text, indexes, chunkIndex) => {
3640
3638
  output.push({
3641
3639
  request: makeRequest(
@@ -3655,7 +3653,7 @@ function buildRelevanceBatches(diff, tests, makeRequest, limits) {
3655
3653
  };
3656
3654
  for (const [chunkIndex, text] of diffs.entries()) {
3657
3655
  let indexes = [];
3658
- for (const index of tests.keys()) {
3656
+ for (const index of scored) {
3659
3657
  const candidate = [...indexes, index];
3660
3658
  const request = makeRequest(
3661
3659
  text,
@@ -3668,7 +3666,7 @@ function buildRelevanceBatches(diff, tests, makeRequest, limits) {
3668
3666
  }
3669
3667
  if (indexes.length) push(text, indexes, chunkIndex);
3670
3668
  }
3671
- return output;
3669
+ return { batches: output, oversized };
3672
3670
  }
3673
3671
 
3674
3672
  // src/vision.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedum-dev/core",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.22",
4
4
  "repository": "https://github.com/sedum-dev/sedum",
5
5
  "publishConfig": {
6
6
  "access": "public"