@llblab/pi-kit 0.38.3 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +2 -2
- package/node_modules/@llblab/pi-actors/AGENTS.md +108 -20
- package/node_modules/@llblab/pi-actors/BACKLOG.md +207 -4
- package/node_modules/@llblab/pi-actors/CHANGELOG.md +13 -0
- package/node_modules/@llblab/pi-actors/README.md +31 -1
- package/node_modules/@llblab/pi-actors/dist/index.js +1 -1
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/async-runs.js +131 -62
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/automatic-review-runtime.js +3 -2
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/command-templates.js +263 -129
- package/node_modules/@llblab/pi-actors/dist/lib/execution-files.d.ts +32 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-files.js +128 -0
- package/node_modules/@llblab/pi-actors/dist/lib/execution-output.js +5 -4
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.d.ts +19 -1
- package/node_modules/@llblab/pi-actors/dist/lib/execution-sessions.js +62 -26
- package/node_modules/@llblab/pi-actors/dist/lib/execution.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/execution.js +6 -1
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.d.ts +9 -2
- package/node_modules/@llblab/pi-actors/dist/lib/extension-runtime.js +92 -14
- package/node_modules/@llblab/pi-actors/dist/lib/file-state.js +21 -2
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-command.js +2 -2
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.d.ts +25 -7
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-overlay.js +562 -262
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.d.ts +20 -10
- package/node_modules/@llblab/pi-actors/dist/lib/inspector.js +80 -91
- package/node_modules/@llblab/pi-actors/dist/lib/limits.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/limits.js +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/observability.d.ts +15 -1
- package/node_modules/@llblab/pi-actors/dist/lib/observability.js +216 -99
- package/node_modules/@llblab/pi-actors/dist/lib/pi.d.ts +5 -4
- package/node_modules/@llblab/pi-actors/dist/lib/pi.js +64 -10
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.d.ts +18 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipe-projection.js +220 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/recipes-context.js +30 -6
- package/node_modules/@llblab/pi-actors/dist/lib/registry.js +270 -36
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.d.ts +213 -5
- package/node_modules/@llblab/pi-actors/dist/lib/run-delivery.js +1909 -40
- package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.d.ts +107 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-supervision.js +412 -0
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.d.ts +9 -2
- package/node_modules/@llblab/pi-actors/dist/lib/run-ui-runtime.js +283 -60
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.d.ts +26 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-artifacts.js +68 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.d.ts +451 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-exports.js +2315 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.d.ts +97 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-context-index.js +368 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control-delivery.js +46 -7
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.d.ts +78 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-control.js +334 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-controls.js +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.d.ts +80 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-descendant-launches.js +287 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.d.ts +110 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-execution-evidence.js +282 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.d.ts +66 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-index.js +349 -13
- package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.d.ts +73 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-native-launches.js +227 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.d.ts +141 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-outcomes.js +292 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.d.ts +10 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-ownership.js +36 -4
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.d.ts +46 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process-windows-mi.js +114 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.d.ts +34 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-process.js +158 -26
- package/node_modules/@llblab/pi-actors/dist/lib/runs-results.d.ts +116 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-results.js +518 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.d.ts +15 -2
- package/node_modules/@llblab/pi-actors/dist/lib/runs-retention.js +148 -9
- package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.d.ts +95 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-session-exports.js +470 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.d.ts +58 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-snapshot.js +92 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.d.ts +2 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-start.js +44 -3
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.d.ts +15 -1
- package/node_modules/@llblab/pi-actors/dist/lib/runs-status.js +337 -13
- package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.d.ts +105 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-supervision.js +501 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/runs-trace.js +14 -3
- package/node_modules/@llblab/pi-actors/dist/lib/runtime.js +22 -3
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.d.ts +37 -0
- package/node_modules/@llblab/pi-actors/dist/lib/session-evidence.js +59 -3
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/state-readers.js +14 -8
- package/node_modules/@llblab/pi-actors/dist/lib/temp.d.ts +2 -4
- package/node_modules/@llblab/pi-actors/dist/lib/temp.js +4 -56
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-access.js +13 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.d.ts +1 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-inspect.js +110 -43
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-local.js +18 -6
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.d.ts +4 -1
- package/node_modules/@llblab/pi-actors/dist/lib/tools-message.js +126 -31
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.d.ts +31 -3
- package/node_modules/@llblab/pi-actors/dist/lib/tools-response.js +311 -47
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.d.ts +3 -0
- package/node_modules/@llblab/pi-actors/dist/lib/tools-spawn.js +29 -7
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.d.ts +20 -0
- package/node_modules/@llblab/pi-actors/dist/lib/trace-projection.js +192 -43
- package/node_modules/@llblab/pi-actors/dist/scripts/async-runner.mjs +272 -194
- package/node_modules/@llblab/pi-actors/dist/scripts/conformance.mjs +14 -2
- package/node_modules/@llblab/pi-actors/dist/skills/actors/SKILL.md +46 -2
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/diagnostics.md +40 -0
- package/node_modules/@llblab/pi-actors/dist/skills/actors/references/runs.md +55 -1
- package/node_modules/@llblab/pi-actors/docs/README.md +9 -1
- package/node_modules/@llblab/pi-actors/docs/actor-inspector.md +84 -15
- package/node_modules/@llblab/pi-actors/docs/agent-experience.md +216 -0
- package/node_modules/@llblab/pi-actors/docs/async-runs.md +18 -2
- package/node_modules/@llblab/pi-actors/docs/composition-transport.md +103 -0
- package/node_modules/@llblab/pi-actors/docs/coordinator-delivery.md +204 -4
- package/node_modules/@llblab/pi-actors/docs/inspection.md +38 -2
- package/node_modules/@llblab/pi-actors/docs/output-projection-map.md +130 -0
- package/node_modules/@llblab/pi-actors/docs/releasing.md +19 -2
- package/node_modules/@llblab/pi-actors/docs/run-supervision.md +1622 -0
- package/node_modules/@llblab/pi-actors/docs/template-recipes.md +4 -0
- package/node_modules/@llblab/pi-actors/docs/windows-process-observation.md +248 -0
- package/node_modules/@llblab/pi-actors/index.ts +1 -1
- package/node_modules/@llblab/pi-actors/lib/async-runs.ts +164 -73
- package/node_modules/@llblab/pi-actors/lib/automatic-review-runtime.ts +4 -2
- package/node_modules/@llblab/pi-actors/lib/command-templates.ts +287 -138
- package/node_modules/@llblab/pi-actors/lib/execution-files.ts +118 -0
- package/node_modules/@llblab/pi-actors/lib/execution-output.ts +4 -4
- package/node_modules/@llblab/pi-actors/lib/execution-sessions.ts +57 -27
- package/node_modules/@llblab/pi-actors/lib/execution.ts +8 -0
- package/node_modules/@llblab/pi-actors/lib/extension-runtime.ts +102 -12
- package/node_modules/@llblab/pi-actors/lib/file-state.ts +16 -2
- package/node_modules/@llblab/pi-actors/lib/inspector-command.ts +2 -2
- package/node_modules/@llblab/pi-actors/lib/inspector-overlay.ts +524 -261
- package/node_modules/@llblab/pi-actors/lib/inspector.ts +101 -130
- package/node_modules/@llblab/pi-actors/lib/limits.ts +1 -0
- package/node_modules/@llblab/pi-actors/lib/observability.ts +235 -116
- package/node_modules/@llblab/pi-actors/lib/pi.ts +59 -11
- package/node_modules/@llblab/pi-actors/lib/recipe-projection.ts +232 -0
- package/node_modules/@llblab/pi-actors/lib/recipes-context.ts +27 -6
- package/node_modules/@llblab/pi-actors/lib/registry.ts +266 -36
- package/node_modules/@llblab/pi-actors/lib/run-delivery.ts +1737 -49
- package/node_modules/@llblab/pi-actors/lib/run-supervision.ts +411 -0
- package/node_modules/@llblab/pi-actors/lib/run-ui-runtime.ts +237 -73
- package/node_modules/@llblab/pi-actors/lib/runs-artifacts.ts +73 -1
- package/node_modules/@llblab/pi-actors/lib/runs-context-exports.ts +1871 -0
- package/node_modules/@llblab/pi-actors/lib/runs-context-index.ts +372 -0
- package/node_modules/@llblab/pi-actors/lib/runs-control-delivery.ts +36 -18
- package/node_modules/@llblab/pi-actors/lib/runs-control.ts +297 -1
- package/node_modules/@llblab/pi-actors/lib/runs-controls.ts +3 -1
- package/node_modules/@llblab/pi-actors/lib/runs-descendant-launches.ts +338 -0
- package/node_modules/@llblab/pi-actors/lib/runs-execution-evidence.ts +302 -0
- package/node_modules/@llblab/pi-actors/lib/runs-index.ts +345 -17
- package/node_modules/@llblab/pi-actors/lib/runs-native-launches.ts +270 -0
- package/node_modules/@llblab/pi-actors/lib/runs-outcomes.ts +377 -0
- package/node_modules/@llblab/pi-actors/lib/runs-ownership.ts +37 -4
- package/node_modules/@llblab/pi-actors/lib/runs-process-windows-mi.ts +113 -0
- package/node_modules/@llblab/pi-actors/lib/runs-process.ts +210 -34
- package/node_modules/@llblab/pi-actors/lib/runs-results.ts +601 -0
- package/node_modules/@llblab/pi-actors/lib/runs-retention.ts +134 -10
- package/node_modules/@llblab/pi-actors/lib/runs-session-exports.ts +406 -0
- package/node_modules/@llblab/pi-actors/lib/runs-snapshot.ts +143 -0
- package/node_modules/@llblab/pi-actors/lib/runs-start.ts +44 -2
- package/node_modules/@llblab/pi-actors/lib/runs-status.ts +252 -10
- package/node_modules/@llblab/pi-actors/lib/runs-supervision.ts +394 -0
- package/node_modules/@llblab/pi-actors/lib/runs-trace.ts +14 -3
- package/node_modules/@llblab/pi-actors/lib/runtime.ts +22 -3
- package/node_modules/@llblab/pi-actors/lib/session-evidence.ts +76 -4
- package/node_modules/@llblab/pi-actors/lib/state-readers.ts +16 -7
- package/node_modules/@llblab/pi-actors/lib/temp.ts +3 -56
- package/node_modules/@llblab/pi-actors/lib/tools-access.ts +13 -0
- package/node_modules/@llblab/pi-actors/lib/tools-inspect.ts +110 -51
- package/node_modules/@llblab/pi-actors/lib/tools-local.ts +37 -24
- package/node_modules/@llblab/pi-actors/lib/tools-message.ts +120 -37
- package/node_modules/@llblab/pi-actors/lib/tools-response.ts +273 -50
- package/node_modules/@llblab/pi-actors/lib/tools-spawn.ts +31 -10
- package/node_modules/@llblab/pi-actors/lib/trace-projection.ts +165 -42
- package/node_modules/@llblab/pi-actors/package.json +10 -6
- package/node_modules/@llblab/pi-actors/scripts/async-runner.mjs +272 -194
- package/node_modules/@llblab/pi-actors/scripts/conformance.mjs +14 -2
- package/node_modules/@llblab/pi-actors/skills/actors/SKILL.md +46 -2
- package/node_modules/@llblab/pi-actors/skills/actors/references/diagnostics.md +40 -0
- package/node_modules/@llblab/pi-actors/skills/actors/references/runs.md +55 -1
- package/node_modules/@llblab/pi-codex-usage/AGENTS.md +2 -2
- package/node_modules/@llblab/pi-codex-usage/CHANGELOG.md +6 -0
- package/node_modules/@llblab/pi-codex-usage/README.md +9 -5
- package/node_modules/@llblab/pi-codex-usage/lib/query.ts +229 -50
- package/node_modules/@llblab/pi-codex-usage/lib/usage.ts +9 -1
- package/node_modules/@llblab/pi-codex-usage/package.json +1 -1
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +172 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +11 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +116 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
- package/node_modules/yaml/browser/dist/public-api.js +102 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +201 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
- package/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
- package/node_modules/yaml/dist/compose/composer.js +224 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +337 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +25 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +19 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/Alias.js +118 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +350 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +980 -0
- package/node_modules/yaml/dist/public-api.d.ts +44 -0
- package/node_modules/yaml/dist/public-api.js +107 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
- package/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
- package/node_modules/yaml/dist/schema/tags.js +99 -0
- package/node_modules/yaml/dist/schema/types.d.ts +92 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +16 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +97 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +3 -3
- package/node_modules/@llblab/pi-actors/banner.jpg +0 -0
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.d.ts +0 -16
- package/node_modules/@llblab/pi-actors/dist/lib/inspector-actions.js +0 -57
- package/node_modules/@llblab/pi-actors/lib/inspector-actions.ts +0 -79
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Async run state-directory ownership.
|
|
3
|
-
* Owns:
|
|
3
|
+
* Owns: marker proof for lifecycle/retention and optional bounded readonly identity admission.
|
|
4
4
|
*/
|
|
5
5
|
export declare const RUN_STATE_OWNERSHIP_FILE = ".pi-actors-run-state.json";
|
|
6
|
+
/** Avoid acquiring the same lifecycle resource through a second path while its parent lock is held. */
|
|
7
|
+
export declare function assertDistinctRunStateDirectories(parentStateDir: string, childStateDir: string): void;
|
|
6
8
|
export declare function claimRunStateDirectory(stateDir: string, run: string): string;
|
|
9
|
+
/** Read only the public marker identity, never its private ownership token. */
|
|
10
|
+
export declare function readOwnedRunStateDirectory(stateDir: string, options?: {
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
}): {
|
|
13
|
+
run: string;
|
|
14
|
+
stateDir: string;
|
|
15
|
+
};
|
|
7
16
|
export declare function assertOwnedRunStateDirectory(stateDir: string, run: string): string;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Async run state-directory ownership.
|
|
3
|
-
* Owns:
|
|
3
|
+
* Owns: marker proof for lifecycle/retention and optional bounded readonly identity admission.
|
|
4
4
|
*/
|
|
5
5
|
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, } from "node:fs";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
9
9
|
import { writeJsonAtomic } from "./file-state.js";
|
|
10
|
+
import { readJsonFileResilient } from "./state-readers.js";
|
|
10
11
|
export const RUN_STATE_OWNERSHIP_FILE = ".pi-actors-run-state.json";
|
|
11
12
|
function markerPath(stateDir) {
|
|
12
13
|
return join(stateDir, RUN_STATE_OWNERSHIP_FILE);
|
|
@@ -39,10 +40,15 @@ function assertCanonicalDirectory(stateDir) {
|
|
|
39
40
|
}
|
|
40
41
|
return resolved;
|
|
41
42
|
}
|
|
42
|
-
function readMarker(stateDir) {
|
|
43
|
+
function readMarker(stateDir, maxBytes) {
|
|
43
44
|
try {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
45
|
+
const path = markerPath(stateDir);
|
|
46
|
+
if (!lstatSync(path).isFile())
|
|
47
|
+
return undefined;
|
|
48
|
+
const value = maxBytes === undefined
|
|
49
|
+
? JSON.parse(readFileSync(path, "utf8"))
|
|
50
|
+
: readJsonFileResilient(path, undefined, { maxBytes, strictUtf8: true }).value;
|
|
51
|
+
if (!value || value.version !== 1 ||
|
|
46
52
|
typeof value.run !== "string" ||
|
|
47
53
|
typeof value.state_dir !== "string" ||
|
|
48
54
|
typeof value.ownership_token !== "string" ||
|
|
@@ -64,6 +70,22 @@ function assertMarkerMatches(marker, stateDir, run) {
|
|
|
64
70
|
}
|
|
65
71
|
return marker;
|
|
66
72
|
}
|
|
73
|
+
/** Avoid acquiring the same lifecycle resource through a second path while its parent lock is held. */
|
|
74
|
+
export function assertDistinctRunStateDirectories(parentStateDir, childStateDir) {
|
|
75
|
+
const parent = realpathSync.native(resolve(parentStateDir));
|
|
76
|
+
let child;
|
|
77
|
+
try {
|
|
78
|
+
child = realpathSync.native(resolve(childStateDir));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error.code === "ENOENT")
|
|
82
|
+
return;
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
if (comparablePath(parent) === comparablePath(child)) {
|
|
86
|
+
throw new Error("Run descendant preparation cannot target its parent state directory.");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
67
89
|
export function claimRunStateDirectory(stateDir, run) {
|
|
68
90
|
const resolved = resolve(stateDir);
|
|
69
91
|
if (existsSync(resolved) && lstatSync(resolved).isSymbolicLink()) {
|
|
@@ -89,6 +111,16 @@ export function claimRunStateDirectory(stateDir, run) {
|
|
|
89
111
|
});
|
|
90
112
|
return canonical;
|
|
91
113
|
}
|
|
114
|
+
/** Read only the public marker identity, never its private ownership token. */
|
|
115
|
+
export function readOwnedRunStateDirectory(stateDir, options = {}) {
|
|
116
|
+
if (options.maxBytes !== undefined && (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0)) {
|
|
117
|
+
throw new Error("Run state ownership read budget must be a nonnegative safe integer.");
|
|
118
|
+
}
|
|
119
|
+
const canonical = assertCanonicalDirectory(stateDir);
|
|
120
|
+
const marker = readMarker(canonical, options.maxBytes);
|
|
121
|
+
const checked = assertMarkerMatches(marker, canonical, marker?.run ?? "");
|
|
122
|
+
return { run: checked.run, stateDir: canonical };
|
|
123
|
+
}
|
|
92
124
|
export function assertOwnedRunStateDirectory(stateDir, run) {
|
|
93
125
|
const canonical = assertCanonicalDirectory(stateDir);
|
|
94
126
|
assertMarkerMatches(readMarker(canonical), canonical, run);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type NativeStage = 'application' | 'session' | 'input' | 'retrieval' | 'operation' | 'representation' | 'cleanup';
|
|
2
|
+
type RawTimestamp = {
|
|
3
|
+
readonly profile: 'mi-timestamp-v1';
|
|
4
|
+
readonly year: number;
|
|
5
|
+
readonly month: number;
|
|
6
|
+
readonly day: number;
|
|
7
|
+
readonly hour: number;
|
|
8
|
+
readonly minute: number;
|
|
9
|
+
readonly second: number;
|
|
10
|
+
readonly microseconds: number;
|
|
11
|
+
readonly utc: number;
|
|
12
|
+
};
|
|
13
|
+
type RawRow = {
|
|
14
|
+
readonly pid: number;
|
|
15
|
+
readonly date: RawTimestamp;
|
|
16
|
+
readonly exe: string;
|
|
17
|
+
readonly cmd: string;
|
|
18
|
+
};
|
|
19
|
+
type DecodeOutcome = {
|
|
20
|
+
readonly kind: 'decoded_unadmitted';
|
|
21
|
+
readonly rows: readonly RawRow[];
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'unusable';
|
|
24
|
+
readonly reason: 'invalid_query' | 'invalid_wire' | 'unsupported_optional_fields';
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'unusable';
|
|
27
|
+
readonly reason: 'native_stage';
|
|
28
|
+
readonly stage: NativeStage;
|
|
29
|
+
};
|
|
30
|
+
export declare function queryArguments(profile: unknown, pids: unknown): string[] | undefined;
|
|
31
|
+
type ProvenanceBinding = {
|
|
32
|
+
readonly source_sha256: string;
|
|
33
|
+
readonly executable_sha256: string;
|
|
34
|
+
readonly executable_bytes: number;
|
|
35
|
+
readonly originating_source_commit: string;
|
|
36
|
+
readonly originating_build_job: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function decodeProvenanceBinding(value: unknown): {
|
|
39
|
+
readonly kind: 'decoded_binding_unadmitted';
|
|
40
|
+
readonly binding: ProvenanceBinding;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'unusable';
|
|
43
|
+
readonly reason: 'invalid_binding';
|
|
44
|
+
};
|
|
45
|
+
export declare function decodeResponse(bytes: Uint8Array, profile: unknown, pids: unknown): DecodeOutcome;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Owns: Bounded raw MI wire decoding, query inputs and unadmitted provenance fragments, subordinate to process acquisition.
|
|
2
|
+
// Excludes: Identity construction/digest/comparison, status/liveness/lifecycle/publication/admission,
|
|
3
|
+
// fallback, native invocation and asset loading. Decoded data never admits a representation profile.
|
|
4
|
+
export function queryArguments(profile, pids) {
|
|
5
|
+
if ((profile !== 'scalar' && profile !== 'shared') || !Array.isArray(pids) ||
|
|
6
|
+
pids.length < 1 || pids.length > 64 || (profile === 'scalar' && pids.length !== 1))
|
|
7
|
+
return undefined;
|
|
8
|
+
const selected = [];
|
|
9
|
+
for (const pid of pids) {
|
|
10
|
+
if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 0 || selected.includes(pid))
|
|
11
|
+
return undefined;
|
|
12
|
+
selected.push(pid);
|
|
13
|
+
}
|
|
14
|
+
const query = `SELECT ${profile === 'shared' ? 'ProcessId,' : ''}CreationDate,ExecutablePath,CommandLine FROM Win32_Process WHERE ${selected.map(pid => `ProcessId = ${pid}`).join(' OR ')}`;
|
|
15
|
+
if (query.length > 4096 || !/^[\x00-\x7f]+$/.test(query))
|
|
16
|
+
return undefined;
|
|
17
|
+
return [profile, ...selected.map(String)];
|
|
18
|
+
}
|
|
19
|
+
function exactKeys(value, keys) {
|
|
20
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) &&
|
|
21
|
+
Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key));
|
|
22
|
+
}
|
|
23
|
+
export function decodeProvenanceBinding(value) {
|
|
24
|
+
const invalid = { kind: 'unusable', reason: 'invalid_binding' };
|
|
25
|
+
if (!exactKeys(value, ['source_sha256', 'executable_sha256', 'executable_bytes', 'originating_source_commit', 'originating_build_job']))
|
|
26
|
+
return invalid;
|
|
27
|
+
const { source_sha256, executable_sha256, executable_bytes, originating_source_commit, originating_build_job } = value;
|
|
28
|
+
if (typeof source_sha256 !== 'string' || !/^[0-9a-f]{64}$(?![\s\S])/.test(source_sha256) ||
|
|
29
|
+
typeof executable_sha256 !== 'string' || !/^[0-9a-f]{64}$(?![\s\S])/.test(executable_sha256) ||
|
|
30
|
+
typeof originating_source_commit !== 'string' || !/^[0-9a-f]{40}$(?![\s\S])/.test(originating_source_commit) ||
|
|
31
|
+
typeof originating_build_job !== 'string' || !/^[1-9][0-9]*$(?![\s\S])/.test(originating_build_job) ||
|
|
32
|
+
typeof executable_bytes !== 'number' || !Number.isSafeInteger(executable_bytes) || executable_bytes <= 0)
|
|
33
|
+
return invalid;
|
|
34
|
+
// These data claims verify neither the asset, its origin nor a representation profile.
|
|
35
|
+
return { kind: 'decoded_binding_unadmitted', binding: { source_sha256, executable_sha256, executable_bytes, originating_source_commit, originating_build_job } };
|
|
36
|
+
}
|
|
37
|
+
function timestamp(value) {
|
|
38
|
+
if (!exactKeys(value, ['profile', 'year', 'month', 'day', 'hour', 'minute', 'second', 'microseconds', 'utc']) || value.profile !== 'mi-timestamp-v1')
|
|
39
|
+
return undefined;
|
|
40
|
+
const { year, month, day, hour, minute, second, microseconds, utc } = value;
|
|
41
|
+
if (typeof year !== 'number' || typeof month !== 'number' || typeof day !== 'number' ||
|
|
42
|
+
typeof hour !== 'number' || typeof minute !== 'number' || typeof second !== 'number' ||
|
|
43
|
+
typeof microseconds !== 'number' || typeof utc !== 'number' ||
|
|
44
|
+
![year, month, day, hour, minute, second, microseconds, utc].every(Number.isInteger))
|
|
45
|
+
return undefined;
|
|
46
|
+
if (year < 1601 || year > 9999 || month < 1 || month > 12 || day < 1 ||
|
|
47
|
+
hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59 ||
|
|
48
|
+
microseconds < 0 || microseconds > 999999 || utc < -720 || utc > 840)
|
|
49
|
+
return undefined;
|
|
50
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
51
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
52
|
+
if (day > days[month - 1])
|
|
53
|
+
return undefined;
|
|
54
|
+
return { profile: 'mi-timestamp-v1', year, month, day, hour, minute, second, microseconds, utc };
|
|
55
|
+
}
|
|
56
|
+
export function decodeResponse(bytes, profile, pids) {
|
|
57
|
+
const args = queryArguments(profile, pids);
|
|
58
|
+
if (!args)
|
|
59
|
+
return { kind: 'unusable', reason: 'invalid_query' };
|
|
60
|
+
const invalid = { kind: 'unusable', reason: 'invalid_wire' };
|
|
61
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength > 1024 * 1024 ||
|
|
62
|
+
(bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf))
|
|
63
|
+
return invalid;
|
|
64
|
+
let value;
|
|
65
|
+
try {
|
|
66
|
+
value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return invalid;
|
|
70
|
+
}
|
|
71
|
+
if (exactKeys(value, ['schema', 'status']) && value.schema === 'native-mi-v1') {
|
|
72
|
+
switch (value.status) {
|
|
73
|
+
case 'application':
|
|
74
|
+
case 'session':
|
|
75
|
+
case 'input':
|
|
76
|
+
case 'retrieval':
|
|
77
|
+
case 'operation':
|
|
78
|
+
case 'representation':
|
|
79
|
+
case 'cleanup':
|
|
80
|
+
return { kind: 'unusable', reason: 'native_stage', stage: value.status };
|
|
81
|
+
default: return invalid;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const selected = args.slice(1).map(Number);
|
|
85
|
+
if (!exactKeys(value, ['schema', 'status', 'profile', 'complete', 'rows']) || value.schema !== 'native-mi-v1' ||
|
|
86
|
+
value.status !== 'ok' || value.profile !== profile || value.complete !== true || !Array.isArray(value.rows) ||
|
|
87
|
+
value.rows.length > selected.length)
|
|
88
|
+
return invalid;
|
|
89
|
+
const rows = [];
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
let optionalNull = false;
|
|
92
|
+
for (const row of value.rows) {
|
|
93
|
+
if (!exactKeys(row, profile === 'shared' ? ['pid', 'date', 'exe', 'cmd'] : ['date', 'exe', 'cmd']))
|
|
94
|
+
return invalid;
|
|
95
|
+
const pid = profile === 'shared' ? row.pid : selected[0];
|
|
96
|
+
if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || !selected.includes(pid) || seen.has(pid))
|
|
97
|
+
return invalid;
|
|
98
|
+
seen.add(pid);
|
|
99
|
+
// Preserve the raw optional-field distinction; no normalization or profile admission occurs here.
|
|
100
|
+
if (row.exe === null || row.cmd === null)
|
|
101
|
+
optionalNull = true;
|
|
102
|
+
if ((row.exe !== null && typeof row.exe !== 'string') || (row.cmd !== null && typeof row.cmd !== 'string'))
|
|
103
|
+
return invalid;
|
|
104
|
+
const date = timestamp(row.date);
|
|
105
|
+
if (!date)
|
|
106
|
+
return invalid;
|
|
107
|
+
// Null rows are never returned, even if the other rows are well formed.
|
|
108
|
+
if (typeof row.exe === 'string' && typeof row.cmd === 'string')
|
|
109
|
+
rows.push({ pid, date, exe: row.exe, cmd: row.cmd });
|
|
110
|
+
}
|
|
111
|
+
if (optionalNull)
|
|
112
|
+
return { kind: 'unusable', reason: 'unsupported_optional_fields' };
|
|
113
|
+
return { kind: 'decoded_unadmitted', rows };
|
|
114
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Async run process identity helpers.
|
|
3
|
-
* Owns: cross-platform liveness
|
|
3
|
+
* Owns: cross-platform liveness, stable runner identity, and single-process exit observations.
|
|
4
|
+
* Excludes: stop claims, signal dispatch, descendant/group cleanup, and lifecycle finalization.
|
|
4
5
|
*/
|
|
6
|
+
import { type ChildProcess } from "node:child_process";
|
|
5
7
|
export interface RunProcessIdentity {
|
|
6
8
|
command: string;
|
|
7
9
|
cwd?: string;
|
|
@@ -14,9 +16,40 @@ export interface RunProcessIdentityResult {
|
|
|
14
16
|
valid: boolean;
|
|
15
17
|
}
|
|
16
18
|
type ProcessIdentityReader = (pid: number, runtimePlatform: NodeJS.Platform) => RunProcessIdentity | undefined;
|
|
19
|
+
export type ProcessLiveness = "alive" | "dead" | "unknown";
|
|
20
|
+
type ProcessLivenessProbe = (pid: number, signal: 0) => boolean;
|
|
21
|
+
export declare function readProcessLiveness(pid: number, probe?: ProcessLivenessProbe): ProcessLiveness;
|
|
22
|
+
/** POSIX group presence only: neither ownership, membership completeness, nor whole-Run stop proof. */
|
|
23
|
+
export declare function readProcessGroupLiveness(processGroupId: number, runtimePlatform?: NodeJS.Platform, probe?: ProcessLivenessProbe): ProcessLiveness;
|
|
24
|
+
/** Unknown liveness must retain active-state guards, never authorize state reuse. */
|
|
17
25
|
export declare function isAlive(pid: number): boolean;
|
|
26
|
+
export declare const WINDOWS_IDENTITY_QUERY_PID_LIMIT = 64;
|
|
27
|
+
/** One bounded, complete CIM observation; undefined means query failure, never process absence. */
|
|
28
|
+
export declare function readWindowsProcessIdentities(pids: readonly number[]): Map<number, RunProcessIdentity> | undefined;
|
|
18
29
|
export declare function readProcessIdentity(pid: number, runtimePlatform?: NodeJS.Platform): RunProcessIdentity | undefined;
|
|
30
|
+
export declare function runProcessIdentityDigest(value: unknown): string | undefined;
|
|
19
31
|
export declare function captureRunProcessIdentity(pid: number, cwd: string, stateDir: string, runnerPath: string, runtimePlatform?: NodeJS.Platform, reader?: ProcessIdentityReader): RunProcessIdentity | undefined;
|
|
32
|
+
export interface SpawnIdentityCaptureDeps {
|
|
33
|
+
runtimePlatform?: NodeJS.Platform;
|
|
34
|
+
readIdentity?: ProcessIdentityReader;
|
|
35
|
+
now?: () => number;
|
|
36
|
+
wait?: (milliseconds: number) => void;
|
|
37
|
+
}
|
|
38
|
+
/** Fresh spawn only, while its lifecycle lock/child handle is retained and workload is not admitted. */
|
|
39
|
+
export declare function captureSpawnedRunProcessIdentity(child: Pick<ChildProcess, "pid" | "exitCode" | "signalCode">, cwd: string, stateDir: string, runnerPath: string, deps?: SpawnIdentityCaptureDeps): RunProcessIdentity | undefined;
|
|
40
|
+
/** Immediate managed-native callback only; this observation is not complete membership or termination authority. */
|
|
41
|
+
export declare function captureSpawnedNativeProcessIdentity(child: Pick<ChildProcess, "pid" | "exitCode" | "signalCode">, deps?: SpawnIdentityCaptureDeps): RunProcessIdentity | undefined;
|
|
20
42
|
export declare function verifyRunProcessIdentity(pid: number, expected: RunProcessIdentity | undefined, runtimePlatform?: NodeJS.Platform, reader?: ProcessIdentityReader, alive?: (pid: number) => boolean): RunProcessIdentityResult;
|
|
43
|
+
export interface RunProcessExitObservation {
|
|
44
|
+
status: "exited" | "running" | "unproven";
|
|
45
|
+
process_identity_status: RunProcessIdentityStatus;
|
|
46
|
+
}
|
|
47
|
+
export interface RunProcessExitDeps {
|
|
48
|
+
probe?: ProcessLivenessProbe;
|
|
49
|
+
readIdentity?: ProcessIdentityReader;
|
|
50
|
+
runtimePlatform?: NodeJS.Platform;
|
|
51
|
+
}
|
|
52
|
+
/** Observes one captured process only; signal dispatch and descendant cleanup are separate facts. */
|
|
53
|
+
export declare function observeRunProcessExit(pid: number, expected: RunProcessIdentity | undefined, deps?: RunProcessExitDeps): RunProcessExitObservation;
|
|
21
54
|
export declare function isWithinRunnerIdentityGrace(meta: Record<string, unknown>, graceMs: number): boolean;
|
|
22
55
|
export {};
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Async run process identity helpers.
|
|
3
|
-
* Owns: cross-platform liveness
|
|
3
|
+
* Owns: cross-platform liveness, stable runner identity, and single-process exit observations.
|
|
4
|
+
* Excludes: stop claims, signal dispatch, descendant/group cleanup, and lifecycle finalization.
|
|
4
5
|
*/
|
|
5
6
|
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
6
8
|
import { existsSync, readFileSync, readlinkSync, realpathSync } from "node:fs";
|
|
7
9
|
import { platform } from "node:os";
|
|
8
10
|
import { posix, win32 } from "node:path";
|
|
9
|
-
export function
|
|
11
|
+
export function readProcessLiveness(pid, probe = process.kill.bind(process)) {
|
|
12
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
13
|
+
return "unknown";
|
|
10
14
|
try {
|
|
11
|
-
|
|
12
|
-
return true;
|
|
15
|
+
return probe(pid, 0) === true ? "alive" : "unknown";
|
|
13
16
|
}
|
|
14
|
-
catch {
|
|
15
|
-
return
|
|
17
|
+
catch (error) {
|
|
18
|
+
return error?.code === "ESRCH" ? "dead" : "unknown";
|
|
16
19
|
}
|
|
17
20
|
}
|
|
21
|
+
/** POSIX group presence only: neither ownership, membership completeness, nor whole-Run stop proof. */
|
|
22
|
+
export function readProcessGroupLiveness(processGroupId, runtimePlatform = platform(), probe = process.kill.bind(process)) {
|
|
23
|
+
if (runtimePlatform !== "linux" && runtimePlatform !== "darwin")
|
|
24
|
+
return "unknown";
|
|
25
|
+
return readProcessLiveness(processGroupId, (validatedId, signal) => probe(-validatedId, signal));
|
|
26
|
+
}
|
|
27
|
+
/** Unknown liveness must retain active-state guards, never authorize state reuse. */
|
|
28
|
+
export function isAlive(pid) {
|
|
29
|
+
return readProcessLiveness(pid) !== "dead";
|
|
30
|
+
}
|
|
18
31
|
function readLinuxIdentity(pid) {
|
|
19
32
|
if (!existsSync(`/proc/${pid}`))
|
|
20
33
|
return undefined;
|
|
@@ -51,24 +64,67 @@ function readDarwinIdentity(pid) {
|
|
|
51
64
|
}
|
|
52
65
|
function readWindowsIdentity(pid) {
|
|
53
66
|
const command = [
|
|
54
|
-
`$p = Get-CimInstance Win32_Process -Filter \"ProcessId = ${pid}\";`,
|
|
55
|
-
"if ($null -eq $p) { exit 3 };",
|
|
67
|
+
`$p = Get-CimInstance Win32_Process -Property CreationDate,ExecutablePath,CommandLine -Filter \"ProcessId = ${pid}\";`,
|
|
68
|
+
"if ($null -eq $p) { exit 3 }; [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false, $true);",
|
|
56
69
|
"$p | Select-Object CreationDate,ExecutablePath,CommandLine | ConvertTo-Json -Compress",
|
|
57
70
|
].join(" ");
|
|
58
71
|
const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], { encoding: "utf8", windowsHide: true });
|
|
59
72
|
if (result.status !== 0)
|
|
60
73
|
return undefined;
|
|
61
74
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
return decodeWindowsIdentity(JSON.parse(result.stdout));
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function decodeWindowsIdentity(value) {
|
|
82
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
83
|
+
return undefined;
|
|
84
|
+
const row = value;
|
|
85
|
+
if (typeof row.CreationDate !== "string")
|
|
86
|
+
return undefined;
|
|
87
|
+
const executable = typeof row.ExecutablePath === "string" ? row.ExecutablePath : "";
|
|
88
|
+
const commandLine = typeof row.CommandLine === "string" ? row.CommandLine : "";
|
|
89
|
+
return { command: `${executable}\n${commandLine}`.trim(), platform: "win32", start_time: row.CreationDate };
|
|
90
|
+
}
|
|
91
|
+
export const WINDOWS_IDENTITY_QUERY_PID_LIMIT = 64;
|
|
92
|
+
const WINDOWS_IDENTITY_QUERY_MAX_BYTES = 1024 * 1024;
|
|
93
|
+
/** One bounded, complete CIM observation; undefined means query failure, never process absence. */
|
|
94
|
+
export function readWindowsProcessIdentities(pids) {
|
|
95
|
+
if (!pids.length || pids.length > WINDOWS_IDENTITY_QUERY_PID_LIMIT || new Set(pids).size !== pids.length ||
|
|
96
|
+
pids.some(pid => !Number.isSafeInteger(pid) || pid <= 0))
|
|
97
|
+
return undefined;
|
|
98
|
+
// 64 safe integers (at most 16 digits) keep this ASCII command below 4096 characters,
|
|
99
|
+
// independently of native output. No shell, encoded command, or widened process scan.
|
|
100
|
+
const command = ['$ErrorActionPreference = "Stop";',
|
|
101
|
+
`$p = Get-CimInstance Win32_Process -Property ProcessId,CreationDate,ExecutablePath,CommandLine -Filter "${pids.map(pid => `ProcessId = ${pid}`).join(" OR ")}";`,
|
|
102
|
+
"[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false, $true); ConvertTo-Json -InputObject @($p | Select-Object ProcessId,CreationDate,ExecutablePath,CommandLine) -Compress"].join(" ");
|
|
103
|
+
if (command.length > 4096)
|
|
104
|
+
return undefined;
|
|
105
|
+
try {
|
|
106
|
+
const result = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", command], { encoding: "utf8", windowsHide: true, maxBuffer: WINDOWS_IDENTITY_QUERY_MAX_BYTES });
|
|
107
|
+
if (result.error || result.signal || result.status !== 0 || typeof result.stdout !== "string" ||
|
|
108
|
+
result.stdout.length > WINDOWS_IDENTITY_QUERY_MAX_BYTES || Buffer.byteLength(result.stdout) > WINDOWS_IDENTITY_QUERY_MAX_BYTES)
|
|
64
109
|
return undefined;
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
110
|
+
// Parse the entire bounded output, not a clipped prefix. Every row must correlate exactly once.
|
|
111
|
+
const rows = JSON.parse(result.stdout);
|
|
112
|
+
if (!Array.isArray(rows) || rows.length > pids.length)
|
|
113
|
+
return undefined;
|
|
114
|
+
const selected = new Set(pids);
|
|
115
|
+
const identities = new Map();
|
|
116
|
+
for (const row of rows) {
|
|
117
|
+
if (!row || typeof row !== "object" || Array.isArray(row))
|
|
118
|
+
return undefined;
|
|
119
|
+
const pid = row.ProcessId;
|
|
120
|
+
if (typeof pid !== "number" || !selected.has(pid) || identities.has(pid))
|
|
121
|
+
return undefined;
|
|
122
|
+
const identity = decodeWindowsIdentity(row);
|
|
123
|
+
if (!identity)
|
|
124
|
+
return undefined;
|
|
125
|
+
identities.set(pid, identity);
|
|
126
|
+
}
|
|
127
|
+
return identities;
|
|
72
128
|
}
|
|
73
129
|
catch {
|
|
74
130
|
return undefined;
|
|
@@ -83,26 +139,83 @@ export function readProcessIdentity(pid, runtimePlatform = platform()) {
|
|
|
83
139
|
return readWindowsIdentity(pid);
|
|
84
140
|
return undefined;
|
|
85
141
|
}
|
|
86
|
-
export function
|
|
87
|
-
|
|
88
|
-
if (!identity)
|
|
142
|
+
export function runProcessIdentityDigest(value) {
|
|
143
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
89
144
|
return undefined;
|
|
90
|
-
|
|
145
|
+
const identity = value;
|
|
146
|
+
if (typeof identity.platform !== "string" || !["linux", "darwin", "win32"].includes(identity.platform) ||
|
|
147
|
+
typeof identity.start_time !== "string" || !identity.start_time ||
|
|
148
|
+
typeof identity.command !== "string" || !identity.command ||
|
|
149
|
+
(identity.cwd !== undefined && typeof identity.cwd !== "string"))
|
|
91
150
|
return undefined;
|
|
92
|
-
|
|
151
|
+
return createHash("sha256").update(JSON.stringify([
|
|
152
|
+
identity.platform, identity.start_time, identity.command, identity.cwd ?? null,
|
|
153
|
+
])).digest("hex");
|
|
154
|
+
}
|
|
155
|
+
function matchesRunCwd(identity, cwd, runtimePlatform) {
|
|
93
156
|
const pathApi = runtimePlatform === "win32" ? win32 : posix;
|
|
94
157
|
const resolvedCwd = pathApi.resolve(cwd);
|
|
95
158
|
const canonicalCwd = runtimePlatform === platform() && existsSync(resolvedCwd)
|
|
96
159
|
? realpathSync.native(resolvedCwd)
|
|
97
160
|
: resolvedCwd;
|
|
98
161
|
const expectedCwd = runtimePlatform === "win32" ? canonicalCwd.toLowerCase() : canonicalCwd;
|
|
99
|
-
const actualCwd = runtimePlatform === "win32" && identity.cwd
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
162
|
+
const actualCwd = runtimePlatform === "win32" && identity.cwd ? identity.cwd.toLowerCase() : identity.cwd;
|
|
163
|
+
return !actualCwd || actualCwd === expectedCwd;
|
|
164
|
+
}
|
|
165
|
+
export function captureRunProcessIdentity(pid, cwd, stateDir, runnerPath, runtimePlatform = platform(), reader = readProcessIdentity) {
|
|
166
|
+
const identity = reader(pid, runtimePlatform);
|
|
167
|
+
if (!identity || !identity.command.includes(runnerPath) || !identity.command.includes(stateDir) ||
|
|
168
|
+
!matchesRunCwd(identity, cwd, runtimePlatform))
|
|
103
169
|
return undefined;
|
|
104
170
|
return identity;
|
|
105
171
|
}
|
|
172
|
+
/** Fresh spawn only, while its lifecycle lock/child handle is retained and workload is not admitted. */
|
|
173
|
+
export function captureSpawnedRunProcessIdentity(child, cwd, stateDir, runnerPath, deps = {}) {
|
|
174
|
+
return captureFreshProcessIdentity(child, deps, (current, runtimePlatform) => captureRunProcessIdentity(child.pid, cwd, stateDir, runnerPath, runtimePlatform, () => current), (current, runtimePlatform) => matchesRunCwd(current, cwd, runtimePlatform));
|
|
175
|
+
}
|
|
176
|
+
/** Immediate managed-native callback only; this observation is not complete membership or termination authority. */
|
|
177
|
+
export function captureSpawnedNativeProcessIdentity(child, deps = {}) {
|
|
178
|
+
const runtimePlatform = deps.runtimePlatform ?? platform();
|
|
179
|
+
if (!["linux", "darwin", "win32"].includes(runtimePlatform))
|
|
180
|
+
return undefined;
|
|
181
|
+
return captureFreshProcessIdentity(child, deps, (current) => current, () => true);
|
|
182
|
+
}
|
|
183
|
+
function captureFreshProcessIdentity(child, deps, accept, acceptEmpty) {
|
|
184
|
+
const pid = child.pid;
|
|
185
|
+
if (!Number.isSafeInteger(pid) || !pid || pid <= 0)
|
|
186
|
+
return undefined;
|
|
187
|
+
const runtimePlatform = deps.runtimePlatform ?? platform();
|
|
188
|
+
const read = deps.readIdentity ?? readProcessIdentity;
|
|
189
|
+
const now = deps.now ?? (() => performance.now());
|
|
190
|
+
const wait = deps.wait ?? ((ms) => { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); });
|
|
191
|
+
const started = now();
|
|
192
|
+
let birth;
|
|
193
|
+
// Bound startup retries, not OS probe latency; never retry an observed contradiction.
|
|
194
|
+
for (let attempt = 0; attempt <= 100; attempt++) {
|
|
195
|
+
if (child.pid !== pid || child.exitCode !== null || child.signalCode !== null)
|
|
196
|
+
return undefined;
|
|
197
|
+
const current = read(pid, runtimePlatform);
|
|
198
|
+
if (child.pid !== pid || child.exitCode !== null || child.signalCode !== null)
|
|
199
|
+
return undefined;
|
|
200
|
+
if (current) {
|
|
201
|
+
if (current.platform !== runtimePlatform || typeof current.start_time !== "string" || !current.start_time ||
|
|
202
|
+
typeof current.command !== "string" || (current.cwd !== undefined && (typeof current.cwd !== "string" || !current.cwd)) ||
|
|
203
|
+
(birth !== undefined && current.start_time !== birth))
|
|
204
|
+
return undefined;
|
|
205
|
+
birth = current.start_time;
|
|
206
|
+
if (current.command) {
|
|
207
|
+
return accept({ ...current }, runtimePlatform);
|
|
208
|
+
}
|
|
209
|
+
if (!acceptEmpty(current, runtimePlatform))
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const elapsed = now() - started;
|
|
213
|
+
if (!Number.isFinite(elapsed) || elapsed < 0 || elapsed >= 500)
|
|
214
|
+
return undefined;
|
|
215
|
+
wait(Math.min(5, 500 - elapsed));
|
|
216
|
+
}
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
106
219
|
export function verifyRunProcessIdentity(pid, expected, runtimePlatform = platform(), reader = readProcessIdentity, alive = isAlive) {
|
|
107
220
|
if (!alive(pid))
|
|
108
221
|
return { status: "dead_pid", valid: false };
|
|
@@ -117,6 +230,25 @@ export function verifyRunProcessIdentity(pid, expected, runtimePlatform = platfo
|
|
|
117
230
|
current.cwd === expected.cwd;
|
|
118
231
|
return { status: valid ? "valid" : "owner_mismatch", valid };
|
|
119
232
|
}
|
|
233
|
+
/** Observes one captured process only; signal dispatch and descendant cleanup are separate facts. */
|
|
234
|
+
export function observeRunProcessExit(pid, expected, deps = {}) {
|
|
235
|
+
const runtimePlatform = deps.runtimePlatform ?? platform();
|
|
236
|
+
if (!expected || expected.platform !== runtimePlatform ||
|
|
237
|
+
typeof expected.command !== "string" || !expected.command ||
|
|
238
|
+
typeof expected.start_time !== "string" || !expected.start_time ||
|
|
239
|
+
(expected.cwd !== undefined && typeof expected.cwd !== "string")) {
|
|
240
|
+
return { status: "unproven", process_identity_status: "unsupported_proof" };
|
|
241
|
+
}
|
|
242
|
+
const liveness = readProcessLiveness(pid, deps.probe);
|
|
243
|
+
if (liveness === "unknown") {
|
|
244
|
+
return { status: "unproven", process_identity_status: "unsupported_proof" };
|
|
245
|
+
}
|
|
246
|
+
const identity = verifyRunProcessIdentity(pid, expected, runtimePlatform, deps.readIdentity ?? readProcessIdentity, () => liveness === "alive");
|
|
247
|
+
return {
|
|
248
|
+
status: identity.status === "dead_pid" ? "exited" : identity.valid ? "running" : "unproven",
|
|
249
|
+
process_identity_status: identity.status,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
120
252
|
export function isWithinRunnerIdentityGrace(meta, graceMs) {
|
|
121
253
|
const createdAt = typeof meta.createdAt === "string" ? Date.parse(meta.createdAt) : NaN;
|
|
122
254
|
return (Number.isFinite(createdAt) &&
|