@driftsys/markspec 0.10.1 → 0.10.2
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/esm/collect/mod.d.ts +34 -0
- package/esm/collect/mod.d.ts.map +1 -0
- package/esm/collect/mod.js +37 -0
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +29 -1
- package/esm/gates/mod.d.ts +82 -0
- package/esm/gates/mod.d.ts.map +1 -0
- package/esm/gates/mod.js +139 -0
- package/esm/lint/runner.d.ts +26 -3
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +39 -9
- package/esm/lock/edge_drift.d.ts +31 -0
- package/esm/lock/edge_drift.d.ts.map +1 -0
- package/esm/lock/edge_drift.js +29 -0
- package/esm/lock/mod.d.ts +2 -0
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +1 -0
- package/esm/mod.d.ts +11 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +10 -4
- package/esm/model/mod.d.ts +8 -0
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +10 -0
- package/esm/model/profile.d.ts +8 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +38 -11
- package/esm/profile/delivered.d.ts +22 -1
- package/esm/profile/delivered.d.ts.map +1 -1
- package/esm/profile/delivered.js +44 -1
- package/esm/profile/merge.js +1 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +2 -3
- package/esm/util/fence.d.ts +8 -0
- package/esm/util/fence.d.ts.map +1 -1
- package/esm/util/fence.js +22 -0
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +14 -12
- package/package.json +1 -1
- package/script/collect/mod.d.ts +34 -0
- package/script/collect/mod.d.ts.map +1 -0
- package/script/collect/mod.js +40 -0
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +29 -1
- package/script/gates/mod.d.ts +82 -0
- package/script/gates/mod.d.ts.map +1 -0
- package/script/gates/mod.js +144 -0
- package/script/lint/runner.d.ts +26 -3
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +39 -9
- package/script/lock/edge_drift.d.ts +31 -0
- package/script/lock/edge_drift.d.ts.map +1 -0
- package/script/lock/edge_drift.js +32 -0
- package/script/lock/mod.d.ts +2 -0
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +3 -1
- package/script/mod.d.ts +11 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +45 -29
- package/script/model/mod.d.ts +8 -0
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +11 -0
- package/script/model/profile.d.ts +8 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +38 -11
- package/script/profile/delivered.d.ts +22 -1
- package/script/profile/delivered.d.ts.map +1 -1
- package/script/profile/delivered.js +45 -1
- package/script/profile/merge.js +1 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +2 -3
- package/script/util/fence.d.ts +8 -0
- package/script/util/fence.d.ts.map +1 -1
- package/script/util/fence.js +23 -0
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +14 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/collect
|
|
3
|
+
*
|
|
4
|
+
* Project-entry collection: discover every MarkSpec-relevant file under a
|
|
5
|
+
* root and parse it into a flat `Entry[]`. The single source of truth for
|
|
6
|
+
* "the set of entries whose trace edges the lockfile pins" — shared by
|
|
7
|
+
* `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
|
|
8
|
+
* so they cannot disagree on which files count. Previously each of those
|
|
9
|
+
* commands hand-rolled the same discover→parse loop (a `cli/commands/lock.ts`
|
|
10
|
+
* private helper the others reached into), which had to stay byte-identical
|
|
11
|
+
* by hand or the lockfile edge-hash comparison would drift spuriously.
|
|
12
|
+
*/
|
|
13
|
+
import type { Entry } from "../model/mod.js";
|
|
14
|
+
import { type DiscoveryIO } from "../discovery/mod.js";
|
|
15
|
+
/** Options for {@linkcode collectProjectEntries}. */
|
|
16
|
+
export interface CollectOptions {
|
|
17
|
+
/** Gitignore-syntax patterns (e.g. `project.yaml` `exclude:`), anchored at
|
|
18
|
+
* `root`. Applied after `.gitignore` rules. Defaults to none. */
|
|
19
|
+
readonly exclude?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Walk `root` via {@linkcode discoverFiles} — relying on its default
|
|
23
|
+
* extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
|
|
24
|
+
* depends on — and parse each discovered file, returning the flattened
|
|
25
|
+
* entry list. Unreadable files are skipped. Parse diagnostics are not
|
|
26
|
+
* surfaced here: this collector exists to give the lockfile pinner and its
|
|
27
|
+
* checkers one definition of the file set; callers that need diagnostics
|
|
28
|
+
* re-parse.
|
|
29
|
+
*
|
|
30
|
+
* @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
|
|
31
|
+
* entry points pass a Deno-backed implementation).
|
|
32
|
+
*/
|
|
33
|
+
export declare function collectProjectEntries(root: string, io: DiscoveryIO, opts?: CollectOptions): Promise<Entry[]>;
|
|
34
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/collect/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B;qEACiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,KAAK,EAAE,CAAC,CASlB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/collect
|
|
3
|
+
*
|
|
4
|
+
* Project-entry collection: discover every MarkSpec-relevant file under a
|
|
5
|
+
* root and parse it into a flat `Entry[]`. The single source of truth for
|
|
6
|
+
* "the set of entries whose trace edges the lockfile pins" — shared by
|
|
7
|
+
* `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
|
|
8
|
+
* so they cannot disagree on which files count. Previously each of those
|
|
9
|
+
* commands hand-rolled the same discover→parse loop (a `cli/commands/lock.ts`
|
|
10
|
+
* private helper the others reached into), which had to stay byte-identical
|
|
11
|
+
* by hand or the lockfile edge-hash comparison would drift spuriously.
|
|
12
|
+
*/
|
|
13
|
+
import { discoverFiles } from "../discovery/mod.js";
|
|
14
|
+
import { parseFile } from "../parser/mod.js";
|
|
15
|
+
/**
|
|
16
|
+
* Walk `root` via {@linkcode discoverFiles} — relying on its default
|
|
17
|
+
* extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
|
|
18
|
+
* depends on — and parse each discovered file, returning the flattened
|
|
19
|
+
* entry list. Unreadable files are skipped. Parse diagnostics are not
|
|
20
|
+
* surfaced here: this collector exists to give the lockfile pinner and its
|
|
21
|
+
* checkers one definition of the file set; callers that need diagnostics
|
|
22
|
+
* re-parse.
|
|
23
|
+
*
|
|
24
|
+
* @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
|
|
25
|
+
* entry points pass a Deno-backed implementation).
|
|
26
|
+
*/
|
|
27
|
+
export async function collectProjectEntries(root, io, opts = {}) {
|
|
28
|
+
const out = [];
|
|
29
|
+
for await (const file of discoverFiles(root, io, { exclude: opts.exclude })) {
|
|
30
|
+
const content = await io.readFile(file);
|
|
31
|
+
if (content === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
const result = await parseFile(content, { file });
|
|
34
|
+
out.push(...result.entries);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc/D;AAmSD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC;CAC/C;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AA2BD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAc/D;AAmSD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC;CAC/C;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AA2BD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAgQd;AA4DD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAmB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CA2Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAcR;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2B5C"}
|
package/esm/formatter/mod.js
CHANGED
|
@@ -412,11 +412,39 @@ export function format(markdown, options) {
|
|
|
412
412
|
for (const entry of sorted) {
|
|
413
413
|
const indent = (entry.location.column - 1) + 2;
|
|
414
414
|
let attrs = [...entry.rawAttributes];
|
|
415
|
+
const titleLineIdx = entry.location.line - 1;
|
|
416
|
+
// #686: a title that soft-wraps onto extra physical lines is a single
|
|
417
|
+
// Markdown paragraph, but the line-based passes here and in
|
|
418
|
+
// `emitBodyViaAst` (which takes `titleLineIdx + 1` as the body start)
|
|
419
|
+
// assume the title occupies one physical line. Collapse the wrapped
|
|
420
|
+
// title onto a single line so Id stamping and body splicing land on the
|
|
421
|
+
// right lines and the continuation is not clobbered or dropped. The
|
|
422
|
+
// parser already folded the title text on the model side; this repairs
|
|
423
|
+
// the raw buffer to match. The scan runs from the title line to the
|
|
424
|
+
// first blank line (the title/body separator), bounded above by the
|
|
425
|
+
// attribute block so a malformed entry with no blank line before its
|
|
426
|
+
// trailer cannot swallow it.
|
|
427
|
+
if (titleLineIdx >= 0 && titleLineIdx < lines.length) {
|
|
428
|
+
const attrRange = findAttributeBlockRange(lines, entry.location.line, indent);
|
|
429
|
+
const limit = attrRange ? attrRange.start : lines.length;
|
|
430
|
+
let titleEnd = titleLineIdx;
|
|
431
|
+
while (titleEnd + 1 < limit && lines[titleEnd + 1].trim() !== "") {
|
|
432
|
+
titleEnd++;
|
|
433
|
+
}
|
|
434
|
+
if (titleEnd > titleLineIdx) {
|
|
435
|
+
const collapsed = lines[titleLineIdx].replace(/\s+$/, "") + " " +
|
|
436
|
+
lines
|
|
437
|
+
.slice(titleLineIdx + 1, titleEnd + 1)
|
|
438
|
+
.map((l) => l.trim())
|
|
439
|
+
.join(" ");
|
|
440
|
+
lines.splice(titleLineIdx, titleEnd - titleLineIdx + 1, collapsed);
|
|
441
|
+
changed = true;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
415
444
|
// Title-line bullet canonicalisation per spec §3.2: rewrite `*`
|
|
416
445
|
// or `+` to `-`. The list-item position from the parser is the
|
|
417
446
|
// line carrying the bullet marker; we only touch the marker
|
|
418
447
|
// character itself, leaving the rest of the title alone.
|
|
419
|
-
const titleLineIdx = entry.location.line - 1;
|
|
420
448
|
if (titleLineIdx >= 0 && titleLineIdx < lines.length) {
|
|
421
449
|
const titleLine = lines[titleLineIdx];
|
|
422
450
|
const markerCol = entry.location.column - 1;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gates
|
|
3
|
+
*
|
|
4
|
+
* Composite-`check` gate stages (ADR-027). Each function is a pure,
|
|
5
|
+
* independently-testable transformation from already-gathered inputs to a
|
|
6
|
+
* `Diagnostic[]`; the CLI `check` command orchestrates them (gather inputs →
|
|
7
|
+
* call stages → merge diagnostics → render) and owns the scope policy that
|
|
8
|
+
* decides whether they run at all (project-wide only).
|
|
9
|
+
*
|
|
10
|
+
* Extracted from `cli/commands/check.ts` (#659) so the diagnostic-producing
|
|
11
|
+
* logic lives in `core` — composable, unit-testable in isolation, and reusable
|
|
12
|
+
* by future surfaces — rather than inline in the command body. The command
|
|
13
|
+
* keeps the I/O it must do (loading the Markdown prose formatter, reading
|
|
14
|
+
* `markspec.lock`) and feeds the results in.
|
|
15
|
+
*
|
|
16
|
+
* `gates` is a top-level composition layer: it depends on `formatter`,
|
|
17
|
+
* `parser`, `refs`, `lock`, and `lint`, and nothing in those depends back on
|
|
18
|
+
* it — no cycle.
|
|
19
|
+
*/
|
|
20
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
21
|
+
import type { ProseFormatter } from "../formatter/dprint.js";
|
|
22
|
+
import { type LockEdge, type ParseLockfileResult } from "../lock/mod.js";
|
|
23
|
+
/**
|
|
24
|
+
* Format-drift gate — the `MSL-F010` (formatter drift) and `MSL-F011`
|
|
25
|
+
* (reference-canonicalization drift) findings.
|
|
26
|
+
*
|
|
27
|
+
* Runs the SAME `format() → parse → canonicalizeRefs` sequence `markspec fmt`
|
|
28
|
+
* performs, from the same exclude-aware corpus, so bare `check` and
|
|
29
|
+
* `fmt --check` never disagree on what "formatted" means. `MSL-F010` is pure
|
|
30
|
+
* formatter drift; `MSL-F011` is reference-canonicalization drift (a ULID or
|
|
31
|
+
* stale display ID `fmt` would rewrite) — kept distinct so the author knows
|
|
32
|
+
* which fmt concern fired. Markdown only — `markspec fmt` never rewrites source
|
|
33
|
+
* files, so the caller passes only Markdown file contents.
|
|
34
|
+
*
|
|
35
|
+
* @param mdContents Markdown file path → current on-disk content.
|
|
36
|
+
* @param entries The full parsed entry set (project + corpus). Only
|
|
37
|
+
* project-owned entries (`!e.origin`) build the reference index
|
|
38
|
+
* `canonicalizeRefs` heals against — `markspec fmt` is corpus-blind (ADR-030).
|
|
39
|
+
* @param ledger The lockfile's `[[edge]]` ULID ledger (`lockfile.edges`, or
|
|
40
|
+
* `[]` when there is no lockfile), threaded into `canonicalizeRefs`.
|
|
41
|
+
* @param formatMarkdownProse The loaded ADR-029 whole-document Markdown
|
|
42
|
+
* formatter, or `undefined` to degrade to entry-only formatting.
|
|
43
|
+
*/
|
|
44
|
+
export declare function fmtDriftGate(mdContents: ReadonlyMap<string, string>, entries: readonly Entry[], ledger: readonly LockEdge[], formatMarkdownProse: ProseFormatter | undefined): Promise<Diagnostic[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Lockfile-drift gate — the `MSL-L212` offline traceability-edge drift finding.
|
|
47
|
+
*
|
|
48
|
+
* A malformed lockfile surfaces the parser's own diagnostics unchanged. An
|
|
49
|
+
* intact lockfile is compared against the current graph's canonical edge hash.
|
|
50
|
+
* Offline by design — upstream resolution (network) stays in
|
|
51
|
+
* `markspec lock --check`.
|
|
52
|
+
*
|
|
53
|
+
* Corpus-blind by design: the lockfile is not corpus-aware yet (ADR-030 defers
|
|
54
|
+
* lockfile integration), so `markspec lock` never counts corpus edges. Counting
|
|
55
|
+
* them here would raise an `MSL-L212` drift error that `markspec lock` can never
|
|
56
|
+
* fix — a consumer gate must not fail on upstream content the consumer cannot
|
|
57
|
+
* re-lock. The gate therefore filters to project-owned entries (`!e.origin`),
|
|
58
|
+
* mirroring `markspec lock`.
|
|
59
|
+
*
|
|
60
|
+
* @param lockParse The parsed `markspec.lock` (already read from disk).
|
|
61
|
+
* @param lockPath Absolute path to `markspec.lock`, used as the diagnostic
|
|
62
|
+
* location so JSON consumers that group by `location.file` keep the finding.
|
|
63
|
+
* @param entries The full parsed entry set; corpus entries are filtered out.
|
|
64
|
+
*/
|
|
65
|
+
export declare function lockfileDriftGate(lockParse: ParseLockfileResult, lockPath: string, entries: readonly Entry[]): Promise<Diagnostic[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Prose-lint gate — the advisory `MSL-Q` prose-analysis findings, projected to
|
|
68
|
+
* plain {@linkcode Diagnostic}s.
|
|
69
|
+
*
|
|
70
|
+
* Pass the FULL entry set (project + corpus) and the active profile.
|
|
71
|
+
* {@linkcode runLint} excludes corpus entries from its output but keeps them in
|
|
72
|
+
* the glossary / `$Identifier` indexes, so a corpus-defined term still silences
|
|
73
|
+
* Q500 in project prose (ADR-030 §D4). The profile threads into `isProseScope`
|
|
74
|
+
* so profile-typed entries are scoped (#675).
|
|
75
|
+
*
|
|
76
|
+
* `runLint`'s {@linkcode LintDiagnostic} carries `slug`/`group`/`score` fields
|
|
77
|
+
* that must not leak into `check`'s stable JSON schema — the result is projected
|
|
78
|
+
* to plain {@linkcode Diagnostic}. `runLint`'s `readFile` option (for glossary
|
|
79
|
+
* file indexing) is not needed here: `check` passes no `glossaryFilePaths`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function proseLintGate(entries: readonly Entry[], profile: EffectiveProfile | undefined): Promise<Diagnostic[]>;
|
|
82
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/gates/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,mBAAmB,EAAE,cAAc,GAAG,SAAS,GAC9C,OAAO,CAAC,UAAU,EAAE,CAAC,CAuCvB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC,CAiBvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,SAAS,GACpC,OAAO,CAAC,UAAU,EAAE,CAAC,CAQvB"}
|
package/esm/gates/mod.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/gates
|
|
3
|
+
*
|
|
4
|
+
* Composite-`check` gate stages (ADR-027). Each function is a pure,
|
|
5
|
+
* independently-testable transformation from already-gathered inputs to a
|
|
6
|
+
* `Diagnostic[]`; the CLI `check` command orchestrates them (gather inputs →
|
|
7
|
+
* call stages → merge diagnostics → render) and owns the scope policy that
|
|
8
|
+
* decides whether they run at all (project-wide only).
|
|
9
|
+
*
|
|
10
|
+
* Extracted from `cli/commands/check.ts` (#659) so the diagnostic-producing
|
|
11
|
+
* logic lives in `core` — composable, unit-testable in isolation, and reusable
|
|
12
|
+
* by future surfaces — rather than inline in the command body. The command
|
|
13
|
+
* keeps the I/O it must do (loading the Markdown prose formatter, reading
|
|
14
|
+
* `markspec.lock`) and feeds the results in.
|
|
15
|
+
*
|
|
16
|
+
* `gates` is a top-level composition layer: it depends on `formatter`,
|
|
17
|
+
* `parser`, `refs`, `lock`, and `lint`, and nothing in those depends back on
|
|
18
|
+
* it — no cycle.
|
|
19
|
+
*/
|
|
20
|
+
import { format } from "../formatter/mod.js";
|
|
21
|
+
import { parseFile } from "../parser/mod.js";
|
|
22
|
+
import { buildRefIndex, canonicalizeRefs } from "../refs/mod.js";
|
|
23
|
+
import { detectOfflineEdgeDrift, } from "../lock/mod.js";
|
|
24
|
+
import { runLint } from "../lint/mod.js";
|
|
25
|
+
/**
|
|
26
|
+
* Format-drift gate — the `MSL-F010` (formatter drift) and `MSL-F011`
|
|
27
|
+
* (reference-canonicalization drift) findings.
|
|
28
|
+
*
|
|
29
|
+
* Runs the SAME `format() → parse → canonicalizeRefs` sequence `markspec fmt`
|
|
30
|
+
* performs, from the same exclude-aware corpus, so bare `check` and
|
|
31
|
+
* `fmt --check` never disagree on what "formatted" means. `MSL-F010` is pure
|
|
32
|
+
* formatter drift; `MSL-F011` is reference-canonicalization drift (a ULID or
|
|
33
|
+
* stale display ID `fmt` would rewrite) — kept distinct so the author knows
|
|
34
|
+
* which fmt concern fired. Markdown only — `markspec fmt` never rewrites source
|
|
35
|
+
* files, so the caller passes only Markdown file contents.
|
|
36
|
+
*
|
|
37
|
+
* @param mdContents Markdown file path → current on-disk content.
|
|
38
|
+
* @param entries The full parsed entry set (project + corpus). Only
|
|
39
|
+
* project-owned entries (`!e.origin`) build the reference index
|
|
40
|
+
* `canonicalizeRefs` heals against — `markspec fmt` is corpus-blind (ADR-030).
|
|
41
|
+
* @param ledger The lockfile's `[[edge]]` ULID ledger (`lockfile.edges`, or
|
|
42
|
+
* `[]` when there is no lockfile), threaded into `canonicalizeRefs`.
|
|
43
|
+
* @param formatMarkdownProse The loaded ADR-029 whole-document Markdown
|
|
44
|
+
* formatter, or `undefined` to degrade to entry-only formatting.
|
|
45
|
+
*/
|
|
46
|
+
export async function fmtDriftGate(mdContents, entries, ledger, formatMarkdownProse) {
|
|
47
|
+
const diagnostics = [];
|
|
48
|
+
// Corpus-blind by design (ADR-030): `markspec fmt` never loads the delivered
|
|
49
|
+
// corpus, so it can only canonicalize references into project-owned entries.
|
|
50
|
+
// Building the heal index over the full set (including corpus) would flag an
|
|
51
|
+
// MSL-F011 drift that `fmt` can never fix — a permanently red gate for any
|
|
52
|
+
// consumer using a delivered corpus. Filter to `!e.origin`, mirroring
|
|
53
|
+
// lockfileDriftGate.
|
|
54
|
+
const refIndex = buildRefIndex(entries.filter((e) => !e.origin));
|
|
55
|
+
for (const [filePath, content] of mdContents) {
|
|
56
|
+
const formatted = format(content, {
|
|
57
|
+
file: filePath,
|
|
58
|
+
formatMarkdownProse,
|
|
59
|
+
});
|
|
60
|
+
if (formatted.changed) {
|
|
61
|
+
diagnostics.push({
|
|
62
|
+
code: "MSL-F010",
|
|
63
|
+
severity: "error",
|
|
64
|
+
message: "file is not formatted (run `markspec fmt`)",
|
|
65
|
+
location: { file: filePath, line: 1, column: 1 },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const parsed = await parseFile(formatted.output, { file: filePath });
|
|
69
|
+
const refResult = canonicalizeRefs(formatted.output, parsed.entries, refIndex, ledger);
|
|
70
|
+
if (refResult.changed) {
|
|
71
|
+
diagnostics.push({
|
|
72
|
+
code: "MSL-F011",
|
|
73
|
+
severity: "error",
|
|
74
|
+
message: "references are not canonical (run `markspec fmt`)",
|
|
75
|
+
location: { file: filePath, line: 1, column: 1 },
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return diagnostics;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lockfile-drift gate — the `MSL-L212` offline traceability-edge drift finding.
|
|
83
|
+
*
|
|
84
|
+
* A malformed lockfile surfaces the parser's own diagnostics unchanged. An
|
|
85
|
+
* intact lockfile is compared against the current graph's canonical edge hash.
|
|
86
|
+
* Offline by design — upstream resolution (network) stays in
|
|
87
|
+
* `markspec lock --check`.
|
|
88
|
+
*
|
|
89
|
+
* Corpus-blind by design: the lockfile is not corpus-aware yet (ADR-030 defers
|
|
90
|
+
* lockfile integration), so `markspec lock` never counts corpus edges. Counting
|
|
91
|
+
* them here would raise an `MSL-L212` drift error that `markspec lock` can never
|
|
92
|
+
* fix — a consumer gate must not fail on upstream content the consumer cannot
|
|
93
|
+
* re-lock. The gate therefore filters to project-owned entries (`!e.origin`),
|
|
94
|
+
* mirroring `markspec lock`.
|
|
95
|
+
*
|
|
96
|
+
* @param lockParse The parsed `markspec.lock` (already read from disk).
|
|
97
|
+
* @param lockPath Absolute path to `markspec.lock`, used as the diagnostic
|
|
98
|
+
* location so JSON consumers that group by `location.file` keep the finding.
|
|
99
|
+
* @param entries The full parsed entry set; corpus entries are filtered out.
|
|
100
|
+
*/
|
|
101
|
+
export async function lockfileDriftGate(lockParse, lockPath, entries) {
|
|
102
|
+
if (!lockParse.lockfile) {
|
|
103
|
+
return [...lockParse.diagnostics];
|
|
104
|
+
}
|
|
105
|
+
const projectEntries = entries.filter((e) => !e.origin);
|
|
106
|
+
const drift = await detectOfflineEdgeDrift(projectEntries, lockParse.lockfile.generatedCache);
|
|
107
|
+
if (!drift.drifted)
|
|
108
|
+
return [];
|
|
109
|
+
return [{
|
|
110
|
+
code: "MSL-L212",
|
|
111
|
+
severity: "error",
|
|
112
|
+
message: `traceability edges drifted from markspec.lock: locked ${drift.lockedCount} edge(s), current ${drift.currentCount} — run \`markspec lock\` to refresh. (After upgrading MarkSpec this can also fire once because traceability inputs now include source-file doc comments; re-running \`markspec lock\` clears it.)`,
|
|
113
|
+
location: { file: lockPath, line: 1, column: 1 },
|
|
114
|
+
}];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Prose-lint gate — the advisory `MSL-Q` prose-analysis findings, projected to
|
|
118
|
+
* plain {@linkcode Diagnostic}s.
|
|
119
|
+
*
|
|
120
|
+
* Pass the FULL entry set (project + corpus) and the active profile.
|
|
121
|
+
* {@linkcode runLint} excludes corpus entries from its output but keeps them in
|
|
122
|
+
* the glossary / `$Identifier` indexes, so a corpus-defined term still silences
|
|
123
|
+
* Q500 in project prose (ADR-030 §D4). The profile threads into `isProseScope`
|
|
124
|
+
* so profile-typed entries are scoped (#675).
|
|
125
|
+
*
|
|
126
|
+
* `runLint`'s {@linkcode LintDiagnostic} carries `slug`/`group`/`score` fields
|
|
127
|
+
* that must not leak into `check`'s stable JSON schema — the result is projected
|
|
128
|
+
* to plain {@linkcode Diagnostic}. `runLint`'s `readFile` option (for glossary
|
|
129
|
+
* file indexing) is not needed here: `check` passes no `glossaryFilePaths`.
|
|
130
|
+
*/
|
|
131
|
+
export async function proseLintGate(entries, profile) {
|
|
132
|
+
const lintResult = await runLint({ entries, profile });
|
|
133
|
+
return lintResult.diagnostics.map((d) => ({
|
|
134
|
+
code: d.code,
|
|
135
|
+
severity: d.severity,
|
|
136
|
+
message: d.message,
|
|
137
|
+
location: d.location,
|
|
138
|
+
}));
|
|
139
|
+
}
|
package/esm/lint/runner.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* suppression hygiene on all Authored entries, applies suppression, and
|
|
7
7
|
* returns the final diagnostics.
|
|
8
8
|
*/
|
|
9
|
-
import type { Entry } from "../model/mod.js";
|
|
9
|
+
import type { EffectiveProfile, Entry } from "../model/mod.js";
|
|
10
10
|
import type { LintDiagnostic } from "./types.js";
|
|
11
11
|
import type { FileReader } from "./glossary.js";
|
|
12
12
|
import type { ScoreRollup } from "./score.js";
|
|
@@ -16,10 +16,23 @@ import type { ScoreRollup } from "./score.js";
|
|
|
16
16
|
* In-scope: Authored shape AND resolved core type is Specification or
|
|
17
17
|
* a direct subtype (Requirement, Test, Contract, Record, Risk).
|
|
18
18
|
* Reference-shape entries are always excluded.
|
|
19
|
+
*
|
|
20
|
+
* `profile` is threaded into {@linkcode resolvedCoreType} so an entry
|
|
21
|
+
* classified purely by a profile type (via `Type:` or a profile
|
|
22
|
+
* display-id pattern, e.g. `platform-component`) resolves to its core
|
|
23
|
+
* ancestor through the profile's `extends:` chain. Without it (#675),
|
|
24
|
+
* such entries never enter prose scope and are silently skipped.
|
|
19
25
|
*/
|
|
20
|
-
export declare function isProseScope(entry: Entry): boolean;
|
|
26
|
+
export declare function isProseScope(entry: Entry, profile?: EffectiveProfile): boolean;
|
|
21
27
|
export interface LintOptions {
|
|
22
28
|
readonly entries: readonly Entry[];
|
|
29
|
+
/**
|
|
30
|
+
* Active profile, threaded into {@linkcode isProseScope} so entries
|
|
31
|
+
* classified purely by a profile type enter prose scope (#675). Optional:
|
|
32
|
+
* callers with no profile (e.g. file-local prose scoring) pass nothing and
|
|
33
|
+
* only core-resolvable types are scoped.
|
|
34
|
+
*/
|
|
35
|
+
readonly profile?: EffectiveProfile;
|
|
23
36
|
/** Profile-extended capitalized-allow lexicon. Defaults to core baseline. */
|
|
24
37
|
readonly capitalizedAllow?: ReadonlySet<string>;
|
|
25
38
|
/** Glossary file paths discovered by the listing-directive validator. */
|
|
@@ -34,8 +47,18 @@ export interface LintResult {
|
|
|
34
47
|
/**
|
|
35
48
|
* Run the lint pipeline on a set of entries.
|
|
36
49
|
*
|
|
50
|
+
* Corpus handling (ADR-030 §D4): the glossary and `$Identifier` indexes are
|
|
51
|
+
* built from the FULL `entries` set — including delivered-corpus entries — so a
|
|
52
|
+
* term or `$Identifier` defined only in a corpus document still silences Q500
|
|
53
|
+
* in project prose (the additive-enrichment invariant). Prose *diagnostics*,
|
|
54
|
+
* suppression hygiene, and the score roll-up run only on project entries
|
|
55
|
+
* (`entry.origin === undefined`): a consumer cannot fix an upstream profile's
|
|
56
|
+
* prose, so corpus findings are never emitted and never skew the score. Callers
|
|
57
|
+
* therefore pass the merged project + corpus set, not a pre-filtered one.
|
|
58
|
+
*
|
|
37
59
|
* Pipeline:
|
|
38
|
-
* 1. Filter to in-scope entries (Specification subtypes, Authored shape
|
|
60
|
+
* 1. Filter to in-scope entries (Specification subtypes, Authored shape,
|
|
61
|
+
* non-corpus).
|
|
39
62
|
* 2. Build glossary index from DefinitionList nodes and glossary files.
|
|
40
63
|
* 3. Run lexicon rules on each in-scope entry's prose blocks.
|
|
41
64
|
* 4. Run structural rules on each in-scope entry.
|
package/esm/lint/runner.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/lint/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG/D,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;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAKT;AAMD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA0FvE"}
|
package/esm/lint/runner.js
CHANGED
|
@@ -38,11 +38,17 @@ function isSpecificationDescendant(typeName) {
|
|
|
38
38
|
* In-scope: Authored shape AND resolved core type is Specification or
|
|
39
39
|
* a direct subtype (Requirement, Test, Contract, Record, Risk).
|
|
40
40
|
* Reference-shape entries are always excluded.
|
|
41
|
+
*
|
|
42
|
+
* `profile` is threaded into {@linkcode resolvedCoreType} so an entry
|
|
43
|
+
* classified purely by a profile type (via `Type:` or a profile
|
|
44
|
+
* display-id pattern, e.g. `platform-component`) resolves to its core
|
|
45
|
+
* ancestor through the profile's `extends:` chain. Without it (#675),
|
|
46
|
+
* such entries never enter prose scope and are silently skipped.
|
|
41
47
|
*/
|
|
42
|
-
export function isProseScope(entry) {
|
|
48
|
+
export function isProseScope(entry, profile) {
|
|
43
49
|
if (entry.shape === "Reference")
|
|
44
50
|
return false;
|
|
45
|
-
const coreType = resolvedCoreType(entry);
|
|
51
|
+
const coreType = resolvedCoreType(entry, profile);
|
|
46
52
|
if (!coreType)
|
|
47
53
|
return false;
|
|
48
54
|
return isSpecificationDescendant(coreType);
|
|
@@ -65,8 +71,18 @@ function disabledCodes(entry) {
|
|
|
65
71
|
/**
|
|
66
72
|
* Run the lint pipeline on a set of entries.
|
|
67
73
|
*
|
|
74
|
+
* Corpus handling (ADR-030 §D4): the glossary and `$Identifier` indexes are
|
|
75
|
+
* built from the FULL `entries` set — including delivered-corpus entries — so a
|
|
76
|
+
* term or `$Identifier` defined only in a corpus document still silences Q500
|
|
77
|
+
* in project prose (the additive-enrichment invariant). Prose *diagnostics*,
|
|
78
|
+
* suppression hygiene, and the score roll-up run only on project entries
|
|
79
|
+
* (`entry.origin === undefined`): a consumer cannot fix an upstream profile's
|
|
80
|
+
* prose, so corpus findings are never emitted and never skew the score. Callers
|
|
81
|
+
* therefore pass the merged project + corpus set, not a pre-filtered one.
|
|
82
|
+
*
|
|
68
83
|
* Pipeline:
|
|
69
|
-
* 1. Filter to in-scope entries (Specification subtypes, Authored shape
|
|
84
|
+
* 1. Filter to in-scope entries (Specification subtypes, Authored shape,
|
|
85
|
+
* non-corpus).
|
|
70
86
|
* 2. Build glossary index from DefinitionList nodes and glossary files.
|
|
71
87
|
* 3. Run lexicon rules on each in-scope entry's prose blocks.
|
|
72
88
|
* 4. Run structural rules on each in-scope entry.
|
|
@@ -87,18 +103,25 @@ function disabledCodes(entry) {
|
|
|
87
103
|
* 14. Return diagnostics and score.
|
|
88
104
|
*/
|
|
89
105
|
export async function runLint(options) {
|
|
90
|
-
const { entries } = options;
|
|
106
|
+
const { entries, profile } = options;
|
|
91
107
|
const allow = options.capitalizedAllow ?? loadLexicon("capitalized-allow");
|
|
108
|
+
// Glossary + $Identifier indexes see the FULL entry set (corpus included) so
|
|
109
|
+
// corpus-defined terms/identifiers silence Q500 additively (ADR-030 §D4).
|
|
92
110
|
const glossary = await buildGlossaryIndex(entries, options.readFile ?? (() => Promise.resolve(undefined)), options.glossaryFilePaths ?? []);
|
|
93
111
|
// Corpus-scan resolver leg (issue #502, ADR-021 Decision 1). Built once
|
|
94
112
|
// per invocation; reused across every in-scope entry. Honors the
|
|
95
113
|
// additive-enrichment invariant — Q500 fires *less* as the resolver
|
|
96
114
|
// grows, never *more*.
|
|
97
115
|
const isIdHook = buildIsIdentifierHook(buildIdentifierIndex(entries));
|
|
98
|
-
// Steps 1–9: collect diagnostics keyed by entry
|
|
116
|
+
// Steps 1–9: collect diagnostics keyed by entry. Delivered-corpus entries
|
|
117
|
+
// (`entry.origin`) are excluded from rule execution — a consumer cannot fix
|
|
118
|
+
// upstream prose (ADR-030 §D4) — even though they contribute to the indexes
|
|
119
|
+
// above.
|
|
99
120
|
const inScopeDiags = new Map();
|
|
100
121
|
for (const entry of entries) {
|
|
101
|
-
if (
|
|
122
|
+
if (entry.origin)
|
|
123
|
+
continue;
|
|
124
|
+
if (!isProseScope(entry, profile))
|
|
102
125
|
continue;
|
|
103
126
|
const diags = [];
|
|
104
127
|
// Step 3: lexicon rules
|
|
@@ -117,11 +140,15 @@ export async function runLint(options) {
|
|
|
117
140
|
diags.push(...runPassiveRules(entry));
|
|
118
141
|
inScopeDiags.set(entry, diags);
|
|
119
142
|
}
|
|
120
|
-
// Step 10: suppression hygiene on all Authored entries
|
|
143
|
+
// Step 10: suppression hygiene on all Authored project entries. Corpus
|
|
144
|
+
// entries are skipped for the same reason as rule execution — hygiene
|
|
145
|
+
// findings located in a corpus file are unfixable by the consumer.
|
|
121
146
|
const hygieneDiags = [];
|
|
122
147
|
for (const entry of entries) {
|
|
123
148
|
if (entry.shape !== "Authored")
|
|
124
149
|
continue;
|
|
150
|
+
if (entry.origin)
|
|
151
|
+
continue;
|
|
125
152
|
hygieneDiags.push(...runSuppressionRules(entry));
|
|
126
153
|
}
|
|
127
154
|
// Step 11: apply suppression to in-scope diagnostics; track matched codes
|
|
@@ -151,7 +178,10 @@ export async function runLint(options) {
|
|
|
151
178
|
}
|
|
152
179
|
// Append hygiene diagnostics (Q900/Q901 — never suppressed)
|
|
153
180
|
out.push(...hygieneDiags);
|
|
154
|
-
// Step 13: compute score roll-up across
|
|
155
|
-
|
|
181
|
+
// Step 13: compute score roll-up across project entries (including 0-score
|
|
182
|
+
// ones). Corpus entries are excluded — counting them would skew band-counts
|
|
183
|
+
// and the mean on prose a consumer cannot act on (ADR-030 §D4). A no-op when
|
|
184
|
+
// no corpus is present.
|
|
185
|
+
const score = computeScoreRollup(out, entries.filter((e) => !e.origin));
|
|
156
186
|
return { diagnostics: out, score };
|
|
157
187
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lock/edge_drift
|
|
3
|
+
*
|
|
4
|
+
* Offline traceability edge-drift detection: compare the current project
|
|
5
|
+
* graph's canonical edge hash against a lockfile's generated-cache. Pure,
|
|
6
|
+
* offline (no upstream resolution) — the single source of truth shared by
|
|
7
|
+
* `check`'s MSL-L212 gate and `doctor`'s lock-drift health check so the two
|
|
8
|
+
* can never disagree on what "drift" means.
|
|
9
|
+
*/
|
|
10
|
+
import type { Entry } from "../model/mod.js";
|
|
11
|
+
import type { GeneratedCache } from "./model.js";
|
|
12
|
+
/** Result of the offline (no-network) edge-hash drift comparison. */
|
|
13
|
+
export interface OfflineEdgeDrift {
|
|
14
|
+
/** True when the current canonical edge hash differs from the lockfile. */
|
|
15
|
+
readonly drifted: boolean;
|
|
16
|
+
/** Edge count recorded in the lockfile's generated-cache. */
|
|
17
|
+
readonly lockedCount: number;
|
|
18
|
+
/** Edge count in the current project graph. */
|
|
19
|
+
readonly currentCount: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Compare the current project graph's canonical edge hash against a
|
|
23
|
+
* lockfile's generated-cache. Offline by design — no upstream resolution.
|
|
24
|
+
*
|
|
25
|
+
* `projectEntries` MUST already exclude delivered-corpus entries (ADR-030
|
|
26
|
+
* corpus-blindness); the caller filters `!e.origin`, mirroring how
|
|
27
|
+
* `markspec lock` and `check`'s MSL-L212 gate count only project-owned
|
|
28
|
+
* edges.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectOfflineEdgeDrift(projectEntries: readonly Entry[], cache: GeneratedCache): Promise<OfflineEdgeDrift>;
|
|
31
|
+
//# sourceMappingURL=edge_drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge_drift.d.ts","sourceRoot":"","sources":["../../src/lock/edge_drift.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,qEAAqE;AACrE,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,cAAc,EAAE,SAAS,KAAK,EAAE,EAChC,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,gBAAgB,CAAC,CAQ3B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/lock/edge_drift
|
|
3
|
+
*
|
|
4
|
+
* Offline traceability edge-drift detection: compare the current project
|
|
5
|
+
* graph's canonical edge hash against a lockfile's generated-cache. Pure,
|
|
6
|
+
* offline (no upstream resolution) — the single source of truth shared by
|
|
7
|
+
* `check`'s MSL-L212 gate and `doctor`'s lock-drift health check so the two
|
|
8
|
+
* can never disagree on what "drift" means.
|
|
9
|
+
*/
|
|
10
|
+
import { extractEdgeQuads } from "./resolve.js";
|
|
11
|
+
import { hashCanonicalEdges } from "./canonical_edges.js";
|
|
12
|
+
/**
|
|
13
|
+
* Compare the current project graph's canonical edge hash against a
|
|
14
|
+
* lockfile's generated-cache. Offline by design — no upstream resolution.
|
|
15
|
+
*
|
|
16
|
+
* `projectEntries` MUST already exclude delivered-corpus entries (ADR-030
|
|
17
|
+
* corpus-blindness); the caller filters `!e.origin`, mirroring how
|
|
18
|
+
* `markspec lock` and `check`'s MSL-L212 gate count only project-owned
|
|
19
|
+
* edges.
|
|
20
|
+
*/
|
|
21
|
+
export async function detectOfflineEdgeDrift(projectEntries, cache) {
|
|
22
|
+
const quads = extractEdgeQuads(projectEntries);
|
|
23
|
+
const currentHash = await hashCanonicalEdges(quads);
|
|
24
|
+
return {
|
|
25
|
+
drifted: cache.edgesHash !== currentHash,
|
|
26
|
+
lockedCount: cache.edgesCount,
|
|
27
|
+
currentCount: quads.length,
|
|
28
|
+
};
|
|
29
|
+
}
|
package/esm/lock/mod.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ 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 { detectOfflineEdgeDrift } from "./edge_drift.js";
|
|
19
|
+
export type { OfflineEdgeDrift } from "./edge_drift.js";
|
|
18
20
|
export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
|
|
19
21
|
export type { FetchUrl, ReadFile, ResolvedBoundEntry, ResolvedProfile, ResolvedReference, ResolvedRegistry, ResolvedUpstreams, ResolveUpstreamsOptions, } from "./resolve.js";
|
|
20
22
|
//# sourceMappingURL=mod.d.ts.map
|
package/esm/lock/mod.d.ts.map
CHANGED
|
@@ -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,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,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,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"}
|
|
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,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,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,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
|
@@ -12,4 +12,5 @@ export { isBelowFloor } from "./compare.js";
|
|
|
12
12
|
export { checkDrift } from "./check.js";
|
|
13
13
|
export { sha256Bytes, sha256String } from "./hash.js";
|
|
14
14
|
export { canonicalEdgeJson, hashCanonicalEdges } from "./canonical_edges.js";
|
|
15
|
+
export { detectOfflineEdgeDrift } from "./edge_drift.js";
|
|
15
16
|
export { extractEdgeLedger, extractEdgeQuads, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, } from "./resolve.js";
|