@jr2/orchestrator 0.3.0 → 0.5.1
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 +20 -2
- package/bin/server.ts +7 -4
- package/console/canvas.ts +27 -14
- package/console/components/app.ts +12 -1
- package/console/components/fleet.ts +52 -6
- package/console/components/machine-pane.ts +128 -2
- package/console/components/nav.ts +1 -1
- package/console/components/schema-form.ts +12 -4
- package/console/json-field.ts +23 -0
- package/console/main.ts +122 -39
- package/console/store.ts +321 -21
- package/console/style.css +111 -0
- package/docs/agents-block.md +5 -0
- package/docs/concepts/agents-and-turns.md +442 -0
- package/docs/concepts/architecture.md +230 -0
- package/docs/concepts/charts.md +143 -0
- package/docs/concepts/composition.md +357 -0
- package/docs/concepts/converge.md +254 -0
- package/docs/concepts/durable-runs.md +189 -0
- package/docs/concepts/effects.md +603 -0
- package/docs/concepts/gates.md +208 -0
- package/docs/concepts/machines-and-workflows.md +289 -0
- package/docs/concepts/pools-and-sources.md +230 -0
- package/docs/concepts/secrets-and-trust.md +222 -0
- package/docs/concepts/the-menu.md +378 -0
- package/docs/concepts/workspaces.md +678 -0
- package/docs/get-started/a-model-decides.md +563 -0
- package/docs/get-started/an-agent-in-a-sandbox.md +381 -0
- package/docs/get-started/connect-a-model.md +248 -0
- package/docs/get-started/create-an-instance.md +194 -0
- package/docs/get-started/have-your-assistant-write-a-machine.md +922 -0
- package/docs/get-started/install.md +126 -0
- package/docs/guides/add-tools-to-the-sandbox.md +295 -0
- package/docs/guides/answer-a-gate.md +304 -0
- package/docs/guides/bind-open-parts.md +223 -0
- package/docs/guides/cancel-a-run.md +146 -0
- package/docs/guides/clean-up.md +206 -0
- package/docs/guides/fix-a-failed-converge.md +361 -0
- package/docs/guides/give-the-cluster-git-credentials.md +222 -0
- package/docs/guides/iterate-on-a-machine-on-kind.md +190 -0
- package/docs/guides/let-an-agent-write-a-chart.md +226 -0
- package/docs/guides/look-inside-a-sandbox.md +174 -0
- package/docs/guides/mirror-the-kit-images.md +176 -0
- package/docs/guides/move-from-kind-to-a-shared-cluster.md +302 -0
- package/docs/guides/open-the-console.md +91 -0
- package/docs/guides/publish-a-machine-as-an-npm-package.md +350 -0
- package/docs/guides/push-and-sign-a-branch.md +486 -0
- package/docs/guides/run-a-chart-by-name.md +270 -0
- package/docs/guides/run-a-command-or-call-a-url.md +544 -0
- package/docs/guides/run-one-worker-per-item.md +321 -0
- package/docs/guides/set-an-agents-access-and-dials.md +375 -0
- package/docs/guides/size-a-workspace.md +204 -0
- package/docs/guides/start-a-run-from-a-run.md +237 -0
- package/docs/guides/start-a-run.md +207 -0
- package/docs/guides/upgrade-the-kit-version.md +240 -0
- package/docs/guides/use-a-hosted-provider.md +208 -0
- package/docs/guides/use-a-local-model.md +313 -0
- package/docs/guides/watch-a-run.md +326 -0
- package/docs/guides/write-a-workflow.md +318 -0
- package/docs/index.md +44 -0
- package/docs/llms.txt +216 -0
- package/docs/reference/authoring-surface/agent.md +128 -0
- package/docs/reference/authoring-surface/answer.md +140 -0
- package/docs/reference/authoring-surface/arg.md +60 -0
- package/docs/reference/authoring-surface/basic.md +62 -0
- package/docs/reference/authoring-surface/bearer.md +53 -0
- package/docs/reference/authoring-surface/chartschema.md +23 -0
- package/docs/reference/authoring-surface/chartschemafor.md +48 -0
- package/docs/reference/authoring-surface/command.md +191 -0
- package/docs/reference/authoring-surface/customize.md +64 -0
- package/docs/reference/authoring-surface/defineconfig.md +41 -0
- package/docs/reference/authoring-surface/defineevent.md +114 -0
- package/docs/reference/authoring-surface/dispatch.md +126 -0
- package/docs/reference/authoring-surface/fail.md +83 -0
- package/docs/reference/authoring-surface/file.md +122 -0
- package/docs/reference/authoring-surface/frompick.md +277 -0
- package/docs/reference/authoring-surface/http.md +159 -0
- package/docs/reference/authoring-surface/isfailure.md +58 -0
- package/docs/reference/authoring-surface/jr2setup.md +237 -0
- package/docs/reference/authoring-surface/open.md +74 -0
- package/docs/reference/authoring-surface/openbody.md +86 -0
- package/docs/reference/authoring-surface/paramsof.md +125 -0
- package/docs/reference/authoring-surface/pool.md +186 -0
- package/docs/reference/authoring-surface/push.md +112 -0
- package/docs/reference/authoring-surface/secret.md +118 -0
- package/docs/reference/authoring-surface/sentby.md +83 -0
- package/docs/reference/authoring-surface/source.md +51 -0
- package/docs/reference/authoring-surface/text.md +62 -0
- package/docs/reference/authoring-surface/type-agentdeclaration.md +27 -0
- package/docs/reference/authoring-surface/type-agentdefinition.md +80 -0
- package/docs/reference/authoring-surface/type-agentlogic.md +15 -0
- package/docs/reference/authoring-surface/type-agentslots.md +12 -0
- package/docs/reference/authoring-surface/type-answeraction.md +12 -0
- package/docs/reference/authoring-surface/type-arg.md +19 -0
- package/docs/reference/authoring-surface/type-argnames.md +12 -0
- package/docs/reference/authoring-surface/type-binding.md +62 -0
- package/docs/reference/authoring-surface/type-bindingof.md +12 -0
- package/docs/reference/authoring-surface/type-bodyacceptsdoor.md +15 -0
- package/docs/reference/authoring-surface/type-bodyacceptsslots.md +17 -0
- package/docs/reference/authoring-surface/type-ceilings.md +41 -0
- package/docs/reference/authoring-surface/type-chainlink.md +19 -0
- package/docs/reference/authoring-surface/type-chartaction.md +46 -0
- package/docs/reference/authoring-surface/type-chartagent.md +28 -0
- package/docs/reference/authoring-surface/type-chartevent.md +20 -0
- package/docs/reference/authoring-surface/type-chartguard.md +20 -0
- package/docs/reference/authoring-surface/type-chartinvoke.md +28 -0
- package/docs/reference/authoring-surface/type-chartjson.md +14 -0
- package/docs/reference/authoring-surface/type-chartstate.md +46 -0
- package/docs/reference/authoring-surface/type-charttext.md +40 -0
- package/docs/reference/authoring-surface/type-charttransition.md +22 -0
- package/docs/reference/authoring-surface/type-charttransitions.md +14 -0
- package/docs/reference/authoring-surface/type-chartvalue.md +15 -0
- package/docs/reference/authoring-surface/type-childat.md +12 -0
- package/docs/reference/authoring-surface/type-childslots.md +12 -0
- package/docs/reference/authoring-surface/type-commandenv.md +15 -0
- package/docs/reference/authoring-surface/type-commandinput.md +19 -0
- package/docs/reference/authoring-surface/type-commandoptions.md +78 -0
- package/docs/reference/authoring-surface/type-commandoutput.md +104 -0
- package/docs/reference/authoring-surface/type-customize.md +109 -0
- package/docs/reference/authoring-surface/type-dispatchdefinition.md +39 -0
- package/docs/reference/authoring-surface/type-dispatchinput.md +14 -0
- package/docs/reference/authoring-surface/type-dispatchopenparts.md +14 -0
- package/docs/reference/authoring-surface/type-dispatchoutput.md +65 -0
- package/docs/reference/authoring-surface/type-duration.md +15 -0
- package/docs/reference/authoring-surface/type-effectbinding.md +93 -0
- package/docs/reference/authoring-surface/type-effectlogic.md +12 -0
- package/docs/reference/authoring-surface/type-envopenparts.md +14 -0
- package/docs/reference/authoring-surface/type-eventaudience.md +27 -0
- package/docs/reference/authoring-surface/type-eventdef.md +45 -0
- package/docs/reference/authoring-surface/type-eventfrom.md +16 -0
- package/docs/reference/authoring-surface/type-eventsemantics.md +26 -0
- package/docs/reference/authoring-surface/type-execoutcome.md +34 -0
- package/docs/reference/authoring-surface/type-failslot.md +14 -0
- package/docs/reference/authoring-surface/type-failure.md +19 -0
- package/docs/reference/authoring-surface/type-failureinput.md +20 -0
- package/docs/reference/authoring-surface/type-filebody.md +41 -0
- package/docs/reference/authoring-surface/type-frominput.md +14 -0
- package/docs/reference/authoring-surface/type-hostinjectedinput.md +58 -0
- package/docs/reference/authoring-surface/type-httpdefinition.md +101 -0
- package/docs/reference/authoring-surface/type-httpinput.md +12 -0
- package/docs/reference/authoring-surface/type-httpmethod.md +14 -0
- package/docs/reference/authoring-surface/type-httpopenparts.md +12 -0
- package/docs/reference/authoring-surface/type-httpoutput.md +89 -0
- package/docs/reference/authoring-surface/type-httprequestparts.md +33 -0
- package/docs/reference/authoring-surface/type-jr2config.md +126 -0
- package/docs/reference/authoring-surface/type-lends.md +38 -0
- package/docs/reference/authoring-surface/type-logicat.md +12 -0
- package/docs/reference/authoring-surface/type-markedif.md +12 -0
- package/docs/reference/authoring-surface/type-mergedactors.md +12 -0
- package/docs/reference/authoring-surface/type-namedsecret.md +25 -0
- package/docs/reference/authoring-surface/type-noslotspec.md +26 -0
- package/docs/reference/authoring-surface/type-noslotworkspaceoptions.md +32 -0
- package/docs/reference/authoring-surface/type-openbodydeclaration.md +40 -0
- package/docs/reference/authoring-surface/type-openbodylogic.md +14 -0
- package/docs/reference/authoring-surface/type-openbodyoutput.md +42 -0
- package/docs/reference/authoring-surface/type-openbodyslot.md +18 -0
- package/docs/reference/authoring-surface/type-opencommandinput.md +17 -0
- package/docs/reference/authoring-surface/type-openeffect.md +12 -0
- package/docs/reference/authoring-surface/type-openeffectslots.md +12 -0
- package/docs/reference/authoring-surface/type-openof.md +12 -0
- package/docs/reference/authoring-surface/type-opensecret.md +23 -0
- package/docs/reference/authoring-surface/type-opensecretmark.md +12 -0
- package/docs/reference/authoring-surface/type-permissivenoslotworkspaceoptions.md +31 -0
- package/docs/reference/authoring-surface/type-permissiveworkspaceoptions.md +32 -0
- package/docs/reference/authoring-surface/type-poolmachine.md +28 -0
- package/docs/reference/authoring-surface/type-poolspec.md +60 -0
- package/docs/reference/authoring-surface/type-pushinput.md +15 -0
- package/docs/reference/authoring-surface/type-pushoptions.md +79 -0
- package/docs/reference/authoring-surface/type-pushoutput.md +124 -0
- package/docs/reference/authoring-surface/type-pushwireoutput.md +12 -0
- package/docs/reference/authoring-surface/type-quantity.md +14 -0
- package/docs/reference/authoring-surface/type-reached.md +12 -0
- package/docs/reference/authoring-surface/type-reposlot.md +70 -0
- package/docs/reference/authoring-surface/type-reposlotsof.md +16 -0
- package/docs/reference/authoring-surface/type-sandboxoptions.md +77 -0
- package/docs/reference/authoring-surface/type-secret.md +25 -0
- package/docs/reference/authoring-surface/type-sender.md +19 -0
- package/docs/reference/authoring-surface/type-sentbyguards.md +12 -0
- package/docs/reference/authoring-surface/type-size.md +85 -0
- package/docs/reference/authoring-surface/type-slothandles.md +32 -0
- package/docs/reference/authoring-surface/type-sourcenextresult.md +17 -0
- package/docs/reference/authoring-surface/type-sourcespec.md +44 -0
- package/docs/reference/authoring-surface/type-syncstate.md +12 -0
- package/docs/reference/authoring-surface/type-text.md +19 -0
- package/docs/reference/authoring-surface/type-textpart.md +24 -0
- package/docs/reference/authoring-surface/type-thinkinglevel.md +39 -0
- package/docs/reference/authoring-surface/type-toparameterizedobject.md +14 -0
- package/docs/reference/authoring-surface/type-toprovidedactor.md +14 -0
- package/docs/reference/authoring-surface/type-unknown.md +21 -0
- package/docs/reference/authoring-surface/type-usercontainer.md +77 -0
- package/docs/reference/authoring-surface/type-withoutemptyindex.md +20 -0
- package/docs/reference/authoring-surface/type-workflowevent.md +46 -0
- package/docs/reference/authoring-surface/type-workspaceaccess.md +16 -0
- package/docs/reference/authoring-surface/type-workspaced.md +94 -0
- package/docs/reference/authoring-surface/type-workspacehandles.md +23 -0
- package/docs/reference/authoring-surface/type-workspacemachine.md +29 -0
- package/docs/reference/authoring-surface/type-workspaceof.md +13 -0
- package/docs/reference/authoring-surface/type-workspaceoptions.md +39 -0
- package/docs/reference/authoring-surface/type-workspacespec.md +37 -0
- package/docs/reference/authoring-surface/workspace.md +259 -0
- package/docs/reference/authoring-surface.md +197 -0
- package/docs/reference/cli.md +433 -0
- package/docs/reference/config.md +756 -0
- package/docs/reference/decisions/0001-operator-owned-generic-sandbox.md +113 -0
- package/docs/reference/decisions/0002-duplex-streaming-actor.md +110 -0
- package/docs/reference/decisions/0004-worktree-provisioning-model.md +124 -0
- package/docs/reference/decisions/0005-sandbox-pod-composition.md +230 -0
- package/docs/reference/decisions/0006-agent-control-surface.md +47 -0
- package/docs/reference/decisions/0007-durable-machine-state.md +109 -0
- package/docs/reference/decisions/0008-orchestrator-as-deployed-app.md +60 -0
- package/docs/reference/decisions/0009-cli-and-instance-interface.md +275 -0
- package/docs/reference/decisions/0010-bdd-acceptance-tests.md +160 -0
- package/docs/reference/decisions/0011-workflow-defined-events.md +141 -0
- package/docs/reference/decisions/0012-workspace-wrapper-machine.md +103 -0
- package/docs/reference/decisions/0013-the-agent-reaches-its-machine-through-a-container-it-cannot-read.md +157 -0
- package/docs/reference/decisions/0014-observation-is-open-run-state-is-not.md +95 -0
- package/docs/reference/decisions/0015-authoring-surface-absorbs-the-mechanism.md +265 -0
- package/docs/reference/decisions/0016-agent-turn-mechanics-are-internal.md +124 -0
- package/docs/reference/decisions/0017-pool-over-a-source-port.md +69 -0
- package/docs/reference/decisions/0018-instance-agents-are-definitions-jr2-assembles-the-harness.md +111 -0
- package/docs/reference/decisions/0019-one-converging-command-against-the-current-context.md +275 -0
- package/docs/reference/decisions/0020-private-ca-trust-is-a-named-concept.md +60 -0
- package/docs/reference/decisions/0021-workspace-continuity-is-a-lease-that-answers-back.md +100 -0
- package/docs/reference/decisions/0022-observation-is-a-level-triggered-feed.md +103 -0
- package/docs/reference/decisions/0023-the-harness-prints-the-conversation.md +176 -0
- package/docs/reference/decisions/0024-an-agents-turn-ends-with-the-state-that-asked-for-it.md +439 -0
- package/docs/reference/decisions/0025-cancel-ends-a-run-stop-parks-it.md +65 -0
- package/docs/reference/decisions/0026-a-turn-that-is-over-is-never-prompted.md +62 -0
- package/docs/reference/decisions/0027-the-harness-is-jr2s-own-server-flue-retires-the-wire-stays.md +237 -0
- package/docs/reference/decisions/0028-what-an-agent-may-do-to-the-workspace-is-part-of-its-definition.md +89 -0
- package/docs/reference/decisions/0029-a-menu-is-fixed-for-a-conversation-and-a-turn-is-told-its-allowed-picks.md +154 -0
- package/docs/reference/decisions/0030-a-snapshot-names-the-machine-it-was-written-under.md +100 -0
- package/docs/reference/decisions/0031-menu-only-agents-run-on-the-instance-harness.md +190 -0
- package/docs/reference/decisions/0032-the-console-unlocks-with-the-instance-token.md +61 -0
- package/docs/reference/decisions/0033-a-machine-declares-the-input-that-starts-it.md +127 -0
- package/docs/reference/decisions/0034-the-console-renders-with-preact-and-the-server-erases-the-types.md +57 -0
- package/docs/reference/decisions/0035-a-runaway-turn-is-ended-rerolled-once-then-a-fault.md +92 -0
- package/docs/reference/decisions/0036-a-turn-compacts-its-own-context-mid-flight.md +138 -0
- package/docs/reference/decisions/0037-an-instance-builds-its-sandbox-images-jr2-injects-the-harness.md +196 -0
- package/docs/reference/decisions/0038-jr2-up-builds-every-image-it-deploys.md +170 -0
- package/docs/reference/decisions/0039-image-garbage-collects-by-reachability.md +115 -0
- package/docs/reference/decisions/0041-a-build-the-host-already-holds-is-not-spent-again.md +64 -0
- package/docs/reference/decisions/0042-ready-is-not-routable-an-admission-retries-its-connection.md +142 -0
- package/docs/reference/decisions/0043-the-kit-is-tested-as-installed-a-local-registry-stands-in-for-npm.md +170 -0
- package/docs/reference/decisions/0044-kit-images-live-at-a-canonical-home-a-self-host-mirrors-it.md +85 -0
- package/docs/reference/decisions/0045-the-platform-joins-the-image-address-and-the-cluster-chooses-it.md +82 -0
- package/docs/reference/decisions/0046-a-converge-failure-carries-its-diagnosis.md +34 -0
- package/docs/reference/decisions/0047-the-git-ssh-key-source-is-the-users-choice.md +47 -0
- package/docs/reference/decisions/0048-the-orchestrator-boots-without-its-repos.md +36 -0
- package/docs/reference/decisions/0049-a-machine-carries-its-parts-and-composes-by-invoke.md +126 -0
- package/docs/reference/decisions/0050-what-code-names-config-declares-what-the-cli-names-discovery-finds.md +73 -0
- package/docs/reference/decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md +227 -0
- package/docs/reference/decisions/0052-a-sandbox-lands-where-an-ordinary-pod-lands-and-the-cache-follows-it.md +81 -0
- package/docs/reference/decisions/0053-a-fetch-inside-the-pod-asks-the-node-cache-and-the-cache-asks-the-remote.md +111 -0
- package/docs/reference/decisions/0054-the-kit-ships-machines-and-a-shipped-machine-leaves-its-parts-open.md +126 -0
- package/docs/reference/decisions/0055-a-release-is-a-pushed-tag-and-the-publish-guard-is-the-credential.md +107 -0
- package/docs/reference/decisions/0056-a-global-jr2-hands-off-to-the-instances-own-and-an-instance-has-one-kit-version.md +62 -0
- package/docs/reference/decisions/0057-a-turn-is-its-frame-its-dials-and-whether-it-continues.md +152 -0
- package/docs/reference/decisions/0058-a-harness-answers-the-orchestrator-alone.md +106 -0
- package/docs/reference/decisions/0059-a-harness-holds-stand-ins-and-the-custodian-holds-the-keys.md +384 -0
- package/docs/reference/decisions/0060-a-workspace-states-its-size-and-jr2-reserves-all-of-it.md +111 -0
- package/docs/reference/decisions/0061-a-memory-kill-ends-the-agents-processes-not-the-harness.md +83 -0
- package/docs/reference/decisions/0062-jr2-briefs-the-agent-on-its-seat-never-on-its-task.md +212 -0
- package/docs/reference/decisions/0063-the-orchestrator-watches-the-cluster.md +83 -0
- package/docs/reference/decisions/0064-a-workspace-waits-for-capacity.md +79 -0
- package/docs/reference/decisions/0065-a-persist-survives-a-crash-and-history-is-a-week.md +65 -0
- package/docs/reference/decisions/0066-a-model-tier-runs-a-real-model-and-a-change-to-what-it-reads-runs-the-tier.md +550 -0
- package/docs/reference/decisions/0067-an-effect-is-an-actor-slot-and-runs-at-most-once-unless-marked-idempotent.md +430 -0
- package/docs/reference/decisions/0068-an-effector-holds-an-effects-secrets-and-signs-its-wire.md +464 -0
- package/docs/reference/decisions/0069-the-orchestrator-is-a-kit-image-and-an-instance-publishes-its-assembly.md +180 -0
- package/docs/reference/decisions/0070-a-machine-lends-its-parts-to-a-chart.md +323 -0
- package/docs/reference/decisions/0071-a-run-starts-a-run-through-a-dispatch-effect.md +183 -0
- package/docs/reference/decisions/0072-the-docs-ship-inside-the-kit-and-an-instances-agents-md-indexes-them.md +144 -0
- package/docs/reference/decisions/0073-a-machine-fails-a-run-with-fail-and-an-uncaught-failure-ends-it-failed.md +122 -0
- package/docs/reference/decisions/0074-an-unrouted-mechanism-event-is-refused-at-load-and-faults-the-run.md +76 -0
- package/docs/reference/decisions.md +83 -0
- package/docs/reference/glossary.md +648 -0
- package/docs/reference/http-api.md +1348 -0
- package/docs/reference/machines.md +190 -0
- package/docs/reference/mechanism-events.md +72 -0
- package/docs/why.md +206 -0
- package/package.json +6 -4
- package/src/actor.ts +976 -61
- package/src/agent.ts +114 -38
- package/src/ambient.ts +4 -1
- package/src/assembly-checks.ts +347 -0
- package/src/assembly-tar.ts +494 -0
- package/src/assembly.ts +721 -0
- package/src/cause.ts +234 -0
- package/src/chart.ts +2182 -0
- package/src/charts.ts +748 -0
- package/src/config.ts +520 -162
- package/src/content-hash.ts +105 -0
- package/src/custodian.lua +6 -5
- package/src/custodian.ts +143 -39
- package/src/customize.ts +388 -55
- package/src/dispatch-effect.ts +945 -0
- package/src/door-compat.ts +217 -0
- package/src/durability.ts +11 -4
- package/src/effect-checks.ts +557 -0
- package/src/effect.ts +1202 -0
- package/src/effector-wire.ts +674 -0
- package/src/fail.ts +209 -0
- package/src/fingerprint.ts +4 -3
- package/src/gate.ts +8 -0
- package/src/git-clone.ts +65 -0
- package/src/git-push.ts +336 -0
- package/src/harness-client.ts +764 -48
- package/src/held-secrets.ts +82 -26
- package/src/holds.ts +156 -0
- package/src/http-effect.ts +1423 -0
- package/src/http.ts +916 -113
- package/src/images.ts +47 -21
- package/src/index.ts +62 -43
- package/src/instance.ts +505 -59
- package/src/internal.ts +84 -0
- package/src/kube-client.ts +333 -0
- package/src/machine-doc.ts +106 -6
- package/src/mechanism-routes.ts +168 -0
- package/src/model-keys.generated.ts +53 -0
- package/src/model-keys.ts +18 -58
- package/src/mount-digest.ts +53 -0
- package/src/names.ts +66 -8
- package/src/notices.ts +141 -0
- package/src/open-body.ts +1580 -0
- package/src/open-effect.ts +217 -0
- package/src/open.ts +59 -6
- package/src/parts.ts +709 -41
- package/src/party.ts +534 -0
- package/src/pick.ts +761 -0
- package/src/pool.ts +248 -37
- package/src/registration.ts +382 -19
- package/src/repo-fetch.ts +60 -85
- package/src/repos.ts +65 -75
- package/src/rest.ts +133 -0
- package/src/run-host.ts +2383 -115
- package/src/run-output.ts +38 -0
- package/src/sandbox-effect.ts +1126 -0
- package/src/sandbox-effector.ts +111 -0
- package/src/sandbox-kube.ts +1721 -0
- package/src/sandbox-watch.ts +260 -0
- package/src/secret-placement.ts +529 -0
- package/src/server.ts +284 -84
- package/src/setup.ts +819 -117
- package/src/size.ts +454 -0
- package/src/snapshot-store.ts +115 -20
- package/src/stub-harness.ts +49 -16
- package/src/sync-client.ts +54 -0
- package/src/timers.ts +191 -0
- package/src/tokens.ts +35 -4
- package/src/vocabulary.ts +135 -15
- package/src/wire.ts +238 -10
- package/src/workspace.ts +1195 -338
- package/src/sandbox-kubectl.ts +0 -1108
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Pools and Sources
|
|
3
|
+
description: How a Pool runs one worker Machine for each work item that a Source gives, and how its run ends.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pools and Sources
|
|
7
|
+
|
|
8
|
+
A [Pool](../reference/glossary.md#pool) is a [Machine](../reference/glossary.md#machine) that runs one worker Machine
|
|
9
|
+
for each item of work. It gets the items from a [Source](../reference/glossary.md#source), one at a time, and it runs a
|
|
10
|
+
limited number of workers at once. You make a Pool with [`pool()`](../reference/authoring-surface/pool.md) and a Source
|
|
11
|
+
with [`source()`](../reference/authoring-surface/source.md). A Pool is usually the root of a
|
|
12
|
+
[Workflow](../reference/glossary.md#workflow). For example, a Pool can run one [`task`](../reference/machines.md#task)
|
|
13
|
+
for each ticket that is ready.
|
|
14
|
+
|
|
15
|
+
## Why it exists
|
|
16
|
+
|
|
17
|
+
A Machine that works through a list of items does the same work each time. It claims an item and starts a worker for it.
|
|
18
|
+
It runs no more workers than a limit. It collects each result, looks for more work, and decides when the run is done. A
|
|
19
|
+
Pool does all of this. The Machine gives only the Source, the worker and the limit.
|
|
20
|
+
|
|
21
|
+
The Pool holds both the Source and the workers. Thus it can tell three conditions apart. All the work is done, the work
|
|
22
|
+
that remains can never start, or the workers wait for a person.
|
|
23
|
+
|
|
24
|
+
## How a Pool behaves
|
|
25
|
+
|
|
26
|
+
The example is a Pool over a Source of four tickets. T-3 needs T-1 and T-2, and T-4 needs a ticket that does not exist.
|
|
27
|
+
Each worker waits at a [Gate](../reference/glossary.md#gate) until a person approves or rejects its ticket. Thus the
|
|
28
|
+
example runs with no model. A worker is usually a Machine with an [Agent](../reference/glossary.md#agent), such as
|
|
29
|
+
`task`.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { assign, fromPromise } from "xstate";
|
|
33
|
+
import { z } from "zod";
|
|
34
|
+
import { defineEvent, jr2Setup, pool, source } from "@jr2/orchestrator";
|
|
35
|
+
|
|
36
|
+
type Ticket = { id: string; title: string; needs: string[] };
|
|
37
|
+
|
|
38
|
+
// A small backlog with dependencies. T-3 can start only when T-1 and T-2 are done.
|
|
39
|
+
// T-4 needs a ticket that does not exist, so it never becomes ready.
|
|
40
|
+
const backlog: Ticket[] = [
|
|
41
|
+
{ id: "T-1", title: "Trim the name.", needs: [] },
|
|
42
|
+
{ id: "T-2", title: "Add a --version flag.", needs: [] },
|
|
43
|
+
{ id: "T-3", title: "Document the two changes.", needs: ["T-1", "T-2"] },
|
|
44
|
+
{ id: "T-4", title: "Remove the old flag.", needs: ["T-9"] },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// The ids that the Pool claimed. This set is in memory, so it serves one run.
|
|
48
|
+
// A real Work Source asks the issue tracker instead.
|
|
49
|
+
const claimed = new Set<string>();
|
|
50
|
+
|
|
51
|
+
// The Source: give the next ready ticket, or say how many tickets are not ready.
|
|
52
|
+
const tickets = source<Ticket>({
|
|
53
|
+
next: fromPromise(async ({ input }: { input: { active: string[] } }) => {
|
|
54
|
+
const done = (id: string) => claimed.has(id) && !input.active.includes(id);
|
|
55
|
+
const waiting = backlog.filter((t) => !claimed.has(t.id));
|
|
56
|
+
const ready = waiting.find((t) => t.needs.every(done));
|
|
57
|
+
if (!ready) return { item: null, open: waiting.length };
|
|
58
|
+
claimed.add(ready.id);
|
|
59
|
+
return { item: ready, open: waiting.length - 1 };
|
|
60
|
+
}),
|
|
61
|
+
// Send this event to the Pool's `source` Gate when the backlog changes.
|
|
62
|
+
wake: defineEvent({
|
|
63
|
+
name: "tickets_changed",
|
|
64
|
+
description: "The backlog changed. Look for ready tickets again.",
|
|
65
|
+
audience: "external",
|
|
66
|
+
input: z.object({}),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const approve = defineEvent({
|
|
71
|
+
name: "approve",
|
|
72
|
+
description: "Accept the ticket.",
|
|
73
|
+
audience: "external",
|
|
74
|
+
input: z.object({}),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const reject = defineEvent({
|
|
78
|
+
name: "reject",
|
|
79
|
+
description: "Refuse the ticket.",
|
|
80
|
+
audience: "external",
|
|
81
|
+
input: z.object({ reason: z.string().describe("Why, in one sentence.") }),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
type Outcome = { id: string; outcome: "approved" } | { id: string; outcome: "rejected"; reason: string };
|
|
85
|
+
|
|
86
|
+
// The worker: one Machine for each ticket. Here a person decides at a Gate.
|
|
87
|
+
// A worker is usually a Machine with an Agent, such as `task`.
|
|
88
|
+
const review = jr2Setup({
|
|
89
|
+
types: {} as { input: Ticket; context: Ticket & { outcome?: Outcome }; output: Outcome },
|
|
90
|
+
events: [approve, reject],
|
|
91
|
+
}).createMachine({
|
|
92
|
+
id: "review",
|
|
93
|
+
context: ({ input }) => input,
|
|
94
|
+
initial: "review",
|
|
95
|
+
states: {
|
|
96
|
+
review: {
|
|
97
|
+
invoke: { src: "gate", input: ({ context }) => ({ meta: { title: context.title } }) },
|
|
98
|
+
on: {
|
|
99
|
+
approve: {
|
|
100
|
+
target: "decided",
|
|
101
|
+
actions: assign({ outcome: ({ context }) => ({ id: context.id, outcome: "approved" as const }) }),
|
|
102
|
+
},
|
|
103
|
+
reject: {
|
|
104
|
+
target: "decided",
|
|
105
|
+
actions: assign({
|
|
106
|
+
outcome: ({ context, event }) => ({ id: context.id, outcome: "rejected" as const, reason: event.reason }),
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
decided: { type: "final" },
|
|
112
|
+
},
|
|
113
|
+
output: ({ context }) => context.outcome!,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// The Pool: one `review` for each ready ticket, two at most at once.
|
|
117
|
+
export const machine = pool(review, {
|
|
118
|
+
id: "tickets",
|
|
119
|
+
source: tickets,
|
|
120
|
+
itemId: (ticket: Ticket) => ticket.id,
|
|
121
|
+
cap: 2,
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The Pool asks for work, starts workers, and waits:
|
|
126
|
+
|
|
127
|
+
- The Pool calls the `next` of its Source when the run starts. It gives `next` the ids of the items that its workers
|
|
128
|
+
have now.
|
|
129
|
+
- When `next` gives an item, the Pool starts a worker for it, and calls `next` again. The id of the worker is
|
|
130
|
+
`itemId(item)`.
|
|
131
|
+
- When `cap` workers run, the Pool does not call `next`. It calls `next` again when a worker finishes.
|
|
132
|
+
- When no item is ready and workers run, the Pool waits. It calls `next` again when a worker finishes, when the `wake`
|
|
133
|
+
event comes, or after `pollEvery` milliseconds.
|
|
134
|
+
- When no worker runs and `next` gives no item, the run ends.
|
|
135
|
+
|
|
136
|
+
In the example, T-1 and T-2 start at once, because `cap` is 2. The run then has three Gates: `T-1.review`, `T-2.review`
|
|
137
|
+
and `source`. When a person answers both tickets, T-3 starts. When T-3 finishes, only T-4 remains, and it can never
|
|
138
|
+
start. Thus the run ends in the state `deadlocked`, and the `status` of its output is `deadlocked`.
|
|
139
|
+
|
|
140
|
+
### How the run ends
|
|
141
|
+
|
|
142
|
+
The output of a Pool is `{ status, items, failures }`. `items` holds the output of each worker that got to a final
|
|
143
|
+
state, by item id. `failures` holds the [Failure](../reference/glossary.md#failure) of each worker that failed, by item
|
|
144
|
+
id. The Pool catches a worker's Failure: that worker stops, its Sandbox is deleted, and the other workers go on. A
|
|
145
|
+
defect in a worker is not caught, and ends the run `error`.
|
|
146
|
+
|
|
147
|
+
When the Pool ends and one or more workers failed, the run ends `failed` by default. This is true for `drained` and for
|
|
148
|
+
`deadlocked`. Its output is then the Failure of the Pool: the reason is `"<n> of <m> items failed"`, and the detail is
|
|
149
|
+
`{ status, items, failures }`. `jr2 run` exits 1. To end `done` with the failures in the output, give `pool()` the
|
|
150
|
+
option `failures: "report"`. Use it when a failed item is a correct answer of the run, for example in a run that tries
|
|
151
|
+
each item and reports which ones did not succeed.
|
|
152
|
+
|
|
153
|
+
`status` comes from the last answer of `next`:
|
|
154
|
+
|
|
155
|
+
| The last answer of `next` | `status` | What it means |
|
|
156
|
+
| ----------------------------------------------- | ------------ | ---------------------------------------- |
|
|
157
|
+
| `null`, or `{ item: null, open: 0 }` | `drained` | No item is left. |
|
|
158
|
+
| `{ item: null, open: <n> }`, with `<n>` above 0 | `deadlocked` | Items exist, but none of them can start. |
|
|
159
|
+
|
|
160
|
+
While workers wait at Gates, the run does not end. It stays open, and the Gates of the run show what needs you. This is
|
|
161
|
+
not a status in the output: a run that waits has no output yet.
|
|
162
|
+
|
|
163
|
+
### Inputs, Gates and the wake event
|
|
164
|
+
|
|
165
|
+
- A worker gets its item as its input, or what `itemInput(item, { input })` makes of it. The Pool does not give the run
|
|
166
|
+
input to a worker. `itemInput` can copy a part of it into the worker's input.
|
|
167
|
+
- The run input of a Pool is its own `input` schema, not the input of its worker. `cap` and `itemInput` read it.
|
|
168
|
+
- The Gates of a worker show in the run. The id of each one starts with the id of its item, such as `T-1.review`.
|
|
169
|
+
- The Pool takes the `wake` event of the Source at a Gate named `source`, for the whole run. A webhook or
|
|
170
|
+
[`jr2 send`](../reference/cli.md#send) sends it. When the Pool is inside a different Machine, the Gate is
|
|
171
|
+
`<path>.source`.
|
|
172
|
+
- The [Vocabulary](../reference/glossary.md#vocabulary) of a Pool is only its `wake` event. Each worker keeps its own.
|
|
173
|
+
|
|
174
|
+
A Pool is a Machine. It can be the root of a Workflow, or a different Machine can compose it.
|
|
175
|
+
[`customize()`](../reference/authoring-surface/customize.md) goes through a Pool to its worker, as
|
|
176
|
+
[Composition](composition.md) tells.
|
|
177
|
+
|
|
178
|
+
## Sources
|
|
179
|
+
|
|
180
|
+
[`source(spec)`](../reference/authoring-surface/source.md) declares where a Pool gets its items. A Source has three
|
|
181
|
+
parts ([`SourceSpec`](../reference/authoring-surface/type-sourcespec.md)):
|
|
182
|
+
|
|
183
|
+
- `next`: an [xstate](https://xstate.js.org) promise actor that claims the next ready item. Its input is `{ active }`,
|
|
184
|
+
the ids of the items that workers have now.
|
|
185
|
+
- `wake`: an optional event, made with [`defineEvent`](../reference/authoring-surface/defineevent.md), that tells the
|
|
186
|
+
Pool that new work is ready.
|
|
187
|
+
- `pollEvery`: an optional time in milliseconds. While the Pool waits, it calls `next` again at this interval.
|
|
188
|
+
|
|
189
|
+
`next` resolves to one of three answers ([`SourceNextResult`](../reference/authoring-surface/type-sourcenextresult.md)):
|
|
190
|
+
an item, `null` when no item is ready now, or `{ item, open }`. `open` is the number of items that exist but are not
|
|
191
|
+
ready. Without `open`, the Pool cannot tell a finished run from a blocked one. Thus, when no worker runs, `null` means
|
|
192
|
+
`drained`.
|
|
193
|
+
|
|
194
|
+
A Source can be a queue, a generator, or a set that `next` queries again each time.
|
|
195
|
+
|
|
196
|
+
## Work Source and the Ready-set
|
|
197
|
+
|
|
198
|
+
A [Work Source](../reference/glossary.md#work-source) is a Source over an issue tracker, such as GitHub issues or Jira.
|
|
199
|
+
The Work Source reads the dependencies between the items from the issue tracker. The
|
|
200
|
+
[Ready-set](../reference/glossary.md#ready-set) is the set of items that nothing blocks now. The `next` of a Work Source
|
|
201
|
+
gives the next item of the Ready-set.
|
|
202
|
+
|
|
203
|
+
The Machine does not hold the dependencies, and it does not copy the Ready-set into its context. It asks the Work Source
|
|
204
|
+
again each time. The Ready-set changes during a run. A person can add a ticket, or open a closed ticket again. Use
|
|
205
|
+
`wake` or `pollEvery`, so that the Pool sees the change while it waits.
|
|
206
|
+
|
|
207
|
+
jr2 does not include a Work Source. You write its `next` for your issue tracker. In the example, the list in memory is
|
|
208
|
+
the issue tracker.
|
|
209
|
+
|
|
210
|
+
## Rules
|
|
211
|
+
|
|
212
|
+
- `itemId` gives each item an id of its own, and the same id each time. The Pool uses it as the id of the worker and as
|
|
213
|
+
the key in `items`.
|
|
214
|
+
- `next` must not give an item that a worker has now, or an item that a worker finished. The Pool gives `next` the
|
|
215
|
+
active ids only. Your Source keeps the finished items.
|
|
216
|
+
- `cap` is a number, or a function of the run input. Without `cap`, one worker runs at a time.
|
|
217
|
+
- `onDrained` takes only `"final"`: the run ends.
|
|
218
|
+
- The Pool calls `next` again on `wake` or after `pollEvery` only while it waits: workers run and no item is ready.
|
|
219
|
+
- A `task` in a Pool needs a `branch` in its input. Make it in `itemInput`, for example from the item id.
|
|
220
|
+
|
|
221
|
+
## Read next
|
|
222
|
+
|
|
223
|
+
- [Run one worker per item](../guides/run-one-worker-per-item.md)
|
|
224
|
+
- [Composition](composition.md)
|
|
225
|
+
- [Gates](gates.md)
|
|
226
|
+
- Reference: [`pool()`](../reference/authoring-surface/pool.md), [`source()`](../reference/authoring-surface/source.md),
|
|
227
|
+
[`PoolSpec`](../reference/authoring-surface/type-poolspec.md),
|
|
228
|
+
[`SourceSpec`](../reference/authoring-surface/type-sourcespec.md),
|
|
229
|
+
[`SourceNextResult`](../reference/authoring-surface/type-sourcenextresult.md)
|
|
230
|
+
- [ADR-0017](../reference/decisions/0017-pool-over-a-source-port.md): the run loop is a Pool over a Source
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Secrets and trust
|
|
3
|
+
description: Where jr2 keeps each credential, which tokens it makes, and what a caller can see and do without one.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Secrets and trust
|
|
7
|
+
|
|
8
|
+
jr2 keeps each credential of the `secrets` list, the key of `harness.provider.apiKey`, and each token of its own, out of
|
|
9
|
+
the containers in which an [Agent](../reference/glossary.md#agent) executes code. A
|
|
10
|
+
[Held secret](../reference/glossary.md#held-secret) is a credential that the [Harness](../reference/glossary.md#harness)
|
|
11
|
+
uses through its pod's [Custodian](../reference/glossary.md#custodian), and the Harness container holds only its
|
|
12
|
+
[Stand-in](../reference/glossary.md#stand-in). An [Effect secret](../reference/glossary.md#effect-secret) is a
|
|
13
|
+
credential that an [Effect](../reference/glossary.md#effect) uses, and only an
|
|
14
|
+
[Effector](../reference/glossary.md#effector) holds its value. jr2 also makes its own tokens, for each caller of the
|
|
15
|
+
[Orchestrator](../reference/glossary.md#orchestrator) and of each Harness. Without a token, a caller can see each
|
|
16
|
+
[Machine](../reference/glossary.md#machine) and where each live run is in it, but it cannot control a run.
|
|
17
|
+
|
|
18
|
+
## Why it exists
|
|
19
|
+
|
|
20
|
+
An Agent's [Working tools](../reference/glossary.md#working-tools) give it a shell in the Harness container. Thus the
|
|
21
|
+
Agent can read each variable and each file of that container, and it can send them out of the pod. If a model API key
|
|
22
|
+
were in that container, the Agent could take it away. If the credential of the Orchestrator's API were there, the Agent
|
|
23
|
+
could answer its own review [Gate](../reference/glossary.md#gate).
|
|
24
|
+
|
|
25
|
+
jr2 does not try to hide the API from the Agent. Instead, it keeps the credentials out of that container. The Instance
|
|
26
|
+
token enters no Harness pod. Each credential of the `secrets` list, and the key of `harness.provider.apiKey`, goes to a
|
|
27
|
+
container in which the Agent executes nothing. [Architecture](architecture.md) tells where those containers run.
|
|
28
|
+
|
|
29
|
+
## One list, and the name decides
|
|
30
|
+
|
|
31
|
+
[`jr2.config.ts`](../reference/config.md) has one [`secrets`](../reference/config.md#secrets) list. An entry goes to
|
|
32
|
+
each place that names it, and to no other place:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { defineConfig } from "@jr2/orchestrator";
|
|
36
|
+
|
|
37
|
+
export default defineConfig({
|
|
38
|
+
secrets: [
|
|
39
|
+
// A model key. Each pod whose Agents use Anthropic claims it, and the Custodian of that pod holds it.
|
|
40
|
+
// It has no hosts, so it goes only to the host that Anthropic's calls go to.
|
|
41
|
+
{ name: "ANTHROPIC_API_KEY", value: process.env.ANTHROPIC_API_KEY },
|
|
42
|
+
// A Held secret for a tool that the Agent runs. A workspace() claims it with secrets: ["TRACKER_TOKEN"].
|
|
43
|
+
// The tool sends it as a bearer. The Custodian puts the value only into requests to this host.
|
|
44
|
+
{ name: "TRACKER_TOKEN", value: process.env.TRACKER_TOKEN, hosts: ["api.tracker.example.com"] },
|
|
45
|
+
// An Effect secret. An Effect names it with secret("DEPLOY_TOKEN"), and only its Effector holds the value.
|
|
46
|
+
{ name: "DEPLOY_TOKEN", value: process.env.DEPLOY_TOKEN },
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- A pod claims a Held secret when its [`workspace()`](../reference/authoring-surface/workspace.md) lists the name under
|
|
52
|
+
`secrets`. A pod also claims the key of each provider that an Agent in that pod uses.
|
|
53
|
+
- The [Instance Harness](../reference/glossary.md#instance-harness) claims only the model keys of the Menu-only Agents
|
|
54
|
+
that it hosts.
|
|
55
|
+
- An Effect claims an Effect secret when it names it with [`secret()`](../reference/authoring-surface/secret.md).
|
|
56
|
+
- One entry can be a Held secret and an Effect secret at the same time. The placement is a fact of each place that names
|
|
57
|
+
it, not of the entry.
|
|
58
|
+
- An entry that nothing names goes nowhere, and [`jr2 up`](../reference/cli.md#up) warns about it.
|
|
59
|
+
|
|
60
|
+
[`harness.provider.apiKey`](../reference/config.md#harness-provider-apikey) is a Held secret too. Each pod whose Agents
|
|
61
|
+
use the custom provider claims it, and it goes only to the host of `harness.provider.baseUrl`.
|
|
62
|
+
|
|
63
|
+
`jr2 up` reads the values on your computer, from your shell or `.env`. It writes each value only into the Secrets of the
|
|
64
|
+
containers that hold it. An entry can also name a key of a Secret that you manage, with `valueFrom`.
|
|
65
|
+
|
|
66
|
+
## Held secrets
|
|
67
|
+
|
|
68
|
+
The Harness container of a pod gets one variable for each Held secret of the pod. Its value is the Stand-in,
|
|
69
|
+
`jr2-held-<NAME>`. The Stand-in is the same in each pod, and it is not secret. It has a meaning only to the Custodian of
|
|
70
|
+
that pod.
|
|
71
|
+
|
|
72
|
+
When a pod holds a Held secret other than the Sandbox token, the Harness container sends its HTTPS traffic through the
|
|
73
|
+
Custodian (`HTTPS_PROXY`). For each request to a host that a Held secret is bound to, the Custodian does these things:
|
|
74
|
+
|
|
75
|
+
1. It ends the TLS connection with a certificate that `jr2 up` issued from the CA of the
|
|
76
|
+
[Instance](../reference/glossary.md#instance).
|
|
77
|
+
2. It replaces the Stand-in with the value, in the headers that the entry names.
|
|
78
|
+
3. It opens its own TLS connection to the host, and verifies the certificate of the host.
|
|
79
|
+
|
|
80
|
+
The Custodian sends the traffic to each other host with no change. It refuses a loopback, link-local or unspecified
|
|
81
|
+
address. A request to a bound host that has no Stand-in in its headers does not leave the pod.
|
|
82
|
+
|
|
83
|
+
These fields of an entry bind a Held secret. They do not place it:
|
|
84
|
+
|
|
85
|
+
- [`hosts`](../reference/config.md#secrets-hosts): the hosts that the value can go to. A known model key with one
|
|
86
|
+
default host, such as `ANTHROPIC_API_KEY`, can leave it out. It then goes only to the host of its provider.
|
|
87
|
+
- [`headers`](../reference/config.md#secrets-headers): the headers in which the Custodian replaces the Stand-in.
|
|
88
|
+
- [`paths`](../reference/config.md#secrets-paths): the path prefixes that the value can go to.
|
|
89
|
+
|
|
90
|
+
The Custodian also holds the Sandbox token of its pod, and the Harness container holds only its Stand-in. Each
|
|
91
|
+
[Sandbox](../reference/glossary.md#sandbox) and the Instance Harness has a Sandbox token. The Harness reads the
|
|
92
|
+
[Menu](../reference/glossary.md#menu) and sends each pick with the Stand-in of that token, and the Custodian replaces
|
|
93
|
+
it.
|
|
94
|
+
|
|
95
|
+
### What a Held secret does not stop
|
|
96
|
+
|
|
97
|
+
- **The Agent can spend the key.** While the pod lives, the Agent can send requests through the Custodian to a bound
|
|
98
|
+
host. A key that can make new keys gives the Agent a key that it can take away. Use a key with no admin rights. Set
|
|
99
|
+
narrow `paths`.
|
|
100
|
+
- **A response passes with no change.** If a host puts the full key in a response, the Agent reads it.
|
|
101
|
+
- **jr2 does not control egress.** A client that does not use the Custodian sends only the Stand-in, which is worth
|
|
102
|
+
nothing outside the pod. The cluster decides which hosts a pod can reach.
|
|
103
|
+
- **A key that signs the request cannot be a Held secret.** A SigV4 or ADC credential signs the request, and the
|
|
104
|
+
Custodian cannot put a value into a signature. Use an Effect secret for such a credential. For a model provider, use a
|
|
105
|
+
gateway that holds the credential, and make the key of the gateway a Held secret.
|
|
106
|
+
- **A tool must trust the CA of the Instance.** When a pod holds a Held secret other than the Sandbox token, jr2 sets
|
|
107
|
+
the trust variables of Node.js, OpenSSL, Python and git in its Harness container. A client that does not trust the CA,
|
|
108
|
+
such as a Java client, cannot connect to a bound host. It sends nothing.
|
|
109
|
+
|
|
110
|
+
## Effect secrets
|
|
111
|
+
|
|
112
|
+
An Effect secret is the real value, in an Effector. The Effector reads the value and puts it into the call, or into the
|
|
113
|
+
environment of a `command`. The Agent executes nothing in the Effector, and the Orchestrator never holds the value.
|
|
114
|
+
[Effects](effects.md) tells which Effects run in which Effector.
|
|
115
|
+
|
|
116
|
+
A `command` that names an Effect secret can run the Agent's code, such as `npm run deploy`. It runs on a copy of one
|
|
117
|
+
commit of the Agent's branch, in its scratch folder. Because the command can run the Agent's code, the Effector confines
|
|
118
|
+
the process of the command with Landlock. The process can read and run the system files of the image. It can use its own
|
|
119
|
+
scratch folder, and read the Effect secrets that the command names. It cannot read the Effector's key, the other Effect
|
|
120
|
+
secrets, the push credentials or the [Worktree](../reference/glossary.md#worktree).
|
|
121
|
+
|
|
122
|
+
The Effector removes each Effect secret that it holds from what it returns, in the forms that it sent and in common
|
|
123
|
+
encodings. It does not find a changed form of an Effect secret, such as a hash or a part of it.
|
|
124
|
+
|
|
125
|
+
## Git credentials
|
|
126
|
+
|
|
127
|
+
The [`git.credentials`](../reference/config.md#git-credentials) entries give the cluster its git credentials. The
|
|
128
|
+
Orchestrator matches a [Repo](../reference/glossary.md#repo) to an entry, and names the Secret of that entry. It never
|
|
129
|
+
reads a git credential:
|
|
130
|
+
|
|
131
|
+
- The clone credential goes into a Secret that only the Repo cache reads.
|
|
132
|
+
- The push credential and the signing key go to the [Sandbox Effector](../reference/glossary.md#sandbox-effector) of the
|
|
133
|
+
Sandbox whose `push` Effect uses them.
|
|
134
|
+
|
|
135
|
+
The list is also a fence. A Repo url that comes from the run input must match an entry, or the Orchestrator refuses to
|
|
136
|
+
make the Sandbox. [Give the cluster git credentials](../guides/give-the-cluster-git-credentials.md) gives the fields.
|
|
137
|
+
|
|
138
|
+
## The tokens
|
|
139
|
+
|
|
140
|
+
jr2 makes its own tokens. `jr2 up` makes the Instance token and the signing key the first time, and keeps them in the
|
|
141
|
+
`jr2-instance` Secret. Each other token comes from the signing key, so the Orchestrator stores no token for each pod.
|
|
142
|
+
|
|
143
|
+
| Token | Who holds it | What it lets the holder do |
|
|
144
|
+
| -------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
145
|
+
| Instance token | You, the CLI, the [Console](../reference/glossary.md#console) when you type it, and a webhook client | Everything: start a run, read its full state, answer a Gate, cancel a run. |
|
|
146
|
+
| Sandbox token | The Custodian of one pod, as a file | Read the Menu and send the picks of the Agents in that pod. Ask for a fetch of a Repo that the Sandbox mounts. |
|
|
147
|
+
| Harness bearer | The Orchestrator. The Harness holds only its SHA-256 digest. | Call the Harness in one pod: start a [Turn](../reference/glossary.md#turn), read it, stop it, set up a Worktree, and run a `command` Effect. |
|
|
148
|
+
| Effector key | The Orchestrator, and the Effector of one placement | Sign a request to that Effector, and sign its answer. |
|
|
149
|
+
|
|
150
|
+
- The Instance token enters no Harness pod. The CLI reads it from the `jr2-instance` Secret over the Kubernetes API.
|
|
151
|
+
Thus Kubernetes RBAC decides who holds it.
|
|
152
|
+
- A Sandbox token cannot answer a Gate and cannot speak for a different pod. Thus an Agent cannot approve its own work,
|
|
153
|
+
and a Sandbox cannot send a pick for an Agent in a different Sandbox.
|
|
154
|
+
- A Harness can check its bearer, but it cannot make a bearer. Thus an Agent cannot drive a conversation in a different
|
|
155
|
+
pod.
|
|
156
|
+
|
|
157
|
+
## Open observation, guarded control
|
|
158
|
+
|
|
159
|
+
Each route of the [HTTP API](../reference/http-api.md) is in one of three access bands:
|
|
160
|
+
|
|
161
|
+
- [**Open**](../reference/http-api.md#band-open), with no token: the [Workflows](../reference/glossary.md#workflow), the
|
|
162
|
+
structure of each Machine, and the live runs of a Workflow with their states. An open route shows no context of a run,
|
|
163
|
+
and an [Emit](../reference/glossary.md#emit) shows only its type.
|
|
164
|
+
- [**Authenticated**](../reference/http-api.md#band-authenticated), with the Instance token or a Sandbox token: the
|
|
165
|
+
routes of the Agent's Menu and the fetch. A Sandbox token reaches only what its own pod owns.
|
|
166
|
+
- [**Instance token only**](../reference/http-api.md#band-instanceonly): the start of a run, the full state of a run,
|
|
167
|
+
the Gates, and cancel.
|
|
168
|
+
|
|
169
|
+
Thus the Console shows the Machines and the runs without a token. When you type the Instance token in the Console, it
|
|
170
|
+
can also start runs and answer Gates. The Console keeps the token in the session storage of the browser tab, and forgets
|
|
171
|
+
it when you close the tab.
|
|
172
|
+
|
|
173
|
+
"Open" means open to each caller that can reach the Service of the Orchestrator: a port forward, a pod in the cluster,
|
|
174
|
+
or an ingress. The names of the states and the types of the Emits are open.
|
|
175
|
+
|
|
176
|
+
The Harness writes each Agent's conversation to its container log. The log has the prompts, the model's text and
|
|
177
|
+
thinking, its tool calls and the answers to its picks. It does not write the results of the Working tools. Each person
|
|
178
|
+
who can read the pod logs of the namespace can read these conversations.
|
|
179
|
+
|
|
180
|
+
## Rules
|
|
181
|
+
|
|
182
|
+
- A model key goes in the `secrets` list. `jr2 up` refuses a known model key in `harness.env`, or in a Secret or a
|
|
183
|
+
ConfigMap that `harness.envFrom` names.
|
|
184
|
+
- A Held secret goes only over `https://`. `jr2 up` refuses `harness.provider.apiKey` when `harness.provider.baseUrl` is
|
|
185
|
+
not `https://`. A local model over plain `http://` has no key.
|
|
186
|
+
- [`harness.env`](../reference/config.md#harness-env) and `harness.envFrom` put each value into the Harness container,
|
|
187
|
+
and the Agent can read it. Put a credential in the `secrets` list.
|
|
188
|
+
- A Held secret must name its `hosts`, unless it is a known model key with one default host.
|
|
189
|
+
- A name that a `workspace()` lists must be in the `secrets` list. A name that an Effect gives to `secret()` must be in
|
|
190
|
+
it too.
|
|
191
|
+
- An Effect secret has 8 characters or more.
|
|
192
|
+
- The name of a Held secret is an env var name. It cannot start with `JR2_`, and it cannot be a proxy or trust variable.
|
|
193
|
+
- The Orchestrator can make and change a Secret, but it cannot get or list one.
|
|
194
|
+
- A changed value does not reach a live Sandbox. A new Sandbox gets it. When a Menu-only Agent uses the value, the next
|
|
195
|
+
`jr2 up` restarts the Instance Harness with it.
|
|
196
|
+
- A `command` that names an Effect secret needs Landlock in the kernel of the node. On a node without it, the Effector
|
|
197
|
+
does not start, and the provision of the Sandbox fails.
|
|
198
|
+
- When a pod holds a Held secret other than the Sandbox token, `SSL_CERT_FILE` and the other trust variables replace the
|
|
199
|
+
trust store of the image. They hold the public roots, `harness.caBundle` and the CA of the Instance. Thus a private CA
|
|
200
|
+
goes in [`harness.caBundle`](../reference/config.md#harness-cabundle), not in the image.
|
|
201
|
+
- `jr2 up` makes the CA of the Instance one time, in the `jr2-held-ca` Secret, and never changes it. No pod mounts that
|
|
202
|
+
Secret. When you delete it, the next `jr2 up` makes a new CA.
|
|
203
|
+
|
|
204
|
+
## Read next
|
|
205
|
+
|
|
206
|
+
- [Use a local model](../guides/use-a-local-model.md)
|
|
207
|
+
- [Use a hosted provider or a gateway](../guides/use-a-hosted-provider.md)
|
|
208
|
+
- [Give the cluster git credentials](../guides/give-the-cluster-git-credentials.md)
|
|
209
|
+
- [Run a command or call a URL with an Effect](../guides/run-a-command-or-call-a-url.md)
|
|
210
|
+
- [Open the Console](../guides/open-the-console.md)
|
|
211
|
+
- [Architecture](architecture.md) and [Effects](effects.md)
|
|
212
|
+
- The [`secrets`](../reference/config.md#secrets), [`git`](../reference/config.md#git) and
|
|
213
|
+
[`harness`](../reference/config.md#harness) fields of `jr2.config.ts`,
|
|
214
|
+
[`secret()`](../reference/authoring-surface/secret.md), and the [HTTP API](../reference/http-api.md)
|
|
215
|
+
- [ADR-0013](../reference/decisions/0013-the-agent-reaches-its-machine-through-a-container-it-cannot-read.md),
|
|
216
|
+
[ADR-0014](../reference/decisions/0014-observation-is-open-run-state-is-not.md),
|
|
217
|
+
[ADR-0023](../reference/decisions/0023-the-harness-prints-the-conversation.md),
|
|
218
|
+
[ADR-0032](../reference/decisions/0032-the-console-unlocks-with-the-instance-token.md),
|
|
219
|
+
[ADR-0051](../reference/decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md),
|
|
220
|
+
[ADR-0058](../reference/decisions/0058-a-harness-answers-the-orchestrator-alone.md),
|
|
221
|
+
[ADR-0059](../reference/decisions/0059-a-harness-holds-stand-ins-and-the-custodian-holds-the-keys.md) and
|
|
222
|
+
[ADR-0068](../reference/decisions/0068-an-effector-holds-an-effects-secrets-and-signs-its-wire.md)
|