@driftsys/markspec 0.7.1 → 0.7.3

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 (95) hide show
  1. package/esm/config/markspec.d.ts +17 -0
  2. package/esm/config/markspec.d.ts.map +1 -1
  3. package/esm/config/markspec.js +30 -1
  4. package/esm/lock/mod.d.ts +2 -2
  5. package/esm/lock/mod.d.ts.map +1 -1
  6. package/esm/lock/mod.js +1 -1
  7. package/esm/lock/model.d.ts +25 -0
  8. package/esm/lock/model.d.ts.map +1 -1
  9. package/esm/lock/parser.d.ts.map +1 -1
  10. package/esm/lock/parser.js +20 -0
  11. package/esm/lock/resolve.d.ts +19 -1
  12. package/esm/lock/resolve.d.ts.map +1 -1
  13. package/esm/lock/resolve.js +47 -1
  14. package/esm/lock/serializer.d.ts.map +1 -1
  15. package/esm/lock/serializer.js +31 -0
  16. package/esm/mod.d.ts +9 -7
  17. package/esm/mod.d.ts.map +1 -1
  18. package/esm/mod.js +6 -4
  19. package/esm/model/mod.d.ts +16 -0
  20. package/esm/model/mod.d.ts.map +1 -1
  21. package/esm/model/mod.js +16 -0
  22. package/esm/profile/display_id.d.ts +78 -25
  23. package/esm/profile/display_id.d.ts.map +1 -1
  24. package/esm/profile/display_id.js +164 -26
  25. package/esm/profile/manifest.d.ts.map +1 -1
  26. package/esm/profile/manifest.js +19 -0
  27. package/esm/profile/mod.d.ts +2 -2
  28. package/esm/profile/mod.d.ts.map +1 -1
  29. package/esm/profile/mod.js +1 -1
  30. package/esm/refs/mod.d.ts +43 -0
  31. package/esm/refs/mod.d.ts.map +1 -0
  32. package/esm/refs/mod.js +128 -0
  33. package/esm/validator/mod.d.ts +1 -1
  34. package/esm/validator/mod.d.ts.map +1 -1
  35. package/esm/validator/pattern.d.ts +47 -13
  36. package/esm/validator/pattern.d.ts.map +1 -1
  37. package/esm/validator/pattern.js +91 -41
  38. package/esm/validator/pipeline.d.ts +15 -1
  39. package/esm/validator/pipeline.d.ts.map +1 -1
  40. package/esm/validator/pipeline.js +16 -7
  41. package/esm/validator/traceability.d.ts +6 -3
  42. package/esm/validator/traceability.d.ts.map +1 -1
  43. package/esm/validator/traceability.js +23 -5
  44. package/esm/validator/types.d.ts.map +1 -1
  45. package/esm/validator/types.js +10 -4
  46. package/esm/validator/value_types.d.ts.map +1 -1
  47. package/esm/validator/value_types.js +4 -2
  48. package/package.json +1 -1
  49. package/script/config/markspec.d.ts +17 -0
  50. package/script/config/markspec.d.ts.map +1 -1
  51. package/script/config/markspec.js +30 -0
  52. package/script/lock/mod.d.ts +2 -2
  53. package/script/lock/mod.d.ts.map +1 -1
  54. package/script/lock/mod.js +2 -1
  55. package/script/lock/model.d.ts +25 -0
  56. package/script/lock/model.d.ts.map +1 -1
  57. package/script/lock/parser.d.ts.map +1 -1
  58. package/script/lock/parser.js +20 -0
  59. package/script/lock/resolve.d.ts +19 -1
  60. package/script/lock/resolve.d.ts.map +1 -1
  61. package/script/lock/resolve.js +47 -0
  62. package/script/lock/serializer.d.ts.map +1 -1
  63. package/script/lock/serializer.js +31 -0
  64. package/script/mod.d.ts +9 -7
  65. package/script/mod.d.ts.map +1 -1
  66. package/script/mod.js +30 -22
  67. package/script/model/mod.d.ts +16 -0
  68. package/script/model/mod.d.ts.map +1 -1
  69. package/script/model/mod.js +17 -1
  70. package/script/profile/display_id.d.ts +78 -25
  71. package/script/profile/display_id.d.ts.map +1 -1
  72. package/script/profile/display_id.js +166 -26
  73. package/script/profile/manifest.d.ts.map +1 -1
  74. package/script/profile/manifest.js +19 -0
  75. package/script/profile/mod.d.ts +2 -2
  76. package/script/profile/mod.d.ts.map +1 -1
  77. package/script/profile/mod.js +2 -1
  78. package/script/refs/mod.d.ts +43 -0
  79. package/script/refs/mod.d.ts.map +1 -0
  80. package/script/refs/mod.js +133 -0
  81. package/script/validator/mod.d.ts +1 -1
  82. package/script/validator/mod.d.ts.map +1 -1
  83. package/script/validator/pattern.d.ts +47 -13
  84. package/script/validator/pattern.d.ts.map +1 -1
  85. package/script/validator/pattern.js +92 -41
  86. package/script/validator/pipeline.d.ts +15 -1
  87. package/script/validator/pipeline.d.ts.map +1 -1
  88. package/script/validator/pipeline.js +16 -7
  89. package/script/validator/traceability.d.ts +6 -3
  90. package/script/validator/traceability.d.ts.map +1 -1
  91. package/script/validator/traceability.js +23 -5
  92. package/script/validator/types.d.ts.map +1 -1
  93. package/script/validator/types.js +9 -3
  94. package/script/validator/value_types.d.ts.map +1 -1
  95. package/script/validator/value_types.js +3 -1
