@driftsys/markspec 0.6.1 → 0.7.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.
Files changed (156) hide show
  1. package/README.md +2 -3
  2. package/esm/compiler/constants.d.ts +1 -1
  3. package/esm/compiler/constants.d.ts.map +1 -1
  4. package/esm/compiler/constants.js +4 -14
  5. package/esm/config/markspec.d.ts +1 -0
  6. package/esm/config/markspec.d.ts.map +1 -1
  7. package/esm/config/markspec.js +5 -1
  8. package/esm/lint/mod.d.ts +2 -0
  9. package/esm/lint/mod.d.ts.map +1 -1
  10. package/esm/lint/mod.js +1 -0
  11. package/esm/lint/rules/xref.d.ts +32 -5
  12. package/esm/lint/rules/xref.d.ts.map +1 -1
  13. package/esm/lint/rules/xref.js +40 -0
  14. package/esm/lint/runner.d.ts.map +1 -1
  15. package/esm/lint/runner.js +6 -2
  16. package/esm/lint/score_text.d.ts +67 -0
  17. package/esm/lint/score_text.d.ts.map +1 -0
  18. package/esm/lint/score_text.js +74 -0
  19. package/esm/lock/compare.d.ts +34 -0
  20. package/esm/lock/compare.d.ts.map +1 -0
  21. package/esm/lock/compare.js +64 -0
  22. package/esm/lock/mod.d.ts +2 -1
  23. package/esm/lock/mod.d.ts.map +1 -1
  24. package/esm/lock/mod.js +1 -0
  25. package/esm/lock/model.d.ts +13 -0
  26. package/esm/lock/model.d.ts.map +1 -1
  27. package/esm/lock/parser.d.ts +3 -0
  28. package/esm/lock/parser.d.ts.map +1 -1
  29. package/esm/lock/parser.js +37 -1
  30. package/esm/lock/resolve.d.ts.map +1 -1
  31. package/esm/lock/resolve.js +3 -11
  32. package/esm/lock/serializer.d.ts.map +1 -1
  33. package/esm/lock/serializer.js +6 -1
  34. package/esm/mod.d.ts +9 -5
  35. package/esm/mod.d.ts.map +1 -1
  36. package/esm/mod.js +7 -3
  37. package/esm/model/attributes.d.ts.map +1 -1
  38. package/esm/model/attributes.js +7 -0
  39. package/esm/model/mod.d.ts +3 -1
  40. package/esm/model/mod.d.ts.map +1 -1
  41. package/esm/model/mod.js +6 -14
  42. package/esm/model/relations.d.ts +35 -0
  43. package/esm/model/relations.d.ts.map +1 -0
  44. package/esm/model/relations.js +86 -0
  45. package/esm/model/type_hierarchy.d.ts +7 -0
  46. package/esm/model/type_hierarchy.d.ts.map +1 -1
  47. package/esm/model/type_hierarchy.js +35 -10
  48. package/esm/profile/display_id.d.ts +60 -0
  49. package/esm/profile/display_id.d.ts.map +1 -0
  50. package/esm/profile/display_id.js +80 -0
  51. package/esm/profile/manifest.d.ts +8 -0
  52. package/esm/profile/manifest.d.ts.map +1 -1
  53. package/esm/profile/manifest.js +9 -8
  54. package/esm/profile/mod.d.ts +3 -0
  55. package/esm/profile/mod.d.ts.map +1 -1
  56. package/esm/profile/mod.js +2 -0
  57. package/esm/profile/trace_targets.d.ts +43 -0
  58. package/esm/profile/trace_targets.d.ts.map +1 -0
  59. package/esm/profile/trace_targets.js +74 -0
  60. package/esm/self_upgrade/compare.d.ts +19 -0
  61. package/esm/self_upgrade/compare.d.ts.map +1 -0
  62. package/esm/self_upgrade/compare.js +35 -0
  63. package/esm/self_upgrade/manifest.d.ts +21 -0
  64. package/esm/self_upgrade/manifest.d.ts.map +1 -0
  65. package/esm/self_upgrade/manifest.js +27 -0
  66. package/esm/self_upgrade/mod.d.ts +12 -0
  67. package/esm/self_upgrade/mod.d.ts.map +1 -0
  68. package/esm/self_upgrade/mod.js +11 -0
  69. package/esm/self_upgrade/pm_detect.d.ts +27 -0
  70. package/esm/self_upgrade/pm_detect.d.ts.map +1 -0
  71. package/esm/self_upgrade/pm_detect.js +55 -0
  72. package/esm/self_upgrade/target.d.ts +25 -0
  73. package/esm/self_upgrade/target.d.ts.map +1 -0
  74. package/esm/self_upgrade/target.js +34 -0
  75. package/esm/validator/listing.d.ts.map +1 -1
  76. package/esm/validator/listing.js +9 -10
  77. package/esm/validator/trace_types.d.ts.map +1 -1
  78. package/esm/validator/trace_types.js +7 -29
  79. package/package.json +1 -1
  80. package/script/compiler/constants.d.ts +1 -1
  81. package/script/compiler/constants.d.ts.map +1 -1
  82. package/script/compiler/constants.js +4 -14
  83. package/script/config/markspec.d.ts +1 -0
  84. package/script/config/markspec.d.ts.map +1 -1
  85. package/script/config/markspec.js +7 -3
  86. package/script/lint/mod.d.ts +2 -0
  87. package/script/lint/mod.d.ts.map +1 -1
  88. package/script/lint/mod.js +3 -1
  89. package/script/lint/rules/xref.d.ts +32 -5
  90. package/script/lint/rules/xref.d.ts.map +1 -1
  91. package/script/lint/rules/xref.js +42 -0
  92. package/script/lint/runner.d.ts.map +1 -1
  93. package/script/lint/runner.js +5 -1
  94. package/script/lint/score_text.d.ts +67 -0
  95. package/script/lint/score_text.d.ts.map +1 -0
  96. package/script/lint/score_text.js +77 -0
  97. package/script/lock/compare.d.ts +34 -0
  98. package/script/lock/compare.d.ts.map +1 -0
  99. package/script/lock/compare.js +67 -0
  100. package/script/lock/mod.d.ts +2 -1
  101. package/script/lock/mod.d.ts.map +1 -1
  102. package/script/lock/mod.js +3 -1
  103. package/script/lock/model.d.ts +13 -0
  104. package/script/lock/model.d.ts.map +1 -1
  105. package/script/lock/parser.d.ts +3 -0
  106. package/script/lock/parser.d.ts.map +1 -1
  107. package/script/lock/parser.js +37 -1
  108. package/script/lock/resolve.d.ts.map +1 -1
  109. package/script/lock/resolve.js +3 -11
  110. package/script/lock/serializer.d.ts.map +1 -1
  111. package/script/lock/serializer.js +6 -1
  112. package/script/mod.d.ts +9 -5
  113. package/script/mod.d.ts.map +1 -1
  114. package/script/mod.js +85 -63
  115. package/script/model/attributes.d.ts.map +1 -1
  116. package/script/model/attributes.js +7 -0
  117. package/script/model/mod.d.ts +3 -1
  118. package/script/model/mod.d.ts.map +1 -1
  119. package/script/model/mod.js +9 -14
  120. package/script/model/relations.d.ts +35 -0
  121. package/script/model/relations.d.ts.map +1 -0
  122. package/script/model/relations.js +89 -0
  123. package/script/model/type_hierarchy.d.ts +7 -0
  124. package/script/model/type_hierarchy.d.ts.map +1 -1
  125. package/script/model/type_hierarchy.js +36 -10
  126. package/script/profile/display_id.d.ts +60 -0
  127. package/script/profile/display_id.d.ts.map +1 -0
  128. package/script/profile/display_id.js +86 -0
  129. package/script/profile/manifest.d.ts +8 -0
  130. package/script/profile/manifest.d.ts.map +1 -1
  131. package/script/profile/manifest.js +18 -16
  132. package/script/profile/mod.d.ts +3 -0
  133. package/script/profile/mod.d.ts.map +1 -1
  134. package/script/profile/mod.js +10 -1
  135. package/script/profile/trace_targets.d.ts +43 -0
  136. package/script/profile/trace_targets.d.ts.map +1 -0
  137. package/script/profile/trace_targets.js +79 -0
  138. package/script/self_upgrade/compare.d.ts +19 -0
  139. package/script/self_upgrade/compare.d.ts.map +1 -0
  140. package/script/self_upgrade/compare.js +38 -0
  141. package/script/self_upgrade/manifest.d.ts +21 -0
  142. package/script/self_upgrade/manifest.d.ts.map +1 -0
  143. package/script/self_upgrade/manifest.js +31 -0
  144. package/script/self_upgrade/mod.d.ts +12 -0
  145. package/script/self_upgrade/mod.d.ts.map +1 -0
  146. package/script/self_upgrade/mod.js +20 -0
  147. package/script/self_upgrade/pm_detect.d.ts +27 -0
  148. package/script/self_upgrade/pm_detect.d.ts.map +1 -0
  149. package/script/self_upgrade/pm_detect.js +58 -0
  150. package/script/self_upgrade/target.d.ts +25 -0
  151. package/script/self_upgrade/target.d.ts.map +1 -0
  152. package/script/self_upgrade/target.js +38 -0
  153. package/script/validator/listing.d.ts.map +1 -1
  154. package/script/validator/listing.js +9 -10
  155. package/script/validator/trace_types.d.ts.map +1 -1
  156. package/script/validator/trace_types.js +6 -28
