@shapeshift-labs/frontier-lang-compiler 0.2.189 → 0.2.190

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/README.md CHANGED
@@ -557,7 +557,7 @@ Current JS/TS semantic-merge status matrix:
557
557
  | CSS dependency graph evidence | bounded-evidence | CSS dependency graph proof uses `cssDependencySurfaceFiles`, `cssDependencyGraphEvidenceFiles`, missing-proof/blocker counters, and the `css-dependency-graph` proof status for custom property, `var()` fallback, animation, font, asset, `@property`, and `@page` dependency surfaces. It is absent when no dependency surface is present and does not claim cascade/browser equivalence. |
558
558
  | CSS runtime descriptor evidence | bounded-evidence | CSS runtime descriptor proof uses `cssRuntimeDescriptorFiles`, `cssRuntimeDescriptorEvidenceFiles`, property/page descriptor counters, and the `css-runtime-descriptor-evidence` proof status for parser-backed `@property` syntax/inherits/initial-value evidence plus `@page` descriptor and margin-box records. It is source/shape-key evidence only; browser cascade, render, and runtime equivalence remain in the separate browser proof row. |
559
559
  | HTML/CSS browser runtime proof | bounded-evidence | HTML/CSS browser proof is an explicit separate row tracked by `htmlCssBrowserRuntimeProofs`, the `html-css-browser-runtime-proof` surface, and the `browser-runtime-proof` proof status. Structural source merges keep browser/render/cascade equivalence claims false unless a bounded browser proof bundle is attached; HTML runtime-boundary proofs and CSS cascade runtime proofs must include source hashes, a runtime command, probe id, evidence hash, and the required runtime signal. Missing proof routes to `prove-html-css-browser-runtime`. |
