pi-daddy 0.28.0 → 0.32.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 +99 -124
- package/README.md +18 -896
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/contracts/ledger-record/v1/README.md +44 -0
- package/contracts/ledger-record/v1/fixtures/child-lifecycle.json +45 -0
- package/contracts/ledger-record/v1/fixtures/ledger-record.jsonl +3 -0
- package/contracts/ledger-record/v1/governance-event.schema.json +747 -0
- package/contracts/ledger-record/v1/record.schema.json +91 -0
- package/dist/cli.d.ts +6 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +108 -103
- package/dist/cli.js.map +1 -1
- package/dist/executors/activity-session.d.ts +12 -0
- package/dist/executors/activity-session.d.ts.map +1 -0
- package/dist/executors/activity-session.js +43 -0
- package/dist/executors/activity-session.js.map +1 -0
- package/dist/executors/executor.d.ts +39 -0
- package/dist/executors/executor.d.ts.map +1 -0
- package/dist/executors/executor.js +95 -0
- package/dist/executors/executor.js.map +1 -0
- package/dist/executors/herdr-cli.d.ts +78 -0
- package/dist/executors/herdr-cli.d.ts.map +1 -0
- package/dist/executors/herdr-cli.js +114 -0
- package/dist/executors/herdr-cli.js.map +1 -0
- package/dist/executors/herdr-name.d.ts.map +1 -0
- package/dist/executors/herdr-name.js.map +1 -0
- package/dist/executors/herdr-pi-lifecycle.d.ts.map +1 -0
- package/dist/executors/herdr-pi-lifecycle.js +22 -0
- package/dist/executors/herdr-pi-lifecycle.js.map +1 -0
- package/dist/executors/herdr-poll.d.ts +140 -0
- package/dist/executors/herdr-poll.d.ts.map +1 -0
- package/dist/executors/herdr-poll.js +252 -0
- package/dist/executors/herdr-poll.js.map +1 -0
- package/dist/executors/herdr-stage.d.ts +40 -0
- package/dist/executors/herdr-stage.d.ts.map +1 -0
- package/dist/executors/herdr-stage.js +54 -0
- package/dist/executors/herdr-stage.js.map +1 -0
- package/dist/executors/herdr-start.d.ts.map +1 -0
- package/dist/executors/herdr-start.js.map +1 -0
- package/dist/executors/native-session-target.d.ts +9 -0
- package/dist/executors/native-session-target.d.ts.map +1 -0
- package/dist/executors/native-session-target.js +30 -0
- package/dist/executors/native-session-target.js.map +1 -0
- package/dist/executors/pane-reaper.d.ts +111 -0
- package/dist/executors/pane-reaper.d.ts.map +1 -0
- package/dist/executors/pane-reaper.js +242 -0
- package/dist/executors/pane-reaper.js.map +1 -0
- package/dist/executors/process-activity.d.ts +3 -0
- package/dist/executors/process-activity.d.ts.map +1 -0
- package/dist/executors/process-activity.js +59 -0
- package/dist/executors/process-activity.js.map +1 -0
- package/dist/executors/run-herdr.d.ts +122 -0
- package/dist/executors/run-herdr.d.ts.map +1 -0
- package/dist/executors/run-herdr.js +341 -0
- package/dist/executors/run-herdr.js.map +1 -0
- package/dist/executors/vendor/herdr-pi-lifecycle.d.ts.map +1 -0
- package/dist/executors/vendor/herdr-pi-lifecycle.js.map +1 -0
- package/dist/governance/approval-prompt.d.ts +119 -0
- package/dist/governance/approval-prompt.d.ts.map +1 -0
- package/dist/governance/approval-prompt.js +133 -0
- package/dist/governance/approval-prompt.js.map +1 -0
- package/dist/governance/approval-store.d.ts +149 -0
- package/dist/governance/approval-store.d.ts.map +1 -0
- package/dist/governance/approval-store.js +309 -0
- package/dist/governance/approval-store.js.map +1 -0
- package/dist/governance/execution-retention.d.ts +90 -0
- package/dist/governance/execution-retention.d.ts.map +1 -0
- package/dist/governance/execution-retention.js +317 -0
- package/dist/governance/execution-retention.js.map +1 -0
- package/dist/governance/file-lock.d.ts.map +1 -0
- package/dist/governance/file-lock.js +205 -0
- package/dist/governance/file-lock.js.map +1 -0
- package/dist/governance/finalization.d.ts.map +1 -0
- package/dist/governance/finalization.js.map +1 -0
- package/dist/governance/grant-store.d.ts +96 -0
- package/dist/governance/grant-store.d.ts.map +1 -0
- package/dist/governance/grant-store.js +186 -0
- package/dist/governance/grant-store.js.map +1 -0
- package/dist/governance/init.d.ts +129 -0
- package/dist/governance/init.d.ts.map +1 -0
- package/dist/governance/init.js +360 -0
- package/dist/governance/init.js.map +1 -0
- package/dist/governance/lease-helper.d.ts.map +1 -0
- package/dist/governance/lease-helper.js +121 -0
- package/dist/governance/lease-helper.js.map +1 -0
- package/dist/governance/lease-record.d.ts +90 -0
- package/dist/governance/lease-record.d.ts.map +1 -0
- package/dist/governance/lease-record.js.map +1 -0
- package/dist/governance/ledger-events.d.ts +111 -0
- package/dist/governance/ledger-events.d.ts.map +1 -0
- package/dist/governance/ledger-events.js +129 -0
- package/dist/governance/ledger-events.js.map +1 -0
- package/dist/governance/ledger-report.d.ts +134 -0
- package/dist/governance/ledger-report.d.ts.map +1 -0
- package/dist/governance/ledger-report.js +294 -0
- package/dist/governance/ledger-report.js.map +1 -0
- package/dist/governance/ledger-v3-validation.d.ts +21 -0
- package/dist/governance/ledger-v3-validation.d.ts.map +1 -0
- package/dist/governance/ledger-v3-validation.js +353 -0
- package/dist/governance/ledger-v3-validation.js.map +1 -0
- package/dist/governance/ledger.d.ts +258 -0
- package/dist/governance/ledger.d.ts.map +1 -0
- package/dist/governance/ledger.js +201 -0
- package/dist/governance/ledger.js.map +1 -0
- package/dist/governance/native-session.d.ts +59 -0
- package/dist/governance/native-session.d.ts.map +1 -0
- package/dist/governance/native-session.js +208 -0
- package/dist/governance/native-session.js.map +1 -0
- package/dist/governance/record.d.ts +65 -0
- package/dist/governance/record.d.ts.map +1 -0
- package/dist/governance/record.js +259 -0
- package/dist/governance/record.js.map +1 -0
- package/dist/governance/retention-contract.d.ts.map +1 -0
- package/dist/governance/retention-contract.js +187 -0
- package/dist/governance/retention-contract.js.map +1 -0
- package/dist/governance/retention-json.d.ts.map +1 -0
- package/dist/governance/retention-json.js.map +1 -0
- package/dist/governance/workspace-lease.d.ts +40 -0
- package/dist/governance/workspace-lease.d.ts.map +1 -0
- package/dist/governance/workspace-lease.js +357 -0
- package/dist/governance/workspace-lease.js.map +1 -0
- package/dist/index.d.ts +59 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -42
- package/dist/index.js.map +1 -1
- package/dist/kernel/approval.d.ts +241 -0
- package/dist/kernel/approval.d.ts.map +1 -0
- package/dist/kernel/approval.js +270 -0
- package/dist/kernel/approval.js.map +1 -0
- package/dist/kernel/capabilities.d.ts +136 -0
- package/dist/kernel/capabilities.d.ts.map +1 -0
- package/dist/kernel/capabilities.js +199 -0
- package/dist/kernel/capabilities.js.map +1 -0
- package/dist/kernel/catalog.d.ts +98 -0
- package/dist/kernel/catalog.d.ts.map +1 -0
- package/dist/kernel/catalog.js +280 -0
- package/dist/kernel/catalog.js.map +1 -0
- package/dist/kernel/chain.d.ts.map +1 -0
- package/dist/kernel/chain.js.map +1 -0
- package/dist/kernel/correlation.d.ts.map +1 -0
- package/dist/kernel/correlation.js +267 -0
- package/dist/kernel/correlation.js.map +1 -0
- package/dist/kernel/definitions.d.ts.map +1 -0
- package/dist/kernel/definitions.js +164 -0
- package/dist/kernel/definitions.js.map +1 -0
- package/dist/kernel/delegate-types.d.ts +160 -0
- package/dist/kernel/delegate-types.d.ts.map +1 -0
- package/dist/kernel/delegate-types.js +9 -0
- package/dist/kernel/delegate-types.js.map +1 -0
- package/dist/kernel/delegate.d.ts.map +1 -0
- package/dist/kernel/delegate.js +314 -0
- package/dist/kernel/delegate.js.map +1 -0
- package/dist/kernel/delegation-approval.d.ts.map +1 -0
- package/dist/kernel/delegation-approval.js +93 -0
- package/dist/kernel/delegation-approval.js.map +1 -0
- package/dist/kernel/env-names.d.ts +51 -0
- package/dist/kernel/env-names.d.ts.map +1 -0
- package/dist/kernel/env-names.js +112 -0
- package/dist/kernel/env-names.js.map +1 -0
- package/dist/kernel/execution-id.d.ts.map +1 -0
- package/dist/kernel/execution-id.js.map +1 -0
- package/dist/kernel/fanout.d.ts.map +1 -0
- package/dist/kernel/fanout.js +93 -0
- package/dist/kernel/fanout.js.map +1 -0
- package/dist/kernel/grant-env.d.ts +118 -0
- package/dist/kernel/grant-env.d.ts.map +1 -0
- package/dist/kernel/grant-env.js +104 -0
- package/dist/kernel/grant-env.js.map +1 -0
- package/dist/kernel/ledger-identifiers.d.ts.map +1 -0
- package/dist/kernel/ledger-identifiers.js.map +1 -0
- package/dist/kernel/model-preflight.d.ts +13 -0
- package/dist/kernel/model-preflight.d.ts.map +1 -0
- package/dist/kernel/model-preflight.js +30 -0
- package/dist/kernel/model-preflight.js.map +1 -0
- package/dist/kernel/pi-tools.d.ts.map +1 -0
- package/dist/kernel/pi-tools.js +29 -0
- package/dist/kernel/pi-tools.js.map +1 -0
- package/dist/kernel/progress.d.ts.map +1 -0
- package/dist/kernel/progress.js.map +1 -0
- package/dist/kernel/project-paths.d.ts +43 -0
- package/dist/kernel/project-paths.d.ts.map +1 -0
- package/dist/kernel/project-paths.js +81 -0
- package/dist/kernel/project-paths.js.map +1 -0
- package/dist/kernel/propagation.d.ts +195 -0
- package/dist/kernel/propagation.d.ts.map +1 -0
- package/dist/kernel/propagation.js +275 -0
- package/dist/kernel/propagation.js.map +1 -0
- package/dist/kernel/refusals.d.ts +16 -0
- package/dist/kernel/refusals.d.ts.map +1 -0
- package/dist/kernel/refusals.js +53 -0
- package/dist/kernel/refusals.js.map +1 -0
- package/dist/kernel/resolve.d.ts.map +1 -0
- package/dist/kernel/resolve.js +201 -0
- package/dist/kernel/resolve.js.map +1 -0
- package/dist/kernel/routing-authority.d.ts.map +1 -0
- package/dist/kernel/routing-authority.js.map +1 -0
- package/dist/kernel/run-child.d.ts +111 -0
- package/dist/kernel/run-child.d.ts.map +1 -0
- package/dist/kernel/run-child.js +324 -0
- package/dist/kernel/run-child.js.map +1 -0
- package/dist/kernel/skill-packages.d.ts +116 -0
- package/dist/kernel/skill-packages.d.ts.map +1 -0
- package/dist/kernel/skill-packages.js +300 -0
- package/dist/kernel/skill-packages.js.map +1 -0
- package/dist/kernel/skill-resources.d.ts.map +1 -0
- package/dist/kernel/skill-resources.js +56 -0
- package/dist/kernel/skill-resources.js.map +1 -0
- package/dist/kernel/spawn.d.ts.map +1 -0
- package/dist/kernel/spawn.js.map +1 -0
- package/dist/kernel/workspace.d.ts +51 -0
- package/dist/kernel/workspace.d.ts.map +1 -0
- package/dist/kernel/workspace.js +223 -0
- package/dist/kernel/workspace.js.map +1 -0
- package/dist/products/activity-timeline.d.ts +126 -0
- package/dist/products/activity-timeline.d.ts.map +1 -0
- package/dist/products/activity-timeline.js +542 -0
- package/dist/products/activity-timeline.js.map +1 -0
- package/dist/products/dashboard-cli.d.ts +26 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -0
- package/dist/products/dashboard-cli.js +224 -0
- package/dist/products/dashboard-cli.js.map +1 -0
- package/dist/products/dashboard-display-controls.d.ts +17 -0
- package/dist/products/dashboard-display-controls.d.ts.map +1 -0
- package/dist/products/dashboard-display-controls.js +38 -0
- package/dist/products/dashboard-display-controls.js.map +1 -0
- package/dist/products/dashboard-handshake.d.ts +42 -0
- package/dist/products/dashboard-handshake.d.ts.map +1 -0
- package/dist/products/dashboard-handshake.js +158 -0
- package/dist/products/dashboard-handshake.js.map +1 -0
- package/dist/products/dashboard-herdr.d.ts +55 -0
- package/dist/products/dashboard-herdr.d.ts.map +1 -0
- package/dist/products/dashboard-herdr.js +324 -0
- package/dist/products/dashboard-herdr.js.map +1 -0
- package/dist/products/dashboard-projection.d.ts +62 -0
- package/dist/products/dashboard-projection.d.ts.map +1 -0
- package/dist/products/dashboard-projection.js +305 -0
- package/dist/products/dashboard-projection.js.map +1 -0
- package/dist/products/dashboard-render.d.ts.map +1 -0
- package/dist/products/dashboard-render.js +208 -0
- package/dist/products/dashboard-render.js.map +1 -0
- package/extensions/activity-timeline.ts +134 -28
- package/extensions/approval-banking.ts +3 -3
- package/extensions/approvals.ts +18 -12
- package/extensions/chain-approval-facts.ts +9 -6
- package/extensions/chain-ledger.ts +4 -4
- package/extensions/chain-plan.ts +6 -6
- package/extensions/correlation-shape.ts +42 -33
- package/extensions/delegate-chain.ts +93 -45
- package/extensions/delegation-authority.ts +7 -3
- package/extensions/delegation-ledger.ts +2 -2
- package/extensions/delegation-native.ts +24 -7
- package/extensions/delegation.ts +91 -80
- package/extensions/execute-child.ts +440 -293
- package/extensions/execution-occurrence.ts +2 -2
- package/extensions/executor-session.ts +5 -5
- package/extensions/fanout-outcome.ts +8 -6
- package/extensions/grant-store-refusal.ts +24 -12
- package/extensions/grants-command.ts +41 -33
- package/extensions/grants-connected-command.ts +29 -15
- package/extensions/grants.ts +73 -73
- package/extensions/init-command.ts +18 -12
- package/extensions/reload-environment.ts +12 -5
- package/extensions/run-delegation.ts +29 -19
- package/extensions/session-environment.ts +25 -11
- package/extensions/session-report.ts +60 -11
- package/extensions/session.ts +58 -34
- package/extensions/spawn-summary.ts +5 -5
- package/extensions/stored-grant-session.ts +5 -5
- package/extensions/tripwire.ts +1 -1
- package/extensions/workspace-runtime.ts +26 -24
- package/herdr-plugin/herdr-plugin.toml +1 -1
- package/package.json +4 -211
- package/src/cli.ts +136 -89
- package/src/executors/activity-session.ts +54 -0
- package/src/executors/executor.ts +123 -0
- package/src/executors/herdr-cli.ts +132 -0
- package/src/executors/herdr-pi-lifecycle.ts +21 -0
- package/src/executors/herdr-poll.ts +305 -0
- package/src/executors/herdr-stage.ts +55 -0
- package/src/executors/native-session-target.ts +31 -0
- package/src/executors/pane-reaper.ts +270 -0
- package/src/executors/process-activity.ts +54 -0
- package/src/executors/run-herdr.ts +426 -0
- package/src/governance/approval-prompt.ts +225 -0
- package/src/governance/approval-store.ts +385 -0
- package/src/governance/execution-retention.ts +372 -0
- package/src/governance/file-lock.ts +210 -0
- package/src/governance/finalization.ts +82 -0
- package/src/governance/grant-store.ts +235 -0
- package/src/governance/init.ts +447 -0
- package/src/governance/lease-helper.ts +124 -0
- package/src/governance/lease-record.ts +131 -0
- package/src/governance/ledger-events.ts +222 -0
- package/src/governance/ledger-report.ts +396 -0
- package/src/governance/ledger-v3-validation.ts +384 -0
- package/src/governance/ledger.ts +419 -0
- package/src/governance/native-session.ts +264 -0
- package/src/governance/record.ts +294 -0
- package/src/governance/retention-contract.ts +201 -0
- package/src/governance/retention-json.ts +24 -0
- package/src/governance/workspace-lease.ts +429 -0
- package/src/index.ts +82 -92
- package/src/kernel/approval.ts +406 -0
- package/src/kernel/capabilities.ts +216 -0
- package/src/kernel/catalog.ts +313 -0
- package/src/kernel/correlation.ts +351 -0
- package/src/kernel/definitions.ts +215 -0
- package/src/kernel/delegate-types.ts +162 -0
- package/src/kernel/delegate.ts +370 -0
- package/src/kernel/delegation-approval.ts +126 -0
- package/src/kernel/env-names.ts +119 -0
- package/src/kernel/fanout.ts +106 -0
- package/src/kernel/grant-env.ts +174 -0
- package/src/kernel/model-preflight.ts +44 -0
- package/src/kernel/pi-tools.ts +32 -0
- package/src/kernel/project-paths.ts +97 -0
- package/src/kernel/propagation.ts +341 -0
- package/src/kernel/refusals.ts +64 -0
- package/src/kernel/resolve.ts +258 -0
- package/src/kernel/run-child.ts +418 -0
- package/src/kernel/skill-packages.ts +329 -0
- package/src/kernel/skill-resources.ts +64 -0
- package/src/kernel/workspace.ts +336 -0
- package/src/products/activity-timeline.ts +679 -0
- package/src/products/dashboard-cli.ts +250 -0
- package/src/products/dashboard-display-controls.ts +44 -0
- package/src/products/dashboard-handshake.ts +222 -0
- package/src/products/dashboard-herdr.ts +427 -0
- package/src/products/dashboard-projection.ts +389 -0
- package/src/products/dashboard-render.ts +260 -0
- package/PRODUCT-GUIDE.md +0 -155
- package/REQUIREMENTS.md +0 -41
- package/contracts/daily-view/v1/README.md +0 -114
- package/contracts/daily-view/v1/fixtures/view.json +0 -525
- package/contracts/daily-view/v1/fixtures/view.txt +0 -75
- package/contracts/daily-view/v1/fixtures/work.jsonl +0 -17
- package/contracts/daily-view/v1/p03/README.md +0 -26
- package/contracts/daily-view/v1/p03/fixtures/retained-executions.json +0 -241
- package/contracts/daily-view/v1/p03/projection.schema.json +0 -194
- package/contracts/daily-view/v1/p03/provenance.json +0 -21
- package/contracts/dashboard-host/v1/README.md +0 -176
- package/contracts/debrief/v1/README.md +0 -146
- package/contracts/debrief/v1/intervention/README.md +0 -32
- package/contracts/debrief/v1/intervention/fixtures/artifact-3ee11136beb864f518252e5024dae9197421fbf97b6e981d3243c782b5c44bd0.txt +0 -1
- package/contracts/debrief/v1/intervention/fixtures/artifact-58905d872dd3c54a9705f67b05fa82edbad7af6476ae8993faf1a7b9fadfb905.txt +0 -1
- package/contracts/debrief/v1/intervention/fixtures/assessment.json +0 -29
- package/contracts/debrief/v1/intervention/fixtures/blind-view.json +0 -20
- package/contracts/debrief/v1/intervention/fixtures/choice.json +0 -7
- package/contracts/debrief/v1/intervention/fixtures/manifest.json +0 -57
- package/contracts/debrief/v1/intervention/fixtures/reveal.json +0 -39
- package/contracts/debrief/v1/provenance.json +0 -89
- package/contracts/debrief/v1/work-capture/README.md +0 -38
- package/contracts/debrief/v1/work-capture/fixtures/batch.json +0 -17
- package/contracts/debrief/v1/work-capture/fixtures/cases.json +0 -184
- package/contracts/debrief/v1/work-capture/fixtures/review.json +0 -184
- package/contracts/debrief/v1/work-capture/review-request.schema.json +0 -41
- package/contracts/debrief/v1/work-capture/work-case.schema.json +0 -190
- package/contracts/debrief/v2/README.md +0 -71
- package/contracts/debrief/v2/input-pin.json +0 -66
- package/contracts/debrief/v2/intervention-upstream.md +0 -40
- package/contracts/debrief/v2/work-signals-upstream.md +0 -22
- package/contracts/dispatch-control/v1/README.md +0 -109
- package/contracts/dispatch-control/v1/request.schema.json +0 -19
- package/contracts/effect-profile/v1/README.md +0 -124
- package/contracts/execution-retention/v1/README.md +0 -109
- package/contracts/execution-retention/v2/README.md +0 -148
- package/contracts/execution-retention/v2/fixtures/interrupted-native-bytes.json +0 -91
- package/contracts/execution-retention/v2/fixtures/missing-native-session.json +0 -91
- package/contracts/execution-retention/v2/fixtures/native-file-unknown-branch.json +0 -91
- package/contracts/execution-retention/v2/fixtures/native-id-without-bytes.json +0 -91
- package/contracts/execution-retention/v2/fixtures/native-live-branch.json +0 -90
- package/contracts/execution-retention/v2/fixtures/replaced-native-session.json +0 -92
- package/contracts/execution-retention/v2/fixtures/result-82c620cdfeb8ca6b858cf653d7f5e2eedca5315d6244216d60e8b36f03223d6a.bin +0 -1
- package/contracts/execution-retention/v2/fixtures/session-2ec1f134bc739984434f7fca689e1c3d1c39fce2dcadae709e9b6faedfcc4ac7.bin +0 -3
- package/contracts/execution-retention/v2/fixtures/session-9bdb4bd16a901da31580acf056bda525225259e15ec409e0410480109011772f.bin +0 -3
- package/contracts/execution-retention/v2/manifest.schema.json +0 -858
- package/contracts/experiment/v1/README.md +0 -164
- package/contracts/factory-order/v1/README.md +0 -151
- package/contracts/factory-order/v1/adoption-pin.json +0 -8
- package/contracts/intent-control/v1/README.md +0 -135
- package/contracts/intent-control/v1/request.schema.json +0 -1096
- package/contracts/intent-control/v2/README.md +0 -34
- package/contracts/intent-control/v2/request.schema.json +0 -1070
- package/contracts/ledger/v2/README.md +0 -59
- package/contracts/ledger/v2/fixtures/capability-decision.json +0 -95
- package/contracts/ledger/v2/fixtures/check-receipt.json +0 -40
- package/contracts/ledger/v2/fixtures/child-lifecycle.json +0 -42
- package/contracts/ledger/v2/fixtures/workspace-lease.json +0 -41
- package/contracts/ledger/v2/ledger-event.schema.json +0 -633
- package/contracts/ledger/v3/README.md +0 -36
- package/contracts/ledger/v3/fixtures/check-receipt.json +0 -41
- package/contracts/ledger/v3/fixtures/child-lifecycle.json +0 -44
- package/contracts/ledger/v3/fixtures/workflow-fact.json +0 -40
- package/contracts/ledger/v3/ledger-event.schema.json +0 -955
- package/contracts/ledger/v4/README.md +0 -241
- package/contracts/ledger/v4/fixtures/layout-options.json +0 -428
- package/contracts/ledger/v4/fixtures/work-acceptance.json +0 -57
- package/contracts/ledger/v4/fixtures/work-occurrence.json +0 -44
- package/contracts/ledger/v4/fixtures/work-revision.json +0 -26
- package/contracts/ledger/v4/fixtures/work-snapshot.json +0 -73
- package/contracts/ledger/v4/ledger-event.schema.json +0 -162
- package/contracts/ordinary-control/v1/README.md +0 -59
- package/contracts/producer-ipc/v1/README.md +0 -137
- package/dist/activity-timeline.d.ts +0 -109
- package/dist/activity-timeline.d.ts.map +0 -1
- package/dist/activity-timeline.js +0 -208
- package/dist/activity-timeline.js.map +0 -1
- package/dist/approval-prompt.d.ts +0 -119
- package/dist/approval-prompt.d.ts.map +0 -1
- package/dist/approval-prompt.js +0 -133
- package/dist/approval-prompt.js.map +0 -1
- package/dist/approval-store.d.ts +0 -149
- package/dist/approval-store.d.ts.map +0 -1
- package/dist/approval-store.js +0 -314
- package/dist/approval-store.js.map +0 -1
- package/dist/approval.d.ts +0 -241
- package/dist/approval.d.ts.map +0 -1
- package/dist/approval.js +0 -268
- package/dist/approval.js.map +0 -1
- package/dist/capabilities.d.ts +0 -136
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js +0 -203
- package/dist/capabilities.js.map +0 -1
- package/dist/catalog.d.ts +0 -98
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js +0 -273
- package/dist/catalog.js.map +0 -1
- package/dist/chain.d.ts.map +0 -1
- package/dist/chain.js.map +0 -1
- package/dist/check-runner.d.ts +0 -66
- package/dist/check-runner.d.ts.map +0 -1
- package/dist/check-runner.js +0 -275
- package/dist/check-runner.js.map +0 -1
- package/dist/control-journal.d.ts +0 -20
- package/dist/control-journal.d.ts.map +0 -1
- package/dist/control-journal.js +0 -73
- package/dist/control-journal.js.map +0 -1
- package/dist/correlation.d.ts.map +0 -1
- package/dist/correlation.js +0 -231
- package/dist/correlation.js.map +0 -1
- package/dist/daily-dashboard-host.d.ts +0 -136
- package/dist/daily-dashboard-host.d.ts.map +0 -1
- package/dist/daily-dashboard-host.js +0 -164
- package/dist/daily-dashboard-host.js.map +0 -1
- package/dist/daily-panel.d.ts +0 -36
- package/dist/daily-panel.d.ts.map +0 -1
- package/dist/daily-panel.js +0 -84
- package/dist/daily-panel.js.map +0 -1
- package/dist/daily-view-input.d.ts +0 -44
- package/dist/daily-view-input.d.ts.map +0 -1
- package/dist/daily-view-input.js +0 -68
- package/dist/daily-view-input.js.map +0 -1
- package/dist/daily-view-render.d.ts +0 -5
- package/dist/daily-view-render.d.ts.map +0 -1
- package/dist/daily-view-render.js +0 -42
- package/dist/daily-view-render.js.map +0 -1
- package/dist/daily-view.d.ts +0 -77
- package/dist/daily-view.d.ts.map +0 -1
- package/dist/daily-view.js +0 -176
- package/dist/daily-view.js.map +0 -1
- package/dist/dashboard-cli.d.ts +0 -54
- package/dist/dashboard-cli.d.ts.map +0 -1
- package/dist/dashboard-cli.js +0 -367
- package/dist/dashboard-cli.js.map +0 -1
- package/dist/dashboard-display-controls.d.ts +0 -15
- package/dist/dashboard-display-controls.d.ts.map +0 -1
- package/dist/dashboard-display-controls.js +0 -34
- package/dist/dashboard-display-controls.js.map +0 -1
- package/dist/dashboard-handshake.d.ts +0 -42
- package/dist/dashboard-handshake.d.ts.map +0 -1
- package/dist/dashboard-handshake.js +0 -147
- package/dist/dashboard-handshake.js.map +0 -1
- package/dist/dashboard-harness.d.ts +0 -22
- package/dist/dashboard-harness.d.ts.map +0 -1
- package/dist/dashboard-harness.js +0 -89
- package/dist/dashboard-harness.js.map +0 -1
- package/dist/dashboard-herdr.d.ts +0 -55
- package/dist/dashboard-herdr.d.ts.map +0 -1
- package/dist/dashboard-herdr.js +0 -293
- package/dist/dashboard-herdr.js.map +0 -1
- package/dist/dashboard-host-contract.d.ts +0 -127
- package/dist/dashboard-host-contract.d.ts.map +0 -1
- package/dist/dashboard-host-contract.js +0 -14
- package/dist/dashboard-host-contract.js.map +0 -1
- package/dist/dashboard-host-transport.d.ts +0 -16
- package/dist/dashboard-host-transport.d.ts.map +0 -1
- package/dist/dashboard-host-transport.js +0 -127
- package/dist/dashboard-host-transport.js.map +0 -1
- package/dist/dashboard-host.d.ts +0 -239
- package/dist/dashboard-host.d.ts.map +0 -1
- package/dist/dashboard-host.js +0 -474
- package/dist/dashboard-host.js.map +0 -1
- package/dist/dashboard-menu.d.ts +0 -16
- package/dist/dashboard-menu.d.ts.map +0 -1
- package/dist/dashboard-menu.js +0 -33
- package/dist/dashboard-menu.js.map +0 -1
- package/dist/dashboard-observation.d.ts +0 -28
- package/dist/dashboard-observation.d.ts.map +0 -1
- package/dist/dashboard-observation.js +0 -87
- package/dist/dashboard-observation.js.map +0 -1
- package/dist/dashboard-projection.d.ts +0 -73
- package/dist/dashboard-projection.d.ts.map +0 -1
- package/dist/dashboard-projection.js +0 -294
- package/dist/dashboard-projection.js.map +0 -1
- package/dist/dashboard-render.d.ts.map +0 -1
- package/dist/dashboard-render.js +0 -212
- package/dist/dashboard-render.js.map +0 -1
- package/dist/debrief-contract.d.ts +0 -65
- package/dist/debrief-contract.d.ts.map +0 -1
- package/dist/debrief-contract.js +0 -151
- package/dist/debrief-contract.js.map +0 -1
- package/dist/debrief-fixture.d.ts +0 -16
- package/dist/debrief-fixture.d.ts.map +0 -1
- package/dist/debrief-fixture.js +0 -41
- package/dist/debrief-fixture.js.map +0 -1
- package/dist/debrief-host.d.ts +0 -59
- package/dist/debrief-host.d.ts.map +0 -1
- package/dist/debrief-host.js +0 -49
- package/dist/debrief-host.js.map +0 -1
- package/dist/debrief-render.d.ts +0 -5
- package/dist/debrief-render.d.ts.map +0 -1
- package/dist/debrief-render.js +0 -65
- package/dist/debrief-render.js.map +0 -1
- package/dist/debrief.d.ts +0 -90
- package/dist/debrief.d.ts.map +0 -1
- package/dist/debrief.js +0 -263
- package/dist/debrief.js.map +0 -1
- package/dist/definitions.d.ts.map +0 -1
- package/dist/definitions.js +0 -164
- package/dist/definitions.js.map +0 -1
- package/dist/delegate-types.d.ts +0 -154
- package/dist/delegate-types.d.ts.map +0 -1
- package/dist/delegate-types.js +0 -8
- package/dist/delegate-types.js.map +0 -1
- package/dist/delegate.d.ts.map +0 -1
- package/dist/delegate.js +0 -313
- package/dist/delegate.js.map +0 -1
- package/dist/delegation-approval.d.ts.map +0 -1
- package/dist/delegation-approval.js +0 -94
- package/dist/delegation-approval.js.map +0 -1
- package/dist/dispatch-control.d.ts +0 -45
- package/dist/dispatch-control.d.ts.map +0 -1
- package/dist/dispatch-control.js +0 -76
- package/dist/dispatch-control.js.map +0 -1
- package/dist/effect-profile-runtime.d.ts +0 -40
- package/dist/effect-profile-runtime.d.ts.map +0 -1
- package/dist/effect-profile-runtime.js +0 -51
- package/dist/effect-profile-runtime.js.map +0 -1
- package/dist/effect-profile.d.ts +0 -40
- package/dist/effect-profile.d.ts.map +0 -1
- package/dist/effect-profile.js +0 -152
- package/dist/effect-profile.js.map +0 -1
- package/dist/execution-id.d.ts.map +0 -1
- package/dist/execution-id.js.map +0 -1
- package/dist/execution-retention.d.ts +0 -90
- package/dist/execution-retention.d.ts.map +0 -1
- package/dist/execution-retention.js +0 -247
- package/dist/execution-retention.js.map +0 -1
- package/dist/executor.d.ts +0 -39
- package/dist/executor.d.ts.map +0 -1
- package/dist/executor.js +0 -94
- package/dist/executor.js.map +0 -1
- package/dist/experiment-contract.d.ts +0 -56
- package/dist/experiment-contract.d.ts.map +0 -1
- package/dist/experiment-contract.js +0 -80
- package/dist/experiment-contract.js.map +0 -1
- package/dist/experiment-state.d.ts +0 -22
- package/dist/experiment-state.d.ts.map +0 -1
- package/dist/experiment-state.js +0 -79
- package/dist/experiment-state.js.map +0 -1
- package/dist/experiment-store.d.ts +0 -30
- package/dist/experiment-store.d.ts.map +0 -1
- package/dist/experiment-store.js +0 -147
- package/dist/experiment-store.js.map +0 -1
- package/dist/experiment.d.ts +0 -65
- package/dist/experiment.d.ts.map +0 -1
- package/dist/experiment.js +0 -362
- package/dist/experiment.js.map +0 -1
- package/dist/factory-contract.d.ts +0 -79
- package/dist/factory-contract.d.ts.map +0 -1
- package/dist/factory-contract.js +0 -89
- package/dist/factory-contract.js.map +0 -1
- package/dist/factory-migration.d.ts +0 -20
- package/dist/factory-migration.d.ts.map +0 -1
- package/dist/factory-migration.js +0 -55
- package/dist/factory-migration.js.map +0 -1
- package/dist/factory-order.d.ts +0 -848
- package/dist/factory-order.d.ts.map +0 -1
- package/dist/factory-order.js +0 -83
- package/dist/factory-order.js.map +0 -1
- package/dist/factory-registry.d.ts +0 -121
- package/dist/factory-registry.d.ts.map +0 -1
- package/dist/factory-registry.js +0 -133
- package/dist/factory-registry.js.map +0 -1
- package/dist/fanout.d.ts.map +0 -1
- package/dist/fanout.js +0 -93
- package/dist/fanout.js.map +0 -1
- package/dist/file-lock.d.ts.map +0 -1
- package/dist/file-lock.js +0 -201
- package/dist/file-lock.js.map +0 -1
- package/dist/finalization.d.ts.map +0 -1
- package/dist/finalization.js.map +0 -1
- package/dist/git-identity.d.ts +0 -13
- package/dist/git-identity.d.ts.map +0 -1
- package/dist/git-identity.js +0 -47
- package/dist/git-identity.js.map +0 -1
- package/dist/grant-env.d.ts +0 -75
- package/dist/grant-env.d.ts.map +0 -1
- package/dist/grant-env.js +0 -154
- package/dist/grant-env.js.map +0 -1
- package/dist/grant-store.d.ts +0 -96
- package/dist/grant-store.d.ts.map +0 -1
- package/dist/grant-store.js +0 -188
- package/dist/grant-store.js.map +0 -1
- package/dist/herdr-cli.d.ts +0 -78
- package/dist/herdr-cli.d.ts.map +0 -1
- package/dist/herdr-cli.js +0 -113
- package/dist/herdr-cli.js.map +0 -1
- package/dist/herdr-name.d.ts.map +0 -1
- package/dist/herdr-name.js.map +0 -1
- package/dist/herdr-pi-lifecycle.d.ts.map +0 -1
- package/dist/herdr-pi-lifecycle.js +0 -22
- package/dist/herdr-pi-lifecycle.js.map +0 -1
- package/dist/herdr-poll.d.ts +0 -133
- package/dist/herdr-poll.d.ts.map +0 -1
- package/dist/herdr-poll.js +0 -222
- package/dist/herdr-poll.js.map +0 -1
- package/dist/herdr-stage.d.ts +0 -40
- package/dist/herdr-stage.d.ts.map +0 -1
- package/dist/herdr-stage.js +0 -54
- package/dist/herdr-stage.js.map +0 -1
- package/dist/herdr-start.d.ts.map +0 -1
- package/dist/herdr-start.js.map +0 -1
- package/dist/init.d.ts +0 -117
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -323
- package/dist/init.js.map +0 -1
- package/dist/intent-application.d.ts +0 -17
- package/dist/intent-application.d.ts.map +0 -1
- package/dist/intent-application.js +0 -114
- package/dist/intent-application.js.map +0 -1
- package/dist/intent-control.d.ts +0 -201
- package/dist/intent-control.d.ts.map +0 -1
- package/dist/intent-control.js +0 -110
- package/dist/intent-control.js.map +0 -1
- package/dist/intent-scheduling.d.ts +0 -9
- package/dist/intent-scheduling.d.ts.map +0 -1
- package/dist/intent-scheduling.js +0 -15
- package/dist/intent-scheduling.js.map +0 -1
- package/dist/learning-connection.d.ts +0 -127
- package/dist/learning-connection.d.ts.map +0 -1
- package/dist/learning-connection.js +0 -54
- package/dist/learning-connection.js.map +0 -1
- package/dist/lease-helper.d.ts.map +0 -1
- package/dist/lease-helper.js +0 -94
- package/dist/lease-helper.js.map +0 -1
- package/dist/lease-record.d.ts +0 -90
- package/dist/lease-record.d.ts.map +0 -1
- package/dist/lease-record.js.map +0 -1
- package/dist/ledger-append.d.ts +0 -15
- package/dist/ledger-append.d.ts.map +0 -1
- package/dist/ledger-append.js +0 -94
- package/dist/ledger-append.js.map +0 -1
- package/dist/ledger-events.d.ts +0 -131
- package/dist/ledger-events.d.ts.map +0 -1
- package/dist/ledger-events.js +0 -107
- package/dist/ledger-events.js.map +0 -1
- package/dist/ledger-identifiers.d.ts.map +0 -1
- package/dist/ledger-identifiers.js.map +0 -1
- package/dist/ledger-report.d.ts +0 -134
- package/dist/ledger-report.d.ts.map +0 -1
- package/dist/ledger-report.js +0 -271
- package/dist/ledger-report.js.map +0 -1
- package/dist/ledger-v3-validation.d.ts +0 -11
- package/dist/ledger-v3-validation.d.ts.map +0 -1
- package/dist/ledger-v3-validation.js +0 -265
- package/dist/ledger-v3-validation.js.map +0 -1
- package/dist/ledger.d.ts +0 -242
- package/dist/ledger.d.ts.map +0 -1
- package/dist/ledger.js +0 -142
- package/dist/ledger.js.map +0 -1
- package/dist/measured-order.d.ts +0 -249
- package/dist/measured-order.d.ts.map +0 -1
- package/dist/measured-order.js +0 -309
- package/dist/measured-order.js.map +0 -1
- package/dist/measured-session.d.ts +0 -97
- package/dist/measured-session.d.ts.map +0 -1
- package/dist/measured-session.js +0 -134
- package/dist/measured-session.js.map +0 -1
- package/dist/model-preflight.d.ts +0 -13
- package/dist/model-preflight.d.ts.map +0 -1
- package/dist/model-preflight.js +0 -29
- package/dist/model-preflight.js.map +0 -1
- package/dist/native-session-target.d.ts +0 -9
- package/dist/native-session-target.d.ts.map +0 -1
- package/dist/native-session-target.js +0 -29
- package/dist/native-session-target.js.map +0 -1
- package/dist/native-session.d.ts +0 -59
- package/dist/native-session.d.ts.map +0 -1
- package/dist/native-session.js +0 -154
- package/dist/native-session.js.map +0 -1
- package/dist/order-schedule.d.ts +0 -37
- package/dist/order-schedule.d.ts.map +0 -1
- package/dist/order-schedule.js +0 -81
- package/dist/order-schedule.js.map +0 -1
- package/dist/ordinary-children.d.ts +0 -52
- package/dist/ordinary-children.d.ts.map +0 -1
- package/dist/ordinary-children.js +0 -93
- package/dist/ordinary-children.js.map +0 -1
- package/dist/pane-reaper.d.ts +0 -111
- package/dist/pane-reaper.d.ts.map +0 -1
- package/dist/pane-reaper.js +0 -242
- package/dist/pane-reaper.js.map +0 -1
- package/dist/pi-tools.d.ts.map +0 -1
- package/dist/pi-tools.js +0 -21
- package/dist/pi-tools.js.map +0 -1
- package/dist/producer-ipc-contract.d.ts +0 -29
- package/dist/producer-ipc-contract.d.ts.map +0 -1
- package/dist/producer-ipc-contract.js +0 -29
- package/dist/producer-ipc-contract.js.map +0 -1
- package/dist/producer-ipc.d.ts +0 -55
- package/dist/producer-ipc.d.ts.map +0 -1
- package/dist/producer-ipc.js +0 -143
- package/dist/producer-ipc.js.map +0 -1
- package/dist/product-files.d.ts +0 -6
- package/dist/product-files.d.ts.map +0 -1
- package/dist/product-files.js +0 -55
- package/dist/product-files.js.map +0 -1
- package/dist/progress.d.ts.map +0 -1
- package/dist/progress.js.map +0 -1
- package/dist/propagation.d.ts +0 -203
- package/dist/propagation.d.ts.map +0 -1
- package/dist/propagation.js +0 -279
- package/dist/propagation.js.map +0 -1
- package/dist/refusals.d.ts +0 -16
- package/dist/refusals.d.ts.map +0 -1
- package/dist/refusals.js +0 -55
- package/dist/refusals.js.map +0 -1
- package/dist/resolve.d.ts.map +0 -1
- package/dist/resolve.js +0 -211
- package/dist/resolve.js.map +0 -1
- package/dist/resource-budget.d.ts +0 -334
- package/dist/resource-budget.d.ts.map +0 -1
- package/dist/resource-budget.js +0 -415
- package/dist/resource-budget.js.map +0 -1
- package/dist/retention-contract.d.ts.map +0 -1
- package/dist/retention-contract.js +0 -104
- package/dist/retention-contract.js.map +0 -1
- package/dist/retention-json.d.ts.map +0 -1
- package/dist/retention-json.js.map +0 -1
- package/dist/routing-authority.d.ts.map +0 -1
- package/dist/routing-authority.js.map +0 -1
- package/dist/run-child.d.ts +0 -87
- package/dist/run-child.d.ts.map +0 -1
- package/dist/run-child.js +0 -248
- package/dist/run-child.js.map +0 -1
- package/dist/run-herdr.d.ts +0 -119
- package/dist/run-herdr.d.ts.map +0 -1
- package/dist/run-herdr.js +0 -335
- package/dist/run-herdr.js.map +0 -1
- package/dist/skill-packages.d.ts +0 -116
- package/dist/skill-packages.d.ts.map +0 -1
- package/dist/skill-packages.js +0 -295
- package/dist/skill-packages.js.map +0 -1
- package/dist/skill-resources.d.ts.map +0 -1
- package/dist/skill-resources.js +0 -52
- package/dist/skill-resources.js.map +0 -1
- package/dist/spawn.d.ts.map +0 -1
- package/dist/spawn.js.map +0 -1
- package/dist/vendor/adoption.d.ts +0 -129
- package/dist/vendor/adoption.d.ts.map +0 -1
- package/dist/vendor/adoption.js +0 -102
- package/dist/vendor/adoption.js.map +0 -1
- package/dist/vendor/herdr-pi-lifecycle.d.ts.map +0 -1
- package/dist/vendor/herdr-pi-lifecycle.js.map +0 -1
- package/dist/work-command.d.ts +0 -32
- package/dist/work-command.d.ts.map +0 -1
- package/dist/work-command.js +0 -179
- package/dist/work-command.js.map +0 -1
- package/dist/work-ledger-destination.d.ts +0 -20
- package/dist/work-ledger-destination.d.ts.map +0 -1
- package/dist/work-ledger-destination.js +0 -131
- package/dist/work-ledger-destination.js.map +0 -1
- package/dist/work-ledger-json.d.ts +0 -25
- package/dist/work-ledger-json.d.ts.map +0 -1
- package/dist/work-ledger-json.js +0 -267
- package/dist/work-ledger-json.js.map +0 -1
- package/dist/work-ledger-occurrences.d.ts +0 -227
- package/dist/work-ledger-occurrences.d.ts.map +0 -1
- package/dist/work-ledger-occurrences.js +0 -115
- package/dist/work-ledger-occurrences.js.map +0 -1
- package/dist/work-ledger-projection.d.ts +0 -295
- package/dist/work-ledger-projection.d.ts.map +0 -1
- package/dist/work-ledger-projection.js +0 -237
- package/dist/work-ledger-projection.js.map +0 -1
- package/dist/work-ledger-snapshot.d.ts +0 -29
- package/dist/work-ledger-snapshot.d.ts.map +0 -1
- package/dist/work-ledger-snapshot.js +0 -267
- package/dist/work-ledger-snapshot.js.map +0 -1
- package/dist/work-ledger-types.d.ts +0 -261
- package/dist/work-ledger-types.d.ts.map +0 -1
- package/dist/work-ledger-types.js +0 -13
- package/dist/work-ledger-types.js.map +0 -1
- package/dist/work-ledger-validation.d.ts +0 -14
- package/dist/work-ledger-validation.d.ts.map +0 -1
- package/dist/work-ledger-validation.js +0 -226
- package/dist/work-ledger-validation.js.map +0 -1
- package/dist/work-ledger.d.ts +0 -43
- package/dist/work-ledger.d.ts.map +0 -1
- package/dist/work-ledger.js +0 -225
- package/dist/work-ledger.js.map +0 -1
- package/dist/work-policy-registry.d.ts +0 -133
- package/dist/work-policy-registry.d.ts.map +0 -1
- package/dist/work-policy-registry.js +0 -128
- package/dist/work-policy-registry.js.map +0 -1
- package/dist/work-run.d.ts +0 -56
- package/dist/work-run.d.ts.map +0 -1
- package/dist/work-run.js +0 -102
- package/dist/work-run.js.map +0 -1
- package/dist/work-setup.d.ts +0 -40
- package/dist/work-setup.d.ts.map +0 -1
- package/dist/work-setup.js +0 -174
- package/dist/work-setup.js.map +0 -1
- package/dist/workflow-fact-id.d.ts +0 -4
- package/dist/workflow-fact-id.d.ts.map +0 -1
- package/dist/workflow-fact-id.js +0 -14
- package/dist/workflow-fact-id.js.map +0 -1
- package/dist/workflow-facts.d.ts +0 -34
- package/dist/workflow-facts.d.ts.map +0 -1
- package/dist/workflow-facts.js +0 -43
- package/dist/workflow-facts.js.map +0 -1
- package/dist/workspace-lease.d.ts +0 -40
- package/dist/workspace-lease.d.ts.map +0 -1
- package/dist/workspace-lease.js +0 -333
- package/dist/workspace-lease.js.map +0 -1
- package/dist/workspace.d.ts +0 -57
- package/dist/workspace.d.ts.map +0 -1
- package/dist/workspace.js +0 -216
- package/dist/workspace.js.map +0 -1
- package/extensions/daily-dashboard-session.ts +0 -48
- package/extensions/daily-work-session.ts +0 -20
- package/extensions/learning-outcome-session.ts +0 -38
- package/extensions/learning-session.ts +0 -59
- package/extensions/ordinary-runtime.ts +0 -14
- package/extensions/primary-shadow.ts +0 -11
- package/extensions/work-policy-session.ts +0 -139
- package/extensions/work-run-session.ts +0 -75
- package/extensions/work-runtime.ts +0 -44
- package/extensions/work-session.ts +0 -132
- package/src/activity-timeline.ts +0 -133
- package/src/approval-prompt.ts +0 -225
- package/src/approval-store.ts +0 -386
- package/src/approval.ts +0 -399
- package/src/capabilities.ts +0 -220
- package/src/catalog.ts +0 -306
- package/src/check-runner.ts +0 -387
- package/src/control-journal.ts +0 -26
- package/src/correlation.ts +0 -320
- package/src/daily-dashboard-host.ts +0 -105
- package/src/daily-panel.ts +0 -80
- package/src/daily-view-input.ts +0 -59
- package/src/daily-view-render.ts +0 -45
- package/src/daily-view.ts +0 -160
- package/src/dashboard-cli.ts +0 -340
- package/src/dashboard-display-controls.ts +0 -21
- package/src/dashboard-handshake.ts +0 -199
- package/src/dashboard-harness.ts +0 -37
- package/src/dashboard-herdr.ts +0 -363
- package/src/dashboard-host-contract.ts +0 -50
- package/src/dashboard-host-transport.ts +0 -43
- package/src/dashboard-host.ts +0 -244
- package/src/dashboard-menu.ts +0 -28
- package/src/dashboard-observation.ts +0 -46
- package/src/dashboard-projection.ts +0 -390
- package/src/dashboard-render.ts +0 -259
- package/src/debrief-contract.ts +0 -127
- package/src/debrief-fixture.ts +0 -29
- package/src/debrief-host.ts +0 -53
- package/src/debrief-render.ts +0 -49
- package/src/debrief.ts +0 -198
- package/src/definitions.ts +0 -211
- package/src/delegate-types.ts +0 -154
- package/src/delegate.ts +0 -348
- package/src/delegation-approval.ts +0 -126
- package/src/dispatch-control.ts +0 -81
- package/src/effect-profile-runtime.ts +0 -46
- package/src/effect-profile.ts +0 -129
- package/src/execution-retention.ts +0 -230
- package/src/executor.ts +0 -123
- package/src/experiment-contract.ts +0 -66
- package/src/experiment-state.ts +0 -44
- package/src/experiment-store.ts +0 -98
- package/src/experiment.ts +0 -236
- package/src/factory-contract.ts +0 -47
- package/src/factory-migration.ts +0 -29
- package/src/factory-order.ts +0 -56
- package/src/factory-registry.ts +0 -60
- package/src/fanout.ts +0 -106
- package/src/file-lock.ts +0 -178
- package/src/finalization.ts +0 -79
- package/src/git-identity.ts +0 -56
- package/src/grant-env.ts +0 -221
- package/src/grant-store.ts +0 -235
- package/src/herdr-cli.ts +0 -125
- package/src/herdr-pi-lifecycle.ts +0 -21
- package/src/herdr-poll.ts +0 -253
- package/src/herdr-stage.ts +0 -55
- package/src/init.ts +0 -389
- package/src/intent-application.ts +0 -91
- package/src/intent-control.ts +0 -107
- package/src/intent-scheduling.ts +0 -14
- package/src/learning-connection.ts +0 -70
- package/src/lease-helper.ts +0 -97
- package/src/lease-record.ts +0 -131
- package/src/ledger-append.ts +0 -72
- package/src/ledger-events.ts +0 -226
- package/src/ledger-report.ts +0 -357
- package/src/ledger-v3-validation.ts +0 -266
- package/src/ledger.ts +0 -369
- package/src/measured-order.ts +0 -72
- package/src/measured-session.ts +0 -70
- package/src/model-preflight.ts +0 -41
- package/src/native-session-target.ts +0 -23
- package/src/native-session.ts +0 -139
- package/src/order-schedule.ts +0 -42
- package/src/ordinary-children.ts +0 -59
- package/src/pane-reaper.ts +0 -270
- package/src/pi-tools.ts +0 -25
- package/src/producer-ipc-contract.ts +0 -26
- package/src/producer-ipc.ts +0 -107
- package/src/product-files.ts +0 -34
- package/src/propagation.ts +0 -333
- package/src/refusals.ts +0 -70
- package/src/resolve.ts +0 -267
- package/src/resource-budget.ts +0 -349
- package/src/retention-contract.ts +0 -84
- package/src/retention-json.ts +0 -20
- package/src/run-child.ts +0 -303
- package/src/run-herdr.ts +0 -386
- package/src/skill-packages.ts +0 -314
- package/src/skill-resources.ts +0 -48
- package/src/vendor/adoption.ts +0 -109
- package/src/work-command.ts +0 -197
- package/src/work-ledger-destination.ts +0 -113
- package/src/work-ledger-json.ts +0 -228
- package/src/work-ledger-occurrences.ts +0 -99
- package/src/work-ledger-projection.ts +0 -262
- package/src/work-ledger-snapshot.ts +0 -246
- package/src/work-ledger-types.ts +0 -229
- package/src/work-ledger-validation.ts +0 -174
- package/src/work-ledger.ts +0 -186
- package/src/work-policy-registry.ts +0 -81
- package/src/work-run.ts +0 -79
- package/src/work-setup.ts +0 -141
- package/src/workflow-fact-id.ts +0 -16
- package/src/workflow-facts.ts +0 -65
- package/src/workspace-lease.ts +0 -363
- package/src/workspace.ts +0 -308
- /package/contracts/{ledger/v3 → ledger-record/v1}/fixtures/capability-decision.json +0 -0
- /package/contracts/{ledger/v3 → ledger-record/v1}/fixtures/workspace-lease.json +0 -0
- /package/dist/{herdr-name.d.ts → executors/herdr-name.d.ts} +0 -0
- /package/dist/{herdr-name.js → executors/herdr-name.js} +0 -0
- /package/dist/{herdr-pi-lifecycle.d.ts → executors/herdr-pi-lifecycle.d.ts} +0 -0
- /package/dist/{herdr-start.d.ts → executors/herdr-start.d.ts} +0 -0
- /package/dist/{herdr-start.js → executors/herdr-start.js} +0 -0
- /package/dist/{vendor → executors/vendor}/herdr-pi-lifecycle.d.ts +0 -0
- /package/dist/{vendor → executors/vendor}/herdr-pi-lifecycle.js +0 -0
- /package/dist/{file-lock.d.ts → governance/file-lock.d.ts} +0 -0
- /package/dist/{finalization.d.ts → governance/finalization.d.ts} +0 -0
- /package/dist/{finalization.js → governance/finalization.js} +0 -0
- /package/dist/{lease-helper.d.ts → governance/lease-helper.d.ts} +0 -0
- /package/dist/{lease-record.js → governance/lease-record.js} +0 -0
- /package/dist/{retention-contract.d.ts → governance/retention-contract.d.ts} +0 -0
- /package/dist/{retention-json.d.ts → governance/retention-json.d.ts} +0 -0
- /package/dist/{retention-json.js → governance/retention-json.js} +0 -0
- /package/dist/{chain.d.ts → kernel/chain.d.ts} +0 -0
- /package/dist/{chain.js → kernel/chain.js} +0 -0
- /package/dist/{correlation.d.ts → kernel/correlation.d.ts} +0 -0
- /package/dist/{definitions.d.ts → kernel/definitions.d.ts} +0 -0
- /package/dist/{delegate.d.ts → kernel/delegate.d.ts} +0 -0
- /package/dist/{delegation-approval.d.ts → kernel/delegation-approval.d.ts} +0 -0
- /package/dist/{execution-id.d.ts → kernel/execution-id.d.ts} +0 -0
- /package/dist/{execution-id.js → kernel/execution-id.js} +0 -0
- /package/dist/{fanout.d.ts → kernel/fanout.d.ts} +0 -0
- /package/dist/{ledger-identifiers.d.ts → kernel/ledger-identifiers.d.ts} +0 -0
- /package/dist/{ledger-identifiers.js → kernel/ledger-identifiers.js} +0 -0
- /package/dist/{pi-tools.d.ts → kernel/pi-tools.d.ts} +0 -0
- /package/dist/{progress.d.ts → kernel/progress.d.ts} +0 -0
- /package/dist/{progress.js → kernel/progress.js} +0 -0
- /package/dist/{resolve.d.ts → kernel/resolve.d.ts} +0 -0
- /package/dist/{routing-authority.d.ts → kernel/routing-authority.d.ts} +0 -0
- /package/dist/{routing-authority.js → kernel/routing-authority.js} +0 -0
- /package/dist/{skill-resources.d.ts → kernel/skill-resources.d.ts} +0 -0
- /package/dist/{spawn.d.ts → kernel/spawn.d.ts} +0 -0
- /package/dist/{spawn.js → kernel/spawn.js} +0 -0
- /package/dist/{dashboard-render.d.ts → products/dashboard-render.d.ts} +0 -0
- /package/src/{herdr-name.ts → executors/herdr-name.ts} +0 -0
- /package/src/{herdr-start.ts → executors/herdr-start.ts} +0 -0
- /package/src/{vendor → executors/vendor}/herdr-pi-lifecycle.ts +0 -0
- /package/src/{chain.ts → kernel/chain.ts} +0 -0
- /package/src/{execution-id.ts → kernel/execution-id.ts} +0 -0
- /package/src/{ledger-identifiers.ts → kernel/ledger-identifiers.ts} +0 -0
- /package/src/{progress.ts → kernel/progress.ts} +0 -0
- /package/src/{routing-authority.ts → kernel/routing-authority.ts} +0 -0
- /package/src/{spawn.ts → kernel/spawn.ts} +0 -0
package/src/ledger.ts
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Append-only grant ledger.
|
|
3
|
-
*
|
|
4
|
-
* Exists because pi-fabric's persisted execution trace records `args: {}` — it captures *that* a child
|
|
5
|
-
* ran, not *what it was authorised to do* (docs/probes/pi-fabric-eval probe 5). Without this record
|
|
6
|
-
* you cannot answer "what was this sub-agent permitted to do?" after the fact, which is the whole
|
|
7
|
-
* point of a governance layer.
|
|
8
|
-
*
|
|
9
|
-
* `denied` is the field that earns the file: an agent repeatedly requesting capabilities it does not
|
|
10
|
-
* hold is an escalation attempt, and it is invisible without a record.
|
|
11
|
-
*
|
|
12
|
-
* PRIVACY: capability ids, counts, and identifiers only. Never prompts, tool arguments, or results.
|
|
13
|
-
*
|
|
14
|
-
* ADR-0018 makes the boundary explicit rather than leaving it to be inferred, because a record now carries
|
|
15
|
-
* something about the child's instructions. **`definitionDigest` is an identifier**: a SHA-256 of an
|
|
16
|
-
* operator-authored file already committed to a repository, which names a version without reproducing it.
|
|
17
|
-
* **The task is not recorded, anywhere, ever** — it is assembled by the model from the parent's context and
|
|
18
|
-
* can carry anything the parent could see, so a ledger holding it would be a secrets sink. That half of
|
|
19
|
-
* "what was this child told to do?" is out of the ledger by decision, not by omission.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { readFile } from "node:fs/promises";
|
|
23
|
-
import { appendLedgerLine } from "./ledger-append.ts";
|
|
24
|
-
import type { Capability, ResolveResult } from "./resolve.ts";
|
|
25
|
-
import type { ExecutorKind } from "./executor.ts";
|
|
26
|
-
import type { DefinitionDigest } from "./definitions.ts";
|
|
27
|
-
import { DELEGATE_SUBJECT } from "./approval.ts";
|
|
28
|
-
import type { ApprovalScope, ApprovalSource } from "./approval.ts";
|
|
29
|
-
import type { PromptOutcomeKind } from "./approval-prompt.ts";
|
|
30
|
-
import type { CorrelationMetadata } from "./correlation.ts";
|
|
31
|
-
import type { StructuredRefusal } from "./refusals.ts";
|
|
32
|
-
// Type-only, so the cycle with ./ledger-events.ts is erased at runtime.
|
|
33
|
-
import type { RuntimeLedgerEvent } from "./ledger-events.ts";
|
|
34
|
-
import { assertExecutionId } from "./execution-id.ts";
|
|
35
|
-
import { assertLedgerV3Wire } from "./ledger-v3-validation.ts";
|
|
36
|
-
|
|
37
|
-
export const LEDGER_VERSION = 3 as const;
|
|
38
|
-
export const LEDGER_EVENT_KINDS = [
|
|
39
|
-
"capability_decision", "workspace_lease", "child_lifecycle", "check_receipt", "workflow_fact",
|
|
40
|
-
] as const;
|
|
41
|
-
export type LedgerEventKind = typeof LEDGER_EVENT_KINDS[number];
|
|
42
|
-
export const LEDGER_GATE_OUTCOMES = ["declined", "dismissed", "no-ui", "error"] as const;
|
|
43
|
-
export type LedgerGateOutcome = typeof LEDGER_GATE_OUTCOMES[number];
|
|
44
|
-
|
|
45
|
-
export interface LedgerEventBase {
|
|
46
|
-
/** Optional only on the legacy-compatible `GrantRecord` public type; every v3 event builder writes it. */
|
|
47
|
-
ledgerVersion?: typeof LEDGER_VERSION;
|
|
48
|
-
event?: LedgerEventKind;
|
|
49
|
-
ts: string;
|
|
50
|
-
/** Unique execution occurrence. Optional only for legacy, unversioned GrantRecord values. */
|
|
51
|
-
executionId?: string;
|
|
52
|
-
/** Explicit execution parent; null means the delegating session is not itself a governed child. */
|
|
53
|
-
parentExecutionId?: string | null;
|
|
54
|
-
childId?: string;
|
|
55
|
-
correlation?: CorrelationMetadata;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface GrantRecord extends LedgerEventBase {
|
|
59
|
-
/**
|
|
60
|
-
* Present only when a trusted `taskDigest` was supplied — that is what makes a line v3. `buildRecord`
|
|
61
|
-
* does NOT always emit it, and the comment here used to say it did while the emission site 200 lines
|
|
62
|
-
* down said the opposite. Two comments asserting contradictory facts about one field is R-28's shape.
|
|
63
|
-
*/
|
|
64
|
-
event?: "capability_decision";
|
|
65
|
-
parentId: string;
|
|
66
|
-
childId: string;
|
|
67
|
-
depth: number;
|
|
68
|
-
agentType?: string;
|
|
69
|
-
requested: Capability[];
|
|
70
|
-
parentGrant: Capability[];
|
|
71
|
-
effective: Capability[];
|
|
72
|
-
denied: Capability[];
|
|
73
|
-
clipped: Capability[];
|
|
74
|
-
gatedBlocked: Capability[];
|
|
75
|
-
/** True when the spawn was refused outright rather than narrowed. */
|
|
76
|
-
blocked: boolean;
|
|
77
|
-
/** Present when the spawn was refused, or when resolution failed. */
|
|
78
|
-
reason?: string;
|
|
79
|
-
/**
|
|
80
|
-
* Gated capabilities satisfied for this spawn.
|
|
81
|
-
*
|
|
82
|
-
* The ledger used to have ONE flavour of no. It now has three, and they call for different responses:
|
|
83
|
-
* - `denied` non-empty -> an agent asked for more than it holds. ESCALATION ATTEMPT.
|
|
84
|
-
* - `humanDenied` -> a person was asked and said no. WORKING AS DESIGNED.
|
|
85
|
-
* - `gatedBlocked` with no source -> nobody was there to ask. A background run hit a gate; the fix is
|
|
86
|
-
* an operator pre-approving it, not an incident.
|
|
87
|
-
*/
|
|
88
|
-
approved?: Capability[];
|
|
89
|
-
approvalSource?: ApprovalSource;
|
|
90
|
-
/**
|
|
91
|
-
* WHERE each approved capability's yes came from — one entry per capability (R-46).
|
|
92
|
-
*
|
|
93
|
-
* `approvalSource` above is a single scalar and was written for a set: gate `tool:bash` and `tool:write`,
|
|
94
|
-
* let a persisted entry cover `bash` while a human clicks *Allow once* for `write`, and the record read
|
|
95
|
-
* `approved: ["tool:bash","tool:write"], approvalSource: "prompt"` — **asserting a human was asked about
|
|
96
|
-
* `tool:bash`, which they were not.** The ledger's whole job is answering "did a human authorise this?",
|
|
97
|
-
* so over-claiming in that direction is the worst available failure.
|
|
98
|
-
*
|
|
99
|
-
* The scalar is kept and is now written **only when every approved capability shares one source**, so a
|
|
100
|
-
* reader of old and new lines alike can trust it; when sources differ it is omitted and this map carries
|
|
101
|
-
* the truth. Two fields, one of which is a safe summary of the other — not two competing answers.
|
|
102
|
-
*/
|
|
103
|
-
approvalSources?: Record<Capability, ApprovalSource>;
|
|
104
|
-
/**
|
|
105
|
-
* How far each prompted capability's yes reaches (F5). Same shape and same reason as `approvalSources`:
|
|
106
|
-
* `approvalScope` below is a **derived summary**, emitted only when every prompted capability shares one
|
|
107
|
-
* scope. This field decides propagation — `inheritApprovals` drops `once` — so a scalar that described
|
|
108
|
-
* one capability while claiming to describe the set was not merely a reporting defect.
|
|
109
|
-
*/
|
|
110
|
-
approvalScopes?: Record<Capability, ApprovalScope>;
|
|
111
|
-
/** Persisted approval expiry, by capability. Session-scoped approvals have no wall-clock expiry. */
|
|
112
|
-
approvalExpiresAt?: Record<Capability, string>;
|
|
113
|
-
/** Count bounds where one exists. A consumed `once` approval records `{max:1, remaining:0}`. */
|
|
114
|
-
approvalUses?: Record<Capability, { max: number; remaining: number }>;
|
|
115
|
-
/** Present only when the source was a live prompt, and only when one scope covers the whole set. */
|
|
116
|
-
approvalScope?: ApprovalScope;
|
|
117
|
-
/** A human was asked and declined. Distinct from `denied`, which is an escalation attempt. */
|
|
118
|
-
humanDenied?: true;
|
|
119
|
-
/**
|
|
120
|
-
* WHY a gate went unsatisfied, when the answer was not a yes.
|
|
121
|
-
*
|
|
122
|
-
* `PromptOutcomeKind` has five members and this record kept exactly one of them (`humanDenied`, from
|
|
123
|
-
* `declined`). So `no-ui`, `dismissed` (a timeout or an abort) and `error` produced **identical** records
|
|
124
|
-
* — `gatedBlocked` non-empty, no `approvalSource`, `blocked: true` — and the only thing separating them
|
|
125
|
-
* was free-text `reason`, written for a human at the call site. Given a failed run, *"was there an
|
|
126
|
-
* operator who timed out, or was there nobody to ask?"* was not answerable from any field, and the fix
|
|
127
|
-
* for each is different: one is a queue or a longer `PI_GRANTS_APPROVAL_TIMEOUT`, the other is an
|
|
128
|
-
* operator pre-approving.
|
|
129
|
-
*
|
|
130
|
-
* The discriminant was already computed and thrown away. ADR-0026 leans on this vocabulary being able to
|
|
131
|
-
* say *"nobody was there to ask"* and be believed, so it is recorded rather than inferred.
|
|
132
|
-
*
|
|
133
|
-
* **Privacy is unchanged**: this is a fixed five-member enum, not text — nothing model-authored, nothing
|
|
134
|
-
* a task could carry. The prompt has five outcomes, but `granted` is deliberately omitted from the
|
|
135
|
-
* four-member ledger enum because the approval source/scope fields already record a yes.
|
|
136
|
-
*/
|
|
137
|
-
gateOutcome?: LedgerGateOutcome;
|
|
138
|
-
/**
|
|
139
|
-
* WHICH operator-authored instructions this child was given (ADR-0018).
|
|
140
|
-
*
|
|
141
|
-
* Identifies, never reproduces: matching digests prove two children ran the same text, and a digest that
|
|
142
|
-
* no longer matches the file proves the definition changed since. **It says nothing about whether those
|
|
143
|
-
* instructions were correct or whether the child obeyed them** — it identifies text, it does not evaluate
|
|
144
|
-
* it. Absent for a `tools:`-style delegation, which has no definition.
|
|
145
|
-
*/
|
|
146
|
-
definitionDigest?: DefinitionDigest;
|
|
147
|
-
/**
|
|
148
|
-
* WHERE this child ran — ADR-0031.
|
|
149
|
-
*
|
|
150
|
-
* **Required rather than optional**, which is unusual in this record and deliberate. Before ADR-0031 the
|
|
151
|
-
* executor was a variable an operator set, so "which one ran?" was answerable from configuration after the
|
|
152
|
-
* fact. It is now decided by a **runtime probe** at session start, so nothing outside the record preserves
|
|
153
|
-
* the answer — and the two paths do not produce the same argv, because the herdr plan withholds `--print`
|
|
154
|
-
* (`delegationContext.interactive`). A trail that cannot say where a child ran cannot be read back
|
|
155
|
-
* reliably, and reading it back is the only reason it exists.
|
|
156
|
-
*
|
|
157
|
-
* Written on refusals too, including the tripwire's: the honest value there is the executor the session
|
|
158
|
-
* *would* have used, because a refused spawn has no executor of its own.
|
|
159
|
-
*/
|
|
160
|
-
executor: ExecutorKind;
|
|
161
|
-
/**
|
|
162
|
-
* The child whose OUTPUT composed this child's task — ADR-0033.
|
|
163
|
-
*
|
|
164
|
-
* **Optional, unlike `executor`, and the asymmetry is deliberate.** A non-chained spawn has no prior author, and
|
|
165
|
-
* an empty string would assert one. Present only on chain steps after the first.
|
|
166
|
-
*
|
|
167
|
-
* Why it is recorded at all: a chain makes step N's task the output of a governed child, and ADR-0033's chosen
|
|
168
|
-
* handoff is *framing* rather than enforcement. So "who wrote this instruction?" is exactly the question that
|
|
169
|
-
* decision makes worth asking, and it is unanswerable from any other field — `agentType` names the definition,
|
|
170
|
-
* `definitionDigest` names its instructions, and neither says where the TASK came from.
|
|
171
|
-
*/
|
|
172
|
-
taskFrom?: string;
|
|
173
|
-
/** Unique occurrence whose output composed this task; taskFrom remains the readable logical position. */
|
|
174
|
-
taskFromExecutionId?: string;
|
|
175
|
-
/** Trusted SHA-256 of the exact task; task text remains forbidden (ADR-0034). */
|
|
176
|
-
taskDigest?: string;
|
|
177
|
-
/** Stable machine-readable refusal accompanying `reason`. */
|
|
178
|
-
refusal?: StructuredRefusal;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface LedgerOptions {
|
|
182
|
-
/** Path to the JSONL file. Parent directories are created on demand. */
|
|
183
|
-
path: string;
|
|
184
|
-
/**
|
|
185
|
-
* When true, a ledger write failure throws instead of being swallowed.
|
|
186
|
-
*
|
|
187
|
-
* Default is `true` and that is deliberate: for a security control, an unrecorded grant should fail
|
|
188
|
-
* closed. Set false only where the ledger is advisory.
|
|
189
|
-
*/
|
|
190
|
-
strict?: boolean;
|
|
191
|
-
/**
|
|
192
|
-
* Called when a NON-strict append failed. Required in spirit rather than in types: a caller that opts
|
|
193
|
-
* out of failing closed still has to say something, or the ledger silently develops holes.
|
|
194
|
-
*/
|
|
195
|
-
onFailure?: (error: unknown) => void;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export function buildRecord(args: {
|
|
199
|
-
/** Required whenever taskDigest makes this an explicit v3 event. */
|
|
200
|
-
executionId?: string;
|
|
201
|
-
/** Required (including explicit null) whenever taskDigest makes this an explicit v3 event. */
|
|
202
|
-
parentExecutionId?: string | null;
|
|
203
|
-
parentId: string;
|
|
204
|
-
childId: string;
|
|
205
|
-
depth: number;
|
|
206
|
-
agentType?: string;
|
|
207
|
-
requested: Capability[];
|
|
208
|
-
parentGrant: Capability[];
|
|
209
|
-
result: ResolveResult;
|
|
210
|
-
blocked: boolean;
|
|
211
|
-
reason?: string;
|
|
212
|
-
approved?: Capability[];
|
|
213
|
-
approvalSources?: Record<Capability, ApprovalSource>;
|
|
214
|
-
approvalScopes?: Record<Capability, ApprovalScope>;
|
|
215
|
-
approvalExpiresAt?: Record<Capability, string>;
|
|
216
|
-
approvalUses?: Record<Capability, { max: number; remaining: number }>;
|
|
217
|
-
humanDenied?: boolean;
|
|
218
|
-
gateOutcome?: PromptOutcomeKind;
|
|
219
|
-
definitionDigest?: DefinitionDigest;
|
|
220
|
-
/** Where the child ran (ADR-0031). Required: the probe's answer survives nowhere else. */
|
|
221
|
-
executor: ExecutorKind;
|
|
222
|
-
/** The logical child whose output composed this task (ADR-0033). */
|
|
223
|
-
taskFrom?: string;
|
|
224
|
-
/** The unique occurrence whose output composed this task. */
|
|
225
|
-
taskFromExecutionId?: string;
|
|
226
|
-
taskDigest?: string;
|
|
227
|
-
correlation?: CorrelationMetadata;
|
|
228
|
-
refusal?: StructuredRefusal;
|
|
229
|
-
now: Date;
|
|
230
|
-
}): GrantRecord {
|
|
231
|
-
if (args.taskDigest !== undefined) {
|
|
232
|
-
if (!/^[a-f0-9]{64}$/i.test(args.taskDigest)) throw new TypeError("taskDigest must be a SHA-256 hex digest");
|
|
233
|
-
assertExecutionId(args.executionId);
|
|
234
|
-
if (args.parentExecutionId !== null) assertExecutionId(args.parentExecutionId, "parentExecutionId");
|
|
235
|
-
if (args.parentExecutionId === args.executionId) throw new TypeError("an execution cannot be its own parent");
|
|
236
|
-
if (args.taskFromExecutionId !== undefined) assertExecutionId(args.taskFromExecutionId, "taskFromExecutionId");
|
|
237
|
-
}
|
|
238
|
-
if (args.definitionDigest && !/^[a-f0-9]{64}$/i.test(args.definitionDigest.sha256)) {
|
|
239
|
-
throw new TypeError("definitionDigest.sha256 must be a SHA-256 hex digest");
|
|
240
|
-
}
|
|
241
|
-
// R-46: the scalar is a SUMMARY, emitted only when it cannot mislead. `buildRecord` derives it rather
|
|
242
|
-
// than accepting it, so a call site cannot supply one that disagrees with the map beside it.
|
|
243
|
-
const sources = args.approvalSources ?? {};
|
|
244
|
-
const distinct = [...new Set(Object.values(sources))];
|
|
245
|
-
const scopes = args.approvalScopes ?? {};
|
|
246
|
-
const distinctScopes = [...new Set(Object.values(scopes))];
|
|
247
|
-
const record: GrantRecord = {
|
|
248
|
-
// A trusted task digest is what distinguishes a v3 capability event from the legacy construction API.
|
|
249
|
-
// Production delegation always supplies it; old TypeScript callers remain able to append legacy lines.
|
|
250
|
-
...(args.taskDigest !== undefined
|
|
251
|
-
? {
|
|
252
|
-
ledgerVersion: LEDGER_VERSION,
|
|
253
|
-
event: "capability_decision" as const,
|
|
254
|
-
executionId: args.executionId,
|
|
255
|
-
parentExecutionId: args.parentExecutionId,
|
|
256
|
-
}
|
|
257
|
-
: {}),
|
|
258
|
-
ts: args.now.toISOString(),
|
|
259
|
-
parentId: args.parentId,
|
|
260
|
-
childId: args.childId,
|
|
261
|
-
depth: args.depth,
|
|
262
|
-
agentType: args.agentType,
|
|
263
|
-
executor: args.executor,
|
|
264
|
-
...(args.taskFrom ? { taskFrom: args.taskFrom } : {}),
|
|
265
|
-
...(args.taskFromExecutionId ? { taskFromExecutionId: args.taskFromExecutionId } : {}),
|
|
266
|
-
...(args.taskDigest !== undefined ? { taskDigest: args.taskDigest } : {}),
|
|
267
|
-
...(args.correlation ? { correlation: structuredClone(args.correlation) } : {}),
|
|
268
|
-
...(args.refusal ? { refusal: structuredClone(args.refusal) } : {}),
|
|
269
|
-
requested: args.requested,
|
|
270
|
-
parentGrant: args.parentGrant,
|
|
271
|
-
effective: args.result.effective,
|
|
272
|
-
denied: args.result.denied,
|
|
273
|
-
clipped: args.result.clipped,
|
|
274
|
-
gatedBlocked: args.result.gatedBlocked,
|
|
275
|
-
blocked: args.blocked,
|
|
276
|
-
reason: args.reason,
|
|
277
|
-
...(args.approved && args.approved.length > 0 ? { approved: args.approved } : {}),
|
|
278
|
-
...(distinct.length === 1 ? { approvalSource: distinct[0] } : {}),
|
|
279
|
-
...(Object.keys(sources).length > 0 ? { approvalSources: sources } : {}),
|
|
280
|
-
...(distinctScopes.length === 1 ? { approvalScope: distinctScopes[0] } : {}),
|
|
281
|
-
...(Object.keys(scopes).length > 0 ? { approvalScopes: scopes } : {}),
|
|
282
|
-
...(args.approvalExpiresAt && Object.keys(args.approvalExpiresAt).length > 0
|
|
283
|
-
? { approvalExpiresAt: args.approvalExpiresAt }
|
|
284
|
-
: {}),
|
|
285
|
-
...(args.approvalUses && Object.keys(args.approvalUses).length > 0 ? { approvalUses: args.approvalUses } : {}),
|
|
286
|
-
...(args.humanDenied ? { humanDenied: true } : {}),
|
|
287
|
-
// Written whenever a gate was reached and not satisfied by a yes. `granted` is omitted deliberately —
|
|
288
|
-
// an approved spawn already says so through `approvalSources`, and a field that appears on every record
|
|
289
|
-
// stops being a signal.
|
|
290
|
-
...(args.gateOutcome && args.gateOutcome !== "granted" ? { gateOutcome: args.gateOutcome } : {}),
|
|
291
|
-
...(args.definitionDigest ? { definitionDigest: args.definitionDigest } : {}),
|
|
292
|
-
};
|
|
293
|
-
if (args.taskDigest !== undefined) assertLedgerV3Wire(record);
|
|
294
|
-
return record;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// R-49: the lock moved to `src/file-lock.ts` so the approvals store could use the SAME one rather than
|
|
298
|
-
// grow a second copy. Re-exported because `./ledger` is a published subpath and these were part of it.
|
|
299
|
-
export { LOCK_TIMEOUT_MS, STALE_LOCK_MS } from "./file-lock.ts";
|
|
300
|
-
|
|
301
|
-
// The reading half, split out under the file-size guard and re-exported so `./ledger` is unchanged for
|
|
302
|
-
// anyone importing it. See `ledger-report.ts` for why the seam is where it is.
|
|
303
|
-
export { verifyLedger, type LedgerReport } from "./ledger-report.ts";
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Serialise appends across processes.
|
|
307
|
-
*
|
|
308
|
-
* **Why the ledger needs it.** For most of this package's life cardinality was bounded to one by `delegate`
|
|
309
|
-
* being blocking, so there was never a second writer. Fan-out removes that: `ENV_LEDGER` propagates to
|
|
310
|
-
* children, so a subtree can have many processes appending to one file.
|
|
311
|
-
*
|
|
312
|
-
* A ledger write that cannot take the lock **fails the delegation closed** — see `appendRecord`'s `strict`
|
|
313
|
-
* — because a child running with granted capabilities and no audit line is what the ledger exists to
|
|
314
|
-
* prevent. That is the opposite of what the approvals store does with the same lock, and deliberately so.
|
|
315
|
-
*/
|
|
316
|
-
export async function appendLedgerEvent(options: LedgerOptions, event: RuntimeLedgerEvent | GrantRecord): Promise<void> {
|
|
317
|
-
const line = `${JSON.stringify(event)}\n`;
|
|
318
|
-
try {
|
|
319
|
-
await appendLedgerLine(options, line);
|
|
320
|
-
} catch (error) {
|
|
321
|
-
if (options.strict ?? true) {
|
|
322
|
-
throw new Error(`grant ledger write failed (failing closed): ${String(error)}`);
|
|
323
|
-
}
|
|
324
|
-
// A non-strict append is a deliberate choice not to fail closed. It is NOT a choice to be silent:
|
|
325
|
-
// a silent safe-mode is as confusing as a silent unsafe one, so the caller is always told.
|
|
326
|
-
options.onFailure?.(error);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export async function appendRecord(options: LedgerOptions, record: GrantRecord): Promise<void> {
|
|
331
|
-
return appendLedgerEvent(options, record);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/** True when this record shows an agent asking for more than it holds. */
|
|
335
|
-
export function isEscalationAttempt(record: GrantRecord): boolean {
|
|
336
|
-
return record.denied.length > 0;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export {
|
|
340
|
-
CHILD_LIFECYCLE_STATES,
|
|
341
|
-
CHILD_PROCESS_SIGNALS,
|
|
342
|
-
WORKSPACE_ACCESSES,
|
|
343
|
-
WORKSPACE_LEASE_OUTCOMES,
|
|
344
|
-
WORKSPACE_RECOVERY_VALUES,
|
|
345
|
-
buildCheckReceiptLedgerEvent,
|
|
346
|
-
buildChildLifecycleEvent,
|
|
347
|
-
buildWorkspaceLeaseEvent,
|
|
348
|
-
type CapabilityDecisionEvent,
|
|
349
|
-
type ChildLifecycleEvent,
|
|
350
|
-
type ChildLifecycleState,
|
|
351
|
-
type ChildProcessSignal,
|
|
352
|
-
type CheckReceiptLedgerEvent,
|
|
353
|
-
type RuntimeLedgerEvent,
|
|
354
|
-
type WorkspaceAccess,
|
|
355
|
-
type WorkspaceLeaseEvent,
|
|
356
|
-
type WorkspaceLeaseOutcome,
|
|
357
|
-
type WorkspaceRecovery,
|
|
358
|
-
} from "./ledger-events.ts";
|
|
359
|
-
|
|
360
|
-
export {
|
|
361
|
-
WORKFLOW_FACT_KINDS,
|
|
362
|
-
WORKFLOW_FACT_PROVENANCE,
|
|
363
|
-
WORKFLOW_FACT_STATES,
|
|
364
|
-
buildWorkflowFactEvent,
|
|
365
|
-
type WorkflowFactEvent,
|
|
366
|
-
type WorkflowFactKind,
|
|
367
|
-
type WorkflowFactProvenance,
|
|
368
|
-
type WorkflowFactState,
|
|
369
|
-
} from "./workflow-facts.ts";
|
package/src/measured-order.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { constants } from "node:fs";
|
|
3
|
-
import { mkdir, open, readFile, realpath, lstat, writeFile } from "node:fs/promises";
|
|
4
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { withFileLock } from "./file-lock.ts";
|
|
6
|
-
import { intentKey } from "./intent-control.ts";
|
|
7
|
-
import { runMeasuredAgentSession, MeasuredSessionFailure, MeasuredSessionUnknownError, type MeasuredSessionHost, type MeasuredSessionInput } from "./measured-session.ts";
|
|
8
|
-
import { openResourceBudget, resourceBindingDigest, type GovernedBudgetBinding } from "./resource-budget.ts";
|
|
9
|
-
import { freezeWork } from "./work-ledger-json.ts";
|
|
10
|
-
|
|
11
|
-
const ID=/^[a-zA-Z0-9:_-]{1,128}$/,HEX=/^[a-f0-9]{64}$/;
|
|
12
|
-
const hash=(value:unknown)=>createHash("sha256").update(typeof value==="string"?value:intentKey(value)).digest("hex");
|
|
13
|
-
const exact=(value:object,keys:string[])=>Object.keys(value).sort().join()===keys.sort().join();
|
|
14
|
-
type JournalJson=null|boolean|number|string|JournalJson[]|{[key:string]:JournalJson};
|
|
15
|
-
class JournalSerializationError extends Error {constructor(){super("invalid measured order journal value");this.name="JournalSerializationError";}}
|
|
16
|
-
/** Result evidence is not work/intent input: provider money is finite decimal Number data, not an integer schema field. */
|
|
17
|
-
function journalKey(value:unknown):string{try{const ancestors=new Set<object>();const copy=(v:unknown,depth:number):JournalJson=>{if(v===null||typeof v==="boolean"||typeof v==="string")return v;if(typeof v==="number"){if(Number.isFinite(v))return v;throw new JournalSerializationError();}if(!v||typeof v!=="object"||depth>16||ancestors.has(v))throw new JournalSerializationError();ancestors.add(v);let result:JournalJson;if(Array.isArray(v)){if(Object.getPrototypeOf(v)!==Array.prototype||v.length>256)throw new JournalSerializationError();const fields=Object.getOwnPropertyDescriptors(v);if(Reflect.ownKeys(fields).length!==v.length+1)throw new JournalSerializationError();result=[];for(let i=0;i<v.length;i++){const field=fields[String(i)];if(!field||!Object.hasOwn(field,"value")||!field.enumerable)throw new JournalSerializationError();result.push(copy(field.value,depth+1));}}else{if(Object.getPrototypeOf(v)!==Object.prototype&&Object.getPrototypeOf(v)!==null)throw new JournalSerializationError();const fields=Object.getOwnPropertyDescriptors(v),object:Record<string,JournalJson>=Object.create(null);for(const key of Reflect.ownKeys(fields)){if(typeof key!=="string")throw new JournalSerializationError();const field=fields[key];if(!Object.hasOwn(field,"value")||!field.enumerable)throw new JournalSerializationError();Object.defineProperty(object,key,{value:copy(field.value,depth+1),enumerable:true});}result=object;}ancestors.delete(v);return result;},emit=(v:JournalJson):string=>v===null||typeof v!=="object"?JSON.stringify(v):Array.isArray(v)?`[${v.map(emit).join(",")}]`:`{${Object.keys(v).sort().map(key=>`${JSON.stringify(key)}:${emit(v[key])}`).join(",")}}`;return emit(copy(value,1));}catch(error){if(error instanceof JournalSerializationError)throw error;throw new JournalSerializationError();}}
|
|
18
|
-
const journalHash=(value:unknown)=>createHash("sha256").update(journalKey(value)).digest("hex");
|
|
19
|
-
export type MeasuredOutputContract={version:"measured-output-exact-v1";expectedSha256:string}|{version:"measured-output-json-projection-v1";requiredKeys:string[];textFields:string[];arrayField:string;minItems:number;maxItems:number;itemRequiredFields:string[];projectionFields:string[];expectedProjectionSha256:string};
|
|
20
|
-
export interface MeasuredOrderAttempt extends Omit<MeasuredSessionInput,"budget"|"attempt"|"signal">{attemptId:string;includeDependencies:boolean;qualification:MeasuredOutputContract}
|
|
21
|
-
export interface MeasuredOrderNode {nodeId:string;dependencies:string[];attempts:MeasuredOrderAttempt[]}
|
|
22
|
-
export interface MeasuredOrder {version:"measured-order-v1";orderId:string;authorityDigest:string;budgetDigest:string;nodes:MeasuredOrderNode[]}
|
|
23
|
-
export interface MeasuredOrderBinding {version:"measured-order-binding-v1";directory:string;directoryDevice:string;directoryInode:string;journalDevice:string;journalInode:string;budget:GovernedBudgetBinding;order:MeasuredOrder;digest:string}
|
|
24
|
-
export interface MeasuredOrderAuthority {authorityDigest:string;orderDigests:string[];acknowledgementDigests:string[]}
|
|
25
|
-
export interface MeasuredOrderAcknowledgement {version:"measured-order-ack-v1";requestId:string;bindingDigest:string;attemptId:string;claimOwner:string;claimDigest:string}
|
|
26
|
-
type JournalEvent=
|
|
27
|
-
|{type:"claim";sequence:number;previousDigest:string|null;attemptId:string;owner:string;digest:string}
|
|
28
|
-
|{type:"result";sequence:number;previousDigest:string;attemptId:string;owner:string;state:"completed"|"failed"|"cancelled"|"unknown"|"mismatch";outputSha256:string|null;result:unknown;digest:string}
|
|
29
|
-
|{type:"acknowledge-unknown";sequence:number;previousDigest:string;request:MeasuredOrderAcknowledgement;digest:string};
|
|
30
|
-
export interface MeasuredOrderNodeView {nodeId:string;state:"eligible"|"dependency-blocked"|"running"|"unknown"|"exhausted"|"satisfied";action:"dispatch"|"wait"|"acknowledge"|"none";attemptId:string|null;outputSha256:string|null;unknownClaim:{owner:string;digest:string}|null}
|
|
31
|
-
function field(value:unknown):value is string{return typeof value==="string"&&/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value);}
|
|
32
|
-
function checkedContract(input:MeasuredOutputContract):MeasuredOutputContract{const c=JSON.parse(intentKey(input)) as MeasuredOutputContract;if(c.version==="measured-output-exact-v1"){if(!exact(c,["version","expectedSha256"])||!HEX.test(c.expectedSha256))throw Error("invalid exact output contract");return c;}if(c.version!=="measured-output-json-projection-v1"||!exact(c,["version","requiredKeys","textFields","arrayField","minItems","maxItems","itemRequiredFields","projectionFields","expectedProjectionSha256"])||![c.requiredKeys,c.textFields,c.itemRequiredFields,c.projectionFields].every(x=>Array.isArray(x)&&x.length<=32&&new Set(x).size===x.length&&x.every(field))||!field(c.arrayField)||!Number.isSafeInteger(c.minItems)||!Number.isSafeInteger(c.maxItems)||c.minItems<0||c.maxItems<c.minItems||c.maxItems>4096||!c.requiredKeys.includes(c.arrayField)||c.textFields.some(x=>!c.requiredKeys.includes(x))||c.projectionFields.some(x=>!c.itemRequiredFields.includes(x))||!HEX.test(c.expectedProjectionSha256))throw Error("invalid deterministic JSON output contract");return c;}
|
|
33
|
-
export function qualifyMeasuredOutput(output:string,input:MeasuredOutputContract){const contract=checkedContract(input),outputSha256=hash(output);if(contract.version==="measured-output-exact-v1")return{eligible:outputSha256===contract.expectedSha256,outputSha256,projectionSha256:null};let value:unknown;try{value=JSON.parse(output);}catch{return{eligible:false,outputSha256,projectionSha256:null};}if(!value||typeof value!=="object"||Array.isArray(value)||Object.keys(value).sort().join()!==[...contract.requiredKeys].sort().join())return{eligible:false,outputSha256,projectionSha256:null};const object=value as Record<string,unknown>,items=object[contract.arrayField];if(contract.textFields.some(x=>typeof object[x]!=="string"||!(object[x] as string).trim())||!Array.isArray(items)||items.length<contract.minItems||items.length>contract.maxItems||items.some(x=>!x||typeof x!=="object"||Array.isArray(x)||contract.itemRequiredFields.some(k=>!Object.hasOwn(x,k))))return{eligible:false,outputSha256,projectionSha256:null};const projection=(items as Record<string,unknown>[]).map(item=>Object.fromEntries(contract.projectionFields.map(k=>[k,item[k]]))),projectionSha256=hash(intentKey(projection));return{eligible:projectionSha256===contract.expectedProjectionSha256,outputSha256,projectionSha256};}
|
|
34
|
-
|
|
35
|
-
function checkedOrder(input:MeasuredOrder,budget:GovernedBudgetBinding):MeasuredOrder{
|
|
36
|
-
const order=JSON.parse(intentKey(input)) as MeasuredOrder;if(!exact(order,["version","orderId","authorityDigest","budgetDigest","nodes"])||order.version!=="measured-order-v1"||!ID.test(order.orderId)||!HEX.test(order.authorityDigest)||order.budgetDigest!==resourceBindingDigest(budget)||!Array.isArray(order.nodes)||!order.nodes.length||order.nodes.length>8)throw Error("invalid bounded measured order");
|
|
37
|
-
const ids=new Set<string>(),attempts=new Set<string>();let inputBytes=0,count=0;
|
|
38
|
-
for(const node of order.nodes){if(!exact(node,["nodeId","dependencies","attempts"])||!ID.test(node.nodeId)||ids.has(node.nodeId)||!Array.isArray(node.dependencies)||node.dependencies.length>8||new Set(node.dependencies).size!==node.dependencies.length||!Array.isArray(node.attempts)||!node.attempts.length||node.attempts.length>3)throw Error("invalid node/dependency/recovery policy");ids.add(node.nodeId);
|
|
39
|
-
for(const a of node.attempts){if(!exact(a,["attemptId","model","thinkingLevel","prompt","deadlineMs","terminationGraceMs","maxRetainedOutputBytes","maxOutputTokens","includeDependencies","qualification"])||!ID.test(a.attemptId)||attempts.has(a.attemptId)||typeof a.includeDependencies!=="boolean"||!["openai-codex/gpt-5.6-sol","openai-codex/gpt-5.6-terra"].includes(a.model)||typeof a.prompt!=="string"||!a.prompt.length||Buffer.byteLength(a.prompt)>16384||!Number.isSafeInteger(a.deadlineMs)||a.deadlineMs<1000||a.deadlineMs>300000||!Number.isSafeInteger(a.terminationGraceMs)||a.terminationGraceMs<100||a.terminationGraceMs>10000||!Number.isSafeInteger(a.maxRetainedOutputBytes)||a.maxRetainedOutputBytes<1||a.maxRetainedOutputBytes>1024*1024||!Number.isSafeInteger(a.maxOutputTokens)||a.maxOutputTokens<1||a.maxOutputTokens>16384)throw Error("invalid read-only model attempt");checkedContract(a.qualification);attempts.add(a.attemptId);inputBytes+=Buffer.byteLength(a.prompt);count++;}
|
|
40
|
-
}
|
|
41
|
-
for(const node of order.nodes)for(const attempt of node.attempts)if(attempt.includeDependencies){let extra=0;for(const dependency of node.dependencies){const prior=order.nodes.find(n=>n.nodeId===dependency);extra+=256+Math.max(...(prior?.attempts.map(a=>a.maxRetainedOutputBytes)??[0]));}if(Buffer.byteLength(attempt.prompt)+extra>16384)throw Error("sealed dependency prompt exceeds attempt bound");inputBytes+=extra;}
|
|
42
|
-
if(count>budget.limits.maxAttempts||inputBytes>budget.limits.maxInputBytes||budget.limits.maxConcurrent<count)throw Error("order exceeds original accounting allowance");
|
|
43
|
-
const visiting=new Set<string>(),done=new Set<string>();const visit=(id:string)=>{if(done.has(id))return;if(visiting.has(id))throw Error("dependency cycle");const node=order.nodes.find(n=>n.nodeId===id);if(!node)throw Error("missing dependency");visiting.add(id);node.dependencies.forEach(visit);visiting.delete(id);done.add(id);};order.nodes.forEach(n=>visit(n.nodeId));return order;
|
|
44
|
-
}
|
|
45
|
-
export const measuredOrderDigest=(order:MeasuredOrder)=>hash(order);
|
|
46
|
-
export function measuredOrderAcknowledgementDigest(input:MeasuredOrderAcknowledgement){const value=JSON.parse(intentKey(input)) as MeasuredOrderAcknowledgement;if(!exact(value,["version","requestId","bindingDigest","attemptId","claimOwner","claimDigest"])||value.version!=="measured-order-ack-v1"||![value.requestId,value.attemptId,value.claimOwner].every(x=>ID.test(x))||![value.bindingDigest,value.claimDigest].every(x=>HEX.test(x)))throw Error("invalid unknown acknowledgement");return hash(value);}
|
|
47
|
-
function paths(directory:string){return{binding:join(directory,"binding.json"),journal:join(directory,"journal.jsonl")};}
|
|
48
|
-
async function privateDirectory(directory:string){const st=await lstat(directory,{bigint:true});if(!st.isDirectory()||(st.mode&0o077n)||st.uid!==BigInt(process.getuid!())||await realpath(directory)!==directory)throw Error("owner-private measured order directory required");}
|
|
49
|
-
export async function createMeasuredOrder(input:{directory:string;budget:GovernedBudgetBinding;order:MeasuredOrder}):Promise<Readonly<MeasuredOrderBinding>>{
|
|
50
|
-
if(!isAbsolute(input.directory)||resolve(input.directory)!==input.directory)throw Error("absolute measured order directory required");const order=checkedOrder(input.order,input.budget);await mkdir(input.directory,{recursive:false,mode:0o700});await privateDirectory(input.directory);
|
|
51
|
-
const p=paths(input.directory);await writeFile(p.journal,"",{mode:0o600,flag:"wx"});const directoryStat=await lstat(input.directory,{bigint:true}),journalStat=await lstat(p.journal,{bigint:true}),identity={directory:input.directory,directoryDevice:String(directoryStat.dev),directoryInode:String(directoryStat.ino),journalDevice:String(journalStat.dev),journalInode:String(journalStat.ino)};
|
|
52
|
-
const binding={version:"measured-order-binding-v1" as const,...identity,budget:input.budget,order,digest:hash({...identity,budgetDigest:resourceBindingDigest(input.budget),orderDigest:measuredOrderDigest(order)})};await writeFile(p.binding,intentKey(binding)+"\n",{mode:0o600,flag:"wx"});return freezeWork(binding) as unknown as Readonly<MeasuredOrderBinding>;
|
|
53
|
-
}
|
|
54
|
-
function checkedBinding(input:MeasuredOrderBinding):MeasuredOrderBinding{const b=JSON.parse(intentKey(input)) as MeasuredOrderBinding,identity={directory:b.directory,directoryDevice:b.directoryDevice,directoryInode:b.directoryInode,journalDevice:b.journalDevice,journalInode:b.journalInode};if(!exact(b,["version","directory","directoryDevice","directoryInode","journalDevice","journalInode","budget","order","digest"])||b.version!=="measured-order-binding-v1"||!isAbsolute(b.directory)||resolve(b.directory)!==b.directory||![b.directoryDevice,b.directoryInode,b.journalDevice,b.journalInode].every(x=>/^\d+$/.test(x))||b.digest!==hash({...identity,budgetDigest:resourceBindingDigest(b.budget),orderDigest:measuredOrderDigest(checkedOrder(b.order,b.budget))}))throw Error("invalid measured order binding");return b;}
|
|
55
|
-
async function pinnedJournal(binding:MeasuredOrderBinding,writable=false){const path=paths(binding.directory).journal,handle=await open(path,(writable?constants.O_RDWR|constants.O_APPEND:constants.O_RDONLY)|constants.O_NOFOLLOW);try{const st=await handle.stat({bigint:true});if(!st.isFile()||st.nlink!==1n||(st.mode&0o077n)||String(st.dev)!==binding.journalDevice||String(st.ino)!==binding.journalInode)throw Error("measured order binding changed");return handle;}catch(error){await handle.close();throw error;}}
|
|
56
|
-
async function linked(binding:MeasuredOrderBinding){const st=await lstat(paths(binding.directory).journal,{bigint:true});if(!st.isFile()||st.nlink!==1n||String(st.dev)!==binding.journalDevice||String(st.ino)!==binding.journalInode||(await realpath(paths(binding.directory).journal))!==paths(binding.directory).journal)throw Error("measured order binding changed");}
|
|
57
|
-
function parseJournal(text:string):JournalEvent[]{if(text&&!text.endsWith("\n"))throw Error("incomplete measured order journal");const rows=text?text.trimEnd().split("\n").map(line=>{const row=JSON.parse(line) as JournalEvent;if(journalKey(row)!==line)throw Error("noncanonical measured order journal");return row;}):[];let prior:string|null=null;for(let i=0;i<rows.length;i++){const row=rows[i],copy={...row} as any,claimed=copy.digest;delete copy.digest;if(row.sequence!==i||row.previousDigest!==prior||claimed!==journalHash(copy))throw Error("invalid measured order journal");prior=claimed;}return rows;}
|
|
58
|
-
async function appendJournal(binding:MeasuredOrderBinding,event:Omit<JournalEvent,"sequence"|"previousDigest"|"digest">){const path=paths(binding.directory).journal;return withFileLock(path,"measured order",async()=>{const handle=await pinnedJournal(binding,true);try{const rows=parseJournal(await handle.readFile("utf8")),base={...event,sequence:rows.length,previousDigest:rows.at(-1)?.digest??null} as any,record={...base,digest:journalHash(base)} as JournalEvent;await linked(binding);await handle.writeFile(journalKey(record)+"\n");await handle.sync();return record;}finally{await handle.close();}});}
|
|
59
|
-
function project(order:MeasuredOrder,events:JournalEvent[],currentOwner:string):MeasuredOrderNodeView[]{const rows=new Map<string,MeasuredOrderNodeView>();const evaluate=(node:MeasuredOrderNode):MeasuredOrderNodeView=>{const prior=rows.get(node.nodeId);if(prior)return prior;const row:MeasuredOrderNodeView={nodeId:node.nodeId,state:"exhausted",action:"none",attemptId:null,outputSha256:null,unknownClaim:null};if(node.dependencies.some(id=>evaluate(order.nodes.find(n=>n.nodeId===id)!).state!=="satisfied")){row.state="dependency-blocked";row.action="wait";rows.set(node.nodeId,row);return row;}
|
|
60
|
-
for(const attempt of node.attempts){const claim=events.find(e=>e.type==="claim"&&e.attemptId===attempt.attemptId) as Extract<JournalEvent,{type:"claim"}>|undefined;if(!claim){row.state="eligible";row.action="dispatch";row.attemptId=attempt.attemptId;break;}const result=events.find(e=>e.type==="result"&&e.attemptId===attempt.attemptId) as Extract<JournalEvent,{type:"result"}>|undefined;const acknowledged=events.some(e=>e.type==="acknowledge-unknown"&&e.request.attemptId===attempt.attemptId&&e.request.claimDigest===claim.digest&&e.request.claimOwner===claim.owner);if(!result){if(claim.owner!==currentOwner){if(acknowledged)continue;row.state="unknown";row.action="acknowledge";row.unknownClaim={owner:claim.owner,digest:claim.digest};}else{row.state="running";row.action="wait";}row.attemptId=attempt.attemptId;break;}if(result.state==="unknown"){if(!acknowledged){row.state="unknown";row.action="acknowledge";row.attemptId=attempt.attemptId;row.unknownClaim={owner:claim.owner,digest:claim.digest};break;}continue;}if(result.state==="completed"){row.state="satisfied";row.outputSha256=result.outputSha256;row.attemptId=attempt.attemptId;break;}}
|
|
61
|
-
rows.set(node.nodeId,row);return row;};return order.nodes.map(evaluate);}
|
|
62
|
-
export function openMeasuredOrder(input:MeasuredOrderBinding,hostAuthority:MeasuredOrderAuthority|null,host:MeasuredSessionHost){const binding=checkedBinding(input),p=paths(binding.directory),owner=randomUUID(),authorized=()=>hostAuthority?.authorityDigest===binding.order.authorityDigest&&hostAuthority.orderDigests.includes(measuredOrderDigest(binding.order));
|
|
63
|
-
const read=async()=>{await privateDirectory(binding.directory);const directoryStat=await lstat(binding.directory,{bigint:true});if(String(directoryStat.dev)!==binding.directoryDevice||String(directoryStat.ino)!==binding.directoryInode||(await readFile(p.binding,"utf8")).trimEnd()!==intentKey(binding))throw Error("measured order binding changed");await linked(binding);const handle=await pinnedJournal(binding);try{return parseJournal(await handle.readFile("utf8"));}finally{await handle.close();}};
|
|
64
|
-
const inspect=async()=>{const events=await read(),accounting=await openResourceBudget(binding.budget).inspect(),diagnostics=events.filter((e):e is Extract<JournalEvent,{type:"result"}>=>e.type==="result"&&e.state!=="completed").map(e=>`${e.attemptId}:${e.state}`);return freezeWork({version:"measured-order-view-v1",orderId:binding.order.orderId,nodes:project(binding.order,events,owner),resources:accounting,diagnostics,acceptance:"not-assessed",freshness:"snapshot-unknown" as const});};
|
|
65
|
-
return Object.freeze({inspect,async advance(){if(!authorized())throw Error("independent exact order authority required");await read();let selected:MeasuredOrderAttempt|undefined,claim:Extract<JournalEvent,{type:"claim"}>|undefined;
|
|
66
|
-
await withFileLock(p.journal,"measured order advance",async()=>{const handle=await pinnedJournal(binding,true);try{const events=parseJournal(await handle.readFile("utf8")),eligible=project(binding.order,events,owner).find(n=>n.state==="eligible");if(!eligible)return;selected=binding.order.nodes.flatMap(n=>n.attempts).find(a=>a.attemptId===eligible.attemptId)!;const base={type:"claim",sequence:events.length,previousDigest:events.at(-1)?.digest??null,attemptId:selected.attemptId,owner} as const;claim={...base,digest:hash(base)};await linked(binding);await handle.writeFile(intentKey(claim)+"\n");await handle.sync();}finally{await handle.close();}});
|
|
67
|
-
if(!selected||!claim)return inspect();const node=binding.order.nodes.find(n=>n.attempts.some(a=>a.attemptId===selected!.attemptId))!,index=node.attempts.findIndex(a=>a.attemptId===selected!.attemptId),controller=new AbortController();let state:Extract<JournalEvent,{type:"result"}>["state"]="failed",result:unknown=null,outputSha256:string|null=null;
|
|
68
|
-
try{const accounting=await openResourceBudget(binding.budget).inspect(),parent=[...node.attempts.slice(0,index)].reverse().find(a=>accounting.reservations.some(r=>r.attemptId===a.attemptId))??null,events=await read();let prompt=selected.prompt;if(selected.includeDependencies)for(const dependency of node.dependencies){const dependencyNode=binding.order.nodes.find(n=>n.nodeId===dependency)!,prior=dependencyNode.attempts.map(a=>events.find(e=>e.type==="result"&&e.attemptId===a.attemptId)).find((e):e is Extract<JournalEvent,{type:"result"}>=>e?.type==="result"&&e.state==="completed"),output=(prior?.result as {output?:unknown})?.output;if(!prior||typeof output!=="string"||hash(output)!==prior.outputSha256)throw Error("sealed dependency output unavailable");prompt+=`\n\n<sealed-dependency node=${JSON.stringify(dependency)} sha256=${JSON.stringify(prior.outputSha256)}>\n${output}\n</sealed-dependency>`;}
|
|
69
|
-
result=await runMeasuredAgentSession({budget:binding.budget,attempt:{attemptId:selected.attemptId,orderId:binding.order.orderId,experimentId:`${binding.order.orderId}:${node.nodeId}`,kind:parent?"retry":"primary",parentAttemptId:parent?.attemptId??null},model:selected.model,thinkingLevel:selected.thinkingLevel,prompt,deadlineMs:selected.deadlineMs,terminationGraceMs:selected.terminationGraceMs,maxRetainedOutputBytes:selected.maxRetainedOutputBytes,maxOutputTokens:selected.maxOutputTokens,signal:controller.signal},host);const qualified=qualifyMeasuredOutput((result as {output:string}).output,selected.qualification);outputSha256=qualified.outputSha256;state=qualified.eligible?"completed":"mismatch";}catch(error){result=error instanceof MeasuredSessionFailure?error.evidence:{errorType:error instanceof Error?error.name:"unknown",errorCode:typeof error==="object"&&error&&"code" in error?String(error.code):null,message:error instanceof Error?error.message:"unknown"};state=error instanceof MeasuredSessionUnknownError?"unknown":error instanceof MeasuredSessionFailure&&(error.evidence as {state?:string})?.state==="cancelled"?"cancelled":"failed";}
|
|
70
|
-
let event={type:"result" as const,attemptId:selected.attemptId,owner:claim.owner,state,outputSha256,result} as Omit<JournalEvent,"sequence"|"previousDigest"|"digest">;try{journalKey(event);}catch(error){if(!(error instanceof JournalSerializationError))throw error;event={type:"result",attemptId:selected.attemptId,owner:claim.owner,state:"failed",outputSha256,result:{errorType:"JournalSerializationError",errorCode:"MEASURED_RESULT_SERIALIZATION_FAILED",message:"measured result could not be durably serialized"}} as Omit<JournalEvent,"sequence"|"previousDigest"|"digest">;journalKey(event);}await appendJournal(binding,event);return inspect();},
|
|
71
|
-
async acknowledgeUnknown(request:MeasuredOrderAcknowledgement,authority:MeasuredOrderAuthority|null){const digest=measuredOrderAcknowledgementDigest(request);if(authority?.authorityDigest!==binding.order.authorityDigest||!authority.acknowledgementDigests.includes(digest)||request.bindingDigest!==binding.digest)throw Error("independent exact acknowledgement authority required");await read();await withFileLock(p.journal,"measured order acknowledgement",async()=>{const handle=await pinnedJournal(binding,true);try{const events=parseJournal(await handle.readFile("utf8")),claim=events.find(e=>e.type==="claim"&&e.attemptId===request.attemptId) as Extract<JournalEvent,{type:"claim"}>|undefined,result=events.find(e=>e.type==="result"&&e.attemptId===request.attemptId) as Extract<JournalEvent,{type:"result"}>|undefined;if(!claim||claim.owner!==request.claimOwner||claim.digest!==request.claimDigest||!(result?.state==="unknown"||!result&&claim.owner!==owner)||events.some(e=>e.type==="acknowledge-unknown"&&e.request.attemptId===request.attemptId))throw Error("exact current unknown claim required");const base={type:"acknowledge-unknown",sequence:events.length,previousDigest:events.at(-1)!.digest,request} as const,record={...base,digest:hash(base)};await linked(binding);await handle.writeFile(intentKey(record)+"\n");await handle.sync();}finally{await handle.close();}});return inspect();}});
|
|
72
|
-
}
|
package/src/measured-session.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
4
|
-
import { createAgentSession, DefaultResourceLoader, ModelRuntime, SessionManager, SettingsManager } from '@earendil-works/pi-coding-agent';
|
|
5
|
-
import { openResourceBudget, type AttemptDemand, type GovernedBudgetBinding } from './resource-budget.ts';
|
|
6
|
-
import { freezeWork } from './work-ledger-json.ts';
|
|
7
|
-
|
|
8
|
-
const MODELS=['openai-codex/gpt-5.6-sol','openai-codex/gpt-5.6-terra'] as const;
|
|
9
|
-
const THINKING=['off','minimal','low','medium','high','xhigh','max'] as const;
|
|
10
|
-
export interface ProviderUsage {input:number;output:number;cacheRead:number;cacheWrite:number;reasoning:number;totalTokens:number;cost:{input:number;output:number;cacheRead:number;cacheWrite:number;total:number}}
|
|
11
|
-
export interface MeasuredSessionHostInput {model:typeof MODELS[number];thinkingLevel:typeof THINKING[number];prompt:string;deadlineMs:number;maxOutputTokens:number;tools:readonly [];discovery:'factory-only';signal:AbortSignal}
|
|
12
|
-
export interface MeasuredSessionHostResult {output:string;usage:ProviderUsage;provider:'openai-codex';model:'gpt-5.6-sol'|'gpt-5.6-terra';stopReason:string}
|
|
13
|
-
export interface MeasuredSessionHost {run(input:MeasuredSessionHostInput):Promise<MeasuredSessionHostResult>}
|
|
14
|
-
export interface MeasuredSessionInput {budget:GovernedBudgetBinding;attempt:Omit<AttemptDemand,'inputBytes'|'inputDigest'>;model:typeof MODELS[number];thinkingLevel:typeof THINKING[number];prompt:string;deadlineMs:number;terminationGraceMs:number;maxRetainedOutputBytes:number;maxOutputTokens:number;signal?:AbortSignal}
|
|
15
|
-
export class MeasuredSessionFailure extends Error {readonly evidence:unknown;constructor(message:string,evidence:unknown){super(message);this.name='MeasuredSessionFailure';this.evidence=evidence;}}
|
|
16
|
-
export class MeasuredSessionUnknownError extends Error {constructor(){super('measured session did not settle after owned abort; reservation remains active');this.name='MeasuredSessionUnknownError';}}
|
|
17
|
-
const finite=(value:unknown)=>typeof value==='number'&&Number.isFinite(value)&&value>=0;
|
|
18
|
-
function checkedUsage(value:ProviderUsage):ProviderUsage {
|
|
19
|
-
if(!value||typeof value!=='object'||Object.keys(value).sort().join()!=='cacheRead,cacheWrite,cost,input,output,reasoning,totalTokens'||![value.input,value.output,value.cacheRead,value.cacheWrite,value.reasoning,value.totalTokens].every(finite)||!Number.isSafeInteger(value.totalTokens)||!value.cost||Object.keys(value.cost).sort().join()!=='cacheRead,cacheWrite,input,output,total'||!Object.values(value.cost).every(finite))throw Error('provider usage unavailable or malformed');
|
|
20
|
-
return JSON.parse(JSON.stringify(value));
|
|
21
|
-
}
|
|
22
|
-
function checked(input:MeasuredSessionInput):MeasuredSessionInput {
|
|
23
|
-
if(!input||typeof input!=='object'||!MODELS.includes(input.model)||!THINKING.includes(input.thinkingLevel))throw Error('measured sessions require exact Codex Sol or Terra');
|
|
24
|
-
if(typeof input.prompt!=='string'||!input.prompt.length||Buffer.byteLength(input.prompt)>65536||!Number.isSafeInteger(input.deadlineMs)||input.deadlineMs<1000||input.deadlineMs>300000||!Number.isSafeInteger(input.terminationGraceMs)||input.terminationGraceMs<100||input.terminationGraceMs>10000||!Number.isSafeInteger(input.maxRetainedOutputBytes)||input.maxRetainedOutputBytes<1||input.maxRetainedOutputBytes>1024*1024||!Number.isSafeInteger(input.maxOutputTokens)||input.maxOutputTokens<1||input.maxOutputTokens>16384)throw Error('invalid measured session bounds');
|
|
25
|
-
if(input.signal?.aborted)throw new MeasuredSessionFailure('measured session cancelled before reservation',{state:'cancelled-before-reservation',reason:'caller-signal'});
|
|
26
|
-
return input;
|
|
27
|
-
}
|
|
28
|
-
/** Opt-in one-prompt route. Existing resource budgets own attempts; byte retention is checked after generation. */
|
|
29
|
-
export async function runMeasuredAgentSession(raw:MeasuredSessionInput,host:MeasuredSessionHost){
|
|
30
|
-
const input=checked(raw),bytes=Buffer.from(input.prompt),budget=openResourceBudget(input.budget),permit=await budget.reserve({...input.attempt,inputBytes:bytes.length,inputDigest:createHash('sha256').update(bytes).digest('hex')});
|
|
31
|
-
const controller=new AbortController(),abort=()=>controller.abort(input.signal?.reason??'operator-cancellation');input.signal?.addEventListener('abort',abort,{once:true});if(input.signal?.aborted)abort();
|
|
32
|
-
const timer=setTimeout(()=>controller.abort('deadline'),input.deadlineMs);let outcome:'completed'|'failed'|'cancelled'|null='failed';
|
|
33
|
-
try{
|
|
34
|
-
const unknown=new Promise<never>((_,reject)=>controller.signal.addEventListener('abort',()=>setTimeout(()=>reject(new MeasuredSessionUnknownError()),input.terminationGraceMs),{once:true}));
|
|
35
|
-
if(controller.signal.aborted)throw new MeasuredSessionFailure('measured session cancelled after reservation',{state:'cancelled-before-host',reason:'caller-signal'});
|
|
36
|
-
const running=host.run({model:input.model,thinkingLevel:input.thinkingLevel,prompt:input.prompt,deadlineMs:input.deadlineMs,maxOutputTokens:input.maxOutputTokens,tools:[],discovery:'factory-only',signal:controller.signal});
|
|
37
|
-
const result=await Promise.race([running,unknown]);
|
|
38
|
-
const outputBytes=Buffer.from(result.output),outputEvidence={sha256:createHash('sha256').update(outputBytes).digest('hex'),bytes:outputBytes.length,retainedPrefix:outputBytes.subarray(0,input.maxRetainedOutputBytes).toString('utf8')};
|
|
39
|
-
let usage:ProviderUsage;try{usage=checkedUsage(result.usage);}catch(error){throw new MeasuredSessionFailure(String(error),{state:'failed',model:result.model,stopReason:result.stopReason,output:outputEvidence});}
|
|
40
|
-
if(result.provider!=='openai-codex'||`${result.provider}/${result.model}`!==input.model)throw new MeasuredSessionFailure('measured model identity mismatch',{state:'failed',observedProvider:result.provider,observedModel:result.model,stopReason:result.stopReason,output:outputEvidence,usage});
|
|
41
|
-
if(outputEvidence.bytes>input.maxRetainedOutputBytes)throw new MeasuredSessionFailure('measured retained-output bound exceeded',{state:'failed',model:input.model,stopReason:result.stopReason,output:outputEvidence,usage});
|
|
42
|
-
if(controller.signal.aborted||result.stopReason!=='stop')throw new MeasuredSessionFailure('measured assistant did not stop cleanly',{state:controller.signal.aborted?'cancelled':'failed',model:input.model,stopReason:result.stopReason,output:outputEvidence,usage});
|
|
43
|
-
outcome='completed';return freezeWork({version:'measured-session-result-v1',state:'completed',model:input.model,thinkingLevel:input.thinkingLevel,output:result.output,usage,stopReason:result.stopReason,acceptance:'not-assessed',grantExpansion:false});
|
|
44
|
-
}catch(error){
|
|
45
|
-
if(error instanceof MeasuredSessionUnknownError){outcome=null;throw error;}
|
|
46
|
-
if(controller.signal.aborted)outcome='cancelled';
|
|
47
|
-
if(error instanceof MeasuredSessionFailure)throw error;
|
|
48
|
-
throw new MeasuredSessionFailure('measured host failed',{state:controller.signal.aborted?'cancelled':'failed',errorType:error instanceof Error?error.name:'unknown'});
|
|
49
|
-
}
|
|
50
|
-
finally{clearTimeout(timer);input.signal?.removeEventListener('abort',abort);if(outcome)await permit.settle(outcome);}
|
|
51
|
-
}
|
|
52
|
-
export interface MeasuredAuthRuntime {isUsingOAuth(provider:string):boolean;isUsingSubscription(provider:string):boolean;checkAuth(provider:string,options?:{signal?:AbortSignal}):Promise<{type:string}|undefined>}
|
|
53
|
-
export async function verifyMeasuredSubscription(runtime:MeasuredAuthRuntime,signal?:AbortSignal){
|
|
54
|
-
signal?.throwIfAborted();const auth=await runtime.checkAuth('openai-codex',{signal});signal?.throwIfAborted();
|
|
55
|
-
if(auth?.type!=='oauth'||!runtime.isUsingOAuth('openai-codex')||!runtime.isUsingSubscription('openai-codex'))throw Error('exact OpenAI Codex OAuth subscription authorization required');
|
|
56
|
-
}
|
|
57
|
-
/** Concrete SDK host: in-memory session/settings, empty discovery roots, no tools, one factory-named inline extension. */
|
|
58
|
-
export function piSdkMeasuredSessionHost():MeasuredSessionHost{return{async run(input){
|
|
59
|
-
const root=await mkdtemp(join(resolve(process.env.TMPDIR??'/tmp'),'pi-daddy-measured-'));let session:Awaited<ReturnType<typeof createAgentSession>>['session']|undefined;
|
|
60
|
-
try{
|
|
61
|
-
const agentDir=join(root,'agent');await mkdir(agentDir,{mode:0o700});const settings=SettingsManager.inMemory({compaction:{enabled:false},retry:{enabled:false,maxRetries:0}});
|
|
62
|
-
const loader=new DefaultResourceLoader({cwd:root,agentDir,settingsManager:settings,systemPromptOverride:()=> 'Follow the supplied bounded task. Do not use tools or claim acceptance.',agentsFilesOverride:()=>({agentsFiles:[],diagnostics:[]}),skillsOverride:()=>({skills:[],diagnostics:[]}),promptsOverride:()=>({prompts:[],diagnostics:[]}),extensionFactories:[{name:'pi-daddy-measured-session',factory:()=>{}}]});await loader.reload();
|
|
63
|
-
input.signal.throwIfAborted();const runtime=await ModelRuntime.create({signal:input.signal});input.signal.throwIfAborted();await verifyMeasuredSubscription(runtime,input.signal);input.signal.throwIfAborted();
|
|
64
|
-
const [provider,modelId]=input.model.split('/'),found=runtime.getModel(provider,modelId);if(!found)throw Error('requested measured model unavailable');
|
|
65
|
-
const created=await createAgentSession({cwd:root,agentDir,model:{...found,maxTokens:input.maxOutputTokens},thinkingLevel:input.thinkingLevel,modelRuntime:runtime,resourceLoader:loader,sessionManager:SessionManager.inMemory(root),settingsManager:settings,noTools:'all'});session=created.session;if(created.extensionsResult.errors.length)throw Error('factory-only extension load failed');
|
|
66
|
-
const abort=()=>void session!.abort();input.signal.addEventListener('abort',abort,{once:true});try{if(input.signal.aborted){await session.abort();throw input.signal.reason;}await session.prompt(input.prompt,{expandPromptTemplates:false});}finally{input.signal.removeEventListener('abort',abort);}
|
|
67
|
-
const message=[...session.messages].reverse().find(m=>m.role==='assistant');if(!message)throw Error('measured assistant result unavailable');
|
|
68
|
-
return {output:message.content.filter(c=>c.type==='text').map(c=>c.text).join(''),usage:message.usage as ProviderUsage,provider:message.provider as MeasuredSessionHostResult['provider'],model:message.model as MeasuredSessionHostResult['model'],stopReason:message.stopReason};
|
|
69
|
-
}finally{session?.dispose();await rm(root,{recursive:true,force:true});}
|
|
70
|
-
}};}
|
package/src/model-preflight.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { refusal, type StructuredRefusal } from "./refusals.ts";
|
|
2
|
-
|
|
3
|
-
export const ENV_ALLOW_UNRESOLVED_MODELS = "PI_GRANTS_ALLOW_UNRESOLVED_MODELS";
|
|
4
|
-
|
|
5
|
-
/** Pi's resolved catalogue carries provider support in thinkingLevelMap. Never silently clamp a user's choice. */
|
|
6
|
-
export function supportedModelEfforts(model: { reasoning: boolean; thinkingLevelMap?: Partial<Record<string, string | null>> }): ("off"|"minimal"|"low"|"medium"|"high"|"xhigh"|"max")[] {
|
|
7
|
-
if (!model.reasoning) return ["off"];
|
|
8
|
-
return (["off","minimal","low","medium","high","xhigh","max"] as const).filter(level => {
|
|
9
|
-
const mapped=model.thinkingLevelMap?.[level];
|
|
10
|
-
return mapped!==null && ((level!=="xhigh"&&level!=="max") || mapped!==undefined);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ModelCatalogue {
|
|
15
|
-
find(provider: string, modelId: string): unknown;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Resolve an explicit provider/id against pi's own session catalogue without probing credentials or network. */
|
|
19
|
-
export function preflightModel(
|
|
20
|
-
model: string | undefined,
|
|
21
|
-
catalogue: ModelCatalogue,
|
|
22
|
-
cache: Map<string, boolean>,
|
|
23
|
-
allowUnresolved: boolean,
|
|
24
|
-
): StructuredRefusal | undefined {
|
|
25
|
-
if (model === undefined || allowUnresolved) return undefined;
|
|
26
|
-
const slash = model.indexOf("/");
|
|
27
|
-
const provider = slash > 0 ? model.slice(0, slash) : "";
|
|
28
|
-
const id = slash > 0 ? model.slice(slash + 1) : "";
|
|
29
|
-
let resolved = cache.get(model);
|
|
30
|
-
if (resolved === undefined) {
|
|
31
|
-
resolved = provider.length > 0 && id.length > 0 && catalogue.find(provider, id) !== undefined;
|
|
32
|
-
cache.set(model, resolved);
|
|
33
|
-
}
|
|
34
|
-
if (resolved) return undefined;
|
|
35
|
-
return refusal(
|
|
36
|
-
"MODEL_UNRESOLVED",
|
|
37
|
-
`grants: model ${model || "(empty)"} is not in pi's session catalogue; use provider/id from /model, ` +
|
|
38
|
-
`or set ${ENV_ALLOW_UNRESOLVED_MODELS}=1 to let pi attempt custom resolution`,
|
|
39
|
-
{ model: model || "(empty)" },
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { lstat, realpath, mkdir } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute, join, parse, resolve } from "node:path";
|
|
3
|
-
import { createHash } from "node:crypto";
|
|
4
|
-
import { ENV_NATIVE_SESSION_ROOT } from "./native-session.ts";
|
|
5
|
-
export interface NativeSessionHost { /** Explicit host opt-in captured once, not model-supplied. */ readonly nativeSessionRoot?: string }
|
|
6
|
-
export const nativeSessionRootFromEnv=(env:NodeJS.ProcessEnv)=>env[ENV_RETAIN_NATIVE_SESSIONS]==="1"?env[ENV_NATIVE_SESSION_ROOT]??"":undefined;
|
|
7
|
-
export const ENV_RETAIN_NATIVE_SESSIONS = "PI_GRANTS_RETAIN_NATIVE_SESSIONS";
|
|
8
|
-
/** Explicit ordinary-host opt-in only. Never read a destination from tool/model parameters.
|
|
9
|
-
* Allocate a fresh per-occurrence directory; no scan, existing-session takeover or transcript creation. */
|
|
10
|
-
export async function allocateNativeSessionTarget(root: string, executionId: string): Promise<string> {
|
|
11
|
-
if (!isAbsolute(root) || resolve(root) !== root || !/^[a-zA-Z0-9:_-]{1,128}$/.test(executionId)) throw new Error("explicit native root/execution identity required");
|
|
12
|
-
for (let p = root;; p = dirname(p)) {
|
|
13
|
-
const s = await lstat(p); if (!s.isDirectory() || s.isSymbolicLink()) throw new Error("native target ancestor changed");
|
|
14
|
-
if (p === parse(p).root) break;
|
|
15
|
-
}
|
|
16
|
-
const before = await lstat(root);
|
|
17
|
-
if (await realpath(root) !== root || before.mode & 0o077 || before.uid !== process.getuid?.()) throw new Error("private owned native target root required");
|
|
18
|
-
const directory = join(root, "execution-" + createHash("sha256").update(executionId).digest("hex"));
|
|
19
|
-
await mkdir(directory, { mode: 0o700 }); // EEXIST is a refusal, never permission to append an old occurrence.
|
|
20
|
-
const after = await lstat(root);
|
|
21
|
-
if (before.dev !== after.dev || before.ino !== after.ino || await realpath(directory) !== directory) throw new Error("native target root replaced");
|
|
22
|
-
return join(directory, "session.jsonl");
|
|
23
|
-
}
|