@astrosheep/keiyaku 4.6.26 → 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 +113 -35
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +64 -44
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +13 -25
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +42 -29
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +57 -61
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +64 -44
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +13 -25
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +42 -29
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +57 -61
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +14 -26
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +64 -44
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +13 -25
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +42 -29
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +57 -61
- package/build/plugins/pi/README.md +7 -12
- package/build/plugins/pi/akuma-tools.ts +3 -18
- package/build/skills/keiyaku/SKILL.md +14 -26
- package/build/skills/keiyaku-akuma/SKILL.md +64 -44
- package/build/skills/keiyaku-akuma/references/automation.md +13 -25
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +42 -29
- package/build/skills/keiyaku-debt/SKILL.md +13 -8
- package/build/skills/keiyaku-workflow/SKILL.md +57 -61
- 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/events.d.ts +1 -1
- package/build/src/akuma/providers/codex-app-server/events.js +1 -3
- 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 +14 -37
- 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 +88 -81
- package/build/src/cli/commands/contract.js +27 -26
- package/build/src/cli/commands/debt-grammar.js +15 -15
- package/build/src/cli/commands/debt.js +3 -3
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +1 -2
- 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 +2 -1
- 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/runtime/proc/windows-launch.exe +0 -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/SKILL.md +14 -26
- package/skills/keiyaku-akuma/SKILL.md +64 -44
- package/skills/keiyaku-akuma/references/automation.md +13 -25
- package/skills/keiyaku-babysit/SKILL.md +1 -1
- package/skills/keiyaku-bind/SKILL.md +42 -29
- package/skills/keiyaku-debt/SKILL.md +13 -8
- package/skills/keiyaku-workflow/SKILL.md +57 -61
- 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
|
@@ -6,10 +6,10 @@ export declare const contractFileEffectSchema: z.ZodObject<{
|
|
|
6
6
|
kind: z.ZodLiteral<"contract-file">;
|
|
7
7
|
path: z.ZodString;
|
|
8
8
|
action: z.ZodEnum<{
|
|
9
|
-
created: "created";
|
|
10
|
-
updated: "updated";
|
|
11
|
-
unchanged: "unchanged";
|
|
12
9
|
removed: "removed";
|
|
10
|
+
unchanged: "unchanged";
|
|
11
|
+
updated: "updated";
|
|
12
|
+
created: "created";
|
|
13
13
|
}>;
|
|
14
14
|
}, z.core.$strict>;
|
|
15
15
|
export type ContractFileEffect = z.infer<typeof contractFileEffectSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseDependencyKeySet } from "../subject.js";
|
|
2
2
|
import { AuthorityCorruptionError } from "./errors.js";
|
|
3
|
-
import { changeId, actorId, contractId, documentKey, documentSegmentKey, entryUlid, gate, snapshotId, } from "./types.js";
|
|
3
|
+
import { changeId, actorId, contractId, documentKey, documentSegmentKey, entryUlid, gate, requirementId, snapshotId, } from "./types.js";
|
|
4
4
|
const VERSION_BY_KIND = {
|
|
5
5
|
bind: 1,
|
|
6
6
|
amend: 1,
|
|
@@ -92,6 +92,24 @@ function validateTimestamp(value, path) {
|
|
|
92
92
|
}
|
|
93
93
|
return text;
|
|
94
94
|
}
|
|
95
|
+
function targetValue(value, path) {
|
|
96
|
+
if (typeof value === "string")
|
|
97
|
+
return stringValue(value, path);
|
|
98
|
+
const object = requireRecord(value, path);
|
|
99
|
+
requireKeys(object, ["kind", "contractId", "worktree"], path);
|
|
100
|
+
if (object.kind !== "contract")
|
|
101
|
+
fail(`${path}.kind`, "unknown target kind");
|
|
102
|
+
const worktree = requireRecord(object.worktree, `${path}.worktree`);
|
|
103
|
+
requireKeys(worktree, ["id", "identity"], `${path}.worktree`);
|
|
104
|
+
return {
|
|
105
|
+
kind: "contract",
|
|
106
|
+
contractId: brandedValue(object.contractId, `${path}.contractId`, contractId),
|
|
107
|
+
worktree: {
|
|
108
|
+
id: stringValue(worktree.id, `${path}.worktree.id`),
|
|
109
|
+
identity: stringValue(worktree.identity, `${path}.worktree.identity`),
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
95
113
|
function validateCoordinates(value, path) {
|
|
96
114
|
const object = requireRecord(value, path);
|
|
97
115
|
requireKeys(object, ["start", "workspace"], path, ["target"]);
|
|
@@ -101,28 +119,43 @@ function validateCoordinates(value, path) {
|
|
|
101
119
|
return {
|
|
102
120
|
start: brandedValue(object.start, `${path}.start`, snapshotId),
|
|
103
121
|
workspace,
|
|
104
|
-
...(object.target === undefined ? {} : { target:
|
|
122
|
+
...(object.target === undefined ? {} : { target: targetValue(object.target, `${path}.target`) }),
|
|
105
123
|
};
|
|
106
124
|
}
|
|
107
125
|
function termsValue(value, path) {
|
|
108
126
|
const object = requireRecord(value, path);
|
|
109
|
-
requireKeys(object, ["document", "segments", "gates", "after"], path);
|
|
127
|
+
requireKeys(object, ["document", "segments", "gates", "requirements", "after"], path);
|
|
128
|
+
const gates = brandedArray(object.gates, `${path}.gates`, gate);
|
|
129
|
+
if (new Set(gates).size !== gates.length)
|
|
130
|
+
fail(`${path}.gates`, "duplicate gate");
|
|
131
|
+
const rawRequirements = requireRecord(object.requirements, `${path}.requirements`);
|
|
132
|
+
requireKeys(rawRequirements, gates, `${path}.requirements`);
|
|
133
|
+
const requirements = Object.fromEntries(gates.map((declaredGate) => {
|
|
134
|
+
const values = brandedArray(rawRequirements[declaredGate], `${path}.requirements.${declaredGate}`, requirementId);
|
|
135
|
+
if (values.length === 0)
|
|
136
|
+
fail(`${path}.requirements.${declaredGate}`, "expected at least one requirement");
|
|
137
|
+
if (new Set(values).size !== values.length)
|
|
138
|
+
fail(`${path}.requirements.${declaredGate}`, "duplicate requirement");
|
|
139
|
+
return [declaredGate, values];
|
|
140
|
+
}));
|
|
110
141
|
return {
|
|
111
142
|
document: documentValue(object.document, `${path}.document`),
|
|
112
143
|
segments: brandedArray(object.segments, `${path}.segments`, documentSegmentKey),
|
|
113
|
-
gates
|
|
144
|
+
gates,
|
|
145
|
+
requirements,
|
|
114
146
|
after: brandedArray(object.after, `${path}.after`, contractId),
|
|
115
147
|
};
|
|
116
148
|
}
|
|
117
149
|
function validateAttestation(value, path) {
|
|
118
150
|
const object = requireRecord(value, path);
|
|
119
|
-
requireKeys(object, ["gate", "subject", "verdict"], path, ["summary"]);
|
|
151
|
+
requireKeys(object, ["gate", "requirement", "subject", "verdict"], path, ["summary"]);
|
|
120
152
|
const declaredGate = brandedValue(object.gate, `${path}.gate`, gate);
|
|
121
153
|
const verdict = stringValue(object.verdict, `${path}.verdict`);
|
|
122
154
|
if (verdict !== "satisfied" && verdict !== "unsatisfied")
|
|
123
155
|
fail(`${path}.verdict`, "unknown attestation verdict");
|
|
124
156
|
return {
|
|
125
157
|
gate: declaredGate,
|
|
158
|
+
requirement: brandedValue(object.requirement, `${path}.requirement`, requirementId),
|
|
126
159
|
subject: dependencyKeySetValue(object.subject, `${path}.subject`),
|
|
127
160
|
verdict,
|
|
128
161
|
...(object.summary === undefined ? {} : { summary: stringValue(object.summary, `${path}.summary`) }),
|
|
@@ -8,6 +8,7 @@ function cloneTerms(terms) {
|
|
|
8
8
|
document: { ...terms.document },
|
|
9
9
|
segments: [...terms.segments],
|
|
10
10
|
gates: [...terms.gates],
|
|
11
|
+
requirements: Object.fromEntries(Object.entries(terms.requirements).map(([gate, requirements]) => [gate, [...requirements]])),
|
|
11
12
|
after: [...terms.after],
|
|
12
13
|
};
|
|
13
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AttestationEntry, type ChangeId, type ContractState, type Gate } from "./types.js";
|
|
1
|
+
import { type AttestationEntry, type ChangeId, type ContractState, type Gate, type RequirementId } from "./types.js";
|
|
2
2
|
export type GateStaleReason = Readonly<{
|
|
3
3
|
kind: "candidate-content-changed";
|
|
4
4
|
target?: string;
|
|
@@ -17,16 +17,22 @@ export type GateCurrent = Readonly<{
|
|
|
17
17
|
}> | Readonly<{
|
|
18
18
|
kind: "missing";
|
|
19
19
|
}>;
|
|
20
|
+
export type RequirementReport = Readonly<{
|
|
21
|
+
requirement: RequirementId;
|
|
22
|
+
current: GateCurrent;
|
|
23
|
+
}>;
|
|
20
24
|
export type GateReport = Readonly<{
|
|
21
25
|
gate: Gate;
|
|
26
|
+
requirements: readonly RequirementReport[];
|
|
27
|
+
satisfied: boolean;
|
|
22
28
|
current: GateCurrent;
|
|
23
29
|
}>;
|
|
24
30
|
export type GateReports = Readonly<{
|
|
25
31
|
reports: readonly GateReport[];
|
|
26
32
|
satisfied: boolean;
|
|
27
33
|
}>;
|
|
28
|
-
/** Resolve
|
|
29
|
-
export declare function latestCurrentAttestations(state: ContractState, requested: ReadonlySet<Gate>): ReadonlyMap<Gate, AttestationEntry
|
|
34
|
+
/** Resolve latest current testimony independently for each gate and requirement. */
|
|
35
|
+
export declare function latestCurrentAttestations(state: ContractState, requested: ReadonlySet<Gate>): ReadonlyMap<Gate, ReadonlyMap<RequirementId, AttestationEntry>>;
|
|
30
36
|
export declare function gatesSatisfied(state: ContractState): boolean;
|
|
31
|
-
/** Project every declared
|
|
37
|
+
/** Project every declared requirement without allowing consumers to reimplement currency. */
|
|
32
38
|
export declare function gateReports(state: ContractState): GateReports;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dependencyKeys, currentSubjectPredicate } from "../subject.js";
|
|
2
|
+
import { targetName, } from "./types.js";
|
|
2
3
|
function staleReason(state, previous) {
|
|
3
4
|
const target = state.coordinates.target;
|
|
4
5
|
const currentChange = state.currentIntegration?.changeId ?? state.delivery?.data.integration.changeId;
|
|
@@ -9,68 +10,84 @@ function staleReason(state, previous) {
|
|
|
9
10
|
return undefined;
|
|
10
11
|
return {
|
|
11
12
|
kind: "candidate-content-changed",
|
|
12
|
-
...(target === undefined ? {} : { target }),
|
|
13
|
+
...(target === undefined ? {} : { target: targetName(target) }),
|
|
13
14
|
previousChange,
|
|
14
15
|
currentChange,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
/** Resolve
|
|
18
|
+
/** Resolve latest current testimony independently for each gate and requirement. */
|
|
18
19
|
export function latestCurrentAttestations(state, requested) {
|
|
19
20
|
const attestations = new Map();
|
|
20
21
|
const subjectIsCurrent = currentSubjectPredicate(state);
|
|
21
22
|
for (let index = state.attestations.length - 1; index >= 0; index -= 1) {
|
|
22
23
|
const attestation = state.attestations[index];
|
|
23
|
-
const { gate, subject } = attestation.data;
|
|
24
|
-
if (!requested.has(gate) ||
|
|
24
|
+
const { gate, requirement, subject } = attestation.data;
|
|
25
|
+
if (!requested.has(gate) || !subjectIsCurrent(subject))
|
|
25
26
|
continue;
|
|
26
|
-
attestations.
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
let requirements = attestations.get(gate);
|
|
28
|
+
if (requirements === undefined) {
|
|
29
|
+
requirements = new Map();
|
|
30
|
+
attestations.set(gate, requirements);
|
|
31
|
+
}
|
|
32
|
+
if (!requirements.has(requirement))
|
|
33
|
+
requirements.set(requirement, attestation);
|
|
29
34
|
}
|
|
30
35
|
return attestations;
|
|
31
36
|
}
|
|
32
37
|
export function gatesSatisfied(state) {
|
|
33
38
|
return gateReports(state).satisfied;
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
function requirementCurrent(state, current, previous) {
|
|
41
|
+
if (current !== undefined) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "attested",
|
|
44
|
+
verdict: current.data.verdict,
|
|
45
|
+
...(current.data.summary === undefined ? {} : { summary: current.data.summary }),
|
|
46
|
+
at: current.at,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (previous === undefined)
|
|
50
|
+
return { kind: "missing" };
|
|
51
|
+
const reason = staleReason(state, previous);
|
|
52
|
+
return {
|
|
53
|
+
kind: "stale",
|
|
54
|
+
priorVerdict: previous.data.verdict,
|
|
55
|
+
...(reason === undefined ? {} : { reason }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Aggregate only adjudicated requirements, retaining each individual judgment in the report. */
|
|
59
|
+
function aggregateCurrent(requirements) {
|
|
60
|
+
const currents = requirements.map((report) => report.current);
|
|
61
|
+
return (currents.find((current) => current.kind === "attested" && current.verdict === "unsatisfied") ??
|
|
62
|
+
currents.find((current) => current.kind === "missing") ??
|
|
63
|
+
currents.find((current) => current.kind === "stale") ??
|
|
64
|
+
currents.reduce((latest, current) => current.kind === "attested" && latest.kind === "attested" && current.at > latest.at ? current : latest));
|
|
65
|
+
}
|
|
66
|
+
/** Project every declared requirement without allowing consumers to reimplement currency. */
|
|
36
67
|
export function gateReports(state) {
|
|
37
|
-
const
|
|
38
|
-
const requested = new Set(declared);
|
|
39
|
-
const current = latestCurrentAttestations(state, requested);
|
|
68
|
+
const current = latestCurrentAttestations(state, new Set(state.terms.gates));
|
|
40
69
|
const prior = new Map();
|
|
41
70
|
for (let index = state.attestations.length - 1; index >= 0; index -= 1) {
|
|
42
71
|
const entry = state.attestations[index];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const attestation = current.get(gate);
|
|
48
|
-
if (attestation !== undefined) {
|
|
49
|
-
return {
|
|
50
|
-
gate,
|
|
51
|
-
current: {
|
|
52
|
-
kind: "attested",
|
|
53
|
-
verdict: attestation.data.verdict,
|
|
54
|
-
...(attestation.data.summary === undefined ? {} : { summary: attestation.data.summary }),
|
|
55
|
-
at: attestation.at,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
72
|
+
let requirements = prior.get(entry.data.gate);
|
|
73
|
+
if (requirements === undefined) {
|
|
74
|
+
requirements = new Map();
|
|
75
|
+
prior.set(entry.data.gate, requirements);
|
|
58
76
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
if (!requirements.has(entry.data.requirement))
|
|
78
|
+
requirements.set(entry.data.requirement, entry);
|
|
79
|
+
}
|
|
80
|
+
const reports = state.terms.gates.map((gate) => {
|
|
81
|
+
const requirements = state.terms.requirements[gate].map((requirement) => ({
|
|
82
|
+
requirement,
|
|
83
|
+
current: requirementCurrent(state, current.get(gate)?.get(requirement), prior.get(gate)?.get(requirement)),
|
|
84
|
+
}));
|
|
63
85
|
return {
|
|
64
86
|
gate,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...(reason === undefined ? {} : { reason }),
|
|
69
|
-
},
|
|
87
|
+
requirements,
|
|
88
|
+
current: aggregateCurrent(requirements),
|
|
89
|
+
satisfied: requirements.every((report) => report.current.kind === "attested" && report.current.verdict === "satisfied"),
|
|
70
90
|
};
|
|
71
91
|
});
|
|
72
|
-
return {
|
|
73
|
-
reports,
|
|
74
|
-
satisfied: reports.every((report) => report.current.kind === "attested" && report.current.verdict === "satisfied"),
|
|
75
|
-
};
|
|
92
|
+
return { reports, satisfied: reports.every((report) => report.satisfied) };
|
|
76
93
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContractId, ContractState, DocumentKey } from "./types.js";
|
|
1
|
+
import type { ContractId, ContractState, ContractTarget, DocumentKey } from "./types.js";
|
|
2
2
|
/** The complete state projection consumed by one pure pact decision. */
|
|
3
3
|
export type ContractsObservation = ReadonlyMap<ContractId, ContractState | null>;
|
|
4
4
|
export type PrerequisiteStatus = "unknown" | "pending" | "claimed";
|
|
@@ -10,6 +10,12 @@ export type ActiveContractRefusal = Readonly<{
|
|
|
10
10
|
kind: "contract-missing" | "terminal";
|
|
11
11
|
contractId: ContractId;
|
|
12
12
|
}>;
|
|
13
|
+
export type TargetContractRefusal = Readonly<{
|
|
14
|
+
kind: "target-contract-missing" | "target-contract-terminal" | "target-contract-self";
|
|
15
|
+
contractId: ContractId;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function targetContractRefusal(observation: ContractsObservation, owner: ContractId, target: ContractTarget | undefined): TargetContractRefusal | undefined;
|
|
18
|
+
export declare function targetContractIdRefusal(observation: ContractsObservation, owner: ContractId, target: ContractId): TargetContractRefusal | undefined;
|
|
13
19
|
/** The single lifecycle guard shared by every operation on an existing contract. */
|
|
14
20
|
export declare function activeContract(observation: ContractsObservation, contract: ContractId): ContractState | ActiveContractRefusal;
|
|
15
21
|
export declare function documentIsCurrent(state: ContractState, document: DocumentKey): boolean;
|
|
@@ -21,6 +21,21 @@ export function prerequisiteStatus(prerequisites, observation) {
|
|
|
21
21
|
}
|
|
22
22
|
return pending ? "pending" : "claimed";
|
|
23
23
|
}
|
|
24
|
+
export function targetContractRefusal(observation, owner, target) {
|
|
25
|
+
if (target === undefined || typeof target === "string")
|
|
26
|
+
return undefined;
|
|
27
|
+
return targetContractIdRefusal(observation, owner, target.contractId);
|
|
28
|
+
}
|
|
29
|
+
export function targetContractIdRefusal(observation, owner, target) {
|
|
30
|
+
if (owner === target)
|
|
31
|
+
return { kind: "target-contract-self", contractId: owner };
|
|
32
|
+
const state = contractState(observation, target);
|
|
33
|
+
if (state === null)
|
|
34
|
+
return { kind: "target-contract-missing", contractId: target };
|
|
35
|
+
if (state.terminal !== null)
|
|
36
|
+
return { kind: "target-contract-terminal", contractId: target };
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
24
39
|
/** The single lifecycle guard shared by every operation on an existing contract. */
|
|
25
40
|
export function activeContract(observation, contract) {
|
|
26
41
|
const state = contractState(observation, contract);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ContractId, JournalEntry, SnapshotId } from "./types.js";
|
|
1
|
+
import type { ContractId, ContractTarget, JournalEntry, SnapshotId } from "./types.js";
|
|
2
2
|
export type ContractJournalAppend = Readonly<{
|
|
3
3
|
readonly contractId: ContractId;
|
|
4
4
|
readonly entries: readonly JournalEntry[];
|
|
5
5
|
}>;
|
|
6
6
|
/** A target operation is optional because claim can be journal-only. */
|
|
7
7
|
export type RefOperation = Readonly<{
|
|
8
|
-
readonly target:
|
|
8
|
+
readonly target: ContractTarget;
|
|
9
9
|
readonly newOid: SnapshotId;
|
|
10
10
|
readonly expectedOid: SnapshotId;
|
|
11
11
|
}>;
|
|
@@ -6,6 +6,7 @@ declare const changeIdBrand: unique symbol;
|
|
|
6
6
|
declare const documentKeyBrand: unique symbol;
|
|
7
7
|
declare const documentSegmentKeyBrand: unique symbol;
|
|
8
8
|
declare const gateBrand: unique symbol;
|
|
9
|
+
declare const requirementIdBrand: unique symbol;
|
|
9
10
|
declare const dependencyKeySetBrand: unique symbol;
|
|
10
11
|
declare const actorIdBrand: unique symbol;
|
|
11
12
|
export type ContractId = string & {
|
|
@@ -32,6 +33,9 @@ export type DocumentSegmentKey = string & {
|
|
|
32
33
|
export type Gate = string & {
|
|
33
34
|
readonly [gateBrand]: "Gate";
|
|
34
35
|
};
|
|
36
|
+
export type RequirementId = string & {
|
|
37
|
+
readonly [requirementIdBrand]: "RequirementId";
|
|
38
|
+
};
|
|
35
39
|
export type DependencyKeySet = string & {
|
|
36
40
|
readonly [dependencyKeySetBrand]: "DependencyKeySet";
|
|
37
41
|
};
|
|
@@ -51,11 +55,21 @@ export declare function changeId(value: string): ChangeId;
|
|
|
51
55
|
export declare function actorId(value: string): ActorId;
|
|
52
56
|
export declare function documentKey(value: string): DocumentKey;
|
|
53
57
|
export declare function documentSegmentKey(value: string): DocumentSegmentKey;
|
|
58
|
+
export declare function requirementId(value: string): RequirementId;
|
|
54
59
|
export declare function gateWord(value: unknown): value is string;
|
|
55
60
|
export declare function gate(value: string): Gate;
|
|
61
|
+
export type ContractTarget = string | Readonly<{
|
|
62
|
+
kind: "contract";
|
|
63
|
+
contractId: ContractId;
|
|
64
|
+
worktree: Readonly<{
|
|
65
|
+
id: string;
|
|
66
|
+
identity: string;
|
|
67
|
+
}>;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function targetName(target: ContractTarget): string;
|
|
56
70
|
export type ContractCoordinates = Readonly<{
|
|
57
71
|
start: SnapshotId;
|
|
58
|
-
target?:
|
|
72
|
+
target?: ContractTarget;
|
|
59
73
|
workspace: "worktree";
|
|
60
74
|
}>;
|
|
61
75
|
export type ContractTerms = Readonly<{
|
|
@@ -65,6 +79,7 @@ export type ContractTerms = Readonly<{
|
|
|
65
79
|
}>;
|
|
66
80
|
segments: readonly DocumentSegmentKey[];
|
|
67
81
|
gates: readonly Gate[];
|
|
82
|
+
requirements: Readonly<Record<string, readonly RequirementId[]>>;
|
|
68
83
|
after: readonly ContractId[];
|
|
69
84
|
}>;
|
|
70
85
|
export type BindData = Readonly<{
|
|
@@ -92,6 +107,7 @@ export type ReintegratedData = Readonly<{
|
|
|
92
107
|
}>;
|
|
93
108
|
export type AttestationData = Readonly<{
|
|
94
109
|
gate: Gate;
|
|
110
|
+
requirement: RequirementId;
|
|
95
111
|
subject: DependencyKeySet;
|
|
96
112
|
verdict: "satisfied" | "unsatisfied";
|
|
97
113
|
summary?: string;
|
|
@@ -55,6 +55,9 @@ export function documentKey(value) {
|
|
|
55
55
|
export function documentSegmentKey(value) {
|
|
56
56
|
return requireOpaqueId(value, "document segment key");
|
|
57
57
|
}
|
|
58
|
+
export function requirementId(value) {
|
|
59
|
+
return requireOpaqueId(value, "requirement ID");
|
|
60
|
+
}
|
|
58
61
|
export function gateWord(value) {
|
|
59
62
|
return typeof value === "string" && /^[a-z][a-z0-9-]{0,63}$/u.test(value);
|
|
60
63
|
}
|
|
@@ -64,6 +67,9 @@ export function gate(value) {
|
|
|
64
67
|
}
|
|
65
68
|
return value;
|
|
66
69
|
}
|
|
70
|
+
export function targetName(target) {
|
|
71
|
+
return typeof target === "string" ? target : target.contractId;
|
|
72
|
+
}
|
|
67
73
|
/**
|
|
68
74
|
* The one journal-envelope constructor for every verb offering a single fact: entry identity, the
|
|
69
75
|
* invoking decision input's Contract, timestamp, and optional actor, and the verb's own payload.
|
|
@@ -15,6 +15,14 @@ export function decideAmend({ input, attempt, observation, }) {
|
|
|
15
15
|
source.segments.every((value, index) => value === current.terms.segments[index]) &&
|
|
16
16
|
source.gates.length === current.terms.gates.length &&
|
|
17
17
|
source.gates.every((value, index) => value === current.terms.gates[index]) &&
|
|
18
|
+
Object.keys(source.requirements).length === Object.keys(current.terms.requirements).length &&
|
|
19
|
+
source.gates.every((gate) => {
|
|
20
|
+
const expected = source.requirements[gate];
|
|
21
|
+
const actual = current.terms.requirements[gate];
|
|
22
|
+
return (actual !== undefined &&
|
|
23
|
+
expected.length === actual.length &&
|
|
24
|
+
expected.every((value, index) => value === actual[index]));
|
|
25
|
+
}) &&
|
|
18
26
|
samePrerequisites(source.after, current.terms.after);
|
|
19
27
|
if (!termsCurrent) {
|
|
20
28
|
return { kind: "refused", refusal: { kind: "terms-moved", contractId: id } };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
|
|
2
|
+
import { type TargetContractRefusal } from "../facts/observation.js";
|
|
2
3
|
import { type ActorId, type BindData, type ContractId } from "../facts/types.js";
|
|
3
4
|
export type BindInput<Failure = never> = Readonly<{
|
|
4
5
|
contractId: ContractId;
|
|
5
6
|
actor?: ActorId;
|
|
6
7
|
at: string;
|
|
7
8
|
preparation: Preparation<BindData, Failure>;
|
|
9
|
+
targetContract?: ContractId;
|
|
8
10
|
}>;
|
|
9
11
|
export type BindRefusal = Readonly<{
|
|
10
12
|
kind: "contract-exists" | "invalid-after" | "unknown-prerequisite";
|
|
11
13
|
contractId: ContractId;
|
|
12
|
-
}
|
|
14
|
+
}> | TargetContractRefusal;
|
|
13
15
|
export declare function decideBind<Failure>({ input, attempt, observation, }: DecideInput<BindInput<Failure>>): OfferDecision<BindRefusal | Failure>;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { contractState, prerequisiteStatus } from "../facts/observation.js";
|
|
1
|
+
import { contractState, prerequisiteStatus, targetContractIdRefusal, targetContractRefusal, } from "../facts/observation.js";
|
|
2
2
|
import { journalEntry } from "../facts/types.js";
|
|
3
3
|
export function decideBind({ input, attempt, observation, }) {
|
|
4
4
|
const id = input.contractId;
|
|
5
5
|
const current = contractState(observation, id);
|
|
6
6
|
if (current !== null)
|
|
7
7
|
return { kind: "refused", refusal: { kind: "contract-exists", contractId: id } };
|
|
8
|
+
if (input.targetContract !== undefined) {
|
|
9
|
+
const refusal = targetContractIdRefusal(observation, id, input.targetContract);
|
|
10
|
+
if (refusal !== undefined)
|
|
11
|
+
return { kind: "refused", refusal };
|
|
12
|
+
}
|
|
8
13
|
if (input.preparation.kind === "refused")
|
|
9
14
|
return { kind: "refused", refusal: input.preparation.refusal };
|
|
10
15
|
const { data } = input.preparation;
|
|
16
|
+
const targetRefusal = targetContractRefusal(observation, id, data.coordinates.target);
|
|
17
|
+
if (targetRefusal !== undefined)
|
|
18
|
+
return { kind: "refused", refusal: targetRefusal };
|
|
11
19
|
if (data.terms.after.includes(id))
|
|
12
20
|
return { kind: "refused", refusal: { kind: "invalid-after", contractId: id } };
|
|
13
21
|
const prerequisites = prerequisiteStatus(data.terms.after, observation);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DecideInput, OfferDecision, StampedPreparation } from "../decide.js";
|
|
2
|
+
import { type TargetContractRefusal } from "../facts/observation.js";
|
|
2
3
|
import { type ActorId, type ContractId, type DeliverData } from "../facts/types.js";
|
|
3
4
|
export type DeliverInput<Failure = never> = Readonly<{
|
|
4
5
|
contractId: ContractId;
|
|
@@ -9,5 +10,5 @@ export type DeliverInput<Failure = never> = Readonly<{
|
|
|
9
10
|
export type DeliverRefusal = Readonly<{
|
|
10
11
|
kind: "contract-missing" | "terminal" | "document-moved";
|
|
11
12
|
contractId: ContractId;
|
|
12
|
-
}
|
|
13
|
+
}> | TargetContractRefusal;
|
|
13
14
|
export declare function decideDeliver<Failure>({ input, attempt, observation, }: DecideInput<DeliverInput<Failure>>): OfferDecision<DeliverRefusal | Failure>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { activeContract, documentIsCurrent } from "../facts/observation.js";
|
|
1
|
+
import { activeContract, documentIsCurrent, targetContractRefusal, } from "../facts/observation.js";
|
|
2
2
|
import { journalEntry } from "../facts/types.js";
|
|
3
3
|
export function decideDeliver({ input, attempt, observation, }) {
|
|
4
4
|
const state = activeContract(observation, input.contractId);
|
|
5
5
|
if ("kind" in state)
|
|
6
6
|
return { kind: "refused", refusal: state };
|
|
7
|
+
const targetRefusal = targetContractRefusal(observation, state.id, state.coordinates.target);
|
|
8
|
+
if (targetRefusal !== undefined)
|
|
9
|
+
return { kind: "refused", refusal: targetRefusal };
|
|
7
10
|
if (input.preparation.kind === "unavailable") {
|
|
8
11
|
throw new Error("existing contract requires a stamped delivery preparation");
|
|
9
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GateReport } from "../facts/gate.js";
|
|
2
|
+
import { type TargetContractRefusal } from "../facts/observation.js";
|
|
2
3
|
import { type ActorId, type ContractId, type ContractState } from "../facts/types.js";
|
|
3
4
|
import type { DecideInput, OfferDecision } from "../decide.js";
|
|
4
5
|
type PlacementInput = Readonly<{
|
|
@@ -10,7 +11,7 @@ type UnmetPrerequisite = Readonly<{
|
|
|
10
11
|
contractId: ContractId;
|
|
11
12
|
state: "missing" | "active" | "abandoned";
|
|
12
13
|
}>;
|
|
13
|
-
export type PlacementRefusal = Readonly<{
|
|
14
|
+
export type PlacementRefusal = TargetContractRefusal | Readonly<{
|
|
14
15
|
kind: "contract-missing" | "delivery-missing" | "terminal";
|
|
15
16
|
contractId: ContractId;
|
|
16
17
|
}> | Readonly<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gateReports } from "../facts/gate.js";
|
|
2
|
-
import { activeContract, contractState } from "../facts/observation.js";
|
|
3
|
-
import { journalEntry } from "../facts/types.js";
|
|
2
|
+
import { activeContract, contractState, targetContractRefusal, } from "../facts/observation.js";
|
|
3
|
+
import { journalEntry, targetName } from "../facts/types.js";
|
|
4
4
|
export function unmetPrerequisites(prerequisites, observation) {
|
|
5
5
|
const unmet = [];
|
|
6
6
|
for (const contractId of prerequisites) {
|
|
@@ -22,6 +22,9 @@ export function decidePlacement({ input, attempt, observation, }) {
|
|
|
22
22
|
const current = activeContract(observation, id);
|
|
23
23
|
if ("kind" in current)
|
|
24
24
|
return { kind: "refused", refusal: current };
|
|
25
|
+
const targetRefusal = targetContractRefusal(observation, id, current.coordinates.target);
|
|
26
|
+
if (targetRefusal !== undefined)
|
|
27
|
+
return { kind: "refused", refusal: targetRefusal };
|
|
25
28
|
const delivery = current.delivery;
|
|
26
29
|
const integration = current.currentIntegration;
|
|
27
30
|
if (!delivery || !integration) {
|
|
@@ -33,14 +36,14 @@ export function decidePlacement({ input, attempt, observation, }) {
|
|
|
33
36
|
}
|
|
34
37
|
const gates = gateReports(current);
|
|
35
38
|
if (!gates.satisfied) {
|
|
36
|
-
const unmetGates = gates.reports.filter((report) => report.
|
|
39
|
+
const unmetGates = gates.reports.filter((report) => !report.satisfied);
|
|
37
40
|
return {
|
|
38
41
|
kind: "refused",
|
|
39
42
|
refusal: {
|
|
40
43
|
kind: "gates-unsatisfied",
|
|
41
44
|
contractId: id,
|
|
42
45
|
unmet: unmetGates,
|
|
43
|
-
...(current.coordinates.target === undefined ? {} : { target: current.coordinates.target }),
|
|
46
|
+
...(current.coordinates.target === undefined ? {} : { target: targetName(current.coordinates.target) }),
|
|
44
47
|
},
|
|
45
48
|
};
|
|
46
49
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DecideInput, OfferDecision, Preparation } from "../decide.js";
|
|
2
|
+
import { type TargetContractRefusal } from "../facts/observation.js";
|
|
2
3
|
import { type ActorId, type ContractId, type ReintegratedData } from "../facts/types.js";
|
|
3
4
|
export type ReintegrateInput<Failure = never> = Readonly<{
|
|
4
5
|
contractId: ContractId;
|
|
@@ -9,5 +10,5 @@ export type ReintegrateInput<Failure = never> = Readonly<{
|
|
|
9
10
|
export type ReintegrateRefusal = Readonly<{
|
|
10
11
|
kind: "contract-missing" | "delivery-missing" | "terminal";
|
|
11
12
|
contractId: ContractId;
|
|
12
|
-
}
|
|
13
|
+
}> | TargetContractRefusal;
|
|
13
14
|
export declare function decideReintegrate<Failure>({ input, attempt, observation, }: DecideInput<ReintegrateInput<Failure>>): OfferDecision<ReintegrateRefusal | Failure>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { activeContract } from "../facts/observation.js";
|
|
1
|
+
import { activeContract, targetContractRefusal } from "../facts/observation.js";
|
|
2
2
|
import { journalEntry } from "../facts/types.js";
|
|
3
3
|
export function decideReintegrate({ input, attempt, observation, }) {
|
|
4
4
|
const state = activeContract(observation, input.contractId);
|
|
5
5
|
if ("kind" in state)
|
|
6
6
|
return { kind: "refused", refusal: state };
|
|
7
|
+
const targetRefusal = targetContractRefusal(observation, state.id, state.coordinates.target);
|
|
8
|
+
if (targetRefusal !== undefined)
|
|
9
|
+
return { kind: "refused", refusal: targetRefusal };
|
|
7
10
|
if (state.delivery === null) {
|
|
8
11
|
return { kind: "refused", refusal: { kind: "delivery-missing", contractId: input.contractId } };
|
|
9
12
|
}
|
|
@@ -12,15 +12,15 @@ export declare const debtRowSchema: z.ZodObject<{
|
|
|
12
12
|
title: z.ZodString;
|
|
13
13
|
state: z.ZodEnum<{
|
|
14
14
|
open: "open";
|
|
15
|
-
done: "done";
|
|
16
15
|
drop: "drop";
|
|
16
|
+
done: "done";
|
|
17
17
|
}>;
|
|
18
18
|
priority: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
19
19
|
disposition: z.ZodEnum<{
|
|
20
|
-
done: "done";
|
|
21
20
|
drop: "drop";
|
|
22
|
-
ready: "ready";
|
|
23
21
|
blocked: "blocked";
|
|
22
|
+
ready: "ready";
|
|
23
|
+
done: "done";
|
|
24
24
|
}>;
|
|
25
25
|
updatedAt: z.ZodString;
|
|
26
26
|
bodyPresent: z.ZodBoolean;
|
|
@@ -34,15 +34,15 @@ export declare const debtRowsSchema: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
|
34
34
|
title: z.ZodString;
|
|
35
35
|
state: z.ZodEnum<{
|
|
36
36
|
open: "open";
|
|
37
|
-
done: "done";
|
|
38
37
|
drop: "drop";
|
|
38
|
+
done: "done";
|
|
39
39
|
}>;
|
|
40
40
|
priority: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
41
41
|
disposition: z.ZodEnum<{
|
|
42
|
-
done: "done";
|
|
43
42
|
drop: "drop";
|
|
44
|
-
ready: "ready";
|
|
45
43
|
blocked: "blocked";
|
|
44
|
+
ready: "ready";
|
|
45
|
+
done: "done";
|
|
46
46
|
}>;
|
|
47
47
|
updatedAt: z.ZodString;
|
|
48
48
|
bodyPresent: z.ZodBoolean;
|
|
@@ -120,9 +120,9 @@ export declare function projectBlocked(board: DebtBoard, scope: readonly string[
|
|
|
120
120
|
export declare function projectStatusRows(board: DebtBoard, relations: DebtRelationProjection, scope: readonly string[] | null): ({
|
|
121
121
|
id: `debt/${string}`;
|
|
122
122
|
title: string;
|
|
123
|
-
state: "open" | "
|
|
123
|
+
state: "open" | "drop" | "done";
|
|
124
124
|
priority: 0 | 1 | 2 | 3;
|
|
125
|
-
disposition: "
|
|
125
|
+
disposition: "drop" | "blocked" | "ready" | "done";
|
|
126
126
|
updatedAt: string;
|
|
127
127
|
bodyPresent: boolean;
|
|
128
128
|
children?: {
|
|
@@ -137,9 +137,9 @@ export declare function projectStatusRows(board: DebtBoard, relations: DebtRelat
|
|
|
137
137
|
}>[];
|
|
138
138
|
id: `debt/${string}`;
|
|
139
139
|
title: string;
|
|
140
|
-
state: "open" | "
|
|
140
|
+
state: "open" | "drop" | "done";
|
|
141
141
|
priority: 0 | 1 | 2 | 3;
|
|
142
|
-
disposition: "
|
|
142
|
+
disposition: "drop" | "blocked" | "ready" | "done";
|
|
143
143
|
updatedAt: string;
|
|
144
144
|
bodyPresent: boolean;
|
|
145
145
|
children?: {
|
|
@@ -7,15 +7,15 @@ export declare const createdDebtObservationSchema: z.ZodUnion<readonly [z.ZodObj
|
|
|
7
7
|
title: z.ZodString;
|
|
8
8
|
state: z.ZodEnum<{
|
|
9
9
|
open: "open";
|
|
10
|
-
done: "done";
|
|
11
10
|
drop: "drop";
|
|
11
|
+
done: "done";
|
|
12
12
|
}>;
|
|
13
13
|
priority: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
14
14
|
disposition: z.ZodEnum<{
|
|
15
|
-
done: "done";
|
|
16
15
|
drop: "drop";
|
|
17
|
-
ready: "ready";
|
|
18
16
|
blocked: "blocked";
|
|
17
|
+
ready: "ready";
|
|
18
|
+
done: "done";
|
|
19
19
|
}>;
|
|
20
20
|
updatedAt: z.ZodString;
|
|
21
21
|
bodyPresent: z.ZodBoolean;
|