560
- | Parser/source-span/trivia evidence | Partial | Source preservation, source hashes, runtime directive-prologue entries, directives, comments/trivia summaries, project `sourceFileRecords` / `sourceSpanRecords`, protected-span hashes, shebang file-entrypoint directive ownership anchors, `sourceMappingURL` and `sourceURL` generated-boundary source-map spans, deterministic source-map generated-boundary ownership keys from supplied exact source/generated spans and hashes, generated-boundary position conflict evidence, deterministic ownership anchors, source-span/trivia ownership blockers, exact parser-trivia ownership records for directive prologues plus leading/trailing comments and JSDoc/block-comment spans when parser evidence matches the source hash, TypeScript `SourceFile` compiler-scanner exact token/trivia source-preservation evidence for JS/TS/JSX/TSX imports, ESTree/Babel parser token/comment range evidence when the supplied AST covers every non-whitespace byte of the current source, fail-closed scanner/ledger spoof blockers, source-span delta conflicts, parser roundtrip proof records, failed source-span roundtrip proof admission blockers, project-merge stage parser-trivia evidence from supplied parser-backed imports for base/worker/head/output, metadata-only exactness blockers for scanner fallbacks, and fixture corpus checks. Parser-backed exactness also requires contiguous current-source token/comment/trivia coverage with no gaps, overlaps, truncation, or text mismatches; truncated coverage blocks exact token/comment ownership. Adapters without token/comment ranges remain approximate/caller evidence, not exact parser trivia. |
560
+ | Parser/source-span/trivia evidence | Partial | Source preservation, source hashes, runtime directive-prologue entries, directives, comments/trivia summaries, project `sourceFileRecords` / `sourceSpanRecords`, protected-span hashes, shebang file-entrypoint directive ownership anchors, `sourceMappingURL` and `sourceURL` generated-boundary source-map spans, deterministic source-map generated-boundary ownership keys from supplied exact source/generated spans and hashes, generated-boundary position conflict evidence, deterministic ownership anchors, source-span/trivia ownership blockers, exact parser-trivia ownership records for directive prologues plus leading/trailing comments and JSDoc/block-comment spans when parser evidence matches the source hash, TypeScript `SourceFile` compiler-scanner exact token/trivia source-preservation evidence for JS/TS/JSX/TSX imports, ESTree/Babel parser token/comment range evidence plus first-class `parserSpanCoverageProof` records when the supplied AST covers every non-whitespace byte of the current source, project source file/span parser-span coverage status/evidence fields, fail-closed scanner/ledger spoof blockers, source-span delta conflicts, parser roundtrip proof records, failed source-span roundtrip proof admission blockers, project-merge stage parser-trivia evidence from supplied parser-backed imports for base/worker/head/output, metadata-only exactness blockers for scanner fallbacks, and fixture corpus checks. Parser-backed exactness also requires contiguous current-source token/comment/trivia coverage with no gaps, overlaps, truncation, or text mismatches; truncated coverage blocks exact token/comment ownership. Adapters without token/comment ranges remain approximate/caller evidence, not exact parser trivia. |
561
561
  | Scope/use-def graph | Partial | Lightweight lexical scope/use-def scans, destructuring alias binding records, object/array/nested/rest/default-initializer parameter binding evidence for function and arrow parameters, default import alias reads through re-export chains when a stable default-export local binding is observed, source-bound anonymous default export fallback evidence for resolved default re-export chains with source hash/span and source symbol hashes, fail-closed `lexical-scope-import-alias-target-unresolved` records when an alias target cannot be tied to either lexical binding or source-bound anonymous default evidence, namespace import dot and literal/static-template computed member-read evidence, blocked evidence for ambiguous computed namespace reads and namespace member writes, `this`/`super` receiver member read/write evidence including computed string and static-template members, optional chaining markers, and TypeScript checker-backed receiver-member reference proof for full `this`/`super` access spans including private identifiers, template-literal interpolation live-reference records with expression hashes plus tagged-template site/tag root/member metadata, caller-supplied ESTree/scope-manager structural evidence normalization, closure-capture depth/owner/reference hashes, binding-level closure capture hashes, project `scopeBindingRecords` / `scopeReferenceRecords`, public owner use hashes, public scope-use and reference-site delta conflicts with alias target route/use-hash evidence, TypeScript compiler reference relations when a checker is supplied, exact compiler reference-site proof hashes on scope reference records, fail-closed `typescript-compiler-reference-site-ambiguous`, `typescript-compiler-reference-lexical-binding-mismatch`, and `typescript-compiler-reference-import-alias-target-mismatch` records when compiler alias evidence cannot be reconciled with the lexical route or re-export/import target, and dependency-sensitive fixture coverage. Full whole-program binding/control-flow resolution is still caller/compiler-evidence bounded. |
