feat(core): add TaskFileResolver primitive; refactor show target --check to use it#35583
feat(core): add TaskFileResolver primitive; refactor show target --check to use it#35583polygraph-app[bot] wants to merge 3 commits intomasterfrom
Conversation
…cking Adds a programmatic API that lets external consumers verify whether sandbox-violation file paths from a prior task run would be considered legitimate inputs/outputs in the current workspace configuration. The API mirrors the logic that powers nx show target --check: inputs are reconciled via HashPlanInspector.inspectTaskInputs, outputs via getOutputsForTargetAndConfiguration with glob matching. HashPlanInspector and the new verifier are now exported from devkit-exports for use by the nx-cloud light client.
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit b90bdf7
☁️ Nx Cloud last updated this comment at |
…evkit-internals Replaces the sandbox-report-aware verifySandboxViolations export with a generic primitive. createTaskFileResolver returns a handle exposing getInputs / getOutputs / isInput / isOutput per task — the cloud light client owns the SandboxReport shape and the iteration loop. Exposed via devkit-internals (not the public devkit-exports surface). A follow-up commit will refactor nx show target --check to consume this same resolver.
9ec92af to
8378d0e
Compare
…ally
Previously isInput() only matched against the materialized HashInputs.files
list — when an upstream task hadn't run yet, depOutputs was empty and any
file declared via { dependentTasksOutputFiles: '...', transitive?: bool }
was reported as not-an-input even when the path obviously matched both the
glob and a declared upstream output.
The new logic walks the task graph from the inspected task, pulls each
upstream's declared output globs, and reports the path as an input when
it matches the dependentTasksOutputFiles glob AND lies inside one of those
upstream outputs. Honors transitive: true/false. The check is exposed
separately as resolver.matchesDependentTaskOutputs so consumers (e.g. the
nx-cloud check-sandbox-report command) can reason about why a path was
considered an input.
Adds 6 unit tests covering: materialized depOutputs, static glob+output
match, glob-without-output mismatch, output-without-glob mismatch,
transitive=true walk, transitive=false short-walk, and the standalone
matchesDependentTaskOutputs accessor.
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We removed five // eslint-disable-next-line import/order comments from task-file-resolver.spec.ts that were referencing an ESLint rule not registered in this project's configuration. Because eslint-plugin-import is not set up here, ESLint treats each disable comment as an error ("Definition for rule 'import/order' was not found"), causing the nx:lint task to fail. Dropping the comments resolves all five lint errors without altering any functional code or import logic.
Warning
❌ We could not verify this fix.
diff --git a/packages/nx/src/hasher/task-file-resolver.spec.ts b/packages/nx/src/hasher/task-file-resolver.spec.ts
index 3b1a6f18..f138f70d 100644
--- a/packages/nx/src/hasher/task-file-resolver.spec.ts
+++ b/packages/nx/src/hasher/task-file-resolver.spec.ts
@@ -27,15 +27,10 @@ jest.mock('./task-hasher', () => ({
// ── Imports (after mocks) ────────────────────────────────────────────────────
-// eslint-disable-next-line import/order
import { HashPlanInspector } from './hash-plan-inspector';
-// eslint-disable-next-line import/order
import { getOutputsForTargetAndConfiguration } from '../tasks-runner/utils';
-// eslint-disable-next-line import/order
import { createTaskGraph } from '../tasks-runner/create-task-graph';
-// eslint-disable-next-line import/order
import { getInputs as mockedGetInputs } from './task-hasher';
-// eslint-disable-next-line import/order
import { createTaskFileResolver } from './task-file-resolver';
const MockHashPlanInspector = jest.mocked(HashPlanInspector);
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally mhOE-JwVl
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Summary
Adds a small generic
TaskFileResolverprimitive (exported fromdevkit-internals,not
devkit-exports) that lets callers ask whether a workspace-relative path is adeclared input or output of a given task. Refactors
nx show target ... --check(both inputs and outputs) to use it instead of duplicating the input/output
reconciliation logic.
This supersedes the earlier
verifySandboxViolationsAPI: that high-level helperhas been removed in favor of this lower-level primitive. Consumers (the nx-cloud
light client) own their own report schemas and call the primitive per file.
API
Exported from
packages/nx/src/devkit-internals.ts.isInput()accepts a path as an input if any of the following hold:HashInputs.files(resolved self-inputs).HashInputs.depOutputs(materialized — only populated afterupstream tasks have run).
dependentTasksOutputFilesglob declared on the task ANDlies inside the declared outputs of an upstream task in the task graph
(honors
transitive: true|false). This is the static check that letssandbox-report verification work without first running the dependency.
Files
packages/nx/src/hasher/task-file-resolver.tspackages/nx/src/hasher/task-file-resolver.spec.tspackages/nx/src/hasher/verify-sandbox-violations.tspackages/nx/src/hasher/verify-sandbox-violations.spec.tspackages/nx/src/devkit-internals.tscreateTaskFileResolverpackages/nx/src/devkit-exports.tsverifySandboxViolationsexportspackages/nx/src/command-line/show/show-target/inputs.tspackages/nx/src/command-line/show/show-target/outputs.tsTest plan
6 new tests covering
dependentTasksOutputFilesstatic validation).show target inputs|outputs(25 tests passing locally).Linked PR
Consumed by nrwl/ocean#11134, which owns the
SandboxReportschema anditerates the report calling
resolver.isInput/resolver.isOutputper file.