package/README.md CHANGED
@@ -20,10 +20,9 @@ that processes it.
20
20
  **Authoring and validation**
21
21
 
22
22
  ```text
23
- markspec format # stamp ULIDs, normalize attributes
24
- markspec validate # check broken refs, missing Ids, duplicates
23
+ markspec fmt # stamp ULIDs, normalize attributes
24
+ markspec check # check broken refs, missing Ids, duplicates
25
25
  markspec lint # prose analysis (modal verbs, EARS, passive, …)
26
- markspec hook # pre-commit gate: format --check + validate
27
26
  markspec insert <type> # append a scaffolded entry to a file
28
27
  markspec create <type> # scaffold a new entry block (stdout)
29
28
  markspec next-id <type> # next available display ID for a type
@@ -9,7 +9,7 @@ import type { LinkKind } from "../model/mod.js";
9
9
  *
10
10
  * Spec attributes: Satisfies, Derived-from, References, Allocated-to.
11
11
  * Test attributes: Verifies, Tests.
12
- * Element attributes: Realizes, Depends-on, Part-of, Generated-from.
12
+ * Element attributes: Realizes, Depends-on, Part-of, Generated-from, Provides, Requires.
13
13
  * Universal: Supersedes (same-family).
14
14
  */
15
15
  export declare const ATTR_TO_LINK_KIND: Readonly<Record<string, LinkKind>>;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/compiler/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAYhE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/compiler/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAG9D,CAAC"}
@@ -3,24 +3,14 @@
3
3
  *
4
4
  * Shared constants for the compiler pipeline.
5
5
  */
6
+ import { CORE_RELATIONS } from "../model/mod.js";
6
7
  /**
7
8
  * Attribute keys that produce traceability links per ADR-002.
8
9
  *
9
10
  * Spec attributes: Satisfies, Derived-from, References, Allocated-to.
10
11
  * Test attributes: Verifies, Tests.
11
- * Element attributes: Realizes, Depends-on, Part-of, Generated-from.
12
+ * Element attributes: Realizes, Depends-on, Part-of, Generated-from, Provides, Requires.
12
13
  * Universal: Supersedes (same-family).
13
14
  */
14
- export const ATTR_TO_LINK_KIND = {
15
- "Satisfies": "satisfies",
16
- "Derived-from": "derived-from",
17
- "References": "references",
18
- "Allocated-to": "allocated-to",
19
- "Realizes": "realizes",
20
- "Verifies": "verifies",
21
- "Tests": "tests",
22
- "Depends-on": "depends-on",
23
- "Part-of": "part-of",
24
- "Generated-from": "generated-from",
25
- "Supersedes": "supersedes",
26
- };
15
+ export const ATTR_TO_LINK_KIND = Object
16
+ .fromEntries(CORE_RELATIONS.filter((r) => r.linkKind).map((r) => [r.attr, r.linkKind]));
@@ -33,6 +33,7 @@ export interface ParseMarkspecYamlResult {
33
33
  readonly config: MarkspecYaml | null;
34
34
  readonly diagnostics: readonly Diagnostic[];
35
35
  }
36
+ export declare const ALLOWED_MARKSPEC_YAML_KEYS: Set<string>;
36
37
  /**
37
38
  * Parse and validate a `.markspec.yaml` string.
38
39
  *
@@ -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,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;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,mDAAm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AAG,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"}
@@ -23,7 +23,11 @@ export async function readMarkspecYaml(projectRoot, readFile) {
23
23
  const content = await readFile(path);
24
24
  return content ?? null;
25
25
  }
26
- const ALLOWED_MARKSPEC_YAML_KEYS = new Set(["profiles", "default-profile"]);
26
+ export const ALLOWED_MARKSPEC_YAML_KEYS = new Set([
27
+ "$schema",
28
+ "profiles",
29
+ "default-profile",
30
+ ]);
27
31
  /**
28
32
  * Parse and validate a `.markspec.yaml` string.
29
33
  *
package/esm/lint/mod.d.ts CHANGED
@@ -9,6 +9,8 @@ export { isProseScope, runLint } from "./runner.js";
9
9
  export type { LintOptions, LintResult } from "./runner.js";
10
10
  export { ANTI_PATTERN_NOTE, computeScoreRollup } from "./score.js";
11
11
  export type { EntryScore, RuleContribution, ScoreRollup } from "./score.js";
12
+ export { scoreText } from "./score_text.js";
13
+ export type { ScoreTextOptions, ScoreTextResult } from "./score_text.js";
12
14
  export { segmentSentences } from "./segmenter.js";
13
15
  export type { Sentence } from "./segmenter.js";
14
16
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lint/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/lint/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
package/esm/lint/mod.js CHANGED
@@ -6,4 +6,5 @@
6
6
  */
7
7
  export { isProseScope, runLint } from "./runner.js";
8
8
  export { ANTI_PATTERN_NOTE, computeScoreRollup } from "./score.js";
9
+ export { scoreText } from "./score_text.js";
9
10
  export { segmentSentences } from "./segmenter.js";
@@ -8,12 +8,39 @@
8
8
  import type { Entry } from "../../model/mod.js";
9
9
  import type { LintDiagnostic } from "../types.js";
10
10
  import type { GlossaryIndex } from "../glossary.js";
11
- /** Hook signature for the deferred $Identifier registry leg. Returns
12
- * true when the token is a resolvable $Identifier (i.e. should be
13
- * skipped by Q500). Today, always returns false; ADR-016's marker
14
- * pass replaces this with a real registry lookup. See ADR-021
15
- * Decision 1. */
11
+ /** Hook signature for the $Identifier registry leg. Returns true when
12
+ * the token is a resolvable $Identifier (i.e. should be skipped by
13
+ * Q500). See ADR-021 Decision 1 for the integration seam, and
14
+ * {@linkcode buildIdentifierIndex} + {@linkcode buildIsIdentifierHook}
15
+ * for the corpus-scan implementation that backs it today. */
16
16
  export type IsIdentifierHook = (token: string) => boolean;
17
+ /**
18
+ * Build a corpus-wide `$Identifier` index from every entry's `bodyTokens`.
19
+ *
20
+ * Aggregates the bare name (text with leading `$` stripped) of every
21
+ * `entity-ref` token across `entries` into a `Set<string>`. The set is
22
+ * the data backing the {@linkcode IsIdentifierHook} closure produced by
23
+ * {@linkcode buildIsIdentifierHook}.
24
+ *
25
+ * Behavioural contract (ADR-021 Decision 1, additive-enrichment invariant):
26
+ * - Every name in the index is observed in the corpus as `$Name`.
27
+ * - The index is purely additive: more entries → more silenced phrases,
28
+ * never more diagnostics.
29
+ *
30
+ * Scope note: this is the pragmatic minimal resolver leg per issue #502.
31
+ * The formal `MSL-M050`/`MSL-M051` entity-resolution model (definition
32
+ * vs. use, typed identifiers, profile Aliases) is deferred to a
33
+ * follow-up story — the closure body changes but the hook signature
34
+ * stays the same.
35
+ */
36
+ export declare function buildIdentifierIndex(entries: readonly Entry[]): ReadonlySet<string>;
37
+ /**
38
+ * Build the {@linkcode IsIdentifierHook} closure from a precomputed
39
+ * index. Separated from {@linkcode buildIdentifierIndex} so the index
40
+ * can be computed once per `runLint` invocation and reused across
41
+ * every in-scope entry.
42
+ */
43
+ export declare function buildIsIdentifierHook(index: ReadonlySet<string>): IsIdentifierHook;
17
44
  /** Public entry point: run Q500 against an entry's paragraph bodies. */
18
45
  export declare function runXrefRules(entry: Entry, glossary: GlossaryIndex, capitalizedAllow: ReadonlySet<string>, isIdentifier: IsIdentifierHook): LintDiagnostic[];
19
46
  //# sourceMappingURL=xref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xref.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/xref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD;;;;iBAIiB;AACjB,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAmN1D,wEAAwE;AACxE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,YAAY,EAAE,gBAAgB,GAC7B,cAAc,EAAE,CAsElB"}
1
+ {"version":3,"file":"xref.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/xref.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD;;;;6DAI6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,CAAC,CAUrB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GACzB,gBAAgB,CAElB;AAmND,wEAAwE;AACxE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,EACrC,YAAY,EAAE,gBAAgB,GAC7B,cAAc,EAAE,CAsElB"}
@@ -7,6 +7,46 @@
7
7
  */
8
8
  import { deriveTermSlug } from "../../parser/glossary.js";
9
9
  import { offsetToRange } from "../range_util.js";
10
+ /**
11
+ * Build a corpus-wide `$Identifier` index from every entry's `bodyTokens`.
12
+ *
13
+ * Aggregates the bare name (text with leading `$` stripped) of every
14
+ * `entity-ref` token across `entries` into a `Set<string>`. The set is
15
+ * the data backing the {@linkcode IsIdentifierHook} closure produced by
16
+ * {@linkcode buildIsIdentifierHook}.
17
+ *
18
+ * Behavioural contract (ADR-021 Decision 1, additive-enrichment invariant):
19
+ * - Every name in the index is observed in the corpus as `$Name`.
20
+ * - The index is purely additive: more entries → more silenced phrases,
21
+ * never more diagnostics.
22
+ *
23
+ * Scope note: this is the pragmatic minimal resolver leg per issue #502.
24
+ * The formal `MSL-M050`/`MSL-M051` entity-resolution model (definition
25
+ * vs. use, typed identifiers, profile Aliases) is deferred to a
26
+ * follow-up story — the closure body changes but the hook signature
27
+ * stays the same.
28
+ */
29
+ export function buildIdentifierIndex(entries) {
30
+ const out = new Set();
31
+ for (const entry of entries) {
32
+ for (const token of entry.bodyTokens) {
33
+ if (token.kind !== "entity-ref")
34
+ continue;
35
+ // `token.text` is the full `$Identifier` form; strip the leading `$`.
36
+ out.add(token.text.slice(1));
37
+ }
38
+ }
39
+ return out;
40
+ }
41
+ /**
42
+ * Build the {@linkcode IsIdentifierHook} closure from a precomputed
43
+ * index. Separated from {@linkcode buildIdentifierIndex} so the index
44
+ * can be computed once per `runLint` invocation and reused across
45
+ * every in-scope entry.
46
+ */
47
+ export function buildIsIdentifierHook(index) {
48
+ return (phrase) => index.has(phrase);
49
+ }
10
50
  /** RFC 2119 modal verbs + EARS leading-clause keywords that must never
11
51
  * trigger Q500 mid-sentence. Sentence-initial exclusion is handled
12
52
  * separately by position; this set catches keyword uses elsewhere. */
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUjD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAS/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAKlD;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAoBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0EvE"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAUjD,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAY/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgB9C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAKlD;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,yEAAyE;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAoBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA8EvE"}
@@ -12,7 +12,7 @@ import { runLexiconRules } from "./rules/lexicon.js";
12
12
  import { runStructRules } from "./rules/struct.js";
13
13
  import { hasRationale, parseDisableValue, runSuppressionRules, runUnusedSuppressionCheck, } from "./rules/suppression.js";
14
14
  import { buildGlossaryIndex } from "./glossary.js";
15
- import { runXrefRules } from "./rules/xref.js";
15
+ import { buildIdentifierIndex, buildIsIdentifierHook, runXrefRules, } from "./rules/xref.js";
16
16
  import { runEarsRules } from "./rules/ears.js";
17
17
  import { runModalSentenceRules } from "./rules/modal_sentence.js";
18
18
  import { runIncoseSentenceRules } from "./rules/incose_sentence.js";
@@ -90,7 +90,11 @@ export async function runLint(options) {
90
90
  const { entries } = options;
91
91
  const allow = options.capitalizedAllow ?? loadLexicon("capitalized-allow");
92
92
  const glossary = await buildGlossaryIndex(entries, options.readFile ?? (() => Promise.resolve(undefined)), options.glossaryFilePaths ?? []);
93
- const isIdHook = () => false;
93
+ // Corpus-scan resolver leg (issue #502, ADR-021 Decision 1). Built once
94
+ // per invocation; reused across every in-scope entry. Honors the
95
+ // additive-enrichment invariant — Q500 fires *less* as the resolver
96
+ // grows, never *more*.
97
+ const isIdHook = buildIsIdentifierHook(buildIdentifierIndex(entries));
94
98
  // Steps 1–9: collect diagnostics keyed by entry
95
99
  const inScopeDiags = new Map();
96
100
  for (const entry of entries) {
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @module core/lint/score_text
3
+ *
4
+ * Score a single piece of requirement prose using the PA-3 lint
5
+ * pipeline. Wraps the input text in a synthetic `Entry` (type
6
+ * `Requirement`, body = text, bodyAst = parsed) and runs `runLint`
7
+ * against a one-entry corpus.
8
+ *
9
+ * Two non-obvious wrapping choices:
10
+ * - `bodyAst` is populated via `buildBodyAst(text)`. Most PA-3
11
+ * rules (modal, EARS, INCOSE, passive, lexicon) walk `bodyAst`,
12
+ * not the raw `body` string — without the AST, ~95% of the
13
+ * rule catalog silently no-ops.
14
+ * - `title` is set to the resolved id. Q400 (`struct-title-length`)
15
+ * fires when title length is outside [3, 120]; reusing the id
16
+ * (always ≥ 3 chars) keeps Q400 silent so the score reflects
17
+ * prose quality, not the absence of an authored title.
18
+ *
19
+ * Corpus-dependent rules (Q500 xref-glossary, xref-undefined,
20
+ * suppression hygiene) self-skip because there is nothing for them
21
+ * to cross-reference on a one-entry corpus. Note specifically:
22
+ * `bodyTokens` is left empty here, which means any `$Identifier`
23
+ * style entity references inside `text` are NOT extracted and so
24
+ * Q500 cannot fire on them in either direction. External requirement
25
+ * prose (DOORS / Word / PDF) does not use MarkSpec's `$Identifier`
26
+ * syntax, so this is the right trade for v1; a caller that does want
27
+ * `$Identifier` resolution should run the prose through `parseFile`
28
+ * to get a real entry and use the normal `runLint` path instead.
29
+ */
30
+ import type { LintDiagnostic } from "./types.js";
31
+ import type { RuleContribution } from "./score.js";
32
+ /** Options for {@linkcode scoreText}. */
33
+ export interface ScoreTextOptions {
34
+ /**
35
+ * Caller-supplied identifier carried through to the result so a
36
+ * batch caller can correlate inputs and outputs. Defaults to
37
+ * `"EXT_0001"` when absent or empty.
38
+ */
39
+ readonly id?: string;
40
+ }
41
+ /**
42
+ * Result returned by {@linkcode scoreText}.
43
+ *
44
+ * `warningCount + infoCount === diagnostics.length` by convention:
45
+ * every PA-3 rule emits `warning` or `info` only. The `Severity` type
46
+ * permits `error`, but no current rule produces one; if that ever
47
+ * changes the partition will need a third counter.
48
+ */
49
+ export interface ScoreTextResult {
50
+ readonly id: string;
51
+ /** Sum of `weight × occurrences` across all firings. */
52
+ readonly score: number;
53
+ /** Number of diagnostics with severity `"warning"`. */
54
+ readonly warningCount: number;
55
+ /** Number of diagnostics with severity `"info"`. */
56
+ readonly infoCount: number;
57
+ /** Sorted by weight DESC, code ASC. */
58
+ readonly contributions: readonly RuleContribution[];
59
+ /** Full lint diagnostics, in pipeline order. */
60
+ readonly diagnostics: readonly LintDiagnostic[];
61
+ }
62
+ /**
63
+ * Score a single piece of requirement prose against the PA-3 rule
64
+ * catalog. See module doc for the wrapping strategy.
65
+ */
66
+ export declare function scoreText(text: string, opts?: ScoreTextOptions): Promise<ScoreTextResult>;
67
+ //# sourceMappingURL=score_text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score_text.d.ts","sourceRoot":"","sources":["../../src/lint/score_text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAKnD,yCAAyC;AACzC,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,eAAe,CAAC,CAqC1B"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @module core/lint/score_text
3
+ *
4
+ * Score a single piece of requirement prose using the PA-3 lint
5
+ * pipeline. Wraps the input text in a synthetic `Entry` (type
6
+ * `Requirement`, body = text, bodyAst = parsed) and runs `runLint`
7
+ * against a one-entry corpus.
8
+ *
9
+ * Two non-obvious wrapping choices:
10
+ * - `bodyAst` is populated via `buildBodyAst(text)`. Most PA-3
11
+ * rules (modal, EARS, INCOSE, passive, lexicon) walk `bodyAst`,
12
+ * not the raw `body` string — without the AST, ~95% of the
13
+ * rule catalog silently no-ops.
14
+ * - `title` is set to the resolved id. Q400 (`struct-title-length`)
15
+ * fires when title length is outside [3, 120]; reusing the id
16
+ * (always ≥ 3 chars) keeps Q400 silent so the score reflects
17
+ * prose quality, not the absence of an authored title.
18
+ *
19
+ * Corpus-dependent rules (Q500 xref-glossary, xref-undefined,
20
+ * suppression hygiene) self-skip because there is nothing for them
21
+ * to cross-reference on a one-entry corpus. Note specifically:
22
+ * `bodyTokens` is left empty here, which means any `$Identifier`
23
+ * style entity references inside `text` are NOT extracted and so
24
+ * Q500 cannot fire on them in either direction. External requirement
25
+ * prose (DOORS / Word / PDF) does not use MarkSpec's `$Identifier`
26
+ * syntax, so this is the right trade for v1; a caller that does want
27
+ * `$Identifier` resolution should run the prose through `parseFile`
28
+ * to get a real entry and use the normal `runLint` path instead.
29
+ */
30
+ import { makeDisplayId } from "../model/mod.js";
31
+ import { buildBodyAst } from "../ast/build.js";
32
+ import { runLint } from "./runner.js";
33
+ const SYNTHETIC_FILE = "<scoreText>";
34
+ const DEFAULT_ID = "EXT_0001";
35
+ /**
36
+ * Score a single piece of requirement prose against the PA-3 rule
37
+ * catalog. See module doc for the wrapping strategy.
38
+ */
39
+ export async function scoreText(text, opts) {
40
+ const id = typeof opts?.id === "string" && opts.id.length > 0
41
+ ? opts.id
42
+ : DEFAULT_ID;
43
+ const entry = {
44
+ displayId: makeDisplayId(id),
45
+ title: id,
46
+ body: text,
47
+ bodyAst: buildBodyAst(text),
48
+ rawAttributes: [],
49
+ typedAttributes: new Map(),
50
+ type: "Requirement",
51
+ shape: "Authored",
52
+ location: { file: SYNTHETIC_FILE, line: 1, column: 1 },
53
+ source: { kind: "markdown" },
54
+ bodyTokens: [],
55
+ };
56
+ const lintResult = await runLint({ entries: [entry] });
57
+ let warningCount = 0;
58
+ let infoCount = 0;
59
+ for (const d of lintResult.diagnostics) {
60
+ if (d.severity === "warning")
61
+ warningCount++;
62
+ else if (d.severity === "info")
63
+ infoCount++;
64
+ }
65
+ const entryScore = lintResult.score.perEntry[0];
66
+ return {
67
+ id,
68
+ score: entryScore?.score ?? 0,
69
+ warningCount,
70
+ infoCount,
71
+ contributions: entryScore?.contributions ?? [],
72
+ diagnostics: lintResult.diagnostics,
73
+ };
74
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module core/lock/compare
3
+ *
4
+ * Pure comparison utilities for lockfile-related version data.
5
+ * Consumed by the LSP extension (slice C) and `markspec doctor`
6
+ * (slice F) to surface skew between the project's declared
7
+ * `[meta.toolchain].min-version` floor and the running CLI's release
8
+ * version.
9
+ *
10
+ * Keeping this in the lock module makes the comparison the SSOT —
11
+ * downstream consumers import one function rather than reinventing
12
+ * parsing + comparison logic each time.
13
+ */
14
+ /**
15
+ * Returns `true` when `actualVersion` is strictly below `floor`,
16
+ * compared as `(major, minor)` tuples. The patch component of
17
+ * `actualVersion` is ignored.
18
+ *
19
+ * Returns `false` when `floor` is `undefined` (project declares no
20
+ * floor) or when `actualVersion >= floor`.
21
+ *
22
+ * Throws `Error` if either argument is not in the expected grammar.
23
+ * Callers should pass values that originated from the parsed lockfile
24
+ * model (`LockfileToolchain.minVersion`, already validated at parse
25
+ * time) and from `VERSION` (a known-good semver constant).
26
+ *
27
+ * @example
28
+ * isBelowFloor("0.6.1", "0.6") // false
29
+ * isBelowFloor("0.5.99", "0.6") // true
30
+ * isBelowFloor("0.7.0", "0.6") // false
31
+ * isBelowFloor("0.6.1", undefined) // false (no floor)
32
+ */
33
+ export declare function isBelowFloor(actualVersion: string, floor: string | undefined): boolean;
34
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/lock/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAmBT"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @module core/lock/compare
3
+ *
4
+ * Pure comparison utilities for lockfile-related version data.
5
+ * Consumed by the LSP extension (slice C) and `markspec doctor`
6
+ * (slice F) to surface skew between the project's declared
7
+ * `[meta.toolchain].min-version` floor and the running CLI's release
8
+ * version.
9
+ *
10
+ * Keeping this in the lock module makes the comparison the SSOT —
11
+ * downstream consumers import one function rather than reinventing
12
+ * parsing + comparison logic each time.
13
+ */
14
+ /**
15
+ * Strict MAJOR.MINOR grammar — must match the parser's MIN_VERSION_RE.
16
+ * Used to validate the `floor` argument.
17
+ */
18
+ const FLOOR_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
19
+ /**
20
+ * Prefix-match grammar for the running binary's VERSION string. Accepts
21
+ * standard semver (MAJOR.MINOR.PATCH and optional pre-release/build),
22
+ * extracting only the major + minor pair.
23
+ */
24
+ const ACTUAL_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.|[-+]|$)/;
25
+ /**
26
+ * Returns `true` when `actualVersion` is strictly below `floor`,
27
+ * compared as `(major, minor)` tuples. The patch component of
28
+ * `actualVersion` is ignored.
29
+ *
30
+ * Returns `false` when `floor` is `undefined` (project declares no
31
+ * floor) or when `actualVersion >= floor`.
32
+ *
33
+ * Throws `Error` if either argument is not in the expected grammar.
34
+ * Callers should pass values that originated from the parsed lockfile
35
+ * model (`LockfileToolchain.minVersion`, already validated at parse
36
+ * time) and from `VERSION` (a known-good semver constant).
37
+ *
38
+ * @example
39
+ * isBelowFloor("0.6.1", "0.6") // false
40
+ * isBelowFloor("0.5.99", "0.6") // true
41
+ * isBelowFloor("0.7.0", "0.6") // false
42
+ * isBelowFloor("0.6.1", undefined) // false (no floor)
43
+ */
44
+ export function isBelowFloor(actualVersion, floor) {
45
+ if (floor === undefined)
46
+ return false;
47
+ const f = FLOOR_RE.exec(floor);
48
+ if (!f) {
49
+ throw new Error(`isBelowFloor: invalid floor ${JSON.stringify(floor)}`);
50
+ }
51
+ const a = ACTUAL_RE.exec(actualVersion);
52
+ if (!a) {
53
+ throw new Error(`isBelowFloor: invalid actualVersion ${JSON.stringify(actualVersion)}`);
54
+ }
55
+ const fMajor = parseInt(f[1], 10);
56
+ const fMinor = parseInt(f[2], 10);
57
+ const aMajor = parseInt(a[1], 10);
58
+ const aMinor = parseInt(a[2], 10);
59
+ if (aMajor < fMajor)
60
+ return true;
61
+ if (aMajor > fMajor)
62
+ return false;
63
+ return aMinor < fMinor;
64
+ }
package/esm/lock/mod.d.ts CHANGED
@@ -5,11 +5,12 @@
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, Upstream, UpstreamProfile, UpstreamReference, UpstreamRegistry, } from "./model.js";
8
+ export type { BoundEntry, BoundEntryBinding, GeneratedCache, LockedAttributes, 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";
12
12
  export type { ParseLockfileResult } from "./parser.js";
13
+ export { isBelowFloor } from "./compare.js";
13
14
  export { checkDrift } from "./check.js";
14
15
  export { sha256Bytes, sha256String } from "./hash.js";
15
16
  export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
@@ -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,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;A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BAAsB,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,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"}
package/esm/lock/mod.js CHANGED
@@ -8,6 +8,7 @@
8
8
  export { LOCKFILE_SCHEMA_VERSION } from "./model.js";
9
9
  export { serializeLockfile } from "./serializer.js";
10
10
  export { parseLockfile } from "./parser.js";
11
+ export { isBelowFloor } from "./compare.js";
11
12
  export { checkDrift } from "./check.js";
12
13
  export { sha256Bytes, sha256String } from "./hash.js";
13
14
  export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
@@ -62,11 +62,24 @@ export interface GeneratedCache {
62
62
  readonly edgesHash: string;
63
63
  readonly edgesCount: number;
64
64
  }
65
+ /** Toolchain requirements declared by the project. */
66
+ export interface LockfileToolchain {
67
+ /**
68
+ * Minimum required markspec release version at minor granularity
69
+ * (e.g. "0.6" means "any 0.6.x or later"). Compared as a
70
+ * (major, minor) tuple against the running binary's VERSION.
71
+ * Format: /^(0|[1-9]\d*)\.(0|[1-9]\d*)$/ — exactly two components,
72
+ * no leading zeros, no prefix, no operator.
73
+ */
74
+ readonly minVersion: string;
75
+ }
65
76
  /** Lockfile metadata. */
66
77
  export interface LockfileMeta {
67
78
  readonly markspecSchema: number;
68
79
  /** Timestamp the lockfile was written, RFC 3339 UTC (e.g. "2026-05-25T12:00:00Z"). */
69
80
  readonly lockedAt: string;
81
+ /** Toolchain requirements; omitted when no floor is declared. */
82
+ readonly toolchain?: LockfileToolchain;
70
83
  }
71
84
  /** Top-level lockfile model. */
72
85
  export interface Lockfile {
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lock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Ac,EAAE,cAAc,CAAC;CACzC;AAED,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC"}
@@ -8,6 +8,9 @@
8
8
  * - MSL-L001 — malformed TOML or missing required field
9
9
  * - MSL-L002 — lockfile schema is newer than this binary supports
10
10
  * - MSL-L003 — lockfile schema is unrecognised (< 1)
11
+ * - MSL-L030 — `[meta.toolchain].min-version` is malformed
12
+ * - MSL-L031 — `[meta.toolchain].min-version` is not a string
13
+ * - MSL-L032 — `meta.toolchain` is a scalar instead of a table
11
14
  */
12
15
  import type { Diagnostic } from "../model/mod.js";
13
16
  import { type Lockfile } from "./model.js";
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/lock/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AAEpB,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CA+L/D"}
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/lock/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAGL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAUpB,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAkO/D"}