@astrosheep/keiyaku 4.6.27 → 4.6.28
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 +76 -35
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/pi/README.md +7 -12
- package/build/plugins/pi/akuma-tools.ts +3 -18
- package/build/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/src/akuma/akuma-call.d.ts +15 -18
- package/build/src/akuma/akuma-call.js +55 -112
- package/build/src/akuma/akuma-errors.d.ts +0 -5
- package/build/src/akuma/akuma-errors.js +0 -9
- package/build/src/akuma/akuma-instance.d.ts +0 -2
- package/build/src/akuma/akuma-instance.js +18 -14
- package/build/src/akuma/akuma-observe.js +0 -1
- package/build/src/akuma/akuma-owner.js +0 -1
- package/build/src/akuma/akuma.d.ts +10 -26
- package/build/src/akuma/akuma.js +0 -2
- package/build/src/akuma/archetype.d.ts +0 -2
- package/build/src/akuma/archetype.js +3 -9
- package/build/src/akuma/body-launch.d.ts +12 -4
- package/build/src/akuma/body.d.ts +2 -5
- package/build/src/akuma/body.js +5 -49
- package/build/src/akuma/call-initial-tell.d.ts +39 -147
- package/build/src/akuma/call-initial-tell.js +0 -48
- package/build/src/akuma/caller.d.ts +0 -4
- package/build/src/akuma/custody.js +1 -57
- package/build/src/akuma/heart/facts.d.ts +0 -39
- package/build/src/akuma/heart/facts.js +0 -1
- package/build/src/akuma/heart/index.d.ts +1 -2
- package/build/src/akuma/heart/index.js +0 -1
- package/build/src/akuma/heart/schema.js +0 -26
- package/build/src/akuma/heart/soul.d.ts +2 -2
- package/build/src/akuma/heart/soul.js +2 -4
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +0 -2
- package/build/src/akuma/in-process-body.d.ts +1 -1
- package/build/src/akuma/index.d.ts +0 -2
- package/build/src/akuma/index.js +0 -1
- package/build/src/akuma/projection.d.ts +23 -23
- package/build/src/akuma/provider.d.ts +0 -5
- package/build/src/akuma/provider.js +0 -1
- package/build/src/akuma/providers/acp/core.js +1 -1
- package/build/src/akuma/providers/claude/index.js +1 -2
- package/build/src/akuma/providers/codex-app-server/index.js +1 -1
- package/build/src/akuma/providers/execution-environment.d.ts +1 -3
- package/build/src/akuma/providers/execution-environment.js +1 -7
- package/build/src/akuma/providers/opencode-sdk/index.js +0 -1
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +0 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +4 -4
- package/build/src/akuma/providers/paseo/index.js +2 -9
- package/build/src/akuma/providers/pi/index.js +8 -14
- package/build/src/akuma/publication.d.ts +24 -59
- package/build/src/akuma/publication.js +29 -64
- package/build/src/akuma/selection-observation.d.ts +47 -2036
- package/build/src/akuma/selection-observation.js +1 -59
- package/build/src/akuma/turn-drive.d.ts +0 -8
- package/build/src/akuma/turn-drive.js +19 -103
- package/build/src/akuma-body.js +3 -6
- package/build/src/body-host.d.ts +8 -2
- package/build/src/body-host.js +30 -4
- package/build/src/cli/commands/akuma-grammar.d.ts +0 -2
- package/build/src/cli/commands/akuma-grammar.js +10 -33
- package/build/src/cli/commands/akuma.js +31 -49
- package/build/src/cli/commands/contract-grammar.d.ts +7 -1
- package/build/src/cli/commands/contract-grammar.js +15 -0
- package/build/src/cli/commands/contract-help.d.ts +13 -1
- package/build/src/cli/commands/contract-help.js +47 -16
- package/build/src/cli/commands/contract.js +27 -26
- package/build/src/cli/commands/debt.js +3 -3
- package/build/src/cli/commands/whoami.d.ts +0 -2
- package/build/src/cli/commands/whoami.js +0 -5
- package/build/src/cli/coordinates.js +15 -0
- package/build/src/cli/delivery-identity.d.ts +3 -0
- package/build/src/cli/delivery-identity.js +23 -0
- package/build/src/cli/parse.js +1 -0
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +1 -4
- package/build/src/cli/render/catalog.js +7 -1
- package/build/src/cli/render/contract-history.js +16 -38
- package/build/src/cli/render/contract-observation.d.ts +23 -10
- package/build/src/cli/render/contract-observation.js +9 -6
- package/build/src/cli/render/contract-wait.d.ts +2 -0
- package/build/src/cli/render/contract-wait.js +18 -0
- package/build/src/cli/render/contract.d.ts +2 -2
- package/build/src/cli/render/contract.js +57 -39
- package/build/src/cli/render/delivery-preview.js +13 -26
- package/build/src/cli/render/execution-progress.js +9 -9
- package/build/src/cli/render/kanshi.js +4 -11
- package/build/src/cli/render/receipt.d.ts +18 -0
- package/build/src/cli/render/receipt.js +34 -10
- package/build/src/cli/render/reconcile.js +3 -0
- package/build/src/cli/render/refusal.js +28 -6
- package/build/src/cli/render/whoami.js +1 -4
- package/build/src/cli/runtime.d.ts +0 -2
- package/build/src/cli/runtime.js +3 -7
- package/build/src/cli/selectors.d.ts +1 -2
- package/build/src/cli/selectors.js +2 -5
- package/build/src/contract-guidance.js +4 -2
- package/build/src/contract-worktree.d.ts +3 -3
- package/build/src/core/facts/codec.js +38 -5
- package/build/src/core/facts/fold.js +1 -0
- package/build/src/core/facts/gate.d.ts +10 -4
- package/build/src/core/facts/gate.js +56 -39
- package/build/src/core/facts/observation.d.ts +7 -1
- package/build/src/core/facts/observation.js +15 -0
- package/build/src/core/facts/offer.d.ts +2 -2
- package/build/src/core/facts/types.d.ts +17 -1
- package/build/src/core/facts/types.js +6 -0
- package/build/src/core/verbs/amend.js +8 -0
- package/build/src/core/verbs/bind.d.ts +3 -1
- package/build/src/core/verbs/bind.js +9 -1
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +4 -1
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +7 -4
- package/build/src/core/verbs/reintegrate.d.ts +2 -1
- package/build/src/core/verbs/reintegrate.js +4 -1
- package/build/src/debt/board.d.ts +10 -10
- package/build/src/debt/created-observation.d.ts +3 -3
- package/build/src/debt/document.d.ts +1 -1
- package/build/src/debt/index.d.ts +2 -24
- package/build/src/debt/index.js +11 -71
- package/build/src/debt/operation-types.d.ts +44 -3
- package/build/src/git/admission.js +18 -6
- package/build/src/git/integration.d.ts +4 -4
- package/build/src/git/integration.js +7 -1
- package/build/src/git/observe.d.ts +6 -4
- package/build/src/git/observe.js +18 -17
- package/build/src/git/reconcile.d.ts +20 -8
- package/build/src/git/reconcile.js +94 -45
- package/build/src/git/repository.d.ts +3 -1
- package/build/src/git/repository.js +26 -4
- package/build/src/git/scratch.d.ts +1 -1
- package/build/src/git/scratch.js +19 -18
- package/build/src/git/target-placement.d.ts +33 -7
- package/build/src/git/target-placement.js +67 -18
- package/build/src/git/target.d.ts +32 -0
- package/build/src/git/target.js +84 -0
- package/build/src/git/terminal-reconcile.d.ts +1 -1
- package/build/src/git/terminal-reconcile.js +34 -6
- package/build/src/index.d.ts +9 -7
- package/build/src/index.js +1 -1
- package/build/src/library/address.d.ts +1 -20
- package/build/src/library/address.js +3 -24
- package/build/src/library/akuma-creation.d.ts +2 -5
- package/build/src/library/akuma-creation.js +60 -44
- package/build/src/library/akumas.d.ts +3 -9
- package/build/src/library/akumas.js +12 -25
- package/build/src/library/bind.d.ts +21 -9
- package/build/src/library/bind.js +5 -1
- package/build/src/library/continuation.d.ts +130 -155
- package/build/src/library/continuation.js +1 -4
- package/build/src/library/contract-composition.d.ts +4 -9
- package/build/src/library/contract-composition.js +8 -12
- package/build/src/library/contract-creation.d.ts +1 -3
- package/build/src/library/contract-creation.js +2 -3
- package/build/src/library/contract-execution.d.ts +3 -5
- package/build/src/library/contract-execution.js +55 -96
- package/build/src/library/contract-outcomes.d.ts +2 -1
- package/build/src/library/contract-types.d.ts +5 -0
- package/build/src/library/contract-wait.d.ts +35 -0
- package/build/src/library/contract-wait.js +141 -0
- package/build/src/library/delivery.d.ts +13 -525
- package/build/src/library/delivery.js +1 -12
- package/build/src/library/input.js +2 -1
- package/build/src/library/invocation.d.ts +5 -1
- package/build/src/library/invocation.js +9 -2
- package/build/src/library/keiyaku.d.ts +7 -6
- package/build/src/library/keiyaku.js +12 -7
- package/build/src/library/outcome.d.ts +461 -12586
- package/build/src/library/outcome.js +15 -234
- package/build/src/library/reconcile.d.ts +12 -0
- package/build/src/library/reconcile.js +1 -0
- package/build/src/library/refusal.d.ts +251 -34
- package/build/src/library/refusal.js +10 -5
- package/build/src/library/selection.d.ts +9 -35
- package/build/src/library/selection.js +59 -129
- package/build/src/plugin/akuma-signals.d.ts +2 -2
- package/build/src/plugin/akuma-signals.js +2 -2
- package/build/src/plugin/public.d.ts +0 -7
- package/build/src/plugin/runtime.d.ts +2 -2
- package/build/src/plugin/runtime.js +4 -3
- package/build/src/protocol/attempt.js +7 -3
- package/build/src/protocol/bind.d.ts +18 -4
- package/build/src/protocol/bind.js +102 -35
- package/build/src/protocol/completion.d.ts +18 -331
- package/build/src/protocol/completion.js +17 -130
- package/build/src/protocol/deliver.d.ts +3 -3
- package/build/src/protocol/deliver.js +64 -74
- package/build/src/protocol/delivery-preview.d.ts +85 -28
- package/build/src/protocol/delivery-preview.js +34 -22
- package/build/src/protocol/execution-observation.d.ts +12 -9
- package/build/src/protocol/execution-observation.js +0 -1
- package/build/src/protocol/intent.d.ts +20 -50
- package/build/src/protocol/intent.js +37 -44
- package/build/src/protocol/operations.d.ts +299 -19
- package/build/src/protocol/operations.js +68 -27
- package/build/src/protocol/outcome.d.ts +1 -1
- package/build/src/protocol/placement.d.ts +2 -2
- package/build/src/protocol/placement.js +4 -3
- package/build/src/protocol/progress.d.ts +35 -2
- package/build/src/protocol/progress.js +12 -1
- package/build/src/protocol/read/observation.js +15 -4
- package/build/src/protocol/read/status.d.ts +9 -14
- package/build/src/protocol/read/status.js +15 -22
- package/build/src/protocol/reintegrate.d.ts +4 -3
- package/build/src/protocol/reintegrate.js +21 -5
- package/build/src/protocol/review.d.ts +9 -15
- package/build/src/protocol/review.js +2 -6
- package/build/src/protocol/run.d.ts +1 -1
- package/build/src/protocol/verify.d.ts +51 -0
- package/build/src/protocol/verify.js +128 -0
- package/build/src/verification/declaration.d.ts +5 -1
- package/build/src/verification/declaration.js +19 -2
- package/build/src/verification/execution.d.ts +5 -2
- package/build/src/verification/execution.js +48 -53
- package/build/src/verification/observation.d.ts +10 -6
- package/build/src/verification/observation.js +5 -2
- package/package.json +3 -3
- package/plugins/paseo/plugin/index.server.ts +3 -0
- package/plugins/paseo/plugin/server/attach.ts +42 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +51 -0
- package/plugins/paseo/plugin/server/model.ts +26 -0
- package/plugins/paseo/plugin/server/provider.ts +4 -6
- package/plugins/paseo/plugin/server/reopen.ts +4 -39
- package/plugins/pi/README.md +7 -12
- package/plugins/pi/akuma-tools.ts +3 -18
- package/skills/keiyaku-akuma/SKILL.md +39 -4
- package/skills/keiyaku-akuma/references/automation.md +4 -7
- package/skills/keiyaku-babysit/SKILL.md +1 -1
- package/skills/keiyaku-bind/SKILL.md +39 -15
- package/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/src/akuma/allowed.d.ts +0 -23
- package/build/src/akuma/allowed.js +0 -63
- package/build/src/akuma/call-request.d.ts +0 -308
- package/build/src/akuma/call-request.js +0 -175
- package/build/src/akuma/heart/request-authority.d.ts +0 -16
- package/build/src/akuma/heart/request-authority.js +0 -140
- package/build/src/akuma/heart/request-rows.d.ts +0 -18
- package/build/src/akuma/heart/request-rows.js +0 -107
- package/build/src/akuma/request-lifecycle.d.ts +0 -42
- package/build/src/akuma/request-lifecycle.js +0 -197
- package/build/src/akuma/request-observation.d.ts +0 -45
- package/build/src/akuma/request-observation.js +0 -162
- package/build/src/akuma/request-rendezvous.d.ts +0 -32
- package/build/src/akuma/request-rendezvous.js +0 -189
- package/build/src/akuma/request-serve.d.ts +0 -16
- package/build/src/akuma/request-serve.js +0 -188
- package/build/src/akuma/request-wire.d.ts +0 -143
- package/build/src/akuma/request-wire.js +0 -146
- package/build/src/akuma/requests.d.ts +0 -20
- package/build/src/akuma/requests.js +0 -72
- package/build/src/akuma/selection-owner-port.d.ts +0 -14
- package/build/src/akuma/selection-owner-port.js +0 -54
- package/build/src/akuma/selection-request.d.ts +0 -305
- package/build/src/akuma/selection-request.js +0 -307
- package/build/src/body-requests.d.ts +0 -13
- package/build/src/body-requests.js +0 -131
- package/build/src/cli/square-identity.d.ts +0 -10
- package/build/src/cli/square-identity.js +0 -130
- package/build/src/debt/mutation-result.d.ts +0 -981
- package/build/src/debt/mutation-result.js +0 -109
- package/build/src/debt/mutation.d.ts +0 -424
- package/build/src/debt/mutation.js +0 -223
- package/build/src/library/contract-operations.d.ts +0 -382
- package/build/src/library/contract-operations.js +0 -300
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/** @architectureCompositionRoot */
|
|
2
|
-
import { AkumaBodyRequestError } from "../akuma/request-rendezvous.js";
|
|
3
|
-
import { executionChannel } from "../akuma/requests.js";
|
|
4
2
|
import { prepareAmendDocument } from "../body/amend.js";
|
|
5
3
|
import { decodeArcDocument } from "../body/arc.js";
|
|
6
4
|
import { decodeContractDocument } from "../body/decode.js";
|
|
@@ -16,15 +14,15 @@ import { admitDeliveryOperation } from "../protocol/deliver.js";
|
|
|
16
14
|
import { withScopeAbortSignal, } from "../protocol/operations.js";
|
|
17
15
|
import { executionStop, isOperationalFailure, isOperationalStop, } from "../protocol/progress.js";
|
|
18
16
|
import { admitReviewOperation } from "../protocol/review.js";
|
|
17
|
+
import { verifyOperation } from "../protocol/verify.js";
|
|
19
18
|
import { releaseDebtHolder, releaseDebtHolderWithFence, debtHolderObservationSelection } from "../settlement/holder.js";
|
|
20
19
|
import { continueDeliveredDependents } from "./continuation.js";
|
|
21
|
-
import { requestForwardedContractLive } from "./contract-operations.js";
|
|
22
20
|
import { acceptedOutcome, expected, retainAdmission } from "./contract-outcomes.js";
|
|
23
21
|
import { derivedContractPolicy, derivedFreshness, derivedGates, derivedHooks, gateNames, } from "./contract-settings.js";
|
|
24
22
|
import { deliveryForContract } from "./delivery.js";
|
|
25
23
|
import { actorOption, contractTerms, documentDerivation, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
|
|
26
24
|
import { InvocationAccumulator } from "./invocation.js";
|
|
27
|
-
import { KeiyakuError,
|
|
25
|
+
import { KeiyakuError, project, validated, } from "./outcome.js";
|
|
28
26
|
import { reconcileAffectedContracts } from "./reconcile.js";
|
|
29
27
|
import { observeChangedRegion } from "./region.js";
|
|
30
28
|
export class ContractExecution {
|
|
@@ -38,9 +36,6 @@ export class ContractExecution {
|
|
|
38
36
|
get scope() {
|
|
39
37
|
return this.seat.scope;
|
|
40
38
|
}
|
|
41
|
-
get execution() {
|
|
42
|
-
return this.seat.execution;
|
|
43
|
-
}
|
|
44
39
|
get composition() {
|
|
45
40
|
return this.seat.composition;
|
|
46
41
|
}
|
|
@@ -77,14 +72,7 @@ export class ContractExecution {
|
|
|
77
72
|
const amendment = amendmentPlan === undefined ? undefined : validated(() => amendmentPlan(current));
|
|
78
73
|
changedSections = amendment?.changedSections;
|
|
79
74
|
const amended = amendment === undefined ? current : validated(() => decodeContractDocument(amendment.document));
|
|
80
|
-
const terms =
|
|
81
|
-
? {
|
|
82
|
-
document: source.document,
|
|
83
|
-
segments: source.segments,
|
|
84
|
-
gates: gates ?? source.gates,
|
|
85
|
-
after: prerequisites ?? source.after,
|
|
86
|
-
}
|
|
87
|
-
: contractTerms(amended, gates ?? source.gates, prerequisites ?? source.after);
|
|
75
|
+
const terms = contractTerms(amended, gates ?? source.gates, prerequisites ?? source.after);
|
|
88
76
|
return { terms, verification: documentDerivation(amended, terms.gates, this.id).verification };
|
|
89
77
|
},
|
|
90
78
|
});
|
|
@@ -112,24 +100,6 @@ export class ContractExecution {
|
|
|
112
100
|
async deliver(input, options) {
|
|
113
101
|
const values = validated(() => normalizeDeliverInput(input));
|
|
114
102
|
const observer = validated(() => observationOptions(options));
|
|
115
|
-
const channel = executionChannel(this.execution);
|
|
116
|
-
if (channel.kind === "body-request")
|
|
117
|
-
return await forwardedContractOutcome({
|
|
118
|
-
revive: (value) => deliveryForContract(this.scope, value),
|
|
119
|
-
directory: channel.directory,
|
|
120
|
-
action: "contract.deliver",
|
|
121
|
-
...(observer === undefined ? {} : { observe: observer }),
|
|
122
|
-
...(values.signal === undefined ? {} : { signal: values.signal }),
|
|
123
|
-
request: {
|
|
124
|
-
action: "contract.deliver",
|
|
125
|
-
repoRoot: this.scope.primaryWorktree,
|
|
126
|
-
contractId: this.id,
|
|
127
|
-
...(values.message === undefined ? {} : { message: values.message }),
|
|
128
|
-
includeDirty: values.includeDirty,
|
|
129
|
-
materializeConflict: values.materializeConflict,
|
|
130
|
-
overwrite: values.overwrite,
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
103
|
const { hooks, requireBranchesToBeUpToDate } = derivedContractPolicy(this.composition);
|
|
134
104
|
return await this.local("deliver", async (accumulator, localChannel, scope) => {
|
|
135
105
|
let leadingValue;
|
|
@@ -156,8 +126,8 @@ export class ContractExecution {
|
|
|
156
126
|
return expected(this.id, outcome);
|
|
157
127
|
leadingValue = outcome.value;
|
|
158
128
|
accumulator.extendConclusions(this.id, { leading: outcome.value.leading });
|
|
159
|
-
stage = "
|
|
160
|
-
await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, outcome, values.signal
|
|
129
|
+
stage = "placement";
|
|
130
|
+
await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, outcome, values.signal);
|
|
161
131
|
}
|
|
162
132
|
catch (error) {
|
|
163
133
|
retainTrailingFailure(accumulator, this.id, error, values.signal, stage);
|
|
@@ -171,6 +141,54 @@ export class ContractExecution {
|
|
|
171
141
|
return acceptedOutcome("deliver", this.id, accumulator, deliveryForContract(this.scope, value));
|
|
172
142
|
}, values.signal, observer);
|
|
173
143
|
}
|
|
144
|
+
async verify(input, options) {
|
|
145
|
+
const values = validated(() => input === undefined ? undefined : requireInput(input, "verify input", ["index", "includeDirty", "signal"]));
|
|
146
|
+
const index = validated(() => {
|
|
147
|
+
if (values?.index === undefined)
|
|
148
|
+
return undefined;
|
|
149
|
+
if (typeof values.index !== "number" || !Number.isSafeInteger(values.index) || values.index < 1)
|
|
150
|
+
throw new TypeError("verification index must be a positive safe integer");
|
|
151
|
+
return values.index;
|
|
152
|
+
});
|
|
153
|
+
const includeDirty = validated(() => optionalBoolean(values?.includeDirty, "includeDirty") ?? false);
|
|
154
|
+
const signal = validated(() => optionalSignal(values?.signal));
|
|
155
|
+
const observer = validated(() => observationOptions(options));
|
|
156
|
+
const { hooks, requireBranchesToBeUpToDate } = derivedContractPolicy(this.composition);
|
|
157
|
+
return await this.local("verify", async (accumulator, localChannel, scope) => {
|
|
158
|
+
const outcome = await verifyOperation({
|
|
159
|
+
scope,
|
|
160
|
+
channel: localChannel,
|
|
161
|
+
contractId: this.id,
|
|
162
|
+
progress: accumulator,
|
|
163
|
+
deriveDocument: derivedDocument,
|
|
164
|
+
includeDirty,
|
|
165
|
+
requireBranchesToBeUpToDate,
|
|
166
|
+
...(index === undefined ? {} : { index }),
|
|
167
|
+
...(signal === undefined ? {} : { signal }),
|
|
168
|
+
...(this.composition.actor === undefined ? {} : { actor: this.composition.actor }),
|
|
169
|
+
});
|
|
170
|
+
if (outcome.kind !== "accepted")
|
|
171
|
+
return expected(this.id, outcome);
|
|
172
|
+
accumulator.extendConclusions(this.id, outcome.value);
|
|
173
|
+
let completion = {};
|
|
174
|
+
try {
|
|
175
|
+
if (!signal?.aborted)
|
|
176
|
+
completion = await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, {
|
|
177
|
+
kind: "accepted",
|
|
178
|
+
facts: [],
|
|
179
|
+
state: outcome.checkpoint.state,
|
|
180
|
+
journal: outcome.checkpoint.journal,
|
|
181
|
+
}, signal);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
retainTrailingFailure(accumulator, this.id, error, signal, "placement");
|
|
185
|
+
}
|
|
186
|
+
const value = { ...outcome.value, ...completion };
|
|
187
|
+
accumulator.extendConclusions(this.id, value);
|
|
188
|
+
await reconcileAffectedContracts(accumulator, this.id, scope, localChannel, hooks);
|
|
189
|
+
return acceptedOutcome("verify", this.id, accumulator, value);
|
|
190
|
+
}, signal, observer);
|
|
191
|
+
}
|
|
174
192
|
async review(input, options) {
|
|
175
193
|
const values = validated(() => requireInput(input, "review input", ["verdict", "summary", "actor", "signal"]));
|
|
176
194
|
const actor = validated(() => actorOption(values.actor));
|
|
@@ -182,22 +200,6 @@ export class ContractExecution {
|
|
|
182
200
|
const summary = validated(() => optionalNonblank(values.summary, "review summary"));
|
|
183
201
|
const signal = validated(() => optionalSignal(values.signal));
|
|
184
202
|
const observer = validated(() => observationOptions(options));
|
|
185
|
-
const channel = executionChannel(this.execution);
|
|
186
|
-
if (channel.kind === "body-request")
|
|
187
|
-
return await forwardedContractOutcome({
|
|
188
|
-
directory: channel.directory,
|
|
189
|
-
action: "contract.review",
|
|
190
|
-
...(observer === undefined ? {} : { observe: observer }),
|
|
191
|
-
...(signal === undefined ? {} : { signal }),
|
|
192
|
-
request: {
|
|
193
|
-
action: "contract.review",
|
|
194
|
-
repoRoot: this.scope.primaryWorktree,
|
|
195
|
-
contractId: this.id,
|
|
196
|
-
verdict,
|
|
197
|
-
...(summary === undefined ? {} : { summary }),
|
|
198
|
-
...actor,
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
203
|
const hooks = derivedHooks(this.composition);
|
|
202
204
|
return await this.local("review", async (accumulator, localChannel, scope) => {
|
|
203
205
|
let value = {};
|
|
@@ -223,7 +225,7 @@ export class ContractExecution {
|
|
|
223
225
|
if (verdict === "satisfied")
|
|
224
226
|
value = {
|
|
225
227
|
...value,
|
|
226
|
-
...(await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, outcome, signal
|
|
228
|
+
...(await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, outcome, signal)),
|
|
227
229
|
};
|
|
228
230
|
}
|
|
229
231
|
catch (error) {
|
|
@@ -308,21 +310,6 @@ export class ContractExecution {
|
|
|
308
310
|
const showDiff = validated(() => optionalBoolean(values?.showDiff, "showDiff") ?? false);
|
|
309
311
|
const signal = validated(() => optionalSignal(values?.signal));
|
|
310
312
|
const observer = validated(() => observationOptions(options));
|
|
311
|
-
const channel = executionChannel(this.execution);
|
|
312
|
-
if (channel.kind === "body-request")
|
|
313
|
-
return await forwardedContractOutcome({
|
|
314
|
-
directory: channel.directory,
|
|
315
|
-
action: "contract.preview-delivery",
|
|
316
|
-
...(observer === undefined ? {} : { observe: observer }),
|
|
317
|
-
...(signal === undefined ? {} : { signal }),
|
|
318
|
-
request: {
|
|
319
|
-
action: "contract.preview-delivery",
|
|
320
|
-
repoRoot: this.scope.primaryWorktree,
|
|
321
|
-
contractId: this.id,
|
|
322
|
-
includeDirty,
|
|
323
|
-
showDiff,
|
|
324
|
-
},
|
|
325
|
-
});
|
|
326
313
|
const requireBranchesToBeUpToDate = derivedFreshness(this.composition);
|
|
327
314
|
return await this.local("deliver-preview", async (accumulator, localChannel, scope) => {
|
|
328
315
|
const admission = await previewDeliveryOperation({
|
|
@@ -430,15 +417,13 @@ function retainTrailingFailure(accumulator, contractId, error, signal, stage) {
|
|
|
430
417
|
accumulator.recordStop(executionStop(contractId, stage, error, signal));
|
|
431
418
|
}
|
|
432
419
|
// eslint-disable-next-line max-params -- Keep this local operation's custody, admission, and policy witnesses explicit.
|
|
433
|
-
async function advanceAndContinue(accumulator, scope, channel, contractId, composition, outcome, signal
|
|
420
|
+
async function advanceAndContinue(accumulator, scope, channel, contractId, composition, outcome, signal) {
|
|
434
421
|
const checkpoint = { state: outcome.state, journal: outcome.journal };
|
|
435
422
|
const result = await completeCandidate({
|
|
436
423
|
repository: scope,
|
|
437
424
|
channel,
|
|
438
425
|
checkpoint,
|
|
439
426
|
progress: accumulator,
|
|
440
|
-
start,
|
|
441
|
-
deriveDocument: derivedDocument,
|
|
442
427
|
...(composition.actor === undefined ? {} : { actor: composition.actor }),
|
|
443
428
|
...(signal === undefined ? {} : { signal }),
|
|
444
429
|
});
|
|
@@ -451,7 +436,6 @@ async function advanceAndContinue(accumulator, scope, channel, contractId, compo
|
|
|
451
436
|
channel,
|
|
452
437
|
progress: accumulator,
|
|
453
438
|
completed: result,
|
|
454
|
-
deriveDocument: derivedDocument,
|
|
455
439
|
...(composition.actor === undefined ? {} : { actor: composition.actor }),
|
|
456
440
|
...(signal === undefined ? {} : { signal }),
|
|
457
441
|
});
|
|
@@ -473,31 +457,6 @@ function admittedDeliveryValue(accumulator, contractId) {
|
|
|
473
457
|
return { ...delivery.data, leading: { kind: "already-admitted", fact: delivery.entry } };
|
|
474
458
|
throw new Error("confirmed delivery requires its own receipt");
|
|
475
459
|
}
|
|
476
|
-
async function forwardedContractOutcome(input) {
|
|
477
|
-
try {
|
|
478
|
-
const result = (await requestForwardedContractLive({
|
|
479
|
-
directory: input.directory,
|
|
480
|
-
action: input.action,
|
|
481
|
-
request: input.request,
|
|
482
|
-
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
483
|
-
...(input.observe === undefined ? {} : { observe: input.observe }),
|
|
484
|
-
}));
|
|
485
|
-
return result.kind === "accepted" && input.revive !== undefined
|
|
486
|
-
? { ...result, value: input.revive(result.value) }
|
|
487
|
-
: result;
|
|
488
|
-
}
|
|
489
|
-
catch (error) {
|
|
490
|
-
if (error instanceof KeiyakuError)
|
|
491
|
-
throw error;
|
|
492
|
-
if (input.signal?.aborted === true && error === input.signal.reason)
|
|
493
|
-
throw invocationFailure(error, input.signal);
|
|
494
|
-
throw new KeiyakuError(error instanceof AkumaBodyRequestError && (error.outcome === "unknown" || error.outcome === "unproven")
|
|
495
|
-
? "unknown-outcome"
|
|
496
|
-
: errorCategory(error), errorMessage(error), {
|
|
497
|
-
cause: error,
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
460
|
function invocationFailure(error, signal) {
|
|
502
461
|
return signal?.aborted === true && error === signal.reason
|
|
503
462
|
? new KeiyakuError("aborted", errorMessage(error), { cause: error })
|
|
@@ -7,7 +7,7 @@ import type { ContractWorkspaceLocation } from "../workspace-place.js";
|
|
|
7
7
|
import type { Delivery, DeliveryValue } from "./delivery.js";
|
|
8
8
|
import type { InvocationAccumulator } from "./invocation.js";
|
|
9
9
|
import type { Keiyaku } from "./keiyaku.js";
|
|
10
|
-
import type { ContractVerb, HandoffOutcome, OperationOutcome, OutcomeProjection, Review } from "./outcome.js";
|
|
10
|
+
import type { ContractVerb, HandoffOutcome, OperationOutcome, OutcomeProjection, Review, Verify } from "./outcome.js";
|
|
11
11
|
import type { OperationRefusals } from "./refusal.js";
|
|
12
12
|
import type { AmendRegionObservation, RegionObservation } from "./region.js";
|
|
13
13
|
export type BindValue = Readonly<{
|
|
@@ -25,6 +25,7 @@ export type AmendValue = Readonly<{
|
|
|
25
25
|
export type BindOutcome = OperationOutcome<"bind", BindValue, OperationRefusals["bind"]>;
|
|
26
26
|
export type AmendOutcome = OperationOutcome<"amend", AmendValue, OperationRefusals["amend"]>;
|
|
27
27
|
export type DeliverOutcome = OperationOutcome<"deliver", Delivery & DeliveryValue, OperationRefusals["deliver"]> | HandoffOutcome;
|
|
28
|
+
export type VerifyOutcome = OperationOutcome<"verify", Verify, OperationRefusals["verify"]>;
|
|
28
29
|
export type ReviewOutcome = OperationOutcome<"review", Review, OperationRefusals["review"]>;
|
|
29
30
|
export type DeliveryPreviewOutcome = OperationOutcome<"deliver-preview", DeliveryPreviewReport, OperationRefusals["deliver-preview"]>;
|
|
30
31
|
export type ArcOutcome = OperationOutcome<"arc", void, OperationRefusals["arc"]>;
|
|
@@ -114,6 +114,11 @@ export type ReviewInput = ActorOptions & Readonly<{
|
|
|
114
114
|
export type AbandonInput = ActorOptions & Readonly<{
|
|
115
115
|
note?: string;
|
|
116
116
|
}>;
|
|
117
|
+
export type VerifyInput = Readonly<{
|
|
118
|
+
index?: number;
|
|
119
|
+
includeDirty?: boolean;
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}>;
|
|
117
122
|
export type DeliverInput = Readonly<{
|
|
118
123
|
message?: string;
|
|
119
124
|
includeDirty?: boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ContractHead, type ContractId } from "../core/facts/types.js";
|
|
2
|
+
import type { RepositoryScope } from "../protocol/operations.js";
|
|
3
|
+
import { type Repo } from "./repo.js";
|
|
4
|
+
export type ContractWaitOptions = Readonly<{
|
|
5
|
+
completion?: "any" | "all";
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}>;
|
|
9
|
+
export type ContractWaitInput = ContractWaitOptions & Readonly<{
|
|
10
|
+
repo: Repo;
|
|
11
|
+
contracts: readonly string[];
|
|
12
|
+
}>;
|
|
13
|
+
export type ContractWaitMember = Readonly<{
|
|
14
|
+
contract: ContractId;
|
|
15
|
+
baseline: ContractHead | null;
|
|
16
|
+
head: ContractHead | null;
|
|
17
|
+
changed: boolean;
|
|
18
|
+
present: boolean | null;
|
|
19
|
+
terminal: "claimed" | "abandoned" | null;
|
|
20
|
+
}>;
|
|
21
|
+
export type ContractWaitResult = Readonly<{
|
|
22
|
+
kind: "changed" | "terminal" | "deadline" | "missing";
|
|
23
|
+
completion: "any" | "all";
|
|
24
|
+
contracts: readonly ContractWaitMember[];
|
|
25
|
+
}>;
|
|
26
|
+
export type ValidatedWait = Readonly<{
|
|
27
|
+
scope: RepositoryScope;
|
|
28
|
+
ids: readonly ContractId[];
|
|
29
|
+
completion: "any" | "all";
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function validateContractWait(input: unknown): ValidatedWait;
|
|
34
|
+
export declare function validateContractWaitHandle(scope: RepositoryScope, id: ContractId, input?: ContractWaitOptions): ValidatedWait;
|
|
35
|
+
export declare function waitContractLocal(input: ValidatedWait): Promise<ContractWaitResult>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
import { contractId } from "../core/facts/types.js";
|
|
3
|
+
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
4
|
+
import { withGitDecodeChannel } from "../git/read-observation.js";
|
|
5
|
+
import { optionalSignal, requireInput } from "./input.js";
|
|
6
|
+
import { readContractValue } from "./outcome.js";
|
|
7
|
+
import { scopeForRepo } from "./repo.js";
|
|
8
|
+
export function validateContractWait(input) {
|
|
9
|
+
const values = requireInput(input, "Contract wait input", ["repo", "contracts", "completion", "timeoutMs", "signal"]);
|
|
10
|
+
return validateContractWaitValues(values, scopeForRepo(values.repo));
|
|
11
|
+
}
|
|
12
|
+
export function validateContractWaitHandle(scope, id, input) {
|
|
13
|
+
const values = input === undefined ? {} : requireInput(input, "Contract wait options", ["completion", "timeoutMs", "signal"]);
|
|
14
|
+
return validateContractWaitValues({ ...values, contracts: [id] }, scope);
|
|
15
|
+
}
|
|
16
|
+
function validateContractWaitValues(values, scope) {
|
|
17
|
+
if (!Array.isArray(values.contracts) || values.contracts.length === 0)
|
|
18
|
+
throw new TypeError("contracts must be a nonempty array");
|
|
19
|
+
const ids = [
|
|
20
|
+
...new Set(values.contracts.map((value) => {
|
|
21
|
+
if (typeof value !== "string")
|
|
22
|
+
throw new TypeError("contract ID must be a string");
|
|
23
|
+
try {
|
|
24
|
+
return contractId(value);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new TypeError(error instanceof Error ? error.message : String(error));
|
|
28
|
+
}
|
|
29
|
+
})),
|
|
30
|
+
];
|
|
31
|
+
const completion = values.completion === undefined ? "any" : values.completion;
|
|
32
|
+
if (completion !== "any" && completion !== "all")
|
|
33
|
+
throw new TypeError("completion must be any or all");
|
|
34
|
+
const timeoutMs = values.timeoutMs;
|
|
35
|
+
if (timeoutMs !== undefined && (typeof timeoutMs !== "number" || !Number.isFinite(timeoutMs) || timeoutMs < 0))
|
|
36
|
+
throw new TypeError("timeoutMs must be a nonnegative finite number");
|
|
37
|
+
const signal = optionalSignal(values.signal);
|
|
38
|
+
return {
|
|
39
|
+
scope,
|
|
40
|
+
ids,
|
|
41
|
+
completion,
|
|
42
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
43
|
+
...(signal === undefined ? {} : { signal }),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function readiness(members, completion) {
|
|
47
|
+
if (members.some((member) => member.present === false))
|
|
48
|
+
return "missing";
|
|
49
|
+
const satisfied = (member) => member.present === true && (member.changed || member.terminal !== null);
|
|
50
|
+
if (completion === "any" ? members.some(satisfied) : members.every(satisfied))
|
|
51
|
+
return members.some((member) => member.changed) ? "changed" : "terminal";
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
export async function waitContractLocal(input) {
|
|
55
|
+
const { ids, completion, timeoutMs, signal } = input;
|
|
56
|
+
signal?.throwIfAborted();
|
|
57
|
+
const deadline = timeoutMs === undefined ? Infinity : performance.now() + timeoutMs;
|
|
58
|
+
const deadlineController = new AbortController();
|
|
59
|
+
// Zero means an unbounded baseline-only read. Positive durations also bound that read.
|
|
60
|
+
let timer;
|
|
61
|
+
const scheduleDeadline = () => {
|
|
62
|
+
const remaining = deadline - performance.now();
|
|
63
|
+
if (remaining <= 0)
|
|
64
|
+
deadlineController.abort();
|
|
65
|
+
else
|
|
66
|
+
timer = setTimeout(scheduleDeadline, Math.min(remaining, 2_147_483_647));
|
|
67
|
+
};
|
|
68
|
+
if (timeoutMs !== undefined && timeoutMs > 0)
|
|
69
|
+
scheduleDeadline();
|
|
70
|
+
const readSignal = signal === undefined ? deadlineController.signal : AbortSignal.any([signal, deadlineController.signal]);
|
|
71
|
+
const scope = { ...input.scope, signal: readSignal };
|
|
72
|
+
const read = async () => await readContractValue(() => withGitDecodeChannel(scope, async (channel) => {
|
|
73
|
+
const observed = await observeContractsForAdmissionAt(scope, channel, ids);
|
|
74
|
+
return ids.map((id) => {
|
|
75
|
+
const record = observed.journals.get(id);
|
|
76
|
+
if (record === undefined)
|
|
77
|
+
throw new Error(`missing requested contract observation: ${id}`);
|
|
78
|
+
return record.state;
|
|
79
|
+
});
|
|
80
|
+
}));
|
|
81
|
+
let members = ids.map((contract) => ({
|
|
82
|
+
contract,
|
|
83
|
+
baseline: null,
|
|
84
|
+
head: null,
|
|
85
|
+
changed: false,
|
|
86
|
+
present: null,
|
|
87
|
+
terminal: null,
|
|
88
|
+
}));
|
|
89
|
+
const result = (kind) => ({ kind, completion, contracts: members });
|
|
90
|
+
try {
|
|
91
|
+
const initial = await read();
|
|
92
|
+
signal?.throwIfAborted();
|
|
93
|
+
members = members.map((member, index) => {
|
|
94
|
+
const state = initial[index] ?? null;
|
|
95
|
+
return {
|
|
96
|
+
...member,
|
|
97
|
+
baseline: state?.head ?? null,
|
|
98
|
+
head: state?.head ?? null,
|
|
99
|
+
present: state !== null,
|
|
100
|
+
terminal: state?.terminal?.kind ?? null,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
const initialResult = readiness(members, completion);
|
|
104
|
+
if (initialResult !== undefined)
|
|
105
|
+
return result(initialResult);
|
|
106
|
+
if (performance.now() >= deadline)
|
|
107
|
+
return result("deadline");
|
|
108
|
+
for (;;) {
|
|
109
|
+
const states = await read();
|
|
110
|
+
signal?.throwIfAborted();
|
|
111
|
+
members = members.map((member, index) => {
|
|
112
|
+
const state = states[index] ?? null;
|
|
113
|
+
const head = state?.head ?? null;
|
|
114
|
+
return {
|
|
115
|
+
...member,
|
|
116
|
+
head,
|
|
117
|
+
present: state !== null,
|
|
118
|
+
terminal: state?.terminal?.kind ?? null,
|
|
119
|
+
changed: member.changed || (state !== null && head !== member.baseline),
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
const observedResult = readiness(members, completion);
|
|
123
|
+
if (observedResult !== undefined)
|
|
124
|
+
return result(observedResult);
|
|
125
|
+
const remaining = deadline - performance.now();
|
|
126
|
+
if (remaining <= 0)
|
|
127
|
+
return result("deadline");
|
|
128
|
+
await delay(Math.min(remaining, 100), undefined, { signal: readSignal });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
signal?.throwIfAborted();
|
|
133
|
+
if (deadlineController.signal.aborted)
|
|
134
|
+
return result("deadline");
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
if (timer !== undefined)
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
}
|
|
141
|
+
}
|