562
562
  | Module/export/import graph | Partial | Project graph stages, module resolution, runtime-neutral package manifest conversion from in-memory `package.json` objects/text, duplicate workspace-root package-name ambiguity diagnostics and fail-closed `package-workspace-root-ambiguous-missing` edges with `packageWorkspaceRoots` evidence, package exports/imports including wildcard package export key/target evidence, fail-closed package `imports` condition misses, runtime-ambiguous `import`/`require` condition blockers, caller-supplied package type runtime-condition evidence for `.js`/`.ts` package exports/imports, caller-supplied package environment-condition evidence such as `browser`, fail-closed `package-export-environment-ambiguous-missing` / `package-import-environment-ambiguous-missing` blockers with condition candidates when environment targets such as `browser` and `node` diverge without explicit evidence, and fail-closed host-runtime ambiguity blockers for non-resolver host package specifiers with divergent `import`/`require` targets, re-export identities including static TypeScript-style CommonJS bare and `tslib_1.__...` member-form `__exportStar(require("./dep"), exports)` fanout and `__createBinding(exports, require("./dep"), "name", "alias")` named re-export fanout, same-document CommonJS require-alias getter re-export identities for descriptor `get: function () { return dep.name; }`, named descriptor `get: function getName() { return dep.name; }`, shorthand `get() { return dep.name; }`, and block-bodied arrow `get: () => { return dep.name; }`, TypeScript-style CommonJS bare and `tslib_1.__...` member-form `__importDefault(require("./dep"))` and `__importStar(require("./dep"))` helper import edges, CommonJS `module.exports` default-import interop when no direct `default` export exists, literal computed CommonJS export properties such as `exports["default"]`, static `module.exports = { named }`, `Object.assign(exports, { named })`, `Object.defineProperty(exports, "named", { value/get })`, and `Object.defineProperties(exports, { named: { value/get } })` export maps in lightweight and AST-backed imports, ESTree/Babel no-expression `TemplateLiteral` normalization for CommonJS `require`, computed export keys, descriptor export specifiers, dynamic `import()`, CommonJS helper re-export specifiers, and host dependency specifiers while expression-bearing templates stay unresolved, TypeScript compiler no-substitution dynamic import and host dependency template evidence, `exports.__esModule` marker filtering, import-target deltas for head-introduced CommonJS export assignments, namespace/ambient module/global augmentation/export-assignment static shape records with proof hashes and no runtime-equivalence claim, fail-closed namespace/export-assignment shape delta conflicts, non-literal dynamic `import()` pseudo-specifiers with expression kind/text/hash evidence and fail-closed resolution evidence, static `new URL(specifier, import.meta.url)`, `Worker`, `SharedWorker`, `serviceWorker.register`, worklet `addModule`, `importScripts`, `import.meta.resolve`, and `require.resolve` host dependency edges with expression hashes and no runtime-resolution claim, dynamic host dependency targets emitted as `<host-dependency>` with expression hashes, `hostDependencyStaticSpecifierEvidence: false`, and proof-required unresolved evidence, import-attribute/import-assertion normalized key/value/count/hash evidence on static imports, dynamic imports, and re-exports, import-attribute delta conflicts, output graph unresolved-module conflicts that preserve edge-level fail-closed package, host, dynamic import, and import-attribute value evidence, and output graph resolved-module missing-export conflicts that preserve edge-level package and import-attribute evidence. Host filesystem/package graph crawling, namespace runtime evaluation, ambient/global compatibility, and CommonJS runtime interop equivalence remain out of the root API. |
