Files
reverse-engineering-anything/src/application/WorkflowEvidence.ts
T
dependabot[bot]andVincent Koc 029ad60f4f chore(deps): update 37 npm pins and preserve capture and release behavior (#14231)
* chore(deps): bump the npm-minor-and-patch group across 2 directories with 38 updates

Bumps the npm-minor-and-patch group with 37 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) | `8.0.4` | `8.1.2` |
| [@babel/types](https://github.com/babel/babel/tree/HEAD/packages/babel-types) | `8.0.4` | `8.1.2` |
| [@bufbuild/protobuf](https://github.com/bufbuild/protobuf-es/tree/HEAD/packages/protobuf) | `2.16.0` | `2.17.0` |
| [@clack/prompts](https://github.com/bombshell-dev/clack/tree/HEAD/packages/prompts) | `1.7.0` | `1.9.0` |
| [@zip.js/zip.js](https://github.com/gildas-lormeau/zip.js) | `2.15.0` | `2.25.0` |
| [evmole](https://github.com/cdump/evmole/tree/HEAD/javascript) | `0.9.3` | `0.9.4` |
| [ignore](https://github.com/kaelzhang/node-ignore) | `7.0.6` | `7.0.14` |
| [isomorphic-git](https://github.com/isomorphic-git/isomorphic-git) | `1.38.7` | `1.44.15` |
| [lossless-json](https://github.com/josdejong/lossless-json) | `4.3.1` | `4.3.3` |
| [parse5](https://github.com/inikulin/parse5) | `8.0.1` | `8.1.1` |
| [playwright-core](https://github.com/microsoft/playwright) | `1.64.1` | `1.65.1` |
| [plist](https://github.com/TooTallNate/plist.js) | `5.0.0` | `5.1.1` |
| [semver](https://github.com/npm/node-semver) | `7.8.5` | `7.8.6` |
| [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.7.1` | `7.8.0` |
| [smol-toml](https://github.com/squirrelchat/smol-toml) | `1.9.0` | `1.9.1` |
| [stream-chain](https://github.com/uhop/stream-chain) | `4.2.6` | `4.4.2` |
| [stream-json](https://github.com/uhop/stream-json) | `3.7.0` | `3.9.0` |
| [ws](https://github.com/websockets/ws) | `8.21.0` | `8.23.0` |
| [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws) | `8.18.1` | `8.18.2` |
| [yaml](https://github.com/eemeli/yaml) | `2.9.0` | `2.9.1` |
| [zod](https://github.com/colinhacks/zod) | `4.6.6` | `4.6.7` |
| [@electron/asar](https://github.com/electron/asar) | `4.2.0` | `4.3.2` |
| [@stryker-mutator/core](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/core) | `10.0.0` | `10.1.1` |
| [@stryker-mutator/typescript-checker](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/typescript-checker) | `10.0.0` | `10.1.1` |
| [@stryker-mutator/vitest-runner](https://github.com/stryker-mutator/stryker-js/tree/HEAD/packages/vitest-runner) | `10.0.0` | `10.1.1` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.6.4` | `26.6.6` |
| [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) | `7.7.1` | `7.8.0` |
| [@types/ws](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ws) | `8.18.1` | `8.18.2` |
| [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) | `5.0.3` | `5.1.0` |
| [jscpd](https://github.com/kucherenko/jscpd/tree/HEAD/rust/jscpd) | `5.0.12` | `5.4.3` |
| [knip](https://github.com/webpro-nl/knip/tree/HEAD/packages/knip) | `6.39.0` | `6.45.1` |
| [oxfmt](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxfmt) | `0.72.0` | `0.79.0` |
| [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint) | `1.87.0` | `1.94.0` |
| [oxlint-tsgolint](https://github.com/oxc-project/tsgolint) | `7.0.2005` | `7.0.2007` |
| [release-please](https://github.com/googleapis/release-please) | `17.3.0` | `17.11.2` |
| [rolldown](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.12` | `1.3.2` |
| [turbo](https://github.com/vercel/turborepo) | `2.11.7` | `2.11.11` |
| [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `5.0.3` | `5.1.0` |
| [frida](https://github.com/frida/frida-node) | `17.23.2` | `17.26.4` |

Bumps the npm-minor-and-patch group with 1 update in the /scripts/verify-tools/skills directory: [skills](https://github.com/vercel-labs/skills).


Updates `@babel/parser` from 8.0.4 to 8.1.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v8.1.2/packages/babel-parser)

Updates `@babel/types` from 8.0.4 to 8.1.2
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v8.1.2/packages/babel-types)

Updates `@bufbuild/protobuf` from 2.16.0 to 2.17.0
- [Release notes](https://github.com/bufbuild/protobuf-es/releases)
- [Commits](https://github.com/bufbuild/protobuf-es/commits/v2.17.0/packages/protobuf)

Updates `@clack/prompts` from 1.7.0 to 1.9.0
- [Release notes](https://github.com/bombshell-dev/clack/releases)
- [Changelog](https://github.com/bombshell-dev/clack/blob/main/packages/prompts/CHANGELOG.md)
- [Commits](https://github.com/bombshell-dev/clack/commits/@clack/prompts@1.9.0/packages/prompts)

Updates `@zip.js/zip.js` from 2.15.0 to 2.25.0
- [Release notes](https://github.com/gildas-lormeau/zip.js/releases)
- [Commits](https://github.com/gildas-lormeau/zip.js/compare/v2.15.0...v2.25.0)

Updates `evmole` from 0.9.3 to 0.9.4
- [Release notes](https://github.com/cdump/evmole/releases)
- [Commits](https://github.com/cdump/evmole/commits/0.9.4/javascript)

Updates `ignore` from 7.0.6 to 7.0.14
- [Release notes](https://github.com/kaelzhang/node-ignore/releases)
- [Commits](https://github.com/kaelzhang/node-ignore/compare/7.0.6...7.0.14)

Updates `isomorphic-git` from 1.38.7 to 1.44.15
- [Release notes](https://github.com/isomorphic-git/isomorphic-git/releases)
- [Commits](https://github.com/isomorphic-git/isomorphic-git/compare/v1.38.7...v1.44.15)

Updates `lossless-json` from 4.3.1 to 4.3.3
- [Changelog](https://github.com/josdejong/lossless-json/blob/main/CHANGELOG.md)
- [Commits](https://github.com/josdejong/lossless-json/compare/v4.3.1...v4.3.3)

Updates `parse5` from 8.0.1 to 8.1.1
- [Release notes](https://github.com/inikulin/parse5/releases)
- [Commits](https://github.com/inikulin/parse5/compare/v8.0.1...v8.1.1)

Updates `playwright-core` from 1.64.1 to 1.65.1
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.64.1...v1.65.1)

Updates `plist` from 5.0.0 to 5.1.1
- [Release notes](https://github.com/TooTallNate/plist.js/releases)
- [Changelog](https://github.com/TooTallNate/plist.js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TooTallNate/plist.js/compare/plist@5.0.0...plist@5.1.1)

Updates `semver` from 7.8.5 to 7.8.6
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.8.5...v7.8.6)

Updates `@types/semver` from 7.7.1 to 7.8.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver)

Updates `smol-toml` from 1.9.0 to 1.9.1
- [Release notes](https://github.com/squirrelchat/smol-toml/releases)
- [Commits](https://github.com/squirrelchat/smol-toml/compare/v1.9.0...v1.9.1)

Updates `stream-chain` from 4.2.6 to 4.4.2
- [Commits](https://github.com/uhop/stream-chain/compare/4.2.6...4.4.2)

Updates `stream-json` from 3.7.0 to 3.9.0
- [Commits](https://github.com/uhop/stream-json/compare/3.7.0...3.9.0)

Updates `ws` from 8.21.0 to 8.23.0
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.21.0...8.23.0)

Updates `@types/ws` from 8.18.1 to 8.18.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

Updates `yaml` from 2.9.0 to 2.9.1
- [Release notes](https://github.com/eemeli/yaml/releases)
- [Commits](https://github.com/eemeli/yaml/compare/v2.9.0...v2.9.1)

Updates `zod` from 4.6.6 to 4.6.7
- [Release notes](https://github.com/colinhacks/zod/releases)
- [Commits](https://github.com/colinhacks/zod/compare/v4.6.6...v4.6.7)

Updates `@electron/asar` from 4.2.0 to 4.3.2
- [Release notes](https://github.com/electron/asar/releases)
- [Changelog](https://github.com/electron/asar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/electron/asar/compare/v4.2.0...v4.3.2)

Updates `@stryker-mutator/core` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/core/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/core)

Updates `@stryker-mutator/typescript-checker` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/typescript-checker/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/typescript-checker)

Updates `@stryker-mutator/vitest-runner` from 10.0.0 to 10.1.1
- [Release notes](https://github.com/stryker-mutator/stryker-js/releases)
- [Changelog](https://github.com/stryker-mutator/stryker-js/blob/master/packages/vitest-runner/CHANGELOG.md)
- [Commits](https://github.com/stryker-mutator/stryker-js/commits/v10.1.1/packages/vitest-runner)

Updates `@types/node` from 26.6.4 to 26.6.6
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `@types/semver` from 7.7.1 to 7.8.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver)

Updates `@types/ws` from 8.18.1 to 8.18.2
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ws)

Updates `@vitest/coverage-v8` from 5.0.3 to 5.1.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.1.0/packages/coverage-v8)

Updates `jscpd` from 5.0.12 to 5.4.3
- [Release notes](https://github.com/kucherenko/jscpd/releases)
- [Commits](https://github.com/kucherenko/jscpd/commits/v5.4.3/rust/jscpd)

Updates `knip` from 6.39.0 to 6.45.1
- [Release notes](https://github.com/webpro-nl/knip/releases)
- [Commits](https://github.com/webpro-nl/knip/commits/knip@6.45.1/packages/knip)

Updates `oxfmt` from 0.72.0 to 0.79.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxfmt/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxfmt_v0.79.0/npm/oxfmt)

Updates `oxlint` from 1.87.0 to 1.94.0
- [Release notes](https://github.com/oxc-project/oxc/releases)
- [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md)
- [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.94.0/npm/oxlint)

Updates `oxlint-tsgolint` from 7.0.2005 to 7.0.2007
- [Release notes](https://github.com/oxc-project/tsgolint/releases)
- [Commits](https://github.com/oxc-project/tsgolint/compare/v7.0.2005...v7.0.2007)

Updates `release-please` from 17.3.0 to 17.11.2
- [Release notes](https://github.com/googleapis/release-please/releases)
- [Changelog](https://github.com/googleapis/release-please/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/release-please/compare/v17.3.0...v17.11.2)

Updates `rolldown` from 1.2.12 to 1.3.2
- [Release notes](https://github.com/rolldown/rolldown/releases)
- [Changelog](https://github.com/rolldown/rolldown/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rolldown/rolldown/commits/v1.3.2/packages/rolldown)

Updates `turbo` from 2.11.7 to 2.11.11
- [Release notes](https://github.com/vercel/turborepo/releases)
- [Changelog](https://github.com/vercel/turborepo/blob/main/RELEASE.md)
- [Commits](https://github.com/vercel/turborepo/compare/v2.11.7...v2.11.11)

Updates `vitest` from 5.0.3 to 5.1.0
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v5.1.0/packages/vitest)

Updates `frida` from 17.23.2 to 17.26.4
- [Commits](https://github.com/frida/frida-node/compare/17.23.2...17.26.4)

Updates `skills` from 1.7.2 to 1.9.0
- [Release notes](https://github.com/vercel-labs/skills/releases)
- [Commits](https://github.com/vercel-labs/skills/compare/v1.7.2...v1.9.0)

---
updated-dependencies:
- dependency-name: "@babel/parser"
  dependency-version: 8.1.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@babel/types"
  dependency-version: 8.1.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@bufbuild/protobuf"
  dependency-version: 2.17.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@clack/prompts"
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@electron/asar"
  dependency-version: 4.3.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/core"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/typescript-checker"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@stryker-mutator/vitest-runner"
  dependency-version: 10.1.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/node"
  dependency-version: 26.6.6
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/semver"
  dependency-version: 7.8.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/semver"
  dependency-version: 7.8.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/ws"
  dependency-version: 8.18.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@types/ws"
  dependency-version: 8.18.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 5.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: "@zip.js/zip.js"
  dependency-version: 2.25.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: evmole
  dependency-version: 0.9.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: frida
  dependency-version: 17.26.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: ignore
  dependency-version: 7.0.14
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: isomorphic-git
  dependency-version: 1.44.15
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: jscpd
  dependency-version: 5.4.3
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: knip
  dependency-version: 6.45.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: lossless-json
  dependency-version: 4.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: oxfmt
  dependency-version: 0.79.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: oxlint
  dependency-version: 1.94.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: oxlint-tsgolint
  dependency-version: 7.0.2007
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: parse5
  dependency-version: 8.1.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: playwright-core
  dependency-version: 1.65.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: plist
  dependency-version: 5.1.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: release-please
  dependency-version: 17.11.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: rolldown
  dependency-version: 1.3.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: semver
  dependency-version: 7.8.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: skills
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: smol-toml
  dependency-version: 1.9.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: stream-chain
  dependency-version: 4.4.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: stream-json
  dependency-version: 3.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: turbo
  dependency-version: 2.11.11
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: vitest
  dependency-version: 5.1.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: ws
  dependency-version: 8.23.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-and-patch
- dependency-name: yaml
  dependency-version: 2.9.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
- dependency-name: zod
  dependency-version: 4.6.7
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(deps): adapt release tooling and capture metadata to the new npm pins

* fix(deps): preserve numeric, plist and archive evidence semantics

* test(zip): verify malformed compression with CRC checks enabled

* fix(capture): preserve exact decimal projections and redaction

* test(apple): verify keyed archive controls before altering the trailer

* test(lint): cover safe and suggested regex escape fixes

* fix(reference): preserve directory exclusion provenance with ignore 7

* docs(examples): refresh HAR evidence identities for the current decoder

* fix(reference): preserve metadata failures with strict Git ref reads

* chore(config): remove the unused MCP profile type alias

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-11-24 21:26:48 +08:00

596 lines
20 KiB
TypeScript

import { unknownTarget } from "../domain/targetIdentity.js";
import { AnalysisWorkScope } from "../ports/AnalysisWorkScope.js";
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
import { jsonStringByteLength } from "../domain/jsonStringByteLength.js";
import { createAnalysisExecutionEvidence } from "../domain/analysisObservation.js";
import { REA_WORKFLOW_PROVIDER } from "../domain/investigationProviders.js";
import {
workflowAnalysisProfile,
workflowAnalysisProfileParameters,
} from "./WorkflowAnalysisProfile.js";
import type {
AnalysisExecution,
AnalysisOperation,
AnalysisOperationPort,
} from "../ports/AnalysisProvider.js";
import { err, ok } from "../domain/result.js";
import type { EnhancedResult } from "./EnhancedToolTypes.js";
import type { AnalysisProfileCommitment } from "../domain/analysisProfile.js";
import type { AnalysisError } from "../domain/analysisErrorBase.js";
import type { WorkflowSnapshotRecordInput } from "./binary/BinarySessionRecords.js";
import {
analysisProfileSchema,
committedProviderSchema,
} from "../domain/analysisProfile.js";
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
import {
createEvidence,
evidenceEnvelopeForAdmission,
type Evidence,
type EvidenceLocation,
} from "../domain/evidence.js";
import type { JsonValue } from "../domain/jsonValue.js";
import type { UnknownRegistryPort } from "./investigation/InvestigationRecordPort.js";
import { UnknownRegistryError } from "../domain/unknownRegistryError.js";
import { EvidenceLedger } from "./investigation/EvidenceLedger.js";
import {
recordEvidenceSources,
retainAnalysisResultSources,
withEvidenceSources,
type AnalysisResultWithSources,
} from "./investigation/recordEvidenceSources.js";
import { preserveCompletedSourceEvidence } from "./investigation/sourcePublicationRecovery.js";
import {
admitInvestigationAuthentication,
type RecoveryAdmission,
} from "./investigation/InvestigationRetention.js";
import { estimateJsonStorage } from "./JsonAuthenticationHeadroom.js";
import { workflowUnknownInput } from "./investigation/WorkflowUnknown.js";
import {
renderSourceLimitations,
sourceLimitationGroupKey,
sourceLimitationKey,
type SourceLimitation,
} from "./SourceLimitations.js";
/**
* Bound for caveats a workflow observes once per item. Provider caveats can
* name per-item addresses, so they do not deduplicate and would otherwise grow
* with the number of items.
*/
export interface ComposedLimitationBudget {
/** Operations whose caveats the workflow admits after checking the item. */
readonly perItemOperations: ReadonlySet<AnalysisOperation>;
/**
* First distinct per-item caveats retained, grouped by provider and text.
* Kept lines are rendered in the usual sorted order.
*/
readonly maxDistinct: number;
/** Retained caveat text as JSON-encoded UTF-8 bytes; defaults to 8,000. */
readonly maxBytes?: number;
/** Where the omitted per-item caveats remain, as a clause. */
readonly retainedIn: string;
}
const DECOMPILE_ALL_LIMITATIONS: ComposedLimitationBudget = {
perItemOperations: new Set(["procedure_info", "procedure_pseudo_code"]),
maxDistinct: 8,
retainedIn:
"decompile-index.json keeps the latest record for each function; decompile-journal.jsonl keeps each attempt and its caveats",
};
/** The caveat budget for a composed workflow, when it has one. */
export const composedLimitationBudget = (
operation: string,
): ComposedLimitationBudget | undefined =>
operation === "decompile_all" ? DECOMPILE_ALL_LIMITATIONS : undefined;
/** What one composed call answered, or admitted before a failure stopped it. */
export interface ComposedWorkflowObservation {
readonly result: JsonValue;
readonly limitations: readonly string[];
readonly cachePolicy?: "live";
readonly evidenceLinks?: readonly string[];
}
/** A composed outcome; only a stopped failure carries its admitted observation. */
export type ComposedWorkflowResult =
AnalysisResultWithSources<ComposedWorkflowObservation> & {
readonly partial?: ComposedWorkflowObservation;
};
export interface WorkflowAnalysisPort extends AnalysisOperationPort {
/** Publish caveats only after admitting an observation for a workflow item. */
recordItemLimitations?(
operation: AnalysisOperation,
execution: AnalysisExecution,
): void;
}
/** Retain the limits of exactly the observations used by one composed call. */
export const executeComposedWorkflow = async (
analysis: AnalysisOperationPort,
execute: (observed: WorkflowAnalysisPort) => EnhancedResult,
budget?: ComposedLimitationBudget,
): Promise<ComposedWorkflowResult> => {
const limitations = new Map<string, SourceLimitation>();
const evidenceLinks = new Set<string>();
const sourceLedger = new EvidenceLedger();
const perItemGroups = new Set<string>();
let perItemBytes = 0;
let omittedObservations = 0;
let cachePolicy: "live" | undefined;
const workScope = new AnalysisWorkScope();
const recordLimitations = (
operation: AnalysisOperation,
execution: AnalysisExecution,
): void => {
for (const limitation of execution.limitations) {
const fact = {
provider: execution.provider,
operation,
limitation,
} satisfies SourceLimitation;
if (budget?.perItemOperations.has(operation) === true) {
// Reject oversized text before allocating a grouping key. Complete
// caveats are already retained by the export's per-function owner.
const maxBytes = budget.maxBytes ?? 8_000;
const bytes = jsonStringByteLength(limitation, maxBytes);
if (bytes > maxBytes) {
omittedObservations += 1;
continue;
}
const group = sourceLimitationGroupKey(fact);
if (!perItemGroups.has(group)) {
if (
perItemGroups.size >= budget.maxDistinct ||
perItemBytes + bytes > maxBytes
) {
omittedObservations += 1;
continue;
}
perItemGroups.add(group);
perItemBytes += bytes;
}
}
limitations.set(sourceLimitationKey(fact), fact);
}
};
const observed: WorkflowAnalysisPort = {
recordItemLimitations: (operation, execution) => {
if (budget?.perItemOperations.has(operation) === true)
recordLimitations(operation, execution);
},
resourceScope: analysis.resourceScope,
execute: async (operation, parameters, options) => {
let execution = await analysis.execute(operation, parameters, {
...options,
workScope,
});
if (execution.ok && execution.value.sourceEvidence !== undefined) {
const recorded = recordEvidenceSources(
(source) => sourceLedger.record(source),
execution.value.sourceEvidence,
);
if (!recorded.ok) return recorded;
}
if (
execution.ok &&
options?.retainEvidence === true &&
execution.value.evidenceId === undefined
) {
const source = createAnalysisExecutionEvidence(
operation,
parameters,
execution.value,
"observed",
);
const recorded = recordEvidenceSources(
(evidence) => sourceLedger.record(evidence),
[source],
);
if (!recorded.ok) return recorded;
execution = ok({ ...execution.value, evidenceId: source.evidence_id });
}
if (execution.ok && execution.value.evidenceId !== undefined)
evidenceLinks.add(execution.value.evidenceId);
if (execution.ok && execution.value.cachePolicy === "live")
cachePolicy = "live";
if (execution.ok && budget?.perItemOperations.has(operation) !== true)
recordLimitations(operation, execution.value);
return execution;
},
};
const result = await Promise.resolve()
.then(() => execute(observed))
.finally(() => workScope.clear());
const sources = sourceLedger.recordsForAnalysis();
if (!result.ok && !("partialResult" in result))
return withEvidenceSources(result, sources);
for (const source of sources) evidenceLinks.add(source.evidence_id);
const observation = (value: JsonValue): ComposedWorkflowObservation => ({
result: value,
limitations: [
...renderSourceLimitations([...limitations.values()]),
...(omittedObservations === 0
? []
: [
`${omittedObservations} per-item provider limitation observation${omittedObservations === 1 ? " was" : "s were"} omitted from this answer; ${budget?.retainedIn}.`,
]),
],
...(cachePolicy === undefined ? {} : { cachePolicy }),
...(evidenceLinks.size === 0
? {}
: { evidenceLinks: [...evidenceLinks].sort(compareUnicodeCodePoints) }),
});
return withEvidenceSources(
result.ok
? ok(observation(result.value))
: {
ok: false as const,
error: result.error,
partial: observation(result.partialResult),
},
sources,
);
};
/** Scope of the exact-address reference lookups composed by trace_feature. */
const TRACE_FEATURE_REFERENCE_LIMITATION =
"Reference queries cover only each matched start address, not interior bytes of strings and procedures. Empty references and truncated: false do not establish complete reference coverage.";
/** Build the shared Evidence record for a successful composed binary workflow. */
export interface WorkflowEvidenceInput {
readonly target: BinaryTarget | undefined;
readonly operation: AnalysisOperation;
readonly parameters: Readonly<Record<string, JsonValue>>;
readonly result: JsonValue;
readonly upstreamProfile: AnalysisProfileCommitment | undefined;
readonly upstreamLimitations: readonly string[];
readonly upstreamEvidenceLinks?: readonly string[];
}
const WORKFLOW_DERIVATION_LIMITATION = "Derived by an REA composed workflow.";
const workflowLimitations = (operation: AnalysisOperation): readonly string[] =>
operation === "trace_feature"
? [WORKFLOW_DERIVATION_LIMITATION, TRACE_FEATURE_REFERENCE_LIMITATION]
: [WORKFLOW_DERIVATION_LIMITATION];
/** A workflow without an open target derives only from the Evidence it links. */
const workflowSubject = (target: BinaryTarget | undefined) =>
target ?? unknownTarget("derived-from-linked-evidence");
export const createWorkflowEvidence = (
input: WorkflowEvidenceInput,
): Evidence =>
createEvidence(
workflowSubject(input.target),
REA_WORKFLOW_PROVIDER,
{
operation: input.operation,
parameters: input.parameters,
result: input.result,
...(input.upstreamProfile === undefined
? {}
: {
analysisProfile: workflowAnalysisProfile(
input.upstreamProfile,
input.operation,
),
}),
confidence: "derived",
...(input.upstreamEvidenceLinks === undefined
? {}
: { evidenceLinks: input.upstreamEvidenceLinks }),
limitations: [
...workflowLimitations(input.operation),
...input.upstreamLimitations,
],
...(input.operation === "batch_decompile"
? { locations: batchProcedureLocations(input.result) }
: {}),
},
{ callerTarget: input.target },
);
const admitWorkflowRecovery = (
observation: ComposedWorkflowObservation,
evidenceInput: Pick<
WorkflowEvidenceInput,
"target" | "operation" | "parameters" | "upstreamProfile"
>,
admitRecovery: RecoveryAdmission,
) => {
const admissionInput = {
operation: evidenceInput.operation,
parameters: evidenceInput.parameters,
target:
evidenceInput.target === undefined
? null
: {
path: evidenceInput.target.path,
sha256: evidenceInput.target.sha256,
format: evidenceInput.target.format,
architecture: evidenceInput.target.architecture ?? null,
},
profile: evidenceInput.upstreamProfile ?? null,
result: observation.result,
limitations: observation.limitations,
links: observation.evidenceLinks ?? [],
};
// The completed result can also generate a location per batch item and
// the workflow profile embeds the upstream profile. Admit these copies
// before constructing or hashing the recovery Evidence.
const shell = evidenceEnvelopeForAdmission(
workflowSubject(evidenceInput.target),
REA_WORKFLOW_PROVIDER,
{
operation: evidenceInput.operation,
parameters: {},
result: null,
...(evidenceInput.upstreamProfile === undefined
? {}
: {
analysisProfile: {
provider: REA_WORKFLOW_PROVIDER,
parameters: workflowAnalysisProfileParameters(
null,
evidenceInput.operation,
),
digest: "0".repeat(64),
},
}),
confidence: "derived",
limitations: workflowLimitations(evidenceInput.operation),
locations: [],
evidenceLinks: [],
},
evidenceInput.target,
);
const additional = estimateJsonStorage([
observation.result,
evidenceInput.upstreamProfile ?? null,
shell,
]);
return admitRecovery(admissionInput, evidenceInput.operation, additional);
};
/** Experimental shared recovery of a workflow that completed before source admission. */
export const retainComposedWorkflowSources = (
recordEvidence: Parameters<typeof retainAnalysisResultSources>[1],
result: Awaited<ReturnType<typeof executeComposedWorkflow>>,
evidenceInput: Omit<
WorkflowEvidenceInput,
"result" | "upstreamLimitations" | "upstreamEvidenceLinks"
>,
evidenceForAnalysis?: (id: string) => Evidence | undefined,
admitRecovery: RecoveryAdmission = (input, operation, additional) =>
admitInvestigationAuthentication(input, operation, {}, additional),
): ReturnType<
typeof retainAnalysisResultSources<{
readonly result: JsonValue;
readonly limitations: readonly string[];
readonly cachePolicy?: "live";
readonly evidenceLinks?: readonly string[];
}>
> => {
const retained = retainAnalysisResultSources(
evidenceInput.operation,
recordEvidence,
result,
);
if (result.ok && !retained.ok) {
const admitted = admitWorkflowRecovery(
result.value,
evidenceInput,
admitRecovery,
);
if (!admitted.ok) {
retained.error.retainSourcePublication({
kind: "omitted",
reason:
admitted.error._tag === "AnalysisResourceConstraintError"
? "insufficient-authentication-headroom"
: "recovery-input-invalid",
source_closure: "not-established",
});
return retained;
}
const evidence = createWorkflowEvidence({
...evidenceInput,
result: result.value.result,
upstreamLimitations: result.value.limitations,
...(result.value.evidenceLinks === undefined
? {}
: { upstreamEvidenceLinks: result.value.evidenceLinks }),
});
preserveCompletedSourceEvidence(
retained.error,
evidence,
evidenceForAnalysis,
);
}
return retained;
};
/** Retain a stopped workflow's admitted observation as partial workflow Evidence on its failure. */
export const retainPartialWorkflowEvidence = (
outcome: ComposedWorkflowResult,
context: Pick<
Parameters<typeof createWorkflowEvidence>[0],
"target" | "operation" | "parameters" | "upstreamProfile"
>,
admitRecovery: RecoveryAdmission = (input, operation, additional) =>
admitInvestigationAuthentication(input, operation, {}, additional),
): void => {
if (
outcome.ok ||
outcome.partial === undefined ||
outcome.error.partialObservation !== undefined
)
return;
const admitted = admitWorkflowRecovery(
outcome.partial,
context,
admitRecovery,
);
if (!admitted.ok) {
outcome.error.retainPartialObservation({
kind: "omitted-observation",
reason:
admitted.error._tag === "AnalysisResourceConstraintError"
? "insufficient-authentication-headroom"
: "recovery-input-invalid",
});
return;
}
const evidence = createWorkflowEvidence({
...context,
result: outcome.partial.result,
upstreamLimitations: outcome.partial.limitations,
...(outcome.partial.evidenceLinks === undefined
? {}
: { upstreamEvidenceLinks: outcome.partial.evidenceLinks }),
});
// A partial observation the failing read already reported stays its own.
outcome.error.retainPartialObservation(evidence);
};
const batchProcedureLocations = (result: JsonValue): EvidenceLocation[] => {
if (
result === null ||
typeof result !== "object" ||
Array.isArray(result) ||
!Array.isArray(result.items)
)
return [];
const addresses = new Set<string>();
for (const item of result.items) {
if (item === null || typeof item !== "object" || Array.isArray(item))
continue;
const procedure = item.procedure;
if (
procedure !== null &&
typeof procedure === "object" &&
!Array.isArray(procedure) &&
procedure.status === "resolved" &&
typeof procedure.address === "string"
)
addresses.add(procedure.address);
}
return [...addresses].map((address) => ({ kind: "address", address }));
};
/** Convert workflow Evidence into its exact replay binding, when it has a profile. */
export const workflowSnapshotRecord = (
evidence: Evidence,
operation: AnalysisOperation,
bindingProfile: AnalysisProfileCommitment | undefined,
cachePolicy?: "live",
): WorkflowSnapshotRecordInput | undefined => {
if (
evidence.analysis_profile === null ||
bindingProfile === undefined ||
cachePolicy === "live"
)
return undefined;
return {
operation,
bindingProfile,
parameters: evidence.parameters,
execution: {
result: evidence.normalized_result,
rawResult: evidence.raw_result,
provider: committedProviderSchema.parse(evidence.provider),
analysisProfile: analysisProfileSchema.parse(evidence.analysis_profile),
limitations: evidence.limitations,
locations: evidence.locations,
subject: evidence.subject,
},
};
};
interface WorkflowUnknownInput {
readonly name: string;
readonly result: JsonValue;
readonly evidenceId: string;
readonly recordUnknown: UnknownRegistryPort["recordUnknown"] | undefined;
/** The caller confirmed the completed Evidence is in its investigation. */
readonly evidenceRetained?: boolean;
}
/** Retain residual workflow questions using the shared investigation policy. */
export const recordWorkflowUnknowns = ({
name,
result,
evidenceId,
recordUnknown,
evidenceRetained,
}: WorkflowUnknownInput):
| ReturnType<UnknownRegistryPort["recordUnknown"]>
| { readonly ok: true; readonly value: null } => {
if (
!["trace_feature", "trace_call_path", "inspect_native_api"].includes(
name,
) ||
recordUnknown === undefined ||
typeof result !== "object" ||
result === null ||
Array.isArray(result) ||
!Array.isArray(result.residual_unknowns)
)
return { ok: true, value: null };
const questions = result.residual_unknowns;
const total = questions.reduce<number>(
(count, value) => count + (typeof value === "string" ? 1 : 0),
0,
);
let created = 0;
let existing = 0;
const stopped = (error: AnalysisError, index: number) =>
err(
error.retainWorkflowUnknownPublication({
evidence_id: evidenceId,
evidence_retention:
evidenceRetained === true ? "retained" : "unverified",
total_questions: total,
created_questions: created,
existing_questions: existing,
next_question_index: index,
}),
);
for (let index = 0; index < questions.length; index += 1) {
const question = questions[index];
if (typeof question !== "string") continue;
const input = workflowUnknownInput(evidenceId, {
question,
severity: "medium",
domain: name === "inspect_native_api" ? "native-api" : "control-flow",
required_authority: "shipped-artifact",
required_confidence: "observed",
required_environment: null,
recommended_probes: [
{
operation: name,
rationale:
name === "inspect_native_api"
? "Confirm the unsupported boundary with a capable provider or ABI probe."
: "Continue with a focused query or another available provider.",
},
],
relationships: [],
});
if (!input.ok) return stopped(input.error, index);
const recorded = recordUnknown(input.value);
if (recorded.ok) created += 1;
else if (
recorded.error instanceof UnknownRegistryError &&
recorded.error.reason === "already-exists"
)
existing += 1;
else return stopped(recorded.error, index);
}
return { ok: true, value: null };
};