@jini-ai/devops 0.7.2 → 0.7.3-next.1
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/CHANGELOG.md +2 -8
- package/README.md +8 -4
- package/dist/agent-jobs/jobs.d.ts +1 -1
- package/dist/agent-jobs/jobs.js +4 -3
- package/dist/agent-jobs/node.d.ts +2 -2
- package/dist/agent-jobs/node.js +2 -2
- package/dist/backup/plan-store.node.d.ts +73 -0
- package/dist/backup/plan-store.node.js +60 -0
- package/dist/backup/push-jobs.d.ts +88 -0
- package/dist/backup/push-jobs.js +95 -0
- package/dist/backup/upload.node.d.ts +71 -0
- package/dist/backup/upload.node.js +122 -0
- package/dist/checks/coverage/diff.d.ts +2 -2
- package/dist/checks/coverage/diff.js +2 -2
- package/dist/checks/coverage/disk.d.ts +5 -5
- package/dist/checks/coverage/disk.js +5 -5
- package/dist/checks/coverage/floors.d.ts +2 -2
- package/dist/checks/coverage/floors.js +2 -2
- package/dist/checks/coverage/integrity.d.ts +10 -5
- package/dist/checks/coverage/integrity.js +12 -5
- package/dist/checks/coverage/lcov.d.ts +8 -8
- package/dist/checks/coverage/lcov.js +8 -8
- package/dist/checks/env-access.d.ts +37 -0
- package/dist/checks/env-access.js +57 -0
- package/dist/checks/hardwiring-node.d.ts +6 -3
- package/dist/checks/hardwiring-node.js +7 -6
- package/dist/checks/hardwiring.d.ts +32 -8
- package/dist/checks/hardwiring.js +395 -338
- package/dist/checks/node.d.ts +2 -2
- package/dist/checks/node.js +2 -2
- package/dist/checks/published-types/index.d.ts +10 -4
- package/dist/checks/published-types/index.js +30 -9
- package/dist/core/redirect-guard.d.ts +2 -2
- package/dist/core/redirect-guard.js +2 -2
- package/dist/deploy/adapters/undici.d.ts +8 -0
- package/dist/deploy/adapters/undici.js +6 -0
- package/dist/deploy/config-injection.d.ts +43 -0
- package/dist/deploy/config-injection.js +60 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +1 -0
- package/dist/deploy/naming.d.ts +2 -2
- package/dist/deploy/naming.js +2 -2
- package/dist/deploy/node.d.ts +17 -6
- package/dist/deploy/node.js +8 -9
- package/dist/deploy/ops-runner.d.ts +8 -6
- package/dist/deploy/ops-runner.js +7 -6
- package/dist/deploy/ops-tool-contracts.d.ts +2 -1
- package/dist/deploy/ops-tools.js +1 -1
- package/dist/deploy/reachability.d.ts +1 -1
- package/dist/deploy/reachability.js +1 -1
- package/dist/deploy/react/PublishRunResult.d.ts +24 -0
- package/dist/deploy/react/PublishRunResult.js +25 -0
- package/dist/deploy/react/index.d.ts +3 -0
- package/dist/deploy/react/index.js +2 -0
- package/dist/deploy/tool.d.ts +1 -1
- package/dist/deploy/tool.js +1 -1
- package/dist/dns/delegation.d.ts +2 -2
- package/dist/dns/delegation.js +5 -5
- package/dist/dns/node/resolver.js +30 -29
- package/dist/dns/verify.d.ts +1 -2
- package/dist/dns/verify.js +3 -3
- package/dist/local-dev/free-port.d.ts +25 -0
- package/dist/local-dev/free-port.js +44 -0
- package/dist/local-dev/index.d.ts +4 -3
- package/dist/local-dev/index.js +4 -3
- package/dist/local-dev/node-runtime.d.ts +2 -2
- package/dist/local-dev/node-runtime.js +1 -1
- package/dist/packaging/electron/archive.d.ts +5 -5
- package/dist/packaging/electron/archive.js +5 -5
- package/dist/packaging/electron/asar-adapter.d.ts +1 -1
- package/dist/packaging/electron/asar-adapter.js +1 -1
- package/dist/packaging/electron/entry.d.ts +4 -0
- package/dist/packaging/electron/entry.js +4 -0
- package/dist/packaging/electron/imports.d.ts +2 -2
- package/dist/packaging/electron/imports.js +2 -2
- package/dist/packaging/electron/isolation.d.ts +36 -0
- package/dist/packaging/electron/isolation.js +64 -0
- package/dist/packaging/electron/node.d.ts +2 -2
- package/dist/packaging/electron/node.js +2 -2
- package/dist/packaging/electron/payload-scan.d.ts +17 -0
- package/dist/packaging/electron/payload-scan.js +20 -0
- package/dist/packaging/electron/policies.d.ts +6 -6
- package/dist/packaging/electron/policies.js +6 -6
- package/dist/packaging/electron/stability.d.ts +1 -1
- package/dist/packaging/electron/stability.js +1 -1
- package/dist/packaging/electron/staging.d.ts +11 -11
- package/dist/packaging/electron/staging.js +11 -11
- package/dist/packaging/electron/tree-fingerprint.d.ts +31 -0
- package/dist/packaging/electron/tree-fingerprint.js +59 -0
- package/dist/packaging/electron/typescript.d.ts +8 -2
- package/dist/packaging/electron/typescript.js +108 -99
- package/dist/packaging/electron/update-manifest-merge.d.ts +53 -0
- package/dist/packaging/electron/update-manifest-merge.js +82 -0
- package/dist/source-control/commit.d.ts +19 -3
- package/dist/source-control/commit.js +99 -16
- package/dist/source-control/contracts.d.ts +20 -1
- package/dist/source-control/kit.d.ts +1 -1
- package/dist/source-control/kit.js +1 -1
- package/dist/source-control/registry.d.ts +2 -2
- package/dist/source-control/registry.js +2 -2
- package/dist/static-export/css-urls.d.ts +3 -1
- package/dist/static-export/css-urls.js +1 -1
- package/dist/static-export/fetch-adapter.d.ts +1 -1
- package/dist/static-export/fetch-adapter.js +1 -1
- package/dist/static-export/html-url-locations.js +1 -1
- package/dist/static-export/transforms.d.ts +4 -4
- package/dist/static-export/transforms.js +6 -6
- package/package.json +48 -14
|
@@ -35,7 +35,7 @@ function bothTiers(file, result) {
|
|
|
35
35
|
return { file, unit: { ...result }, integration: { ...result }, ok: result.ok };
|
|
36
36
|
}
|
|
37
37
|
/** Evaluate two independent tiers; missing records differ from a known branchless source file. */
|
|
38
|
-
export function evaluateFileTiers({ file, unitRec, integrationRec, thresholds }) {
|
|
38
|
+
export function evaluateFileTiers({ file, unitRec, integrationRec, thresholds }, _optional = {}) {
|
|
39
39
|
assertThresholds(thresholds);
|
|
40
40
|
const brf = sharedBranchTotal(unitRec, integrationRec);
|
|
41
41
|
if (typeof brf !== 'number')
|
|
@@ -47,7 +47,7 @@ export function evaluateFileTiers({ file, unitRec, integrationRec, thresholds })
|
|
|
47
47
|
return { file, unit, integration, ok: unit.ok && integration.ok };
|
|
48
48
|
}
|
|
49
49
|
/** Query a diff port, then parse supplied coverage artifacts only when measurable files changed. */
|
|
50
|
-
export async function checkCoverageDiff({ baseRef, repoRoot, sourceRoots, diff, reader, isMeasurable, unitCoveragePath, integrationCoveragePath, thresholds }) {
|
|
50
|
+
export async function checkCoverageDiff({ baseRef, repoRoot, sourceRoots, diff, reader, isMeasurable, unitCoveragePath, integrationCoveragePath, thresholds }, _optional = {}) {
|
|
51
51
|
const changed = [...new Set(await diff.changedFiles({ baseRef, repoRoot, sourceRoots }))].filter((file) => isMeasurable({ file }));
|
|
52
52
|
if (changed.length === 0)
|
|
53
53
|
return { ok: true, files: [] };
|
|
@@ -38,7 +38,7 @@ export interface DiskAreaResult {
|
|
|
38
38
|
/** Exclude test and declaration filenames from a production-source inventory. */
|
|
39
39
|
export declare function isMeasurableSource({ file: relPath }: {
|
|
40
40
|
file: string;
|
|
41
|
-
}): boolean;
|
|
41
|
+
}, _optional?: Record<string, never>): boolean;
|
|
42
42
|
/** Whether `relPath` is one of `excludeDirs` or lies anywhere beneath one. Anchored at the start and
|
|
43
43
|
* matched on a whole directory segment, so `src/renderer` excludes `src/renderer/x.ts` but never
|
|
44
44
|
* `src/renderer-foo/x.js`: a bare `startsWith` would move a main-process file out of its area with
|
|
@@ -48,7 +48,7 @@ export declare function isMeasurableSource({ file: relPath }: {
|
|
|
48
48
|
export declare function isInExcludedDir({ file: relPath, excludeDirs }: {
|
|
49
49
|
file: string;
|
|
50
50
|
excludeDirs: readonly string[];
|
|
51
|
-
}): boolean;
|
|
51
|
+
}, _optional?: Record<string, never>): boolean;
|
|
52
52
|
/** Splits an npm script of `&&`-chained `node [args] --test <globs>` commands into
|
|
53
53
|
* `{ nodeArgs, globs }` passes, with double quotes stripped. Every token after `--test` counts as a
|
|
54
54
|
* glob, so a flag placed there shows up as drift rather than being skipped. Any other command
|
|
@@ -56,7 +56,7 @@ export declare function isInExcludedDir({ file: relPath, excludeDirs }: {
|
|
|
56
56
|
* @complexity O(n) in script length. */
|
|
57
57
|
export declare function parseNodeTestScript({ script }: {
|
|
58
58
|
script: string;
|
|
59
|
-
}): RunnerGlobs[];
|
|
59
|
+
}, _optional?: Record<string, never>): RunnerGlobs[];
|
|
60
60
|
/** Every glob that `TEST_PASSES` and `package.json`'s parsed `test` script disagree on, one message
|
|
61
61
|
* per glob per side; empty when they agree. Globs are compared per runner as literal strings: order
|
|
62
62
|
* is ignored, a glob moved between runners is reported on both, and two spellings of one pattern
|
|
@@ -65,13 +65,13 @@ export declare function parseNodeTestScript({ script }: {
|
|
|
65
65
|
export declare function runnerSplitDrift({ passes, scriptPasses }: {
|
|
66
66
|
passes: readonly RunnerGlobs[];
|
|
67
67
|
scriptPasses: readonly RunnerGlobs[];
|
|
68
|
-
}): string[];
|
|
68
|
+
}, _optional?: Record<string, never>): string[];
|
|
69
69
|
/** Evaluate floors against an independently supplied source inventory and declared gaps. */
|
|
70
70
|
export declare function evaluateDiskArea({ area, onDisk, coverage }: {
|
|
71
71
|
area: CoverageArea;
|
|
72
72
|
onDisk: readonly string[];
|
|
73
73
|
coverage: ReadonlyMap<string, LcovCounters>;
|
|
74
|
-
}): DiskAreaResult;
|
|
74
|
+
}, _optional?: Record<string, never>): DiskAreaResult;
|
|
75
75
|
/** One area's result, rendered. The unmeasured files are named on EVERY run — a gap nobody is told
|
|
76
76
|
* about is the trap; a gap printed every run is a decision.
|
|
77
77
|
* @complexity O(n). */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// formatDiskArea; scripts/check-coverage.ts and coverage-floors.json are host-owned consumers.
|
|
3
3
|
import { pct, withoutTrailingSlashes } from './lcov.js';
|
|
4
4
|
/** Exclude test and declaration filenames from a production-source inventory. */
|
|
5
|
-
export function isMeasurableSource({ file: relPath }) {
|
|
5
|
+
export function isMeasurableSource({ file: relPath }, _optional = {}) {
|
|
6
6
|
if (/\.(test|spec)\.(js|cjs|mjs|ts|tsx|mts)$/.test(relPath))
|
|
7
7
|
return false;
|
|
8
8
|
if (relPath.endsWith(".d.ts"))
|
|
@@ -15,7 +15,7 @@ export function isMeasurableSource({ file: relPath }) {
|
|
|
15
15
|
* no failure. Both sides are desktop-root-relative and `/`-separated; a trailing `/` on a
|
|
16
16
|
* configured directory is ignored.
|
|
17
17
|
* @complexity O(d) in excluded directories. */
|
|
18
|
-
export function isInExcludedDir({ file: relPath, excludeDirs }) {
|
|
18
|
+
export function isInExcludedDir({ file: relPath, excludeDirs }, _optional = {}) {
|
|
19
19
|
return excludeDirs.some((dir) => {
|
|
20
20
|
const base = withoutTrailingSlashes({ path: dir });
|
|
21
21
|
return relPath === base || relPath.startsWith(`${base}/`);
|
|
@@ -26,7 +26,7 @@ export function isInExcludedDir({ file: relPath, excludeDirs }) {
|
|
|
26
26
|
* glob, so a flag placed there shows up as drift rather than being skipped. Any other command
|
|
27
27
|
* throws, so a script this cannot read fails loudly instead of comparing as zero globs.
|
|
28
28
|
* @complexity O(n) in script length. */
|
|
29
|
-
export function parseNodeTestScript({ script }) {
|
|
29
|
+
export function parseNodeTestScript({ script }, _optional = {}) {
|
|
30
30
|
return script.split("&&").map((command) => {
|
|
31
31
|
const tokens = [...command.matchAll(/"([^"]*)"|(\S+)/g)].map((match) => match[1] ?? match[2]);
|
|
32
32
|
const testAt = tokens.indexOf("--test");
|
|
@@ -61,7 +61,7 @@ function unmatchedGlobs(side, other) {
|
|
|
61
61
|
* is ignored, a glob moved between runners is reported on both, and two spellings of one pattern
|
|
62
62
|
* count as drift.
|
|
63
63
|
* @complexity O(g) in globs. */
|
|
64
|
-
export function runnerSplitDrift({ passes, scriptPasses }) {
|
|
64
|
+
export function runnerSplitDrift({ passes, scriptPasses }, _optional = {}) {
|
|
65
65
|
const inPasses = globsByRunner(passes);
|
|
66
66
|
const inScript = globsByRunner(scriptPasses);
|
|
67
67
|
return [
|
|
@@ -103,7 +103,7 @@ function floorFailures(area, measured) {
|
|
|
103
103
|
return { actual, failures };
|
|
104
104
|
}
|
|
105
105
|
/** Evaluate floors against an independently supplied source inventory and declared gaps. */
|
|
106
|
-
export function evaluateDiskArea({ area, onDisk, coverage }) {
|
|
106
|
+
export function evaluateDiskArea({ area, onDisk, coverage }, _optional = {}) {
|
|
107
107
|
const diskPaths = [...new Set(onDisk)];
|
|
108
108
|
const known = new Set(area.knownUnmeasured ?? []);
|
|
109
109
|
const measuredPaths = diskPaths.filter((p) => coverage.has(p));
|
|
@@ -21,11 +21,11 @@ export interface AreaFloorResult extends FloorResult {
|
|
|
21
21
|
export declare function evaluateFloor({ files, floors }: {
|
|
22
22
|
files: readonly FileCoverage[];
|
|
23
23
|
floors: CoverageFloor;
|
|
24
|
-
}): FloorResult;
|
|
24
|
+
}, _optional?: Record<string, never>): FloorResult;
|
|
25
25
|
/** Evaluate one declared area with a host classifier; the prefix must match whole directories. */
|
|
26
26
|
export declare function evaluateArea({ area, all, isMeasurable }: {
|
|
27
27
|
area: AreaFloor;
|
|
28
28
|
all: readonly FileCoverage[];
|
|
29
29
|
isMeasurable: SourceClassifier;
|
|
30
|
-
}): AreaFloorResult;
|
|
30
|
+
}, _optional?: Record<string, never>): AreaFloorResult;
|
|
31
31
|
//# sourceMappingURL=floors.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pct, withoutTrailingSlashes } from './lcov.js';
|
|
2
2
|
/** Aggregate counters before comparing percentages; an empty measurable scope always fails. */
|
|
3
|
-
export function evaluateFloor({ files, floors }) {
|
|
3
|
+
export function evaluateFloor({ files, floors }, _optional = {}) {
|
|
4
4
|
for (const value of Object.values(floors))
|
|
5
5
|
if (!Number.isFinite(value) || value < 0 || value > 100)
|
|
6
6
|
throw new RangeError('coverage floors must be percentages from 0 to 100');
|
|
@@ -16,7 +16,7 @@ export function evaluateFloor({ files, floors }) {
|
|
|
16
16
|
return { count: files.length, ...actual, failures };
|
|
17
17
|
}
|
|
18
18
|
/** Evaluate one declared area with a host classifier; the prefix must match whole directories. */
|
|
19
|
-
export function evaluateArea({ area, all, isMeasurable }) {
|
|
19
|
+
export function evaluateArea({ area, all, isMeasurable }, _optional = {}) {
|
|
20
20
|
const prefix = `${withoutTrailingSlashes({ path: area.prefix })}/`;
|
|
21
21
|
const files = all.filter((record) => record.file.startsWith(prefix) && isMeasurable({ file: record.file }));
|
|
22
22
|
return { area, ...evaluateFloor({ files, floors: { line: area.line, branch: area.branch, funcs: area.funcs } }) };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { SourceClassifier } from './lcov.js';
|
|
2
2
|
export interface LcovBlock {
|
|
3
|
+
/** Raw `SF:` path text, not yet normalized to repo-relative. */
|
|
3
4
|
readonly file: string;
|
|
4
5
|
readonly fnda: ReadonlyArray<{
|
|
5
6
|
readonly name: string;
|
|
6
7
|
readonly hits: number;
|
|
7
8
|
}>;
|
|
9
|
+
/** `DA:` hit counts only, in record order. Line numbers are deliberately not kept: the report is file-granular, and instrumented line numbers may not match source lines. */
|
|
8
10
|
readonly da: ReadonlyArray<number>;
|
|
11
|
+
/** Declared `FNF:` and `FNH:` counts can be read directly because aggregate counts are unaffected by the comment-stripping line-number bug. A record may omit either summary. */
|
|
9
12
|
readonly fnf?: number | undefined;
|
|
10
13
|
readonly fnh?: number | undefined;
|
|
11
14
|
}
|
|
@@ -17,7 +20,9 @@ export interface BlockVerdict {
|
|
|
17
20
|
readonly reason: string;
|
|
18
21
|
}
|
|
19
22
|
export interface IntegrityReport {
|
|
23
|
+
/** Every CONTAMINATED block, severe or not — filter on `.severe` for the SEVERE subset. */
|
|
20
24
|
readonly contaminated: readonly BlockVerdict[];
|
|
25
|
+
/** Number of blocks run through the heuristics, excluding skipped blocks. */
|
|
21
26
|
readonly evaluated: number;
|
|
22
27
|
readonly skipped: number;
|
|
23
28
|
}
|
|
@@ -29,11 +34,11 @@ export interface GatedVerdict extends BlockVerdict {
|
|
|
29
34
|
export declare function applyBaseline({ contaminated, baselineSet }: {
|
|
30
35
|
contaminated: readonly BlockVerdict[];
|
|
31
36
|
baselineSet: ReadonlySet<string>;
|
|
32
|
-
}): readonly GatedVerdict[];
|
|
37
|
+
}, _optional?: Record<string, never>): readonly GatedVerdict[];
|
|
33
38
|
/** Read the caller-provided baseline JSON; an absent ledger is empty. */
|
|
34
39
|
export declare function parseBaseline({ baselineJson }: {
|
|
35
40
|
baselineJson: string;
|
|
36
|
-
}): ReadonlySet<string>;
|
|
41
|
+
}, _optional?: Record<string, never>): ReadonlySet<string>;
|
|
37
42
|
export declare const DEFAULT_BASELINE_COMMENT: readonly string[];
|
|
38
43
|
/** Serialize deduplicated, sorted debt paths for reviewable changes. */
|
|
39
44
|
export declare function serializeBaseline({ paths }: {
|
|
@@ -49,15 +54,15 @@ export interface ParsedArgs {
|
|
|
49
54
|
/** Parse coverage artifact and baseline CLI arguments without process globals. */
|
|
50
55
|
export declare function parseArgs({ argv }: {
|
|
51
56
|
argv: readonly string[];
|
|
52
|
-
}): ParsedArgs;
|
|
57
|
+
}, _optional?: Record<string, never>): ParsedArgs;
|
|
53
58
|
/** Parse function and line hit records, preserving summaries when present. */
|
|
54
59
|
export declare function parseLcovBlocks({ lcovText }: {
|
|
55
60
|
lcovText: string;
|
|
56
|
-
}): LcovBlock[];
|
|
61
|
+
}, _optional?: Record<string, never>): LcovBlock[];
|
|
57
62
|
/** Recognize plain re-export barrels using the inherited source-text heuristic. */
|
|
58
63
|
export declare function isPureReExportBarrelSource({ sourceText }: {
|
|
59
64
|
sourceText: string;
|
|
60
|
-
}): boolean;
|
|
65
|
+
}, _optional?: Record<string, never>): boolean;
|
|
61
66
|
/** Classify esbuild interop contamination using the host source classifier. */
|
|
62
67
|
export declare function classifyBlock({ block, repoRoot, isFirstParty }: {
|
|
63
68
|
block: LcovBlock;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { toRepoRelative } from './lcov.js';
|
|
2
2
|
const WRAPPER_HELPER_NAMES = new Set(["__toCommonJS", "__copyProps", "__toESM", "__export"]);
|
|
3
|
+
// 30 is comfortably below the real severe block measured 2026-08-21 (357 DA records) and comfortably above a trivial single-purpose file.
|
|
3
4
|
const MIN_DA_RECORDS_FOR_SEVERE_HEURISTIC = 30;
|
|
4
5
|
/** Apply path-based debt: severe contamination can never be suppressed. */
|
|
5
|
-
export function applyBaseline({ contaminated, baselineSet }) {
|
|
6
|
+
export function applyBaseline({ contaminated, baselineSet }, _optional = {}) {
|
|
6
7
|
return contaminated.map((v) => {
|
|
7
8
|
const baselined = baselineSet.has(v.file);
|
|
8
9
|
return { ...v, baselined, fails: v.severe || !baselined };
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
12
|
/** Read the caller-provided baseline JSON; an absent ledger is empty. */
|
|
12
|
-
export function parseBaseline({ baselineJson }) {
|
|
13
|
+
export function parseBaseline({ baselineJson }, _optional = {}) {
|
|
13
14
|
const parsed = JSON.parse(baselineJson);
|
|
14
15
|
return new Set(parsed.knownContaminated ?? []);
|
|
15
16
|
}
|
|
@@ -23,7 +24,8 @@ export function serializeBaseline({ paths }, { comment = DEFAULT_BASELINE_COMMEN
|
|
|
23
24
|
return `${JSON.stringify({ _comment: comment, knownContaminated }, null, 2)}\n`;
|
|
24
25
|
}
|
|
25
26
|
/** Parse coverage artifact and baseline CLI arguments without process globals. */
|
|
26
|
-
|
|
27
|
+
// One optional positional, one value-bearing flag and one boolean flag keep this parser small enough to avoid a parsing dependency. The first non-flag argument wins, matching the permissive handling of the other check scripts.
|
|
28
|
+
export function parseArgs({ argv }, _optional = {}) {
|
|
27
29
|
let lcovArg;
|
|
28
30
|
let baselinePath;
|
|
29
31
|
let updateBaseline = false;
|
|
@@ -43,11 +45,12 @@ export function parseArgs({ argv }) {
|
|
|
43
45
|
return { lcovArg, baselinePath, updateBaseline };
|
|
44
46
|
}
|
|
45
47
|
/** Parse function and line hit records, preserving summaries when present. */
|
|
46
|
-
export function parseLcovBlocks({ lcovText }) {
|
|
48
|
+
export function parseLcovBlocks({ lcovText }, _optional = {}) {
|
|
47
49
|
const records = lcovText.replace(/\r\n/g, '\n').split(/^end_of_record$/m);
|
|
48
50
|
const blocks = [];
|
|
49
51
|
for (const record of records) {
|
|
50
52
|
const sfMatch = record.match(/^SF:(.+)$/m);
|
|
53
|
+
// A record with no `SF:` line is malformed input or text before the first block. Ignore it as the coverage loader does.
|
|
51
54
|
if (!sfMatch)
|
|
52
55
|
continue;
|
|
53
56
|
const fnda = [...record.matchAll(/^FNDA:(\d+),(.+)$/gm)].map((m) => ({
|
|
@@ -67,9 +70,11 @@ export function parseLcovBlocks({ lcovText }) {
|
|
|
67
70
|
}
|
|
68
71
|
return blocks;
|
|
69
72
|
}
|
|
73
|
+
// The `[^{}]*` class spans multiline export lists without a dot-all flag. Export specifier lists cannot contain nested braces, so the match stays within one statement. The semicolon is optional for ASI.
|
|
70
74
|
const EXPORT_FROM_STATEMENT = /export\s+(?:type\s+)?(?:\{[^{}]*\}|\*(?:\s+as\s+[A-Za-z_$][\w$]*)?)\s+from\s+["'][^"']+["']\s*;?/g;
|
|
71
75
|
/** Recognize plain re-export barrels using the inherited source-text heuristic. */
|
|
72
|
-
|
|
76
|
+
// Check the file’s source because a logic-bearing file can coincidentally have the same LCOV shape as a pure barrel. Any real declaration keeps the file subject to normal contamination checks.
|
|
77
|
+
export function isPureReExportBarrelSource({ sourceText }, _optional = {}) {
|
|
73
78
|
const withoutComments = sourceText.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
74
79
|
const matches = [...withoutComments.matchAll(EXPORT_FROM_STATEMENT)];
|
|
75
80
|
if (matches.length === 0)
|
|
@@ -95,12 +100,14 @@ function collectWrapperHits(fnda) {
|
|
|
95
100
|
return { names, values };
|
|
96
101
|
}
|
|
97
102
|
/** The SEVERE suffix when the wrapper image also won the line-hit merge, otherwise undefined. */
|
|
103
|
+
// A bare ‘few distinct DA values’ threshold flagged 53–54 first-party files in every historical validation run, including clean runs. Comparing DA values to the wrapper's own FNDA counts identified the one independently confirmed corrupt block across the six runs.
|
|
98
104
|
function severeLineMergeReason(da, wrapperValues) {
|
|
99
105
|
// A tiny barrel can share hit counts by coincidence. Escalation requires enough DA records
|
|
100
106
|
// and a nonzero overlap with the wrapper's own counts; all-zero runs carry no merge signal.
|
|
101
107
|
if (da.length < MIN_DA_RECORDS_FOR_SEVERE_HEURISTIC)
|
|
102
108
|
return undefined;
|
|
103
109
|
const comparisonSet = new Set(wrapperValues);
|
|
110
|
+
// Dead or unreached code under either image legitimately reads 0.
|
|
104
111
|
comparisonSet.add(0);
|
|
105
112
|
const distinctDa = [...new Set(da)].sort((a, b) => a - b);
|
|
106
113
|
const extra = distinctDa.filter((value) => !comparisonSet.has(value));
|
|
@@ -32,7 +32,7 @@ export type SourceClassifier = (args: {
|
|
|
32
32
|
export declare function pct({ hit, found }: {
|
|
33
33
|
hit: number;
|
|
34
34
|
found: number;
|
|
35
|
-
}): number;
|
|
35
|
+
}, _optional?: Record<string, never>): number;
|
|
36
36
|
/** Strip a path's trailing separators in one backward pass, including all-separator paths.
|
|
37
37
|
* @complexity O(path length) time, O(path length) for the returned slice. */
|
|
38
38
|
export declare function withoutTrailingSlashes({ path }: {
|
|
@@ -42,42 +42,42 @@ export declare function withoutTrailingSlashes({ path }: {
|
|
|
42
42
|
export declare function toRepoRelative({ sourceFile, repoRoot }: {
|
|
43
43
|
sourceFile: string;
|
|
44
44
|
repoRoot: string;
|
|
45
|
-
}): string;
|
|
45
|
+
}, _optional?: Record<string, never>): string;
|
|
46
46
|
/** Match caller-supplied integration suffixes and directory segments. */
|
|
47
47
|
export declare function isIntegrationTestFile({ file, suffixes, directories }: {
|
|
48
48
|
file: string;
|
|
49
49
|
suffixes: readonly string[];
|
|
50
50
|
directories: readonly string[];
|
|
51
|
-
}): boolean;
|
|
51
|
+
}, _optional?: Record<string, never>): boolean;
|
|
52
52
|
/** Match source roots on directory boundaries and apply host-defined exclusions. */
|
|
53
53
|
export declare function isMeasurableSourceFile({ file, rules }: {
|
|
54
54
|
file: string;
|
|
55
55
|
rules: SourceClassificationRules;
|
|
56
|
-
}): boolean;
|
|
56
|
+
}, _optional?: Record<string, never>): boolean;
|
|
57
57
|
/** Parse LCOV summaries without filtering source or accessing a filesystem. */
|
|
58
58
|
export declare function parseLcov({ text, repoRoot }: {
|
|
59
59
|
text: string;
|
|
60
60
|
repoRoot: string;
|
|
61
|
-
}): FileCoverage[];
|
|
61
|
+
}, _optional?: Record<string, never>): FileCoverage[];
|
|
62
62
|
/** Read the exact supplied artifact; missing/unreadable artifacts propagate the reader's error. */
|
|
63
63
|
export declare function loadLcov({ lcovPath, repoRoot, reader }: {
|
|
64
64
|
lcovPath: string;
|
|
65
65
|
repoRoot: string;
|
|
66
66
|
reader: SourceReaderPort;
|
|
67
|
-
}): FileCoverage[];
|
|
67
|
+
}, _optional?: Record<string, never>): FileCoverage[];
|
|
68
68
|
/** Load and classify coverage without repository-specific route knowledge. */
|
|
69
69
|
export declare function loadRouteCoverage({ lcovPath, repoRoot, reader, isMeasurable }: {
|
|
70
70
|
lcovPath: string;
|
|
71
71
|
repoRoot: string;
|
|
72
72
|
reader: SourceReaderPort;
|
|
73
73
|
isMeasurable: SourceClassifier;
|
|
74
|
-
}): FileCoverage[];
|
|
74
|
+
}, _optional?: Record<string, never>): FileCoverage[];
|
|
75
75
|
/** Union separate reports by line, branch and function identity without double counting.
|
|
76
76
|
* @throws If duplicate records cannot be unioned from matching entry-level evidence.
|
|
77
77
|
* @complexity O(e) time and space in supplied entries. */
|
|
78
78
|
export declare function mergeCoverage({ reports, isMeasurable }: {
|
|
79
79
|
reports: readonly (readonly FileCoverage[])[];
|
|
80
80
|
isMeasurable: SourceClassifier;
|
|
81
|
-
}): ReadonlyMap<string, FileCoverage>;
|
|
81
|
+
}, _optional?: Record<string, never>): ReadonlyMap<string, FileCoverage>;
|
|
82
82
|
export {};
|
|
83
83
|
//# sourceMappingURL=lcov.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* area was measured at all.
|
|
5
5
|
* @complexity O(1). */
|
|
6
6
|
// evaluateArea is the disk inventory owner, now evaluateDiskArea in ./disk.ts.
|
|
7
|
-
export function pct({ hit, found }) { return found === 0 ? 100 : 100 * hit / found; }
|
|
7
|
+
export function pct({ hit, found }, _optional = {}) { return found === 0 ? 100 : 100 * hit / found; }
|
|
8
8
|
/** Strip a path's trailing separators in one backward pass, including all-separator paths.
|
|
9
9
|
* @complexity O(path length) time, O(path length) for the returned slice. */
|
|
10
10
|
export function withoutTrailingSlashes({ path }, _options = {}) {
|
|
@@ -14,7 +14,7 @@ export function withoutTrailingSlashes({ path }, _options = {}) {
|
|
|
14
14
|
return path.slice(0, end);
|
|
15
15
|
}
|
|
16
16
|
/** Normalize paths with a directory boundary check, including Windows paths on non-Windows hosts. */
|
|
17
|
-
export function toRepoRelative({ sourceFile, repoRoot }) {
|
|
17
|
+
export function toRepoRelative({ sourceFile, repoRoot }, _optional = {}) {
|
|
18
18
|
const file = sourceFile.trim().replace(/\\/g, '/');
|
|
19
19
|
const root = withoutTrailingSlashes({ path: repoRoot.replace(/\\/g, '/') });
|
|
20
20
|
if (file === root)
|
|
@@ -24,12 +24,12 @@ export function toRepoRelative({ sourceFile, repoRoot }) {
|
|
|
24
24
|
return file;
|
|
25
25
|
}
|
|
26
26
|
/** Match caller-supplied integration suffixes and directory segments. */
|
|
27
|
-
export function isIntegrationTestFile({ file, suffixes, directories }) {
|
|
27
|
+
export function isIntegrationTestFile({ file, suffixes, directories }, _optional = {}) {
|
|
28
28
|
const normalized = file.replace(/\\/g, '/');
|
|
29
29
|
return suffixes.some((suffix) => normalized.endsWith(suffix)) || directories.some((dir) => `/${normalized}`.includes(`/${withoutTrailingSlashes({ path: dir.replace(/^\/+/, '') })}/`));
|
|
30
30
|
}
|
|
31
31
|
/** Match source roots on directory boundaries and apply host-defined exclusions. */
|
|
32
|
-
export function isMeasurableSourceFile({ file, rules }) {
|
|
32
|
+
export function isMeasurableSourceFile({ file, rules }, _optional = {}) {
|
|
33
33
|
const normalized = file.replace(/\\/g, '/');
|
|
34
34
|
if (!rules.prefixes.some((prefix) => normalized.startsWith(`${withoutTrailingSlashes({ path: prefix })}/`)))
|
|
35
35
|
return false;
|
|
@@ -81,7 +81,7 @@ function readFunctionEntries(record) {
|
|
|
81
81
|
return entries;
|
|
82
82
|
}
|
|
83
83
|
/** Parse LCOV summaries without filtering source or accessing a filesystem. */
|
|
84
|
-
export function parseLcov({ text, repoRoot }) {
|
|
84
|
+
export function parseLcov({ text, repoRoot }, _optional = {}) {
|
|
85
85
|
const out = [];
|
|
86
86
|
for (const record of text.replace(/\r\n/g, '\n').split(/^end_of_record$/m)) {
|
|
87
87
|
const source = record.match(/^SF:(.+)$/m)?.[1];
|
|
@@ -93,11 +93,11 @@ export function parseLcov({ text, repoRoot }) {
|
|
|
93
93
|
return out;
|
|
94
94
|
}
|
|
95
95
|
/** Read the exact supplied artifact; missing/unreadable artifacts propagate the reader's error. */
|
|
96
|
-
export function loadLcov({ lcovPath, repoRoot, reader }) {
|
|
96
|
+
export function loadLcov({ lcovPath, repoRoot, reader }, _optional = {}) {
|
|
97
97
|
return parseLcov({ text: reader.readText({ path: lcovPath }), repoRoot });
|
|
98
98
|
}
|
|
99
99
|
/** Load and classify coverage without repository-specific route knowledge. */
|
|
100
|
-
export function loadRouteCoverage({ lcovPath, repoRoot, reader, isMeasurable }) { return loadLcov({ lcovPath, repoRoot, reader }).filter((record) => isMeasurable({ file: record.file })); }
|
|
100
|
+
export function loadRouteCoverage({ lcovPath, repoRoot, reader, isMeasurable }, _optional = {}) { return loadLcov({ lcovPath, repoRoot, reader }).filter((record) => isMeasurable({ file: record.file })); }
|
|
101
101
|
/** Union matching instrumentation; summaries alone cannot identify overlapping hits.
|
|
102
102
|
* @throws When reports lack entries or use incompatible instrumentation.
|
|
103
103
|
* @complexity O(e) time and space in entries. */
|
|
@@ -125,7 +125,7 @@ function unionRecords(a, b) {
|
|
|
125
125
|
/** Union separate reports by line, branch and function identity without double counting.
|
|
126
126
|
* @throws If duplicate records cannot be unioned from matching entry-level evidence.
|
|
127
127
|
* @complexity O(e) time and space in supplied entries. */
|
|
128
|
-
export function mergeCoverage({ reports, isMeasurable }) {
|
|
128
|
+
export function mergeCoverage({ reports, isMeasurable }, _optional = {}) {
|
|
129
129
|
const byFile = new Map();
|
|
130
130
|
for (const report of reports)
|
|
131
131
|
for (const record of report) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Environment-access rules of the hardwiring audit.
|
|
2
|
+
*
|
|
3
|
+
* Reading configuration from the ambient environment is the job of a process entry. Everything
|
|
4
|
+
* else receives a value or an environment map from its host. These rules report the code that
|
|
5
|
+
* reaches for the ambient object itself; the host classifies each file (it owns the list of
|
|
6
|
+
* entries) and keeps existing occurrences in a debt file that may only shrink.
|
|
7
|
+
*
|
|
8
|
+
* They share the hardwiring inspector's parser, its definition of `process.env` and of module
|
|
9
|
+
* scope, its violation shape and its debt ratchet (`diffHardwiringDebt`), so one waiver format
|
|
10
|
+
* covers both audits. Name-based rules (which names exist, which may be read from an injected
|
|
11
|
+
* map) need the host's schema and are added with it; nothing here keeps a list of names.
|
|
12
|
+
*/
|
|
13
|
+
import type ts from 'typescript';
|
|
14
|
+
import type { createHardwiringInspector, HardwiringViolation } from './hardwiring.js';
|
|
15
|
+
export declare const ENV_ACCESS_RULES: readonly ["HW9-env-access", "HW12-env-import-time"];
|
|
16
|
+
export interface EnvAccessSource {
|
|
17
|
+
file: string;
|
|
18
|
+
source: string;
|
|
19
|
+
/** A declared process entry (a `bin` target, a host entry): it may touch the ambient environment. */
|
|
20
|
+
envRoot: boolean;
|
|
21
|
+
/** The owning package runs in a browser, DOM or universal runtime. There a bundler replaces the
|
|
22
|
+
* exact expression `process.env.NODE_ENV` with a constant, so it is a build define, not a read. */
|
|
23
|
+
buildDefine: boolean;
|
|
24
|
+
}
|
|
25
|
+
type HardwiringInspector = ReturnType<typeof createHardwiringInspector>;
|
|
26
|
+
/** Bind the installed compiler and the hardwiring inspector whose helpers these rules reuse.
|
|
27
|
+
* Inspection is one O(n) walk over the file's AST nodes; no I/O, no module state.
|
|
28
|
+
* Only the env name (or the ambient object's own name) is hashed for debt identity.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createEnvAccessInspector({ compiler: c, inspector }: {
|
|
31
|
+
compiler: typeof ts;
|
|
32
|
+
inspector: HardwiringInspector;
|
|
33
|
+
}, _options?: Record<string, never>): {
|
|
34
|
+
inspect: (input: EnvAccessSource, _options?: Record<string, never>) => HardwiringViolation[];
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=env-access.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const ENV_ACCESS_RULES = ['HW9-env-access', 'HW12-env-import-time'];
|
|
2
|
+
const ACCESS_REASON = 'Only a declared process entry may touch process.env or import.meta.env; take the value or an environment map from the host.';
|
|
3
|
+
const IMPORT_TIME_REASON = 'This environment read runs while the module is being imported, before a host can supply configuration; move it into the process entry.';
|
|
4
|
+
/** Bind the installed compiler and the hardwiring inspector whose helpers these rules reuse.
|
|
5
|
+
* Inspection is one O(n) walk over the file's AST nodes; no I/O, no module state.
|
|
6
|
+
* Only the env name (or the ambient object's own name) is hashed for debt identity.
|
|
7
|
+
*/
|
|
8
|
+
export function createEnvAccessInspector({ compiler: c, inspector }, _options = {}) {
|
|
9
|
+
function isImportMetaEnv({ node }) {
|
|
10
|
+
return c.isPropertyAccessExpression(node) && node.name.text === 'env' &&
|
|
11
|
+
c.isMetaProperty(node.expression) && node.expression.keywordToken === c.SyntaxKind.ImportKeyword;
|
|
12
|
+
}
|
|
13
|
+
function ambientEnv({ node }) {
|
|
14
|
+
if (inspector.isProcessEnv({ node }))
|
|
15
|
+
return 'process.env';
|
|
16
|
+
return isImportMetaEnv({ node }) ? 'import.meta.env' : undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The static name read directly off the ambient object (`process.env.X`, `import.meta.env['X']`). */
|
|
19
|
+
function staticKey({ node }) {
|
|
20
|
+
const parent = node.parent;
|
|
21
|
+
if (c.isPropertyAccessExpression(parent) && parent.expression === node)
|
|
22
|
+
return parent.name.text;
|
|
23
|
+
if (c.isElementAccessExpression(parent) && parent.expression === node && c.isStringLiteralLike(parent.argumentExpression))
|
|
24
|
+
return parent.argumentExpression.text;
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Only the exact expression is a define: `process.env`, `process.env[name]` and other keys stay reads. */
|
|
28
|
+
function isBuildDefine({ input, owner, key }) {
|
|
29
|
+
return input.buildDefine && owner === 'process.env' && key === 'NODE_ENV';
|
|
30
|
+
}
|
|
31
|
+
/** Report every reference to the ambient environment outside a process entry.
|
|
32
|
+
* A module-scope reference is reported under both rules: it is an access, and it runs at import.
|
|
33
|
+
* Reads reached through a call made at module scope are invisible to a syntax rule; an
|
|
34
|
+
* import-recording test in the host covers those.
|
|
35
|
+
*/
|
|
36
|
+
function inspect(input, _options = {}) {
|
|
37
|
+
const tree = inspector.parse(input);
|
|
38
|
+
if (input.envRoot)
|
|
39
|
+
return [];
|
|
40
|
+
const found = [];
|
|
41
|
+
function visit(node) {
|
|
42
|
+
const owner = ambientEnv({ node });
|
|
43
|
+
const key = owner ? staticKey({ node }) : undefined;
|
|
44
|
+
if (owner && !isBuildDefine({ input, owner, key })) {
|
|
45
|
+
const identity = key ?? owner;
|
|
46
|
+
found.push(inspector.violation({ tree, node, rule: 'HW9-env-access', reason: ACCESS_REASON, identity }));
|
|
47
|
+
if (inspector.isModuleScope({ node }))
|
|
48
|
+
found.push(inspector.violation({ tree, node, rule: 'HW12-env-import-time', reason: IMPORT_TIME_REASON, identity }));
|
|
49
|
+
}
|
|
50
|
+
c.forEachChild(node, visit);
|
|
51
|
+
}
|
|
52
|
+
visit(tree);
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
return { inspect };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=env-access.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
|
+
import { type Logger } from '@jini-ai/core/primitives';
|
|
2
3
|
import type { HardwiringViolation } from './hardwiring.js';
|
|
3
4
|
/** Authored inventory excludes generated output, fixtures and tests. O(directory entries). */
|
|
4
5
|
export declare function sourceFiles({ directory, declarations }: {
|
|
@@ -32,12 +33,14 @@ export declare function installedPublicFunctions({ root, compiler: c }: {
|
|
|
32
33
|
compiler: typeof ts;
|
|
33
34
|
}, _options?: Record<string, never>): ReadonlySet<string>;
|
|
34
35
|
/** Shared occurrence ratchet and the sole debt generator. Never regenerate baselines in CI. */
|
|
35
|
-
export declare function runHardwiring({ collect, debtPath, baselineComment,
|
|
36
|
+
export declare function runHardwiring({ collect, debtPath, baselineComment, report }: {
|
|
36
37
|
collect: () => readonly HardwiringViolation[] | Promise<readonly HardwiringViolation[]>;
|
|
37
38
|
debtPath: string;
|
|
38
39
|
baselineComment: string;
|
|
39
|
-
|
|
40
|
-
}, { writeBaseline }?: {
|
|
40
|
+
report?: Pick<Logger, 'info' | 'error'>;
|
|
41
|
+
}, { writeBaseline, rules }?: {
|
|
41
42
|
writeBaseline?: boolean;
|
|
43
|
+
/** The rule family this run reports on; a host with a separate debt file per family passes that family's rules. */
|
|
44
|
+
rules?: readonly string[];
|
|
42
45
|
}): Promise<HardwiringViolation[]>;
|
|
43
46
|
//# sourceMappingURL=hardwiring-node.d.ts.map
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
6
6
|
import { isBuiltin } from 'node:module';
|
|
7
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
7
8
|
import { diffHardwiringDebt, HARDWIRING_RULES, syntaxError } from './hardwiring.js';
|
|
8
9
|
const SKIPPED_DIRECTORY_NAMES = new Set(['node_modules', 'dist', 'build', 'coverage', 'release', 'release-verify', 'staging', '__tests__', '__measurements__', 'fixtures', 'vendor', '.git', '.build']);
|
|
9
10
|
/** JS/TS source that is not a test; declaration files only when asked for. */
|
|
@@ -186,18 +187,18 @@ export function installedPublicFunctions({ root, compiler: c }, _options = {}) {
|
|
|
186
187
|
return found;
|
|
187
188
|
}
|
|
188
189
|
/** Shared occurrence ratchet and the sole debt generator. Never regenerate baselines in CI. */
|
|
189
|
-
export async function runHardwiring({ collect, debtPath, baselineComment,
|
|
190
|
+
export async function runHardwiring({ collect, debtPath, baselineComment, report = createConsoleLogger({ prefix: '' }) }, { writeBaseline = false, rules = HARDWIRING_RULES } = {}) {
|
|
190
191
|
const violations = await collect();
|
|
191
192
|
if (writeBaseline)
|
|
192
193
|
writeFileSync(debtPath, JSON.stringify({ _comment: baselineComment, violations }, null, 2) + '\n');
|
|
193
194
|
const debt = JSON.parse(readFileSync(debtPath, 'utf8'));
|
|
194
195
|
const { added, removed } = diffHardwiringDebt({ baseline: debt.violations, current: violations });
|
|
195
|
-
for (const rule of
|
|
196
|
-
|
|
196
|
+
for (const rule of rules)
|
|
197
|
+
report.info({ message: `[hardwiring] ${rule}: ${violations.filter(v => v.rule === rule).length} total; ${added.filter(v => v.rule === rule).length} new` });
|
|
197
198
|
if (removed.length)
|
|
198
|
-
|
|
199
|
-
for (const
|
|
200
|
-
|
|
199
|
+
report.info({ message: `[hardwiring] ${removed.length} stale debt occurrences; remove them from ${debtPath}.` });
|
|
200
|
+
for (const { rule, file, line, reason: why } of added)
|
|
201
|
+
report.error({ message: `[hardwiring] ${rule} ${file}:${line}: ${why}` });
|
|
201
202
|
return added;
|
|
202
203
|
}
|
|
203
204
|
//# sourceMappingURL=hardwiring-node.js.map
|
|
@@ -28,6 +28,17 @@ export declare function syntaxError({ tree, file }: {
|
|
|
28
28
|
file: string;
|
|
29
29
|
}, _options?: Record<string, never>): Error | undefined;
|
|
30
30
|
export declare const HARDWIRING_RULES: readonly ["HW1-env-default", "HW2-vendor-adapter", "HW3-module-state", "HW4-injected-fetch", "HW5-jini-export", "HW6-boot-default", "HW7-public-react", "HW8-provider-url", "HW9-plugin-import"];
|
|
31
|
+
/** Traverse every runtime edge, including dynamic imports, barrels and CommonJS requires.
|
|
32
|
+
* O(V + E) visits with a set: cycles and diamond imports never rescan a module.
|
|
33
|
+
* Host resolver supplies browser/package-export conditions and fails on unresolved code edges.
|
|
34
|
+
*/
|
|
35
|
+
declare function inspectPublicGraph({ c, entries, readSource, resolveImport, displayFile }: {
|
|
36
|
+
c: typeof ts;
|
|
37
|
+
entries: readonly string[];
|
|
38
|
+
readSource: (file: string) => string;
|
|
39
|
+
resolveImport: (specifier: string, file: string) => string | undefined;
|
|
40
|
+
displayFile: (file: string) => string;
|
|
41
|
+
}): HardwiringViolation[];
|
|
31
42
|
/** Bind the installed compiler, keeping this optional parser out of the runtime dependency graph.
|
|
32
43
|
* Inspection is O(n) AST nodes, plus lexical-scope scans for bare fetch calls; no external I/O.
|
|
33
44
|
* Only the rule-identifying value is hashed for debt identity and never included in diagnostics (it may contain secrets).
|
|
@@ -36,13 +47,8 @@ export declare function createHardwiringInspector({ compiler: c }: {
|
|
|
36
47
|
compiler: typeof ts;
|
|
37
48
|
}, _options?: Record<string, never>): {
|
|
38
49
|
inspect: (input: HardwiringSource, _options?: Record<string, never>) => HardwiringViolation[];
|
|
39
|
-
inspectPublicGraph: (
|
|
40
|
-
|
|
41
|
-
readSource: (file: string) => string;
|
|
42
|
-
resolveImport: (specifier: string, file: string) => string | undefined;
|
|
43
|
-
displayFile: (file: string) => string;
|
|
44
|
-
}, _options?: Record<string, never>) => HardwiringViolation[];
|
|
45
|
-
parse: ({ file, source }: {
|
|
50
|
+
inspectPublicGraph: (required: Omit<Parameters<typeof inspectPublicGraph>[0], "c">, _options?: Record<string, never>) => HardwiringViolation[];
|
|
51
|
+
parse: (required: {
|
|
46
52
|
file: string;
|
|
47
53
|
source: string;
|
|
48
54
|
}, _options?: Record<string, never>) => ts.SourceFile;
|
|
@@ -50,7 +56,7 @@ export declare function createHardwiringInspector({ compiler: c }: {
|
|
|
50
56
|
tree: ts.SourceFile;
|
|
51
57
|
includeTypeOnly?: boolean;
|
|
52
58
|
}, _options?: Record<string, never>) => RuntimeImport[];
|
|
53
|
-
exportedFunctions: (
|
|
59
|
+
exportedFunctions: (required: {
|
|
54
60
|
tree: ts.SourceFile;
|
|
55
61
|
}, _options?: Record<string, never>) => {
|
|
56
62
|
name: string;
|
|
@@ -59,6 +65,23 @@ export declare function createHardwiringInspector({ compiler: c }: {
|
|
|
59
65
|
envKey: ({ node }: {
|
|
60
66
|
node: ts.Node;
|
|
61
67
|
}, _options?: Record<string, never>) => string | undefined;
|
|
68
|
+
hasLocalBinding: ({ node, name }: {
|
|
69
|
+
node: ts.Node;
|
|
70
|
+
name: string;
|
|
71
|
+
}, _options?: Record<string, never>) => boolean;
|
|
72
|
+
isProcessEnv: ({ node }: {
|
|
73
|
+
node: ts.Node;
|
|
74
|
+
}, _options?: Record<string, never>) => boolean;
|
|
75
|
+
isModuleScope: ({ node }: {
|
|
76
|
+
node: ts.Node;
|
|
77
|
+
}, _options?: Record<string, never>) => boolean;
|
|
78
|
+
violation: (required: {
|
|
79
|
+
tree: ts.SourceFile;
|
|
80
|
+
node: ts.Node;
|
|
81
|
+
rule: string;
|
|
82
|
+
reason: string;
|
|
83
|
+
identity: string;
|
|
84
|
+
}, _options?: Record<string, never>) => HardwiringViolation;
|
|
62
85
|
};
|
|
63
86
|
/** Occurrence-based debt ratchet: adding a duplicate in an already listed file still fails.
|
|
64
87
|
* Line shifts and body edits do not create debt; new identifying values cannot inherit waivers. O(n) time/space.
|
|
@@ -70,4 +93,5 @@ export declare function diffHardwiringDebt({ baseline, current }: {
|
|
|
70
93
|
added: HardwiringViolation[];
|
|
71
94
|
removed: HardwiringViolation[];
|
|
72
95
|
};
|
|
96
|
+
export {};
|
|
73
97
|
//# sourceMappingURL=hardwiring.d.ts.map
|