563
563
  | Type/public API graph | Partial | Public-contract regions, signature/contract hashes, TypeScript compiler symbol/type records, source-bound checker proof source path/hash requirements, compiler-backed type-reference target proof that binds public API type references to resolved target symbols, declaration spans, and declaration source text hashes, inferred exported factory call-signature evidence, compiler-backed public call/construct signature shape evidence and proof hashes, exported overload declaration/signature counts, compiler-backed overload signature-set proof, compiler-backed generic type-parameter/default proof, compiler-backed public member property/method property-set proof, compiler-backed public index-signature key/value/readonly evidence and proof hashes, stable public-surface hashes that ignore transient TypeScript symbol flags, compiler-backed class heritage and constructor-signature evidence/proof hashes, compiler-backed private class member and accessor-field static shape records/proof hashes plus source- and required-signal-bound private/accessor runtime proof binding with command/trace/evidence hashes, private brand, private method, private accessor, static private, subclass brand-boundary, and accessor descriptor trace slots, and false claim flags, compiler-backed class/member/parameter decorator target and expression static metadata records/proof hashes plus source-bound decorator runtime execution proof binding with trace hashes and false claim flags, compiler-backed enum runtime-shape/member-value evidence and proof hashes, TypeScript compiler importer support for source-bound computed enum evaluated-value traces with emitted-shape hashes, trace/evidence hashes, and false claim flags, compiler-backed conditional, indexed-access, mapped, `keyof`, template-literal, `infer`, union, intersection, tuple, and mixed known advanced/composite type-shape proof hashes, static compiler-backed inference syntax evidence/proof hashes for `satisfies`, `as const`, and const type parameters, bounded TypeChecker `isTypeAssignableTo` oracle proof for simple public type aliases with source path/hash binding and fail-closed `typescript-public-api-type-equivalence-proof-missing` for missing or ambiguous oracle evidence, class private/accessor/decorator/class/enum/advanced-shape/composite-shape/inference-syntax/index-signature/callable-signature/type-reference-target hashes in public compiler-type delta fingerprints, fail-closed missing-proof blockers for missing public API source hashes, type-reference target proof hashes, call/construct signature return/parameter evidence, constructor/class-heritage/private-class-member/accessor-field/index-signature value-type/enum runtime-shape/conditional-branch/indexed-access object-index-result/mapped constraint-value/`keyof` target/template-literal span/`infer` type-parameter/union member/intersection member/tuple element evidence, fail-closed computed enum runtime-value blockers when source-bound evaluated-value proof is missing, stale, trace-incomplete, value-incomplete, or claim-bearing, fail-closed private/accessor and decorator runtime execution blockers when source-bound trace proof is missing, stale, trace-incomplete, schema/kind-mismatched, required-signal-incomplete, commandless, or claim-bearing, fail-closed unknown advanced type-shape evidence, unsupported type-equivalence reason codes, public compiler-type delta conflicts, declaration-output gate, TypeScript declaration emit parity proof for worker/head/output public boundaries, and project graph delta conflicts. Full type-equivalence, broad decorator execution equivalence beyond source-bound trace proofs, broad enum runtime evaluation beyond source-bound computed-value traces, broad runtime equivalence for private/accessor execution beyond source-bound trace proofs, or broad inference-semantics proof beyond these focused compiler-backed cases is not claimed. |
@@ -598,6 +598,7 @@ Recent residual closures represented in the matrix shards:
598
598
  - Project admission now exposes `admission.routes` / `routeSummary` records for structural apply/review/reject/rerun/rebase decisions across cross-file symbol rename, symbol move, split/merge, replay-proof, and missing-evidence paths, while keeping `autoMergeClaim: false` and `semanticEquivalenceClaim: false`.
599
599
  - Semantic equivalence proof now accepts source/output/gate-bound external proof records for exact JS/TS project bindings, removes the external-proof missing route only when the proof validates, and keeps stale, malformed, or overclaiming proofs fail-closed with `semantic-equivalence-unknown`.
600
600
  - Parser/source-span/trivia now requires contiguous parser-backed current-source token/comment/trivia coverage with no gaps, overlaps, truncation, or text mismatches before claiming exact token/comment ownership, including distinct JSDoc and block-comment ownership relations.
601
+ - Parser/source-span/trivia now emits first-class ESTree/Babel `parserSpanCoverageProof` evidence from token/comment ranges, threads it into parser-trivia exactness, source file/span records, ownership anchors, and source-span roundtrip summaries, and keeps truncated syntax-AST coverage fail-closed.
601
602
  - Scope/use-def graph now blocks compiler/lexical import-alias re-export target disagreement with `typescript-compiler-reference-import-alias-target-mismatch`.
602
603
  - Scope/use-def graph now treats no-expression template literals in namespace-import and `this`/`super` computed member reads as static member evidence while expression templates remain blocked.
603
604
  - Module/export/import graph now treats duplicate package names across different workspace roots as `ambiguous-package-workspace-root` and emits fail-closed `package-workspace-root-ambiguous-missing` edges.