@@ -1,30 +1,64 @@
1
1
  /**
2
2
  * @module core/validator/pattern
3
3
  *
4
- * Display-ID pattern template → anchored RegExp.
4
+ * Display-ID pattern template → anchored RegExp (the classification half of
5
+ * the grammar). The tokenizer and well-formedness oracle live in
6
+ * `core/profile/display_id.ts` — {@linkcode tokenizePattern} and
7
+ * {@linkcode validateDisplayIdPattern} — and are shared with the
8
+ * minting/scaffold parser so the two never disagree about which forms are
9
+ * valid (#596). This module only builds the recognizer regex.
5
10
  *
6
- * Grammar (per ADR-009 §5):
7
- * pattern := segment+ (exactly one counter)
8
- * segment := literal | counter | named
9
- * counter := "{n}" | "{n:" PADDING "d}"
10
- * named := "{" identifier "}" (e.g. {scope}, {feature})
11
- * PADDING := "0" digits
11
+ * A pattern is one of two kinds, selected by whether it contains a counter:
12
12
  *
13
- * The counter `{n}` is the numeric running index (exactly one required). A
14
- * named placeholder such as `{scope}` matches a free alphanumeric segment —
15
- * it validates the *shape* `PREFIX_<scope>_<NNNN>` without pinning the scope
16
- * to a fixed value, so one profile pattern serves every feature scope.
13
+ * numbered := segment+ (exactly one counter) — mintable + classifying
14
+ * named := segment+ (literal anchor, ≥1 named, no counter) — classifying
15
+ *
16
+ * segment := literal | counter | named
17
+ * counter := "{n}" | "{n:" digits "d}" (e.g. {n}, {n:4d}, {n:04d})
18
+ * named := "{" identifier "}" (e.g. {scope}, {name})
19
+ *
20
+ * **Numbered patterns** carry exactly one counter — the numeric running
21
+ * index used both for classification (a recognizer regex) and for minting the
22
+ * next ID. A medial named placeholder such as `{scope}` matches a single free
23
+ * alphanumeric segment, so one pattern serves every feature scope.
24
+ *
25
+ * **Named patterns** (ADR-025, issue #594) carry no counter — they classify
26
+ * types whose IDs are *named, not numbered* (e.g. components `SWC_LIGHT_CTRL`,
27
+ * `HWC_PIU`). They require a non-empty literal anchor plus at least one named
28
+ * placeholder; the trailing named placeholder captures the rest of the
29
+ * display ID (underscores, dots, slashes, hyphens included). A bare `{name}`
30
+ * with no literal anchor is rejected — it would match every ID and collide
31
+ * with every type. Named patterns are not mintable (no counter to increment);
32
+ * `parseDisplayIdPattern` skips them so the scaffold/next-id paths fall back
33
+ * to author-typed IDs.
17
34
  *
18
35
  * Examples:
19
36
  * REQ-{n} → ^REQ-(\d+)$
20
37
  * REQ-{n:04d} → ^REQ-(\d{4})$
38
+ * STK_{n:4d} → ^STK_(\d{4})$
21
39
  * XREQ_{scope}_{n:04d} → ^XREQ_(?<scope>[A-Za-z0-9]+)_(\d{4})$
40
+ * SWC_{name} → ^SWC_(?<name>[A-Za-z0-9._/-]+)$
22
41
  */
23
42
  /**
24
43
  * Compile a display-ID pattern template into an anchored RegExp.
25
44
  *
26
- * Throws if the template is missing the `{n}` counter, has more than one, or
27
- * has an invalid padding specifier.
45
+ * Throws the {@linkcode validateDisplayIdPattern} reason when the template is
46
+ * malformed (more than one counter, a malformed/zero-width padding specifier,
47
+ * no variable part, a counter-less pattern without a literal anchor, or a
48
+ * duplicate named placeholder). Validating first guarantees `new RegExp`
49
+ * below never sees a duplicate capture name.
28
50
  */
29
51
  export declare function compileDisplayIdPattern(template: string): RegExp;
52
+ /**
53
+ * Compile a display-ID pattern, returning `undefined` instead of throwing when
54
+ * the template is malformed.
55
+ *
56
+ * Defensive guard for the classification stage: the canonical fix rejects a
57
+ * malformed `display-id-pattern` at profile-load (`PROFILE-TYPE-008`, #597),
58
+ * but until that fix is on the same branch a bad pattern reaching
59
+ * classification must not crash `markspec check` with an uncaught throw
60
+ * (clig.dev: never surface a raw stack trace). A skipped type simply does not
61
+ * classify — the entry surfaces as `MSL-T003` rather than a crash.
62
+ */
63
+ export declare function tryCompileDisplayIdPattern(template: string): RegExp | undefined;
30
64
  //# sourceMappingURL=pattern.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/validator/pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAuChE"}
