@adrkit/evaluator 0.1.0 → 0.2.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/dist/index.js +2 -7
- package/package.json +2 -2
- package/src/rules/no-orphan-refs.ts +2 -12
package/dist/index.js
CHANGED
|
@@ -505,12 +505,7 @@ function evaluateSupersessionConsistent(ctx) {
|
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
// src/rules/no-orphan-refs.ts
|
|
508
|
-
|
|
509
|
-
const idx = ref.indexOf(":");
|
|
510
|
-
if (idx <= 0)
|
|
511
|
-
return { id: ref };
|
|
512
|
-
return { log: ref.slice(0, idx), id: ref.slice(idx + 1) };
|
|
513
|
-
}
|
|
508
|
+
import { parseAdrRef } from "@adrkit/core";
|
|
514
509
|
function evaluateNoOrphanRefs(ctx) {
|
|
515
510
|
const resolutionLog = ctx.input.resolutionLog;
|
|
516
511
|
const localIds = new Set;
|
|
@@ -533,7 +528,7 @@ function evaluateNoOrphanRefs(ctx) {
|
|
|
533
528
|
}
|
|
534
529
|
const subs = [];
|
|
535
530
|
function classify(ref) {
|
|
536
|
-
const parsed =
|
|
531
|
+
const parsed = parseAdrRef(ref);
|
|
537
532
|
if (parsed.log === undefined || parsed.log === resolutionLog) {
|
|
538
533
|
return localIds.has(parsed.id) ? "resolved" : "dangling";
|
|
539
534
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adrkit/evaluator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Deterministic, model-free ADR proposal evaluation and routing for adrkit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit --customConditions bun --project ../../tsconfig.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@adrkit/core": "0.
|
|
43
|
+
"@adrkit/core": "0.2.0",
|
|
44
44
|
"jsonpath-rfc9535": "1.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -9,23 +9,13 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { Adr } from '@adrkit/core';
|
|
12
|
+
import { parseAdrRef } from '@adrkit/core';
|
|
12
13
|
import { aggregate, passResult, type SubResult } from './kernel.ts';
|
|
13
14
|
import type { RuleContext } from './context.ts';
|
|
14
15
|
import type { ReasonCode, RuleFinding, RuleResult } from '../types.ts';
|
|
15
16
|
|
|
16
17
|
type RefField = 'supersedes' | 'relatesTo';
|
|
17
18
|
|
|
18
|
-
interface Parsed {
|
|
19
|
-
readonly log?: string;
|
|
20
|
-
readonly id: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function parseRef(ref: string): Parsed {
|
|
24
|
-
const idx = ref.indexOf(':');
|
|
25
|
-
if (idx <= 0) return { id: ref };
|
|
26
|
-
return { log: ref.slice(0, idx), id: ref.slice(idx + 1) };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
19
|
export function evaluateNoOrphanRefs(ctx: RuleContext): RuleResult {
|
|
30
20
|
const resolutionLog = ctx.input.resolutionLog;
|
|
31
21
|
|
|
@@ -50,7 +40,7 @@ export function evaluateNoOrphanRefs(ctx: RuleContext): RuleResult {
|
|
|
50
40
|
const subs: SubResult[] = [];
|
|
51
41
|
|
|
52
42
|
function classify(ref: string): 'resolved' | 'dangling' | 'federated-absent' {
|
|
53
|
-
const parsed =
|
|
43
|
+
const parsed = parseAdrRef(ref);
|
|
54
44
|
if (parsed.log === undefined || parsed.log === resolutionLog) {
|
|
55
45
|
return localIds.has(parsed.id) ? 'resolved' : 'dangling';
|
|
56
46
|
}
|