@agent-teams/engineering-foundation 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capabilities/public-api-compatibility/adapters/inbound/configuration/load-native-tool-transition.d.ts +20 -0
- package/dist/capabilities/public-api-compatibility/adapters/inbound/configuration/load-native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/inbound/configuration/load-native-tool-transition.js +60 -0
- package/dist/capabilities/public-api-compatibility/adapters/inbound/configuration/load-native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/audit-compiler-bindings.d.ts +9 -7
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/audit-compiler-bindings.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/audit-compiler-bindings.js +128 -76
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/audit-compiler-bindings.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/load-pinned-audit-sdk.d.ts +5 -6
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/load-pinned-audit-sdk.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/load-pinned-audit-sdk.js +34 -10
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/load-pinned-audit-sdk.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.d.ts +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js +48 -138
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-extractor.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-observer.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-observer.js +248 -211
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/microsoft-public-api-observer.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-engine.d.ts +35 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-engine.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-engine.js +97 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-engine.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-excerpt.d.ts +42 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-excerpt.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-excerpt.js +199 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-excerpt.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-inputs.d.ts +9 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-inputs.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-inputs.js +197 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-inputs.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-item.d.ts +23 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-item.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-item.js +103 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-item.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-model.d.ts +19 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-model.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-model.js +250 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-model.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-reference.d.ts +21 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-reference.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-reference.js +269 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/native-public-api-reference.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/growth-invocation.js +3 -3
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/growth-invocation.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-tool-transition-content.d.ts +14 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-tool-transition-content.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-tool-transition-content.js +40 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-tool-transition-content.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-transition-archive.d.ts +18 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-transition-archive.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-transition-archive.js +152 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/native-transition-archive.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/observe-native-tool-transition.d.ts +24 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/observe-native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/observe-native-tool-transition.js +199 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/filesystem/observe-native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/model/native-tool-transition.d.ts +76 -0
- package/dist/capabilities/public-api-compatibility/application/model/native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/model/native-tool-transition.js +35 -0
- package/dist/capabilities/public-api-compatibility/application/model/native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/policies/validate-native-tool-transition.d.ts +7 -0
- package/dist/capabilities/public-api-compatibility/application/policies/validate-native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/policies/validate-native-tool-transition.js +55 -0
- package/dist/capabilities/public-api-compatibility/application/policies/validate-native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/ports/native-tool-transition.d.ts +10 -0
- package/dist/capabilities/public-api-compatibility/application/ports/native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/ports/native-tool-transition.js +2 -0
- package/dist/capabilities/public-api-compatibility/application/ports/native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/use-cases/prepare-native-tool-transition.d.ts +29 -0
- package/dist/capabilities/public-api-compatibility/application/use-cases/prepare-native-tool-transition.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/application/use-cases/prepare-native-tool-transition.js +124 -0
- package/dist/capabilities/public-api-compatibility/application/use-cases/prepare-native-tool-transition.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/module.js +2 -2
- package/dist/capabilities/public-api-compatibility/module.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/native-transition-module.d.ts +37 -0
- package/dist/capabilities/public-api-compatibility/native-transition-module.d.ts.map +1 -0
- package/dist/capabilities/public-api-compatibility/native-transition-module.js +44 -0
- package/dist/capabilities/public-api-compatibility/native-transition-module.js.map +1 -0
- package/dist/capabilities/public-api-compatibility/node.d.ts +2 -0
- package/dist/capabilities/public-api-compatibility/node.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/node.js +1 -0
- package/dist/capabilities/public-api-compatibility/node.js.map +1 -1
- package/dist/capabilities/public-api-compatibility/schemas.d.ts +1 -1
- package/dist/capabilities/public-api-compatibility/schemas.d.ts.map +1 -1
- package/dist/capabilities/public-api-compatibility/schemas.js +1 -0
- package/dist/capabilities/public-api-compatibility/schemas.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/adapters/inbound/configuration/load-quality-gate-policy.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/adapters/inbound/configuration/load-quality-gate-policy.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/adapters/inbound/configuration/parse-quality-gate-policy.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/adapters/inbound/configuration/parse-quality-gate-policy.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/adapters/inbound/configuration/parse-quality-gate-policy.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/model/quality-gate.d.ts +11 -3
- package/dist/capabilities/quality-gate-runner/application/model/quality-gate.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/policies/evaluate-quality-gate-scripts.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/application/policies/evaluate-quality-gate-scripts.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/policies/evaluate-quality-gate-scripts.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/policies/validate-quality-gate-graph.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/application/policies/validate-quality-gate-graph.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/policies/validate-quality-gate-graph.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/ports/quality-gate-policy-loader.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/application/ports/quality-gate-policy-loader.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/analyze-quality-gate-runner.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/application/use-cases/analyze-quality-gate-runner.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/create-quality-gate-command.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/create-quality-gate-command.js +12 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/create-quality-gate-command.js.map +1 -1
- package/dist/capabilities/quality-gate-runner/application/use-cases/run-quality-gate-profile.d.ts +2 -2
- package/dist/capabilities/quality-gate-runner/application/use-cases/run-quality-gate-profile.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/composition/node-quality-gate-command.d.ts.map +1 -1
- package/dist/capabilities/quality-gate-runner/composition/node-quality-gate-command.js +4 -2
- package/dist/capabilities/quality-gate-runner/composition/node-quality-gate-command.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/load-agent-workflow-policy.d.ts +1 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/load-agent-workflow-policy.d.ts.map +1 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/load-agent-workflow-policy.js +4 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/load-agent-workflow-policy.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/parse-agent-workflow-policy.d.ts.map +1 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/parse-agent-workflow-policy.js +15 -1
- package/dist/capabilities/repository-agent-workflow/adapters/inbound/configuration/parse-agent-workflow-policy.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.d.ts.map +1 -1
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.js +4 -2
- package/dist/capabilities/repository-agent-workflow/application/policies/evaluate-repository-agent-workflow.js.map +1 -1
- package/dist/capabilities/repository-agent-workflow/schemas.d.ts +1 -1
- package/dist/capabilities/repository-agent-workflow/schemas.d.ts.map +1 -1
- package/dist/capabilities/repository-agent-workflow/schemas.js +2 -1
- package/dist/capabilities/repository-agent-workflow/schemas.js.map +1 -1
- package/dist/capabilities/source-dependencies/adapters/outbound/node/node-source-dependency-resolver.d.ts.map +1 -1
- package/dist/capabilities/source-dependencies/adapters/outbound/node/node-source-dependency-resolver.js +2 -6
- package/dist/capabilities/source-dependencies/adapters/outbound/node/node-source-dependency-resolver.js.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/adapters/inbound/filesystem/load-capability-config.d.ts +1 -1
- package/dist/capabilities/workspace-dependency-declarations/adapters/inbound/filesystem/load-capability-config.d.ts.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/adapters/inbound/filesystem/load-capability-config.js +4 -1
- package/dist/capabilities/workspace-dependency-declarations/adapters/inbound/filesystem/load-capability-config.js.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/adapters/inbound/filesystem/parse-capability-config.js.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/application/model/workspace-dependency-settings.d.ts +1 -1
- package/dist/capabilities/workspace-dependency-declarations/application/model/workspace-dependency-settings.d.ts.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/application/policies/evaluate-workspace-dependencies.d.ts +2 -1
- package/dist/capabilities/workspace-dependency-declarations/application/policies/evaluate-workspace-dependencies.d.ts.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/application/policies/evaluate-workspace-dependencies.js +10 -7
- package/dist/capabilities/workspace-dependency-declarations/application/policies/evaluate-workspace-dependencies.js.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/module.js +1 -1
- package/dist/capabilities/workspace-dependency-declarations/module.js.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/schemas.d.ts +1 -1
- package/dist/capabilities/workspace-dependency-declarations/schemas.d.ts.map +1 -1
- package/dist/capabilities/workspace-dependency-declarations/schemas.js +2 -1
- package/dist/capabilities/workspace-dependency-declarations/schemas.js.map +1 -1
- package/dist/features/command-host/adapters/inbound/cli/cli-arguments.d.ts.map +1 -1
- package/dist/features/command-host/adapters/inbound/cli/cli-arguments.js +18 -0
- package/dist/features/command-host/adapters/inbound/cli/cli-arguments.js.map +1 -1
- package/dist/features/command-host/adapters/inbound/cli/foundation-cli.d.ts.map +1 -1
- package/dist/features/command-host/adapters/inbound/cli/foundation-cli.js +9 -1
- package/dist/features/command-host/adapters/inbound/cli/foundation-cli.js.map +1 -1
- package/dist/features/command-host/application/command-invocation.d.ts +2 -0
- package/dist/features/command-host/application/command-invocation.d.ts.map +1 -1
- package/dist/features/command-host/application/command-invocation.js.map +1 -1
- package/dist/features/command-host/application/command-services.d.ts +4 -0
- package/dist/features/command-host/application/command-services.d.ts.map +1 -1
- package/dist/features/command-host/composition/node-command-host.d.ts +2 -2
- package/dist/features/command-host/composition/node-command-host.d.ts.map +1 -1
- package/dist/features/command-host/composition/node-command-host.js +8 -5
- package/dist/features/command-host/composition/node-command-host.js.map +1 -1
- package/dist/features/quality-coverage/adapters/consumer-observations.d.ts.map +1 -1
- package/dist/features/quality-coverage/adapters/consumer-observations.js +7 -2
- package/dist/features/quality-coverage/adapters/consumer-observations.js.map +1 -1
- package/dist/features/quality-coverage/api.d.ts +1 -1
- package/dist/features/quality-coverage/api.d.ts.map +1 -1
- package/dist/features/quality-coverage/api.js +1 -1
- package/dist/features/quality-coverage/api.js.map +1 -1
- package/dist/features/quality-coverage/application/script-route.d.ts.map +1 -1
- package/dist/features/quality-coverage/application/script-route.js +11 -7
- package/dist/features/quality-coverage/application/script-route.js.map +1 -1
- package/dist/process-execution/module.d.ts +1 -1
- package/dist/process-execution/module.d.ts.map +1 -1
- package/dist/process-execution/module.js +1 -1
- package/dist/process-execution/module.js.map +1 -1
- package/dist/process-execution/node-process-runner.d.ts.map +1 -1
- package/dist/process-execution/node-process-runner.js +19 -6
- package/dist/process-execution/node-process-runner.js.map +1 -1
- package/dist/schema-catalog.d.ts +1 -1
- package/dist/schema-catalog.d.ts.map +1 -1
- package/dist/schema-ids.d.ts +1 -1
- package/dist/schema-ids.d.ts.map +1 -1
- package/package.json +8 -4
- package/schemas/package-public-api-native-transition/v1.schema.json +173 -0
- package/schemas/repository-agent-workflow/v2.schema.json +94 -0
- package/schemas/workspace-dependency-declarations/v2.schema.json +83 -0
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/pinned-audit-compiler.d.ts +0 -101
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/pinned-audit-compiler.d.ts.map +0 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/pinned-audit-compiler.js +0 -2
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/pinned-audit-compiler.js.map +0 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/prepare-public-api-extractor.d.ts +0 -15
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/prepare-public-api-extractor.d.ts.map +0 -1
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/prepare-public-api-extractor.js +0 -47
- package/dist/capabilities/public-api-compatibility/adapters/outbound/api-extractor/prepare-public-api-extractor.js.map +0 -1
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertPinnedAuditSdk, auditToolchainIdentity, compilerLibraryRoot } from "./load-pinned-audit-sdk.js";
|
|
2
2
|
import { bindAuditCompilerReferences } from "./audit-compiler-bindings.js";
|
|
3
|
+
import { NATIVE_EXTRACTOR_VERSION, nativeCompilerDiagnostics, withNativePublicApiProject } from "./native-public-api-engine.js";
|
|
4
|
+
import { createNativePublicApiModel } from "./native-public-api-model.js";
|
|
3
5
|
import { stagePublicApiAudit } from "../filesystem/stage-public-api-audit.js";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
6
|
import { mkdtemp, readFile, realpath, rm } from "node:fs/promises";
|
|
6
7
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
7
8
|
import { tmpdir } from "node:os";
|
|
8
|
-
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
10
|
+
import { parse } from "jsonc-parser";
|
|
11
|
+
import { SymbolFlags } from "typescript/unstable/async";
|
|
12
|
+
import { ApiDeclaredItem, ExcerptTokenKind, ApiExportedMixin, ApiReleaseTagMixin, ReleaseTag } from "@microsoft/api-extractor-model";
|
|
11
13
|
import { PUBLIC_API_AUDIT_PROFILE } from "../../../application/model/public-api-observation.js";
|
|
12
14
|
import { assertNotCancelled } from "../../../application/policies/public-api-evidence-errors.js";
|
|
13
15
|
import { auditDigest, auditInputPath, auditRelativePath, remapAuditStagePath, AUDIT_MAX_BYTES, AUDIT_MAX_FILES, auditPackagePolicy } from "../filesystem/public-api-audit-inputs.js";
|
|
14
16
|
import { mapReleasedBaseline } from "../filesystem/public-api-baseline-mapper.js";
|
|
15
|
-
import { preparePublicApiExtractor, invokePublicApiExtractor } from "./prepare-public-api-extractor.js";
|
|
16
|
-
const require = createRequire(import.meta.url);
|
|
17
|
-
const compiler = pinnedCompiler;
|
|
18
17
|
const BUILTINS = new Set(["AbortSignal", "Error", "Extract", "NoInfer", "Promise", "Readonly", "Record", "Uint8Array"]);
|
|
19
|
-
|
|
20
|
-
const line = diagnostic.file !== undefined && diagnostic.start !== undefined
|
|
21
|
-
? diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start).line + 1 : undefined;
|
|
22
|
-
return { source: "compiler", id: `TS${diagnostic.code}`,
|
|
23
|
-
severity: compiler.DiagnosticCategory[diagnostic.category]?.toLowerCase() ?? "unknown",
|
|
24
|
-
text: compiler.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
|
|
25
|
-
...(diagnostic.file === undefined ? {} : { file: diagnostic.file.fileName }),
|
|
26
|
-
...(line === undefined ? {} : { line }) };
|
|
27
|
-
}
|
|
18
|
+
const normalized = (path) => resolve(path).replaceAll("\\", "/");
|
|
28
19
|
function libraryFile(path) {
|
|
29
20
|
const resolved = realpathSync(path);
|
|
30
21
|
return dirname(resolved) === compilerLibraryRoot && /^lib\..*\.d\.ts$/u.test(basename(resolved));
|
|
31
22
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
async function nativeSources(context) {
|
|
24
|
+
const sources = [];
|
|
25
|
+
for (const path of await context.program.getSourceFileNames()) {
|
|
26
|
+
const source = await context.program.getSourceFile(path);
|
|
27
|
+
if (source === undefined) {
|
|
28
|
+
throw new Error("Native compiler source is unavailable.");
|
|
29
|
+
}
|
|
30
|
+
sources.push(source);
|
|
31
|
+
}
|
|
32
|
+
return sources;
|
|
33
|
+
}
|
|
34
|
+
async function defaultLibrary(context, source) {
|
|
35
|
+
return (await context.program.getSourceFileMetadata(source.fileName))?.isDefaultLibrary === true;
|
|
37
36
|
}
|
|
38
|
-
function builtin(reference,
|
|
39
|
-
const
|
|
40
|
-
const name = match?.[1];
|
|
37
|
+
async function builtin(reference, context) {
|
|
38
|
+
const name = /^!([A-Za-z][A-Za-z0-9]*):(?:interface|type|var)$/u.exec(reference ?? "")?.[1];
|
|
41
39
|
if (name === undefined || !BUILTINS.has(name)) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
|
-
const checker = program.getTypeChecker();
|
|
45
42
|
const identities = new Set();
|
|
46
43
|
let found = false;
|
|
47
|
-
// Every
|
|
48
|
-
//
|
|
49
|
-
for (const source of
|
|
50
|
-
if (
|
|
44
|
+
// Every source must resolve this spelling exclusively to actual pinned libraries.
|
|
45
|
+
// A local shadow or any merged augmentation prevents external-library admission.
|
|
46
|
+
for (const source of await nativeSources(context)) {
|
|
47
|
+
if (await defaultLibrary(context, source)) {
|
|
51
48
|
continue;
|
|
52
49
|
}
|
|
53
|
-
const symbol = checker.
|
|
54
|
-
if (symbol === undefined || symbol.declarations
|
|
50
|
+
const symbol = await context.checker.resolveName(name, SymbolFlags.Type | SymbolFlags.Value, source);
|
|
51
|
+
if (symbol === undefined || symbol.declarations.length === 0) {
|
|
55
52
|
return;
|
|
56
53
|
}
|
|
57
54
|
found = true;
|
|
58
|
-
for (const
|
|
55
|
+
for (const handle of symbol.declarations) {
|
|
56
|
+
const declaration = await handle.resolve(context.project);
|
|
57
|
+
if (declaration === undefined) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
59
60
|
const file = declaration.getSourceFile();
|
|
60
|
-
if (!
|
|
61
|
+
if (!await defaultLibrary(context, file) || !libraryFile(file.fileName)) {
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
identities.add(`${basename(file.fileName)}:${auditDigest(file.text)}`);
|
|
@@ -65,14 +66,25 @@ function builtin(reference, program) {
|
|
|
65
66
|
}
|
|
66
67
|
return found ? { symbol: name, declarations: [...identities].toSorted() } : undefined;
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
const
|
|
69
|
+
async function modelReferences(item, model, identity, context) {
|
|
70
|
+
const references = [];
|
|
71
|
+
for (const token of item.excerpt.spannedTokens.filter(candidate => candidate.kind === ExcerptTokenKind.Reference)) {
|
|
72
|
+
const reference = token.canonicalReference;
|
|
73
|
+
const target = reference === undefined ? undefined : model.resolveDeclarationReference(reference, item).resolvedApiItem;
|
|
74
|
+
const library = target === undefined ? await builtin(reference?.toString() ?? null, context) : undefined;
|
|
75
|
+
references.push({ text: token.text, canonicalReference: reference?.toString() ?? null,
|
|
76
|
+
resolution: target !== undefined ? "local" : library !== undefined ? "verified-external-library" : "unresolved",
|
|
77
|
+
...(target === undefined ? {} : { target: { ...identity, canonicalReference: target.canonicalReference.toString() } }),
|
|
78
|
+
...(library === undefined ? {} : { library }) });
|
|
79
|
+
}
|
|
80
|
+
return references;
|
|
81
|
+
}
|
|
82
|
+
async function readModel(model, pkg, observation, context, historical = false) {
|
|
71
83
|
if (pkg.name !== observation.packageName || pkg.entryPoints.length !== 1) {
|
|
72
84
|
throw new Error("Unsupported audit model package/entrypoint identity.");
|
|
73
85
|
}
|
|
74
86
|
const output = [];
|
|
75
|
-
function walk(item, parentPublic) {
|
|
87
|
+
async function walk(item, parentPublic) {
|
|
76
88
|
if (output.length >= AUDIT_MAX_FILES) {
|
|
77
89
|
throw new Error("Audit model node budget exhausted.");
|
|
78
90
|
}
|
|
@@ -87,25 +99,17 @@ function readModel(modelPath, observation, program, historical = false) {
|
|
|
87
99
|
}
|
|
88
100
|
if (item instanceof ApiDeclaredItem) {
|
|
89
101
|
const identity = { subject: observation.subject, packageName: observation.packageName, exportPath: observation.exportPath, canonicalReference: item.canonicalReference.toString() };
|
|
102
|
+
const references = await modelReferences(item, model, identity, context);
|
|
90
103
|
output.push({ identity, displayName: item.displayName, kind: item.kind,
|
|
91
104
|
parentReference: item.parent?.canonicalReference.toString() ?? "", parentKind: item.parent?.kind ?? "None",
|
|
92
|
-
excerpt: item.excerpt.text, isExported: exported, public: isPublic,
|
|
93
|
-
references: item.excerpt.spannedTokens.filter((token) => token.kind === ExcerptTokenKind.Reference).map((token) => {
|
|
94
|
-
const reference = token.canonicalReference;
|
|
95
|
-
const target = reference === undefined ? undefined : model.resolveDeclarationReference(reference, item).resolvedApiItem;
|
|
96
|
-
const library = target === undefined ? builtin(reference?.toString() ?? null, program) : undefined;
|
|
97
|
-
return { text: token.text, canonicalReference: reference?.toString() ?? null,
|
|
98
|
-
resolution: target !== undefined ? "local" : library !== undefined ? "verified-external-library" : "unresolved",
|
|
99
|
-
...(target === undefined ? {} : { target: { ...identity, canonicalReference: target.canonicalReference.toString() } }),
|
|
100
|
-
...(library === undefined ? {} : { library }) };
|
|
101
|
-
}) });
|
|
105
|
+
excerpt: item.excerpt.text, isExported: exported, public: isPublic, references });
|
|
102
106
|
}
|
|
103
107
|
for (const member of item.members) {
|
|
104
|
-
walk(member, isPublic);
|
|
108
|
+
await walk(member, isPublic);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
|
-
walk(pkg, true);
|
|
108
|
-
// The
|
|
111
|
+
await walk(pkg, true);
|
|
112
|
+
// The model resolver can fail for a modeled hidden namespace member. Exact opaque
|
|
109
113
|
// identities in this one export-path model provide a bounded local binding.
|
|
110
114
|
return output.map((item) => ({ ...item, references: item.references.map((reference) => {
|
|
111
115
|
if (reference.resolution !== "unresolved") {
|
|
@@ -116,126 +120,146 @@ function readModel(modelPath, observation, program, historical = false) {
|
|
|
116
120
|
: candidates.length > 1 ? { ...reference, resolution: "ambiguous" } : reference;
|
|
117
121
|
}) }));
|
|
118
122
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const readConfig = (path) => {
|
|
123
|
-
const normalized = resolve(path);
|
|
124
|
-
if (!allowed.has(normalized)) {
|
|
125
|
-
throw new Error(`Undeclared configuration dependency: ${relative(input.consumerRoot, path)}.`);
|
|
126
|
-
}
|
|
127
|
-
const text = readFileSync(normalized, "utf8");
|
|
128
|
-
if (auditDigest(text) !== allowed.get(normalized)) {
|
|
129
|
-
throw new Error("Configuration digest mismatch.");
|
|
130
|
-
}
|
|
131
|
-
configFiles.set(normalized, auditDigest(text));
|
|
132
|
-
return text;
|
|
133
|
-
};
|
|
134
|
-
const config = compiler.readConfigFile(configPath, readConfig);
|
|
135
|
-
if (config.error !== undefined) {
|
|
136
|
-
diagnostics.push(compilerDiagnostic(config.error));
|
|
137
|
-
}
|
|
138
|
-
const parsed = compiler.parseJsonConfigFileContent(config.config, {
|
|
139
|
-
useCaseSensitiveFileNames: true, readFile: readConfig,
|
|
140
|
-
fileExists: (path) => allowed.has(resolve(path)), readDirectory: () => { throw new Error("Audit requires explicit tsconfig files; glob discovery unsupported."); }
|
|
141
|
-
}, dirname(configPath), undefined, configPath);
|
|
142
|
-
diagnostics.push(...parsed.errors.map(compilerDiagnostic));
|
|
143
|
-
if (parsed.options.plugins !== undefined || parsed.projectReferences !== undefined) {
|
|
144
|
-
throw new Error("Compiler plugins and project references are outside the audit boundary.");
|
|
123
|
+
function object(value) {
|
|
124
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
125
|
+
throw new Error("Unsupported audit compiler configuration object.");
|
|
145
126
|
}
|
|
146
|
-
|
|
147
|
-
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function configDependency(path, specifier, files) {
|
|
130
|
+
const candidates = [];
|
|
131
|
+
if (specifier.startsWith(".") || isAbsolute(specifier)) {
|
|
132
|
+
const pathBase = resolve(dirname(path), specifier);
|
|
133
|
+
candidates.push(pathBase, `${pathBase}.json`);
|
|
148
134
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
135
|
+
else {
|
|
136
|
+
let directory = dirname(path);
|
|
137
|
+
for (;;) {
|
|
138
|
+
const pathBase = join(directory, "node_modules", specifier);
|
|
139
|
+
candidates.push(pathBase, `${pathBase}.json`, join(pathBase, "tsconfig.json"));
|
|
140
|
+
const parent = dirname(directory);
|
|
141
|
+
if (parent === directory) {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
directory = parent;
|
|
152
145
|
}
|
|
153
146
|
}
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const configuredLibraries = options.lib;
|
|
158
|
-
const abortSignalLibraryName = basename(pinnedAbortSignalLibraryPath);
|
|
159
|
-
if (Array.isArray(configuredLibraries) &&
|
|
160
|
-
configuredLibraries.every((library) => typeof library === "string") &&
|
|
161
|
-
!configuredLibraries.includes(abortSignalLibraryName)) {
|
|
162
|
-
// Keep AbortSignal resolvable inside the fixed pinned-library boundary. An
|
|
163
|
-
// implicit library set already includes this declaration.
|
|
164
|
-
options.lib = [...configuredLibraries, abortSignalLibraryName];
|
|
147
|
+
const selected = candidates.find(candidate => files.has(normalized(candidate)));
|
|
148
|
+
if (selected === undefined) {
|
|
149
|
+
throw new Error(`Undeclared configuration dependency: ${specifier}.`);
|
|
165
150
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
for (const path of allowed
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
directory = dirname(directory);
|
|
151
|
+
return normalized(selected);
|
|
152
|
+
}
|
|
153
|
+
function prepareNativeFiles(context, configFiles) {
|
|
154
|
+
const files = new Map();
|
|
155
|
+
for (const [path, digest] of context.allowed) {
|
|
156
|
+
const text = readFileSync(path, "utf8");
|
|
157
|
+
if (auditDigest(text) !== digest) {
|
|
158
|
+
throw new Error("Compiler host input digest mismatch.");
|
|
175
159
|
}
|
|
160
|
+
files.set(normalized(path), text);
|
|
176
161
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
162
|
+
const configPath = normalized(join(context.input.consumerRoot, context.pkg.tsconfigPath));
|
|
163
|
+
const configurations = new Map();
|
|
164
|
+
const visiting = new Set();
|
|
165
|
+
function readConfiguration(path) {
|
|
166
|
+
if (visiting.has(path)) {
|
|
167
|
+
throw new Error("Circular audit compiler configuration.");
|
|
168
|
+
}
|
|
169
|
+
visiting.add(path);
|
|
170
|
+
const text = files.get(path);
|
|
171
|
+
if (text === undefined) {
|
|
172
|
+
throw new Error(`Undeclared configuration dependency: ${path}.`);
|
|
173
|
+
}
|
|
174
|
+
const errors = [];
|
|
175
|
+
const configuration = object(parse(text, errors, { allowTrailingComma: true, disallowComments: false }));
|
|
176
|
+
if (errors.length > 0) {
|
|
177
|
+
throw new Error("Invalid audit compiler JSONC configuration.");
|
|
178
|
+
}
|
|
179
|
+
configurations.set(path, configuration);
|
|
180
|
+
configFiles.set(resolve(path), auditDigest(text));
|
|
181
|
+
const optionLayers = [];
|
|
182
|
+
let roots;
|
|
183
|
+
let include;
|
|
184
|
+
const extended = configuration["extends"];
|
|
185
|
+
if (extended !== undefined) {
|
|
186
|
+
const bases = typeof extended === "string" ? [extended] : extended;
|
|
187
|
+
if (!Array.isArray(bases) || !bases.every((base) => typeof base === "string")) {
|
|
188
|
+
throw new Error("Unsupported audit compiler inheritance.");
|
|
189
|
+
}
|
|
190
|
+
for (const base of bases) {
|
|
191
|
+
const inherited = readConfiguration(configDependency(path, base, files));
|
|
192
|
+
optionLayers.push(inherited.options);
|
|
193
|
+
roots = inherited.roots ?? roots;
|
|
194
|
+
include = inherited.include ?? include;
|
|
195
|
+
}
|
|
183
196
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
197
|
+
if (configuration["references"] !== undefined) {
|
|
198
|
+
throw new Error("Compiler plugins and project references are outside the audit boundary.");
|
|
199
|
+
}
|
|
200
|
+
if (configuration["compilerOptions"] !== undefined) {
|
|
201
|
+
optionLayers.push(object(configuration["compilerOptions"]));
|
|
202
|
+
}
|
|
203
|
+
if (configuration["files"] !== undefined) {
|
|
204
|
+
const specified = configuration["files"];
|
|
205
|
+
if (!Array.isArray(specified) || !specified.every((file) => typeof file === "string")) {
|
|
206
|
+
throw new Error("Unsupported audit compiler root files.");
|
|
207
|
+
}
|
|
208
|
+
roots = specified.map(file => normalized(resolve(dirname(path), file)));
|
|
209
|
+
}
|
|
210
|
+
include = configuration["include"] ?? include;
|
|
211
|
+
visiting.delete(path);
|
|
212
|
+
return { options: Object.fromEntries(optionLayers.flatMap(layer => Object.entries(layer))), roots, include };
|
|
213
|
+
}
|
|
214
|
+
const configuration = readConfiguration(configPath);
|
|
215
|
+
if (configuration.options["plugins"] !== undefined) {
|
|
216
|
+
throw new Error("Compiler plugins and project references are outside the audit boundary.");
|
|
217
|
+
}
|
|
218
|
+
if (configuration.options["skipLibCheck"] === true || configuration.options["skipDefaultLibCheck"] === true || configuration.options["noCheck"] === true) {
|
|
219
|
+
throw new Error("Compiler diagnostic suppression is unsupported for audit admission.");
|
|
220
|
+
}
|
|
221
|
+
if (configuration.roots === undefined || (configuration.include !== undefined && (!Array.isArray(configuration.include) || configuration.include.length > 0))) {
|
|
222
|
+
throw new Error("Audit requires explicit tsconfig files; glob discovery unsupported.");
|
|
223
|
+
}
|
|
224
|
+
for (const path of configuration.roots) {
|
|
225
|
+
if (!context.allowed.has(resolve(path))) {
|
|
226
|
+
throw new Error("Undeclared compiler root.");
|
|
187
227
|
}
|
|
188
|
-
if (basename(path) === "package.json") {
|
|
189
|
-
configFiles.set(resolve(path), auditDigest(text));
|
|
190
|
-
}
|
|
191
|
-
return text;
|
|
192
|
-
};
|
|
193
|
-
host.directoryExists = (path) => directories.has(resolve(path)) || resolve(path) === compilerLibraryRoot;
|
|
194
|
-
host.getDirectories = (path) => [...directories].filter((directory) => dirname(directory) === resolve(path)).map((directory) => basename(directory));
|
|
195
|
-
host.realpath = (path) => resolve(path);
|
|
196
|
-
host.getCurrentDirectory = () => input.consumerRoot;
|
|
197
|
-
const roots = [...new Set([...parsed.fileNames, ...(entry === undefined ? [] : [resolve(input.consumerRoot, entry.declarationEntryPoint)])])];
|
|
198
|
-
const program = compiler.createProgram(roots, options, host);
|
|
199
|
-
if (entry === undefined) {
|
|
200
|
-
return { program, invocation: undefined };
|
|
201
228
|
}
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
229
|
+
const raw = configurations.get(configPath);
|
|
230
|
+
const rawOptions = raw["compilerOptions"] === undefined ? {} : object(raw["compilerOptions"]);
|
|
231
|
+
const configuredLibraries = configuration.options["lib"];
|
|
232
|
+
if (configuredLibraries !== undefined && (!Array.isArray(configuredLibraries) || !configuredLibraries.every((library) => typeof library === "string"))) {
|
|
233
|
+
throw new Error("Unsupported audit compiler libraries.");
|
|
234
|
+
}
|
|
235
|
+
const entryPoint = context.entry === undefined ? [] : [normalized(join(context.input.consumerRoot, context.entry.declarationEntryPoint))];
|
|
236
|
+
files.set(configPath, JSON.stringify({ ...raw, files: [...new Set([...configuration.roots, ...entryPoint])], compilerOptions: {
|
|
237
|
+
...rawOptions, outDir: null, declarationDir: null,
|
|
238
|
+
...(configuredLibraries === undefined ? {} : { lib: [...configuredLibraries, ...(configuredLibraries.some(library => /^(?:lib\.)?dom(?:\.d\.ts)?$/iu.test(library)) ? [] : ["DOM"])] })
|
|
239
|
+
} }));
|
|
240
|
+
return { configPath, files };
|
|
208
241
|
}
|
|
209
|
-
function validateCompilerSources(
|
|
210
|
-
const
|
|
242
|
+
async function validateCompilerSources(native, context) {
|
|
243
|
+
const sources = await nativeSources(native);
|
|
211
244
|
let bytes = 0;
|
|
212
|
-
for (const source of
|
|
245
|
+
for (const source of sources) {
|
|
213
246
|
bytes += Buffer.byteLength(source.text);
|
|
214
|
-
if (
|
|
247
|
+
if (sources.length > AUDIT_MAX_FILES || bytes > AUDIT_MAX_BYTES) {
|
|
215
248
|
throw new Error("Compiler input budget exhausted.");
|
|
216
249
|
}
|
|
217
250
|
if (!source.isDeclarationFile) {
|
|
218
251
|
throw new Error("Only prepared declarations are supported.");
|
|
219
252
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
for (const statement of source.statements) {
|
|
224
|
-
const imported = statement.moduleSpecifier;
|
|
225
|
-
if (imported?.text === undefined || imported.text.startsWith(".")) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
const symbol = program.getTypeChecker().getSymbolAtLocation(imported);
|
|
229
|
-
if (symbol === undefined) {
|
|
230
|
-
continue;
|
|
231
|
-
} // Independent diagnostics retain unresolved modules.
|
|
232
|
-
const universe = input.declarations.resolutionUniverse.find((candidate) => `${candidate.packageName}${candidate.exportPath === "." ? "" : candidate.exportPath.slice(1)}` === imported.text);
|
|
233
|
-
if (universe === undefined || symbol.declarations?.length !== 1 ||
|
|
234
|
-
resolve(symbol.declarations[0].getSourceFile().fileName) !== resolve(input.consumerRoot, universe.declarationPath)) {
|
|
235
|
-
throw new Error("Module binding is outside the explicit same-subject universe.");
|
|
253
|
+
if (await defaultLibrary(native, source)) {
|
|
254
|
+
if (!libraryFile(source.fileName)) {
|
|
255
|
+
throw new Error("Compiler library outside pinned native toolchain.");
|
|
236
256
|
}
|
|
237
257
|
}
|
|
258
|
+
else if (context.allowed.get(resolve(source.fileName)) !== auditDigest(source.text)) {
|
|
259
|
+
throw new Error(`Compiler input outside verified subject: ${source.fileName}.`);
|
|
260
|
+
}
|
|
238
261
|
}
|
|
262
|
+
return sources;
|
|
239
263
|
}
|
|
240
264
|
function compilerEnvironment(options, context) {
|
|
241
265
|
const { input, subjectRoot } = context;
|
|
@@ -272,13 +296,13 @@ async function observeEntrypoint(context) {
|
|
|
272
296
|
const diagnostics = [];
|
|
273
297
|
const unsupported = [];
|
|
274
298
|
const configFiles = new Map();
|
|
275
|
-
let program;
|
|
276
299
|
let compilerOptions = {};
|
|
277
300
|
let invocation = { outcome: "not-invoked", succeeded: false, errorCount: null, warningCount: null };
|
|
278
301
|
let collected = false;
|
|
279
302
|
let modelPresent = false;
|
|
280
303
|
let modelDigest;
|
|
281
304
|
let items = [];
|
|
305
|
+
let sources = [];
|
|
282
306
|
let revalidated = false;
|
|
283
307
|
let storedSurface;
|
|
284
308
|
try {
|
|
@@ -291,55 +315,71 @@ async function observeEntrypoint(context) {
|
|
|
291
315
|
}
|
|
292
316
|
effectiveContext = { ...context, input: { ...input, consumerRoot: stage.root }, allowed: stage.files,
|
|
293
317
|
subjectRoot: join(stage.root, relative(input.consumerRoot, context.subjectRoot)) };
|
|
294
|
-
const prepared =
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const { state, extractorConfig, modelPath } = prepared.invocation;
|
|
306
|
-
try {
|
|
307
|
-
const result = invokePublicApiExtractor(extractorConfig, state, (message) => {
|
|
308
|
-
diagnostics.push({ source: "extractor", id: message.messageId, severity: message.logLevel, text: message.text.replaceAll(outputRoot, "<audit-model-output>"),
|
|
309
|
-
...(message.sourceFilePath === undefined ? {} : { file: message.sourceFilePath }),
|
|
310
|
-
...(message.sourceFileLine === undefined ? {} : { line: message.sourceFileLine }) });
|
|
311
|
-
message.handled = true;
|
|
312
|
-
});
|
|
313
|
-
invocation = { outcome: "completed", succeeded: result.succeeded, errorCount: result.errorCount, warningCount: result.warningCount };
|
|
318
|
+
const prepared = prepareNativeFiles(effectiveContext, configFiles);
|
|
319
|
+
await withNativePublicApiProject({ cwd: stage.root, configPath: prepared.configPath, files: prepared.files,
|
|
320
|
+
...(input.signal === undefined ? {} : { signal: input.signal }) }, async (native) => {
|
|
321
|
+
const { configFilePath: _configPath, ...options } = native.config.options;
|
|
322
|
+
compilerOptions = options;
|
|
323
|
+
diagnostics.push(...await nativeCompilerDiagnostics(native));
|
|
324
|
+
collected = true;
|
|
325
|
+
const checkedSources = await validateCompilerSources(native, effectiveContext);
|
|
326
|
+
const checkedInputs = [];
|
|
327
|
+
for (const source of checkedSources) {
|
|
328
|
+
checkedInputs.push({ fileName: source.fileName, text: source.text, library: await defaultLibrary(native, source) });
|
|
314
329
|
}
|
|
315
|
-
|
|
316
|
-
|
|
330
|
+
sources = checkedInputs;
|
|
331
|
+
for (const path of native.readFiles) {
|
|
332
|
+
if (basename(path) === "package.json" && effectiveContext.allowed.has(resolve(path))) {
|
|
333
|
+
configFiles.set(resolve(path), auditDigest(readFileSync(path)));
|
|
334
|
+
}
|
|
317
335
|
}
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
336
|
+
if (entry !== undefined) {
|
|
337
|
+
const modelPath = join(outputRoot, "surface.api.json");
|
|
338
|
+
try {
|
|
339
|
+
if (diagnostics.some(diagnostic => diagnostic.source === "compiler" && diagnostic.severity === "error")) {
|
|
340
|
+
throw new Error("Native public API extraction cannot model compiler errors.");
|
|
341
|
+
}
|
|
342
|
+
const result = await createNativePublicApiModel(native, { packageName: pkg.packageName,
|
|
343
|
+
entryPointPath: resolve(stage.root, entry.declarationEntryPoint), includeForgottenExports: true, untrimmedObservation: true,
|
|
344
|
+
referenceProjection: "declaration-graph" });
|
|
345
|
+
diagnostics.push(...result.diagnostics.filter(diagnostic => diagnostic.source !== "compiler"));
|
|
346
|
+
invocation = { outcome: "completed", succeeded: result.succeeded,
|
|
347
|
+
errorCount: result.diagnostics.filter(diagnostic => diagnostic.severity === "error").length,
|
|
348
|
+
warningCount: result.diagnostics.filter(diagnostic => diagnostic.severity === "warning").length };
|
|
349
|
+
result.apiPackage.saveToJsonFile(modelPath, { toolPackage: "@agent-teams/engineering-foundation", toolVersion: NATIVE_EXTRACTOR_VERSION });
|
|
350
|
+
try {
|
|
351
|
+
const modelBytes = await readFile(modelPath);
|
|
352
|
+
modelPresent = true;
|
|
353
|
+
modelDigest = auditDigest(modelBytes);
|
|
354
|
+
if (modelBytes.length > AUDIT_MAX_BYTES) {
|
|
355
|
+
throw new Error("Audit model byte budget exhausted.");
|
|
356
|
+
}
|
|
357
|
+
items = await readModel(result.model, result.apiPackage, { subject: input.subject, packageName: pkg.packageName, exportPath: entry.exportPath }, native);
|
|
358
|
+
await bindAuditCompilerReferences({ program: native.program, checker: native.checker, project: native.project,
|
|
359
|
+
root: stage.root, declarations: input.declarations, items, declarationBindings: result.declarationBindings, bindings: context.dependencyBindings });
|
|
360
|
+
await validateModelExports(native, resolve(stage.root, entry.declarationEntryPoint), items);
|
|
361
|
+
storedSurface = mapReleasedBaseline({ schemaVersion: 1, packageName: pkg.packageName, packageVersion: pkg.packageVersion,
|
|
362
|
+
extractorVersion: NATIVE_EXTRACTOR_VERSION, entrypoints: [{ exportPath: entry.exportPath,
|
|
363
|
+
items: (await readModel(result.model, result.apiPackage, { subject: input.subject, packageName: pkg.packageName, exportPath: entry.exportPath }, native, true)).map(item => ({
|
|
364
|
+
canonicalReference: item.identity.canonicalReference, kind: item.kind, parentKind: item.parentKind, parentReference: item.parentReference,
|
|
365
|
+
signature: item.excerpt.replaceAll("\r\n", "\n").trim() || (item.kind === "Namespace" ? `namespace ${item.displayName}` : "")
|
|
366
|
+
})).toSorted((a, b) => a.canonicalReference < b.canonicalReference ? -1 : a.canonicalReference > b.canonicalReference ? 1 : 0) }] }, auditPackagePolicy(pkg));
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
unsupported.push(`model-unavailable: ${String(error).replaceAll(outputRoot, "<audit-model-output>")}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
invocation = { outcome: "exception", succeeded: false, errorCount: null, warningCount: null,
|
|
374
|
+
exception: String(error).replaceAll(outputRoot, "<audit-model-output>") };
|
|
324
375
|
}
|
|
325
|
-
items = readModel(modelPath, { subject: input.subject, packageName: pkg.packageName, exportPath: entry.exportPath }, program);
|
|
326
|
-
bindAuditCompilerReferences({ compiler, program, root: stage.root, declarations: input.declarations, pkg, items, bindings: context.dependencyBindings });
|
|
327
|
-
validateModelExports(program, resolve(stage.root, entry.declarationEntryPoint), items);
|
|
328
|
-
storedSurface = mapReleasedBaseline({ schemaVersion: 1, packageName: pkg.packageName, packageVersion: pkg.packageVersion,
|
|
329
|
-
extractorVersion: Extractor.version, entrypoints: [{ exportPath: entry.exportPath, items: readModel(modelPath, { subject: input.subject, packageName: pkg.packageName, exportPath: entry.exportPath }, program, true).map((item) => ({
|
|
330
|
-
canonicalReference: item.identity.canonicalReference, kind: item.kind, parentKind: item.parentKind, parentReference: item.parentReference,
|
|
331
|
-
signature: item.excerpt.replaceAll("\r\n", "\n").trim() || (item.kind === "Namespace" ? `namespace ${item.displayName}` : "")
|
|
332
|
-
})).toSorted((a, b) => a.canonicalReference < b.canonicalReference ? -1 : a.canonicalReference > b.canonicalReference ? 1 : 0) }] }, auditPackagePolicy(pkg));
|
|
333
376
|
}
|
|
334
|
-
|
|
335
|
-
|
|
377
|
+
else {
|
|
378
|
+
storedSurface = mapReleasedBaseline({ schemaVersion: 1, packageName: pkg.packageName, packageVersion: pkg.packageVersion,
|
|
379
|
+
extractorVersion: NATIVE_EXTRACTOR_VERSION, entrypoints: [] }, auditPackagePolicy(pkg));
|
|
336
380
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
storedSurface = mapReleasedBaseline({ schemaVersion: 1, packageName: pkg.packageName, packageVersion: pkg.packageVersion,
|
|
340
|
-
extractorVersion: Extractor.version, entrypoints: [] }, auditPackagePolicy(pkg));
|
|
341
|
-
}
|
|
342
|
-
await revalidateObservationInputs(effectiveContext, metadataPresence, program);
|
|
381
|
+
await revalidateObservationInputs(effectiveContext, metadataPresence, sources);
|
|
382
|
+
});
|
|
343
383
|
await stage.revalidate();
|
|
344
384
|
revalidated = true;
|
|
345
385
|
}
|
|
@@ -364,11 +404,11 @@ async function observeEntrypoint(context) {
|
|
|
364
404
|
assertNotCancelled(input.signal);
|
|
365
405
|
const fileIdentity = (path, digest) => ({ path: relative(input.consumerRoot, remapAuditStagePath(path, stageRoot, input.consumerRoot)).split(sep).join("/"), digest });
|
|
366
406
|
return { subject: input.subject, packageName: pkg.packageName, packageVersion: pkg.packageVersion, exportPath: entry?.exportPath ?? null, modelExpected: entry !== undefined,
|
|
367
|
-
toolchain:
|
|
407
|
+
toolchain: auditToolchainIdentity(), normalizationProfile: PUBLIC_API_AUDIT_PROFILE,
|
|
368
408
|
compilerEnvironment: compilerEnvironment(compilerOptions, effectiveContext), compilerOptions: restoreStagePaths(compilerOptions, stageRoot, input.consumerRoot),
|
|
369
409
|
configurationDependencies: [...configFiles].map(([path, digest]) => fileIdentity(path, digest)),
|
|
370
|
-
sourceFiles:
|
|
371
|
-
externalDeclarations:
|
|
410
|
+
sourceFiles: sources.map(source => fileIdentity(source.fileName, auditDigest(source.text))),
|
|
411
|
+
externalDeclarations: sources.filter(source => source.library).map(source => ({ path: basename(source.fileName), digest: auditDigest(source.text) })),
|
|
372
412
|
...(storedSurface === undefined ? {} : { storedSurface }),
|
|
373
413
|
diagnostics: restoreStagePaths(diagnostics, stageRoot, input.consumerRoot), compilerDiagnosticsCollected: collected, invocation, modelPresent,
|
|
374
414
|
...(modelDigest === undefined ? {} : { modelDigest }), items, inputBytesRevalidated: revalidated, unsupported };
|
|
@@ -387,9 +427,7 @@ function resolveSubjectReferences(observations, bindings) {
|
|
|
387
427
|
export class MicrosoftPublicApiObserver {
|
|
388
428
|
async observe(request) {
|
|
389
429
|
assertNotCancelled(request.signal);
|
|
390
|
-
|
|
391
|
-
throw new Error("Unsupported audit toolchain: require Extractor 7.58.12 and its TypeScript 5.9.3.");
|
|
392
|
-
}
|
|
430
|
+
assertPinnedAuditSdk();
|
|
393
431
|
// Match auditInputPath's native realpath: the JS sync variant can retain Windows 8.3 aliases.
|
|
394
432
|
const input = { ...request, consumerRoot: await realpath(request.consumerRoot) };
|
|
395
433
|
const expectedModels = input.declarations.packages.reduce((total, pkg) => total + Math.max(1, pkg.entrypoints.length), 0);
|
|
@@ -431,7 +469,7 @@ export class MicrosoftPublicApiObserver {
|
|
|
431
469
|
}
|
|
432
470
|
}
|
|
433
471
|
function collectMetadataPresence(allowed, configFiles) {
|
|
434
|
-
//
|
|
472
|
+
// Compiler resolution observes enclosing package metadata. Declare and digest every
|
|
435
473
|
// existing ancestor manifest, including nested and outside-root manifests;
|
|
436
474
|
// record absence for best-effort mutation detection, not an atomic freeze.
|
|
437
475
|
const metadataPresence = new Map();
|
|
@@ -455,19 +493,18 @@ function collectMetadataPresence(allowed, configFiles) {
|
|
|
455
493
|
}
|
|
456
494
|
return metadataPresence;
|
|
457
495
|
}
|
|
458
|
-
function validateModelExports(
|
|
459
|
-
const entrySource = program.getSourceFile(entryPoint);
|
|
460
|
-
const moduleSymbol = entrySource === undefined ? undefined :
|
|
496
|
+
async function validateModelExports(context, entryPoint, items) {
|
|
497
|
+
const entrySource = await context.program.getSourceFile(entryPoint);
|
|
498
|
+
const moduleSymbol = entrySource === undefined ? undefined : await context.checker.getSymbolAtLocation(entrySource);
|
|
461
499
|
if (moduleSymbol === undefined) {
|
|
462
500
|
throw new Error("Unsupported declaration entrypoint module binding.");
|
|
463
501
|
}
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
if (!items.some((item) => item.public && item.parentKind === "EntryPoint" && item.displayName === exported.name)) {
|
|
502
|
+
for (const exported of await context.checker.getExportsOfModule(moduleSymbol)) {
|
|
503
|
+
if (!items.some(item => item.public && item.parentKind === "EntryPoint" && item.displayName === exported.name)) {
|
|
467
504
|
throw new Error(`Unsupported model omission for compiler export: ${exported.name}.`);
|
|
468
505
|
}
|
|
469
506
|
}
|
|
470
|
-
if (items.some(
|
|
507
|
+
if (items.some(item => item.public && item.kind !== "Namespace" && !item.excerpt.trim())) {
|
|
471
508
|
throw new Error("Empty historical declaration signature.");
|
|
472
509
|
}
|
|
473
510
|
}
|
|
@@ -481,7 +518,7 @@ function recordMetadataDigest(manifest, allowed, configFiles) {
|
|
|
481
518
|
}
|
|
482
519
|
configFiles.set(manifest, digest);
|
|
483
520
|
}
|
|
484
|
-
async function revalidateObservationInputs(context, metadataPresence,
|
|
521
|
+
async function revalidateObservationInputs(context, metadataPresence, sources) {
|
|
485
522
|
const { input, allowed } = context;
|
|
486
523
|
for (const [path, present] of metadataPresence) {
|
|
487
524
|
if (existsSync(path) !== present) {
|
|
@@ -494,7 +531,7 @@ async function revalidateObservationInputs(context, metadataPresence, program) {
|
|
|
494
531
|
throw new Error("Audit input changed during observation.");
|
|
495
532
|
}
|
|
496
533
|
}
|
|
497
|
-
for (const source of
|
|
534
|
+
for (const source of sources) {
|
|
498
535
|
if (auditDigest(await readFile(source.fileName)) !== auditDigest(source.text)) {
|
|
499
536
|
throw new Error("Compiler source changed during observation.");
|
|
500
537
|
}
|