@astrosheep/keiyaku 4.6.32 → 4.6.34
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 +18 -7
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/README.md +55 -97
- package/build/plugins/pi/keiyaku.ts +1 -142
- package/build/skills/keiyaku-akuma/SKILL.md +18 -11
- package/build/skills/keiyaku-babysit/SKILL.md +8 -6
- package/build/skills/keiyaku-debt/SKILL.md +2 -1
- package/build/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/src/akuma/akuma-instance.d.ts +11 -0
- package/build/src/akuma/akuma-instance.js +1 -2
- package/build/src/akuma/akuma-observe.d.ts +8 -0
- package/build/src/akuma/akuma-observe.js +81 -14
- package/build/src/akuma/akuma-owner.d.ts +1 -0
- package/build/src/akuma/akuma-owner.js +3 -5
- package/build/src/akuma/akuma-selection-execution.d.ts +82 -7
- package/build/src/akuma/akuma-selection-execution.js +26 -27
- package/build/src/akuma/akuma-wait.d.ts +155 -1
- package/build/src/akuma/akuma-wait.js +94 -34
- package/build/src/akuma/akuma.d.ts +17 -1
- package/build/src/akuma/akuma.js +37 -18
- package/build/src/akuma/body.js +13 -18
- package/build/src/akuma/call-initial-tell.d.ts +0 -1
- package/build/src/akuma/call-initial-tell.js +0 -1
- package/build/src/akuma/heart/activity-schema.d.ts +16 -0
- package/build/src/akuma/heart/activity-schema.js +7 -0
- package/build/src/akuma/heart/facts.d.ts +1 -0
- package/build/src/akuma/heart/facts.js +14 -0
- package/build/src/akuma/heart/index.d.ts +7 -1
- package/build/src/akuma/heart/index.js +35 -9
- package/build/src/akuma/heart/rows.d.ts +1 -0
- package/build/src/akuma/heart/rows.js +4 -0
- package/build/src/akuma/heart/timeline.js +4 -4
- package/build/src/akuma/lineage-cache.d.ts +7 -2
- package/build/src/akuma/lineage-cache.js +48 -24
- package/build/src/akuma/projection-read.d.ts +4 -2
- package/build/src/akuma/projection-read.js +25 -23
- package/build/src/akuma/projection.d.ts +94 -2
- package/build/src/akuma/projection.js +47 -47
- package/build/src/akuma/provider.d.ts +2 -2
- package/build/src/akuma/provider.js +27 -20
- package/build/src/akuma/providers/acp/core.js +2 -5
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
- package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
- package/build/src/akuma/publication.js +3 -2
- package/build/src/akuma/selection-observation.d.ts +645 -0
- package/build/src/akuma/selection-observation.js +22 -7
- package/build/src/akuma/status-projection.d.ts +14 -1
- package/build/src/akuma/status-projection.js +40 -2
- package/build/src/akuma/turn-drive.js +21 -15
- package/build/src/body/amend.js +5 -17
- package/build/src/body/decode.js +11 -1
- package/build/src/body/envelope.d.ts +5 -1
- package/build/src/body/envelope.js +4 -2
- package/build/src/body/render.js +4 -6
- package/build/src/bounded-list.d.ts +8 -0
- package/build/src/bounded-list.js +10 -0
- package/build/src/cli/commands/akuma-grammar.d.ts +5 -8
- package/build/src/cli/commands/akuma-grammar.js +52 -77
- package/build/src/cli/commands/akuma.d.ts +1 -2
- package/build/src/cli/commands/akuma.js +12 -61
- package/build/src/cli/commands/contract-grammar.d.ts +1 -0
- package/build/src/cli/commands/contract-grammar.js +39 -42
- package/build/src/cli/commands/contract-help.d.ts +6 -5
- package/build/src/cli/commands/contract-help.js +21 -13
- package/build/src/cli/commands/contract.d.ts +3 -3
- package/build/src/cli/commands/contract.js +13 -9
- package/build/src/cli/commands/debt-grammar.js +2 -4
- package/build/src/cli/parse.d.ts +4 -10
- package/build/src/cli/parse.js +2 -5
- package/build/src/cli/render/akuma-activity.d.ts +12 -34
- package/build/src/cli/render/akuma-activity.js +99 -180
- package/build/src/cli/render/akuma.d.ts +5 -11
- package/build/src/cli/render/akuma.js +22 -30
- package/build/src/cli/render/catalog.js +4 -6
- package/build/src/cli/render/contract-history.d.ts +1 -3
- package/build/src/cli/render/contract-history.js +70 -49
- package/build/src/cli/render/contract-observation.d.ts +2 -1
- package/build/src/cli/render/contract-observation.js +25 -1
- package/build/src/cli/render/contract-wait.d.ts +2 -2
- package/build/src/cli/render/contract-wait.js +21 -17
- package/build/src/cli/render/contract.js +12 -9
- package/build/src/cli/render/debt.js +1 -2
- package/build/src/cli/render/execution-progress.js +1 -3
- package/build/src/cli/render/kanshi-akuma.d.ts +4 -3
- package/build/src/cli/render/kanshi-akuma.js +27 -23
- package/build/src/cli/render/kanshi.js +45 -60
- package/build/src/cli/render/receipt.d.ts +1 -1
- package/build/src/cli/render/receipt.js +33 -28
- package/build/src/cli/render/reconcile.js +2 -5
- package/build/src/cli/render/refusal.js +3 -6
- package/build/src/cli/render/terminal.d.ts +2 -4
- package/build/src/cli/render/terminal.js +10 -17
- package/build/src/cli/render/verbs.d.ts +1 -0
- package/build/src/cli/render/verbs.js +39 -34
- package/build/src/cli/runtime.js +12 -32
- package/build/src/core/facts/codec.js +7 -2
- package/build/src/core/facts/eligibility.d.ts +4 -4
- package/build/src/core/facts/eligibility.js +11 -0
- package/build/src/core/facts/fold.js +9 -5
- package/build/src/core/facts/gate.d.ts +5 -1
- package/build/src/core/facts/gate.js +14 -10
- package/build/src/core/facts/types.d.ts +5 -1
- package/build/src/core/facts/types.js +7 -0
- package/build/src/core/subject.d.ts +4 -1
- package/build/src/core/subject.js +10 -2
- package/build/src/core/verbs/amend.d.ts +15 -4
- package/build/src/core/verbs/amend.js +19 -9
- package/build/src/debt/board.d.ts +2 -1
- package/build/src/debt/board.js +3 -3
- package/build/src/debt/catalog.js +2 -1
- package/build/src/debt/document.d.ts +1 -0
- package/build/src/debt/document.js +3 -0
- package/build/src/debt/index.d.ts +2 -2
- package/build/src/debt/index.js +9 -14
- package/build/src/debt/input.d.ts +2 -1
- package/build/src/debt/input.js +6 -4
- package/build/src/debt/operations.d.ts +2 -1
- package/build/src/dispatch/index.d.ts +0 -17
- package/build/src/dispatch/index.js +1 -10
- package/build/src/git/identity.js +16 -45
- package/build/src/git/nuke.js +13 -23
- package/build/src/git/observe.d.ts +7 -3
- package/build/src/git/observe.js +29 -26
- package/build/src/git/process.js +11 -18
- package/build/src/git/read-observation.d.ts +5 -4
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -1
- package/build/src/git/scratch.js +2 -14
- package/build/src/git/terminal-reconcile.js +1 -13
- package/build/src/history.d.ts +26 -0
- package/build/src/history.js +43 -0
- package/build/src/index.d.ts +6 -3
- package/build/src/kanshi/counts.d.ts +15 -1
- package/build/src/kanshi/counts.js +14 -3
- package/build/src/kanshi/index.d.ts +3 -4
- package/build/src/kanshi/index.js +2 -3
- package/build/src/kanshi/read.d.ts +21 -0
- package/build/src/kanshi/read.js +7 -3
- package/build/src/kanshi/report.d.ts +94 -0
- package/build/src/library/address.d.ts +12 -5
- package/build/src/library/address.js +18 -32
- package/build/src/library/akuma-creation.d.ts +39 -0
- package/build/src/library/akuma-creation.js +3 -9
- package/build/src/library/akumas.d.ts +5 -1
- package/build/src/library/akumas.js +11 -5
- package/build/src/library/continuation.d.ts +10 -0
- package/build/src/library/contract-composition.js +10 -10
- package/build/src/library/contract-creation.js +12 -13
- package/build/src/library/contract-outcomes.d.ts +72 -1
- package/build/src/library/contract-outcomes.js +1 -0
- package/build/src/library/contract-types.d.ts +233 -25
- package/build/src/library/contract-types.js +32 -12
- package/build/src/library/contract-wait.d.ts +212 -0
- package/build/src/library/contract-wait.js +65 -49
- package/build/src/library/delivery.d.ts +25 -0
- package/build/src/library/input.d.ts +8 -26
- package/build/src/library/input.js +17 -12
- package/build/src/library/kei.js +167 -90
- package/build/src/library/keiyaku-attribution.d.ts +1 -1
- package/build/src/library/keiyaku-attribution.js +3 -1
- package/build/src/library/keiyaku-classify.js +8 -4
- package/build/src/library/keiyaku-debt.d.ts +8 -7
- package/build/src/library/keiyaku-debt.js +1 -2
- package/build/src/library/keiyaku-identity.d.ts +4 -3
- package/build/src/library/keiyaku-identity.js +35 -7
- package/build/src/library/keiyaku-verbs.d.ts +974 -1409
- package/build/src/library/keiyaku-verbs.js +154 -161
- package/build/src/library/keiyaku-wait.d.ts +753 -0
- package/build/src/library/keiyaku-wait.js +230 -0
- package/build/src/library/keiyaku.d.ts +3110 -29
- package/build/src/library/keiyaku.js +342 -438
- package/build/src/library/model-tools.d.ts +754 -0
- package/build/src/library/model-tools.js +362 -0
- package/build/src/library/outcome.js +5 -6
- package/build/src/library/refusal.d.ts +25 -1
- package/build/src/library/refusal.js +4 -5
- package/build/src/library/selection.d.ts +18 -5
- package/build/src/library/selection.js +11 -5
- package/build/src/mcp/adapter.d.ts +0 -6
- package/build/src/mcp/adapter.js +11 -160
- package/build/src/mcp/description.d.ts +2 -0
- package/build/src/mcp/description.js +2 -0
- package/build/src/mcp/help.d.ts +1 -1
- package/build/src/mcp/help.js +10 -7
- package/build/src/pi/index.d.ts +5 -0
- package/build/src/pi/index.js +99 -0
- package/build/src/pi/status.d.ts +12 -0
- package/build/src/pi/status.js +140 -0
- package/build/src/protocol/amend.d.ts +14 -3
- package/build/src/protocol/amend.js +113 -46
- package/build/src/protocol/bind.d.ts +1 -1
- package/build/src/protocol/bind.js +5 -16
- package/build/src/protocol/completion.d.ts +30 -0
- package/build/src/protocol/completion.js +8 -5
- package/build/src/protocol/deliver.js +7 -20
- package/build/src/protocol/delivery-preview.d.ts +5 -0
- package/build/src/protocol/execution-observation.d.ts +8 -0
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +4 -1
- package/build/src/protocol/operations.d.ts +56 -16
- package/build/src/protocol/operations.js +18 -32
- package/build/src/protocol/placement.js +7 -1
- package/build/src/protocol/progress.js +0 -6
- package/build/src/protocol/read/status.d.ts +52 -4
- package/build/src/protocol/read/status.js +26 -22
- package/build/src/protocol/reintegrate.js +2 -2
- package/build/src/protocol/result-leaves.d.ts +56 -8
- package/build/src/protocol/result-leaves.js +11 -2
- package/build/src/protocol/run.js +1 -4
- package/build/src/protocol/verify.d.ts +10 -0
- package/build/src/protocol/verify.js +1 -0
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/settle.js +19 -68
- package/package.json +7 -3
- package/plugins/paseo/plugin/index.server.ts +6 -2
- package/plugins/paseo/plugin/server/attach.ts +68 -48
- package/plugins/paseo/plugin/server/directory.ts +259 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +3 -32
- package/plugins/paseo/plugin/server/reopen.ts +52 -38
- package/plugins/pi/README.md +55 -97
- package/plugins/pi/keiyaku.ts +1 -142
- package/skills/keiyaku-akuma/SKILL.md +18 -11
- package/skills/keiyaku-babysit/SKILL.md +8 -6
- package/skills/keiyaku-debt/SKILL.md +2 -1
- package/skills/keiyaku-workflow/SKILL.md +2 -1
- package/build/plugins/pi/akuma-tools.ts +0 -283
- package/build/src/body/keys.d.ts +0 -4
- package/build/src/body/keys.js +0 -11
- package/build/src/kanshi/roster.d.ts +0 -2
- package/build/src/kanshi/roster.js +0 -2
- package/build/src/mcp/output.d.ts +0 -385
- package/build/src/mcp/output.js +0 -193
- package/plugins/pi/akuma-tools.ts +0 -283
|
@@ -1,12 +1,76 @@
|
|
|
1
|
-
import { extendContractsForAdmissionAt, observeContractsForAdmissionAt } from "../git/observe.js";
|
|
1
|
+
import { extendContractsForAdmissionAt, observeContractsForAdmissionAt, selectExplicitTarget, } from "../git/observe.js";
|
|
2
2
|
import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
|
|
3
3
|
import { contractState } from "../core/facts/observation.js";
|
|
4
|
+
import { sameTarget } from "../core/facts/types.js";
|
|
5
|
+
import { readRef } from "../git/repository.js";
|
|
6
|
+
import { resolveContractTarget } from "../git/target.js";
|
|
7
|
+
import { acquireTargetPlacementFence } from "../git/target-placement.js";
|
|
4
8
|
import { decideAmend } from "../core/verbs/amend.js";
|
|
5
9
|
import { VERIFIED, } from "../verification/declaration.js";
|
|
6
10
|
import { admitDecidedOffer, mintAttempts } from "./attempt.js";
|
|
7
11
|
import { admitted } from "./outcome.js";
|
|
8
12
|
import { protocolSeatClose } from "./run.js";
|
|
9
13
|
import { timestamp } from "./operations.js";
|
|
14
|
+
/** No target selection and no document derivation is one amendment that requests no change. */
|
|
15
|
+
function requestsEdit(input) {
|
|
16
|
+
return input.target !== undefined || input.deriveAmendment !== undefined;
|
|
17
|
+
}
|
|
18
|
+
/** Empty intent keeps the owner's existence and terminal judgment and admits nothing. */
|
|
19
|
+
async function unchangedAmend(input) {
|
|
20
|
+
const observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
21
|
+
const decision = decideAmend({
|
|
22
|
+
input: { contractId: input.contractId, at: timestamp() },
|
|
23
|
+
attempt: { entryUlids: [] },
|
|
24
|
+
observation: observation.decision,
|
|
25
|
+
});
|
|
26
|
+
return decision.kind === "offer" ? { kind: "unchanged" } : decision;
|
|
27
|
+
}
|
|
28
|
+
async function prepareAmendmentAt(input, selection, amendment, observation) {
|
|
29
|
+
const state = contractState(observation.decision, input.contractId);
|
|
30
|
+
observation = await extendPrerequisiteClosureAt(input.channel, observation, [
|
|
31
|
+
...new Set([...(state?.terms.after ?? []), ...amendment.terms.after]),
|
|
32
|
+
]);
|
|
33
|
+
let target;
|
|
34
|
+
let refusal;
|
|
35
|
+
if (selection?.kind === "contract") {
|
|
36
|
+
observation = await extendTargetClosureAt(input.channel, observation, selection.contractId);
|
|
37
|
+
const resolved = await resolveContractTarget(input.scope, selection.contractId);
|
|
38
|
+
if (resolved.kind === "refused")
|
|
39
|
+
refusal = resolved.refusal;
|
|
40
|
+
else
|
|
41
|
+
target = resolved.target;
|
|
42
|
+
}
|
|
43
|
+
else if (selection?.kind === "explicit") {
|
|
44
|
+
if ((await readRef(input.scope, selection.target)) === null)
|
|
45
|
+
refusal = { kind: "target-missing" };
|
|
46
|
+
else
|
|
47
|
+
target = selection.target;
|
|
48
|
+
}
|
|
49
|
+
if (sameTarget(state?.coordinates.target, target))
|
|
50
|
+
target = undefined;
|
|
51
|
+
const preparation = refusal !== undefined
|
|
52
|
+
? { kind: "refused", refusal }
|
|
53
|
+
: amendment.verification.kind === "prepared" || !amendment.terms.gates.includes(VERIFIED)
|
|
54
|
+
? { kind: "prepared", data: { ...amendment.terms, ...(target === undefined ? {} : { target }) } }
|
|
55
|
+
: { kind: "refused", refusal: amendment.verification.refusal };
|
|
56
|
+
return {
|
|
57
|
+
observation,
|
|
58
|
+
...(target === undefined ? {} : { target }),
|
|
59
|
+
preparation,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function extendTargetClosureAt(channel, observation, seed) {
|
|
63
|
+
let current = observation;
|
|
64
|
+
const visited = new Set();
|
|
65
|
+
let id = seed;
|
|
66
|
+
while (id !== undefined && !visited.has(id)) {
|
|
67
|
+
visited.add(id);
|
|
68
|
+
current = await extendContractsForAdmissionAt(channel, current, [id]);
|
|
69
|
+
const target = contractState(current.decision, id)?.coordinates.target;
|
|
70
|
+
id = typeof target === "object" ? target.contractId : undefined;
|
|
71
|
+
}
|
|
72
|
+
return current;
|
|
73
|
+
}
|
|
10
74
|
async function extendPrerequisiteClosureAt(channel, observation, seeds) {
|
|
11
75
|
let current = observation;
|
|
12
76
|
const visited = new Set();
|
|
@@ -27,6 +91,11 @@ async function extendPrerequisiteClosureAt(channel, observation, seeds) {
|
|
|
27
91
|
return current;
|
|
28
92
|
}
|
|
29
93
|
export async function amendOperation(input) {
|
|
94
|
+
if (!requestsEdit(input))
|
|
95
|
+
return await unchangedAmend(input);
|
|
96
|
+
const selection = input.target === undefined ? undefined : await selectExplicitTarget(input.scope, input.target);
|
|
97
|
+
if (selection === null)
|
|
98
|
+
return { kind: "refused", refusal: { kind: "invalid-target" } };
|
|
30
99
|
let source = input.source;
|
|
31
100
|
if (source === undefined) {
|
|
32
101
|
const initial = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
|
|
@@ -36,50 +105,48 @@ export async function amendOperation(input) {
|
|
|
36
105
|
const amendment = source === undefined || input.deriveAmendment === undefined
|
|
37
106
|
? undefined
|
|
38
107
|
: { source, ...input.deriveAmendment(source) };
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
return admitted(admission, amendment);
|
|
108
|
+
// A requested edit must carry observed terms; only a Contract that appeared after observation has none.
|
|
109
|
+
if (amendment === undefined)
|
|
110
|
+
throw new Error("requested amendment is missing its observed source terms");
|
|
111
|
+
const incoming = selection?.kind === "contract" ? await acquireTargetPlacementFence(input.scope, selection.contractId) : undefined;
|
|
112
|
+
try {
|
|
113
|
+
return protocolSeatClose(await withPrivateStatePublicationSeat(input.scope, async (seat) => {
|
|
114
|
+
const attempts = mintAttempts({ entryCount: 1 });
|
|
115
|
+
for (let index = 0; index < attempts.length; index += 1) {
|
|
116
|
+
const { observation, target, preparation } = await prepareAmendmentAt(input, selection, amendment, await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]));
|
|
117
|
+
const decision = decideAmend({
|
|
118
|
+
input: {
|
|
119
|
+
contractId: input.contractId,
|
|
120
|
+
at: timestamp(),
|
|
121
|
+
edit: {
|
|
122
|
+
source: amendment.source,
|
|
123
|
+
preparation,
|
|
124
|
+
...(selection?.kind === "contract" ? { targetContract: selection.contractId } : {}),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
attempt: attempts[index],
|
|
128
|
+
observation: observation.decision,
|
|
129
|
+
});
|
|
130
|
+
if (decision.kind !== "offer")
|
|
131
|
+
return decision;
|
|
132
|
+
const admission = await admitDecidedOffer({
|
|
133
|
+
...input,
|
|
134
|
+
seat,
|
|
135
|
+
observation,
|
|
136
|
+
attempt: attempts[index],
|
|
137
|
+
offer: decision.offer,
|
|
138
|
+
});
|
|
139
|
+
if (admission.kind === "accepted")
|
|
140
|
+
return admitted(admission, { ...amendment, ...(target === undefined ? {} : { target }) });
|
|
141
|
+
if (admission.kind === "publication-failed")
|
|
142
|
+
return { kind: "retry", reason: admission };
|
|
143
|
+
if (admission.kind === "collision" && index + 1 === attempts.length)
|
|
144
|
+
return { kind: "retry", reason: admission };
|
|
77
145
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}));
|
|
146
|
+
return { kind: "retry", reason: { kind: "exhausted" } };
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
incoming?.close();
|
|
151
|
+
}
|
|
85
152
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import type { BindData, ContractId } from "../core/facts/types.js";
|
|
3
3
|
import { type TargetWorkspaceRefusal } from "../git/target.js";
|
|
4
4
|
import { type BindRefusal } from "../core/verbs/bind.js";
|
|
5
5
|
import { type BindTargetSelection } from "../git/observe.js";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { contractId } from "../core/facts/types.js";
|
|
3
2
|
import { resolveContractTarget, targetRef, targetWorkspaceRefusalSchema, } from "../git/target.js";
|
|
4
3
|
import { acquireTargetPlacementFence } from "../git/target-placement.js";
|
|
5
4
|
import { decideBind } from "../core/verbs/bind.js";
|
|
6
5
|
import { gitObjectIdForSnapshot } from "../git/identity.js";
|
|
7
|
-
import {
|
|
6
|
+
import { selectExplicitTarget, observeBindCoordinates, } from "../git/observe.js";
|
|
8
7
|
import { VERIFIED, } from "../verification/declaration.js";
|
|
9
8
|
import { admitPreparedIntent } from "./intent.js";
|
|
10
9
|
import { complete } from "./outcome.js";
|
|
@@ -120,20 +119,10 @@ async function assembleBindInput(input, selection, seed, prepared) {
|
|
|
120
119
|
export async function bindOperation(input) {
|
|
121
120
|
let selection = input.targetSelection;
|
|
122
121
|
if (selection.kind === "explicit") {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
catch {
|
|
128
|
-
return { kind: "refused", refusal: { kind: "invalid-target" } };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
const normalized = await normalizeTargetBranch(input.scope, selection.target);
|
|
133
|
-
if (normalized === null)
|
|
134
|
-
return { kind: "refused", refusal: { kind: "invalid-target" } };
|
|
135
|
-
selection = { kind: "explicit", target: normalized };
|
|
136
|
-
}
|
|
122
|
+
const explicit = await selectExplicitTarget(input.scope, selection.target);
|
|
123
|
+
if (explicit === null)
|
|
124
|
+
return { kind: "refused", refusal: { kind: "invalid-target" } };
|
|
125
|
+
selection = explicit;
|
|
137
126
|
}
|
|
138
127
|
const at = new Date().toISOString();
|
|
139
128
|
const id = input.contractId;
|
|
@@ -17,6 +17,11 @@ export declare const requirementProblemSchema: z.ZodUnion<readonly [z.ZodReadonl
|
|
|
17
17
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
18
18
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
19
19
|
state: z.ZodLiteral<"stale">;
|
|
20
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
22
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
23
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
24
|
+
}, z.core.$strict>>>;
|
|
20
25
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
21
26
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
22
27
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -58,6 +63,11 @@ export declare const placementReasonSchema: z.ZodUnion<readonly [z.ZodReadonly<z
|
|
|
58
63
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
59
64
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
60
65
|
state: z.ZodLiteral<"stale">;
|
|
66
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
67
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
68
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
69
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
70
|
+
}, z.core.$strict>>>;
|
|
61
71
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
62
72
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
63
73
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -131,6 +141,11 @@ export declare const normalContinuationStopSchema: z.ZodUnion<readonly [z.ZodRea
|
|
|
131
141
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
132
142
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
133
143
|
state: z.ZodLiteral<"stale">;
|
|
144
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
146
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
147
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
148
|
+
}, z.core.$strict>>>;
|
|
134
149
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
135
150
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
136
151
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -164,6 +179,11 @@ export declare const placementStopSchema: z.ZodUnion<readonly [z.ZodReadonly<z.Z
|
|
|
164
179
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
165
180
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
166
181
|
state: z.ZodLiteral<"stale">;
|
|
182
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
183
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
184
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
185
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
186
|
+
}, z.core.$strict>>>;
|
|
167
187
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
168
188
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
169
189
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -287,6 +307,11 @@ export declare const normalPlacementSchema: z.ZodUnion<readonly [z.ZodReadonly<z
|
|
|
287
307
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
288
308
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
289
309
|
state: z.ZodLiteral<"stale">;
|
|
310
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
311
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
312
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
313
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
314
|
+
}, z.core.$strict>>>;
|
|
290
315
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
291
316
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
292
317
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -323,6 +348,11 @@ export declare const placementSchema: z.ZodUnion<readonly [z.ZodReadonly<z.ZodOb
|
|
|
323
348
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
324
349
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
325
350
|
state: z.ZodLiteral<"stale">;
|
|
351
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
352
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
353
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
354
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
355
|
+
}, z.core.$strict>>>;
|
|
326
356
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
327
357
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
328
358
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { targetName } from "../core/facts/types.js";
|
|
3
3
|
import { snapshotIdSchema, contractIdSchema } from "../git/identity.js";
|
|
4
|
-
import { requirementIdSchema, gateSchema } from "./result-leaves.js";
|
|
4
|
+
import { requirementIdSchema, gateSchema, snapshotChangeSchema } from "./result-leaves.js";
|
|
5
5
|
import { admitPlacement, observeTargetPlacement, observeIntegrationTargetMovement } from "./placement.js";
|
|
6
6
|
import { reintegrateOperation } from "./reintegrate.js";
|
|
7
7
|
import { contractCheckpoint, executionStop, isOperationalFailure, isOperationalStop, } from "./progress.js";
|
|
@@ -18,6 +18,7 @@ export const requirementProblemSchema = z.union([
|
|
|
18
18
|
.strictObject({
|
|
19
19
|
...requirementCoordinate,
|
|
20
20
|
state: z.literal("stale"),
|
|
21
|
+
reason: snapshotChangeSchema.exactOptional(),
|
|
21
22
|
previousContentId: z.string().min(1).exactOptional(),
|
|
22
23
|
currentContentId: z.string().min(1).exactOptional(),
|
|
23
24
|
})
|
|
@@ -47,10 +48,12 @@ export function unmetGateProblems(reports) {
|
|
|
47
48
|
state: "stale",
|
|
48
49
|
...(current.reason === undefined
|
|
49
50
|
? {}
|
|
50
|
-
:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
: current.reason.kind === "snapshot-changed"
|
|
52
|
+
? { reason: current.reason }
|
|
53
|
+
: {
|
|
54
|
+
previousContentId: current.reason.previousChange,
|
|
55
|
+
currentContentId: current.reason.currentChange,
|
|
56
|
+
}),
|
|
54
57
|
},
|
|
55
58
|
];
|
|
56
59
|
}));
|
|
@@ -59,7 +59,6 @@ export const materializedConflictSchema = z
|
|
|
59
59
|
})
|
|
60
60
|
.strict()
|
|
61
61
|
.readonly();
|
|
62
|
-
const DELIVER_CONFLICT_RECOVERY = conflictRecovery;
|
|
63
62
|
async function captureAuthorizedDeliveryTender(repository, stage, includeDirty) {
|
|
64
63
|
const { contractId, coordinates } = stage;
|
|
65
64
|
const appointed = coordinates.workspace === "worktree"
|
|
@@ -120,13 +119,7 @@ async function prepareDeliveryWithWorktree(repository, stage, input, captured) {
|
|
|
120
119
|
method: "squash",
|
|
121
120
|
policy: { requireBranchesToBeUpToDate },
|
|
122
121
|
},
|
|
123
|
-
worktree:
|
|
124
|
-
tree: tender.data.tree,
|
|
125
|
-
head: tender.data.head,
|
|
126
|
-
...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
|
|
127
|
-
dirty: tender.data.dirty,
|
|
128
|
-
changeId,
|
|
129
|
-
},
|
|
122
|
+
worktree: worktreeWitness(tender.data, changeId),
|
|
130
123
|
};
|
|
131
124
|
}
|
|
132
125
|
export async function prepareDelivery(repository, stage, input) {
|
|
@@ -146,13 +139,7 @@ async function recaptureDeliveryWorktree(input, state) {
|
|
|
146
139
|
const tender = await captureAuthorizedDeliveryTender(input.scope, { contractId: state.id, coordinates: state.coordinates }, input.includeDirty);
|
|
147
140
|
if (tender.kind === "refused")
|
|
148
141
|
return undefined;
|
|
149
|
-
return {
|
|
150
|
-
tree: tender.data.tree,
|
|
151
|
-
head: tender.data.head,
|
|
152
|
-
...(tender.data.mergeHead === undefined ? {} : { mergeHead: tender.data.mergeHead }),
|
|
153
|
-
dirty: tender.data.dirty,
|
|
154
|
-
changeId: await worktreeChangeId(input.scope, { coordinates: state.coordinates }, tender.data),
|
|
155
|
-
};
|
|
142
|
+
return worktreeWitness(tender.data, await worktreeChangeId(input.scope, { coordinates: state.coordinates }, tender.data));
|
|
156
143
|
}
|
|
157
144
|
async function mechanicalDeliveryPreparation(input, state, derivation, journal, captured) {
|
|
158
145
|
const prepared = await prepareDeliveryWithWorktree(input.scope, {
|
|
@@ -170,14 +157,14 @@ async function mechanicalDeliveryPreparation(input, state, derivation, journal,
|
|
|
170
157
|
worktree: prepared.worktree,
|
|
171
158
|
};
|
|
172
159
|
}
|
|
173
|
-
function
|
|
174
|
-
return
|
|
160
|
+
function worktreeWitness(tender, changeId) {
|
|
161
|
+
return {
|
|
175
162
|
tree: tender.tree,
|
|
176
163
|
head: tender.head,
|
|
177
164
|
...(tender.mergeHead === undefined ? {} : { mergeHead: tender.mergeHead }),
|
|
178
165
|
dirty: tender.dirty,
|
|
179
166
|
changeId,
|
|
180
|
-
}
|
|
167
|
+
};
|
|
181
168
|
}
|
|
182
169
|
/**
|
|
183
170
|
* Repeatable physical delivery work outside the publication seat: locate the appointed worktree from
|
|
@@ -195,7 +182,7 @@ async function prepareDeliveryArtifacts(input, observation, state) {
|
|
|
195
182
|
const captured = await captureAuthorizedDeliveryTender(input.scope, { contractId: state.id, coordinates: state.coordinates }, input.includeDirty);
|
|
196
183
|
if (captured.kind === "refused")
|
|
197
184
|
return { kind: "refused", refusal: captured.refusal };
|
|
198
|
-
const worktree = await
|
|
185
|
+
const worktree = worktreeWitness(captured.data, await worktreeChangeId(input.scope, { coordinates: state.coordinates }, captured.data));
|
|
199
186
|
if (reusesCurrentCandidate(input, state, worktree.changeId)) {
|
|
200
187
|
return { kind: "reuse", worktree };
|
|
201
188
|
}
|
|
@@ -477,7 +464,7 @@ async function materializeDeliverConflict(input, refusal) {
|
|
|
477
464
|
conflictPaths: refusal.conflictPaths,
|
|
478
465
|
workspace,
|
|
479
466
|
handoffBase: handoffHead,
|
|
480
|
-
recovery:
|
|
467
|
+
recovery: conflictRecovery,
|
|
481
468
|
};
|
|
482
469
|
}
|
|
483
470
|
async function finishDeliverRefusal(input, refusal) {
|
|
@@ -30,6 +30,11 @@ export declare const deliveryPreviewReportSchema: z.ZodUnion<readonly [z.ZodRead
|
|
|
30
30
|
requirement: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>;
|
|
31
31
|
}, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
|
|
32
32
|
state: z.ZodLiteral<"stale">;
|
|
33
|
+
reason: z.ZodExactOptional<z.ZodReadonly<z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<"snapshot-changed">;
|
|
35
|
+
previousSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
36
|
+
currentSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
37
|
+
}, z.core.$strict>>>;
|
|
33
38
|
previousContentId: z.ZodExactOptional<z.ZodString>;
|
|
34
39
|
currentContentId: z.ZodExactOptional<z.ZodString>;
|
|
35
40
|
gate: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -43,6 +43,14 @@ export declare const executionObservationSchema: z.ZodDiscriminatedUnion<[z.ZodR
|
|
|
43
43
|
gates: z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
44
44
|
requirements: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").RequirementId, string>>>>>>;
|
|
45
45
|
after: z.ZodReadonly<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>>>;
|
|
46
|
+
target: z.ZodExactOptional<z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodObject<{
|
|
47
|
+
kind: z.ZodLiteral<"contract">;
|
|
48
|
+
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
49
|
+
worktree: z.ZodReadonly<z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
identity: z.ZodString;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
}, z.core.$strict>>]>>;
|
|
46
54
|
}, z.core.$strict>>;
|
|
47
55
|
v: z.ZodLiteral<1>;
|
|
48
56
|
contract: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
|
|
@@ -136,7 +136,10 @@ async function verificationStep(input, execution, subject) {
|
|
|
136
136
|
/** Execute one declaration and record testimony only when its gate is selected. */
|
|
137
137
|
export async function verifyRequirement(input) {
|
|
138
138
|
const snapshot = input.snapshot;
|
|
139
|
-
const subject = dependencyKeySet([
|
|
139
|
+
const subject = dependencyKeySet([
|
|
140
|
+
{ kind: "snapshot", value: snapshot },
|
|
141
|
+
...(input.targetRevision === undefined ? [] : [{ kind: "target", value: input.targetRevision }]),
|
|
142
|
+
]);
|
|
140
143
|
const execution = await executeVerification({
|
|
141
144
|
repository: input.repository,
|
|
142
145
|
candidate: snapshot,
|