approval-md 0.2.0 → 0.4.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/README.md +85 -877
- package/SPEC.md +150 -19
- package/cli.js +66 -7
- package/dist/src/adapters/smtp.d.ts +18 -0
- package/dist/src/adapters/smtp.js +24 -3
- package/dist/src/adapters/smtp.js.map +1 -1
- package/dist/src/channels/contract.d.ts +53 -1
- package/dist/src/channels/contract.js +304 -7
- package/dist/src/channels/contract.js.map +1 -1
- package/dist/src/channels/relay-server.d.ts +90 -0
- package/dist/src/channels/relay-server.js +295 -0
- package/dist/src/channels/relay-server.js.map +1 -0
- package/dist/src/channels/relay.d.ts +273 -0
- package/dist/src/channels/relay.js +564 -0
- package/dist/src/channels/relay.js.map +1 -0
- package/dist/src/channels/tagging.js +6 -1
- package/dist/src/channels/tagging.js.map +1 -1
- package/dist/src/channels/telegram-webhook.d.ts +273 -0
- package/dist/src/channels/telegram-webhook.js +536 -0
- package/dist/src/channels/telegram-webhook.js.map +1 -0
- package/dist/src/channels/telegram.d.ts +394 -12
- package/dist/src/channels/telegram.js +621 -68
- package/dist/src/channels/telegram.js.map +1 -1
- package/dist/src/channels/web.d.ts +9 -0
- package/dist/src/channels/web.js +17 -0
- package/dist/src/channels/web.js.map +1 -1
- package/dist/src/cli/amend.js +564 -34
- package/dist/src/cli/amend.js.map +1 -1
- package/dist/src/cli/attest.d.ts +9 -0
- package/dist/src/cli/attest.js +177 -13
- package/dist/src/cli/attest.js.map +1 -1
- package/dist/src/cli/channel-relay.d.ts +108 -0
- package/dist/src/cli/channel-relay.js +334 -0
- package/dist/src/cli/channel-relay.js.map +1 -0
- package/dist/src/cli/channel-telegram-webhook.d.ts +273 -0
- package/dist/src/cli/channel-telegram-webhook.js +709 -0
- package/dist/src/cli/channel-telegram-webhook.js.map +1 -0
- package/dist/src/cli/channel-telegram.d.ts +347 -28
- package/dist/src/cli/channel-telegram.js +763 -28
- package/dist/src/cli/channel-telegram.js.map +1 -1
- package/dist/src/cli/channel.d.ts +10 -1
- package/dist/src/cli/channel.js +14 -1
- package/dist/src/cli/channel.js.map +1 -1
- package/dist/src/cli/codex-bridge.d.ts +819 -0
- package/dist/src/cli/codex-bridge.js +1607 -0
- package/dist/src/cli/codex-bridge.js.map +1 -0
- package/dist/src/cli/codex.d.ts +1 -1
- package/dist/src/cli/codex.js +304 -7
- package/dist/src/cli/codex.js.map +1 -1
- package/dist/src/cli/daemon.js +41 -6
- package/dist/src/cli/daemon.js.map +1 -1
- package/dist/src/cli/doctor.d.ts +63 -0
- package/dist/src/cli/doctor.js +1322 -122
- package/dist/src/cli/doctor.js.map +1 -1
- package/dist/src/cli/execute.d.ts +17 -1
- package/dist/src/cli/execute.js +366 -22
- package/dist/src/cli/execute.js.map +1 -1
- package/dist/src/cli/exit-codes.d.ts +12 -0
- package/dist/src/cli/exit-codes.js +13 -0
- package/dist/src/cli/exit-codes.js.map +1 -1
- package/dist/src/cli/gate.d.ts +2 -0
- package/dist/src/cli/gate.js +233 -2
- package/dist/src/cli/gate.js.map +1 -1
- package/dist/src/cli/help.d.ts +14 -2
- package/dist/src/cli/help.js +395 -82
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/hook-codex.d.ts +49 -1
- package/dist/src/cli/hook-codex.js +60 -1
- package/dist/src/cli/hook-codex.js.map +1 -1
- package/dist/src/cli/hook.d.ts +828 -4
- package/dist/src/cli/hook.js +2972 -142
- package/dist/src/cli/hook.js.map +1 -1
- package/dist/src/cli/import.js +1 -1
- package/dist/src/cli/import.js.map +1 -1
- package/dist/src/cli/init.js +16 -7
- package/dist/src/cli/init.js.map +1 -1
- package/dist/src/cli/instructions.js +24 -3
- package/dist/src/cli/instructions.js.map +1 -1
- package/dist/src/cli/log-anchor.d.ts +55 -0
- package/dist/src/cli/log-anchor.js +199 -60
- package/dist/src/cli/log-anchor.js.map +1 -1
- package/dist/src/cli/main.d.ts +0 -12
- package/dist/src/cli/main.js +56 -3
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/cli/muse.d.ts +2 -0
- package/dist/src/cli/muse.js +62 -0
- package/dist/src/cli/muse.js.map +1 -0
- package/dist/src/cli/payload.js +79 -1
- package/dist/src/cli/payload.js.map +1 -1
- package/dist/src/cli/policy-apply.d.ts +195 -0
- package/dist/src/cli/policy-apply.js +573 -0
- package/dist/src/cli/policy-apply.js.map +1 -0
- package/dist/src/cli/policy.js +14 -1
- package/dist/src/cli/policy.js.map +1 -1
- package/dist/src/cli/preflight.d.ts +151 -13
- package/dist/src/cli/preflight.js +398 -41
- package/dist/src/cli/preflight.js.map +1 -1
- package/dist/src/cli/sandbox.js +17 -1
- package/dist/src/cli/sandbox.js.map +1 -1
- package/dist/src/cli/scaffold.d.ts +1 -1
- package/dist/src/cli/scaffold.js +7 -1
- package/dist/src/cli/scaffold.js.map +1 -1
- package/dist/src/cli/serve.d.ts +53 -0
- package/dist/src/cli/serve.js +270 -0
- package/dist/src/cli/serve.js.map +1 -0
- package/dist/src/cli/setup-channel.d.ts +9 -0
- package/dist/src/cli/setup-channel.js +28 -1
- package/dist/src/cli/setup-channel.js.map +1 -1
- package/dist/src/cli/setup-common.d.ts +3 -1
- package/dist/src/cli/setup-common.js +3 -2
- package/dist/src/cli/setup-common.js.map +1 -1
- package/dist/src/cli/setup.d.ts +2 -0
- package/dist/src/cli/setup.js +94 -2
- package/dist/src/cli/setup.js.map +1 -1
- package/dist/src/cli/up.js +134 -51
- package/dist/src/cli/up.js.map +1 -1
- package/dist/src/cli/values.js +3 -4
- package/dist/src/cli/values.js.map +1 -1
- package/dist/src/cli/verb-registry.d.ts +2 -0
- package/dist/src/cli/verb-registry.js +510 -47
- package/dist/src/cli/verb-registry.js.map +1 -1
- package/dist/src/cli/wordmark.d.ts +2 -2
- package/dist/src/cli/wordmark.js +2 -2
- package/dist/src/codex/broker.d.ts +229 -0
- package/dist/src/codex/broker.js +548 -0
- package/dist/src/codex/broker.js.map +1 -0
- package/dist/src/codex/runner.d.ts +178 -0
- package/dist/src/codex/runner.js +231 -0
- package/dist/src/codex/runner.js.map +1 -0
- package/dist/src/codex/serve.d.ts +56 -0
- package/dist/src/codex/serve.js +98 -0
- package/dist/src/codex/serve.js.map +1 -0
- package/dist/src/codex/workspace-commit.d.ts +219 -0
- package/dist/src/codex/workspace-commit.js +549 -0
- package/dist/src/codex/workspace-commit.js.map +1 -0
- package/dist/src/core/advance-cycle.d.ts +51 -0
- package/dist/src/core/advance-cycle.js +66 -2
- package/dist/src/core/advance-cycle.js.map +1 -1
- package/dist/src/core/agents-md.d.ts +20 -18
- package/dist/src/core/agents-md.js +33 -31
- package/dist/src/core/agents-md.js.map +1 -1
- package/dist/src/core/attest-bootstrap.d.ts +95 -0
- package/dist/src/core/attest-bootstrap.js +135 -0
- package/dist/src/core/attest-bootstrap.js.map +1 -0
- package/dist/src/core/attest.d.ts +234 -2
- package/dist/src/core/attest.js +342 -7
- package/dist/src/core/attest.js.map +1 -1
- package/dist/src/core/audit.d.ts +73 -3
- package/dist/src/core/audit.js +65 -5
- package/dist/src/core/audit.js.map +1 -1
- package/dist/src/core/channel-lease.d.ts +322 -0
- package/dist/src/core/channel-lease.js +663 -0
- package/dist/src/core/channel-lease.js.map +1 -0
- package/dist/src/core/channel-owner.d.ts +213 -0
- package/dist/src/core/channel-owner.js +358 -0
- package/dist/src/core/channel-owner.js.map +1 -0
- package/dist/src/core/command-class.d.ts +205 -0
- package/dist/src/core/command-class.js +1433 -28
- package/dist/src/core/command-class.js.map +1 -1
- package/dist/src/core/commit-guard.d.ts +272 -0
- package/dist/src/core/commit-guard.js +424 -0
- package/dist/src/core/commit-guard.js.map +1 -0
- package/dist/src/core/daemon-actor.d.ts +45 -0
- package/dist/src/core/daemon-actor.js +54 -0
- package/dist/src/core/daemon-actor.js.map +1 -0
- package/dist/src/core/daemon-host.d.ts +178 -0
- package/dist/src/core/daemon-host.js +228 -0
- package/dist/src/core/daemon-host.js.map +1 -0
- package/dist/src/core/daemon-identity.d.ts +238 -0
- package/dist/src/core/daemon-identity.js +252 -0
- package/dist/src/core/daemon-identity.js.map +1 -0
- package/dist/src/core/dark-session.d.ts +109 -8
- package/dist/src/core/dark-session.js +266 -82
- package/dist/src/core/dark-session.js.map +1 -1
- package/dist/src/core/decision-refusal.d.ts +23 -2
- package/dist/src/core/decision-refusal.js +24 -2
- package/dist/src/core/decision-refusal.js.map +1 -1
- package/dist/src/core/env-file.d.ts +5 -0
- package/dist/src/core/env-file.js +60 -1
- package/dist/src/core/env-file.js.map +1 -1
- package/dist/src/core/execute.d.ts +15 -2
- package/dist/src/core/execute.js +15 -2
- package/dist/src/core/execute.js.map +1 -1
- package/dist/src/core/gate.d.ts +392 -6
- package/dist/src/core/gate.js +852 -24
- package/dist/src/core/gate.js.map +1 -1
- package/dist/src/core/gesture-refusal.d.ts +166 -0
- package/dist/src/core/gesture-refusal.js +188 -0
- package/dist/src/core/gesture-refusal.js.map +1 -0
- package/dist/src/core/harness-version.d.ts +128 -4
- package/dist/src/core/harness-version.js +181 -12
- package/dist/src/core/harness-version.js.map +1 -1
- package/dist/src/core/harness-wait.d.ts +82 -3
- package/dist/src/core/harness-wait.js +89 -3
- package/dist/src/core/harness-wait.js.map +1 -1
- package/dist/src/core/instance.d.ts +59 -2
- package/dist/src/core/instance.js +113 -0
- package/dist/src/core/instance.js.map +1 -1
- package/dist/src/core/log-subscribe.d.ts +21 -0
- package/dist/src/core/log-subscribe.js +16 -6
- package/dist/src/core/log-subscribe.js.map +1 -1
- package/dist/src/core/log-write-layer.d.ts +55 -0
- package/dist/src/core/log-write-layer.js +91 -0
- package/dist/src/core/log-write-layer.js.map +1 -0
- package/dist/src/core/log.d.ts +89 -22
- package/dist/src/core/log.js +197 -19
- package/dist/src/core/log.js.map +1 -1
- package/dist/src/core/payload-census.d.ts +51 -0
- package/dist/src/core/payload-census.js +125 -2
- package/dist/src/core/payload-census.js.map +1 -1
- package/dist/src/core/payload-store.d.ts +31 -0
- package/dist/src/core/payload-store.js +113 -8
- package/dist/src/core/payload-store.js.map +1 -1
- package/dist/src/core/payload.d.ts +18 -3
- package/dist/src/core/payload.js +20 -4
- package/dist/src/core/payload.js.map +1 -1
- package/dist/src/core/policy-diff.d.ts +10 -0
- package/dist/src/core/policy-diff.js +10 -2
- package/dist/src/core/policy-diff.js.map +1 -1
- package/dist/src/core/policy-explain.d.ts +17 -1
- package/dist/src/core/policy-explain.js +48 -1
- package/dist/src/core/policy-explain.js.map +1 -1
- package/dist/src/core/policy-load.d.ts +65 -1
- package/dist/src/core/policy-load.js +21 -3
- package/dist/src/core/policy-load.js.map +1 -1
- package/dist/src/core/policy-match.d.ts +81 -0
- package/dist/src/core/policy-match.js +87 -0
- package/dist/src/core/policy-match.js.map +1 -1
- package/dist/src/core/policy-proposal.d.ts +75 -0
- package/dist/src/core/policy-proposal.js +110 -4
- package/dist/src/core/policy-proposal.js.map +1 -1
- package/dist/src/core/protected-path-guard.d.ts +117 -4
- package/dist/src/core/protected-path-guard.js +362 -48
- package/dist/src/core/protected-path-guard.js.map +1 -1
- package/dist/src/core/question-preempted.d.ts +141 -0
- package/dist/src/core/question-preempted.js +152 -0
- package/dist/src/core/question-preempted.js.map +1 -0
- package/dist/src/core/read-scope.d.ts +182 -0
- package/dist/src/core/read-scope.js +256 -0
- package/dist/src/core/read-scope.js.map +1 -0
- package/dist/src/core/run-payload.d.ts +160 -0
- package/dist/src/core/run-payload.js +304 -0
- package/dist/src/core/run-payload.js.map +1 -0
- package/dist/src/core/sandbox.d.ts +81 -0
- package/dist/src/core/sandbox.js +190 -1
- package/dist/src/core/sandbox.js.map +1 -1
- package/dist/src/core/sender-identity.d.ts +501 -0
- package/dist/src/core/sender-identity.js +609 -0
- package/dist/src/core/sender-identity.js.map +1 -0
- package/dist/src/core/shlex.d.ts +102 -0
- package/dist/src/core/shlex.js +159 -0
- package/dist/src/core/shlex.js.map +1 -0
- package/dist/src/core/state.d.ts +52 -1
- package/dist/src/core/state.js +52 -6
- package/dist/src/core/state.js.map +1 -1
- package/dist/src/core/telegram-config.d.ts +79 -0
- package/dist/src/core/telegram-config.js +108 -0
- package/dist/src/core/telegram-config.js.map +1 -1
- package/dist/src/core/values.d.ts +18 -8
- package/dist/src/core/values.js +36 -1
- package/dist/src/core/values.js.map +1 -1
- package/dist/src/core/verify.d.ts +23 -1
- package/dist/src/core/verify.js +20 -2
- package/dist/src/core/verify.js.map +1 -1
- package/dist/src/daemon/advance.d.ts +10 -0
- package/dist/src/daemon/advance.js +25 -4
- package/dist/src/daemon/advance.js.map +1 -1
- package/dist/src/daemon/audit.d.ts +80 -5
- package/dist/src/daemon/audit.js +126 -6
- package/dist/src/daemon/audit.js.map +1 -1
- package/dist/src/daemon/daemon.d.ts +174 -2
- package/dist/src/daemon/daemon.js +307 -7
- package/dist/src/daemon/daemon.js.map +1 -1
- package/dist/src/daemon/git-evidence.d.ts +2 -2
- package/dist/src/daemon/git-evidence.js +1 -1
- package/dist/src/daemon/projection.d.ts +13 -2
- package/dist/src/daemon/projection.js +39 -6
- package/dist/src/daemon/projection.js.map +1 -1
- package/dist/src/mcp/server.d.ts +39 -3
- package/dist/src/mcp/server.js +30 -3
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/muse/server.d.ts +16 -0
- package/dist/src/muse/server.js +238 -0
- package/dist/src/muse/server.js.map +1 -0
- package/dist/src/serve/archive.d.ts +158 -0
- package/dist/src/serve/archive.js +354 -0
- package/dist/src/serve/archive.js.map +1 -0
- package/dist/src/serve/arguments.d.ts +93 -0
- package/dist/src/serve/arguments.js +228 -0
- package/dist/src/serve/arguments.js.map +1 -0
- package/dist/src/serve/credentials.d.ts +91 -0
- package/dist/src/serve/credentials.js +143 -0
- package/dist/src/serve/credentials.js.map +1 -0
- package/dist/src/serve/follow.d.ts +86 -0
- package/dist/src/serve/follow.js +101 -0
- package/dist/src/serve/follow.js.map +1 -0
- package/dist/src/serve/hook-thread.d.ts +134 -0
- package/dist/src/serve/hook-thread.js +333 -0
- package/dist/src/serve/hook-thread.js.map +1 -0
- package/dist/src/serve/hook-worker.d.ts +134 -0
- package/dist/src/serve/hook-worker.js +173 -0
- package/dist/src/serve/hook-worker.js.map +1 -0
- package/dist/src/serve/server.d.ts +412 -0
- package/dist/src/serve/server.js +1251 -0
- package/dist/src/serve/server.js.map +1 -0
- package/docs/README-extended.md +766 -0
- package/docs/cli-reference.md +2563 -73
- package/docs/codex-enforced-session.md +75 -2
- package/docs/codex-workspace-broker.md +118 -0
- package/package.json +6 -2
- package/schema/event.schema.json +595 -9
- package/schema/fixtures/event/invalid/approval-granted-sender-hashed-false.json +20 -0
- package/schema/fixtures/event/invalid/approval-granted-sender-hashed-raw-id.json +20 -0
- package/schema/fixtures/event/invalid/audit-gesture-refused-human-actor.json +16 -0
- package/schema/fixtures/event/invalid/audit-gesture-refused-no-actor-no-sender.json +15 -0
- package/schema/fixtures/event/invalid/audit-gesture-refused-unknown-gesture.json +16 -0
- package/schema/fixtures/event/invalid/audit-question-preempted-agent-actor.json +16 -0
- package/schema/fixtures/event/invalid/audit-question-preempted-no-question-id.json +16 -0
- package/schema/fixtures/event/invalid/audit-question-preempted-unknown-source.json +15 -0
- package/schema/fixtures/event/invalid/daemon-id-malformed.json +15 -0
- package/schema/fixtures/event/invalid/execution-started-truncated-policy-sha256.json +18 -0
- package/schema/fixtures/event/invalid/gate-path-signed-off-absolute-path.json +14 -0
- package/schema/fixtures/event/invalid/gate-path-signed-off-agent-actor.json +14 -0
- package/schema/fixtures/event/invalid/gate-path-signed-off-missing-path.json +13 -0
- package/schema/fixtures/event/invalid/harness-cap-at-margin.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-fractional.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-negative.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-string.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-without-harness-execution.json +16 -0
- package/schema/fixtures/event/invalid/harness-cap-zero.json +16 -0
- package/schema/fixtures/event/valid/approval-granted-sender-hashed.json +20 -0
- package/schema/fixtures/event/valid/approval-requested-harness-cap.json +18 -0
- package/schema/fixtures/event/valid/audit-gesture-refused-review-note.json +21 -0
- package/schema/fixtures/event/valid/audit-gesture-refused-sender-key-unavailable.json +19 -0
- package/schema/fixtures/event/valid/audit-gesture-refused.json +19 -0
- package/schema/fixtures/event/valid/audit-question-preempted-no-verdict.json +16 -0
- package/schema/fixtures/event/valid/audit-question-preempted.json +20 -0
- package/schema/fixtures/event/valid/daemon-identity-declared.json +17 -0
- package/schema/fixtures/event/valid/daemon-identity.json +15 -0
- package/schema/fixtures/event/valid/execution-started-policy-sha256.json +18 -0
- package/schema/fixtures/event/valid/gate-path-signed-off.json +14 -0
- package/schema/fixtures/event/valid/harness-kind-claude-code.json +23 -0
- package/schema/fixtures/event/valid/harness-kind-codex.json +23 -0
- package/schema/fixtures/event/valid/harness-kind-cursor.json +23 -0
- package/schema/fixtures/event/valid/harness-kind-grok.json +23 -0
- package/schema/fixtures/event/valid/harness-kind-hermes.json +23 -0
- package/schema/fixtures/event/valid/harness-kind-muse.json +23 -0
- package/schema/fixtures/policy/invalid/daemons-malformed-id.json +10 -0
- package/schema/fixtures/policy/invalid/senders-half-keyed.json +20 -0
- package/schema/fixtures/policy/valid/canonical.json +1 -1
- package/schema/fixtures/policy/valid/daemons-allowlist.json +19 -0
- package/schema/fixtures/policy/valid/senders-keyed.json +24 -0
- package/schema/fixtures/policy-md/invalid/schema-invalid-agent-may-request.md +21 -0
- package/schema/fixtures/policy-md/valid/agent-may-request.md +24 -0
- package/schema/fixtures/policy-md/valid/canonical.md +1 -1
- package/schema/fixtures/policy-md/valid/with-values.md +5 -7
- package/schema/fixtures/values/invalid/class-shaped.json +1 -1
- package/schema/fixtures/values/invalid/duplicate-entry.json +1 -1
- package/schema/fixtures/values/invalid/non-string-item.json +1 -1
- package/schema/fixtures/values/invalid/over-cap.json +1 -1
- package/schema/fixtures/values/invalid/unknown-key.json +1 -1
- package/schema/fixtures/values/invalid/version-float.json +1 -0
- package/schema/fixtures/values/invalid/version-integer.json +1 -0
- package/schema/fixtures/values/invalid/version-wrong-string.json +1 -0
- package/schema/fixtures/values/valid/empty-lists.json +2 -3
- package/schema/fixtures/values/valid/full.json +5 -7
- package/schema/fixtures/values/valid/minimal.json +1 -1
- package/schema/fixtures/values-md/invalid/schema-invalid.md +5 -3
- package/schema/fixtures/values-md/invalid/two-blocks.md +3 -3
- package/schema/fixtures/values-md/invalid/unterminated.md +2 -2
- package/schema/fixtures/values-md/invalid/version-1.md +69 -0
- package/schema/fixtures/values-md/invalid/version-unquoted.md +64 -0
- package/schema/fixtures/values-md/invalid/yaml-error.md +2 -2
- package/schema/fixtures/values-md/valid/absent.md +1 -1
- package/schema/fixtures/values-md/valid/with-values.md +5 -7
- package/schema/policy.schema.json +100 -4
- package/schema/values.schema.json +7 -11
- package/schema/fixtures/values/invalid/version-string.json +0 -1
|
@@ -49,8 +49,11 @@
|
|
|
49
49
|
* `channels/conformance.ts`.
|
|
50
50
|
*/
|
|
51
51
|
import { recordRefusedDecision } from "../core/decision-refusal.js";
|
|
52
|
-
import { decide } from "../core/gate.js";
|
|
53
|
-
import {
|
|
52
|
+
import { decide, readGatePolicy, } from "../core/gate.js";
|
|
53
|
+
import { actorForSender, isChannelDecisionRefusalCode, mapsSendersFor, recordedSenderFor, senderKeyFrom, senderRefusalLine, sendersDiffer, } from "../core/sender-identity.js";
|
|
54
|
+
import { attestationKeySha256, decideAttestation, inForcePolicyText, isAttestationActionKey, openProposalFor, proposalPolicyPath, } from "../core/policy-proposal.js";
|
|
55
|
+
import { payloadStoreDirFor } from "../core/payload-store.js";
|
|
56
|
+
import { loadPolicyText } from "../core/policy-load.js";
|
|
54
57
|
import { readVerifiedRecords } from "../core/state.js";
|
|
55
58
|
import { tick } from "../core/clock.js";
|
|
56
59
|
// ---------------------------------------------------------------------------
|
|
@@ -125,6 +128,13 @@ export const GLOSS_UNVERIFIED_SUFFIX = "(model, unverified)";
|
|
|
125
128
|
* The wording of the first three is APRV-206's, moved here unchanged.
|
|
126
129
|
*/
|
|
127
130
|
export function refusedDecisionLine(code) {
|
|
131
|
+
// APRV-324. The two the surface itself makes, worded where they are defined
|
|
132
|
+
// so one rule about what a refusal may disclose covers every channel: they
|
|
133
|
+
// name the code and nothing about the mapping — not who is mapped, not how
|
|
134
|
+
// many are, and not the id that was seen. The id is on the record, where an
|
|
135
|
+
// operator reads it deliberately; a chat is read by everyone in it.
|
|
136
|
+
if (isChannelDecisionRefusalCode(code))
|
|
137
|
+
return senderRefusalLine(code);
|
|
128
138
|
if (code === "already-decided") {
|
|
129
139
|
return "Already decided — the first answer stands; nothing was recorded.";
|
|
130
140
|
}
|
|
@@ -137,6 +147,14 @@ export function refusedDecisionLine(code) {
|
|
|
137
147
|
}
|
|
138
148
|
if (code === "expired")
|
|
139
149
|
return "Expired — the approval window has closed.";
|
|
150
|
+
// APRV-324 follow-up. The gate has always been able to return this; what
|
|
151
|
+
// changed is that a checkpoint signature and a review can too, because the
|
|
152
|
+
// sender mapping they resolve against is only in force once a human has
|
|
153
|
+
// attested the file it is written in. One sentence, every surface, and it
|
|
154
|
+
// names the repair rather than the check.
|
|
155
|
+
if (code === "policy-not-attested") {
|
|
156
|
+
return "Not recorded — APPROVAL.md has changed and nobody has attested it yet, so its rules are not in force. Re-attest it, or do this from a terminal.";
|
|
157
|
+
}
|
|
140
158
|
// APRV-235, and the reason this helper exists. The distinction the line has to
|
|
141
159
|
// carry is that nothing is wrong with the ACTION: the policy was re-attested
|
|
142
160
|
// after the question was asked, so the rules on the approver's screen are not
|
|
@@ -296,6 +314,47 @@ export function batchDeliveryIdOf(record) {
|
|
|
296
314
|
export function isTestableChannel(channel) {
|
|
297
315
|
return typeof channel.lastRendered === "function";
|
|
298
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* The policy IN FORCE, loaded from its verified bytes (APRV-455 refuter H1).
|
|
319
|
+
*
|
|
320
|
+
* `inForcePolicyText` recovers the attested text from the payload store and
|
|
321
|
+
* checks it against the attested digest from the verified log; this loads it
|
|
322
|
+
* under the path this process enforces, so a load failure reads the way the
|
|
323
|
+
* file's own would.
|
|
324
|
+
*/
|
|
325
|
+
function inForceLoad(logPath, gateOptions) {
|
|
326
|
+
const read = readVerifiedRecords(logPath, gateOptions.schemaDir === undefined ? {} : { schemaDir: gateOptions.schemaDir });
|
|
327
|
+
// A log that cannot be read keeps its own code (SPEC.md §11.1 invariant 6):
|
|
328
|
+
// a torn tail is not an unattested policy, and the repairs differ.
|
|
329
|
+
if (!read.ok)
|
|
330
|
+
return { ok: false, reason: read.message, log: { code: read.code, message: read.message } };
|
|
331
|
+
const inForce = inForcePolicyText(read.records, gateOptions.payloadStoreDir ?? payloadStoreDirFor(logPath));
|
|
332
|
+
if (!inForce.ok)
|
|
333
|
+
return { ok: false, reason: inForce.reason };
|
|
334
|
+
return {
|
|
335
|
+
ok: true,
|
|
336
|
+
load: loadPolicyText(listenerPolicyPath(gateOptions) ?? "APPROVAL.md", inForce.text, gateOptions.schemaDir === undefined ? {} : { schemaDir: gateOptions.schemaDir }),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* The refusal {@link ChannelActorOptions.requireSenderMapping} turns a
|
|
341
|
+
* configured-actor fallback into (APRV-455).
|
|
342
|
+
*
|
|
343
|
+
* `sender-unmapped`, the existing member of the surface's union, because the
|
|
344
|
+
* fact is the same one: the attested policy names nobody for this account on
|
|
345
|
+
* this channel. The recorded form follows the file, as every refusal that does
|
|
346
|
+
* not reach a mapping does (`recordedSenderFor`).
|
|
347
|
+
*/
|
|
348
|
+
function mappingRequiredRefusal(sender, load, subject) {
|
|
349
|
+
return {
|
|
350
|
+
refusal: {
|
|
351
|
+
ok: false,
|
|
352
|
+
code: "sender-unmapped",
|
|
353
|
+
message: `${subject} refused: the ${sender.channel} sender this gesture arrived from is not mapped to an approver in the attested policy, and this surface records no gesture it cannot attribute to a mapped account. It holds no human identity of its own to fall back on, by design: a relay that decided as its launch identity whenever the policy mapped nobody would let whoever holds its secret decide as that identity. Nothing was decided; the observed account is on the audit.decision_refused record. An operator who recognizes it adds it to that approver's \`senders\` block and re-attests.`,
|
|
354
|
+
},
|
|
355
|
+
recorded: recordedSenderFor(load, sender, senderKeyFrom()),
|
|
356
|
+
};
|
|
357
|
+
}
|
|
299
358
|
/**
|
|
300
359
|
* Turn a reported gesture into a log event — by calling the gate, and by doing
|
|
301
360
|
* nothing else.
|
|
@@ -340,7 +399,86 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
|
|
|
340
399
|
if (decision.batchDeliveryId !== undefined) {
|
|
341
400
|
options.batchDeliveryId = decision.batchDeliveryId;
|
|
342
401
|
}
|
|
343
|
-
|
|
402
|
+
// APRV-324. Every surface names itself on the record it writes, so a reader
|
|
403
|
+
// of a grant can tell a tap on a phone from a line typed into a terminal. The
|
|
404
|
+
// fallback matches `noteRefusedDecision`'s below.
|
|
405
|
+
options.channel = actorOptions.channel ?? "cli";
|
|
406
|
+
// APRV-324, and before anything is decided: the actor a decision is recorded
|
|
407
|
+
// under is chosen HERE, from the sender the transport authenticated and the
|
|
408
|
+
// mapping the operator attested, and the gate's own authorization logic is
|
|
409
|
+
// untouched by it. `namesApprover` and `actor-not-approver` then run exactly
|
|
410
|
+
// as they always have, over an identity that is better evidenced.
|
|
411
|
+
// APRV-455 refuter H1. A relay resolves the sender against the policy IN
|
|
412
|
+
// FORCE (the verified bytes the latest attestation names), never against the
|
|
413
|
+
// file on disk. Its own `propose` gesture puts unattested bytes on disk as a
|
|
414
|
+
// matter of course, and a mapping in those bytes must not decide who may
|
|
415
|
+
// answer anything until a human has attested them. Where the in-force bytes
|
|
416
|
+
// cannot be recovered the gesture is refused `policy-not-attested` and
|
|
417
|
+
// nothing is appended: the rule SPEC.md §10.3 already sets for checkpoint
|
|
418
|
+
// signatures and reviews, for the same reason.
|
|
419
|
+
let load = readGatePolicy(gateOptions);
|
|
420
|
+
if (actorOptions.requireSenderMapping === true) {
|
|
421
|
+
const inForce = inForceLoad(logPath, gateOptions);
|
|
422
|
+
if (!inForce.ok && inForce.log !== undefined) {
|
|
423
|
+
return { outcome: { ok: false, code: inForce.log.code, message: inForce.log.message } };
|
|
424
|
+
}
|
|
425
|
+
if (!inForce.ok) {
|
|
426
|
+
return {
|
|
427
|
+
outcome: {
|
|
428
|
+
ok: false,
|
|
429
|
+
code: "policy-not-attested",
|
|
430
|
+
message: `decision on ${decision.action_key} refused: this surface resolves a sender only against the policy in force, and ${inForce.reason}. Nothing was decided and nothing was recorded.`,
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
load = inForce.load;
|
|
435
|
+
}
|
|
436
|
+
const resolution = actorForSender(load, actorOptions.actor, decision.sender,
|
|
437
|
+
// APRV-370. The operator's sender key, where the policy's mapping is keyed.
|
|
438
|
+
// `null` when it is unset, which is a REFUSAL of the whole channel rather
|
|
439
|
+
// than a fallback to the raw comparison; `sender-key-unavailable` carries
|
|
440
|
+
// the reasoning.
|
|
441
|
+
senderKeyFrom());
|
|
442
|
+
// APRV-455. A surface that holds no human identity (the relay) never falls
|
|
443
|
+
// back to its configured actor: an actor that did not come from the mapping
|
|
444
|
+
// is a refusal here, before the gate is called.
|
|
445
|
+
if (resolution.ok && resolution.sender === undefined && actorOptions.requireSenderMapping === true) {
|
|
446
|
+
if (decision.sender === undefined) {
|
|
447
|
+
return {
|
|
448
|
+
outcome: {
|
|
449
|
+
ok: false,
|
|
450
|
+
code: "sender-unmapped",
|
|
451
|
+
message: `decision on ${decision.action_key} refused: this surface records only gestures attributed to a mapped account, and this one carried no sender. Nothing was decided and nothing was recorded, because there is no party to attribute the attempt to.`,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const { refusal, recorded } = mappingRequiredRefusal(decision.sender, load, `decision on ${decision.action_key}`);
|
|
456
|
+
noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, {
|
|
457
|
+
sender: recorded,
|
|
458
|
+
});
|
|
459
|
+
return { outcome: refusal };
|
|
460
|
+
}
|
|
461
|
+
if (!resolution.ok) {
|
|
462
|
+
const refusal = {
|
|
463
|
+
ok: false,
|
|
464
|
+
code: resolution.code,
|
|
465
|
+
message: `decision on ${decision.action_key} refused: ${resolution.message}`,
|
|
466
|
+
};
|
|
467
|
+
// The refusal is the record. Nothing is decided, no token is minted, and
|
|
468
|
+
// the one append is the audit-tier statement that somebody tapped from an
|
|
469
|
+
// account this policy names nobody for — carrying the observed id, because
|
|
470
|
+
// an operator investigating who tried needs the number, and a transport
|
|
471
|
+
// account id is not a credential.
|
|
472
|
+
noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, { sender: resolution.sender });
|
|
473
|
+
return { outcome: refusal };
|
|
474
|
+
}
|
|
475
|
+
const actor = resolution.actor;
|
|
476
|
+
if (resolution.sender !== undefined) {
|
|
477
|
+
options.sender = resolution.sender;
|
|
478
|
+
if (resolution.source !== undefined)
|
|
479
|
+
options.senderSource = resolution.source;
|
|
480
|
+
}
|
|
481
|
+
const result = decide(logPath, decision.action_key, decision.decision, actor, options);
|
|
344
482
|
if (!result.ok) {
|
|
345
483
|
// APRV-235. A human tapped and the gate would not take it. The gate itself
|
|
346
484
|
// appends nothing on a refusal, by design; this surface knows something the
|
|
@@ -351,7 +489,24 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
|
|
|
351
489
|
// Best effort, deliberately last, and it changes nothing about what the
|
|
352
490
|
// channel is handed back: the decision has already been refused, and a
|
|
353
491
|
// failed audit append must not turn one refusal into two.
|
|
354
|
-
noteRefusedDecision(logPath, decision, actorOptions, gateOptions, result
|
|
492
|
+
noteRefusedDecision(logPath, decision, { ...actorOptions, actor }, gateOptions, result,
|
|
493
|
+
// APRV-324, and §11.1 invariant 9 is the reason for the exception. A
|
|
494
|
+
// `class-human-only` refusal says the policy does not transact in this
|
|
495
|
+
// class at all, so the runtime records no identity resolution for it: a
|
|
496
|
+
// refusal record naming the account a human-only tap came from would read
|
|
497
|
+
// afterwards as a class this gate resolves senders for. Every other
|
|
498
|
+
// refusal names the account, because the attention it accounts for was
|
|
499
|
+
// spent by whoever holds it.
|
|
500
|
+
// APRV-370: `resolution.sender`, never `decision.sender`. The resolution
|
|
501
|
+
// carries the sender in the form the record takes, which under a keyed
|
|
502
|
+
// mapping is the digest; writing the observed id here would put the raw
|
|
503
|
+
// account back in the log on exactly the refusals nobody looks at.
|
|
504
|
+
result.code === "class-human-only" || resolution.sender === undefined
|
|
505
|
+
? {}
|
|
506
|
+
: {
|
|
507
|
+
sender: resolution.sender,
|
|
508
|
+
...(resolution.source === undefined ? {} : { senderSource: resolution.source }),
|
|
509
|
+
});
|
|
355
510
|
return { outcome: result };
|
|
356
511
|
}
|
|
357
512
|
const outcome = {
|
|
@@ -375,7 +530,7 @@ export function recordChannelDecision(logPath, decision, actorOptions, gateOptio
|
|
|
375
530
|
* answer away from the human who is waiting for it. What a failure costs is the
|
|
376
531
|
* record, which is exactly what the caller had before this existed.
|
|
377
532
|
*/
|
|
378
|
-
function noteRefusedDecision(logPath, decision, actorOptions, gateOptions, refusal) {
|
|
533
|
+
function noteRefusedDecision(logPath, decision, actorOptions, gateOptions, refusal, sender = {}) {
|
|
379
534
|
try {
|
|
380
535
|
recordRefusedDecision(logPath, {
|
|
381
536
|
actionKey: decision.action_key,
|
|
@@ -385,10 +540,13 @@ function noteRefusedDecision(logPath, decision, actorOptions, gateOptions, refus
|
|
|
385
540
|
// local process, which is what a decision that reached the runtime
|
|
386
541
|
// through no channel at all came through.
|
|
387
542
|
channel: actorOptions.channel ?? "cli",
|
|
543
|
+
...sender,
|
|
388
544
|
}, {
|
|
389
545
|
code: refusal.code,
|
|
390
546
|
message: refusal.message,
|
|
391
|
-
|
|
547
|
+
// A surface-side refusal has made no policy comparison, so it carries no
|
|
548
|
+
// hashes; `in` rather than a cast, so the narrowing is the type system's.
|
|
549
|
+
...("drift" in refusal && refusal.drift !== undefined ? { drift: refusal.drift } : {}),
|
|
392
550
|
}, gateOptions);
|
|
393
551
|
}
|
|
394
552
|
catch {
|
|
@@ -437,6 +595,103 @@ function listenerPolicyPath(options) {
|
|
|
437
595
|
return policy.file;
|
|
438
596
|
return policy.dir === undefined ? null : proposalPolicyPath(policy.dir);
|
|
439
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Who may attest, from a phone, and under whose rules (APRV-324 follow-up,
|
|
600
|
+
* amended SPEC.md §10.3).
|
|
601
|
+
*
|
|
602
|
+
* ## Why this is not the decision rule
|
|
603
|
+
*
|
|
604
|
+
* A decision is resolved against the policy in force, and so is this — but for
|
|
605
|
+
* an attestation the two candidate policies are different documents, and the
|
|
606
|
+
* difference is the whole problem. The tap answers a prompt about the LIVE
|
|
607
|
+
* file, which is the amendment; the amendment may add, remove or repoint the
|
|
608
|
+
* `senders` mapping itself. Resolving against the proposed file would let
|
|
609
|
+
* whoever edited it name their own account as the approver of their own edit,
|
|
610
|
+
* which is a gate that authorizes its own widening. So the oracle is the policy
|
|
611
|
+
* IN FORCE — the bytes the latest attestation names — and never the bytes being
|
|
612
|
+
* attested.
|
|
613
|
+
*
|
|
614
|
+
* ## The ladder
|
|
615
|
+
*
|
|
616
|
+
* 1. **No sender.** The terminal and the web page, which authenticate nobody.
|
|
617
|
+
* Unchanged, and this is the path that keeps a repository recoverable: a
|
|
618
|
+
* `policy.core` edit happens at a terminal anyway, so no mapping, however
|
|
619
|
+
* broken, can strand the repair.
|
|
620
|
+
* 2. **In-force bytes recovered, and the amendment changes the mapping.** Only
|
|
621
|
+
* an account the IN-FORCE policy maps may answer. Where the policy in force
|
|
622
|
+
* maps nobody on this channel, nobody qualifies and the answer is
|
|
623
|
+
* `attest-requires-terminal`: an amendment that introduces the identity
|
|
624
|
+
* system cannot be signed for by the identity system it introduces.
|
|
625
|
+
* 3. **In-force bytes recovered, mapping unchanged.** The ordinary rule, run
|
|
626
|
+
* against the policy in force: mapped answers, unmapped is refused.
|
|
627
|
+
* 4. **In-force bytes NOT recovered.** They frequently are not — an attestation
|
|
628
|
+
* records only a digest, and a terminal attestation stores nothing
|
|
629
|
+
* ({@link inForcePolicyText} says so in full). Then the runtime cannot tell
|
|
630
|
+
* whether this amendment touches the mapping, so it refuses
|
|
631
|
+
* `attest-requires-terminal` whenever the PROPOSED policy maps senders for
|
|
632
|
+
* this channel, and otherwise behaves exactly as it did before this rule.
|
|
633
|
+
*
|
|
634
|
+
* The residual, stated rather than hidden: in case 4 an amendment that REMOVES
|
|
635
|
+
* a mapping is indistinguishable from a policy that never had one, so it falls
|
|
636
|
+
* to the pre-mapping behaviour. Closing that would need the in-force bytes,
|
|
637
|
+
* which is case 2; and reaching it requires an attacker who can already write
|
|
638
|
+
* `APPROVAL.md`, whom SPEC.md §11 already places inside the trust boundary.
|
|
639
|
+
*/
|
|
640
|
+
function resolveAttestationSender(logPath, records, decision, actorOptions, gateOptions, policyPath) {
|
|
641
|
+
const sender = decision.sender;
|
|
642
|
+
if (sender === undefined)
|
|
643
|
+
return { ok: true, actor: actorOptions.actor };
|
|
644
|
+
// APRV-370. Resolved ONCE for this whole ladder: the operator's sender key,
|
|
645
|
+
// and with it the form the refusals below record the account in. The form
|
|
646
|
+
// follows the FILE and the mapping follows the ATTESTATION
|
|
647
|
+
// (`recordedSenderFor` carries the reasoning), so a refusal that never
|
|
648
|
+
// reaches the in-force mapping still honours the disclosure preference the
|
|
649
|
+
// operator wrote down, and grants nobody anything by doing so.
|
|
650
|
+
const key = senderKeyFrom();
|
|
651
|
+
const proposed = readGatePolicy(gateOptions);
|
|
652
|
+
// The same store `proposeAttestation` wrote the policy text to, resolved the
|
|
653
|
+
// same way, so the bytes a prompt displayed and the bytes this reads back are
|
|
654
|
+
// never two different files.
|
|
655
|
+
const inForce = inForcePolicyText(records, gateOptions.payloadStoreDir ?? payloadStoreDirFor(logPath));
|
|
656
|
+
if (!inForce.ok) {
|
|
657
|
+
if (!mapsSendersFor(proposed.ok ? proposed.policy.approvers : undefined, sender.channel)) {
|
|
658
|
+
return { ok: true, actor: actorOptions.actor };
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
ok: false,
|
|
662
|
+
code: "attest-requires-terminal",
|
|
663
|
+
sender: recordedSenderFor(proposed, sender, key),
|
|
664
|
+
message: `the policy being attested maps ${sender.channel} senders and the policy IN FORCE cannot be read to check who may sign for that: ${inForce.reason}. Resolving this tap against the file it is attesting would let whoever wrote that file name the account that approves it, so nothing was attested. Attest from a terminal, which authenticates no sender and is where a policy.core edit happens anyway.`,
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
const before = loadPolicyText(policyPath ?? "APPROVAL.md", inForce.text, gateOptions.schemaDir === undefined ? {} : { schemaDir: gateOptions.schemaDir });
|
|
668
|
+
if (sendersDiffer(before, proposed)) {
|
|
669
|
+
if (!mapsSendersFor(before.ok ? before.policy.approvers : undefined, sender.channel)) {
|
|
670
|
+
return {
|
|
671
|
+
ok: false,
|
|
672
|
+
code: "attest-requires-terminal",
|
|
673
|
+
sender: recordedSenderFor(before, sender, key),
|
|
674
|
+
message: `this amendment changes the sender mapping, and the policy in force maps no ${sender.channel} sender, so there is no account it could recognize as entitled to sign for that change. An amendment that introduces the identity system cannot be signed for by the identity system it introduces. Nothing was attested; attest from a terminal.`,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const resolution = actorForSender(before, actorOptions.actor, sender, key);
|
|
678
|
+
if (!resolution.ok)
|
|
679
|
+
return resolution;
|
|
680
|
+
// A mapped account under the policy in force. Belt and braces on the mode
|
|
681
|
+
// the ladder above already excluded: an amendment that changes the mapping
|
|
682
|
+
// is never answered on the configured identity.
|
|
683
|
+
if (resolution.sender === undefined) {
|
|
684
|
+
return {
|
|
685
|
+
ok: false,
|
|
686
|
+
code: "attest-requires-terminal",
|
|
687
|
+
sender: recordedSenderFor(before, sender, key),
|
|
688
|
+
message: `this amendment changes the sender mapping and this tap resolved to no account under the policy in force. Nothing was attested; attest from a terminal.`,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
return resolution;
|
|
692
|
+
}
|
|
693
|
+
return actorForSender(before, actorOptions.actor, sender, key);
|
|
694
|
+
}
|
|
440
695
|
export function recordAttestationDecision(logPath, decision, actorOptions, gateOptions = {}) {
|
|
441
696
|
const sha256 = attestationKeySha256(decision.action_key);
|
|
442
697
|
if (sha256 === null) {
|
|
@@ -477,7 +732,49 @@ export function recordAttestationDecision(logPath, decision, actorOptions, gateO
|
|
|
477
732
|
const policyPath = listenerPolicyPath(gateOptions);
|
|
478
733
|
if (policyPath !== null)
|
|
479
734
|
options.policyPath = policyPath;
|
|
480
|
-
|
|
735
|
+
// APRV-324 follow-up. The privileged gesture, resolved last and most
|
|
736
|
+
// carefully: an attestation decides which rules are in force, and the rules
|
|
737
|
+
// it can decide include the sender mapping itself.
|
|
738
|
+
const resolved = resolveAttestationSender(logPath, read.records, decision, actorOptions, gateOptions, policyPath);
|
|
739
|
+
if (!resolved.ok) {
|
|
740
|
+
const refusal = {
|
|
741
|
+
ok: false,
|
|
742
|
+
code: resolved.code,
|
|
743
|
+
message: `attestation of ${sha256} refused: ${resolved.message}`,
|
|
744
|
+
};
|
|
745
|
+
// The same audit-tier record a refused decision writes, and it fits without
|
|
746
|
+
// straining: the attestation prompt HAS an action key the log carries
|
|
747
|
+
// (`policy.attest:<sha256>`), and the gesture IS one of the two decision
|
|
748
|
+
// words this event's payload admits, because that is exactly how a tap on a
|
|
749
|
+
// prompt is routed to `attest` or `decline` above.
|
|
750
|
+
noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, { sender: resolved.sender });
|
|
751
|
+
return { outcome: refusal };
|
|
752
|
+
}
|
|
753
|
+
// APRV-455. The relay rule, on the privileged gesture: an attestation whose
|
|
754
|
+
// actor did not come from the mapping in force is refused, whichever rung of
|
|
755
|
+
// the ladder above produced the configured actor.
|
|
756
|
+
if (resolved.sender === undefined && actorOptions.requireSenderMapping === true) {
|
|
757
|
+
if (decision.sender === undefined) {
|
|
758
|
+
return {
|
|
759
|
+
outcome: {
|
|
760
|
+
ok: false,
|
|
761
|
+
code: "sender-unmapped",
|
|
762
|
+
message: `attestation of ${sha256} refused: this surface attests only for a mapped account, and this gesture carried no sender. Nothing was attested and nothing was recorded.`,
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
const { refusal, recorded } = mappingRequiredRefusal(decision.sender, readGatePolicy(gateOptions), `attestation of ${sha256}`);
|
|
767
|
+
noteRefusedDecision(logPath, decision, { ...actorOptions, actor: null }, gateOptions, refusal, {
|
|
768
|
+
sender: recorded,
|
|
769
|
+
});
|
|
770
|
+
return { outcome: refusal };
|
|
771
|
+
}
|
|
772
|
+
if (resolved.sender !== undefined) {
|
|
773
|
+
options.sender = resolved.sender;
|
|
774
|
+
if (resolved.source !== undefined)
|
|
775
|
+
options.senderSource = resolved.source;
|
|
776
|
+
}
|
|
777
|
+
const result = decideAttestation(logPath, proposal.seq, decision.decision === "grant" ? "attest" : "decline", resolved.actor, options);
|
|
481
778
|
if (!result.ok)
|
|
482
779
|
return { outcome: result };
|
|
483
780
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/channels/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAwC,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAqB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA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QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,KAAK,EAAE,QAAQ,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;YAC7D,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,KAAK;SACnB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authenticated relay channel: its HTTP receiver (SPEC.md §10.3, APRV-455).
|
|
3
|
+
*
|
|
4
|
+
* The sibling of `channels/telegram-webhook.ts`, and deliberately the same
|
|
5
|
+
* shape: one header, one path, one method, one bounded body, a loopback bind by
|
|
6
|
+
* default with the operator's proxy terminating TLS, a refusal carried as a
|
|
7
|
+
* body with a frozen code, and no refusal ever written to the log. What differs
|
|
8
|
+
* is what arrives. A Telegram delivery is an Update the channel parses; a relay
|
|
9
|
+
* post is a gesture whose shape `channels/relay.ts` closes, whose freshness and
|
|
10
|
+
* nonce this file checks, and which `applyRelayGesture` turns into a log event
|
|
11
|
+
* through `recordChannelDecision`, the one place a reported gesture becomes one.
|
|
12
|
+
*
|
|
13
|
+
* ## The secret first
|
|
14
|
+
*
|
|
15
|
+
* `x-approval-relay-secret` is compared before the URL is parsed, the method is
|
|
16
|
+
* read or a byte of the body is consumed. A caller without it learns only that
|
|
17
|
+
* something refused. The comparison is over SHA-256 digests under
|
|
18
|
+
* `timingSafeEqual`, constant-time and length-independent, and a request
|
|
19
|
+
* carrying the header twice is refused rather than resolved, because Node joins
|
|
20
|
+
* repeats and the value compared would not be the value a reader names. These
|
|
21
|
+
* are the webhook's three rules, for the webhook's reasons.
|
|
22
|
+
*
|
|
23
|
+
* ## Why this is its own port and its own secret
|
|
24
|
+
*
|
|
25
|
+
* `approval serve` answers two bearer credentials, the agent's and the
|
|
26
|
+
* tenant's, and NEITHER may reach a decision: grant, reject and attest are
|
|
27
|
+
* human-only verbs that serve does not publish. This receiver answers a third
|
|
28
|
+
* credential held by a third party (the operator's control plane), and it is
|
|
29
|
+
* reachable only from the process `approval channel relay` starts. Nothing in
|
|
30
|
+
* `src/serve/` or `src/mcp/` imports this module, the verb registry marks the
|
|
31
|
+
* verb `human_only` so no wrapper publishes it, and `tests/channel-relay.test.ts`
|
|
32
|
+
* pins both.
|
|
33
|
+
*
|
|
34
|
+
* ## Replay
|
|
35
|
+
*
|
|
36
|
+
* Every gesture carries a nonce and an `issued_at`. The nonce is claimed in a
|
|
37
|
+
* ledger of exclusively linked files under the gate's `daemon/` directory before the
|
|
38
|
+
* gesture is applied, so a replayed post is refused `relay-nonce-replayed`
|
|
39
|
+
* whether it arrives at this process, after its restart, or at a second relay
|
|
40
|
+
* on the same gate; a post older than the window is refused
|
|
41
|
+
* `relay-gesture-stale` after the ledger has forgotten it. The gate is the
|
|
42
|
+
* belt: a decision a replay did reach would be refused `already-decided`.
|
|
43
|
+
*/
|
|
44
|
+
import { type ApplyRelayOptions, type NonceLedger, type RelayRefusalCode, type RelayResponse } from "./relay.js";
|
|
45
|
+
/** How long {@link RelayHandle.close} waits for requests in flight. */
|
|
46
|
+
export declare const RELAY_CLOSE_TIMEOUT_MS = 10000;
|
|
47
|
+
/** What this receiver has done since it bound. Counters, never decisions. */
|
|
48
|
+
export interface RelayStats {
|
|
49
|
+
requests: number;
|
|
50
|
+
/** Gestures handed to the gate, accepted or refused there. */
|
|
51
|
+
gestures: number;
|
|
52
|
+
refusals: Record<RelayRefusalCode, number>;
|
|
53
|
+
}
|
|
54
|
+
export interface RelayServerOptions extends ApplyRelayOptions {
|
|
55
|
+
/** The log every gesture is recorded in. */
|
|
56
|
+
logPath: string;
|
|
57
|
+
/**
|
|
58
|
+
* The shared secret, as a value. Resolved by the VERB from the launch
|
|
59
|
+
* environment (SPEC.md §11.1 invariant 7); nothing under `src/channels/`
|
|
60
|
+
* reads `process.env`.
|
|
61
|
+
*/
|
|
62
|
+
secret: string;
|
|
63
|
+
/** Where claimed nonces are remembered. */
|
|
64
|
+
ledger: NonceLedger;
|
|
65
|
+
host?: string;
|
|
66
|
+
/** `0` asks the kernel for an ephemeral port, which is what tests use. */
|
|
67
|
+
port?: number;
|
|
68
|
+
/** The clock freshness is judged against, in epoch ms. Injectable for tests. */
|
|
69
|
+
now?: () => number;
|
|
70
|
+
/** Where operational complaints go. Defaults to stderr. */
|
|
71
|
+
log?: (message: string) => void;
|
|
72
|
+
/** Called after each gesture that reached the gate, with its response. Must not throw. */
|
|
73
|
+
afterGesture?: (response: RelayResponse) => void;
|
|
74
|
+
closeTimeoutMs?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface RelayHandle {
|
|
77
|
+
readonly host: string;
|
|
78
|
+
readonly port: number;
|
|
79
|
+
readonly path: string;
|
|
80
|
+
stats(): RelayStats;
|
|
81
|
+
inFlight(): number;
|
|
82
|
+
/** Stop accepting, let what is in flight finish, then drop the sockets. Idempotent. */
|
|
83
|
+
close(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
/** Is `offered` the secret? Constant-time over equal-length digests. */
|
|
86
|
+
export declare function relaySecretMatches(expected: string, offered: string | null): boolean;
|
|
87
|
+
/** The one secret header offered, `null` for none, `"duplicate"` for more than one. */
|
|
88
|
+
export declare function relaySecretHeaderOf(rawHeaders: readonly string[]): string | null | "duplicate";
|
|
89
|
+
/** Start the receiver. Resolves once bound; rejects when the bind fails. */
|
|
90
|
+
export declare function serveRelay(options: RelayServerOptions): Promise<RelayHandle>;
|