modestbench 0.7.0 → 0.9.0
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/CHANGELOG.md +25 -0
- package/README.md +37 -4
- package/dist/adapters/types.d.cts +1 -1
- package/dist/adapters/types.d.cts.map +1 -1
- package/dist/adapters/types.d.ts +1 -1
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cli/commands/run.cjs +93 -49
- package/dist/cli/commands/run.cjs.map +1 -1
- package/dist/cli/commands/run.d.cts +1 -0
- package/dist/cli/commands/run.d.cts.map +1 -1
- package/dist/cli/commands/run.d.ts +1 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +95 -51
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/index.cjs +7 -1
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +7 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/{core → config}/benchmark-schema.cjs +1 -1
- package/dist/config/benchmark-schema.cjs.map +1 -0
- package/dist/config/benchmark-schema.d.cts +913 -0
- package/dist/config/benchmark-schema.d.cts.map +1 -0
- package/dist/config/benchmark-schema.d.ts +913 -0
- package/dist/config/benchmark-schema.d.ts.map +1 -0
- package/dist/{core → config}/benchmark-schema.js +1 -1
- package/dist/config/benchmark-schema.js.map +1 -0
- package/dist/config/schema.cjs +188 -105
- package/dist/config/schema.cjs.map +1 -1
- package/dist/config/schema.d.cts +208 -80
- package/dist/config/schema.d.cts.map +1 -1
- package/dist/config/schema.d.ts +208 -80
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +187 -104
- package/dist/config/schema.js.map +1 -1
- package/dist/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/engine.cjs +50 -45
- package/dist/core/engine.cjs.map +1 -1
- package/dist/core/engine.d.cts.map +1 -1
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/engine.js +50 -45
- package/dist/core/engine.js.map +1 -1
- package/dist/core/output-path-resolver.cjs +15 -1
- package/dist/core/output-path-resolver.cjs.map +1 -1
- package/dist/core/output-path-resolver.d.cts +8 -0
- package/dist/core/output-path-resolver.d.cts.map +1 -1
- package/dist/core/output-path-resolver.d.ts +8 -0
- package/dist/core/output-path-resolver.d.ts.map +1 -1
- package/dist/core/output-path-resolver.js +13 -0
- package/dist/core/output-path-resolver.js.map +1 -1
- package/dist/errors/index.cjs +3 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +1 -1
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/reporter.cjs +45 -1
- package/dist/errors/reporter.cjs.map +1 -1
- package/dist/errors/reporter.d.cts +32 -0
- package/dist/errors/reporter.d.cts.map +1 -1
- package/dist/errors/reporter.d.ts +32 -0
- package/dist/errors/reporter.d.ts.map +1 -1
- package/dist/errors/reporter.js +42 -0
- package/dist/errors/reporter.js.map +1 -1
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/reporters/json.cjs +1 -1
- package/dist/reporters/json.cjs.map +1 -1
- package/dist/reporters/json.js +1 -1
- package/dist/reporters/json.js.map +1 -1
- package/dist/schema/modestbench-config.schema.json +94 -87
- package/dist/services/budget-evaluator.cjs +8 -6
- package/dist/services/budget-evaluator.cjs.map +1 -1
- package/dist/services/budget-evaluator.d.cts +2 -2
- package/dist/services/budget-evaluator.d.cts.map +1 -1
- package/dist/services/budget-evaluator.d.ts +2 -2
- package/dist/services/budget-evaluator.d.ts.map +1 -1
- package/dist/services/budget-evaluator.js +8 -6
- package/dist/services/budget-evaluator.js.map +1 -1
- package/dist/services/budget-resolver.cjs +214 -0
- package/dist/services/budget-resolver.cjs.map +1 -0
- package/dist/services/budget-resolver.d.cts +98 -0
- package/dist/services/budget-resolver.d.cts.map +1 -0
- package/dist/services/budget-resolver.d.ts +98 -0
- package/dist/services/budget-resolver.d.ts.map +1 -0
- package/dist/services/budget-resolver.js +203 -0
- package/dist/services/budget-resolver.js.map +1 -0
- package/dist/services/file-loader.cjs +1 -1
- package/dist/services/file-loader.cjs.map +1 -1
- package/dist/services/file-loader.js +1 -1
- package/dist/services/file-loader.js.map +1 -1
- package/dist/services/reporter-loader.cjs +281 -0
- package/dist/services/reporter-loader.cjs.map +1 -0
- package/dist/services/reporter-loader.d.cts +67 -0
- package/dist/services/reporter-loader.d.cts.map +1 -0
- package/dist/services/reporter-loader.d.ts +67 -0
- package/dist/services/reporter-loader.d.ts.map +1 -0
- package/dist/services/reporter-loader.js +241 -0
- package/dist/services/reporter-loader.js.map +1 -0
- package/dist/types/budgets.d.cts +31 -0
- package/dist/types/budgets.d.cts.map +1 -1
- package/dist/types/budgets.d.ts +31 -0
- package/dist/types/budgets.d.ts.map +1 -1
- package/dist/types/core.cjs.map +1 -1
- package/dist/types/core.d.cts +28 -75
- package/dist/types/core.d.cts.map +1 -1
- package/dist/types/core.d.ts +28 -75
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/plugin.cjs +9 -0
- package/dist/types/plugin.cjs.map +1 -0
- package/dist/types/plugin.d.cts +179 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.ts +179 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +8 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/utils/package.cjs +66 -5
- package/dist/utils/package.cjs.map +1 -1
- package/dist/utils/package.d.cts +6 -0
- package/dist/utils/package.d.cts.map +1 -1
- package/dist/utils/package.d.ts +6 -0
- package/dist/utils/package.d.ts.map +1 -1
- package/dist/utils/package.js +31 -1
- package/dist/utils/package.js.map +1 -1
- package/dist/utils/reporter-utils.cjs +90 -0
- package/dist/utils/reporter-utils.cjs.map +1 -0
- package/dist/utils/reporter-utils.d.cts +42 -0
- package/dist/utils/reporter-utils.d.cts.map +1 -0
- package/dist/utils/reporter-utils.d.ts +42 -0
- package/dist/utils/reporter-utils.d.ts.map +1 -0
- package/dist/utils/reporter-utils.js +83 -0
- package/dist/utils/reporter-utils.js.map +1 -0
- package/package.json +20 -9
- package/src/adapters/types.ts +1 -1
- package/src/cli/commands/run.ts +140 -69
- package/src/cli/index.ts +8 -1
- package/src/{core → config}/benchmark-schema.ts +1 -1
- package/src/config/schema.ts +379 -302
- package/src/constants.ts +2 -0
- package/src/core/engine.ts +74 -69
- package/src/core/output-path-resolver.ts +14 -0
- package/src/errors/index.ts +2 -0
- package/src/errors/reporter.ts +55 -0
- package/src/index.ts +19 -1
- package/src/reporters/json.ts +1 -1
- package/src/services/budget-evaluator.ts +13 -9
- package/src/services/budget-resolver.ts +254 -0
- package/src/services/file-loader.ts +1 -1
- package/src/services/reporter-loader.ts +323 -0
- package/src/types/budgets.ts +38 -0
- package/src/types/core.ts +64 -99
- package/src/types/index.ts +3 -0
- package/src/types/plugin.ts +197 -0
- package/src/utils/package.ts +32 -1
- package/src/utils/reporter-utils.ts +85 -0
- package/dist/core/benchmark-schema.cjs.map +0 -1
- package/dist/core/benchmark-schema.d.cts +0 -139
- package/dist/core/benchmark-schema.d.cts.map +0 -1
- package/dist/core/benchmark-schema.d.ts +0 -139
- package/dist/core/benchmark-schema.d.ts.map +0 -1
- package/dist/core/benchmark-schema.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-evaluator.d.ts","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,
|
|
1
|
+
{"version":3,"file":"budget-evaluator.d.ts","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAGnB,aAAa,EAEb,eAAe,EACf,MAAM,EACN,UAAU,EACX,0BAAyB;AAI1B;;;;GAIG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAM3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAYzB;;OAEG;IACH,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAC9C,aAAa;IAsChB;;OAEG;IACH,OAAO,CAAC,YAAY;CAuFrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaselineSummaryData,
|
|
1
|
+
import type { BaselineSummaryData, BudgetSummary, ResolvedBudgets, TaskId, TaskResult } from "../types/core.js";
|
|
2
2
|
/**
|
|
3
3
|
* Service for evaluating performance budgets
|
|
4
4
|
*
|
|
@@ -20,7 +20,7 @@ export declare class BudgetEvaluator {
|
|
|
20
20
|
/**
|
|
21
21
|
* Evaluate budgets for an entire benchmark run
|
|
22
22
|
*/
|
|
23
|
-
evaluateRun(budgets:
|
|
23
|
+
evaluateRun(budgets: ResolvedBudgets, taskResults: Map<TaskId, TaskResult>, baselineData?: Map<TaskId, BaselineSummaryData>): BudgetSummary;
|
|
24
24
|
/**
|
|
25
25
|
* Evaluate budgets for a single task
|
|
26
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-evaluator.d.ts","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,
|
|
1
|
+
{"version":3,"file":"budget-evaluator.d.ts","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAGnB,aAAa,EAEb,eAAe,EACf,MAAM,EACN,UAAU,EACX,yBAAyB;AAI1B;;;;GAIG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAM3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAYzB;;OAEG;IACH,WAAW,CACT,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAC9C,aAAa;IAsChB;;OAEG;IACH,OAAO,CAAC,YAAY;CAuFrB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveBudget } from "./budget-resolver.js";
|
|
1
2
|
/**
|
|
2
3
|
* Service for evaluating performance budgets
|
|
3
4
|
*
|
|
@@ -40,14 +41,15 @@ export class BudgetEvaluator {
|
|
|
40
41
|
*/
|
|
41
42
|
evaluateRun(budgets, taskResults, baselineData) {
|
|
42
43
|
const results = [];
|
|
43
|
-
for (const [taskId,
|
|
44
|
-
const
|
|
45
|
-
// Skip if no
|
|
46
|
-
if (!
|
|
44
|
+
for (const [taskId, taskResult] of taskResults) {
|
|
45
|
+
const budget = resolveBudget(taskId, budgets);
|
|
46
|
+
// Skip if no budget matches this task
|
|
47
|
+
if (!budget) {
|
|
47
48
|
continue;
|
|
48
49
|
}
|
|
49
|
-
// Skip relative
|
|
50
|
-
|
|
50
|
+
// Skip if budget has ONLY relative thresholds and no baseline data
|
|
51
|
+
// (absolute budgets can still be evaluated without baseline)
|
|
52
|
+
if (budget.relative && !budget.absolute && !baselineData) {
|
|
51
53
|
continue;
|
|
52
54
|
}
|
|
53
55
|
const budgetResult = this.evaluateTask(taskId, budget, taskResult, baselineData?.get(taskId));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget-evaluator.js","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"budget-evaluator.js","sourceRoot":"","sources":["../../src/services/budget-evaluator.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,6BAA6B;AAErD;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B;;OAEG;IACK,MAAM,CAAC,YAAY,CAAa,KAAa;QACnD,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE;YACnC,qBAAqB,EAAE,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,gBAAgB,CAAa,KAAa;QACvD,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,UAAU,CAAa,WAAmB;QACvD,IAAI,WAAW,GAAG,KAAK,EAAE,CAAC;YACxB,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACvC,CAAC;aAAM,IAAI,WAAW,GAAG,SAAS,EAAE,CAAC;YACnC,OAAO,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,CAAC;aAAM,IAA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
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Budget resolution service for matching budgets to tasks
|
|
4
|
+
*
|
|
5
|
+
* This module provides pattern-based budget resolution using:
|
|
6
|
+
*
|
|
7
|
+
* - Minimatch glob patterns for file matching
|
|
8
|
+
* - Simple `*` wildcards for suite/task matching
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createBudgetPattern = exports.resolveBudget = exports.mergeBudgets = exports.parseTaskId = exports.calculateSpecificity = exports.matchesSuiteOrTask = exports.matchesFile = exports.isGlobPattern = void 0;
|
|
14
|
+
const minimatch_1 = require("minimatch");
|
|
15
|
+
/**
|
|
16
|
+
* Check if a glob pattern contains wildcards
|
|
17
|
+
*
|
|
18
|
+
* @param pattern - The pattern to check
|
|
19
|
+
* @returns True if the pattern contains glob metacharacters
|
|
20
|
+
*/
|
|
21
|
+
const isGlobPattern = (pattern) => {
|
|
22
|
+
return /[*?[\]]/.test(pattern);
|
|
23
|
+
};
|
|
24
|
+
exports.isGlobPattern = isGlobPattern;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a file path matches a glob pattern
|
|
27
|
+
*
|
|
28
|
+
* @param pattern - Minimatch glob pattern
|
|
29
|
+
* @param filePath - File path to match against
|
|
30
|
+
* @returns True if the pattern matches the file path
|
|
31
|
+
*/
|
|
32
|
+
const matchesFile = (pattern, filePath) => {
|
|
33
|
+
// Exact match fast path
|
|
34
|
+
if (pattern === filePath) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return (0, minimatch_1.minimatch)(filePath, pattern, { matchBase: true });
|
|
38
|
+
};
|
|
39
|
+
exports.matchesFile = matchesFile;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a suite or task name matches a pattern
|
|
42
|
+
*
|
|
43
|
+
* @param pattern - Either an exact name or `*` for wildcard
|
|
44
|
+
* @param value - The value to match against
|
|
45
|
+
* @returns True if the pattern matches the value
|
|
46
|
+
*/
|
|
47
|
+
const matchesSuiteOrTask = (pattern, value) => {
|
|
48
|
+
return pattern === '*' || pattern === value;
|
|
49
|
+
};
|
|
50
|
+
exports.matchesSuiteOrTask = matchesSuiteOrTask;
|
|
51
|
+
/**
|
|
52
|
+
* Calculate specificity score for a budget pattern
|
|
53
|
+
*
|
|
54
|
+
* Higher scores indicate more specific patterns. Scoring:
|
|
55
|
+
*
|
|
56
|
+
* - File: +2 for exact match, +1 for glob with specific parts, +0 for `**\/*`
|
|
57
|
+
* - Suite: +1 for exact match, +0 for `*`
|
|
58
|
+
* - Task: +1 for exact match, +0 for `*`
|
|
59
|
+
*
|
|
60
|
+
* @param pattern - The budget pattern to score
|
|
61
|
+
* @returns Specificity score (0-4)
|
|
62
|
+
*/
|
|
63
|
+
const calculateSpecificity = (pattern) => {
|
|
64
|
+
let score = 0;
|
|
65
|
+
// File specificity
|
|
66
|
+
if (!(0, exports.isGlobPattern)(pattern.filePattern)) {
|
|
67
|
+
// Exact file match
|
|
68
|
+
score += 2;
|
|
69
|
+
}
|
|
70
|
+
else if (pattern.filePattern !== '**/*' && pattern.filePattern !== '*') {
|
|
71
|
+
// Glob with some specificity (e.g., "**/api/**/*.bench.js")
|
|
72
|
+
score += 1;
|
|
73
|
+
}
|
|
74
|
+
// else: fully generic glob like "**/*" gets +0
|
|
75
|
+
// Suite specificity
|
|
76
|
+
if (pattern.suitePattern !== '*') {
|
|
77
|
+
score += 1;
|
|
78
|
+
}
|
|
79
|
+
// Task specificity
|
|
80
|
+
if (pattern.taskPattern !== '*') {
|
|
81
|
+
score += 1;
|
|
82
|
+
}
|
|
83
|
+
return score;
|
|
84
|
+
};
|
|
85
|
+
exports.calculateSpecificity = calculateSpecificity;
|
|
86
|
+
/**
|
|
87
|
+
* Parse a TaskId into its components
|
|
88
|
+
*
|
|
89
|
+
* TaskIds have the format: `{filePath}/{suiteName}/{taskName}` The file path
|
|
90
|
+
* can contain slashes, so we parse from the end.
|
|
91
|
+
*
|
|
92
|
+
* @param taskId - The TaskId to parse
|
|
93
|
+
* @returns Object with file, suite, and task components
|
|
94
|
+
*/
|
|
95
|
+
const parseTaskId = (taskId) => {
|
|
96
|
+
const str = taskId;
|
|
97
|
+
const lastSlash = str.lastIndexOf('/');
|
|
98
|
+
const secondLastSlash = str.lastIndexOf('/', lastSlash - 1);
|
|
99
|
+
return {
|
|
100
|
+
file: str.substring(0, secondLastSlash),
|
|
101
|
+
suite: str.substring(secondLastSlash + 1, lastSlash),
|
|
102
|
+
task: str.substring(lastSlash + 1),
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
exports.parseTaskId = parseTaskId;
|
|
106
|
+
/**
|
|
107
|
+
* Deep merge two budget objects
|
|
108
|
+
*
|
|
109
|
+
* More specific (second) budget values override less specific (first) values.
|
|
110
|
+
* Merges at the absolute/relative level.
|
|
111
|
+
*
|
|
112
|
+
* @param base - Base budget (less specific)
|
|
113
|
+
* @param override - Override budget (more specific)
|
|
114
|
+
* @returns Merged budget
|
|
115
|
+
*/
|
|
116
|
+
const mergeBudgets = (base, override) => {
|
|
117
|
+
return {
|
|
118
|
+
...(base.absolute || override.absolute
|
|
119
|
+
? {
|
|
120
|
+
absolute: {
|
|
121
|
+
...base.absolute,
|
|
122
|
+
...override.absolute,
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
: {}),
|
|
126
|
+
...(base.relative || override.relative
|
|
127
|
+
? {
|
|
128
|
+
relative: {
|
|
129
|
+
...base.relative,
|
|
130
|
+
...override.relative,
|
|
131
|
+
},
|
|
132
|
+
}
|
|
133
|
+
: {}),
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
exports.mergeBudgets = mergeBudgets;
|
|
137
|
+
/**
|
|
138
|
+
* Resolve the appropriate budget for a task
|
|
139
|
+
*
|
|
140
|
+
* Resolution order:
|
|
141
|
+
*
|
|
142
|
+
* 1. Check exact match in `exact` map (highest priority)
|
|
143
|
+
* 2. Find all matching patterns
|
|
144
|
+
* 3. Sort by specificity (ascending)
|
|
145
|
+
* 4. Merge matched budgets (more specific overrides less specific)
|
|
146
|
+
*
|
|
147
|
+
* @param taskId - The task identifier to resolve a budget for
|
|
148
|
+
* @param budgets - The resolved budgets structure
|
|
149
|
+
* @returns The resolved budget, or undefined if no budget matches
|
|
150
|
+
*/
|
|
151
|
+
const resolveBudget = (taskId, budgets) => {
|
|
152
|
+
// Fast path: exact match
|
|
153
|
+
const exactMatch = budgets.exact[taskId];
|
|
154
|
+
if (exactMatch) {
|
|
155
|
+
// Still need to check patterns and merge if there are less-specific matches
|
|
156
|
+
const parsed = (0, exports.parseTaskId)(taskId);
|
|
157
|
+
const matchingPatterns = budgets.patterns.filter((p) => (0, exports.matchesFile)(p.filePattern, parsed.file) &&
|
|
158
|
+
(0, exports.matchesSuiteOrTask)(p.suitePattern, parsed.suite) &&
|
|
159
|
+
(0, exports.matchesSuiteOrTask)(p.taskPattern, parsed.task));
|
|
160
|
+
if (matchingPatterns.length === 0) {
|
|
161
|
+
return exactMatch;
|
|
162
|
+
}
|
|
163
|
+
// Sort by specificity ascending (least specific first, so more specific can override)
|
|
164
|
+
const sorted = [...matchingPatterns].sort((a, b) => a.specificity - b.specificity);
|
|
165
|
+
// Merge all patterns, then apply exact match last
|
|
166
|
+
let merged = sorted[0].budget;
|
|
167
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
168
|
+
merged = (0, exports.mergeBudgets)(merged, sorted[i].budget);
|
|
169
|
+
}
|
|
170
|
+
// Exact match has highest priority
|
|
171
|
+
return (0, exports.mergeBudgets)(merged, exactMatch);
|
|
172
|
+
}
|
|
173
|
+
// Find all matching patterns
|
|
174
|
+
const parsed = (0, exports.parseTaskId)(taskId);
|
|
175
|
+
const matchingPatterns = budgets.patterns.filter((p) => (0, exports.matchesFile)(p.filePattern, parsed.file) &&
|
|
176
|
+
(0, exports.matchesSuiteOrTask)(p.suitePattern, parsed.suite) &&
|
|
177
|
+
(0, exports.matchesSuiteOrTask)(p.taskPattern, parsed.task));
|
|
178
|
+
if (matchingPatterns.length === 0) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
// Sort by specificity ascending (least specific first)
|
|
182
|
+
const sorted = [...matchingPatterns].sort((a, b) => a.specificity - b.specificity);
|
|
183
|
+
// Merge all matches (more specific overrides less specific)
|
|
184
|
+
let merged = sorted[0].budget;
|
|
185
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
186
|
+
merged = (0, exports.mergeBudgets)(merged, sorted[i].budget);
|
|
187
|
+
}
|
|
188
|
+
return merged;
|
|
189
|
+
};
|
|
190
|
+
exports.resolveBudget = resolveBudget;
|
|
191
|
+
/**
|
|
192
|
+
* Create a BudgetPattern from its components
|
|
193
|
+
*
|
|
194
|
+
* @param filePattern - Glob pattern for file matching
|
|
195
|
+
* @param suitePattern - Suite name or `*` for wildcard
|
|
196
|
+
* @param taskPattern - Task name or `*` for wildcard
|
|
197
|
+
* @param budget - The budget to apply
|
|
198
|
+
* @returns A BudgetPattern with computed specificity
|
|
199
|
+
*/
|
|
200
|
+
const createBudgetPattern = (filePattern, suitePattern, taskPattern, budget) => {
|
|
201
|
+
return {
|
|
202
|
+
budget,
|
|
203
|
+
filePattern,
|
|
204
|
+
specificity: (0, exports.calculateSpecificity)({
|
|
205
|
+
filePattern,
|
|
206
|
+
suitePattern,
|
|
207
|
+
taskPattern,
|
|
208
|
+
}),
|
|
209
|
+
suitePattern,
|
|
210
|
+
taskPattern,
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
exports.createBudgetPattern = createBudgetPattern;
|
|
214
|
+
//# sourceMappingURL=budget-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-resolver.js","sourceRoot":"","sources":["../../src/services/budget-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,yCAAsC;AAStC;;;;;GAKG;AACI,MAAM,aAAa,GAAG,CAAC,OAAe,EAAW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AAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget resolution service for matching budgets to tasks
|
|
3
|
+
*
|
|
4
|
+
* This module provides pattern-based budget resolution using:
|
|
5
|
+
*
|
|
6
|
+
* - Minimatch glob patterns for file matching
|
|
7
|
+
* - Simple `*` wildcards for suite/task matching
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { Budget, BudgetPattern, ResolvedBudgets, TaskId } from "../types/core.cjs";
|
|
12
|
+
/**
|
|
13
|
+
* Check if a glob pattern contains wildcards
|
|
14
|
+
*
|
|
15
|
+
* @param pattern - The pattern to check
|
|
16
|
+
* @returns True if the pattern contains glob metacharacters
|
|
17
|
+
*/
|
|
18
|
+
export declare const isGlobPattern: (pattern: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a file path matches a glob pattern
|
|
21
|
+
*
|
|
22
|
+
* @param pattern - Minimatch glob pattern
|
|
23
|
+
* @param filePath - File path to match against
|
|
24
|
+
* @returns True if the pattern matches the file path
|
|
25
|
+
*/
|
|
26
|
+
export declare const matchesFile: (pattern: string, filePath: string) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a suite or task name matches a pattern
|
|
29
|
+
*
|
|
30
|
+
* @param pattern - Either an exact name or `*` for wildcard
|
|
31
|
+
* @param value - The value to match against
|
|
32
|
+
* @returns True if the pattern matches the value
|
|
33
|
+
*/
|
|
34
|
+
export declare const matchesSuiteOrTask: (pattern: string, value: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate specificity score for a budget pattern
|
|
37
|
+
*
|
|
38
|
+
* Higher scores indicate more specific patterns. Scoring:
|
|
39
|
+
*
|
|
40
|
+
* - File: +2 for exact match, +1 for glob with specific parts, +0 for `**\/*`
|
|
41
|
+
* - Suite: +1 for exact match, +0 for `*`
|
|
42
|
+
* - Task: +1 for exact match, +0 for `*`
|
|
43
|
+
*
|
|
44
|
+
* @param pattern - The budget pattern to score
|
|
45
|
+
* @returns Specificity score (0-4)
|
|
46
|
+
*/
|
|
47
|
+
export declare const calculateSpecificity: (pattern: Pick<BudgetPattern, "filePattern" | "suitePattern" | "taskPattern">) => number;
|
|
48
|
+
/**
|
|
49
|
+
* Parse a TaskId into its components
|
|
50
|
+
*
|
|
51
|
+
* TaskIds have the format: `{filePath}/{suiteName}/{taskName}` The file path
|
|
52
|
+
* can contain slashes, so we parse from the end.
|
|
53
|
+
*
|
|
54
|
+
* @param taskId - The TaskId to parse
|
|
55
|
+
* @returns Object with file, suite, and task components
|
|
56
|
+
*/
|
|
57
|
+
export declare const parseTaskId: (taskId: TaskId) => {
|
|
58
|
+
file: string;
|
|
59
|
+
suite: string;
|
|
60
|
+
task: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Deep merge two budget objects
|
|
64
|
+
*
|
|
65
|
+
* More specific (second) budget values override less specific (first) values.
|
|
66
|
+
* Merges at the absolute/relative level.
|
|
67
|
+
*
|
|
68
|
+
* @param base - Base budget (less specific)
|
|
69
|
+
* @param override - Override budget (more specific)
|
|
70
|
+
* @returns Merged budget
|
|
71
|
+
*/
|
|
72
|
+
export declare const mergeBudgets: (base: Budget, override: Budget) => Budget;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the appropriate budget for a task
|
|
75
|
+
*
|
|
76
|
+
* Resolution order:
|
|
77
|
+
*
|
|
78
|
+
* 1. Check exact match in `exact` map (highest priority)
|
|
79
|
+
* 2. Find all matching patterns
|
|
80
|
+
* 3. Sort by specificity (ascending)
|
|
81
|
+
* 4. Merge matched budgets (more specific overrides less specific)
|
|
82
|
+
*
|
|
83
|
+
* @param taskId - The task identifier to resolve a budget for
|
|
84
|
+
* @param budgets - The resolved budgets structure
|
|
85
|
+
* @returns The resolved budget, or undefined if no budget matches
|
|
86
|
+
*/
|
|
87
|
+
export declare const resolveBudget: (taskId: TaskId, budgets: ResolvedBudgets) => Budget | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Create a BudgetPattern from its components
|
|
90
|
+
*
|
|
91
|
+
* @param filePattern - Glob pattern for file matching
|
|
92
|
+
* @param suitePattern - Suite name or `*` for wildcard
|
|
93
|
+
* @param taskPattern - Task name or `*` for wildcard
|
|
94
|
+
* @param budget - The budget to apply
|
|
95
|
+
* @returns A BudgetPattern with computed specificity
|
|
96
|
+
*/
|
|
97
|
+
export declare const createBudgetPattern: (filePattern: string, suitePattern: string, taskPattern: string, budget: Budget) => BudgetPattern;
|
|
98
|
+
//# sourceMappingURL=budget-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-resolver.d.ts","sourceRoot":"","sources":["../../src/services/budget-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,eAAe,EACf,MAAM,EACP,0BAAyB;AAE1B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,OAE/C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,OAO/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,OAEnE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC,KAC3E,MAwBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,KACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAU7C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,KAAG,MAmB7D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,SAAS,eAAe,KACvB,MAAM,GAAG,SAyDX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,EACnB,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,QAAQ,MAAM,KACb,aAYF,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget resolution service for matching budgets to tasks
|
|
3
|
+
*
|
|
4
|
+
* This module provides pattern-based budget resolution using:
|
|
5
|
+
*
|
|
6
|
+
* - Minimatch glob patterns for file matching
|
|
7
|
+
* - Simple `*` wildcards for suite/task matching
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { Budget, BudgetPattern, ResolvedBudgets, TaskId } from "../types/core.js";
|
|
12
|
+
/**
|
|
13
|
+
* Check if a glob pattern contains wildcards
|
|
14
|
+
*
|
|
15
|
+
* @param pattern - The pattern to check
|
|
16
|
+
* @returns True if the pattern contains glob metacharacters
|
|
17
|
+
*/
|
|
18
|
+
export declare const isGlobPattern: (pattern: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a file path matches a glob pattern
|
|
21
|
+
*
|
|
22
|
+
* @param pattern - Minimatch glob pattern
|
|
23
|
+
* @param filePath - File path to match against
|
|
24
|
+
* @returns True if the pattern matches the file path
|
|
25
|
+
*/
|
|
26
|
+
export declare const matchesFile: (pattern: string, filePath: string) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a suite or task name matches a pattern
|
|
29
|
+
*
|
|
30
|
+
* @param pattern - Either an exact name or `*` for wildcard
|
|
31
|
+
* @param value - The value to match against
|
|
32
|
+
* @returns True if the pattern matches the value
|
|
33
|
+
*/
|
|
34
|
+
export declare const matchesSuiteOrTask: (pattern: string, value: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate specificity score for a budget pattern
|
|
37
|
+
*
|
|
38
|
+
* Higher scores indicate more specific patterns. Scoring:
|
|
39
|
+
*
|
|
40
|
+
* - File: +2 for exact match, +1 for glob with specific parts, +0 for `**\/*`
|
|
41
|
+
* - Suite: +1 for exact match, +0 for `*`
|
|
42
|
+
* - Task: +1 for exact match, +0 for `*`
|
|
43
|
+
*
|
|
44
|
+
* @param pattern - The budget pattern to score
|
|
45
|
+
* @returns Specificity score (0-4)
|
|
46
|
+
*/
|
|
47
|
+
export declare const calculateSpecificity: (pattern: Pick<BudgetPattern, "filePattern" | "suitePattern" | "taskPattern">) => number;
|
|
48
|
+
/**
|
|
49
|
+
* Parse a TaskId into its components
|
|
50
|
+
*
|
|
51
|
+
* TaskIds have the format: `{filePath}/{suiteName}/{taskName}` The file path
|
|
52
|
+
* can contain slashes, so we parse from the end.
|
|
53
|
+
*
|
|
54
|
+
* @param taskId - The TaskId to parse
|
|
55
|
+
* @returns Object with file, suite, and task components
|
|
56
|
+
*/
|
|
57
|
+
export declare const parseTaskId: (taskId: TaskId) => {
|
|
58
|
+
file: string;
|
|
59
|
+
suite: string;
|
|
60
|
+
task: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Deep merge two budget objects
|
|
64
|
+
*
|
|
65
|
+
* More specific (second) budget values override less specific (first) values.
|
|
66
|
+
* Merges at the absolute/relative level.
|
|
67
|
+
*
|
|
68
|
+
* @param base - Base budget (less specific)
|
|
69
|
+
* @param override - Override budget (more specific)
|
|
70
|
+
* @returns Merged budget
|
|
71
|
+
*/
|
|
72
|
+
export declare const mergeBudgets: (base: Budget, override: Budget) => Budget;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the appropriate budget for a task
|
|
75
|
+
*
|
|
76
|
+
* Resolution order:
|
|
77
|
+
*
|
|
78
|
+
* 1. Check exact match in `exact` map (highest priority)
|
|
79
|
+
* 2. Find all matching patterns
|
|
80
|
+
* 3. Sort by specificity (ascending)
|
|
81
|
+
* 4. Merge matched budgets (more specific overrides less specific)
|
|
82
|
+
*
|
|
83
|
+
* @param taskId - The task identifier to resolve a budget for
|
|
84
|
+
* @param budgets - The resolved budgets structure
|
|
85
|
+
* @returns The resolved budget, or undefined if no budget matches
|
|
86
|
+
*/
|
|
87
|
+
export declare const resolveBudget: (taskId: TaskId, budgets: ResolvedBudgets) => Budget | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Create a BudgetPattern from its components
|
|
90
|
+
*
|
|
91
|
+
* @param filePattern - Glob pattern for file matching
|
|
92
|
+
* @param suitePattern - Suite name or `*` for wildcard
|
|
93
|
+
* @param taskPattern - Task name or `*` for wildcard
|
|
94
|
+
* @param budget - The budget to apply
|
|
95
|
+
* @returns A BudgetPattern with computed specificity
|
|
96
|
+
*/
|
|
97
|
+
export declare const createBudgetPattern: (filePattern: string, suitePattern: string, taskPattern: string, budget: Budget) => BudgetPattern;
|
|
98
|
+
//# sourceMappingURL=budget-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget-resolver.d.ts","sourceRoot":"","sources":["../../src/services/budget-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,eAAe,EACf,MAAM,EACP,yBAAyB;AAE1B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,OAE/C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,OAO/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,OAEnE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC,KAC3E,MAwBF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,KACb;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAU7C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,UAAU,MAAM,KAAG,MAmB7D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,SAAS,eAAe,KACvB,MAAM,GAAG,SAyDX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,EACnB,cAAc,MAAM,EACpB,aAAa,MAAM,EACnB,QAAQ,MAAM,KACb,aAYF,CAAC"}
|