@@ -70,6 +70,10 @@ function sourceFileRecord(context) {
70
70
  exactParserTrivia: parserTriviaExactness.exactParserTrivia,
71
71
  parserTriviaEvidenceId: parserTriviaExactness.evidenceId,
72
72
  parserTriviaAdapterId: parserTriviaExactness.adapterId,
73
+ parserSpanCoverageStatus: parserTriviaExactness.parserSpanCoverageStatus,
74
+ parserSpanCoverageEvidenceId: parserTriviaExactness.parserSpanCoverageEvidenceId,
75
+ parserSpanCoverageReasonCodes: parserTriviaExactness.parserSpanCoverageReasonCodes,
76
+ parserSpanCoverageBlockReasonCodes: parserTriviaExactness.parserSpanCoverageBlockReasonCodes,
73
77
  parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
74
78
  parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes,
75
79
  sourceLedgerAvailable: ownership.sourceLedgerAvailable,
@@ -159,6 +163,10 @@ function sourceSpanRecord(span, index, context, identity) {
159
163
  exactParserTrivia: parserTriviaExactness.exactParserTrivia,
160
164
  parserTriviaEvidenceId: parserTriviaExactness.evidenceId,
161
165
  parserTriviaAdapterId: parserTriviaExactness.adapterId,
166
+ parserSpanCoverageStatus: parserTriviaExactness.parserSpanCoverageStatus,
167
+ parserSpanCoverageEvidenceId: parserTriviaExactness.parserSpanCoverageEvidenceId,
168
+ parserSpanCoverageReasonCodes: parserTriviaExactness.parserSpanCoverageReasonCodes,
169
+ parserSpanCoverageBlockReasonCodes: parserTriviaExactness.parserSpanCoverageBlockReasonCodes,
162
170
  parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
163
171
  parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes,
164
172
  parserTriviaOwnershipStatus,
@@ -218,6 +226,7 @@ function parserTriviaExactnessForPreservation(preservation) {
218
226
  sourceHash: preservation?.sourceHash,
219
227
  parserEvidence: tokenTriviaParserEvidence,
220
228
  parserTokenTriviaEvidence: tokenTriviaParserEvidence,
229
+ parserSpanCoverageProof: preservation?.metadata?.parserSpanCoverageProof,
221
230
  truncated: preservation?.summary?.truncated === true
222
231
  });
223
232
  }
@@ -67,6 +67,10 @@ function sourceSpanOwnershipAnchor(span, role, context, spans, index) {
67
67
  exactParserTrivia: parserTriviaExactness.exactParserTrivia,
68
68
  parserTriviaEvidenceId: parserTriviaExactness.evidenceId,
69
69
  parserTriviaAdapterId: parserTriviaExactness.adapterId,
70
+ parserSpanCoverageStatus: parserTriviaExactness.parserSpanCoverageStatus,
71
+ parserSpanCoverageEvidenceId: parserTriviaExactness.parserSpanCoverageEvidenceId,
72
+ parserSpanCoverageReasonCodes: parserTriviaExactness.parserSpanCoverageReasonCodes,
73
+ parserSpanCoverageBlockReasonCodes: parserTriviaExactness.parserSpanCoverageBlockReasonCodes,
70
74
  parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
71
75
  parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes,
72
76
  ...parserTriviaOwnership
@@ -94,6 +98,7 @@ function parserTriviaExactnessForContext(context) {
94
98
  sourceHash: context.sourceHash,
95
99
  parserEvidence,
96
100
  parserTokenTriviaEvidence: parserEvidence,
101
+ parserSpanCoverageProof: context.preservation.metadata?.parserSpanCoverageProof,
97
102
  truncated: context.preservation.summary?.truncated === true
98
103
  });
99
104
  }
@@ -102,6 +107,7 @@ function parserTriviaExactnessForContext(context) {
102
107
  sourceHash: context.sourceHash,
103
108
  parserEvidence,
104
109
  parserTokenTriviaEvidence: parserEvidence,
110
+ parserSpanCoverageProof: context.preservation.metadata?.parserSpanCoverageProof,
105
111
  truncated: context.preservation.summary?.truncated === true
106
112
  });
107
113
  }
