@h-rig/core 0.0.6-alpha.132 → 0.0.6-alpha.134

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.
@@ -0,0 +1,49 @@
1
+ // @bun
2
+ // packages/core/src/taskScore.ts
3
+ var ROLE_WEIGHT = {
4
+ architect: 25,
5
+ extractor: 10
6
+ };
7
+ var CRITICALITY_WEIGHT = {
8
+ core: 20,
9
+ high: 10,
10
+ normal: 0
11
+ };
12
+ function finiteNumber(value, fallback) {
13
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
14
+ }
15
+ function scoreTask(input) {
16
+ const priority = finiteNumber(input.priority, 3);
17
+ const unblockCount = Math.max(0, finiteNumber(input.unblockCount, 0));
18
+ const roleWeight = input.role ? ROLE_WEIGHT[input.role] ?? 0 : 0;
19
+ const criticalityWeight = input.criticality ? CRITICALITY_WEIGHT[input.criticality] ?? 0 : 0;
20
+ const validationWeight = (input.validation ?? []).some((entry) => entry.includes("test-contract") || entry.includes("test-boundary")) ? 8 : 0;
21
+ const queueWeight = finiteNumber(input.queueWeight, 0);
22
+ return unblockCount * 100 + (10 - priority) + roleWeight + criticalityWeight + validationWeight + queueWeight;
23
+ }
24
+ function rankTasks(tasks, scoreInput, idOf) {
25
+ return tasks.map((task) => {
26
+ const input = scoreInput(task);
27
+ return {
28
+ task,
29
+ score: scoreTask(input),
30
+ priority: finiteNumber(input.priority, 3),
31
+ unblockCount: Math.max(0, finiteNumber(input.unblockCount, 0))
32
+ };
33
+ }).toSorted((left, right) => {
34
+ const scoreDelta = right.score - left.score;
35
+ if (scoreDelta !== 0)
36
+ return scoreDelta;
37
+ const unblockDelta = right.unblockCount - left.unblockCount;
38
+ if (unblockDelta !== 0)
39
+ return unblockDelta;
40
+ const priorityDelta = left.priority - right.priority;
41
+ if (priorityDelta !== 0)
42
+ return priorityDelta;
43
+ return idOf(left.task).localeCompare(idOf(right.task));
44
+ });
45
+ }
46
+ export {
47
+ scoreTask,
48
+ rankTasks
49
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/core",
3
- "version": "0.0.6-alpha.132",
3
+ "version": "0.0.6-alpha.134",
4
4
  "type": "module",
5
5
  "description": "Config and plugin composition library for Rig's OMP extension ecosystem; not a product host/runtime.",
6
6
  "license": "UNLICENSED",
@@ -16,6 +16,26 @@
16
16
  "./load-config": {
17
17
  "types": "./dist/src/load-config.d.ts",
18
18
  "import": "./dist/src/load-config.js"
19
+ },
20
+ "./task-graph": {
21
+ "types": "./dist/src/taskGraph.d.ts",
22
+ "import": "./dist/src/taskGraph.js"
23
+ },
24
+ "./stage-resolve": {
25
+ "types": "./dist/src/stageResolve.d.ts",
26
+ "import": "./dist/src/stageResolve.js"
27
+ },
28
+ "./task-score": {
29
+ "types": "./dist/src/taskScore.d.ts",
30
+ "import": "./dist/src/taskScore.js"
31
+ },
32
+ "./dependency-graph": {
33
+ "types": "./dist/src/dependencyGraph.d.ts",
34
+ "import": "./dist/src/dependencyGraph.js"
35
+ },
36
+ "./rollups": {
37
+ "types": "./dist/src/rollups.d.ts",
38
+ "import": "./dist/src/rollups.js"
19
39
  }
20
40
  },
21
41
  "engines": {
@@ -25,7 +45,7 @@
25
45
  "module": "./dist/src/index.js",
26
46
  "types": "./dist/src/index.d.ts",
27
47
  "dependencies": {
28
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.132",
48
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.134",
29
49
  "effect": "4.0.0-beta.78"
30
50
  }
31
51
  }