Introspect image info from inside docker executor

From the comment section of a related idea:

@ndintenfass mentions pipeline-level variables:

Would it be possible to use pipeline-level variables to convey the immutable digest of the docker image?
E.g:

<< pipeline.executor.docker.image.digest >>

Another issue I’m encountering is that while I’m separating my build and test stages into sequential jobs in my workflow, so that I may enable parallelism for only the testing stage, it is possible for the test job to pull a difference docker image compared to the build job it depends on, given the image tag on the docker registry could have been updated over the span of time for the build job. This of course brakes the caching strategy, as then docker executors are not the same across jobs. Would it be possible for circleci to first query the registry for the immutable identifier upon config expansion at the start of the workflow, so that all jobs would attempt to pull the exact same docker image.

For example, an affix parameter could be added to the docker config, that would express that the image should be affixed with the discovered digest when interpreting the config for the workflow.
added E.g.:

executors:
  some_exec:
    docker:
      - image: library/ubuntu:bionic
+         affix: true
    working_directory: /foo/bar

This would expand the tag to include the digest, so that later jobs, either later in the same workflow or from re-run of failed jobs, would pull from the same repeatable image. Above would expand to this:

executors:
  some_exec:
    docker:
+     - image: library/ubuntu:bionic@sha256:d1d454df0f579c6be4d8161d227462d69e163a8ff9d20a847533989cf0c94d90
    working_directory: /foo/bar

I think this expansion should only be done once at the start of the workflow, and Rerun from failed should keep the same expansion from the workflow it originated from.