@@ -0,0 +1,54 @@
1
+ import { idFragment } from '../../native-import-utils.js';
2
+ import { createParserSpanCoverageProof } from '../../native-source-preservation-ownership.js';
3
+
4
+ export function createSyntaxAstParserSpanCoverageEvidence(input) {
5
+ const parserSpanCoverageProof = createParserSpanCoverageProof({
6
+ sourceText: input.sourceText,
7
+ sourcePath: input.sourcePath,
8
+ sourceHash: input.sourceHash,
9
+ segments: input.segments,
10
+ tokenCount: input.tokenCount,
11
+ triviaCount: input.triviaCount,
12
+ commentCount: input.commentCount,
13
+ parserEvidence: input.parserEvidence,
14
+ adapterId: input.adapterId,
15
+ evidenceId: `${input.adapterId}:parser-span-coverage:${idFragment(input.sourcePath ?? input.sourceHash)}`,
16
+ languageMode: sourceLanguageMode(input),
17
+ boundedLanguages: ['javascript', 'typescript', 'jsx', 'tsx'],
18
+ truncated: input.truncated
19
+ });
20
+ return {
21
+ parserSpanCoverageProof,
22
+ parserTriviaEvidence: parserTriviaEvidenceForSpanCoverage(parserSpanCoverageProof, input)
23
+ };
24
+ }
25
+
26
+ function parserTriviaEvidenceForSpanCoverage(parserSpanCoverageProof, input) {
27
+ const exact = parserSpanCoverageProof?.status === 'exact';
28
+ const blockReasonCodes = exact ? [] : [
29
+ 'exact-parser-trivia-span-coverage-blocked',
30
+ ...(parserSpanCoverageProof?.blockReasonCodes ?? []),
31
+ input.truncated ? 'source-preservation-truncated' : undefined
32
+ ].filter(Boolean);
33
+ return {
34
+ status: exact ? 'exact' : 'blocked',
35
+ exactParserTrivia: exact,
36
+ losslessCst: exact,
37
+ sourceHash: input.sourceHash,
38
+ adapterId: input.adapterId,
39
+ evidenceId: `${input.adapterId}:parser-token-comment:${idFragment(input.sourcePath ?? input.sourceHash)}`,
40
+ parserEvidence: input.parserEvidence,
41
+ parserSpanCoverageProof,
42
+ ...(exact ? {} : { blockReasonCodes })
43
+ };
44
+ }
45
+
46
+ function sourceLanguageMode(input) {
47
+ const sourcePath = String(input.sourcePath ?? '').toLowerCase();
48
+ if (sourcePath.endsWith('.tsx')) return 'tsx';
49
+ if (sourcePath.endsWith('.jsx')) return 'jsx';
50
+ if (sourcePath.endsWith('.ts') || sourcePath.endsWith('.mts') || sourcePath.endsWith('.cts')) return 'typescript';
51
+ if (sourcePath.endsWith('.js') || sourcePath.endsWith('.mjs') || sourcePath.endsWith('.cjs')) return 'javascript';
52
+ const language = String(input.language ?? '').toLowerCase();
53
+ return language === 'typescript' ? 'typescript' : 'javascript';
54
+ }
@@ -6,20 +6,22 @@ import {
6
6
  preservedSourceSegmentRole
7
7
  } from '../../native-source-preservation-ownership.js';
8
8
  import { createNativeSourcePreservation } from './createNativeSourcePreservation.js';
9
+ import { createSyntaxAstParserSpanCoverageEvidence } from './syntaxAstParserSpanCoverage.js';
9
10
 