1
+ {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/validator/pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAuBH;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA+BhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAMpB"}
@@ -1,66 +1,116 @@
1
1
  /**
2
2
  * @module core/validator/pattern
3
3
  *
4
- * Display-ID pattern template → anchored RegExp.
4
+ * Display-ID pattern template → anchored RegExp (the classification half of
5
+ * the grammar). The tokenizer and well-formedness oracle live in
6
+ * `core/profile/display_id.ts` — {@linkcode tokenizePattern} and
7
+ * {@linkcode validateDisplayIdPattern} — and are shared with the
8
+ * minting/scaffold parser so the two never disagree about which forms are
9
+ * valid (#596). This module only builds the recognizer regex.
5
10
  *
6
- * Grammar (per ADR-009 §5):
7
- * pattern := segment+ (exactly one counter)
8
- * segment := literal | counter | named
9
- * counter := "{n}" | "{n:" PADDING "d}"
10
- * named := "{" identifier "}" (e.g. {scope}, {feature})
11
- * PADDING := "0" digits
11
+ * A pattern is one of two kinds, selected by whether it contains a counter:
12
12
  *
13
- * The counter `{n}` is the numeric running index (exactly one required). A
14
- * named placeholder such as `{scope}` matches a free alphanumeric segment —
15
- * it validates the *shape* `PREFIX_<scope>_<NNNN>` without pinning the scope
16
- * to a fixed value, so one profile pattern serves every feature scope.
13
+ * numbered := segment+ (exactly one counter) — mintable + classifying
14
+ * named := segment+ (literal anchor, ≥1 named, no counter) — classifying
15
+ *
16
+ * segment := literal | counter | named
17
+ * counter := "{n}" | "{n:" digits "d}" (e.g. {n}, {n:4d}, {n:04d})
18
+ * named := "{" identifier "}" (e.g. {scope}, {name})
19
+ *
20
+ * **Numbered patterns** carry exactly one counter — the numeric running
21
+ * index used both for classification (a recognizer regex) and for minting the
22
+ * next ID. A medial named placeholder such as `{scope}` matches a single free
23
+ * alphanumeric segment, so one pattern serves every feature scope.
24
+ *
25
+ * **Named patterns** (ADR-025, issue #594) carry no counter — they classify
26
+ * types whose IDs are *named, not numbered* (e.g. components `SWC_LIGHT_CTRL`,
27
+ * `HWC_PIU`). They require a non-empty literal anchor plus at least one named
28
+ * placeholder; the trailing named placeholder captures the rest of the
29
+ * display ID (underscores, dots, slashes, hyphens included). A bare `{name}`
30
+ * with no literal anchor is rejected — it would match every ID and collide
31
+ * with every type. Named patterns are not mintable (no counter to increment);
32
+ * `parseDisplayIdPattern` skips them so the scaffold/next-id paths fall back
33
+ * to author-typed IDs.
17
34
  *
18
35
  * Examples:
19
36
  * REQ-{n} → ^REQ-(\d+)$
20
37
  * REQ-{n:04d} → ^REQ-(\d{4})$
38
+ * STK_{n:4d} → ^STK_(\d{4})$
21
39
  * XREQ_{scope}_{n:04d} → ^XREQ_(?<scope>[A-Za-z0-9]+)_(\d{4})$
40
+ * SWC_{name} → ^SWC_(?<name>[A-Za-z0-9._/-]+)$
41
+ */
42
+ import { tokenizePattern, validateDisplayIdPattern, } from "../profile/display_id.js";
43
+ /**
44
+ * Character class for the trailing named placeholder of a *named* pattern —
45
+ * the established display-ID token set (letters, digits, underscore, dot,
46
+ * slash, hyphen). Wider than the medial-segment class so `SWC_{name}` matches
47
+ * underscore-bearing IDs like `SWC_LIGHT_CTRL`.
48
+ */
49
+ const REST_OF_ID_CLASS = "[A-Za-z0-9._/-]+";
50
+ /**
51
+ * Character class for a medial named placeholder (e.g. `{scope}` between two
52
+ * literal segments). A single free alphanumeric run that stops at the next
53
+ * literal — never swallows an adjacent counter or separator.
22
54
  */
23
- // One token: the {n} counter (optionally padded) OR a {named} segment.
24
- const TOKEN_RE = /\{n(?::(0\d+)d)?\}|\{([A-Za-z][A-Za-z0-9_]*)\}/g;
55
+ const SEGMENT_CLASS = "[A-Za-z0-9]+";
25
56
  /**
26
57
  * Compile a display-ID pattern template into an anchored RegExp.
27
58
  *
28
- * Throws if the template is missing the `{n}` counter, has more than one, or
29
- * has an invalid padding specifier.
59
+ * Throws the {@linkcode validateDisplayIdPattern} reason when the template is
60
+ * malformed (more than one counter, a malformed/zero-width padding specifier,
61
+ * no variable part, a counter-less pattern without a literal anchor, or a
62
+ * duplicate named placeholder). Validating first guarantees `new RegExp`
63
+ * below never sees a duplicate capture name.
30
64
  */
31
65
  export function compileDisplayIdPattern(template) {
66
+ const validation = validateDisplayIdPattern(template);
67
+ if (!validation.ok)
68
+ throw new Error(validation.message);
69
+ const tokens = tokenizePattern(template);
70
+ const counters = tokens.filter((t) => t.kind === "counter").length;
71
+ // In a named (counter-less) pattern the trailing named placeholder matches
72
+ // the rest of the display ID; every other named placeholder — and every
73
+ // named placeholder in a numbered pattern — stays a single segment.
74
+ const restOfIdNamedIndex = counters === 0
75
+ ? tokens.reduce((acc, t, i) => (t.kind === "named" ? i : acc), -1)
76
+ : -1;
32
77
  let regexSource = "^";
33
- let lastIndex = 0;
34
- let counters = 0;
35
- const re = new RegExp(TOKEN_RE);
36
- let match;
37
- while ((match = re.exec(template)) !== null) {
38
- regexSource += escapeRegex(template.slice(lastIndex, match.index));
39
- const named = match[2];
40
- if (named === undefined) {
41
- // {n} / {n:0Nd} counter
42
- const padding = match[1];
43
- regexSource += "(" + (padding ? `\\d{${Number(padding)}}` : `\\d+`) + ")";
44
- counters++;
78
+ tokens.forEach((t, i) => {
79
+ if (t.kind === "literal") {
80
+ regexSource += escapeRegex(t.text);
45
81
  }
46
- else {
47
- // {scope}-style named segment → free alphanumeric capture
48
- regexSource += `(?<${named}>[A-Za-z0-9]+)`;
82
+ else if (t.kind === "counter") {
83
+ regexSource += "(" +
84
+ (t.padding ? `\\d{${Number(t.padding)}}` : `\\d+`) + ")";
49
85
  }
50
- lastIndex = match.index + match[0].length;
51
- }
52
- regexSource += escapeRegex(template.slice(lastIndex)) + "$";
53
- if (counters === 0) {
54
- if (/\{n:[^}]*\}/.test(template)) {
55
- throw new Error(`display-id-pattern '${template}': invalid padding specifier ` +
56
- `(expected {n} or {n:NNd})`);
86
+ else {
87
+ const charClass = i === restOfIdNamedIndex
88
+ ? REST_OF_ID_CLASS
89
+ : SEGMENT_CLASS;
90
+ regexSource += `(?<${t.name}>${charClass})`;
57
91
  }
58
- throw new Error(`display-id-pattern '${template}': missing {n} placeholder`);
92
+ });
93
+ regexSource += "$";
94
+ return new RegExp(regexSource);
95
+ }
96
+ /**
97
+ * Compile a display-ID pattern, returning `undefined` instead of throwing when
98
+ * the template is malformed.
99
+ *
100
+ * Defensive guard for the classification stage: the canonical fix rejects a
101
+ * malformed `display-id-pattern` at profile-load (`PROFILE-TYPE-008`, #597),
102
+ * but until that fix is on the same branch a bad pattern reaching
103
+ * classification must not crash `markspec check` with an uncaught throw
104
+ * (clig.dev: never surface a raw stack trace). A skipped type simply does not
105
+ * classify — the entry surfaces as `MSL-T003` rather than a crash.
106
+ */
107
+ export function tryCompileDisplayIdPattern(template) {
108
+ try {
109
+ return compileDisplayIdPattern(template);
59
110
  }
60
- if (counters > 1) {
61
- throw new Error(`display-id-pattern '${template}': multiple {n} counters (expected one)`);
111
+ catch {
112
+ return undefined;
62
113
  }
63
- return new RegExp(regexSource);
64
114
  }
65
115
  function escapeRegex(s) {
66
116
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -16,6 +16,18 @@ export interface PipelineResult {
16
16
  /** `true` when no error-severity diagnostics were emitted. */
17
17
  readonly valid: boolean;
18
18
  }
19
+ /** Options for {@linkcode runPipeline}. */
20
+ export interface PipelineOptions {
21
+ /**
22
+ * When `false`, suppress MSL-L006 ("link target does not resolve") from
23
+ * Stage 4 output. Use this when the validator is running against a subset
24
+ * of the project's files (e.g. `markspec check <file>`): file-local scope
25
+ * cannot distinguish a typo from a valid cross-file target. MSL-L006 is
26
+ * only meaningful when the full entry set is available (LSP, `compile`).
27
+ * Defaults to `true` (full-project scope — emit MSL-L006 normally).
28
+ */
29
+ readonly projectWide?: boolean;
30
+ }
19
31
  /**
20
32
  * Run the validator pipeline.
21
33
  *
@@ -30,8 +42,10 @@ export interface PipelineResult {
30
42
  * conventions (from `ProjectConfig.captionConventions`). When supplied
31
43
  * and non-empty, MSL-C072 is checked for each entry. Defaults to no
32
44
  * conventions (rule inactive).
45
+ * @param opts - Pipeline options. Pass `{ projectWide: false }` when
46
+ * validating a file-local subset so MSL-L006 is suppressed.
33
47
  */
34
- export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions): PipelineResult;
48
+ export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions, opts?: PipelineOptions): PipelineResult;
35
49
  /**
36
50
  * Drop core Stage 1 `MSL-R010` ("unknown attribute") warnings for attributes
37
51
  * the loaded profile declares — Stage 3 validates those directly, so the
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAsBzB,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;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ASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CASvB"}
@@ -36,8 +36,10 @@ import { buildEffectiveDisciplineRegistry } from "../profile/discipline_registry
36
36
  * conventions (from `ProjectConfig.captionConventions`). When supplied
37
37
  * and non-empty, MSL-C072 is checked for each entry. Defaults to no
38
38
  * conventions (rule inactive).
39
+ * @param opts - Pipeline options. Pass `{ projectWide: false }` when
40
+ * validating a file-local subset so MSL-L006 is suppressed.
39
41
  */
40
- export function runPipeline(entries, profile, captionConventions = {}) {
42
+ export function runPipeline(entries, profile, captionConventions = {}, opts = {}) {
41
43
  const diagnostics = [];
42
44
  // Stage 1 — core hygiene. When a profile is loaded, suppress MSL-R010
43
45
  // warnings for attributes the profile actually declares (Stage 3's scope
@@ -99,18 +101,25 @@ export function runPipeline(entries, profile, captionConventions = {}) {
99
101
  diagnostics.push(...stage3);
100
102
  }
101
103
  }
102
- // Stage 4 — traceability rules (only when a profile is loaded). Builds a
103
- // graph index keyed by `entry.id` from the post-classification entries so
104
- // trace-rule target matchers can look up the classified type/shape.
104
+ // Stage 4 — traceability rules (only when a profile is loaded). Builds two
105
+ // indexes: by `entry.id` (ULID) and by `entry.displayId`, so trace values
106
+ // resolve in either form (issue #593).
105
107
  if (profile !== null) {
106
108
  const graph = new Map();
109
+ const byDisplayId = new Map();
107
110
  for (const e of finalEntries) {
108
- if (e.id)
111
+ if (e.id && !graph.has(e.id))
109
112
  graph.set(e.id, e);
113
+ if (!byDisplayId.has(e.displayId))
114
+ byDisplayId.set(e.displayId, e);
110
115
  }
116
+ const projectWide = opts.projectWide !== false;
111
117
  for (const entry of finalEntries) {
112
- const stage4 = validateTraceabilityForEntry(entry, profile, graph);
113
- diagnostics.push(...stage4);
118
+ const stage4 = validateTraceabilityForEntry(entry, profile, graph, byDisplayId);
119
+ // Suppress MSL-L006 ("link target does not resolve") when running
120
+ // file-locally: the checked subset cannot distinguish a typo from a
121
+ // valid cross-file target. Only emit when the full entry set is present.
122
+ diagnostics.push(...projectWide ? stage4 : stage4.filter((d) => d.code !== "MSL-L006"));
114
123
  }
115
124
  }
116
125
  const valid = !diagnostics.some((d) => d.severity === "error");
@@ -9,12 +9,13 @@
9
9
  * - Required (MSL-L001)
10
10
  * - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
11
11
  * - Target match against the rule's target matchers (MSL-L004)
12
+ * - Target existence (MSL-L006, warning; scheme-qualified URIs exempt)
12
13
  *
13
14
  * Referenced entries are skipped entirely — the profile manifest parser
14
15
  * rejects `referenced.traceability` at load time, so referenced entries
15
16
  * never have declared outgoing links.
16
17
  */
17
- import type { Diagnostic, EffectiveProfile, Entry, TargetMatcher, TraceRule } from "../model/mod.js";
18
+ import { type Diagnostic, type EffectiveProfile, type Entry, type TargetMatcher, type TraceRule } from "../model/mod.js";
18
19
  /**
19
20
  * Effective trace rules for an entry: type-scope rules only.
20
21
  * Type-scope rules are applied only when the entry is classified.
@@ -41,7 +42,9 @@ export declare function matchesAnyTarget(target: Entry, matchers: readonly Targe
41
42
  * @param entry - The entry to validate (after Stage 2 classification +
42
43
  * Stage 2.5 normalization)
43
44
  * @param profile - The effective profile (null → never called)
44
- * @param graph - Index keyed by entry.id for target lookup
45
+ * @param graph - Index keyed by entry.id (ULID) for target lookup
46
+ * @param byDisplayId - Index keyed by entry.displayId for target lookup
47
+ * (issue #593 — display-ID targets). Defaults to empty.
45
48
  */
46
- export declare function validateTraceabilityForEntry(entry: Entry, profile: EffectiveProfile, graph: ReadonlyMap<string, Entry>): Diagnostic[];
49
+ export declare function validateTraceabilityForEntry(entry: Entry, profile: EffectiveProfile, graph: ReadonlyMap<string, Entry>, byDisplayId?: ReadonlyMap<string, Entry>): Diagnostic[];
47
50
  //# sourceMappingURL=traceability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAehC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAChC,UAAU,EAAE,CAuEd"}
1
+ {"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAehC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAST;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,EACjC,WAAW,GAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAa,GAClD,UAAU,EAAE,CAsFd"}
@@ -9,11 +9,13 @@
9
9
  * - Required (MSL-L001)
10
10
  * - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
11
11
  * - Target match against the rule's target matchers (MSL-L004)
12
+ * - Target existence (MSL-L006, warning; scheme-qualified URIs exempt)
12
13
  *
13
14
  * Referenced entries are skipped entirely — the profile manifest parser
14
15
  * rejects `referenced.traceability` at load time, so referenced entries
15
16
  * never have declared outgoing links.
16
17
  */
18
+ import { URI_SCHEME_RE, } from "../model/mod.js";
17
19
  /**
18
20
  * Effective trace rules for an entry: type-scope rules only.
19
21
  * Type-scope rules are applied only when the entry is classified.
@@ -66,9 +68,11 @@ export function matchesAnyTarget(target, matchers) {
66
68
  * @param entry - The entry to validate (after Stage 2 classification +
67
69
  * Stage 2.5 normalization)
68
70
  * @param profile - The effective profile (null → never called)
69
- * @param graph - Index keyed by entry.id for target lookup
71
+ * @param graph - Index keyed by entry.id (ULID) for target lookup
72
+ * @param byDisplayId - Index keyed by entry.displayId for target lookup
73
+ * (issue #593 — display-ID targets). Defaults to empty.
70
74
  */
71
- export function validateTraceabilityForEntry(entry, profile, graph) {
75
+ export function validateTraceabilityForEntry(entry, profile, graph, byDisplayId = new Map()) {
72
76
  const diagnostics = [];
73
77
  if (entry.shape !== "Authored")
74
78
  return diagnostics;
@@ -108,11 +112,25 @@ export function validateTraceabilityForEntry(entry, profile, graph) {
108
112
  location: entry.location,
109
113
  });
110
114
  }
111
- // MSL-L004: target match for each resolved value.
115
+ // MSL-L004 target match + MSL-L006 existence, for each resolved value.
116
+ // Resolve by ULID (graph) first, then by display ID (byDisplayId) — the
117
+ // dual-resolution spine (issue #593).
112
118
  for (const v of values) {
113
- const target = graph.get(v);
114
- if (!target)
119
+ const target = graph.get(v) ?? byDisplayId.get(v);
120
+ if (!target) {
121
+ // Scheme-qualified URIs are intentionally external — never local
122
+ // graph targets, so they are not "broken references".
123
+ if (URI_SCHEME_RE.test(v))
124
+ continue;
125
+ diagnostics.push({
126
+ code: "MSL-L006",
127
+ severity: "warning",
128
+ message: `${entry.displayId}: link '${linkName}' target '${v}' does not ` +
129
+ `resolve to any entry`,
130
+ location: entry.location,
131
+ });
115
132
  continue;
133
+ }
116
134
  if (!matchesAnyTarget(target, rule.target)) {
117
135
  diagnostics.push({
118
136
  code: "MSL-L004",
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAwBzB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAWvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAiBvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CAwBvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,cAAc,CA8DhB;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,C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O,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CAuBrB"}
@@ -8,7 +8,7 @@
8
8
  * entries in a strict profile (types declared) produce MSL-T003.
9
9
  */
10
10
  import { CORE_TYPES } from "../model/mod.js";
11
- import { compileDisplayIdPattern } from "./pattern.js";
11
+ import { tryCompileDisplayIdPattern } from "./pattern.js";
12
12
  import { explicitType, resolvedCoreType, resolvedCoreTypeWithProvenance, } from "./type_resolution.js";
13
13
  /**
14
14
  * Profile-declared concrete-type naming convention (spec §1.3): lowercase
@@ -167,7 +167,11 @@ export function classifyEntry(entry, profile) {
167
167
  const pattern = typeEntry.value.displayIdPattern.value;
168
168
  if (pattern === undefined)
169
169
  continue;
170
- const regex = compileDisplayIdPattern(pattern);
170
+ // A malformed pattern must not crash classification — skip it (canonical
171
+ // fix: load-time PROFILE-TYPE-008, #597).
172
+ const regex = tryCompileDisplayIdPattern(pattern);
173
+ if (regex === undefined)
174
+ continue;
171
175
  if (regex.test(entry.displayId)) {
172
176
  matches.push(typeName);
173
177
  }
@@ -239,8 +243,10 @@ function checkEnforcement(entry, typeEntry) {
239
243
  const level = typeEntry.value.displayIdPatternEnforcement.value;
240
244
  if (level === "off")
241
245
  return undefined;
242
- const regex = compileDisplayIdPattern(pattern);
243
- if (regex.test(entry.displayId))
246
+ // A malformed pattern cannot enforce anything — skip rather than crash
247
+ // (canonical fix: load-time PROFILE-TYPE-008, #597).
248
+ const regex = tryCompileDisplayIdPattern(pattern);
249
+ if (regex === undefined || regex.test(entry.displayId))
244
250
  return undefined;
245
251
  return {
246
252
  code: "MSL-T004",
@@ -1 +1 @@
1
- {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA8C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
1
+ {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA+C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * The top-level {@linkcode validateValue} dispatches on the declared type.
9
9
  */
10
- import { ULID_RE, URI_SCHEME_RE } from "../model/mod.js";
10
+ import { DISPLAY_ID_RE, ULID_RE, URI_SCHEME_RE } from "../model/mod.js";
11
11
  /**
12
12
  * Validate one string value against an attribute's declared value type.
13
13
  * Returns `null` when the value is valid, or a short human-readable detail
@@ -55,7 +55,9 @@ const validateId = (value, _decl) => {
55
55
  return null;
56
56
  if (URI_SCHEME_RE.test(value))
57
57
  return null;
58
- return `not a valid id: '${value}' (expected 26-char ULID or scheme-qualified URI)`;
58
+ if (DISPLAY_ID_RE.test(value))
59
+ return null;
60
+ return `not a valid id: '${value}' (expected a display ID, 26-char ULID, or scheme-qualified URI)`;
59
61
  };
60
62
  /**
61
63
  * HTTP(S) URL prefix used by the `url` value type (spec §1.8). The
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftsys/markspec",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Markdown flavor and toolchain for traceable industrial documentation",
5
5
  "keywords": [
6
6
  "markdown",
@@ -19,6 +19,23 @@ export declare const MARKSPEC_YAML_FILENAME = ".markspec.yaml";
19
19
  * @returns Raw file contents, or `null` when the file is absent
20
20
  */
21
21
  export declare function readMarkspecYaml(projectRoot: string, readFile: ReadFile): Promise<string | null>;
22
+ /**
23
+ * Walk up from `startDir` to the filesystem root looking for a
24
+ * `.markspec.yaml` activator (ADR-008). Returns the absolute path to the
25
+ * directory containing it, or `undefined` when none is found.
26
+ *
27
+ * This is the membership test for "is this a MarkSpec project?". Unlike
28
+ * {@linkcode discoverProjectRoot}, which keys on `project.yaml`, a project
29
+ * is considered MarkSpec-activated only by the presence of a
30
+ * `.markspec.yaml` (per ADR-008): the LSP server uses this to stay inert —
31
+ * no `.markspec/` runtime directory or event log — in a plain Markdown or
32
+ * source repo (issue #609).
33
+ *
34
+ * @param startDir - Directory to begin the upward walk from (typically the
35
+ * workspace root the editor opened).
36
+ * @param readFile - File reader returning `undefined` for missing paths.
37
+ */
38
+ export declare function discoverMarkspecRoot(startDir: string, readFile: ReadFile): Promise<string | undefined>;
22
39
  /** The parsed content of a `.markspec.yaml`. */
23
40
  export interface MarkspecYaml {
24
41
  readonly profiles: readonly ProfileSpecifier[];
@@ -1 +1 @@
1
- {"version":3,"file":"markspec.d.ts","sourceRoot":"","sources":["../../src/config/markspec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAsB,gBA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,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AAMD,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,eAAO,MAAM,0BAA0B,aAIrC,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,uBAAuB,CA8FzB;AAgFD,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,QAAQ,EACpB,WAAW,EAAE,SAAS,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAiDf"}
@@ -11,6 +11,7 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ALLOWED_MARKSPEC_YAML_KEYS = exports.MARKSPEC_YAML_FILENAME = void 0;
13
13
  exports.readMarkspecYaml = readMarkspecYaml;
14
+ exports.discoverMarkspecRoot = discoverMarkspecRoot;
14
15
  exports.parseMarkspecYaml = parseMarkspecYaml;
15
16
  exports.addProfileSpecifier = addProfileSpecifier;
16
17
  const yaml_1 = require("@std/yaml");
@@ -29,6 +30,35 @@ async function readMarkspecYaml(projectRoot, readFile) {
29
30
  const content = await readFile(path);
30
31
  return content ?? null;
31
32
  }
33
+ /**
34
+ * Walk up from `startDir` to the filesystem root looking for a
35
+ * `.markspec.yaml` activator (ADR-008). Returns the absolute path to the
36
+ * directory containing it, or `undefined` when none is found.
37
+ *
38
+ * This is the membership test for "is this a MarkSpec project?". Unlike
39
+ * {@linkcode discoverProjectRoot}, which keys on `project.yaml`, a project
40
+ * is considered MarkSpec-activated only by the presence of a
41
+ * `.markspec.yaml` (per ADR-008): the LSP server uses this to stay inert —
42
+ * no `.markspec/` runtime directory or event log — in a plain Markdown or
43
+ * source repo (issue #609).
44
+ *
45
+ * @param startDir - Directory to begin the upward walk from (typically the
46
+ * workspace root the editor opened).
47
+ * @param readFile - File reader returning `undefined` for missing paths.
48
+ */
49
+ async function discoverMarkspecRoot(startDir, readFile) {
50
+ let current = (0, path_1.resolve)(startDir);
51
+ for (;;) {
52
+ const candidate = (0, path_1.join)(current, exports.MARKSPEC_YAML_FILENAME);
53
+ const content = await readFile(candidate);
54
+ if (content !== undefined)
55
+ return current;
56
+ const parent = (0, path_1.dirname)(current);
57
+ if (parent === current)
58
+ return undefined;
59
+ current = parent;
60
+ }
61
+ }
32
62
  exports.ALLOWED_MARKSPEC_YAML_KEYS = new Set([
33
63
  "$schema",
34
64
  "profiles",
@@ -5,7 +5,7 @@
5
5
  * model, upstream resolution, drift detection. The public boundary
6
6
  * for both `markspec lock` and `markspec compile --frozen`.
7
7
  */
8
- export type { BoundEntry, BoundEntryBinding, GeneratedCache, LockedAttributes, Lockfile, LockfileMeta, LockfileToolchain, Upstream, UpstreamProfile, UpstreamReference, UpstreamRegistry, } from "./model.js";
8
+ export type { BoundEntry, BoundEntryBinding, GeneratedCache, LockedAttributes, LockEdge, Lockfile, LockfileMeta, LockfileToolchain, Upstream, UpstreamProfile, UpstreamReference, UpstreamRegistry, } from "./model.js";
9
9
  export { LOCKFILE_SCHEMA_VERSION } from "./model.js";
10
10
  export { serializeLockfile } from "./serializer.js";
11
11
  export { parseLockfile } from "./parser.js";
@@ -15,6 +15,6 @@ export { checkDrift } from "./check.js";
15
15
  export { sha256Bytes, sha256String } from "./hash.js";
16
16
  export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
17
17
  export type { EdgeQuad } from "./canonical_edges.js";
18
- export { extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
18
+ export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
19
19
  export type { FetchUrl, ReadFile, ResolvedBoundEntry, ResolvedProfile, ResolvedReference, ResolvedRegistry, ResolvedUpstreams, ResolveUpstreamsOptions, } from "./resolve.js";
20
20
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lock/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,WA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B,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,cAAc,CAAC"}
@@ -7,7 +7,7 @@
7
7
  * for both `markspec lock` and `markspec compile --frozen`.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.resolveUpstreams = exports.resolveRegistries = exports.resolveReferences = exports.resolveProfileChain = exports.resolveBoundEntries = exports.extractEdgeQuads = exports.hashCanonicalEdges = exports.canonicalEdgeJson = exports.sha256String = exports.sha256Bytes = exports.checkDrift = exports.isBelowFloor = exports.parseLockfile = exports.serializeLockfile = exports.LOCKFILE_SCHEMA_VERSION = void 0;
10
+ exports.resolveUpstreams = exports.resolveRegistries = exports.resolveReferences = exports.resolveProfileChain = exports.resolveBoundEntries = exports.extractEdgeQuads = exports.extractEdgeLedger = exports.hashCanonicalEdges = exports.canonicalEdgeJson = exports.sha256String = exports.sha256Bytes = exports.checkDrift = exports.isBelowFloor = exports.parseLockfile = exports.serializeLockfile = exports.LOCKFILE_SCHEMA_VERSION = void 0;
11
11
  var model_js_1 = require("./model.js");
12
12
  Object.defineProperty(exports, "LOCKFILE_SCHEMA_VERSION", { enumerable: true, get: function () { return model_js_1.LOCKFILE_SCHEMA_VERSION; } });
13
13
  var serializer_js_1 = require("./serializer.js");
@@ -25,6 +25,7 @@ var canonical_edges_js_1 = require("./canonical_edges.js");
25
25
  Object.defineProperty(exports, "canonicalEdgeJson", { enumerable: true, get: function () { return canonical_edges_js_1.canonicalEdgeJson; } });
26
26
  Object.defineProperty(exports, "hashCanonicalEdges", { enumerable: true, get: function () { return canonical_edges_js_1.hashCanonicalEdges; } });
27
27
  var resolve_js_1 = require("./resolve.js");
28
+ Object.defineProperty(exports, "extractEdgeLedger", { enumerable: true, get: function () { return resolve_js_1.extractEdgeLedger; } });
28
29
  Object.defineProperty(exports, "extractEdgeQuads", { enumerable: true, get: function () { return resolve_js_1.extractEdgeQuads; } });
29
30
  Object.defineProperty(exports, "resolveBoundEntries", { enumerable: true, get: function () { return resolve_js_1.resolveBoundEntries; } });
30
31
  Object.defineProperty(exports, "resolveProfileChain", { enumerable: true, get: function () { return resolve_js_1.resolveProfileChain; } });