@astrosheep/keiyaku 4.5.11 → 4.5.13
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/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +135 -377
- package/build/integrations/pi/keiyaku.ts +11 -116
- package/build/src/akuma/akuma-errors.d.ts +1 -0
- package/build/src/akuma/akuma-errors.js +1 -0
- package/build/src/akuma/akuma-handle.d.ts +1 -0
- package/build/src/akuma/akuma-handle.js +6 -7
- package/build/src/akuma/akuma-product.d.ts +6 -8
- package/build/src/akuma/akuma-product.js +141 -57
- package/build/src/akuma/akuma.d.ts +5 -7
- package/build/src/akuma/akuma.js +1 -22
- package/build/src/akuma/archetype.d.ts +6 -5
- package/build/src/akuma/archetype.js +137 -38
- package/build/src/akuma/body.d.ts +5 -5
- package/build/src/akuma/body.js +223 -63
- package/build/src/akuma/call-input.d.ts +4 -0
- package/build/src/akuma/call-input.js +21 -0
- package/build/src/akuma/call-request.d.ts +5 -8
- package/build/src/akuma/call-request.js +28 -73
- package/build/src/akuma/fleet-execution.d.ts +26 -0
- package/build/src/akuma/fleet-execution.js +109 -0
- package/build/src/{library/fleet-result.d.ts → akuma/fleet-observation.d.ts} +13 -57
- package/build/src/{library/fleet-result.js → akuma/fleet-observation.js} +4 -25
- package/build/src/akuma/fleet-request.d.ts +122 -0
- package/build/src/akuma/fleet-request.js +168 -0
- package/build/src/akuma/heart/facts.d.ts +23 -0
- package/build/src/akuma/heart/facts.js +7 -0
- package/build/src/akuma/heart/index.d.ts +43 -4
- package/build/src/akuma/heart/index.js +107 -7
- package/build/src/akuma/heart/request-authority.d.ts +2 -0
- package/build/src/akuma/heart/request-authority.js +28 -3
- package/build/src/akuma/heart/request-rows.d.ts +2 -0
- package/build/src/akuma/heart/request-rows.js +24 -5
- package/build/src/akuma/heart/rows.d.ts +4 -1
- package/build/src/akuma/heart/rows.js +46 -19
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +28 -6
- package/build/src/akuma/heart/storage.d.ts +1 -1
- package/build/src/akuma/heart/tells.d.ts +29 -0
- package/build/src/akuma/heart/tells.js +136 -5
- package/build/src/akuma/heart/timeline.js +9 -3
- package/build/src/akuma/projection-read.js +36 -3
- package/build/src/akuma/projection.js +3 -4
- package/build/src/akuma/provider.d.ts +4 -0
- package/build/src/akuma/provider.js +56 -3
- package/build/src/akuma/providers/claude/index.js +3 -0
- package/build/src/akuma/providers/codex-app-server/index.js +14 -12
- package/build/src/akuma/providers/pi/index.js +7 -1
- package/build/src/akuma/publication.js +65 -49
- package/build/src/akuma/request-lifecycle.d.ts +5 -4
- package/build/src/akuma/request-lifecycle.js +29 -16
- package/build/src/akuma/request-rendezvous.d.ts +15 -12
- package/build/src/akuma/request-rendezvous.js +80 -51
- package/build/src/akuma/request-serve.d.ts +1 -2
- package/build/src/akuma/request-serve.js +94 -39
- package/build/src/akuma/request-wire.d.ts +57 -26
- package/build/src/akuma/request-wire.js +64 -25
- package/build/src/akuma/turn-drive.d.ts +5 -4
- package/build/src/akuma/turn-drive.js +27 -11
- package/build/src/akuma-body.d.ts +4 -6
- package/build/src/akuma-body.js +19 -17
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +14 -0
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +1 -0
- package/build/src/cli/commands/akuma-invoke.js +1 -25
- package/build/src/cli/commands/contract-help.d.ts +5 -2
- package/build/src/cli/commands/contract-help.js +62 -12
- package/build/src/cli/commands/contract-invoke.d.ts +5 -0
- package/build/src/cli/commands/contract-invoke.js +26 -1
- package/build/src/cli/commands/contract.js +50 -18
- package/build/src/cli/commands/task-invoke.js +10 -2
- package/build/src/cli/commands/task-query.js +3 -4
- package/build/src/cli/coordinates.d.ts +13 -0
- package/build/src/cli/coordinates.js +38 -24
- package/build/src/cli/draft.d.ts +1 -1
- package/build/src/cli/invoke.js +14 -1
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +5 -38
- package/build/src/cli/render/akuma.js +4 -1
- package/build/src/cli/render/audit.js +4 -1
- package/build/src/cli/render/catalog.js +13 -39
- package/build/src/cli/render/contract.js +4 -14
- package/build/src/cli/render/kanshi-akuma.js +3 -8
- package/build/src/cli/render/kanshi.js +8 -34
- package/build/src/cli/render/nuke.js +7 -3
- package/build/src/cli/render/receipt.d.ts +1 -0
- package/build/src/cli/render/receipt.js +8 -0
- package/build/src/cli/render/refusal.js +4 -3
- package/build/src/cli/render/task.js +4 -37
- package/build/src/cli/render/terminal.d.ts +2 -6
- package/build/src/cli/render/terminal.js +4 -9
- package/build/src/cli/result.d.ts +2 -1
- package/build/src/contract-guidance.js +13 -3
- package/build/src/contract-worktree.d.ts +1 -0
- package/build/src/contract-worktree.js +26 -2
- package/build/src/core/facts/codec.d.ts +2 -1
- package/build/src/core/facts/codec.js +3 -0
- package/build/src/core/facts/gate.d.ts +2 -1
- package/build/src/core/facts/gate.js +63 -0
- package/build/src/core/verbs/abandon.d.ts +2 -1
- package/build/src/core/verbs/abandon.js +16 -0
- package/build/src/core/verbs/amend.d.ts +2 -1
- package/build/src/core/verbs/amend.js +20 -0
- package/build/src/core/verbs/arc.d.ts +2 -1
- package/build/src/core/verbs/arc.js +16 -0
- package/build/src/core/verbs/attestation.d.ts +2 -1
- package/build/src/core/verbs/attestation.js +16 -0
- package/build/src/core/verbs/bind.d.ts +2 -1
- package/build/src/core/verbs/bind.js +16 -0
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +16 -0
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +58 -1
- package/build/src/dispatch/association.d.ts +13 -0
- package/build/src/dispatch/association.js +20 -0
- package/build/src/dispatch/index.d.ts +6 -0
- package/build/src/dispatch/index.js +27 -3
- package/build/src/git/hooks.d.ts +9 -1
- package/build/src/git/hooks.js +79 -1
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +6 -11
- package/build/src/git/private-state-seat.d.ts +26 -1
- package/build/src/git/private-state-seat.js +78 -13
- package/build/src/git/process.d.ts +2 -0
- package/build/src/git/reconcile.d.ts +1 -2
- package/build/src/git/reconcile.js +0 -6
- package/build/src/git/repository.d.ts +0 -2
- package/build/src/git/repository.js +27 -25
- package/build/src/git/result-codec.d.ts +29 -0
- package/build/src/git/result-codec.js +306 -0
- package/build/src/git/target-placement.js +2 -8
- package/build/src/git/workspace.d.ts +2 -0
- package/build/src/git/workspace.js +4 -0
- package/build/src/index.d.ts +1 -0
- package/build/src/kanshi/fleet.js +1 -1
- package/build/src/kanshi/read.js +55 -28
- package/build/src/kanshi/report.d.ts +4 -3
- package/build/src/kanshi/select.js +14 -1
- package/build/src/library/address.d.ts +1 -0
- package/build/src/library/address.js +4 -7
- package/build/src/library/akuma-creation.d.ts +5 -3
- package/build/src/library/akuma-creation.js +90 -33
- package/build/src/library/audit.js +2 -1
- package/build/src/library/catalog.d.ts +10 -2
- package/build/src/library/catalog.js +65 -25
- package/build/src/library/composition.d.ts +1 -0
- package/build/src/library/composition.js +1 -0
- package/build/src/library/configuration.d.ts +4 -21
- package/build/src/library/configuration.js +2 -158
- package/build/src/library/continuation.d.ts +20 -1
- package/build/src/library/continuation.js +36 -0
- package/build/src/library/contract-bind.d.ts +1 -0
- package/build/src/library/contract-bind.js +16 -5
- package/build/src/library/contract-forwarding.d.ts +2 -2
- package/build/src/library/contract-forwarding.js +18 -4
- package/build/src/library/contract-handle.js +4 -3
- package/build/src/library/contract-operations.d.ts +5 -9
- package/build/src/library/contract-operations.js +34 -47
- package/build/src/library/contract.d.ts +11 -2
- package/build/src/library/contract.js +21 -1
- package/build/src/library/delivery.d.ts +4 -1
- package/build/src/library/delivery.js +47 -0
- package/build/src/library/fleet.d.ts +4 -136
- package/build/src/library/fleet.js +31 -315
- package/build/src/library/keiyaku.d.ts +7 -3
- package/build/src/library/keiyaku.js +1 -0
- package/build/src/library/mutation.d.ts +431 -3
- package/build/src/library/mutation.js +192 -19
- package/build/src/library/nuke.d.ts +7 -1
- package/build/src/library/nuke.js +18 -4
- package/build/src/library/reconcile.d.ts +14 -0
- package/build/src/library/reconcile.js +22 -8
- package/build/src/library/refusal.d.ts +9 -1
- package/build/src/library/refusal.js +76 -0
- package/build/src/library/region.d.ts +0 -8
- package/build/src/library/region.js +1 -29
- package/build/src/library/result-codec.d.ts +2 -0
- package/build/src/library/result-codec.js +12 -0
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/types.d.ts +2 -1
- package/build/src/markdown/types.js +3 -1
- package/build/src/plugin/akuma-signals.d.ts +12 -0
- package/build/src/plugin/akuma-signals.js +14 -0
- package/build/src/plugin/public.d.ts +51 -0
- package/build/src/plugin/public.js +1 -0
- package/build/src/plugin/runtime.d.ts +14 -0
- package/build/src/plugin/runtime.js +357 -0
- package/build/src/protocol/amend.js +3 -3
- package/build/src/protocol/attempt.d.ts +2 -1
- package/build/src/protocol/attempt.js +1 -1
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +1 -1
- package/build/src/protocol/bind.d.ts +3 -1
- package/build/src/protocol/bind.js +26 -0
- package/build/src/protocol/completion.js +0 -1
- package/build/src/protocol/deliver.d.ts +1 -1
- package/build/src/protocol/deliver.js +136 -57
- package/build/src/protocol/intent.d.ts +0 -1
- package/build/src/protocol/intent.js +0 -1
- package/build/src/protocol/operations.d.ts +9 -2
- package/build/src/protocol/operations.js +16 -1
- package/build/src/protocol/outcome.d.ts +3 -0
- package/build/src/protocol/outcome.js +17 -1
- package/build/src/protocol/placement.js +10 -3
- package/build/src/protocol/read/status.d.ts +8 -0
- package/build/src/protocol/read/status.js +49 -0
- package/build/src/protocol/reintegrate.js +10 -3
- package/build/src/protocol/result-codec.d.ts +22 -0
- package/build/src/protocol/result-codec.js +442 -0
- package/build/src/protocol/review.d.ts +1 -1
- package/build/src/protocol/review.js +81 -46
- package/build/src/protocol/run.d.ts +22 -2
- package/build/src/protocol/run.js +119 -29
- package/build/src/runtime/proc/lifecycle.js +1 -1
- package/build/src/runtime/proc/line-rpc.d.ts +7 -1
- package/build/src/runtime/proc/line-rpc.js +49 -9
- package/build/src/runtime/proc/run.d.ts +0 -1
- package/build/src/runtime/proc/run.js +1 -11
- package/build/src/runtime/proc/termination.d.ts +1 -0
- package/build/src/runtime/proc/termination.js +63 -18
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settings.d.ts +10 -0
- package/build/src/settings.js +88 -2
- package/build/src/settlement/result-codec.d.ts +2 -0
- package/build/src/settlement/result-codec.js +56 -0
- package/build/src/settlement/settle.d.ts +5 -12
- package/build/src/settlement/settle.js +60 -55
- package/build/src/task/board.d.ts +3 -0
- package/build/src/task/board.js +22 -4
- package/build/src/task/catalog.d.ts +13 -2
- package/build/src/task/catalog.js +59 -5
- package/build/src/task/compose.d.ts +4 -2
- package/build/src/task/compose.js +56 -30
- package/build/src/task/created-observation.d.ts +39 -0
- package/build/src/task/created-observation.js +26 -0
- package/build/src/task/identity.d.ts +6 -0
- package/build/src/task/identity.js +48 -7
- package/build/src/task/index.d.ts +4 -3
- package/build/src/task/index.js +19 -16
- package/build/src/task/input.d.ts +3 -1
- package/build/src/task/input.js +7 -4
- package/build/src/task/lifecycle-operations.d.ts +6 -0
- package/build/src/task/lifecycle-operations.js +116 -0
- package/build/src/task/mutation-result.d.ts +762 -20
- package/build/src/task/mutation-result.js +34 -9
- package/build/src/task/mutation.d.ts +4 -9
- package/build/src/task/mutation.js +17 -52
- package/build/src/task/operation-types.d.ts +114 -0
- package/build/src/task/operation-types.js +1 -0
- package/build/src/task/operations.d.ts +6 -113
- package/build/src/task/operations.js +75 -117
- package/build/src/task/query.d.ts +8 -11
- package/build/src/task/query.js +7 -14
- package/build/src/task/store.d.ts +11 -1
- package/build/src/task/store.js +169 -55
- package/build/src/task/view.d.ts +4 -0
- package/build/src/task/view.js +7 -0
- package/build/src/verification/declaration.d.ts +1 -0
- package/build/src/verification/declaration.js +18 -1
- package/build/src/verification/execution.d.ts +0 -1
- package/build/src/verification/execution.js +5 -5
- package/build/src/world.d.ts +0 -2
- package/build/src/world.js +3 -7
- package/package.json +17 -5
- package/build/src/cli/square-edge.d.ts +0 -7
- package/build/src/cli/square-edge.js +0 -159
- package/build/src/git/ref-migration.d.ts +0 -22
- package/build/src/git/ref-migration.js +0 -55
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +0 -102
- package/build/src/library/contract-forwarding-reconciliation-result.js +0 -92
- package/build/src/library/contract-forwarding-result.d.ts +0 -4270
- package/build/src/library/contract-forwarding-result.js +0 -521
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { materializeIntegrationSnapshot, materializeJudgedConflict, planIntegration, worktreeChangeId, } from "../git/integration.js";
|
|
2
2
|
import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
|
|
3
|
-
import { recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, } from "../git/workspace.js";
|
|
3
|
+
import { checkoutDetachedSnapshot, recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, } from "../git/workspace.js";
|
|
4
4
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
5
|
-
import {
|
|
5
|
+
import { matchingPrivateRootObservation, privateStateSeatAttempt, sameSpeculativeWorktreeInput, } from "./run.js";
|
|
6
6
|
import { contractState } from "../core/facts/observation.js";
|
|
7
7
|
import { decideDeliver } from "../core/verbs/deliver.js";
|
|
8
8
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
9
9
|
import { admitted } from "./outcome.js";
|
|
10
10
|
import { completeCandidate } from "./completion.js";
|
|
11
11
|
import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
|
|
12
|
-
import { timestamp } from "./operations.js";
|
|
12
|
+
import { attemptDecisionWithSeatClose, timestamp } from "./operations.js";
|
|
13
|
+
export { decodeMaterializedConflict } from "./result-codec.js";
|
|
13
14
|
const DELIVER_CONFLICT_RECOVERY = Object.freeze({
|
|
14
|
-
materialize: "deliver --materialize-conflict",
|
|
15
|
+
materialize: "deliver --materialize-conflict --include-dirty",
|
|
15
16
|
continue: "deliver --include-dirty",
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
+
async function captureAuthorizedDeliveryTender(repository, stage, includeDirty) {
|
|
18
19
|
const { contractId, coordinates } = stage;
|
|
19
20
|
const appointed = coordinates.workspace === "worktree"
|
|
20
21
|
? stage.appointment === undefined
|
|
@@ -29,10 +30,17 @@ export async function prepareDelivery(repository, stage, input) {
|
|
|
29
30
|
});
|
|
30
31
|
if (tender.kind === "refused")
|
|
31
32
|
return tender;
|
|
32
|
-
if (((tender.data.dirty || tender.data.mergeHead !== undefined) &&
|
|
33
|
+
if (((tender.data.dirty || tender.data.mergeHead !== undefined) && includeDirty !== true) ||
|
|
33
34
|
tender.data.changes.submodules.length > 0) {
|
|
34
35
|
return { kind: "refused", refusal: await dirtyTenderRefusal(repository, contractId, tender.data) };
|
|
35
36
|
}
|
|
37
|
+
return { kind: "prepared", data: tender.data };
|
|
38
|
+
}
|
|
39
|
+
async function prepareDeliveryWithWorktree(repository, stage, input) {
|
|
40
|
+
const { contractId, coordinates } = stage;
|
|
41
|
+
const tender = await captureAuthorizedDeliveryTender(repository, stage, input.includeDirty);
|
|
42
|
+
if (tender.kind === "refused")
|
|
43
|
+
return tender;
|
|
36
44
|
const commit = await prepareDeliveryCommitMetadata(repository, {
|
|
37
45
|
contractId,
|
|
38
46
|
title: input.title,
|
|
@@ -46,6 +54,7 @@ export async function prepareDelivery(repository, stage, input) {
|
|
|
46
54
|
const integration = await planIntegration(repository, { contractId, coordinates }, { ...tender.data, head: tenderSnapshot }, requireBranchesToBeUpToDate);
|
|
47
55
|
if (integration.kind === "refused")
|
|
48
56
|
return integration;
|
|
57
|
+
const changeId = await worktreeChangeId(repository, { contractId, coordinates }, tender.data);
|
|
49
58
|
const integrationSnapshot = coordinates.target === undefined
|
|
50
59
|
? tenderSnapshot
|
|
51
60
|
: await materializeIntegrationSnapshot(repository, integration.data.tree, integration.data.predecessor, commit);
|
|
@@ -56,53 +65,96 @@ export async function prepareDelivery(repository, stage, input) {
|
|
|
56
65
|
integration: {
|
|
57
66
|
predecessor: integration.data.predecessor,
|
|
58
67
|
snapshot: integrationSnapshot,
|
|
59
|
-
changeId
|
|
68
|
+
changeId,
|
|
60
69
|
},
|
|
61
70
|
method: "squash",
|
|
62
71
|
policy: { requireBranchesToBeUpToDate },
|
|
63
72
|
},
|
|
73
|
+
worktree: {
|
|
74
|
+
tree: tender.data.tree,
|
|
75
|
+
head: tender.data.head,
|
|
76
|
+
...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
|
|
77
|
+
dirty: tender.data.dirty,
|
|
78
|
+
changeId,
|
|
79
|
+
},
|
|
64
80
|
};
|
|
65
81
|
}
|
|
66
|
-
async function
|
|
67
|
-
|
|
82
|
+
export async function prepareDelivery(repository, stage, input) {
|
|
83
|
+
const prepared = await prepareDeliveryWithWorktree(repository, stage, input);
|
|
84
|
+
return prepared.kind === "refused" ? prepared : { kind: "prepared", data: prepared.data };
|
|
85
|
+
}
|
|
86
|
+
function deliveryPreparationInput(input, derivation) {
|
|
87
|
+
return {
|
|
88
|
+
title: derivation.title,
|
|
89
|
+
document: derivation.bytes,
|
|
90
|
+
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
91
|
+
...(input.message === undefined ? {} : { message: input.message }),
|
|
92
|
+
requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
|
|
93
|
+
includeDirty: input.includeDirty,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function recaptureDeliveryWorktree(input, state) {
|
|
97
|
+
const tender = await captureAuthorizedDeliveryTender(input.scope, { contractId: state.id, coordinates: state.coordinates }, input.includeDirty);
|
|
98
|
+
if (tender.kind === "refused")
|
|
99
|
+
return undefined;
|
|
100
|
+
return {
|
|
101
|
+
tree: tender.data.tree,
|
|
102
|
+
head: tender.data.head,
|
|
103
|
+
...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
|
|
104
|
+
dirty: tender.data.dirty,
|
|
105
|
+
changeId: await worktreeChangeId(input.scope, { contractId: state.id, coordinates: state.coordinates }, tender.data),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function mechanicalDeliveryPreparation(input, state, derivation) {
|
|
109
|
+
const prepared = await prepareDeliveryWithWorktree(input.scope, { contractId: state.id, coordinates: state.coordinates }, deliveryPreparationInput(input, derivation));
|
|
110
|
+
if (prepared.kind === "refused") {
|
|
111
|
+
return { kind: "refused", document: derivation.document, refusal: prepared.refusal };
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
kind: "prepared",
|
|
115
|
+
document: derivation.document,
|
|
116
|
+
data: prepared.data,
|
|
117
|
+
worktree: prepared.worktree,
|
|
118
|
+
};
|
|
68
119
|
}
|
|
69
|
-
async function
|
|
70
|
-
const
|
|
71
|
-
const state = contractState(
|
|
120
|
+
async function speculateDelivery(input) {
|
|
121
|
+
const observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
122
|
+
const state = contractState(observation.decision, input.contractId);
|
|
72
123
|
const derivation = state === null ? undefined : input.deriveDocument(state);
|
|
73
|
-
let preparation;
|
|
74
124
|
if (state === null || derivation === undefined) {
|
|
75
|
-
preparation
|
|
125
|
+
return { observation, state, preparation: { kind: "unavailable" } };
|
|
76
126
|
}
|
|
77
|
-
|
|
78
|
-
|
|
127
|
+
if (derivation.verification.kind === "refused") {
|
|
128
|
+
return {
|
|
129
|
+
observation,
|
|
130
|
+
state,
|
|
131
|
+
derivation,
|
|
132
|
+
preparation: { kind: "refused", document: derivation.document, refusal: derivation.verification.refusal },
|
|
133
|
+
};
|
|
79
134
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
: { kind: "refused", refusal: materialization };
|
|
97
|
-
preparation =
|
|
98
|
-
prepared.kind === "refused"
|
|
99
|
-
? { kind: "refused", document: derivation.document, refusal: prepared.refusal }
|
|
100
|
-
: {
|
|
101
|
-
kind: "prepared",
|
|
102
|
-
document: derivation.document,
|
|
103
|
-
data: prepared.data,
|
|
104
|
-
};
|
|
135
|
+
if (input.materializeConflict === true && state.terminal === null)
|
|
136
|
+
return { observation, state, derivation };
|
|
137
|
+
const prepared = await mechanicalDeliveryPreparation(input, state, derivation);
|
|
138
|
+
return prepared.kind === "prepared"
|
|
139
|
+
? { observation, state, derivation, preparation: prepared, worktree: prepared.worktree }
|
|
140
|
+
: { observation, state, derivation, preparation: prepared };
|
|
141
|
+
}
|
|
142
|
+
async function resolveDeliveryPreparation(input, speculated) {
|
|
143
|
+
if (speculated.preparation !== undefined)
|
|
144
|
+
return speculated.preparation;
|
|
145
|
+
if (speculated.state === null || speculated.derivation === undefined)
|
|
146
|
+
return { kind: "unavailable" };
|
|
147
|
+
const materialization = await materializationMergeStateRefusal(input);
|
|
148
|
+
if (materialization !== undefined) {
|
|
149
|
+
return { kind: "refused", document: speculated.derivation.document, refusal: materialization };
|
|
105
150
|
}
|
|
151
|
+
const prepared = await mechanicalDeliveryPreparation(input, speculated.state, speculated.derivation);
|
|
152
|
+
return prepared.kind === "prepared"
|
|
153
|
+
? { kind: "prepared", document: prepared.document, data: prepared.data }
|
|
154
|
+
: prepared;
|
|
155
|
+
}
|
|
156
|
+
async function decideAndAdmitDelivery(input, attempt, seat, observation, speculated) {
|
|
157
|
+
const preparation = await resolveDeliveryPreparation(input, speculated);
|
|
106
158
|
const decision = decideDeliver({
|
|
107
159
|
input: {
|
|
108
160
|
contractId: input.contractId,
|
|
@@ -111,7 +163,7 @@ async function deliverAttemptInPrivateStateSeat(input, attempt, seat) {
|
|
|
111
163
|
preparation,
|
|
112
164
|
},
|
|
113
165
|
attempt,
|
|
114
|
-
observation:
|
|
166
|
+
observation: observation.decision,
|
|
115
167
|
});
|
|
116
168
|
if (decision.kind === "refused")
|
|
117
169
|
return { kind: "refused", refusal: decision.refusal };
|
|
@@ -121,23 +173,36 @@ async function deliverAttemptInPrivateStateSeat(input, attempt, seat) {
|
|
|
121
173
|
channel: input.channel,
|
|
122
174
|
repository: input.scope,
|
|
123
175
|
seat,
|
|
124
|
-
decisionObservation,
|
|
176
|
+
decisionObservation: observation,
|
|
125
177
|
attempt,
|
|
126
178
|
offer: decision.offer,
|
|
127
179
|
primaryContract: input.contractId,
|
|
128
180
|
});
|
|
129
|
-
if (admission.kind
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
181
|
+
if (admission.kind !== "accepted")
|
|
182
|
+
return admission;
|
|
183
|
+
if (speculated.derivation === undefined)
|
|
184
|
+
throw new Error("accepted delivery is missing its document derivation");
|
|
185
|
+
return {
|
|
186
|
+
...admission,
|
|
187
|
+
value: { delivery: preparation.data, derivation: speculated.derivation },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
async function deliverAttemptInPrivateStateSeat(input, attempt, seat, speculated) {
|
|
191
|
+
const observation = await matchingPrivateRootObservation(input.scope, input.channel, input.contractId, speculated.observation, async (fresh) => {
|
|
192
|
+
if (speculated.worktree === undefined)
|
|
193
|
+
return true;
|
|
194
|
+
const state = contractState(fresh.decision, input.contractId);
|
|
195
|
+
if (state === null)
|
|
196
|
+
return false;
|
|
197
|
+
return sameSpeculativeWorktreeInput(speculated.worktree, await recaptureDeliveryWorktree(input, state));
|
|
198
|
+
});
|
|
199
|
+
return "kind" in observation
|
|
200
|
+
? observation
|
|
201
|
+
: await decideAndAdmitDelivery(input, attempt, seat, observation, speculated);
|
|
202
|
+
}
|
|
203
|
+
async function deliverAttempt(input, attempt) {
|
|
204
|
+
const speculated = await speculateDelivery(input);
|
|
205
|
+
return await privateStateSeatAttempt(input.scope, async (seat) => await deliverAttemptInPrivateStateSeat(input, attempt, seat, speculated), attemptDecisionWithSeatClose);
|
|
141
206
|
}
|
|
142
207
|
async function completeDelivery(input, first) {
|
|
143
208
|
const derivation = first.value.derivation;
|
|
@@ -246,14 +311,28 @@ async function materializeDeliverConflict(input, refusal) {
|
|
|
246
311
|
});
|
|
247
312
|
if (tender.kind === "refused")
|
|
248
313
|
return tender;
|
|
249
|
-
if (tender.data.
|
|
314
|
+
if (tender.data.changes.submodules.length > 0 || (tender.data.dirty && input.includeDirty !== true)) {
|
|
250
315
|
return { kind: "refused", refusal: await dirtyTenderRefusal(input.scope, input.contractId, tender.data) };
|
|
251
316
|
}
|
|
317
|
+
let handoffHead = tender.data.head;
|
|
318
|
+
if (tender.data.dirty) {
|
|
319
|
+
const derivation = input.deriveDocument(appointed.state);
|
|
320
|
+
const commit = await prepareDeliveryCommitMetadata(input.scope, {
|
|
321
|
+
contractId: input.contractId,
|
|
322
|
+
title: derivation.title,
|
|
323
|
+
document: derivation.bytes,
|
|
324
|
+
at: tender.data.at,
|
|
325
|
+
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
326
|
+
...(input.message === undefined ? {} : { message: input.message }),
|
|
327
|
+
});
|
|
328
|
+
handoffHead = await materializeTenderSnapshot(input.scope, tender.data, commit);
|
|
329
|
+
await checkoutDetachedSnapshot(input.scope, workspace.path, handoffHead);
|
|
330
|
+
}
|
|
252
331
|
await recordConflictHandoff(input.scope, {
|
|
253
332
|
contractId: input.contractId,
|
|
254
333
|
place: appointment.place,
|
|
255
334
|
workspace: workspace.path,
|
|
256
|
-
head:
|
|
335
|
+
head: handoffHead,
|
|
257
336
|
mergeHead: refusal.targetHead,
|
|
258
337
|
});
|
|
259
338
|
await materializeJudgedConflict(input.scope, workspace.path, refusal.targetHead);
|
|
@@ -69,7 +69,6 @@ export async function verifyDelivery(input) {
|
|
|
69
69
|
repository: input.repository,
|
|
70
70
|
candidate: snapshot,
|
|
71
71
|
declarations: input.verification.declarations,
|
|
72
|
-
environment: input.environment,
|
|
73
72
|
materializeScratchCandidate,
|
|
74
73
|
projectSettings,
|
|
75
74
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
@@ -14,12 +14,13 @@ import type { IntegrationPreparationRefusal } from "../git/integration.js";
|
|
|
14
14
|
import type { TargetPlacementRefusal } from "../git/target-placement.js";
|
|
15
15
|
import type { VerificationCleanupFailure, VerificationRuntimeStop, VerificationResult } from "./intent.js";
|
|
16
16
|
import type { VerificationDeclarationPreparation, VerificationDeclarationRefusal } from "../verification/declaration.js";
|
|
17
|
+
import { type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
17
18
|
import type { PlacementProtocolResult } from "./placement.js";
|
|
18
19
|
import type { AcceptedAdmission, DecidedOfferResult } from "./attempt.js";
|
|
19
20
|
import type { AcceptedProtocolStep, IntentOutcome as ProtocolIntentOutcome } from "./outcome.js";
|
|
20
21
|
import type { ProtocolResult, ProtocolTerminal } from "./run.js";
|
|
21
22
|
import { type ContractDocumentProjection } from "./read/documents.js";
|
|
22
|
-
import { type ContractBoard, type ContractObservation } from "./read/status.js";
|
|
23
|
+
import { type ContractBoard, type ContractCatalogue, type ContractObservation } from "./read/status.js";
|
|
23
24
|
export type MergeStatePresentRefusal = Readonly<{
|
|
24
25
|
kind: "merge-state-present";
|
|
25
26
|
contractId: ContractId;
|
|
@@ -40,7 +41,7 @@ export type DeliverConflictRefusal = Readonly<{
|
|
|
40
41
|
targetHead: SnapshotId;
|
|
41
42
|
conflictPaths: readonly string[];
|
|
42
43
|
recovery: Readonly<{
|
|
43
|
-
materialize: "deliver --materialize-conflict";
|
|
44
|
+
materialize: "deliver --materialize-conflict --include-dirty";
|
|
44
45
|
continue: "deliver --include-dirty";
|
|
45
46
|
}>;
|
|
46
47
|
}>;
|
|
@@ -108,6 +109,7 @@ export type AttemptDecision<Value, Refusal = IntentRefusal> = (AcceptedAdmission
|
|
|
108
109
|
kind: "publication-failed";
|
|
109
110
|
}>;
|
|
110
111
|
export declare function timestamp(): string;
|
|
112
|
+
export declare function attemptDecisionWithSeatClose<Value, Refusal = IntentRefusal>(outcome: PrivateStateSeatOutcome<AttemptDecision<Value, Refusal>>): AttemptDecision<Value, Refusal>;
|
|
111
113
|
export declare function mergeAdmissions(current: AcceptedProtocolStep, next: AcceptedProtocolStep): AcceptedProtocolStep;
|
|
112
114
|
export declare function stepStop<Refusal>(result: ProtocolResult<Refusal>): StepStop<Refusal> | undefined;
|
|
113
115
|
export declare function unpackVerificationOutcome(verification: VerificationResult): Readonly<{
|
|
@@ -131,6 +133,11 @@ export declare function contractsOperation(input: Readonly<{
|
|
|
131
133
|
scope: RepositoryScope;
|
|
132
134
|
channel: GitDecodeChannel;
|
|
133
135
|
}>): Promise<ContractBoard>;
|
|
136
|
+
export declare function contractCatalogueOperation(input: Readonly<{
|
|
137
|
+
scope: RepositoryScope;
|
|
138
|
+
channel: GitDecodeChannel;
|
|
139
|
+
limit?: number;
|
|
140
|
+
}>): Promise<ContractCatalogue>;
|
|
134
141
|
export declare function contractObservationOperation(input: Readonly<{
|
|
135
142
|
scope: RepositoryScope;
|
|
136
143
|
channel: GitDecodeChannel;
|
|
@@ -2,18 +2,29 @@ import { readDeliveryDiff } from "../git/integration.js";
|
|
|
2
2
|
import { currentBranch, observeContractAt } from "../git/observe.js";
|
|
3
3
|
import { repositoryAt } from "../git/repository.js";
|
|
4
4
|
import { withGitReadObservation } from "../git/read-observation.js";
|
|
5
|
+
import { appendPrivateStateSeatClose, concatenatePrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
|
|
5
6
|
import { readDocuments } from "./read/documents.js";
|
|
6
|
-
import { readContractBoard, readContractObservationAt, } from "./read/status.js";
|
|
7
|
+
import { readContractBoard, readContractCatalogue, readContractObservationAt, } from "./read/status.js";
|
|
8
|
+
import { boundedListLimit } from "../bounded-list.js";
|
|
7
9
|
export function timestamp() {
|
|
8
10
|
return new Date().toISOString();
|
|
9
11
|
}
|
|
12
|
+
export function attemptDecisionWithSeatClose(outcome) {
|
|
13
|
+
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
14
|
+
if (value.kind !== "accepted")
|
|
15
|
+
throw new Error(closeLag.diagnostic);
|
|
16
|
+
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
10
19
|
export function mergeAdmissions(current, next) {
|
|
11
20
|
const effects = [...(current.physical?.effects ?? []), ...(next.physical?.effects ?? [])];
|
|
12
21
|
const lag = [...(current.physical?.lag ?? []), ...(next.physical?.lag ?? [])];
|
|
22
|
+
const seatClose = concatenatePrivateStateSeatClose(current.seatClose, next.seatClose);
|
|
13
23
|
return {
|
|
14
24
|
...next,
|
|
15
25
|
facts: [...current.facts, ...next.facts],
|
|
16
26
|
...(effects.length === 0 && lag.length === 0 ? {} : { physical: { effects, lag } }),
|
|
27
|
+
...(seatClose === undefined ? {} : { seatClose }),
|
|
17
28
|
};
|
|
18
29
|
}
|
|
19
30
|
export function stepStop(result) {
|
|
@@ -56,6 +67,10 @@ export async function currentBranchOperation(input) {
|
|
|
56
67
|
export async function contractsOperation(input) {
|
|
57
68
|
return withGitReadObservation(input.scope, input.channel, (observation) => readContractBoard(observation));
|
|
58
69
|
}
|
|
70
|
+
export async function contractCatalogueOperation(input) {
|
|
71
|
+
const limit = boundedListLimit(input.limit);
|
|
72
|
+
return withGitReadObservation(input.scope, input.channel, (observation) => readContractCatalogue(observation, limit));
|
|
73
|
+
}
|
|
59
74
|
export async function contractObservationOperation(input) {
|
|
60
75
|
return await readContractObservationAt(input.scope, input.channel, input.contractId);
|
|
61
76
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContractHead, ContractState, JournalEntry } from "../core/facts/types.js";
|
|
2
2
|
import type { WorktreeLeak } from "../git/scratch.js";
|
|
3
3
|
import type { ReconcileResult } from "../git/reconcile.js";
|
|
4
|
+
import { type PrivateStateSeatCloseLag, type PrivateStateSeatOutcome } from "../git/private-state-seat.js";
|
|
4
5
|
import type { AcceptedAdmission } from "./attempt.js";
|
|
5
6
|
import type { VerificationCleanupFailure } from "./intent.js";
|
|
6
7
|
import type { ProtocolResult, ProtocolTerminal } from "./run.js";
|
|
@@ -10,6 +11,7 @@ export type AcceptedProtocolStep = AcceptedAdmission & Readonly<{
|
|
|
10
11
|
export type AcceptedObligations = Readonly<{
|
|
11
12
|
cleanup?: VerificationCleanupFailure;
|
|
12
13
|
leak?: WorktreeLeak;
|
|
14
|
+
seatClose?: readonly PrivateStateSeatCloseLag[];
|
|
13
15
|
}>;
|
|
14
16
|
export type IntentOutcome<Value, Refusal = never> = Readonly<{
|
|
15
17
|
kind: "accepted";
|
|
@@ -27,3 +29,4 @@ export type IntentOutcome<Value, Refusal = never> = Readonly<{
|
|
|
27
29
|
export declare function accepted<Value, Refusal = never>(state: ContractState, facts: readonly JournalEntry[], value: Value, physical?: ReconcileResult, obligations?: AcceptedObligations): IntentOutcome<Value, Refusal>;
|
|
28
30
|
export declare function admitted<Value, Refusal = never>(admission: AcceptedProtocolStep, value: Value): IntentOutcome<Value, Refusal>;
|
|
29
31
|
export declare function complete<Value, Refusal>(result: ProtocolResult<Refusal>, value: Value): IntentOutcome<Value, Refusal>;
|
|
32
|
+
export declare function intentOutcomeWithSeatClose<Value, Refusal>(outcome: PrivateStateSeatOutcome<IntentOutcome<Value, Refusal>>): IntentOutcome<Value, Refusal>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, } from "../git/private-state-seat.js";
|
|
1
2
|
export function accepted(state, facts, value, physical, obligations) {
|
|
2
3
|
if (state.head === null)
|
|
3
4
|
throw new Error("accepted contract is missing its journal head");
|
|
@@ -9,10 +10,18 @@ export function accepted(state, facts, value, physical, obligations) {
|
|
|
9
10
|
...(physical === undefined ? {} : { physical }),
|
|
10
11
|
...(obligations?.cleanup === undefined ? {} : { cleanup: obligations.cleanup }),
|
|
11
12
|
...(obligations?.leak === undefined ? {} : { leak: obligations.leak }),
|
|
13
|
+
...seatCloseObligations(obligations?.seatClose),
|
|
12
14
|
};
|
|
13
15
|
}
|
|
16
|
+
function seatCloseObligations(seatClose) {
|
|
17
|
+
return seatClose === undefined || seatClose.length === 0 ? {} : { seatClose };
|
|
18
|
+
}
|
|
19
|
+
function admissionObligations(admission) {
|
|
20
|
+
const seatClose = admission.seatClose;
|
|
21
|
+
return seatClose === undefined || seatClose.length === 0 ? undefined : { seatClose };
|
|
22
|
+
}
|
|
14
23
|
export function admitted(admission, value) {
|
|
15
|
-
return accepted(admission.state, admission.facts, value, admission.physical);
|
|
24
|
+
return accepted(admission.state, admission.facts, value, admission.physical, admissionObligations(admission));
|
|
16
25
|
}
|
|
17
26
|
export function complete(result, value) {
|
|
18
27
|
if (result.kind === "refused")
|
|
@@ -21,3 +30,10 @@ export function complete(result, value) {
|
|
|
21
30
|
return { kind: "retry", reason: result };
|
|
22
31
|
return admitted(result, value);
|
|
23
32
|
}
|
|
33
|
+
export function intentOutcomeWithSeatClose(outcome) {
|
|
34
|
+
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
35
|
+
if (value.kind !== "accepted")
|
|
36
|
+
throw new Error(closeLag.diagnostic);
|
|
37
|
+
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -3,7 +3,7 @@ import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
|
3
3
|
import { contractState } from "../core/facts/observation.js";
|
|
4
4
|
import { decidePlacement } from "../core/verbs/placement.js";
|
|
5
5
|
import { observeGitForAdmissionAt } from "../git/observe.js";
|
|
6
|
-
import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
6
|
+
import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
|
|
7
7
|
import { reconcileEffectFailure } from "../git/reconcile.js";
|
|
8
8
|
import { GitPlumbingError } from "../git/process.js";
|
|
9
9
|
import { acquireTargetPlacementFence, followTargetPlacement, prepareTargetPlacement, observeTargetHead, observedTreeEqualsCandidate, } from "../git/target-placement.js";
|
|
@@ -21,9 +21,16 @@ function expectedOperationalDiagnostic(error) {
|
|
|
21
21
|
function expectedPlacementFailure(error) {
|
|
22
22
|
return { kind: "placement-failed", diagnostic: expectedOperationalDiagnostic(error) };
|
|
23
23
|
}
|
|
24
|
+
function placementResultWithSeatClose(outcome) {
|
|
25
|
+
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
26
|
+
if (value.kind !== "accepted")
|
|
27
|
+
throw new Error(closeLag.diagnostic);
|
|
28
|
+
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
24
31
|
async function runFencedPlacement(repository, input, protocol) {
|
|
25
32
|
let preparedPhysical;
|
|
26
|
-
const result = await withPrivateStatePublicationSeat(repository, async (seat) => {
|
|
33
|
+
const result = placementResultWithSeatClose(await withPrivateStatePublicationSeat(repository, async (seat) => {
|
|
27
34
|
for (let index = 0; index < protocol.attempts.length; index += 1) {
|
|
28
35
|
const prepared = await prepareProtocolAttempt(protocol, protocol.attempts[index]);
|
|
29
36
|
if (prepared.kind === "refused")
|
|
@@ -67,7 +74,7 @@ async function runFencedPlacement(repository, input, protocol) {
|
|
|
67
74
|
return result;
|
|
68
75
|
}
|
|
69
76
|
return { kind: "exhausted" };
|
|
70
|
-
});
|
|
77
|
+
}));
|
|
71
78
|
if (result.kind !== "accepted")
|
|
72
79
|
return result;
|
|
73
80
|
if (preparedPhysical === undefined) {
|
|
@@ -3,6 +3,7 @@ import type { GitRepository } from "../../git/process.js";
|
|
|
3
3
|
import type { GitDecodeChannel, GitReadObservation } from "../../git/read-observation.js";
|
|
4
4
|
import { type GateCurrent } from "../../core/facts/gate.js";
|
|
5
5
|
import type { ContractId, ContractState, DeliverData, JournalEntry, SnapshotId } from "../../core/facts/types.js";
|
|
6
|
+
import { type BoundedList } from "../../bounded-list.js";
|
|
6
7
|
export type ContractPhase = "waiting" | "bound" | "tendered" | "claimed" | "abandoned";
|
|
7
8
|
export type ContractDisposition = "active" | "terminal";
|
|
8
9
|
export type ContractGateCurrent = GateCurrent;
|
|
@@ -59,6 +60,11 @@ export type ContractBoard = Readonly<{
|
|
|
59
60
|
observedAt: string;
|
|
60
61
|
rows: readonly ContractRow[];
|
|
61
62
|
}>;
|
|
63
|
+
export type ContractCatalogue = Readonly<{
|
|
64
|
+
root: string;
|
|
65
|
+
state: SnapshotId | null;
|
|
66
|
+
observedAt: string;
|
|
67
|
+
}> & BoundedList<ContractRow>;
|
|
62
68
|
export type ContractObservation = Readonly<{
|
|
63
69
|
kind: "missing";
|
|
64
70
|
id: ContractId;
|
|
@@ -70,6 +76,8 @@ export declare function phaseAtFor(state: Pick<ContractState, "terminal" | "deli
|
|
|
70
76
|
export declare function lastJournalAtFor(entries: readonly Pick<JournalEntry, "at">[]): string;
|
|
71
77
|
/** Build the Contract board from one immutable git observation. */
|
|
72
78
|
export declare function readContractBoard(observation: GitReadObservation, include?: ContractId): Promise<ContractBoard>;
|
|
79
|
+
/** Observe a bounded recent active Contract catalogue from one immutable git observation. */
|
|
80
|
+
export declare function readContractCatalogue(observation: GitReadObservation, limit: number): Promise<ContractCatalogue>;
|
|
73
81
|
/** Observe one Contract and its target from one fresh ref epoch. */
|
|
74
82
|
export declare function readContractObservation(observation: GitReadObservation, id: ContractId): Promise<ContractObservation>;
|
|
75
83
|
/** Observe one Contract and its target from one fresh ref epoch. */
|
|
@@ -3,6 +3,7 @@ import { decodeContractDocument } from "../../body/decode.js";
|
|
|
3
3
|
import { observeTargetLag, observeWorkspace, worktreePath } from "../../git/workspace.js";
|
|
4
4
|
import { appointmentFor, readPlaceRegister } from "../../workspace-place.js";
|
|
5
5
|
import { gateReports } from "../../core/facts/gate.js";
|
|
6
|
+
import { projectBoundedList } from "../../bounded-list.js";
|
|
6
7
|
function titleFor(state) {
|
|
7
8
|
try {
|
|
8
9
|
return decodeContractDocument(state.terms.document.bytes).title;
|
|
@@ -149,6 +150,54 @@ export async function readContractBoard(observation, include) {
|
|
|
149
150
|
rows,
|
|
150
151
|
};
|
|
151
152
|
}
|
|
153
|
+
function compareRecentContracts(left, right) {
|
|
154
|
+
return (right.lastJournalAt.localeCompare(left.lastJournalAt) ||
|
|
155
|
+
Buffer.compare(Buffer.from(left.state.id), Buffer.from(right.state.id)));
|
|
156
|
+
}
|
|
157
|
+
function activeContractStates(contracts) {
|
|
158
|
+
return [...contracts.values()].flatMap((record) => record.state === null || record.state.terminal !== null
|
|
159
|
+
? []
|
|
160
|
+
: [
|
|
161
|
+
{
|
|
162
|
+
state: record.state,
|
|
163
|
+
bindAt: record.entries[0].at,
|
|
164
|
+
lastJournalAt: lastJournalAtFor(record.entries),
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
function reverseDependentsFromStates(id, states) {
|
|
169
|
+
return states
|
|
170
|
+
.filter(({ state }) => state.terms.after.includes(id))
|
|
171
|
+
.map(({ state }) => ({ contractId: state.id, phase: phaseFor(state) }))
|
|
172
|
+
.sort((left, right) => left.contractId.localeCompare(right.contractId));
|
|
173
|
+
}
|
|
174
|
+
/** Observe a bounded recent active Contract catalogue from one immutable git observation. */
|
|
175
|
+
export async function readContractCatalogue(observation, limit) {
|
|
176
|
+
const observedAt = new Date().toISOString();
|
|
177
|
+
const observed = await observeActiveContractWorld(observation);
|
|
178
|
+
const active = activeContractStates(observed.contracts);
|
|
179
|
+
const selected = projectBoundedList([...active].sort(compareRecentContracts), limit);
|
|
180
|
+
const afterIds = selected.rows.flatMap(({ state }) => state.terms.after);
|
|
181
|
+
const endpoints = await afterEndpointMap(observation, new Map(observed.eligibility), afterIds);
|
|
182
|
+
const register = await readPlaceRegister(observation.repository);
|
|
183
|
+
const rows = await Promise.all(selected.rows.map(async ({ state, bindAt, lastJournalAt }) => await rowFor({
|
|
184
|
+
repository: observation.repository,
|
|
185
|
+
state,
|
|
186
|
+
bindAt,
|
|
187
|
+
lastJournalAt,
|
|
188
|
+
targetObservation: await observeDeliveryTargetAt(observation, state),
|
|
189
|
+
register,
|
|
190
|
+
after: afterEdges(state, endpoints),
|
|
191
|
+
dependents: reverseDependentsFromStates(state.id, active),
|
|
192
|
+
})));
|
|
193
|
+
return {
|
|
194
|
+
root: observation.repository.primaryWorktree,
|
|
195
|
+
state: observed.snapshot,
|
|
196
|
+
observedAt,
|
|
197
|
+
rows,
|
|
198
|
+
hasMore: selected.hasMore,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
152
201
|
/** Observe one Contract and its target from one fresh ref epoch. */
|
|
153
202
|
export async function readContractObservation(observation, id) {
|
|
154
203
|
const observed = await observeContractsForAdmissionInObservationAt(observation, [id]);
|
|
@@ -2,12 +2,19 @@ import { contractState } from "../core/facts/observation.js";
|
|
|
2
2
|
import { decideReintegrate } from "../core/verbs/reintegrate.js";
|
|
3
3
|
import { materializeReintegrationSnapshot, persistedTender, planIntegration, } from "../git/integration.js";
|
|
4
4
|
import { observeContractsForAdmissionAt } from "../git/observe.js";
|
|
5
|
-
import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
5
|
+
import { appendPrivateStateSeatClose, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
|
|
6
6
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
7
7
|
import { timestamp } from "./operations.js";
|
|
8
8
|
import { runUnderTargetPlacementFence } from "./placement.js";
|
|
9
|
+
function reintegrationResultWithSeatClose(outcome) {
|
|
10
|
+
return mergePrivateStateSeatClose(outcome, (value, closeLag) => {
|
|
11
|
+
if (value.kind !== "accepted")
|
|
12
|
+
throw new Error(closeLag.diagnostic);
|
|
13
|
+
return { ...value, seatClose: appendPrivateStateSeatClose(value.seatClose, closeLag) };
|
|
14
|
+
});
|
|
15
|
+
}
|
|
9
16
|
async function runReintegration(input) {
|
|
10
|
-
return await withPrivateStatePublicationSeat(input.repository, async (seat) => {
|
|
17
|
+
return reintegrationResultWithSeatClose(await withPrivateStatePublicationSeat(input.repository, async (seat) => {
|
|
11
18
|
const attempts = mintAttempts({ entryCount: 1 });
|
|
12
19
|
for (let index = 0; index < attempts.length; index += 1) {
|
|
13
20
|
const attempt = attempts[index];
|
|
@@ -71,7 +78,7 @@ async function runReintegration(input) {
|
|
|
71
78
|
return { kind: "retry", reason: result };
|
|
72
79
|
}
|
|
73
80
|
return { kind: "retry", reason: { kind: "exhausted" } };
|
|
74
|
-
});
|
|
81
|
+
}));
|
|
75
82
|
}
|
|
76
83
|
export async function reintegrateOperation(input) {
|
|
77
84
|
return await runUnderTargetPlacementFence(input.repository, input.target, async () => await runReintegration(input));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AuditReport } from "./audit.js";
|
|
2
|
+
import type { CandidateCompletion, CompletionEvidence } from "./completion.js";
|
|
3
|
+
import type { IntegrationConflictMaterialized } from "./deliver.js";
|
|
4
|
+
import type { CurrentVerifiedAttestation, VerificationCleanupFailure, VerificationRuntimeStop } from "./intent.js";
|
|
5
|
+
import type { DeliverConflictRefusal, DeliveryPreparationRefusal, IntentRefusal, MergeStatePresentRefusal, PlacementStop, VerificationStop } from "./operations.js";
|
|
6
|
+
import type { ReviewValue } from "./review.js";
|
|
7
|
+
import type { ProtocolTerminal } from "./run.js";
|
|
8
|
+
export declare function decodeProtocolTerminal(value: unknown): ProtocolTerminal;
|
|
9
|
+
export declare function decodeMergeStatePresentRefusal(value: unknown): MergeStatePresentRefusal;
|
|
10
|
+
export declare function decodeDeliverConflictRefusal(value: unknown): DeliverConflictRefusal;
|
|
11
|
+
export declare function decodeDeliveryPreparationRefusal(value: unknown): DeliveryPreparationRefusal;
|
|
12
|
+
export declare function decodeIntentRefusal(value: unknown): IntentRefusal;
|
|
13
|
+
export declare function decodeVerificationRuntimeStop(value: unknown): VerificationRuntimeStop;
|
|
14
|
+
export declare function decodeVerificationStop(value: unknown): VerificationStop;
|
|
15
|
+
export declare function decodeVerificationReuse(value: unknown): CurrentVerifiedAttestation;
|
|
16
|
+
export declare function decodePlacementStop(value: unknown): PlacementStop;
|
|
17
|
+
export declare function decodeVerificationCleanupFailure(value: unknown): VerificationCleanupFailure;
|
|
18
|
+
export declare function decodeCandidateCompletion(value: unknown): CandidateCompletion;
|
|
19
|
+
export declare function decodeCompletionEvidence(value: unknown): CompletionEvidence;
|
|
20
|
+
export declare function decodeMaterializedConflict(value: unknown): IntegrationConflictMaterialized;
|
|
21
|
+
export declare function decodeAuditReport(value: unknown): AuditReport;
|
|
22
|
+
export declare function decodeReviewValue(value: unknown): ReviewValue;
|