refactor(architecture): add the ports and resources layers, move ports and shared resource owners there, and ratchet the layer baseline (#11208)

* test(architecture): fail on a stale layer baseline and document the declared layers

verify:module-boundaries reported a layer baseline entry whose imports were
gone but still passed, so main kept process -> artifacts at 20 after it fell
to 17 and a later change could add three imports back unnoticed. A stale
entry now fails like growth; --shrink-layer-baseline lowers it in the change
that removes the imports. The architecture map and CONTRIBUTING name
scripts/lib/module-layers.mjs as the per-directory layer declaration.

* test(architecture): refuse to lower the layer baseline after an inspection failure

A file that cannot be parsed contributes no imports, so a shrink run would record counts that fail as growth once the file is fixed. Whole-command tests cover stale rejection, shrinking, refused growth and the inspection failure.

* refactor(ports): move the progress, work-scope and inspection-scope ports to src/ports (#11214)

* refactor(ports): move the progress, work-scope and inspection-scope ports to src/ports

Pure move with git mv and import specifier updates.

* test(architecture): declare the ports layer and lower the layer baseline

src/ports sits between the foundation and the providers. Moving the three
ports removes 11 provider -> application imports.

* refactor(ports): move AnalysisProvider to src/ports (#11217)

* refactor(ports): move AnalysisProvider to src/ports

Pure move with git mv and import specifier updates in its importers, the
built-fixture path, the CI scope glob and the lint-rule test spellings.

* test(architecture): lower the layer baseline after moving AnalysisProvider

* refactor(ports): move the per-feature provider ports to src/ports (#11226)

* refactor(ports): move the per-feature provider ports to src/ports

Pure move with git mv and import specifier updates: the 47 *Port.ts and
*Ports.ts files that providers implement, plus OptionalObservationProviders,
which only composes the observation ports.

* test(architecture): lower the layer baseline after moving the feature ports

* refactor(providers): move closeAnalysisClient and the Frida session input errors to their owners (#11233)

* refactor(providers): move closeAnalysisClient to src/providers and the Frida session input errors to src/frida

Pure move with git mv and import specifier updates.

* test(architecture): drop the application-providers and application-frida cycles from the layer baseline

* fix(ci): keep provider lanes selecting the ports moved to src/ports

Each lane glob that matched a moved port under src/application gains its src/ports counterpart; the change-scope test pins one moved port per lane.

* refactor(domain): declare the localPath host exception and read HOST_PLATFORM there (#11256)

absoluteLocalPathStringSchema decides which paths are absolute on the running host, so it reads HOST_PLATFORM instead of process.platform. Domain may not import outside domain/contracts; module-layers now declares LAYER_EXCEPTIONS, exact file-to-file imports with a reason, and both the layer count and the pure-layer boundary skip only that import. Any other domain -> platform import still fails.

* refactor(ports): move the doctor check and provider inspection types to src/ports (#11246)

* refactor(ports): move the doctor check and provider inspection types to src/ports

Declaration move from application/Doctor.ts (unchanged text) and import updates; no re-export from Doctor.ts.

* test(architecture): lower the layer baseline after moving the doctor provider types

* refactor(ports): move the packet capture and signal recording ports to src/ports (#11249)

* refactor(ports): move the packet capture and signal recording ports to src/ports

Declaration move (unchanged text) out of the two application services, with import updates.

* test(architecture): lower the layer baseline after moving the capture and signal ports

* refactor(domain): move the analysis error projection schema from contracts to domain (#11251)

* refactor(domain): move the analysis error projection schema from contracts to domain

Declaration move (unchanged text) of the projection schemas that domain modules embed; contracts/errorSchemas.ts keeps the CLI envelope and the published JSON Schema. Import updates only.

* test(architecture): drop the contracts-domain cycle from the layer baseline

* refactor(ports): drop the imports the moved capture, signal and doctor types left behind

Also give the packet capture and signal recording lanes the new port paths, with change-scope cases.

* refactor(resources): add src/resources and move AnalysisCleanupLease and ArtifactReader there (#11259)

* refactor(resources): move AnalysisCleanupLease to src/resources

Pure move: git mv plus import specifier rewrites (source, tests, and the dist paths the verifier scripts load).

* refactor(resources): declare src/resources as a foundation unit

src/resources owns the shared analysis resource modules that process, windows and providers hold; AnalysisCleanupLease is the first. Its tests join the adapters project, the apk signature lane selects it beside src/artifacts, and the layer baseline drops the process and windows imports of the lease.

* test(ci): pin the apk signature lane on the moved cleanup lease

* refactor(resources): move ArtifactReader to src/resources

Pure move: git mv plus import specifier rewrites (source, tests, and the dist path a verifier script loads).

* test(architecture): lower the layer baseline after moving ArtifactReader

windows no longer imports src/artifacts; process -> artifacts 11 -> 9. The CI lanes that selected src/artifacts/ArtifactReader.ts select its new path, pinned in the change-scope test.

* refactor(resources): move ArtifactResourceScope to src/resources (#11265)

* refactor(artifacts): name the output tree and private root capabilities the resource scope releases

ArtifactResourceScope typed its output-tree and private-runtime-root owners with SafeOutputTree (src/artifacts) and PrivateRuntimeRoot (src/process). It only calls rollback() and close(), so it now declares those capabilities itself and names neither unit, which lets it move to src/resources without a resources <-> process cycle. The withheld-export test narrows to SafeOutputTree where it reads the published flag.

* refactor(resources): move ArtifactResourceScope to src/resources

Pure move: git mv plus import specifier rewrites (source, tests, the dist paths verifier scripts load, and the FIFO probe's module-relative URL).

* test(architecture): lower the layer baseline after moving ArtifactResourceScope

process -> artifacts 9 -> 5, and the artifacts <-> dotnet mutual pair is gone. The sqlite and agentenv lanes select the scope at its new path, pinned in the change-scope test.

* refactor(resources): move ArtifactFileOperation to src/resources (#11269)

* refactor(resources): move ArtifactFileOperation to src/resources

Pure move: git mv plus import specifier rewrites (source, tests, and the dist paths verifier scripts load).

* test(architecture): lower the layer baseline after moving ArtifactFileOperation

process -> artifacts 5 -> 1.

* refactor(resources): move readStableArtifact to src/resources (#11271)

* refactor(resources): move readStableArtifact to src/resources

Pure move: git mv plus import specifier rewrites.

* test(architecture): lower the layer baseline after moving readStableArtifact

process no longer imports src/artifacts: process -> artifacts 1 -> 0 and the artifacts <-> process mutual pair is gone. The seven lanes that selected readStableArtifact select its new path, pinned in the change-scope test; the architecture map lists what src/resources owns.

* refactor(hopper): take Linux launcher verification from composition through a port (#11278)

The Hopper launcher imported inspectLinuxHopperLauncher and retryLinuxHopperPublisherCleanup from src/application (the two hopper -> application imports). src/ports/LinuxHopperLauncherVerification.ts now names that capability; src/application/LinuxHopper.ts provides LINUX_HOPPER_LAUNCHER_VERIFICATION, binary composition passes it to HopperProvider, and the provider hands it to the launcher. A launcher built without one refuses a Linux demo launch with reason verification_unavailable before running the launcher. Layer baseline: hopper -> application 2 -> 0.

* refactor(config): move Hopper launcher discovery to a src/hopperPaths foundation unit (#11292)

* refactor(hopper): move the launcher discovery and macOS Hopper paths to src/hopperPaths

Pure move: git mv plus import specifier rewrites.

* refactor(hopper): declare src/hopperPaths as a foundation unit with the Linux launcher candidates

Hopper install paths and launcher discovery are pure path facts that the
Hopper provider, doctor and setup all read. Declare src/hopperPaths in the
foundation layer, add it to the adapters test project, the architecture
map and the package-baseline CI lane, and move the Linux launcher
candidates out of src/application/LinuxHopper.ts into
src/hopperPaths/LinuxHopperPaths.ts so discovery no longer imports
application code.

* refactor(config): leave Hopper launcher discovery to the Hopper provider

parseConfig resolved an unset HOPPER_LAUNCHER_PATH by probing the
filesystem through application-owned discovery, so config imported
application (config -> application 2, application <-> config cycle) and
read process.platform ambiently.

AppConfig.hopperLauncherPath is now the caller's HOPPER_LAUNCHER_PATH
unchanged (string | undefined). src/hopperPaths/HopperLauncherDiscovery.ts
owns the selection (selectedHopperLauncherPath: the configured spelling,
else discovery from the caller environment's home on the provider's
platform); HopperProvider and the two real-Hopper verifiers read it.
Discovery tests move from config.test.ts to src/hopperPaths; a provider
test covers discovery from the provider's own platform and home.

Module layers: config -> application 2 -> 0; application <-> config removed.
Architecture guards: ambient platform reads in parseConfig.ts 2 -> 0.

* refactor(providers): move owned-process prerequisite availability out of application (#11294)

* refactor(providers): move the owned-process prerequisite availability mapping to src/providers

Pure move: git mv plus import specifier rewrites.

* test(architecture): lower the layer baseline after moving owned-process availability

android -> application 1 -> 0; apktool -> application 1 -> 0.

* refactor(process): move the regular-file read owner out of application (#11299)

* refactor(process): move the regular-file read owner from src/application to src/process

Pure move: git mv plus import specifier rewrites.

* test(architecture): lower the layer baseline after moving the regular-file read owner

desktop -> application 5 -> 4; dotnet -> application 2 -> 1.

The agentenv lane listed src/application/RegularFileRead.ts. At its new
path it is a src/process/ shared boundary: fast qualification selects the
code and runtime checks (and the single owning lane, web_source_map, via
src/process/**), and full qualification selects every lane, as for every
other src/process/ module. A second owner entry would only suppress the
web_source_map selection, so the agentenv entry is removed, not renamed.

* refactor(resources): give atomic text writes their own owner (#11302)

* refactor(resources): give atomic text writes their own owner in src/resources

src/application/JsonFiles.ts owned both JSON input reads and the atomic
text write (writeTextFile / writeTextParts and their staged-output
publication). The write side depends only on domain, filesystem and
resource owners, but il2cpp's Ghidra seed writer had to import
application to reach it (il2cpp -> application).

Move the write side verbatim to src/resources/TextFileWrite.ts
(TextWriteCancellation, writeTextFile, writeTextParts and their private
staging, publication and failure classification helpers). JsonFiles keeps
the JSON read owner and reads the shared errno-to-reason classifier
(fileAccessFailureReason) from the write owner instead of a copy.
Importers (il2cpp seed writer, evidence bundle files, desktop build
solves, analysis snapshot files and four boundary tests) read the new
path; no re-export is left in JsonFiles.

* test(architecture): lower the layer baseline after moving the text write owner

il2cpp -> application 1 -> 0.

* refactor(ports): move the desktop build host contract to src/ports (#11303)

* refactor(domain): move the setup cancellation check from src/application to src/domain

Pure move: git mv plus import specifier rewrites.

* refactor(ports): move the desktop build host contract to src/ports

The desktop provider implements doctor's desktop build facts reader and
setup's desktop build host, but the contract it implements lived in
application (DesktopBuildDoctor, SetupDesktopBuild, Doctor's
clientRegistrations signature, ClientRegistrationEnvironment's setting
types), so desktop imported application four times and the two units
were a recorded mutual pair.

src/ports/DesktopBuildHost.ts now holds that contract, moved verbatim:
DesktopBuildCommand, DesktopBuildFacts, DesktopBuildFactsInput,
DesktopBuildSetupFacts, DesktopBuildSetupHost, RecordedProviderSettings
and OwnedProviderSetting. Two names are new: DesktopBuildRegistration,
the registration facts the host reads (client, command and the
recorded-settings names; client registration status satisfies it), and
DesktopBuildRegistrationReader, which replaces
DoctorHost["clientRegistrations"] in the setup host. The facts input's
registration reader returns DesktopBuildRegistration instead of the full
application status; the setup facts' settings are spelled
Readonly<Record<string, string>> (SetupProviderEnvironment's definition).
Application imports the types from the port; no re-export is left.

* test(architecture): lower the layer baseline after the desktop build host port

desktop -> application 4 -> 0; the application <-> desktop mutual pair is gone.

* refactor(domain): define the resolved app bundle resource root beside its schema (#11304)

* refactor(domain): define the resolved app bundle resource root beside its provenance schema

ResolvedAppBundleResourceRoot (an app directory's resource-only identity)
is a pure type over BundleResourceRoot's layout, but it lived in
src/application/AppBundleExecutable.ts, so the native and artifact
providers that receive it imported application.

Move the interface verbatim to src/domain/apple/bundleResourceRoot.ts,
which owns BundleResourceRoot, and point its eight readers there (native
macOS provider and plist source, artifact provider, binary composition,
and the binary session, status, port and bundle-resource session). The
resolver that produces it stays in application.

* test(architecture): lower the layer baseline after moving the resource root type

native -> application 2 -> 0; artifacts -> application 2 -> 1 (the
artifact provider still constructs BundleResourceSession).

* refactor(config): move the pwntools input bound parser to src/config (#11306)

* refactor(config): move the pwntools input bound parser from src/native to src/config

Pure move: git mv plus import specifier rewrites, and the module path in docs/design/rea-limit-inventory.md (table realigned by oxfmt).

* test(architecture): lower the layer baseline after moving the pwntools input bound

config -> native 1 -> 0. The binary_layout and recorded_crash lanes, which
select src/native/pwntools/**, also select src/config/pwntoolsInputLimit*.ts;
ciChangeScope.test.ts pins both.

* refactor(filesystem): move REA cache directory helpers out of config (#11309)

* refactor(filesystem): move the REA cache directory and lexical directory helpers from src/config to src/filesystem

Pure move: git mv plus import specifier rewrites.

* test(architecture): drop the config and filesystem cycle from the layer baseline

config no longer imports filesystem; filesystem still reads the Windows
ChangeTime settle budget from config.

* refactor(windows): break the process and windows import cycle (#11317)

* refactor(domain): move the runtime-control and private-runtime-root refusals from src/process to src/domain

Pure move: git mv plus import specifier rewrites (including the dist path scripts/verify-windows-native.mjs loads).

* refactor(windows): type Job Object cleanup by what a Windows job reports

WindowsOwnedProcess.cleanup() returned process-ownership's
ProcessCleanupResult, so src/windows imported src/process for a type while
process imports windows to supervise Windows trees. A Job Object stop only
ever reports settled-and-signalled or a reason it did not settle; name that
subset WindowsJobCleanupResult in windows. It stays assignable to
ProcessCleanupResult, so the process supervisor reads it unchanged.

* test(architecture): drop the process and windows cycle from the layer baseline

* test(architecture): ratchet cross-provider imports and imports past a provider entry (#11386)

* test(architecture): ratchet cross-provider imports and imports past a provider entry

A provider folder may import the domain, contracts, foundation and ports layers, the shared provider core (src/providers) and its own files; an import of another provider folder is a recorded exception. Application, composition and the CLI/MCP adapters reach a provider only through src/<provider>/index.ts. verify:module-boundaries counts both kinds of import per unit pair in the layer baseline (crossProvider, providerEntry); like the upward counts they may only shrink, and a pair missing from the baseline fails.

* refactor(resources): move StableArtifactFailure and StableArtifactObservation into src/resources (#11387)

* refactor(resources): move StableArtifactFailure and StableArtifactObservation into src/resources

Providers project stable-read failures through StableArtifactFailure next to the other shared provider toolkit owners (ArtifactReader, ArtifactResourceScope, ArtifactFileOperation, AnalysisCleanupLease, readStableArtifact) that already live in src/resources. Under src/artifacts it made every provider that reads a stable artifact import the artifacts provider. Pure move: git mv plus import specifier and baseline updates; the layer baseline drops the provider-boundary counts the move removes.

* refactor(resources): reach the shared provider toolkit through src/resources/index.ts (#11390)

* refactor(resources): import the shared provider toolkit through src/resources/index.ts

Adds src/resources/index.ts, which exports the toolkit names that production code outside src/resources uses, and rewrites those importers (420 files) to import from it, merging each importer's toolkit imports into one declaration. Mechanical: import declarations only.

* test(architecture): reach src/resources only through its entry file

verify:module-boundaries now counts any production import of a src/resources file other than src/resources/index.ts, from any unit, with the imports past a provider entry. The count is renamed from providerEntry to entry ("import past the entry file"); it may only shrink, and src/resources starts at zero.

* test(architecture): cover provider boundary counts through the verifier command

* refactor(resources): move the safe output tree and artifact path owners into src/resources (#11398)

* refactor(resources): move the safe output tree and artifact path owners into src/resources

SafeOutputTree (with its admission, creation failure, readback, cleanup and identity files), StreamBytes, ArtifactPaths and readArtifactFileChunks depend only on domain, filesystem, platform and the toolkit, and browser, firmware, ghidra, javascript, android and apktool use them to publish outputs. Under src/artifacts every such provider imported the artifacts provider. Pure move: git mv, importers moved onto src/resources/index.ts (names added to the entry), the moved files import toolkit modules directly, path keys in the CI scopes and guard baseline follow the move, and the layer baseline drops the removed imports.

* test(architecture): give the shared provider core its own layer below the providers (#11401)

src/providers (deferred client owners and failure attribution) now imports only domain, ports, process, filesystem and the resources toolkit. Declaring it as the providerCore layer, between ports and providers, makes any import from it into a provider folder an upward import that verify:module-boundaries rejects, and lets every unit in the providers layer be a provider folder.

* test(architecture): declare each provider's entry files instead of a provider barrel (#11407)

* chore: ignore the source map parser move (#11348) in blame

* test(architecture): declare inspector's use of the browser CDP client as a provider dependency (#11420)
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 03:56:10 +08:00
1 parent b0e0d52a9f
commit cef87c498a
1391 files changed
+5011 -3705

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Commits on main that only move files or rewrite import paths.
# Use with: git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# Each entry is the full SHA of the commit as it landed on main (squash and
# rebase merges give a PR's commits new SHAs), so a move is listed by a later
# change once it has merged. Add a commit only when it contains nothing but
# `git mv` renames, import specifier updates and the matching layer baseline.
# refactor(domain): move the source map format parser into src/domain (#11348)
97112f14a1f21a21a91578b5371fe4dfbfbb7835
+16
View File
@@ -23,6 +23,16 @@ Production factories construct fresh providers without starting engines or
acquiring targets; optional adapter failures must preserve successful peers. Run
`npm run verify:test-discovery` after adding or moving tests. Resolved import
boundaries are checked by `npm run verify:module-boundaries`, included in lint.
It also checks each top-level `src/` unit against its layer in
[`scripts/lib/module-layers.mjs`](scripts/lib/module-layers.mjs) (a new
directory must declare one) and against the counted outward, mutual,
cross-provider and past-entry imports in
`scripts/lib/module-layers.baseline.json`. Application, composition and the
adapters import a provider through the entry files it declares in that table
([decision](docs/adr/architecture/provider-entry-files.md)); a new entry file
widens the provider's public surface. The baseline may only shrink: a
change that removes such imports lowers it with
`node scripts/verify-module-boundaries.mjs --shrink-layer-baseline`.
Before retiring an alias or facade, trace runtime registration, dynamic imports,
JavaScript verifiers, subprocess scripts, and packaged entrypoints as well as
@@ -273,6 +283,12 @@ and version provenance, update license notices when needed, and report which
verification was actually repeated. The lab requirements describe a recorded
environment; a dependency update does not verify the revised environment.
Commits that only move files or rewrite import paths are listed in
`.git-blame-ignore-revs`; run
`git config blame.ignoreRevsFile .git-blame-ignore-revs` once so `git blame`
attributes lines to the change that wrote them. Move files with `git mv` and
keep such a commit free of other edits.
Repository invariants live in [AGENTS.md](AGENTS.md). Keep provider-specific
protocols in adapters and shared CLI/MCP workflows in the application layer.
@@ -0,0 +1,63 @@
# Declare each provider's entry files instead of a provider barrel
## Status
Accepted, 2026-11-15. Decided in issues #11358 and #11360.
## Context
Application, composition and the CLI/MCP adapters import provider folders
(`src/ghidra/`, `src/native/`, ...) directly. On 2026-11-15, 238 such imports
reached 167 files in 39 provider folders. Nothing stated which of those files a
provider meant to expose.
The rule for `src/domain` subsystems in
[domain-subsystems.md](domain-subsystems.md) is one `index.ts` per module.
A prototype with an `index.ts` for each provider showed that this does not fit
providers. Composition, the capability declarations and the CLI load single
provider files on purpose: some through dynamic `import()`, some for metadata
only, so that unused providers are never loaded. A barrel pulls in everything
it re-exports. Static runtime import closure, measured on the prototype:
| Importer | Single files | Through `index.ts` |
| --------------------------------- | ------------ | ------------------ |
| `capabilityDeclarations` | 55 | 1408 |
| `doctorRuntime.ts` | 1081 | 1255 |
| `javascriptAnalysisWorkerProcess` | 225 | 334 |
| `webSourceLocations` | 161 | 226 |
A separate metadata entry kept `capabilityDeclarations` at 87 files, but it
would need two entries and a barrel discipline in every provider.
## Decision
`ENTRY_FILES` in `scripts/lib/module-layers.mjs` lists each provider's entry
files, relative to `src/<provider>/`. These are the files that composition and
the adapters wire: provider classes, identities, metadata, worker servers,
doctors and commands. The module-boundary check counts every application,
composition or adapter import of any other provider file in the `entry` map of
`scripts/lib/module-layers.baseline.json`. That count may only shrink.
- **Seed.** The entry files are the provider files that composition and the
adapters imported when the rule was added. Application imports of other
provider files stay counted (67 imports: 41 into `desktop`, 11 into
`artifacts`, 8 into `reference`, 3 into `dotnet`, 2 into `browser` and 2
into `frida`), because application should reach that code through ports.
- **Surface growth.** A new entry file is a reviewed change to the provider's
public surface, and it appears in the diff of `module-layers.mjs`.
- **Other units.** `src/resources`, the shared provider toolkit, declares its
`index.ts` as its only entry file. Every other unit reaches it through that
file.
- **Provider to provider.** The entry rule does not apply here. Every import of
another provider folder is already counted in the `crossProvider` map.
- **Not decided here.** No `index.ts` per provider, and no change to the domain
subsystem rule.
## Consequences
- Each provider's public surface is written down, and lazy and metadata-only
loading stays as it is.
- A rename of an entry file must update the table. A unit test fails when an
entry file does not exist.
- The table states only which files are public, not which symbols. Symbol
growth inside an entry file is not reported.
+25 -1
View File
@@ -1,6 +1,24 @@
graph TD
%% Selected layer owners and dependency/wiring paths, not a directory or import inventory.
%% Current deep-provider candidates are wired in src/composition/binary.ts.
%% Layers, innermost first: domain, contracts, foundation, ports (src/ports/:
%% interfaces providers implement), providerCore (src/providers/: the shared
%% provider core), providers, application, composition, adapters. An import may point to the same or an
%% inner layer. scripts/lib/module-layers.mjs declares the layer of every
%% top-level src/ directory and root file; verify:module-boundaries fails on
%% an undeclared unit and ratchets the recorded outward imports and mutual
%% imports in scripts/lib/module-layers.baseline.json.
%% Provider boundary: a provider folder (src/ghidra/, src/native/, ...)
%% imports inner layers, including the shared provider core (src/providers/,
%% which may not import a provider folder), and its own files. Importing another provider folder is recorded debt
%% unless PROVIDER_DEPENDENCIES declares the file (inspector -> browser CDP
%% client); shared pieces belong in
%% ports, foundation or the provider core. Application, composition and
%% adapters reach a provider through the entry files it declares in
%% scripts/lib/module-layers.mjs (ENTRY_FILES; no per-provider barrel).
%% Every unit reaches the shared provider toolkit (src/resources/) through
%% src/resources/index.ts.
%% The baseline counts both kinds of import per unit pair; both only shrink.
subgraph "Entry Points"
CLI["src/cli.ts + src/cli/<br/>One-shot CLI adapter<br/>setup, diagnostics, analysis, decompilation<br/>cliLoader: recorded registrar per command, complete CLI otherwise"]
MAIN["src/main.ts + src/main/<br/>MCP server adapter: stdio default, streamable HTTP opt-in<br/>config, session, process lifetime"]
@@ -67,11 +85,13 @@ graph TD
WINDOWS["src/windows/<br/>Windows host boundary adapters<br/>package loader, opaque handles, owned jobs and private runtimes"]
WINDOWS_NATIVE["native/windows/src/<br/>Node-API implementation<br/>NTFS/ReFS admission, protected DACLs and atomic Job Object assignment"]
FILESYSTEM["src/filesystem/<br/>owned file and directory handles<br/>stable reads, staged output, caller paths"]
HOPPER_PATHS["src/hopperPaths/<br/>Hopper install paths and launcher discovery<br/>read by the Hopper provider, doctor and setup"]
RESOURCES["src/resources/<br/>shared analysis resource owners<br/>cleanup leases, artifact reader contract, resource scope, owned file operations, stable reads, atomic text writes"]
end
subgraph "Contracts Layer"
CONTRACTS["src/contracts/<br/>Caller-visible schemas for analysis, reverse engineering, managed, browser, Electron, application, and session tools"]
ERRORS["src/contracts/errorSchemas.ts<br/>Shared analysis error schemas<br/>CLI diagnostics, generated error catalog"]
ERRORS["src/contracts/errorSchemas.ts<br/>CLI error envelope and published error JSON Schema<br/>projection schema owned by src/domain/analysisErrorProjectionSchema.ts"]
end
subgraph "Domain Layer"
@@ -206,5 +226,9 @@ graph TD
COMPOSITION --> RUNTIME
RUNTIME --> DOMAIN
PROCESS --> FILESYSTEM
PROCESS --> RESOURCES
HOPPER --> HOPPER_PATHS
APP --> HOPPER_PATHS
HOPPER_PATHS --> FILESYSTEM
AUX --> FILESYSTEM
APP --> FILESYSTEM
+16 -16
View File
@@ -96,22 +96,22 @@ floor, and maximum. The accepted operation snapshot supplies the value.
force. An update outside the range is rejected. A hit names the setting and
reports the current value, source, and range. A rejected Windows ChangeTime launch value omits `pending_restart`.
| Environment | Owner | Default | Floor | Maximum | Applies | Fields |
| --------------------------------------------- | ------------------------------------------- | ----------------------: | ------: | -----------: | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
| `REA_BRIDGE_MAX_REQUEST_BYTES` | `src/config/bridgeMaxRequestBytes.ts` | 16777216 | 7464 | 536870887 | each bridge request, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_BRIDGE_MAX_REPLY_BYTES` | `src/config/bridgeMaxReplyBytes.ts` | 268435456 | 1048576 | 536870888 | each Hopper or Ghidra request, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_CAPTURE_PACKET_JSON_EXPANSION_BYTES` | `src/config/capturePacketJsonExpansion.ts` | 137438953472 | 1048576 | 137438953472 | each packet-capture reply before parsing, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_DEBUGGER_COMMAND_DEADLINE_MS` | `src/domain/analysisResourceLimits.ts` | 120000 | 1 | 2147483647 | each command, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_DEBUGGER_MAX_COMMAND_OUTPUT_BYTES` | `src/domain/analysisResourceLimits.ts` | 16777216 | 1 | 89303718 | each command, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_HOPPER_CALLER_SCAN_BUDGET_MS` | `src/domain/analysisResourceLimits.ts` | 2000 | 1 | 2147483647 | each caller scan, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES` | `src/domain/analysisResourceLimits.ts` | 524288 | 1 | 8388608 | each JavaScript source's member-mutation phase, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_JEB_MCP_TIMEOUT_MS` | `src/jeb/JebMcpConnection.ts` | 60000 (MCP SDK default) | 1 | 2147483647 | discovery and each tools/call, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_KUNA_PROJECT_TIMEOUT_MS` | `src/kuna/KunaConfiguration.ts` | 1800000 | 1 | 2147483647 | each project export and whole-program scan, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_KUNA_TIMEOUT_MS` | `src/kuna/KunaConfiguration.ts` | 120000 | 1 | 2147483647 | each function decompile, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_PWNTOOLS_MAX_INPUT_BYTES` | `src/native/pwntools/PwntoolsInputLimit.ts` | 33554432 | 1 | 1073741824 | each pwntools decode, unless the call passes `producer_limits.input_bytes`; otherwise the operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_WINDOWS_CHANGE_TIME_DRIFT_MS` | `src/config/windowsChangeTimeSettle.ts` | 2000 | 1 | 60000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
| `REA_WINDOWS_CHANGE_TIME_SETTLE_POLL_MS` | `src/config/windowsChangeTimeSettle.ts` | 25 | 1 | 1000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
| `REA_WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS` | `src/config/windowsChangeTimeSettle.ts` | 40 | 1 | 1000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
| Environment | Owner | Default | Floor | Maximum | Applies | Fields |
| --------------------------------------------- | ------------------------------------------ | ----------------------: | ------: | -----------: | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
| `REA_BRIDGE_MAX_REQUEST_BYTES` | `src/config/bridgeMaxRequestBytes.ts` | 16777216 | 7464 | 536870887 | each bridge request, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_BRIDGE_MAX_REPLY_BYTES` | `src/config/bridgeMaxReplyBytes.ts` | 268435456 | 1048576 | 536870888 | each Hopper or Ghidra request, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_CAPTURE_PACKET_JSON_EXPANSION_BYTES` | `src/config/capturePacketJsonExpansion.ts` | 137438953472 | 1048576 | 137438953472 | each packet-capture reply before parsing, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_DEBUGGER_COMMAND_DEADLINE_MS` | `src/domain/analysisResourceLimits.ts` | 120000 | 1 | 2147483647 | each command, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_DEBUGGER_MAX_COMMAND_OUTPUT_BYTES` | `src/domain/analysisResourceLimits.ts` | 16777216 | 1 | 89303718 | each command, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_HOPPER_CALLER_SCAN_BUDGET_MS` | `src/domain/analysisResourceLimits.ts` | 2000 | 1 | 2147483647 | each caller scan, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES` | `src/domain/analysisResourceLimits.ts` | 524288 | 1 | 8388608 | each JavaScript source's member-mutation phase, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_JEB_MCP_TIMEOUT_MS` | `src/jeb/JebMcpConnection.ts` | 60000 (MCP SDK default) | 1 | 2147483647 | discovery and each tools/call, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_KUNA_PROJECT_TIMEOUT_MS` | `src/kuna/KunaConfiguration.ts` | 1800000 | 1 | 2147483647 | each project export and whole-program scan, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_KUNA_TIMEOUT_MS` | `src/kuna/KunaConfiguration.ts` | 120000 | 1 | 2147483647 | each function decompile, from the accepted operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_PWNTOOLS_MAX_INPUT_BYTES` | `src/config/pwntoolsInputLimit.ts` | 33554432 | 1 | 1073741824 | each pwntools decode, unless the call passes `producer_limits.input_bytes`; otherwise the operation snapshot | `update_mode: "runtime"`, `pending_restart: false` |
| `REA_WINDOWS_CHANGE_TIME_DRIFT_MS` | `src/config/windowsChangeTimeSettle.ts` | 2000 | 1 | 60000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
| `REA_WINDOWS_CHANGE_TIME_SETTLE_POLL_MS` | `src/config/windowsChangeTimeSettle.ts` | 25 | 1 | 1000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
| `REA_WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS` | `src/config/windowsChangeTimeSettle.ts` | 40 | 1 | 1000 | each ChangeTime observation, from the accepted operation snapshot | `update_mode: "runtime"`; invalid launch omits `pending_restart` |
## Restart-only numeric limits
+1 -1
View File
@@ -23,7 +23,7 @@ section placement:
specifier, redirect and remote tables, and the npm snapshot length.
- `DenoVirtualFs.ts` walks directories, files and symlinks into safe logical
paths with indexed fallbacks, using `ArtifactPathRegistry.conflicts` in
`src/artifacts/ArtifactPaths.ts` to avoid occupied paths.
`src/resources/ArtifactPaths.ts` to avoid occupied paths.
- `DenoStandaloneAdmission.ts` binds the located carrier to the admitted file.
`src/artifacts/DenoStandaloneArtifactReader.ts` projects members, metadata,
+36 -17
View File
@@ -45,6 +45,7 @@ const PATH_SCOPES = {
"src/contracts/pcap/**",
"src/domain/captures/**",
"src/application/captures/**",
"src/ports/captures/**",
"src/contracts/captures/**",
"src/composition/captures.ts",
"src/cli/captureCommands.ts",
@@ -60,6 +61,7 @@ const PATH_SCOPES = {
"src/signals/**",
"src/domain/signals/**",
"src/application/signals/**",
"src/ports/signals/**",
"src/contracts/signals/**",
"src/composition/signals.ts",
"src/cli/signalCommands.ts",
@@ -258,6 +260,7 @@ const PATH_SCOPES = {
"scripts/lib/runtime-admission.d.mts",
"install.sh",
"src/config/**",
"src/hopperPaths/**",
// The darwin package baseline runs packaged Hopper commands against the
// fake bridge, through the reply contracts and the domain schemas they
// are built from. Check a change to either side before merge, not after.
@@ -342,11 +345,12 @@ const PATH_SCOPES = {
"src/domain/sqlite/**",
"src/contracts/sqlite/**",
"src/application/sqlite/**",
"src/ports/sqlite/**",
"src/composition/sqlite.ts",
"src/cli/sqliteCommands.ts",
"src/application/DirectAnalysisStatus*.ts",
"src/application/CapabilityInventory*.ts",
"src/application/AnalysisProvider*.ts",
"src/ports/AnalysisProvider*.ts",
"src/contracts/toolContracts.ts",
"src/contracts/toolContractTypes.ts",
"src/contracts/toolEffects*.ts",
@@ -364,9 +368,10 @@ const PATH_SCOPES = {
"src/process/ProviderProcess*.ts",
"src/process/PrivateRuntimeRoot*.ts",
"src/artifacts/ArtifactReader*.ts",
"src/artifacts/ArtifactResourceScope*.ts",
"src/artifacts/ArtifactPaths*.ts",
"src/artifacts/readStableArtifact*.ts",
"src/resources/ArtifactReader*.ts",
"src/resources/ArtifactResourceScope*.ts",
"src/resources/ArtifactPaths*.ts",
"src/resources/readStableArtifact*.ts",
"src/filesystem/OwnedFileHandle*.ts",
"src/server/EvidenceMcpServer*.ts",
"src/server/analysisAdmission*.ts",
@@ -408,12 +413,14 @@ const PATH_SCOPES = {
"src/domain/analysisView/{EnvironmentManifest*,EnvironmentState*}.ts",
"src/domain/analysisView/{scenarioCaptureRecords,recordedResponseBody,recordedExchangeBody,recordedMediaType,webNetworkRouteTemplates,WebNetworkProjectionAccumulator}.ts",
"src/application/BrowserScenario*.ts",
"src/ports/BrowserScenario*.ts",
"src/application/environment/**",
"src/application/WebModule*.ts",
"src/ports/WebModule*.ts",
"src/composition/browserScenario.ts",
"src/composition/webModules.ts",
"src/artifacts/readStableArtifact.ts",
"src/artifacts/ArtifactPaths.ts",
"src/resources/readStableArtifact.ts",
"src/resources/ArtifactPaths.ts",
"src/application/WebScriptExportService.ts",
"src/contracts/webScriptToolContracts.ts",
"src/server/registerWebScriptTool.ts",
@@ -430,8 +437,10 @@ const PATH_SCOPES = {
".github/workflows/real-binary-layout.yml",
"bridge/pwntools/**",
"src/native/pwntools/**",
"src/config/pwntoolsInputLimit*.ts",
"src/domain/native/binaryLayout*",
"src/application/binaryDiagnostics/**",
"src/ports/binaryDiagnostics/**",
"src/contracts/native/binaryDiagnosticsToolContracts.ts",
"src/composition/binaryDiagnostics.ts",
"src/server/registerBinaryDiagnosticsTools.ts",
@@ -446,8 +455,8 @@ const PATH_SCOPES = {
"src/process/ProviderDeadline.ts",
"src/process/ProcessOwnership*.ts",
"src/process/PrivateRuntimeRoot.ts",
"src/artifacts/readStableArtifact*.ts",
"src/artifacts/ArtifactReader.ts",
"src/resources/readStableArtifact*.ts",
"src/resources/ArtifactReader.ts",
"src/domain/analysisError*.ts",
"scripts/verify-binary-layout.mjs",
"scripts/lib/elf-section-name-fixtures.mjs",
@@ -459,6 +468,7 @@ const PATH_SCOPES = {
"src/evm/**",
"src/domain/evm/**",
"src/application/evm/**",
"src/ports/evm/**",
"src/contracts/evm/**",
"src/composition/evm.ts",
"src/cli/evmCommands.ts",
@@ -472,8 +482,8 @@ const PATH_SCOPES = {
"src/process/ProcessOwnership*.ts",
"src/process/ProviderDeadline.ts",
"src/process/PrivateRuntimeRoot.ts",
"src/artifacts/readStableArtifact*.ts",
"src/artifacts/ArtifactReader.ts",
"src/resources/readStableArtifact*.ts",
"src/resources/ArtifactReader.ts",
"scripts/verify-evm-interface.mjs",
"scripts/verify-solidity-metadata.mjs",
"scripts/fixtures/evm-interface.sol",
@@ -484,6 +494,7 @@ const PATH_SCOPES = {
"src/domain/apkSignature/**",
"src/apkSignature/**",
"src/application/apkSignature/**",
"src/ports/apkSignature/**",
"src/composition/apkSignature.ts",
"src/contracts/apkSignature/**",
"src/cli/apkSignatureCommands.ts",
@@ -493,6 +504,7 @@ const PATH_SCOPES = {
"src/application/analysisView/**",
"src/cli/analysisEvidenceDelivery.ts",
"src/artifacts/**",
"src/resources/**",
"scripts/verify-apk-signature.mjs",
"tests/fixtures/apkSignature/**",
"tests/acceptance/apkSignature*.test.ts",
@@ -502,6 +514,7 @@ const PATH_SCOPES = {
"src/javascript/recovery/**",
"src/domain/javascript/**",
"src/application/javascript/JavaScriptRecovery*.ts",
"src/ports/javascript/JavaScriptRecovery*.ts",
"src/composition/javascriptRecovery.ts",
"src/contracts/javascript/javascriptRecoveryToolContracts.ts",
"src/cli/javascriptRecoveryCommands.ts",
@@ -518,7 +531,7 @@ const PATH_SCOPES = {
"scripts/lib/runtime-admission.mjs",
"scripts/lib/runtime-admission.d.mts",
"src/process/**",
"src/artifacts/SafeOutputTree.ts",
"src/resources/SafeOutputTree.ts",
"scripts/verify/javascript/recovery.mjs",
"scripts/fixtures/javascript-recovery/**",
"third_party/wakaru",
@@ -528,9 +541,11 @@ const PATH_SCOPES = {
"bridge/pwntools/**",
"bridge/pwndbg/**",
"src/native/pwntools/**",
"src/config/pwntoolsInputLimit*.ts",
"src/native/pwndbg/**",
"src/domain/native/recordedCrash*",
"src/application/binaryDiagnostics/**",
"src/ports/binaryDiagnostics/**",
"src/contracts/native/binaryDiagnosticsToolContracts.ts",
"src/contracts/toolEffects.ts",
"src/contracts/toolOutputSchemaGroups.ts",
@@ -540,7 +555,7 @@ const PATH_SCOPES = {
"src/cli/binaryDiagnosticsCommands.ts",
"src/cliCommandNames.ts",
"src/process/**",
"src/artifacts/readStableArtifact*.ts",
"src/resources/readStableArtifact*.ts",
"src/domain/analysisError*.ts",
"scripts/verify-recorded-crash.mjs",
"scripts/verify/recorded-crash/**",
@@ -572,8 +587,8 @@ const PATH_SCOPES = {
"src/process/ProcessOwnership*.ts",
"src/process/PrivateRuntimeRoot.ts",
"src/process/capture/ProcessCaptureLifecycle.ts",
"src/artifacts/readStableArtifact*.ts",
"src/artifacts/ArtifactReader.ts",
"src/resources/readStableArtifact*.ts",
"src/resources/ArtifactReader.ts",
"src/contracts/webNetworkCaptureToolContracts.ts",
"scripts/verify-web-network-captures.mjs",
"scripts/fixtures/generate-mitmproxy-capture.py",
@@ -596,6 +611,7 @@ const PATH_SCOPES = {
"src/domain/webEventListeners.ts",
"src/domain/browserObservationError*.ts",
"src/application/WebRuntime*.ts",
"src/ports/WebRuntime*.ts",
"src/composition/webRuntime.ts",
"src/contracts/webRuntimeToolContracts.ts",
"src/contracts/toolEffects.ts",
@@ -617,6 +633,7 @@ const PATH_SCOPES = {
"src/domain/webSource*.ts",
"src/domain/webScript*.ts",
"src/application/WebSourceLocation*.ts",
"src/ports/WebSourceLocation*.ts",
"src/application/ValidateSelectedWebScript.ts",
"src/composition/webSourceLocations.ts",
"src/server/createServer.ts",
@@ -624,14 +641,16 @@ const PATH_SCOPES = {
"src/process/**",
"src/cli/webSourceLocationCommands.ts",
"src/cli.ts",
"src/artifacts/readStableArtifact.ts",
"src/resources/readStableArtifact.ts",
],
agentenv: [
".github/workflows/real-agentenv.yml",
"scripts/verify-agentenv-environment.mjs",
"src/{application,server}/environment/**",
"src/application/{JsonInputFile,OwnedJsonInput,RegularFileRead}.ts",
"src/artifacts/{SafeOutputTree*,ArtifactResourceScope,StreamBytes}.ts",
"src/application/{JsonInputFile,OwnedJsonInput}.ts",
"src/resources/{SafeOutputTree*,StreamBytes}.ts",
"src/resources/ArtifactResourceScope.ts",
"src/process/RegularFileRead.ts",
"src/cli/cliJsonInput.ts",
"src/server/http/**",
"src/{cli,cliCommandNames,cli/environmentCommands}.ts",
+2 -2
View File
@@ -7,8 +7,8 @@ import {
prepareOwnedCommand,
runOwnedCommand,
} from "../../dist/process/OwnedCommand.js";
import { ArtifactResourceScope } from "../../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/resources/AnalysisCleanupLease.js";
import { retainOwnedCommandCleanup } from "../../dist/providers/OwnedCommandCleanup.js";
/** Keep command ownership through failure and join cleanup before removing a run. */
@@ -8,8 +8,8 @@ import {
spawnOwnedProviderProcess,
} from "../../dist/process/ProviderProcess.js";
import { cleanupOwnedProcessGroup } from "../../dist/process/ProcessOwnership.js";
import { ArtifactResourceScope } from "../../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/resources/AnalysisCleanupLease.js";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
import { discoverCdpEndpoint } from "../../dist/browser/CdpEndpoint.js";
import { BrowserObservationError } from "../../dist/domain/browserObservationError.js";
+1 -1
View File
@@ -1,6 +1,6 @@
import { isDeepStrictEqual } from "node:util";
import { authenticateParsedEvidenceBundle } from "../../dist/domain/evidenceBundle.js";
import { analysisErrorProjectionSchema } from "../../dist/contracts/errorSchemas.js";
import { analysisErrorProjectionSchema } from "../../dist/domain/analysisErrorProjectionSchema.js";
import { toolContract } from "../../dist/contracts/toolContracts.js";
import {
expandProviderCapabilities,
+2 -1
View File
@@ -3,6 +3,7 @@ import { isAbsolute, relative, resolve } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { readImportSpecifiers } from "./import-specifiers.mjs";
import { isLayerException } from "./module-layers.mjs";
const PURE_LAYERS = new Set(["domain", "contracts"]);
const MIGRATED_PROVIDER_ROOTS = new Set([
@@ -125,7 +126,7 @@ const failedBoundary = (file, target, typeOnly) => {
/^src\/(?:cli|main)\./u.test(target))
)
return "artifact-acquisition";
if (PURE_LAYERS.has(layer)) {
if (PURE_LAYERS.has(layer) && !isLayerException(file, target)) {
if (
(/^src\/[^/]+\//u.test(target) && !PURE_LAYERS.has(targetLayer)) ||
/^src\/(?:cli|main)\./u.test(target)
+38 -54
View File
@@ -1,70 +1,54 @@
{
"upward": {
"adb -> application": 4,
"android -> application": 10,
"apkSignature -> application": 3,
"apktool -> application": 3,
"application -> catalogDiscovery.ts": 1,
"application -> catalogIdentity.ts": 2,
"application -> mcpStartupPolicy.ts": 3,
"application -> serverIdentity.ts": 1,
"artifacts -> application": 8,
"browser -> application": 33,
"captures -> application": 2,
"artifacts -> application": 1,
"composition -> cliCommandNames.ts": 3,
"config -> application": 2,
"config -> native": 1,
"desktop -> application": 5,
"domain -> contracts": 4,
"dotnet -> application": 4,
"electron -> application": 2,
"erlang -> application": 2,
"evm -> application": 2,
"firmware -> application": 4,
"flutter -> application": 1,
"frida -> application": 4,
"ghidra -> application": 17,
"go -> application": 2,
"gpu -> application": 2,
"hopper -> application": 13,
"ida -> application": 8,
"il2cpp -> application": 5,
"inspector -> application": 3,
"javascript -> application": 6,
"jeb -> application": 4,
"kuna -> application": 7,
"model -> application": 2,
"native -> application": 35,
"pcap -> application": 2,
"process -> artifacts": 20,
"providers -> application": 4,
"python -> application": 2,
"rust -> application": 2,
"signals -> application": 2,
"sqlite -> application": 2,
"v8 -> application": 2,
"wasm -> application": 2,
"windows -> artifacts": 2
"dotnet -> application": 1
},
"cycles": [
"application <-> artifacts",
"application <-> browser",
"application <-> config",
"application <-> desktop",
"application <-> dotnet",
"application <-> frida",
"application <-> providers",
"artifacts <-> dotnet",
"artifacts <-> javascript",
"artifacts <-> native",
"artifacts <-> process",
"cli <-> cli.ts",
"cli <-> cliBrowserScenarioCommands.ts",
"cli <-> cliEvidenceCommands.ts",
"cli <-> cliOutput.ts",
"config <-> filesystem",
"contracts <-> domain",
"main <-> server",
"process <-> windows"
]
"main <-> server"
],
"crossProvider": {
"android -> artifacts": 2,
"android -> native": 1,
"apktool -> artifacts": 2,
"artifacts -> dotnet": 3,
"artifacts -> javascript": 1,
"artifacts -> native": 2,
"browser -> artifacts": 6,
"browser -> electron": 5,
"browser -> javascript": 1,
"captures -> pcap": 2,
"desktop -> browser": 1,
"desktop -> electron": 1,
"electron -> artifacts": 2,
"flutter -> artifacts": 1,
"go -> native": 2,
"gpu -> artifacts": 2,
"gpu -> native": 5,
"il2cpp -> ghidra": 1,
"il2cpp -> native": 5,
"inspector -> browser": 2,
"kuna -> artifacts": 1,
"kuna -> native": 2,
"model -> artifacts": 1,
"native -> artifacts": 13,
"rust -> native": 2
},
"entry": {
"application -> artifacts": 11,
"application -> browser": 2,
"application -> desktop": 41,
"application -> frida": 2,
"application -> reference": 8
}
}
+56 -2
View File
@@ -1,15 +1,64 @@
export declare const LAYER_ORDER: readonly string[];
export declare const UNIT_LAYERS: Readonly<Record<string, string>>;
/** Single file-to-file upward imports declared as deliberate exceptions. */
export declare const LAYER_EXCEPTIONS: readonly {
readonly file: string;
readonly target: string;
readonly reason: string;
}[];
/** Whether one resolved import is a declared layer exception. */
export function isLayerException(file: string, target: string): boolean;
/** The top-level unit of a production `src/` file, or undefined. */
export function sourceUnit(path: string): string | undefined;
export interface LayerGraphFacts {
/** Whether a unit is a provider folder. */
export function isProviderUnit(unit: string): boolean;
/**
* Declared entry files per unit, relative to src/<unit>/: src/resources is
* reached only through them from every unit, a provider folder from
* application, composition and the CLI/MCP adapters.
*/
export declare const ENTRY_FILES: Readonly<Record<string, readonly string[]>>;
/**
* Declared provider-to-provider dependencies: files of `to`, relative to
* src/<to>/, that `from` may import without a crossProvider count.
*/
export declare const PROVIDER_DEPENDENCIES: readonly {
readonly from: string;
readonly to: string;
readonly files: readonly string[];
readonly reason: string;
}[];
export interface ProviderBoundaryFacts {
/** Imports from one provider folder into another, per unit pair. */
readonly crossProvider: Readonly<Record<string, number>>;
/**
* Imports past the entry files: application, composition and adapter
* imports of a provider file not in its ENTRY_FILES, and any outside import
* of another non-provider unit's file not in its ENTRY_FILES.
*/
readonly entry: Readonly<Record<string, number>>;
}
export function providerBoundaryFacts(
imports: readonly { readonly file: string; readonly target: string }[],
): ProviderBoundaryFacts;
export interface LayerGraphFacts extends ProviderBoundaryFacts {
readonly undeclared: readonly string[];
readonly upward: Readonly<Record<string, number>>;
readonly cycles: readonly string[];
}
export type LayerBaseline = Pick<LayerGraphFacts, "upward" | "cycles"> &
Partial<ProviderBoundaryFacts>;
export function layerGraphFacts(
imports: readonly { readonly file: string; readonly target: string }[],
files?: readonly string[],
@@ -17,5 +66,10 @@ export function layerGraphFacts(
export function compareLayerBaseline(
facts: LayerGraphFacts,
baseline: Pick<LayerGraphFacts, "upward" | "cycles">,
baseline: LayerBaseline,
): { readonly failures: string[]; readonly lowerable: string[] };
export function lowerLayerBaseline(
facts: LayerGraphFacts,
baseline: LayerBaseline,
): Required<LayerBaseline>;
+353 -18
View File
@@ -5,14 +5,18 @@
* its layer when it is added.
*
* The order follows docs/architecture/architecture.mermaid: domain and
* contracts at the centre, the process/filesystem foundation, provider
* adapters, shared application workflows, production composition, then the
* CLI and MCP entry points.
* contracts at the centre, the process/filesystem foundation, the ports
* that providers implement and application consumes, the shared provider
* core (src/providers), provider adapters,
* shared application workflows, production composition, then the CLI and
* MCP entry points.
*/
export const LAYER_ORDER = Object.freeze([
"domain",
"contracts",
"foundation",
"ports",
"providerCore",
"providers",
"application",
"composition",
@@ -29,13 +33,21 @@ export const UNIT_LAYERS = Object.freeze(
"compression",
"config",
"filesystem",
"hopperPaths",
"platform",
"process",
"resources",
"windows",
"generatedPackageMetadata.ts",
"identity.ts",
"logger.ts",
]),
...units("ports", ["ports"]),
// The shared provider core (src/providers): deferred client owners and
// failure attribution that every provider folder may import. It may not
// import a provider folder.
...units("providerCore", ["providers"]),
// Every unit here is a provider folder; see providerBoundaryFacts.
...units("providers", [
"adb",
"android",
@@ -68,7 +80,6 @@ export const UNIT_LAYERS = Object.freeze(
"native",
"objdump",
"pcap",
"providers",
"python",
"reference",
"rizin",
@@ -108,6 +119,32 @@ export const UNIT_LAYERS = Object.freeze(
]),
);
/**
* Single file-to-file imports that may point up the layer order. Each one is
* a deliberate decision, not a baseline debt: it is not counted, and any other
* import between the same units still is. Keep the list short and say why.
*/
export const LAYER_EXCEPTIONS = Object.freeze([
Object.freeze({
file: "src/domain/localPath.ts",
target: "src/platform/HostPlatform.ts",
// `absoluteLocalPathStringSchema` states which paths are absolute on the
// host running REA; that is a fact about the host's path rules, and
// HostPlatform is its only reader (maintainer decision, W8).
reason:
"the absolute local path schema follows the running host's path rules",
}),
]);
const sourcePath = (path) => path.replace(/\.js$/u, ".ts");
/** Whether one resolved import is a declared layer exception. */
export const isLayerException = (file, target) =>
LAYER_EXCEPTIONS.some(
(exception) =>
exception.file === sourcePath(file) &&
exception.target === sourcePath(target),
);
const PRODUCTION_SOURCE = /^src\/.+\.(?:ts|js)$/u;
const NON_PRODUCTION = /\.(?:test|spec|fixture)\.(?:ts|js)$|\.d\.ts$/u;
@@ -148,6 +185,7 @@ export const layerGraphFacts = (imports, files = []) => {
const from = sourceUnit(file);
const to = sourceUnit(target);
if (from === undefined || to === undefined || from === to) continue;
if (isLayerException(file, target)) continue;
for (const unit of [from, to])
if (UNIT_LAYERS[unit] === undefined) undeclared.add(unit);
const key = `${from} -> ${to}`;
@@ -165,13 +203,287 @@ export const layerGraphFacts = (imports, files = []) => {
undeclared: [...undeclared].sort(),
upward,
cycles: mutualPairs(edges),
...providerBoundaryFacts(imports),
};
};
/** Whether a unit is a provider folder. */
export const isProviderUnit = (unit) => UNIT_LAYERS[unit] === "providers";
const ENTRY_IMPORTER_LAYERS = new Set([
"application",
"composition",
"adapters",
]);
/**
* Compare facts with the recorded baseline. Growth fails: a new upward pair,
* more imports on a recorded pair, or a cycle group not recorded. Shrinkage is
* returned separately so the baseline can be lowered.
* Declared entry files of each unit, relative to `src/<unit>/`: the only
* files that outside code may import.
*
* - `src/resources`, the shared provider toolkit (stable reads, artifact
* readers, resource scopes, cleanup leases and their failure projections),
* is reached from every other unit through its `index.ts`.
* - A provider folder is reached from application, composition and the CLI/MCP
* adapters through the files listed here: the provider classes, identities,
* metadata, worker servers, doctors and commands that composition wires.
* There is no per-provider barrel, because composition, the capability
* declarations and the CLI load single provider files lazily or for metadata
* only, and a barrel would pull in the whole provider.
*
* Adding a file here widens that unit's public surface; review it as such.
* Imports of any other file are counted in the baseline's `entry` map.
*/
export const ENTRY_FILES = Object.freeze(
Object.fromEntries(
Object.entries({
resources: ["index.ts"],
adb: ["AdbProvider.ts", "AdbProviderIdentity.ts"],
android: [
"JadxDoctor.ts",
"JadxMcpTransport.ts",
"JadxProvider.ts",
"JadxRelease.ts",
],
apkSignature: ["ApkSignatureProvider.ts", "ApkSignatureRelease.ts"],
apktool: ["ApktoolProvider.ts", "ApktoolProviderIdentity.ts"],
artifacts: [
"ArtifactProvider.ts",
"ArtifactProviderMetadata.ts",
"DesktopApplicationReader.ts",
"ReleaseExposureReader.ts",
],
browser: [
"CdpBrowserProvider.ts",
"CdpElectronProvider.ts",
"IsolatedWebBundleAnalyzer.ts",
"PlaywrightBrowserScenarioProvider.ts",
"PlaywrightElectronActiveProvider.ts",
"PlaywrightScenarioSession.ts",
"WebBundleAnalysisWorkerServer.ts",
"assets/WebSourceLocationArtifacts.ts",
"execution/CdpWebRuntimeProvider.ts",
"history/CaptureProviderIdentities.ts",
"history/HistoricalCaptureDecoder.ts",
"history/MitmproxyCaptureAdapter.ts",
"history/NodeCaptureAdapter.ts",
"history/playwrightTrace/PlaywrightTraceDecoder.ts",
"modules/NativeModuleResolver.ts",
"modules/WebModuleArtifacts.ts",
"providerIdentities.ts",
],
captures: ["TsharkCaptureProvider.ts", "TsharkProviderIdentity.ts"],
cutter: [
"CutterBridgeClient.ts",
"CutterBridgeService.ts",
"CutterProviderIdentity.ts",
],
desktop: [
"AgentEnvComputer.ts",
"BuildComputerEnvironment.ts",
"DconfDatabaseReader.ts",
"DesktopBuildDoctorFacts.ts",
"DesktopSessionRequests.ts",
],
dotnet: ["ManagedStaticProvider.ts", "ManagedStaticProviderMetadata.ts"],
electron: ["ElectronFuseProvider.ts", "ElectronFuseProviderIdentity.ts"],
erlang: ["BeamProvider.ts", "ErlangBeamProviderIdentity.ts"],
evm: ["EvmoleInterfaceProvider.ts", "EvmoleProviderIdentity.ts"],
firmware: [
"FirmwareCommand.ts",
"FirmwareProvider.ts",
"FirmwareProviderIdentities.ts",
"devicetree/DevicetreeProvider.ts",
],
flutter: ["FlutterBuildProvider.ts", "FlutterProviderIdentity.ts"],
frida: ["FridaInstrumentationManager.ts", "FridaProviderIdentity.ts"],
gdb: ["GdbProviderIdentity.ts", "GdbSessionManager.ts"],
ghidra: [
"GhidraDoctor.ts",
"GhidraProvider.ts",
"GhidraProviderMetadata.ts",
],
go: ["GoBinaryProvider.ts", "GoBinaryProviderIdentity.ts"],
gpu: ["GpuCodeObjectsProvider.ts", "GpuCodeObjectsProviderIdentity.ts"],
hopper: [
"HopperProvider.ts",
"HopperProviderMetadata.ts",
"LinuxPrivateDisplayProbe.ts",
],
ida: [
"IdaConfiguration.ts",
"IdaDoctor.ts",
"IdaMcpConnection.ts",
"IdaProvider.ts",
"IdaProviderMetadata.ts",
],
il2cpp: [
"Il2CppMetadataProviderIdentity.ts",
"Il2cppGhidraSeedWriter.ts",
"Il2cppMetadataProvider.ts",
],
inspector: ["V8InspectorProvider.ts", "providerIdentity.ts"],
javascript: [
"analysis/JavaScriptAnalysisTransfer.ts",
"analysis/JavaScriptAnalysisWorkerServer.ts",
"recovery/WakaruCommand.ts",
"recovery/WakaruProvider.ts",
"recovery/WakaruProviderIdentity.ts",
"sourceMaps/SourceMapDecoder.ts",
],
jeb: ["JebMcpConnection.ts", "JebProvider.ts", "JebProviderIdentity.ts"],
kuna: ["KunaDoctor.ts", "KunaProvider.ts", "KunaProviderMetadata.ts"],
model: ["ModelArtifactProvider.ts", "ModelArtifactProviderIdentity.ts"],
native: [
"NativeMacOSProvider.ts",
"NativeMacOSProviderMetadata.ts",
"NativeMacosProviderIdentity.ts",
"apple/AppleIpsProvider.ts",
"elf/ElfNotesProvider.ts",
"elf/ElfUnwindRangesProvider.ts",
"elf/KernelBuildConfigProvider.ts",
"elf/KernelModuleProvider.ts",
"exports/NativeExportsProvider.ts",
"hardening/BinaryHardeningProvider.ts",
"initializers/NativeInitializersProvider.ts",
"pe/PeCertificatesProvider.ts",
"pe/PeImportsProvider.ts",
"pe/PeLoadConfigProvider.ts",
"pe/PeResourcesProvider.ts",
"pwntools/PwntoolsDecoder.ts",
"pwntools/PwntoolsLayoutProvider.ts",
"pwntools/PwntoolsProviderIdentity.ts",
"pwntools/PwntoolsRecordedCrashProvider.ts",
"windows/WindowsShortcutProvider.ts",
],
objdump: ["ObjdumpCommand.ts", "ObjdumpProviderIdentity.ts"],
pcap: [
"PcapConfiguration.ts",
"PcapProvider.ts",
"PcapProviderIdentity.ts",
],
python: ["PythonPycProvider.ts", "PythonPycProviderIdentity.ts"],
reference: [],
rizin: [
"RizinCommand.ts",
"RizinDebugSessionManager.ts",
"RizinDebuggerProviderIdentity.ts",
"RizinProviderIdentity.ts",
],
rust: ["RustBinaryProvider.ts", "RustBinaryProviderIdentity.ts"],
signals: ["SigrokProviderIdentity.ts", "SigrokRecordingProvider.ts"],
sqlite: ["SqliteDatabaseProvider.ts"],
v8: ["V8CodeCacheProvider.ts", "V8CodeCacheProviderIdentity.ts"],
wasm: ["WabtArtifactProvider.ts", "WabtRelease.ts"],
}).map(([unit, files]) => [unit, Object.freeze(files)]),
),
);
/**
* Whether an import from `from` into `to` must use one of `to`'s entry
* files: every import of a non-provider unit that declares entry files, and
* every application, composition or adapter import of a provider folder (a
* provider without declared entry files has none).
*/
const requiresEntry = (from, to) =>
isProviderUnit(to)
? ENTRY_IMPORTER_LAYERS.has(UNIT_LAYERS[from])
: ENTRY_FILES[to] !== undefined;
/** Whether a resolved target is one of its unit's declared entry files. */
const isEntryFile = (unit, target) =>
(ENTRY_FILES[unit] ?? []).some(
(file) => sourcePath(target) === `src/${unit}/${file}`,
);
/**
* Declared provider-to-provider dependencies: files of one provider folder,
* relative to `src/<to>/`, that another provider folder may import. Each one
* is a deliberate decision, not baseline debt: imports of these files are not
* counted in `crossProvider`, and any other import between the same folders
* still is. Keep the list short and say why.
*/
export const PROVIDER_DEPENDENCIES = Object.freeze([
Object.freeze({
from: "inspector",
to: "browser",
files: Object.freeze([
"CdpCaptureValues.ts",
"CdpConnection.ts",
"CdpDiscoveryTargets.ts",
"CdpEndpoint.ts",
"CdpScriptContextFacts.ts",
"CdpTargetSessionOwner.ts",
"protocol/CdpEvents.ts",
]),
// The V8 inspector speaks the Chrome DevTools Protocol. It reuses
// browser's CDP client (endpoint discovery, connection, target sessions
// and captured value projection) instead of keeping a second client.
reason: "the V8 inspector reuses the browser provider's CDP client",
}),
]);
/** Whether one provider-to-provider import is a declared dependency. */
const isDeclaredProviderDependency = (from, to, target) =>
PROVIDER_DEPENDENCIES.some(
(dependency) =>
dependency.from === from &&
dependency.to === to &&
dependency.files.some(
(file) => sourcePath(target) === `src/${to}/${file}`,
),
);
const sortedCounts = (counts) =>
Object.fromEntries(
[...counts].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),
);
/**
* Provider boundary facts, counted per unit pair.
*
* A provider folder may import the domain, contracts, foundation and ports
* layers, the shared provider core (its own layer, below providers) and its
* own files. Any other import of another provider folder is recorded debt
* unless PROVIDER_DEPENDENCIES declares its target file for that pair:
* `crossProvider` counts them per pair, and a pair that is not in the
* baseline fails. Application, composition and the
* CLI/MCP adapters reach a provider only through its declared ENTRY_FILES, and
* every unit reaches src/resources only through its `index.ts`: `entry` counts
* the imports of any other file in such a unit. Both counts may only shrink.
*/
export const providerBoundaryFacts = (imports) => {
const cross = new Map();
const entry = new Map();
for (const { file, target } of imports) {
const from = sourceUnit(file);
const to = sourceUnit(target);
if (from === undefined || to === undefined || from === to) continue;
const key = `${from} -> ${to}`;
if (isProviderUnit(from) && isProviderUnit(to)) {
if (!isDeclaredProviderDependency(from, to, target))
cross.set(key, (cross.get(key) ?? 0) + 1);
} else if (requiresEntry(from, to) && !isEntryFile(to, target))
entry.set(key, (entry.get(key) ?? 0) + 1);
}
return {
crossProvider: sortedCounts(cross),
entry: sortedCounts(entry),
};
};
/** Counted pair maps a baseline ratchets, with the wording of each finding. */
const COUNTED = Object.freeze([
["upward", "upward import"],
["crossProvider", "cross-provider import"],
["entry", "import past the entry file"],
]);
/**
* Compare facts with the recorded baseline. Growth fails: a new counted pair
* (upward, cross-provider, or past a provider entry), more imports on a
* recorded pair, or a cycle group not recorded. Shrinkage is returned
* separately: the caller fails on it too, so the baseline is lowered in the
* change that removes the imports and can never grow back silently.
*/
export const compareLayerBaseline = (facts, baseline) => {
const failures = [];
@@ -180,17 +492,19 @@ export const compareLayerBaseline = (facts, baseline) => {
failures.push(
`undeclared unit src/${unit}: add it to UNIT_LAYERS in scripts/lib/module-layers.mjs`,
);
for (const [key, count] of Object.entries(facts.upward)) {
const allowed = baseline.upward[key] ?? 0;
if (count > allowed)
failures.push(
`upward import ${key}: ${count} imports, baseline ${allowed}`,
);
}
for (const [key, allowed] of Object.entries(baseline.upward)) {
const count = facts.upward[key] ?? 0;
if (count < allowed)
lowerable.push(`upward import ${key}: ${count}, baseline ${allowed}`);
for (const [kind, label] of COUNTED) {
const observed = facts[kind] ?? {};
const recorded = baseline[kind] ?? {};
for (const [key, count] of Object.entries(observed)) {
const allowed = recorded[key] ?? 0;
if (count > allowed)
failures.push(`${label} ${key}: ${count} imports, baseline ${allowed}`);
}
for (const [key, allowed] of Object.entries(recorded)) {
const count = observed[key] ?? 0;
if (count < allowed)
lowerable.push(`${label} ${key}: ${count}, baseline ${allowed}`);
}
}
const recordedCycles = new Set(baseline.cycles);
for (const group of facts.cycles)
@@ -202,3 +516,24 @@ export const compareLayerBaseline = (facts, baseline) => {
lowerable.push(`recorded mutual import no longer present: ${group}`);
return { failures, lowerable };
};
const lowerCounts = (observed = {}, recorded = {}) =>
Object.fromEntries(
Object.entries(recorded).flatMap(([key, allowed]) => {
const count = Math.min(allowed, observed[key] ?? 0);
return count > 0 ? [[key, count]] : [];
}),
);
/**
* The baseline lowered to the observed facts: each recorded counted pair
* keeps the smaller of its recorded and observed counts, and only recorded
* cycles that are still present remain. Nothing is added, so growth still
* fails.
*/
export const lowerLayerBaseline = (facts, baseline) => ({
upward: lowerCounts(facts.upward, baseline.upward),
cycles: baseline.cycles.filter((group) => facts.cycles.includes(group)),
crossProvider: lowerCounts(facts.crossProvider, baseline.crossProvider),
entry: lowerCounts(facts.entry, baseline.entry),
});
+2 -2
View File
@@ -7,8 +7,8 @@ import { Client } from "@modelcontextprotocol/client";
import { createOwnedMcpStdioTransport } from "./owned-mcp-stdio.mjs";
import { createVerifierCommands } from "./verify-commands.mjs";
import { ArtifactResourceScope } from "../../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/resources/AnalysisCleanupLease.js";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
import { parseEvidence } from "../../dist/domain/evidence.js";
+2 -2
View File
@@ -6,7 +6,7 @@ export const SOURCE_TEST_PROJECTS = [
name: "domain",
group: "source",
isolate: false,
include: ["src/{contracts,domain}/**/*.test.ts"],
include: ["src/{contracts,domain,ports}/**/*.test.ts"],
},
{
name: "services",
@@ -19,7 +19,7 @@ export const SOURCE_TEST_PROJECTS = [
group: "source",
include: [
"src/*.test.ts",
"src/{android,apkSignature,apktool,jeb,adb,artifacts,browser,config,cutter,desktop,dotnet,electron,erlang,evm,firmware,flutter,frida,pcap,ghidra,go,gpu,hopper,ida,inspector,javascript,kuna,main,native,process,providers,python,reference,rust,server,sqlite,v8,wasm,windows}/**/*.test.ts",
"src/{android,apkSignature,apktool,jeb,adb,artifacts,browser,config,cutter,desktop,dotnet,electron,erlang,evm,firmware,flutter,frida,pcap,ghidra,go,gpu,hopper,hopperPaths,ida,inspector,javascript,kuna,main,native,process,providers,python,reference,resources,rust,server,sqlite,v8,wasm,windows}/**/*.test.ts",
],
},
{
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ArtifactResourceScope } from "../../src/artifacts/ArtifactResourceScope.js";
import type { ArtifactResourceScope } from "../../src/resources/ArtifactResourceScope.js";
export class VerifierArtifactCleanupFailure extends AggregateError {
readonly _tag: "VerifierArtifactCleanupFailure";
+1 -1
View File
@@ -1,4 +1,4 @@
import { ArtifactResourceScope } from "../../dist/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../../dist/resources/ArtifactResourceScope.js";
/** A failed close retains the scope that can retry all of its owners. */
export class VerifierArtifactCleanupFailure extends AggregateError {
+3 -3
View File
@@ -1,8 +1,8 @@
import { randomUUID } from "node:crypto";
import type { RetainedResourceScope } from "../../src/application/AnalysisProvider.js";
import { AnalysisCleanupLease } from "../../src/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../src/artifacts/ArtifactResourceScope.js";
import type { RetainedResourceScope } from "../../src/ports/AnalysisProvider.js";
import { AnalysisCleanupLease } from "../../src/resources/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../src/resources/ArtifactResourceScope.js";
import {
prepareOwnedCommand,
runOwnedCommand,
+2 -2
View File
@@ -1,5 +1,5 @@
import type { ArtifactResourceScope } from "../../src/artifacts/ArtifactResourceScope.js";
import type { RetainedResourceScope } from "../../src/application/AnalysisProvider.js";
import type { ArtifactResourceScope } from "../../src/resources/ArtifactResourceScope.js";
import type { RetainedResourceScope } from "../../src/ports/AnalysisProvider.js";
/** Complete a prerequisite operation, including retained cleanup on failure. */
export function withVerifierResourceOwner<T>(
+2 -2
View File
@@ -1,6 +1,6 @@
import { hashStableFile } from "../../dist/filesystem/StableFileHash.js";
import { ArtifactResourceScope } from "../../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../../dist/resources/AnalysisCleanupLease.js";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
/** Finish a prerequisite probe and release its exact retained cleanup owners. */
+1 -1
View File
@@ -1,6 +1,6 @@
import { lstat, open } from "node:fs/promises";
import { ArtifactResourceScope } from "../../src/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../../src/resources/ArtifactResourceScope.js";
import { OwnedFileHandle } from "../../src/filesystem/OwnedFileHandle.js";
import type { VerifierCommands } from "./verifier-command-owner.mjs";
import { withVerifierCleanup } from "./verifier-cleanup.mjs";
+3 -3
View File
@@ -1,9 +1,9 @@
import { randomUUID } from "node:crypto";
import type { IDisposable, IPty } from "@lydell/node-pty";
import type { RetainedResourceScope } from "../../src/application/AnalysisProvider.js";
import { AnalysisCleanupLease } from "../../src/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../src/artifacts/ArtifactResourceScope.js";
import type { RetainedResourceScope } from "../../src/ports/AnalysisProvider.js";
import { AnalysisCleanupLease } from "../../src/resources/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../../src/resources/ArtifactResourceScope.js";
import { err, ok, type Result } from "../../src/domain/result.js";
import {
cleanupOwnedProcessGroup,
@@ -20,7 +20,6 @@
"src/application/process/ProcessCli.ts": 1,
"src/artifacts/ArtifactOperationFailure.ts": 1,
"src/artifacts/ReleaseExposureReader.ts": 1,
"src/artifacts/StableArtifactFailure.ts": 2,
"src/browser/BrowserScenarioPartialObservation.ts": 1,
"src/browser/CdpBrowserProvider.ts": 1,
"src/browser/CdpElectronProvider.ts": 1,
@@ -61,6 +60,7 @@
"src/providers/AnalysisClientFailure.ts": 1,
"src/providers/OwnedCommandCleanup.ts": 2,
"src/providers/runOwned.ts": 1,
"src/resources/StableArtifactFailure.ts": 2,
"src/rust/RustBinaryProvider.ts": 1
}
}
+2 -2
View File
@@ -3,8 +3,8 @@ import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { chromium } from "playwright-core";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/resources/AnalysisCleanupLease.js";
import { newPlaywrightCdpSession } from "../dist/browser/PlaywrightCdpSession.js";
import { startBrowserVerifierSite } from "./fixtures/browser-verifier-site.mjs";
import { verifyBrowserDomDestinations } from "./lib/browser-dom-destinations-e2e.mjs";
+1 -1
View File
@@ -6,7 +6,7 @@ import { promisify } from "node:util";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { toolContract } from "../dist/contracts/toolContracts.js";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import { requireMcpOutput } from "./lib/mcp-verifier-results.mjs";
import { closeVerifierResources } from "./lib/verifier-cleanup.mjs";
import { hashVerifierFile } from "./lib/verifier-file-resources.mjs";
+1 -1
View File
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
import { Client } from "@modelcontextprotocol/client";
import { parseEvidence } from "../dist/domain/evidence.js";
import { goBinarySchema } from "../dist/domain/go/goBinary.js";
import { AnalysisCleanupLease } from "../dist/artifacts/AnalysisCleanupLease.js";
import { AnalysisCleanupLease } from "../dist/resources/AnalysisCleanupLease.js";
import { artifactMcpCall } from "./lib/artifact-e2e.mjs";
import { requireMcpOutput } from "./lib/mcp-verifier-results.mjs";
import { createVerifierRun, completeVerifierRun } from "./lib/verifier-run.mjs";
+1 -1
View File
@@ -7,7 +7,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { absoluteCallerPath } from "../dist/filesystem/callerPath.js";
import { toolContract } from "../dist/contracts/toolContracts.js";
import { il2cppMetadataViewRequestSchema } from "../dist/domain/analysisView/il2cppMetadataView.js";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import {
requireMcpOutput,
requireMcpToolError,
+46 -7
View File
@@ -1,5 +1,5 @@
import { execFile } from "node:child_process";
import { readdir, readFile } from "node:fs/promises";
import { readdir, readFile, writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { promisify } from "node:util";
@@ -7,14 +7,23 @@ import {
inspectResolvedModuleBoundaries,
resolveModuleImports,
} from "./lib/module-boundaries.mjs";
import { compareLayerBaseline, layerGraphFacts } from "./lib/module-layers.mjs";
import {
compareLayerBaseline,
layerGraphFacts,
lowerLayerBaseline,
} from "./lib/module-layers.mjs";
const execute = promisify(execFile);
const root = process.cwd();
const printLayerBaseline = process.argv.includes("--print-layer-baseline");
const shrinkLayerBaseline = process.argv.includes("--shrink-layer-baseline");
const selected = process.argv
.slice(2)
.filter((argument) => argument !== "--print-layer-baseline");
.filter(
(argument) =>
argument !== "--print-layer-baseline" &&
argument !== "--shrink-layer-baseline",
);
for (const file of selected)
if (!file.endsWith(".ts"))
throw new TypeError(`Expected an exact TypeScript source file: ${file}`);
@@ -60,6 +69,9 @@ const files = await enumerateSourceFiles();
let checked = 0;
const resolvedImports = [];
const checkedFiles = [];
// A file that could not be parsed contributes no imports, so the graph built
// without it undercounts; it must never lower the recorded baseline.
const uninspected = [];
for (const file of new Set(files.filter((path) => path.endsWith(".ts")))) {
let source;
try {
@@ -85,6 +97,7 @@ for (const file of new Set(files.filter((path) => path.endsWith(".ts")))) {
}
} catch (cause) {
console.error(`Could not inspect ${file}: ${cause.message}`);
uninspected.push(file);
process.exitCode = 1;
}
}
@@ -96,7 +109,16 @@ if (selected.length === 0) {
const facts = layerGraphFacts(resolvedImports, checkedFiles);
if (printLayerBaseline) {
console.log(
JSON.stringify({ upward: facts.upward, cycles: facts.cycles }, null, 2),
JSON.stringify(
{
upward: facts.upward,
cycles: facts.cycles,
crossProvider: facts.crossProvider,
entry: facts.entry,
},
null,
2,
),
);
}
const { failures, lowerable } = compareLayerBaseline(facts, baseline);
@@ -104,10 +126,27 @@ if (selected.length === 0) {
console.error(`module layers: ${failure}`);
process.exitCode = 1;
}
if (lowerable.length > 0)
console.log(
`Module layer baseline can be lowered in scripts/lib/module-layers.baseline.json:\n ${lowerable.join("\n ")}`,
if (
lowerable.length > 0 &&
shrinkLayerBaseline &&
failures.length === 0 &&
uninspected.length === 0
) {
await writeFile(
baselinePath,
`${JSON.stringify(lowerLayerBaseline(facts, baseline), null, 2)}\n`,
);
console.log(
`Lowered scripts/lib/module-layers.baseline.json:\n ${lowerable.join("\n ")}`,
);
} else if (lowerable.length > 0) {
console.error(
uninspected.length > 0
? `module layers: not lowering the baseline while ${uninspected.length} source file(s) could not be inspected`
: `module layers: the baseline records imports that are gone; lower it with \`node scripts/verify-module-boundaries.mjs --shrink-layer-baseline\`:\n ${lowerable.join("\n ")}`,
);
process.exitCode = 1;
}
}
if (process.exitCode !== 1)
console.log(`Checked resolved module boundaries in ${checked} source files.`);
+1 -1
View File
@@ -6,7 +6,7 @@ import { promisify } from "node:util";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { toolContract } from "../dist/contracts/toolContracts.js";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import { requireMcpOutput } from "./lib/mcp-verifier-results.mjs";
import { hashVerifierFile } from "./lib/verifier-file-resources.mjs";
import {
+11 -1
View File
@@ -35,9 +35,19 @@ const { StdioClientTransport } = await import(
const { parseConfig } = await import(
pathToFileURL(join(root, "dist/config/parseConfig.js"))
);
const { selectedHopperLauncherPath } = await import(
pathToFileURL(join(root, "dist/hopperPaths/HopperLauncherDiscovery.js")).href
);
const config = parseConfig(process.env);
if (!config.ok) throw config.error;
await access(config.value.hopperLauncherPath, constants.X_OK);
await access(
selectedHopperLauncherPath(
config.value.hopperLauncherPath,
process.platform,
process.env,
),
constants.X_OK,
);
const run = promisify(execFile);
const clang = (await run("xcrun", ["--find", "clang"])).stdout.trim();
const sdk = (
+2 -2
View File
@@ -9,8 +9,8 @@ import {
withVerifierFixture,
} from "./lib/verifier-fixture.mjs";
import { parseBinaryTarget } from "../dist/application/BinaryTargetResolver.js";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/resources/AnalysisCleanupLease.js";
import { resolveHopperAnalysisProfile } from "../dist/hopper/HopperAnalysisProfile.js";
import { HopperApplicationLauncher } from "../dist/hopper/BridgeLauncher.js";
import { HopperClient } from "../dist/hopper/HopperClient.js";
+8 -2
View File
@@ -19,6 +19,7 @@ import { snapshotHopperRuntime } from "./lib/real-hopper-cleanup.mjs";
import { closeVerifierResources } from "./lib/verifier-cleanup.mjs";
import { HOPPER_TARGET_LEASE_DIRECTORY } from "../dist/process/HopperLease.js";
import { parseConfig } from "../dist/config/parseConfig.js";
import { selectedHopperLauncherPath } from "../dist/hopperPaths/HopperLauncherDiscovery.js";
import {
verifyHopperSourceBinding,
relocateSingleFatSlice,
@@ -37,9 +38,14 @@ if (process.platform !== "darwin" || !["arm64", "x64"].includes(process.arch))
);
const config = parseConfig(process.env);
if (!config.ok) throw config.error;
await access(config.value.hopperLauncherPath, constants.X_OK).catch((cause) => {
const hopperLauncherPath = selectedHopperLauncherPath(
config.value.hopperLauncherPath,
process.platform,
process.env,
);
await access(hopperLauncherPath, constants.X_OK).catch((cause) => {
throw new Error(
`Hopper FAT verification requires the configured executable: ${config.value.hopperLauncherPath}`,
`Hopper FAT verification requires the configured executable: ${hopperLauncherPath}`,
{ cause },
);
});
+2 -2
View File
@@ -22,8 +22,8 @@ import {
KUNA_UNVERIFIED_VERSION_REMEDIATION,
KUNA_VERIFIED_VERSION,
} from "../dist/kuna/KunaRelease.js";
import { ArtifactResourceScope } from "../dist/artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/artifacts/AnalysisCleanupLease.js";
import { ArtifactResourceScope } from "../dist/resources/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../dist/resources/AnalysisCleanupLease.js";
import {
KUNA_XREF_MISSING_NAME_REMEDIATION,
missingKunaXrefNameMessage,
+1 -1
View File
@@ -47,7 +47,7 @@ const { PrivateRuntimeRoot } = await import(
);
const { PrivateRuntimeRootUnavailableError } = await import(
pathToFileURL(
join(packageRoot, "dist/process/PrivateRuntimeRootUnavailableError.js"),
join(packageRoot, "dist/domain/privateRuntimeRootUnavailableError.js"),
)
);
// Windows children write beneath the root; a private root's DELETE handle would block them.
+1 -1
View File
@@ -9,7 +9,7 @@ import { delimiter, dirname, isAbsolute, join } from "node:path";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { TOOL_CONTRACTS } from "../../../dist/contracts/toolContracts.js";
import { analysisErrorProjectionSchema } from "../../../dist/contracts/errorSchemas.js";
import { analysisErrorProjectionSchema } from "../../../dist/domain/analysisErrorProjectionSchema.js";
import {
VerifierFixture,
withVerifierFixture,
+1 -1
View File
@@ -14,7 +14,7 @@ import {
withArtifactMcp,
} from "../../lib/artifact-e2e.mjs";
import { nativeDispatchMetadataResultSchema } from "../../../dist/domain/native/objcSwiftMetadata.js";
import { analysisErrorProjectionSchema } from "../../../dist/contracts/errorSchemas.js";
import { analysisErrorProjectionSchema } from "../../../dist/domain/analysisErrorProjectionSchema.js";
import { cliOperationFailurePayload } from "../../../dist/cliLogging.js";
import { requireMcpToolError } from "../../lib/mcp-verifier-results.mjs";
import {
+1 -1
View File
@@ -73,7 +73,7 @@ check(
// Prerequisite inspection lifetime is an application contract shared by adapters.
check(
"provider-owned inspection lifetime (use src/application/ProviderInspectionScope)",
"provider-owned inspection lifetime (use src/ports/ProviderInspectionScope)",
files,
/providers\/ProviderInspectionScope\.js/,
);
@@ -18,11 +18,9 @@
"src/composition/auxiliaryAnalysisProviders.ts": 1,
"src/composition/binary.ts": 2,
"src/composition/reverseEngineering.ts": 1,
"src/config/parseConfig.ts": 2,
"src/cutter/CutterBridgeClient.ts": 1,
"src/desktop/BuildComputerEnvironment.ts": 3,
"src/desktop/BuildSecretFiles.ts": 1,
"src/domain/localPath.ts": 1,
"src/electron/ElectronFusePath.ts": 1,
"src/evm/EvmoleInterfaceProvider.ts": 2,
"src/filesystem/ChangeTimeBaseline.ts": 2,
+1 -1
View File
@@ -8,7 +8,7 @@ import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { firmwareResultSchemas } from "../../../dist/domain/firmware/firmwareAnalysis.js";
import { parseEvidence } from "../../../dist/domain/evidence.js";
import { ArtifactResourceScope } from "../../../dist/artifacts/ArtifactResourceScope.js";
import { ArtifactResourceScope } from "../../../dist/resources/ArtifactResourceScope.js";
import { hashVerifierFile } from "../../lib/verifier-file-resources.mjs";
import {
VerifierFixture,
@@ -3,13 +3,13 @@
import { realpath } from "node:fs/promises";
import { parseArgs } from "node:util";
import { readStableArtifact } from "../../../dist/artifacts/readStableArtifact.js";
import { ArtifactReaderFailure } from "../../../dist/artifacts/ArtifactReader.js";
import { readStableArtifact } from "../../../dist/resources/readStableArtifact.js";
import { ArtifactReaderFailure } from "../../../dist/resources/ArtifactReader.js";
import {
ArtifactFileCleanupFailure,
artifactFileCompletion,
artifactFilePrimaryFacts,
} from "../../../dist/artifacts/ArtifactFileOperation.js";
} from "../../../dist/resources/ArtifactFileOperation.js";
import { reconcileJavaScriptRuntimeEvidence } from "../../../dist/application/javascript/JavaScriptRuntimeReconciliationService.js";
import { analyzeJavaScriptApplicationWithOwnedScope } from "../../lib/javascript-application-analysis.mjs";
+1 -1
View File
@@ -16,7 +16,7 @@ import {
execFileOutputFailure,
spawnCapacityExhausted,
} from "../process/ExecFileOutput.js";
import type { ProviderAvailability } from "../application/AnalysisProvider.js";
import type { ProviderAvailability } from "../ports/AnalysisProvider.js";
import type { ProviderRejectionCode } from "../domain/providerSelection.js";
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
import type { JsonValue } from "../domain/jsonValue.js";
+1 -1
View File
@@ -1,7 +1,7 @@
import {
createAnalysisExecution,
type AnalysisExecution,
} from "../application/AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { AnalysisProtocolError } from "../domain/analysisErrorCore.js";
import { err, ok, type Result } from "../domain/result.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
+1 -1
View File
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
import { open, stat } from "node:fs/promises";
import { basename, join } from "node:path";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { ArtifactResourceScope } from "../resources/index.js";
import {
AnalysisArtifactChangedError,
AnalysisOutputError,
+1 -1
View File
@@ -1,4 +1,4 @@
import { createAnalysisExecution } from "../application/AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import type { AdbUnparsedLines } from "./AdbUnparsedLines.js";
import type {
AdbBinarySelection,
+4 -6
View File
@@ -33,7 +33,7 @@ import {
type ProviderAvailability,
createAnalysisExecution,
type AnalysisExecution,
} from "../application/AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { providerConfigurationRefusal } from "../domain/providerConfigurationRefusal.js";
import type {
AdbDisplayNumericIssues,
@@ -43,15 +43,13 @@ import type {
AdbPackagePullPartialObservation,
AdbRequest,
} from "../domain/adb/adbDeviceAnalysis.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import {
ArtifactReaderFailure,
ArtifactResourceRetryFailure,
ArtifactResourceScope,
} from "../artifacts/ArtifactResourceScope.js";
import {
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
} from "../artifacts/AnalysisCleanupLease.js";
} from "../resources/index.js";
import {
adbDisplayPartialObservationSchema,
adbResultSchemas,
@@ -99,7 +97,7 @@ import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import {
RuntimeControlUnavailableError,
runtimeControlCapabilityError,
} from "../process/RuntimeControlUnavailableError.js";
} from "../domain/runtimeControlUnavailableError.js";
import {
adbCommandOutputFailure,
adbArguments,
+5 -3
View File
@@ -1,8 +1,10 @@
import { createHash } from "node:crypto";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import {
ArtifactReaderFailure,
type ArtifactResourceScope,
} from "../resources/index.js";
import { ZipArtifactReader } from "../artifacts/ZipArtifactReader.js";
import { streamChunkToBuffer } from "../artifacts/StreamBytes.js";
import { streamChunkToBuffer } from "../resources/index.js";
import type {
AndroidJniLibraryObservation,
AndroidJniReport,
+4 -6
View File
@@ -2,14 +2,12 @@ import {
artifactFileCancellationCause,
artifactFilePrimaryFacts,
bindArtifactFileCleanup,
} from "../artifacts/ArtifactFileOperation.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import {
ArtifactReaderFailure,
stableArtifactInputRecovery,
readerIntegrityFailure,
} from "../artifacts/StableArtifactFailure.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { readStableArtifact } from "../artifacts/readStableArtifact.js";
type ArtifactResourceScope,
readStableArtifact,
} from "../resources/index.js";
import {
ANDROID_MAPPING_LIMITS,
type AndroidMappingSource,
+5 -5
View File
@@ -36,21 +36,21 @@ import {
import type { AndroidOperation } from "../domain/android/androidAnalysis.js";
import type { JsonValue } from "../domain/jsonValue.js";
import { err, ok, type Result } from "../domain/result.js";
import type { ProviderAvailability } from "../application/AnalysisProvider.js";
import { ownedProcessPrerequisiteAvailability } from "../application/ownedProcessAvailability.js";
import type { ProviderAvailability } from "../ports/AnalysisProvider.js";
import { ownedProcessPrerequisiteAvailability } from "../providers/ownedProcessAvailability.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import {
ArtifactReaderFailure,
ArtifactFileCancelled,
ArtifactFileCleanupFailure,
bindArtifactFileCleanup,
withArtifactRegularFile,
} from "../artifacts/ArtifactFileOperation.js";
} from "../resources/index.js";
import { analysisClientFailureForOperation } from "../providers/AnalysisClientFailure.js";
import { ZipArtifactReader } from "../artifacts/ZipArtifactReader.js";
import type { DoctorProviderCheck } from "../application/Doctor.js";
import type { DoctorProviderCheck } from "../ports/DoctorProviderInspection.js";
import {
JADX_JAR_CONFIGURATION_REMEDIATION,
JADX_JAVA_PROBE_REMEDIATION,
+2 -2
View File
@@ -2,11 +2,11 @@ import type { HostPlatform } from "../platform/HostPlatform.js";
import type {
RetainedResourceScope,
ProviderAvailability,
} from "../application/AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import type {
DoctorProviderCheck,
DoctorProviderInspection,
} from "../application/Doctor.js";
} from "../ports/DoctorProviderInspection.js";
import type { JsonValue } from "../domain/jsonValue.js";
import {
inspectJadxAvailability,
+1 -1
View File
@@ -1,6 +1,6 @@
import { validateJadxConfiguration } from "./JadxConfiguration.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { ArtifactResourceRetryFailure } from "../artifacts/ArtifactResourceScope.js";
import { ArtifactResourceRetryFailure } from "../resources/ArtifactResourceScope.js";
import { expect, it, vi } from "vitest";
import { inspectJadxJava, type JadxJavaProbeOptions } from "./JadxJavaProbe.js";
import {
+1 -1
View File
@@ -2,7 +2,7 @@ import { capturedProviderOutput } from "../process/capturedProviderOutput.js";
import type { ProcessInspectionFailure } from "../process/ProcessInspectionCleanup.js";
import { classifyLaunchFailureCode } from "../process/launchFailure.js";
import { randomUUID } from "node:crypto";
import type { RetainedResourceScope } from "../application/AnalysisProvider.js";
import type { RetainedResourceScope } from "../ports/AnalysisProvider.js";
import {
AnalysisError,
type AnalysisCapturedOutput,
+6 -4
View File
@@ -1,18 +1,20 @@
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
import { HOST_PLATFORM, type HostPlatform } from "../platform/HostPlatform.js";
import type { AnalysisSettingsReader } from "../domain/analysisSettings.js";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import {
ArtifactResourceScope,
AnalysisCleanupLease,
} from "../resources/index.js";
import type {
RetainedResourceScope,
ExecutionOptions,
} from "../application/AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { analysisClientFailureForOperation } from "../providers/AnalysisClientFailure.js";
import { throwIfJadxInterrupted } from "./JadxInterruption.js";
import { chmod, copyFile } from "node:fs/promises";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import type { AndroidAnalysisPort } from "../application/android/AndroidAnalysisPort.js";
import type { AndroidAnalysisPort } from "../ports/android/AndroidAnalysisPort.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import { AnalysisCleanupRelease } from "../domain/analysisCleanupRelease.js";
import {
+3 -3
View File
@@ -1,7 +1,7 @@
import { throwIfJadxInterrupted } from "./JadxInterruption.js";
import { OwnedMcpClient } from "../process/OwnedMcpClient.js";
import { createAnalysisExecution } from "../application/AnalysisProvider.js";
import type { AndroidAnalysisExecution } from "../application/android/AndroidAnalysisPort.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import type { AndroidAnalysisExecution } from "../ports/android/AndroidAnalysisPort.js";
import type { AndroidRequest } from "../domain/android/androidAnalysis.js";
import {
type AndroidMappingSource,
@@ -33,7 +33,7 @@ import {
readAndroidJniLibraries,
type AndroidJniLibraries,
} from "./AndroidJniLibraries.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { ArtifactResourceScope } from "../resources/index.js";
import { jadxOperationTimeoutGuidance } from "./JadxOperationTimeout.js";
import { JadxMcpTransport, type JadxLauncher } from "./JadxMcpTransport.js";
import {
@@ -20,7 +20,7 @@ import {
withSigningBlock,
zipWith,
} from "../../tests/fixtures/apkSignature/v1SignatureBlock.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import { ArtifactReaderFailure } from "../resources/ArtifactReader.js";
import { apkSignatureResultSchema } from "../domain/apkSignature/apkSignatureReport.js";
import { ApkSignatureProvider } from "./ApkSignatureProvider.js";
import { apkSignatureFailure } from "./apkSignatureFailures.js";
+7 -7
View File
@@ -1,19 +1,19 @@
import { createHash } from "node:crypto";
import { apkSignatureAdmission } from "./ApkSignatureAdmission.js";
import { createAnalysisExecution } from "../application/AnalysisProvider.js";
import type { ExecutionOptions } from "../application/AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import type { ExecutionOptions } from "../ports/AnalysisProvider.js";
import type {
ApkSignatureExecution,
ApkSignaturePort,
} from "../application/apkSignature/ApkSignaturePort.js";
import { readStableArtifact } from "../artifacts/readStableArtifact.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
} from "../ports/apkSignature/ApkSignaturePort.js";
import {
readStableArtifact,
ArtifactReaderFailure,
assertArtifactReadActive,
bindArtifactFileCleanup,
} from "../artifacts/ArtifactFileOperation.js";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
ArtifactResourceScope,
} from "../resources/index.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import {
+3 -5
View File
@@ -1,17 +1,15 @@
import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import {
ArtifactReaderFailure,
stableArtifactInputFailure,
readerIntegrityFailure,
} from "../artifacts/StableArtifactFailure.js";
import {
artifactFilePrimaryFacts,
type ArtifactFilePrimaryFacts,
artifactFileCancellationCause,
bindArtifactFileCleanup,
} from "../artifacts/ArtifactFileOperation.js";
completedStableArtifactObservation,
} from "../resources/index.js";
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
import { completedStableArtifactObservation } from "../artifacts/StableArtifactObservation.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import {
+2 -4
View File
@@ -5,12 +5,10 @@ import {
import {
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
} from "../artifacts/AnalysisCleanupLease.js";
import {
ArtifactResourceRetryFailure,
ArtifactResourceScope,
} from "../artifacts/ArtifactResourceScope.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
ArtifactReaderFailure,
} from "../resources/index.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
+1 -1
View File
@@ -28,7 +28,7 @@ import {
runOwnedCommand,
prepareOwnedCommand,
} from "../process/OwnedCommand.js";
import type { ProviderAvailability } from "../application/AnalysisProvider.js";
import type { ProviderAvailability } from "../ports/AnalysisProvider.js";
import type { ProviderRejectionCode } from "../domain/providerSelection.js";
import type { JsonValue } from "../domain/jsonValue.js";
import { parse } from "semver";
+5 -5
View File
@@ -1,10 +1,10 @@
import { ok, err, type Result } from "../domain/result.js";
import type {
ArtifactEntry,
ArtifactTraversalOmission,
} from "../artifacts/ArtifactReader.js";
import {
type ArtifactEntry,
type ArtifactTraversalOmission,
assertArtifactReadActive,
} from "../resources/index.js";
import { DirectoryArtifactTraversalLimit } from "../artifacts/DirectoryArtifactReader.js";
import { assertArtifactReadActive } from "../artifacts/ArtifactFileOperation.js";
import { classifyAndroidStringsTable } from "../domain/apktool/apktoolResourceAnalysis.js";
import type { ApktoolWorkspace } from "./ApktoolWorkspace.js";
+5 -7
View File
@@ -5,17 +5,15 @@ import { processInspectionCancellationError } from "../providers/OwnedCommandCle
import { APKTOOL_PROVIDER_IDENTITY } from "./ApktoolProviderIdentity.js";
import { countDecodedFiles } from "./ApktoolDecodedInventory.js";
import { ApktoolWorkspace } from "./ApktoolWorkspace.js";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import {
ArtifactResourceScope,
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
} from "../artifacts/AnalysisCleanupLease.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import {
ArtifactReaderFailure,
ArtifactFileCleanupFailure,
artifactFilePrimaryFacts,
artifactFileCancellationCause,
} from "../artifacts/ArtifactFileOperation.js";
} from "../resources/index.js";
import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
import { capturedApktoolFailureOutput } from "./ApktoolCommandOutput.js";
import { providerOutcomeOf } from "../process/ProviderOutcome.js";
@@ -35,7 +33,7 @@ import {
type ProviderAvailability,
createAnalysisExecution,
type AnalysisExecution,
} from "../application/AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { providerConfigurationRefusal } from "../domain/providerConfigurationRefusal.js";
import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.js";
import {
@@ -67,7 +65,7 @@ import {
import type { RuntimeExhaustionArea } from "../process/RuntimeExhaustion.js";
import { snapshotEnvironment } from "../process/snapshotEnvironment.js";
import { WindowsBatchCommandError } from "../process/WindowsBatchCommand.js";
import { ownedProcessPrerequisiteAvailability } from "../application/ownedProcessAvailability.js";
import { ownedProcessPrerequisiteAvailability } from "../providers/ownedProcessAvailability.js";
import {
ApktoolConfigurationFailure,
apktoolConfigurationAvailability,
@@ -8,8 +8,8 @@ import {
artifactFilePrimaryFacts,
ArtifactFileCleanupFailure,
ArtifactFileCancelled,
} from "../artifacts/ArtifactFileOperation.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
} from "../resources/ArtifactFileOperation.js";
import { ArtifactReaderFailure } from "../resources/ArtifactReader.js";
import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
import { ApktoolCommandCleanup } from "./ApktoolCommandCleanup.js";
import { ApktoolWorkspace } from "./ApktoolWorkspace.js";
+7 -9
View File
@@ -1,20 +1,18 @@
import { readArtifactFileChunks } from "../artifacts/readArtifactFileChunks.js";
import { readArtifactFileChunks } from "../resources/index.js";
import {
ArtifactReaderFailure,
type ArtifactTraversalOptions,
} from "../artifacts/ArtifactReader.js";
import { createHash } from "node:crypto";
import { chmod, open } from "node:fs/promises";
import { join } from "node:path";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { DirectoryArtifactReader } from "../artifacts/DirectoryArtifactReader.js";
import {
ArtifactResourceScope,
assertArtifactReadActive,
artifactSelectedPathErrno,
mapArtifactFileFailure,
withArtifactFileHandle,
withArtifactRegularFile,
} from "../artifacts/ArtifactFileOperation.js";
} from "../resources/index.js";
import { createHash } from "node:crypto";
import { chmod, open } from "node:fs/promises";
import { join } from "node:path";
import { DirectoryArtifactReader } from "../artifacts/DirectoryArtifactReader.js";
import {
AnalysisInputError,
AnalysisAccessDeniedError,
@@ -10,14 +10,14 @@ import {
createAnalysisExecution,
type AnalysisOperationPort,
type AnalysisExecution,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import {
AnalysisCapabilityUnavailableError,
AnalysisCancelledError,
AnalysisOutputError,
AnalysisProtocolError,
} from "../domain/analysisErrorCore.js";
import { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import { AnalysisCleanupLease } from "../resources/AnalysisCleanupLease.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import {
primaryAnalysisError,
+1 -1
View File
@@ -2,7 +2,7 @@ import type {
AnalysisExecution,
AnalysisOperation,
AnalysisOperationPort,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import {
AnalysisCancelledError,
+1 -1
View File
@@ -3,7 +3,7 @@ import { resolveAnalysisDocument } from "./AnalysisDocument.js";
import {
createAnalysisExecution,
type AnalysisOperationPort,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import {
AnalysisCancelledError,
AnalysisCapabilityUnavailableError,
+1 -1
View File
@@ -2,7 +2,7 @@ import { permitsCapabilityFallback } from "./CapabilityFallback.js";
import type {
AnalysisExecution,
AnalysisOperationPort,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.js";
import {
AnalysisOutputError,
@@ -14,7 +14,7 @@ import { executeFact } from "./AnalysisOperationFacts.js";
import {
createAnalysisExecution,
type AnalysisOperationPort,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
const provider = { id: "fixture", name: "Fixture", version: "1" };
+1 -1
View File
@@ -10,7 +10,7 @@ import type {
AnalysisOperation,
AnalysisOperationPort,
ExecutionOptions,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
/** A completed execution and its result parsed once against its named contract. */
export interface AnalysisFactExecution<Fact> {
+1 -1
View File
@@ -5,7 +5,7 @@ import {
applyWindowsChangeTimeSnapshot,
resolveWindowsChangeTimeSettle,
} from "../config/windowsChangeTimeSettle.js";
import { pwntoolsInputBytes } from "../native/pwntools/PwntoolsInputLimit.js";
import { pwntoolsInputBytes } from "../config/pwntoolsInputLimit.js";
import { resolveCaptureDecoderHeap } from "../config/captureDecoderHeap.js";
import { resolveRegexMatchingDeadline } from "../config/regexMatchingDeadline.js";
import { resolveRegexWorkerHeapRequest } from "../config/regexWorkerHeapRequest.js";
+4 -13
View File
@@ -10,7 +10,10 @@ import { isPathWithinRoot } from "../domain/localPath.js";
import { parseXmlPropertyList } from "../domain/propertyListKeys.js";
import { decodeXmlPlistText } from "../domain/propertyListXmlText.js";
import { hasBinaryPlistSignature } from "../domain/apple/appleArchiveFormat.js";
import type { BundleResourceRoot } from "../domain/apple/bundleResourceRoot.js";
import type {
BundleResourceRoot,
ResolvedAppBundleResourceRoot,
} from "../domain/apple/bundleResourceRoot.js";
import { openableAppleBundleExtension } from "../domain/apple/appleBundleTypes.js";
import { err, ok, type Result } from "../domain/result.js";
import { absoluteCallerPath } from "../filesystem/callerPath.js";
@@ -75,18 +78,6 @@ export interface ResolvedAppBundle {
readonly infoPlist?: string;
}
/** Resource-only identity for an app directory; it is not a BinaryTarget. */
export interface ResolvedAppBundleResourceRoot {
/** Path selected by the caller, retained even when it is a symlink alias. */
readonly callerPath: string;
/** Canonical directory whose resources are inspected. */
readonly canonicalPath: string;
readonly infoPlistPath: string;
readonly layout: BundleResourceRoot["layout"];
/** No executable was opened or hashed by resource-root discovery. */
readonly executableSha256: string | null;
}
/** Filesystem operations used by the resolver, injectable for boundary tests. */
interface AppBundleFileSystem {
readonly readFile: (path: string) => Promise<Buffer>;
@@ -12,7 +12,7 @@ import { join } from "node:path";
import { expect, it } from "vitest";
import { createAnalysisExecution } from "./AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.js";
import {
findAppBundleResourceRoot,
+1 -1
View File
@@ -1,6 +1,6 @@
import { expect, it } from "vitest";
import { EnhancedTools } from "./EnhancedTools.js";
import { createAnalysisExecution } from "./AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import {
AnalysisCancelledError,
AnalysisCapabilityUnavailableError,
+5 -3
View File
@@ -16,9 +16,11 @@ import {
bindRegularFileCleanup,
RetainedRegularFileCleanupFailure,
retryRegularFileCleanup,
} from "./RegularFileRead.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
} from "../process/RegularFileRead.js";
import {
type ArtifactResourceScope,
ArtifactReaderFailure,
} from "../resources/index.js";
import { jsonValueSchema } from "../domain/jsonValue.js";
import { childFailureDiagnostics } from "../domain/analysisErrorProjection.js";
import { constants, type Stats } from "node:fs";
+1 -1
View File
@@ -1,5 +1,5 @@
import { isDeepStrictEqual } from "node:util";
import type { ProviderIdentity } from "./AnalysisProvider.js";
import type { ProviderIdentity } from "../ports/AnalysisProvider.js";
import {
createEvidence,
type Evidence,
@@ -17,7 +17,7 @@ import {
import { ok, err } from "../domain/result.js";
import { BrowserObservationError } from "../domain/browserObservationError.js";
import { parseEvidence } from "../domain/evidence.js";
import type { BrowserObservationPort } from "./BrowserObservationPort.js";
import type { BrowserObservationPort } from "../ports/BrowserObservationPort.js";
import * as service from "./BrowserObservationService.js";
const pageProvider = (
@@ -1,5 +1,5 @@
import { expect, it } from "vitest";
import type { BrowserObservationPort } from "./BrowserObservationPort.js";
import type { BrowserObservationPort } from "../ports/BrowserObservationPort.js";
import {
listBrowserTargets,
inspectWebPage,
+2 -2
View File
@@ -33,8 +33,8 @@ import {
} from "../domain/analysisErrorCore.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import { err, ok, type Result } from "../domain/result.js";
import type { ExecutionOptions } from "./AnalysisProvider.js";
import type { BrowserObservationPort } from "./BrowserObservationPort.js";
import type { ExecutionOptions } from "../ports/AnalysisProvider.js";
import type { BrowserObservationPort } from "../ports/BrowserObservationPort.js";
import { createBrowserEvidence } from "./BrowserEvidence.js";
import { jsonValueSchema } from "../domain/jsonValue.js";
import {
@@ -16,7 +16,7 @@ import type {
} from "../domain/browserScenarioCapture.js";
import { err, ok } from "../domain/result.js";
import { scriptScenarioFixture } from "../../tests/fixtures/webScriptCapture.js";
import type { BrowserScenarioCapturePort } from "./BrowserScenarioCapturePort.js";
import type { BrowserScenarioCapturePort } from "../ports/BrowserScenarioCapturePort.js";
import { captureBrowserScenario } from "./BrowserScenarioCaptureService.js";
import {
expectDroppedPartial,
@@ -1,5 +1,5 @@
import type { ExecutionOptions } from "./AnalysisProvider.js";
import type { BrowserScenarioCapturePort } from "./BrowserScenarioCapturePort.js";
import type { ExecutionOptions } from "../ports/AnalysisProvider.js";
import type { BrowserScenarioCapturePort } from "../ports/BrowserScenarioCapturePort.js";
import { createBrowserScenarioEvidence } from "./BrowserScenarioEvidence.js";
import {
AnalysisCapabilityUnavailableError,
+1 -1
View File
@@ -1,6 +1,6 @@
import { isDeepStrictEqual } from "node:util";
import { digestCanonicalValue } from "../domain/canonicalDigest.js";
import type { ProviderIdentity } from "./AnalysisProvider.js";
import type { ProviderIdentity } from "../ports/AnalysisProvider.js";
import type { BrowserScenario } from "../domain/browserScenario.js";
import type { BrowserScenarioCapture } from "../domain/browserScenarioCapture.js";
import {
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { traceCallPath } from "./CallPathTracing.js";
import { createAnalysisExecution } from "./AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import {
AnalysisCancelledError,
AnalysisOutputError,
+1 -1
View File
@@ -8,7 +8,7 @@ import {
import type {
AnalysisOperation,
ExecutionOptions,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import { isAborted, cancelledBy } from "../domain/analysisErrorCore.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import { AnalysisCleanupLease } from "../resources/AnalysisCleanupLease.js";
import { AnalysisError } from "../domain/analysisErrorBase.js";
import {
AnalysisCancelledError,
@@ -11,7 +11,7 @@ import { err, ok } from "../domain/result.js";
import {
createAnalysisExecution,
type AnalysisOperationPort,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import { EnhancedTools } from "./EnhancedTools.js";
const provider = { id: "fixture", name: "Fixture", version: "1" };
+1 -1
View File
@@ -3,7 +3,7 @@ import type {
AnalysisExecution,
AnalysisOperation,
ExecutionOptions,
} from "./AnalysisProvider.js";
} from "../ports/AnalysisProvider.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import type { AnalysisOutputError } from "../domain/analysisErrorCore.js";
import type { JsonValue } from "../domain/jsonValue.js";
+3 -3
View File
@@ -1,7 +1,7 @@
import type { ProviderAvailability } from "./AnalysisProvider.js";
import type { JebAnalysisAvailability } from "./jeb/JebAnalysisPort.js";
import type { ProviderAvailability } from "../ports/AnalysisProvider.js";
import type { JebAnalysisAvailability } from "../ports/jeb/JebAnalysisPort.js";
import type { AvailabilityPolicy } from "./CapabilityInventory.js";
import type { OptionalProviderLoadFailures } from "./OptionalObservationProviders.js";
import type { OptionalProviderLoadFailures } from "../ports/OptionalObservationProviders.js";
import type { CommandProviderLaunchFailures } from "./reverse/ReverseEngineeringService.js";
export interface CapabilityAvailabilityFacts {
@@ -2,7 +2,7 @@ import { expect, it } from "vitest";
import type { JsonValue } from "../domain/jsonValue.js";
import { AnalysisCapabilityUnavailableError } from "../domain/analysisErrorCore.js";
import { err, ok } from "../domain/result.js";
import { createAnalysisExecution } from "./AnalysisProvider.js";
import { createAnalysisExecution } from "../ports/AnalysisProvider.js";
import { buildCapabilityInventory } from "./CapabilityInventory.js";
import { EnhancedTools } from "./EnhancedTools.js";
+3 -3
View File
@@ -15,7 +15,7 @@ import { sqliteDatabaseCapability } from "./sqlite/SqliteDatabaseCapability.js";
import type {
OptionalProviderLoadFailures,
OptionalProviderLoadFailure,
} from "./OptionalObservationProviders.js";
} from "../ports/OptionalObservationProviders.js";
import type {
CommandProviderLaunchFailures,
ReverseEngineeringOperation,
@@ -48,8 +48,8 @@ import { isMachOFormat } from "../domain/binaryTargetTypes.js";
import type {
AnalysisOperation,
ProviderAvailability,
} from "./AnalysisProvider.js";
import type { JebAnalysisAvailability } from "./jeb/JebAnalysisPort.js";
} from "../ports/AnalysisProvider.js";
import type { JebAnalysisAvailability } from "../ports/jeb/JebAnalysisPort.js";
import { FRIDA_TOOL_CONTRACTS } from "../contracts/fridaToolContracts.js";
import { TOOL_CONTRACTS } from "../contracts/toolContracts.js";
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
@@ -2,15 +2,15 @@ import {
ArtifactResourceRetryFailure,
type ArtifactResourceOwner,
type ArtifactResourceScope,
} from "../artifacts/ArtifactResourceScope.js";
import type { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
type AnalysisCleanupLease,
ArtifactReaderFailure,
} from "../resources/index.js";
import type { AnalysisCleanupObservation } from "../domain/analysisErrorBase.js";
import {
RegularFileCleanupFailure,
type RegularFileOperationOutcome,
} from "../filesystem/OwnedRegularFile.js";
import { retryRegularFileCleanupFailures } from "./RegularFileRead.js";
import { retryRegularFileCleanupFailures } from "../process/RegularFileRead.js";
/** Completion and exact staging owner retained when publication cleanup fails. */
export class ClientConfigurationPublicationFailure<
+2 -2
View File
@@ -1,6 +1,6 @@
import { err, ok, type Result } from "../domain/result.js";
import { RegularFileCleanupFailure } from "../filesystem/OwnedRegularFile.js";
import { readRegularFileText } from "./RegularFileRead.js";
import { readRegularFileText } from "../process/RegularFileRead.js";
import {
effectiveClientServer,
parseClientConfiguration,
@@ -12,7 +12,7 @@ import {
} from "./ClientConfigurationDocument.js";
import type { SetupClient } from "./SupportedClients.js";
import { clientRegistrationEnvironment } from "./ClientRegistrationEnvironment.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { ArtifactResourceScope } from "../resources/index.js";
import type { ConfigurationError } from "../domain/configurationErrors.js";
import { mergeEnvironmentOverrides } from "../process/snapshotEnvironment.js";
import { PRODUCT_IDENTITY } from "../identity.js";
@@ -3,7 +3,7 @@ import { constants, type Stats } from "node:fs";
import { link, lstat, mkdtemp, open, realpath, rename } from "node:fs/promises";
import { basename, dirname, join, resolve, sep } from "node:path";
import { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import { AnalysisCleanupLease } from "../resources/index.js";
import { fileHandleMatchesBytes } from "../filesystem/fileHandleMatchesBytes.js";
import { absoluteCallerPath } from "../filesystem/callerPath.js";
import { OwnedFileHandle } from "../filesystem/OwnedFileHandle.js";
@@ -13,7 +13,7 @@ import {
sameRegularFileState,
} from "../filesystem/RegularFile.js";
import type { RegularFileOperationOutcome } from "../filesystem/OwnedRegularFile.js";
import { readRegularFileTextSnapshot } from "./RegularFileRead.js";
import { readRegularFileTextSnapshot } from "../process/RegularFileRead.js";
import { ClientConfigurationPublicationFailure } from "./ClientConfigurationCleanup.js";
import { resolveClientConfigTransactionPath } from "./ClientConfigPath.js";
import { ConfigurationError } from "../domain/configurationErrors.js";
+2 -2
View File
@@ -5,8 +5,8 @@ import { dirname } from "node:path";
import {
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
} from "../artifacts/AnalysisCleanupLease.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
type ArtifactResourceScope,
} from "../resources/index.js";
import { ConfigurationError } from "../domain/configurationErrors.js";
import { RegularFileChangedError } from "../filesystem/RegularFile.js";
import { OwnedFileHandle } from "../filesystem/OwnedFileHandle.js";
@@ -1,3 +1,7 @@
import type {
OwnedProviderSetting,
RecordedProviderSettings,
} from "../ports/DesktopBuildHost.js";
import { validateRegistrationEnvironment } from "./RegistrationEnvironmentValidation.js";
import {
clientRegistrationSource,
@@ -179,21 +183,6 @@ export const clientRegistrationEnvironmentDetails = (
);
};
/** Setting names a registration does not carry as the value selected here. */
export interface RecordedProviderSettings {
/** Selected here and absent from the registration's recorded environment. */
readonly unrecorded: readonly string[];
/** Recorded with text other than the value selected here. */
readonly differing: readonly string[];
/** Recorded as an expression, or in a map REA could not read. */
readonly unresolved: readonly string[];
/** Recorded with a value the caller owns, as an archive setup packed for another version. */
readonly owned?: readonly string[];
}
/** Whether a recorded value is the caller's own, which it may replace; the value never leaves the reader. */
export type OwnedProviderSetting = (name: string, value: string) => boolean;
/** Consume a resolved setting inside its reader without including its value in diagnostics. */
export type ProviderSettingObserver = (name: string, value: string) => void;
+3 -3
View File
@@ -40,12 +40,12 @@ import {
clientRegistrationEnvironmentDetailsWithBudget,
recordedProviderSettings,
} from "./ClientRegistrationEnvironment.js";
import type { ProviderRequestBudgetResolver } from "./ClientRegistrationEnvironment.js";
import type {
OwnedProviderSetting,
ProviderRequestBudgetResolver,
RecordedProviderSettings,
} from "./ClientRegistrationEnvironment.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
} from "../ports/DesktopBuildHost.js";
import type { ArtifactResourceScope } from "../resources/index.js";
import {
parseClientRegistrationPolicy,
+3 -2
View File
@@ -2,8 +2,9 @@ import { describe, expect, it, vi } from "vitest";
import { SUPPORTED_NODE_VERSION_PROSE } from "../domain/runtimeVersion.js";
import { createDoctorHostFixture } from "./Doctor.fixture.js";
import { runDoctor, type DoctorCheck, type DoctorHost } from "./Doctor.js";
import type { DesktopBuildFacts } from "./DesktopBuildDoctor.js";
import { runDoctor, type DoctorHost } from "./Doctor.js";
import type { DoctorCheck } from "../ports/DoctorProviderInspection.js";
import type { DesktopBuildFacts } from "../ports/DesktopBuildHost.js";
const ready: DesktopBuildFacts = {
ps: { found: true, detail: "/usr/bin/ps" },
+6 -75
View File
@@ -1,8 +1,10 @@
import { DESKTOP_EXPORT_FRAMEWORK_VERSION } from "../domain/desktop/appExport.js";
import type { execFileOutput } from "../process/ExecFileOutput.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { ClientRegistrationStatus } from "./ClientRegistrationStatus.js";
import type { DoctorCheck, DoctorHost, DoctorSkillState } from "./Doctor.js";
import type { DoctorHost, DoctorSkillState } from "./Doctor.js";
import type { DoctorCheck } from "../ports/DoctorProviderInspection.js";
import type {
DesktopBuildCommand,
DesktopBuildFacts,
} from "../ports/DesktopBuildHost.js";
import { nodeCheck } from "./DoctorDiagnostics.js";
import { DESKTOP_BUILD_PROVIDER_ID } from "../domain/doctorProviderIds.js";
import type { DoctorScopeReport } from "./DoctorScope.js";
@@ -13,77 +15,6 @@ export const DESKTOP_BUILD_MIN_FREE_BYTES = 20 * 1000 ** 3;
/** The command that installs the agentenv-framework release bundles target. */
export const AGENTENV_INSTALL_COMMAND = `uv tool install agentenv-framework==${DESKTOP_EXPORT_FRAMEWORK_VERSION}`;
/** How a build setting's program was found: set in the environment, or on PATH. */
export type DesktopBuildCommand =
| {
readonly status: "found";
readonly path: string;
readonly source: "environment" | "path";
}
| { readonly status: "missing" }
| { readonly status: "invalid"; readonly value: string };
/** What a desktop build host has, read without changing anything. */
export interface DesktopBuildFacts {
readonly ps: { readonly found: boolean; readonly detail: string };
readonly docker: DesktopBuildCommand;
readonly daemon:
| { readonly status: "reachable"; readonly rootDirectory: string }
| {
readonly status: "permission_denied" | "unreachable";
readonly detail: string;
}
| { readonly status: "unchecked" };
readonly disk:
| { readonly path: string; readonly freeBytes: number }
| { readonly path: string; readonly error: string };
readonly agentEnv: DesktopBuildCommand & {
readonly version?: string | undefined;
};
readonly archive: {
readonly path: string;
readonly source: "environment" | "cache";
readonly status: "current" | "missing" | "stale" | "unknown";
readonly detail?: string;
};
/** Each considered client's registration, by setting names only. */
readonly registrations: readonly {
readonly client: string;
readonly registered: boolean;
readonly unrecorded: readonly string[];
readonly unresolved: readonly string[];
readonly differing?: readonly string[];
readonly unchecked?: readonly string[];
/** Version check of this client's recorded runner, without the recorded path. */
readonly runner?: {
readonly status: "current" | "stale" | "invalid" | "unknown";
readonly version?: string;
};
}[];
/** Build settings this terminal's environment sets. */
readonly environmentSettings: readonly string[];
/** Where a solve endpoint is configured; null means its configuration is unknown. */
readonly solveEndpoint: string | null | undefined;
/** Names of agentenv sandbox containers; undefined when Docker was not reachable. */
readonly leftoverContainers: readonly string[] | undefined;
}
/** What a facts reader gets from doctor: its environment, bounded runner and registration reader. */
export interface DesktopBuildFactsInput {
readonly signal: AbortSignal;
readonly resources: ArtifactResourceScope;
readonly environment: Readonly<NodeJS.ProcessEnv>;
readonly platform: NodeJS.Platform;
readonly run: typeof execFileOutput;
readonly clientIds: readonly string[];
readonly registrations: (
clientIds: readonly string[] | undefined,
settings: Readonly<Record<string, string>>,
owned?: undefined,
observe?: (client: string, name: string, value: string) => void,
) => Promise<readonly ClientRegistrationStatus[]>;
}
/** What doctor already knows that the build checks reuse. */
export interface DesktopBuildContext {
readonly host: Pick<DoctorHost, "platform" | "architecture" | "runtime">;
+1 -1
View File
@@ -67,7 +67,7 @@ import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
import { profilelessNativeDispatchProfile } from "./binary/ProfilelessNativeWorkflowSnapshot.js";
import { err, ok, type Result } from "../domain/result.js";
import type { AnalysisSnapshot } from "../domain/analysisSnapshot.js";
import type { AnalysisExecution } from "./AnalysisProvider.js";
import type { AnalysisExecution } from "../ports/AnalysisProvider.js";
import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.js";
import { REA_WORKFLOW_PROVIDER } from "../domain/investigationProviders.js";
import { workflowAnalysisProfile } from "./WorkflowAnalysisProfile.js";
+1 -1
View File
@@ -13,7 +13,7 @@ import {
import { jsonValueSchema, type JsonValue } from "../domain/jsonValue.js";
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
import { err, type Result } from "../domain/result.js";
import type { AnalysisExecution } from "./AnalysisProvider.js";
import type { AnalysisExecution } from "../ports/AnalysisProvider.js";
import type { BinarySession } from "./binary/BinarySession.js";
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
import {
+2 -2
View File
@@ -2,14 +2,14 @@ import { mkdir } from "node:fs/promises";
import { join, posix } from "node:path";
import { describe, expect, it } from "vitest";
import { defaultHopperLauncherPath } from "../config/parseConfig.js";
import { defaultHopperLauncherPath } from "../hopperPaths/HopperLauncherDiscovery.js";
import { SUPPORTED_NODE_VERSION_PROSE } from "../domain/runtimeVersion.js";
import type { ClientRegistrationStatus } from "./ClientRegistrationStatus.js";
import { createDoctorHostFixture as host } from "./Doctor.fixture.js";
import { runDoctor, systemDoctorHost, type DoctorHost } from "./Doctor.js";
import { err } from "../domain/result.js";
import { HopperReleaseError } from "./HopperReleaseFeed.js";
import { MAC_HOPPER_SYSTEM_LAUNCHER } from "./MacHopperPaths.js";
import { MAC_HOPPER_SYSTEM_LAUNCHER } from "../hopperPaths/MacHopperPaths.js";
import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";
const configurationHost = (
+20 -58
View File
@@ -9,14 +9,20 @@ import {
} from "../domain/analysisErrorCore.js";
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
import { analysisErrorWithCleanupDependencies } from "../domain/analysisErrorCleanup.js";
import { bindArtifactFileCleanup } from "../artifacts/ArtifactFileOperation.js";
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
import { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
import {
bindArtifactFileCleanup,
ArtifactReaderFailure,
AnalysisCleanupLease,
ArtifactResourceScope,
} from "../resources/index.js";
import { constants } from "node:fs";
import { access, realpath, stat } from "node:fs/promises";
import { posix, win32 } from "node:path";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import type { RetainedResourceScope } from "./AnalysisProvider.js";
import type { RetainedResourceScope } from "../ports/AnalysisProvider.js";
import type {
DoctorCheck,
DoctorProviderInspection,
} from "../ports/DoctorProviderInspection.js";
import {
inspectNativeAnalysisConfiguration,
type NativeAnalysisConfigurationInspection,
@@ -34,13 +40,13 @@ import {
execFileOutputFailure,
execFileFailureCapturedOutput,
} from "../process/ExecFileOutput.js";
import { jsonValueSchema, type JsonValue } from "../domain/jsonValue.js";
import { jsonValueSchema } from "../domain/jsonValue.js";
import {
javaScriptRuntime,
type JavaScriptRuntime,
} from "../domain/runtimeVersion.js";
import { installedCaskAppdir, probeHomebrew } from "./homebrew.js";
import { readMacHopperRenamedLauncherCandidates } from "./MacHopperPaths.js";
import { readMacHopperRenamedLauncherCandidates } from "../hopperPaths/MacHopperPaths.js";
import {
inspectLinuxHopperLauncher,
linuxSharedLibrariesAvailable,
@@ -62,10 +68,7 @@ import {
type ClientRegistrationStatus,
type UnhealthyClientRegistrationStatus,
} from "./ClientRegistrationStatus.js";
import type {
OwnedProviderSetting,
ProviderRequestBudgetResolver,
} from "./ClientRegistrationEnvironment.js";
import type { ProviderRequestBudgetResolver } from "./ClientRegistrationEnvironment.js";
import { registrationSpelledSettings } from "./SetupRegistrationEnvironment.js";
import {
collectDoctorDiagnostics,
@@ -76,54 +79,13 @@ import {
scopeDoctorChecks,
type DoctorScopeReport,
} from "./DoctorScope.js";
import {
selectedDesktopBuildChecks,
type DesktopBuildFacts,
type DesktopBuildFactsInput,
} from "./DesktopBuildDoctor.js";
import { selectedDesktopBuildChecks } from "./DesktopBuildDoctor.js";
import type {
DesktopBuildFacts,
DesktopBuildFactsInput,
OwnedProviderSetting,
} from "../ports/DesktopBuildHost.js";
/** One actionable environment diagnostic. */
export interface DoctorCheck {
readonly name: string;
readonly ok: boolean;
readonly classification:
| "healthy"
| "missing_dependency"
| "runtime_failure"
| "unsupported_host"
| "unsupported_target"
| "missing_analysis_engine"
| "unknown"
| "config_drift";
readonly detail?: string;
readonly details?: Readonly<Record<string, JsonValue>>;
readonly remediation?: string;
}
/** One provider-owned check projected without importing its adapter types. */
export interface DoctorProviderCheck {
readonly name: string;
readonly ok: boolean;
readonly code: string | null;
readonly detail: string;
readonly remediation: string | null;
readonly classification: Exclude<DoctorCheck["classification"], "healthy">;
readonly details?: Readonly<Record<string, JsonValue>>;
}
/** Read-only provider inspection supplied by an outer composition adapter. */
export interface DoctorProviderInspection {
readonly id: string;
/** Null means the selected client's setting could not be determined. */
readonly configured: boolean | null;
/** Null means readiness cannot be established for the selected client. */
readonly available: boolean | null;
readonly providerVersion: string | null;
/** Validated discoveries used as registration defaults. Setup preserves
* caller-selected configuration separately from these readiness facts. */
readonly registrationEnvironment: Readonly<Record<string, string>>;
readonly checks: readonly DoctorProviderCheck[];
}
/** Read-only host capabilities required by diagnostics. */
export interface DoctorHost {
readonly signal?: AbortSignal;
Loaded 100 of 1391 files, more files were not shown because too many files have changed in this diff. Show more