10
11
  export function createSyntaxAstSourcePreservation(ast, input, options = {}) {
11
12
  if (!ast || typeof input.sourceText !== 'string') return undefined;
12
13
  const sourceText = input.sourceText;
13
14
  const sourceHash = hashSemanticValue(sourceText);
14
15
  const parserEvidence = `${options.parser ?? input.parser ?? 'syntax-ast'}-parser-token-comment-ranges`;
16
+ const adapterId = input.adapterId ?? options.adapterId ?? `${options.parser ?? input.parser ?? 'syntax'}-native-importer`;
15
17
  const tokensAndTrivia = syntaxAstTokensAndTrivia(ast, input, {
16
18
  ...options,
19
+ adapterId,
17
20
  parserEvidence,
18
21
  sourceHash,
19
22
  sourceText
20
23
  });
21
24
  if (!tokensAndTrivia?.exact) return undefined;
22
- const adapterId = input.adapterId ?? options.adapterId ?? `${options.parser ?? input.parser ?? 'syntax'}-native-importer`;
23
25
  return createNativeSourcePreservation({
24
26
  language: input.language ?? options.language ?? 'javascript',
25
27
  sourcePath: input.sourcePath,
@@ -28,15 +30,8 @@ export function createSyntaxAstSourcePreservation(ast, input, options = {}) {
28
30
  tokensAndTrivia,
29
31
  includeTokens: options.includeTokens !== false,
30
32
  includeTrivia: options.includeTrivia !== false,
31
- parserTriviaEvidence: {
32
- status: 'exact',
33
- exactParserTrivia: true,
34
- losslessCst: true,
35
- sourceHash,
36
- adapterId,
37
- evidenceId: `${adapterId}:parser-token-comment:${idFragment(input.sourcePath ?? sourceHash)}`,
38
- parserEvidence
39
- },
33
+ parserSpanCoverageProof: tokensAndTrivia.parserSpanCoverageProof,
34
+ parserTriviaEvidence: tokensAndTrivia.parserTriviaEvidence,
40
35
  metadata: {
41
36
  parserTokenTriviaEvidence: parserEvidence,
42
37
  parserTokenTriviaSource: options.astFormat ?? options.parser ?? 'syntax-ast'
@@ -56,14 +51,30 @@ function syntaxAstTokensAndTrivia(ast, input, options) {
56
51
  const whitespaceSegments = whitespaceTriviaSegments(parserSegments, input, options);
57
52
  const allTrivia = [...parserSegments.filter((segment) => segment.role === 'trivia'), ...whitespaceSegments]
58
53
  .sort((left, right) => left.span.start - right.span.start || left.span.end - right.span.end);
59
- const tokens = limitRecords(parserSegments.filter((segment) => segment.role !== 'trivia'), options.maxTokens);
60
- const trivia = limitRecords(allTrivia, options.maxTrivia);
54
+ const tokenLimit = limitRecords(parserSegments.filter((segment) => segment.role !== 'trivia'), options.maxTokens);
55
+ const triviaLimit = limitRecords(allTrivia, options.maxTrivia);
56
+ const truncated = tokenLimit.truncated || triviaLimit.truncated;
57
+ const coverage = createSyntaxAstParserSpanCoverageEvidence({
58
+ sourceText,
59
+ sourcePath: input.sourcePath,
60
+ language: input.language ?? options.language,
61
+ sourceHash: options.sourceHash,
62
+ segments: [...tokenLimit.records, ...triviaLimit.records],
63
+ tokenCount: tokenLimit.records.length,
64
+ triviaCount: triviaLimit.records.length,
65
+ commentCount: triviaLimit.records.filter((entry) => isCommentKind(entry.kind)).length,
66
+ parserEvidence: options.parserEvidence,
67
+ adapterId: options.adapterId,
68
+ truncated
69
+ });
61
70
  return {
62
71
  exact: true,
63
- tokens: tokens.records,
64
- trivia: trivia.records,
65
- truncated: tokens.truncated || trivia.truncated,
66
- parserEvidence: options.parserEvidence
72
+ tokens: tokenLimit.records.map((entry) => withParserTriviaEvidence(entry, coverage.parserTriviaEvidence)),
73
+ trivia: triviaLimit.records.map((entry) => withParserTriviaEvidence(entry, coverage.parserTriviaEvidence)),
74
+ truncated,
75
+ parserEvidence: options.parserEvidence,
76
+ parserSpanCoverageProof: coverage.parserSpanCoverageProof,
77
+ parserTriviaEvidence: coverage.parserTriviaEvidence
67
78
  };
68
79
  }
69
80
 
@@ -172,6 +183,29 @@ function preservedParserSegment(input) {
172
183
  };
173
184
  }
174
185
 
186
+ function withParserTriviaEvidence(record, parserTriviaEvidence) {
187
+ const role = preservedSourceSegmentRole(record.kind);
188
+ return {
189
+ ...record,
190
+ ownershipAnchor: createPreservedSourceOwnershipAnchor({
191
+ kind: record.kind,
192
+ role,
193
+ text: record.text,
194
+ textHash: record.textHash,
195
+ sourcePath: record.span.path,
196
+ sourceHash: record.span.sourceId,
197
+ span: record.span,
198
+ anchorKind: preservedOwnershipAnchorKind(record.kind, role),
199
+ parserEvidence: parserTriviaEvidence.parserEvidence,
200
+ parserTriviaEvidence
201
+ }),
202
+ metadata: {
203
+ ...record.metadata,
204
+ parserSpanCoverageStatus: parserTriviaEvidence.parserSpanCoverageProof?.status
205
+ }
206
+ };
207
+ }
208
+
175
209
  function parserSegmentsCoverSource(segments, sourceText) {
176
210
  let cursor = 0;
177
211
  for (const segment of segments) {
@@ -243,6 +277,10 @@ function preservedCommentKind(text) {
243
277
  return 'comment';
244
278
  }
245
279
 
280
+ function isCommentKind(kind) {
281
+ return kind === 'comment' || kind === 'jsdoc-comment' || kind === 'block-comment' || kind === 'source-map-comment';
282
+ }
283
+
246
284
  function limitRecords(records, maxValue) {
247
285
  const max = Number.isFinite(maxValue) ? Math.max(0, maxValue) : 20000;
248
286
  return { records: records.slice(0, max), truncated: records.length > max };
@@ -96,7 +96,11 @@ function parserTriviaExactnessForFile(file, artifacts) {
96
96
  {
97
97
  sourcePath: file.sourcePath,
98
98
  sourceHash: file.outputHash,
99
- parserEvidence: artifacts?.metadata?.parserEvidence
99
+ parserEvidence: artifacts?.metadata?.parserEvidence,
100
+ parserSpanCoverageProof: file.parserSpanCoverageProof
101
+ ?? file.metadata?.parserSpanCoverageProof
102
+ ?? file.result?.metadata?.parserSpanCoverageProof
103
+ ?? artifacts?.metadata?.parserSpanCoverageProof
100
104
  }
101
105
  );
102
106
  }
@@ -207,6 +207,10 @@ function createPreservedSourceOwnershipAnchor(input = {}) {
207
207
  exactParserTrivia: parserTriviaExactness.exactParserTrivia,
208
208
  parserTriviaEvidenceId: parserTriviaExactness.evidenceId,
209
209
  parserTriviaAdapterId: parserTriviaExactness.adapterId,
210
+ parserSpanCoverageStatus: parserTriviaExactness.parserSpanCoverageStatus,
211
+ parserSpanCoverageEvidenceId: parserTriviaExactness.parserSpanCoverageEvidenceId,
212
+ parserSpanCoverageReasonCodes: parserTriviaExactness.parserSpanCoverageReasonCodes,
213
+ parserSpanCoverageBlockReasonCodes: parserTriviaExactness.parserSpanCoverageBlockReasonCodes,
210
214
  parserTriviaExactnessReasonCodes: parserTriviaExactness.reasonCodes,
211
215
  parserTriviaExactnessBlockReasonCodes: parserTriviaExactness.blockReasonCodes
212
216
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-compiler",
3
- "version": "0.2.189",
3
+ "version": "0.2.190",
4
4
  "description": "Compiler facade for Frontier Lang source documents and language projection adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",