@astrosheep/keiyaku 4.6.27 → 4.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -35
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/opencode/package.json +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/plugins/pi/README.md +7 -12
- package/build/plugins/pi/akuma-tools.ts +3 -18
- package/build/skills/keiyaku-akuma/SKILL.md +39 -4
- package/build/skills/keiyaku-akuma/references/automation.md +4 -7
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +39 -15
- package/build/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/src/akuma/akuma-call.d.ts +15 -18
- package/build/src/akuma/akuma-call.js +55 -112
- package/build/src/akuma/akuma-errors.d.ts +0 -5
- package/build/src/akuma/akuma-errors.js +0 -9
- package/build/src/akuma/akuma-instance.d.ts +0 -2
- package/build/src/akuma/akuma-instance.js +18 -14
- package/build/src/akuma/akuma-observe.js +0 -1
- package/build/src/akuma/akuma-owner.js +0 -1
- package/build/src/akuma/akuma.d.ts +10 -26
- package/build/src/akuma/akuma.js +0 -2
- package/build/src/akuma/archetype.d.ts +0 -2
- package/build/src/akuma/archetype.js +3 -9
- package/build/src/akuma/body-launch.d.ts +12 -4
- package/build/src/akuma/body.d.ts +2 -5
- package/build/src/akuma/body.js +5 -49
- package/build/src/akuma/call-initial-tell.d.ts +39 -147
- package/build/src/akuma/call-initial-tell.js +0 -48
- package/build/src/akuma/caller.d.ts +0 -4
- package/build/src/akuma/custody.js +1 -57
- package/build/src/akuma/heart/facts.d.ts +0 -39
- package/build/src/akuma/heart/facts.js +0 -1
- package/build/src/akuma/heart/index.d.ts +1 -2
- package/build/src/akuma/heart/index.js +0 -1
- package/build/src/akuma/heart/schema.js +0 -26
- package/build/src/akuma/heart/soul.d.ts +2 -2
- package/build/src/akuma/heart/soul.js +2 -4
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +0 -2
- package/build/src/akuma/in-process-body.d.ts +1 -1
- package/build/src/akuma/index.d.ts +0 -2
- package/build/src/akuma/index.js +0 -1
- package/build/src/akuma/projection.d.ts +23 -23
- package/build/src/akuma/provider.d.ts +0 -5
- package/build/src/akuma/provider.js +0 -1
- package/build/src/akuma/providers/acp/core.js +1 -1
- package/build/src/akuma/providers/claude/index.js +1 -2
- package/build/src/akuma/providers/codex-app-server/index.js +1 -1
- package/build/src/akuma/providers/execution-environment.d.ts +1 -3
- package/build/src/akuma/providers/execution-environment.js +1 -7
- package/build/src/akuma/providers/opencode-sdk/index.js +0 -1
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +0 -1
- package/build/src/akuma/providers/opencode-sdk/session.js +4 -4
- package/build/src/akuma/providers/paseo/index.js +2 -9
- package/build/src/akuma/providers/pi/index.js +8 -14
- package/build/src/akuma/publication.d.ts +24 -59
- package/build/src/akuma/publication.js +29 -64
- package/build/src/akuma/selection-observation.d.ts +47 -2036
- package/build/src/akuma/selection-observation.js +1 -59
- package/build/src/akuma/turn-drive.d.ts +0 -8
- package/build/src/akuma/turn-drive.js +19 -103
- package/build/src/akuma-body.js +3 -6
- package/build/src/body-host.d.ts +8 -2
- package/build/src/body-host.js +30 -4
- package/build/src/cli/commands/akuma-grammar.d.ts +0 -2
- package/build/src/cli/commands/akuma-grammar.js +10 -33
- package/build/src/cli/commands/akuma.js +31 -49
- package/build/src/cli/commands/contract-grammar.d.ts +7 -1
- package/build/src/cli/commands/contract-grammar.js +15 -0
- package/build/src/cli/commands/contract-help.d.ts +13 -1
- package/build/src/cli/commands/contract-help.js +47 -16
- package/build/src/cli/commands/contract.js +27 -26
- package/build/src/cli/commands/debt.js +3 -3
- package/build/src/cli/commands/whoami.d.ts +0 -2
- package/build/src/cli/commands/whoami.js +0 -5
- package/build/src/cli/coordinates.js +15 -0
- package/build/src/cli/delivery-identity.d.ts +3 -0
- package/build/src/cli/delivery-identity.js +23 -0
- package/build/src/cli/parse.js +1 -0
- package/build/src/cli/render/akuma-activity.d.ts +0 -1
- package/build/src/cli/render/akuma-activity.js +1 -4
- package/build/src/cli/render/catalog.js +7 -1
- package/build/src/cli/render/contract-history.js +16 -38
- package/build/src/cli/render/contract-observation.d.ts +23 -10
- package/build/src/cli/render/contract-observation.js +9 -6
- package/build/src/cli/render/contract-wait.d.ts +2 -0
- package/build/src/cli/render/contract-wait.js +18 -0
- package/build/src/cli/render/contract.d.ts +2 -2
- package/build/src/cli/render/contract.js +57 -39
- package/build/src/cli/render/delivery-preview.js +13 -26
- package/build/src/cli/render/execution-progress.js +9 -9
- package/build/src/cli/render/kanshi.js +4 -11
- package/build/src/cli/render/receipt.d.ts +18 -0
- package/build/src/cli/render/receipt.js +34 -10
- package/build/src/cli/render/reconcile.js +3 -0
- package/build/src/cli/render/refusal.js +28 -6
- package/build/src/cli/render/whoami.js +1 -4
- package/build/src/cli/runtime.d.ts +0 -2
- package/build/src/cli/runtime.js +3 -7
- package/build/src/cli/selectors.d.ts +1 -2
- package/build/src/cli/selectors.js +2 -5
- package/build/src/contract-guidance.js +4 -2
- package/build/src/contract-worktree.d.ts +3 -3
- package/build/src/core/facts/codec.js +38 -5
- package/build/src/core/facts/fold.js +1 -0
- package/build/src/core/facts/gate.d.ts +10 -4
- package/build/src/core/facts/gate.js +56 -39
- package/build/src/core/facts/observation.d.ts +7 -1
- package/build/src/core/facts/observation.js +15 -0
- package/build/src/core/facts/offer.d.ts +2 -2
- package/build/src/core/facts/types.d.ts +17 -1
- package/build/src/core/facts/types.js +6 -0
- package/build/src/core/verbs/amend.js +8 -0
- package/build/src/core/verbs/bind.d.ts +3 -1
- package/build/src/core/verbs/bind.js +9 -1
- package/build/src/core/verbs/deliver.d.ts +2 -1
- package/build/src/core/verbs/deliver.js +4 -1
- package/build/src/core/verbs/placement.d.ts +2 -1
- package/build/src/core/verbs/placement.js +7 -4
- package/build/src/core/verbs/reintegrate.d.ts +2 -1
- package/build/src/core/verbs/reintegrate.js +4 -1
- package/build/src/debt/board.d.ts +10 -10
- package/build/src/debt/created-observation.d.ts +3 -3
- package/build/src/debt/document.d.ts +1 -1
- package/build/src/debt/index.d.ts +2 -24
- package/build/src/debt/index.js +11 -71
- package/build/src/debt/operation-types.d.ts +44 -3
- package/build/src/git/admission.js +18 -6
- package/build/src/git/integration.d.ts +4 -4
- package/build/src/git/integration.js +7 -1
- package/build/src/git/observe.d.ts +6 -4
- package/build/src/git/observe.js +18 -17
- package/build/src/git/reconcile.d.ts +20 -8
- package/build/src/git/reconcile.js +94 -45
- package/build/src/git/repository.d.ts +3 -1
- package/build/src/git/repository.js +26 -4
- package/build/src/git/scratch.d.ts +1 -1
- package/build/src/git/scratch.js +19 -18
- package/build/src/git/target-placement.d.ts +33 -7
- package/build/src/git/target-placement.js +67 -18
- package/build/src/git/target.d.ts +32 -0
- package/build/src/git/target.js +84 -0
- package/build/src/git/terminal-reconcile.d.ts +1 -1
- package/build/src/git/terminal-reconcile.js +34 -6
- package/build/src/index.d.ts +9 -7
- package/build/src/index.js +1 -1
- package/build/src/library/address.d.ts +1 -20
- package/build/src/library/address.js +3 -24
- package/build/src/library/akuma-creation.d.ts +2 -5
- package/build/src/library/akuma-creation.js +60 -44
- package/build/src/library/akumas.d.ts +3 -9
- package/build/src/library/akumas.js +12 -25
- package/build/src/library/bind.d.ts +21 -9
- package/build/src/library/bind.js +5 -1
- package/build/src/library/continuation.d.ts +130 -155
- package/build/src/library/continuation.js +1 -4
- package/build/src/library/contract-composition.d.ts +4 -9
- package/build/src/library/contract-composition.js +8 -12
- package/build/src/library/contract-creation.d.ts +1 -3
- package/build/src/library/contract-creation.js +2 -3
- package/build/src/library/contract-execution.d.ts +3 -5
- package/build/src/library/contract-execution.js +55 -96
- package/build/src/library/contract-outcomes.d.ts +2 -1
- package/build/src/library/contract-types.d.ts +5 -0
- package/build/src/library/contract-wait.d.ts +35 -0
- package/build/src/library/contract-wait.js +141 -0
- package/build/src/library/delivery.d.ts +13 -525
- package/build/src/library/delivery.js +1 -12
- package/build/src/library/input.js +2 -1
- package/build/src/library/invocation.d.ts +5 -1
- package/build/src/library/invocation.js +9 -2
- package/build/src/library/keiyaku.d.ts +7 -6
- package/build/src/library/keiyaku.js +12 -7
- package/build/src/library/outcome.d.ts +461 -12586
- package/build/src/library/outcome.js +15 -234
- package/build/src/library/reconcile.d.ts +12 -0
- package/build/src/library/reconcile.js +1 -0
- package/build/src/library/refusal.d.ts +251 -34
- package/build/src/library/refusal.js +10 -5
- package/build/src/library/selection.d.ts +9 -35
- package/build/src/library/selection.js +59 -129
- package/build/src/plugin/akuma-signals.d.ts +2 -2
- package/build/src/plugin/akuma-signals.js +2 -2
- package/build/src/plugin/public.d.ts +0 -7
- package/build/src/plugin/runtime.d.ts +2 -2
- package/build/src/plugin/runtime.js +4 -3
- package/build/src/protocol/attempt.js +7 -3
- package/build/src/protocol/bind.d.ts +18 -4
- package/build/src/protocol/bind.js +102 -35
- package/build/src/protocol/completion.d.ts +18 -331
- package/build/src/protocol/completion.js +17 -130
- package/build/src/protocol/deliver.d.ts +3 -3
- package/build/src/protocol/deliver.js +64 -74
- package/build/src/protocol/delivery-preview.d.ts +85 -28
- package/build/src/protocol/delivery-preview.js +34 -22
- package/build/src/protocol/execution-observation.d.ts +12 -9
- package/build/src/protocol/execution-observation.js +0 -1
- package/build/src/protocol/intent.d.ts +20 -50
- package/build/src/protocol/intent.js +37 -44
- package/build/src/protocol/operations.d.ts +299 -19
- package/build/src/protocol/operations.js +68 -27
- package/build/src/protocol/outcome.d.ts +1 -1
- package/build/src/protocol/placement.d.ts +2 -2
- package/build/src/protocol/placement.js +4 -3
- package/build/src/protocol/progress.d.ts +35 -2
- package/build/src/protocol/progress.js +12 -1
- package/build/src/protocol/read/observation.js +15 -4
- package/build/src/protocol/read/status.d.ts +9 -14
- package/build/src/protocol/read/status.js +15 -22
- package/build/src/protocol/reintegrate.d.ts +4 -3
- package/build/src/protocol/reintegrate.js +21 -5
- package/build/src/protocol/review.d.ts +9 -15
- package/build/src/protocol/review.js +2 -6
- package/build/src/protocol/run.d.ts +1 -1
- package/build/src/protocol/verify.d.ts +51 -0
- package/build/src/protocol/verify.js +128 -0
- package/build/src/verification/declaration.d.ts +5 -1
- package/build/src/verification/declaration.js +19 -2
- package/build/src/verification/execution.d.ts +5 -2
- package/build/src/verification/execution.js +48 -53
- package/build/src/verification/observation.d.ts +10 -6
- package/build/src/verification/observation.js +5 -2
- package/package.json +3 -3
- package/plugins/paseo/plugin/index.server.ts +3 -0
- package/plugins/paseo/plugin/server/attach.ts +42 -0
- package/plugins/paseo/plugin/server/mirror-identity.ts +51 -0
- package/plugins/paseo/plugin/server/model.ts +26 -0
- package/plugins/paseo/plugin/server/provider.ts +4 -6
- package/plugins/paseo/plugin/server/reopen.ts +4 -39
- package/plugins/pi/README.md +7 -12
- package/plugins/pi/akuma-tools.ts +3 -18
- package/skills/keiyaku-akuma/SKILL.md +39 -4
- package/skills/keiyaku-akuma/references/automation.md +4 -7
- package/skills/keiyaku-babysit/SKILL.md +1 -1
- package/skills/keiyaku-bind/SKILL.md +39 -15
- package/skills/keiyaku-workflow/SKILL.md +42 -22
- package/build/src/akuma/allowed.d.ts +0 -23
- package/build/src/akuma/allowed.js +0 -63
- package/build/src/akuma/call-request.d.ts +0 -308
- package/build/src/akuma/call-request.js +0 -175
- package/build/src/akuma/heart/request-authority.d.ts +0 -16
- package/build/src/akuma/heart/request-authority.js +0 -140
- package/build/src/akuma/heart/request-rows.d.ts +0 -18
- package/build/src/akuma/heart/request-rows.js +0 -107
- package/build/src/akuma/request-lifecycle.d.ts +0 -42
- package/build/src/akuma/request-lifecycle.js +0 -197
- package/build/src/akuma/request-observation.d.ts +0 -45
- package/build/src/akuma/request-observation.js +0 -162
- package/build/src/akuma/request-rendezvous.d.ts +0 -32
- package/build/src/akuma/request-rendezvous.js +0 -189
- package/build/src/akuma/request-serve.d.ts +0 -16
- package/build/src/akuma/request-serve.js +0 -188
- package/build/src/akuma/request-wire.d.ts +0 -143
- package/build/src/akuma/request-wire.js +0 -146
- package/build/src/akuma/requests.d.ts +0 -20
- package/build/src/akuma/requests.js +0 -72
- package/build/src/akuma/selection-owner-port.d.ts +0 -14
- package/build/src/akuma/selection-owner-port.js +0 -54
- package/build/src/akuma/selection-request.d.ts +0 -305
- package/build/src/akuma/selection-request.js +0 -307
- package/build/src/body-requests.d.ts +0 -13
- package/build/src/body-requests.js +0 -131
- package/build/src/cli/square-identity.d.ts +0 -10
- package/build/src/cli/square-identity.js +0 -130
- package/build/src/debt/mutation-result.d.ts +0 -981
- package/build/src/debt/mutation-result.js +0 -109
- package/build/src/debt/mutation.d.ts +0 -424
- package/build/src/debt/mutation.js +0 -223
- package/build/src/library/contract-operations.d.ts +0 -382
- package/build/src/library/contract-operations.js +0 -300
|
@@ -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;
|
|
@@ -3,8 +3,8 @@ import { type DebtCoordinate, type DebtId } from "./identity.js";
|
|
|
3
3
|
export declare const debtNonblankTextSchema: z.ZodString;
|
|
4
4
|
export declare const debtStateSchema: z.ZodEnum<{
|
|
5
5
|
open: "open";
|
|
6
|
-
done: "done";
|
|
7
6
|
drop: "drop";
|
|
7
|
+
done: "done";
|
|
8
8
|
}>;
|
|
9
9
|
export declare const debtPrioritySchema: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
10
10
|
export type DebtState = z.infer<typeof debtStateSchema>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { WorldRoot } from "../world.js";
|
|
2
2
|
import type { NamespaceContextSource, ResolvedNamespaceContext } from "./context.js";
|
|
3
|
-
import { type ExecutionContext } from "../akuma/requests.js";
|
|
4
|
-
import { type DebtLifecycleVerb } from "./mutation.js";
|
|
5
3
|
export type { WorldRoot } from "../world.js";
|
|
6
4
|
import { type BlockedDebtRow, type DebtDetailFacts, type DebtDoctorIssue, type DebtRef, type DebtRow, type DebtTreeNode } from "./board.js";
|
|
7
5
|
import { DebtAuthorityCorruptionError, type DebtPriority, type DebtState } from "./document.js";
|
|
@@ -22,27 +20,13 @@ export type DebtDoctorReport = Readonly<{
|
|
|
22
20
|
}>;
|
|
23
21
|
export type DebtDecompositionTree = DebtOutcome<DebtTreeNode>;
|
|
24
22
|
export type { AddDebtDocumentInput, AddDebtInput, BlockedDebtRow, DebtBatchResult, DebtCleanupFailure, DebtDoctorIssue, DebtId, DebtMutationResult, DebtOutcome, DebtPriority, DebtRef, DebtRefusal, DebtRetry, DebtRow, DebtState, DebtTreeNode, DebtUpdateResult, DebtView, UpdateDebtInput, DebtPage, DebtQueryExpression, DebtQueryPredicate, DebtQueryRow, DebtQuerySort, DebtRelationPredicateField, };
|
|
25
|
-
export type { LibraryExecution } from "../akuma/requests.js";
|
|
26
23
|
export { DebtAuthorityCorruptionError, DEBT_RELATION_PREDICATE_FIELDS };
|
|
27
24
|
export { observeRecentDebtStatus, type RecentDebtStatusRow } from "./catalog.js";
|
|
28
25
|
export { boundedListLimit as debtRowViewLimit } from "../bounded-list.js";
|
|
29
|
-
/**
|
|
30
|
-
* The one bound operation table for a captured route. Each entry either calls the
|
|
31
|
-
* local Debt operations directly or sends the same validated values as the one
|
|
32
|
-
* forwarded request shape. Validation stays in the handle methods.
|
|
33
|
-
*/
|
|
34
|
-
type DebtOperations = Readonly<{
|
|
35
|
-
add(values: AddDebtInput): Promise<DebtMutationResult>;
|
|
36
|
-
addDocument(values: AddDebtDocumentInput): Promise<DebtMutationResult>;
|
|
37
|
-
update(id: DebtId, values: UpdateDebtInput): Promise<DebtUpdateResult>;
|
|
38
|
-
lifecycle(id: DebtId, verb: DebtLifecycleVerb, note: string | undefined, signal?: AbortSignal): Promise<DebtMutationResult>;
|
|
39
|
-
batch(verb: DebtLifecycleVerb, ids: readonly DebtId[], note: string | undefined, signal?: AbortSignal): Promise<DebtBatchResult>;
|
|
40
|
-
}>;
|
|
41
26
|
declare class DebtHandle {
|
|
42
27
|
readonly id: DebtId;
|
|
43
28
|
private readonly world;
|
|
44
|
-
|
|
45
|
-
constructor(id: DebtId, world: WorldRoot, operations: DebtOperations);
|
|
29
|
+
constructor(id: DebtId, world: WorldRoot);
|
|
46
30
|
read(): Promise<DebtDetail | null>;
|
|
47
31
|
tree(): Promise<DebtDecompositionTree>;
|
|
48
32
|
update(input: UpdateDebtInput): Promise<DebtUpdateResult>;
|
|
@@ -60,8 +44,7 @@ export type Debt = DebtHandle;
|
|
|
60
44
|
declare class DebtsHandle {
|
|
61
45
|
private readonly world;
|
|
62
46
|
readonly root: WorldRoot;
|
|
63
|
-
|
|
64
|
-
constructor(world: WorldRoot, execution: ExecutionContext);
|
|
47
|
+
constructor(world: WorldRoot);
|
|
65
48
|
debt(input: Readonly<{
|
|
66
49
|
id: string;
|
|
67
50
|
}>): Debt;
|
|
@@ -101,11 +84,6 @@ declare class DebtsHandle {
|
|
|
101
84
|
}>): Promise<DebtBatchResult>;
|
|
102
85
|
}
|
|
103
86
|
export type Debts = DebtsHandle;
|
|
104
|
-
/**
|
|
105
|
-
* The one Debts composition. Public `of` fixes local execution; CLI and Body pass their captured
|
|
106
|
-
* internal channel through `debtsWithExecution` instead of a second constructor.
|
|
107
|
-
*/
|
|
108
|
-
export declare function debtsWithExecution(world: WorldRoot, execution: ExecutionContext): Debts;
|
|
109
87
|
export declare const Debts: Readonly<{
|
|
110
88
|
of(world: WorldRoot): Debts;
|
|
111
89
|
}>;
|
package/build/src/debt/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { executionChannel, localExecutionContext } from "../akuma/requests.js";
|
|
2
|
-
import { requestForwardedDebt, } from "./mutation.js";
|
|
3
1
|
import { buildTree, createDebtRelations, diagnoseBoard, } from "./board.js";
|
|
4
2
|
import { DebtAuthorityCorruptionError } from "./document.js";
|
|
5
3
|
import { addDebt, addDebtDocument, batchDebts, blockedDebts, lifecycleDebt, listDebts, queryDebts, readDebtDetail, readyDebts, debtView, updateDebt, } from "./operations.js";
|
|
@@ -10,61 +8,12 @@ import { normalizeDebtQuery, debtQuerySelection, DEBT_RELATION_PREDICATE_FIELDS,
|
|
|
10
8
|
export { DebtAuthorityCorruptionError, DEBT_RELATION_PREDICATE_FIELDS };
|
|
11
9
|
export { observeRecentDebtStatus } from "./catalog.js";
|
|
12
10
|
export { boundedListLimit as debtRowViewLimit } from "../bounded-list.js";
|
|
13
|
-
function debtRoute(execution) {
|
|
14
|
-
const channel = executionChannel(execution);
|
|
15
|
-
return channel.kind === "body-request" ? { kind: "forwarded", directory: channel.directory } : { kind: "local" };
|
|
16
|
-
}
|
|
17
|
-
function forwardDebt(directory, world, request, signal) {
|
|
18
|
-
return requestForwardedDebt({
|
|
19
|
-
directory,
|
|
20
|
-
world,
|
|
21
|
-
request,
|
|
22
|
-
...(signal === undefined ? {} : { signal }),
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
/** The single lifecycle request shapes, keyed once by verb instead of switched per handle. */
|
|
26
|
-
const SINGLE_LIFECYCLE = {
|
|
27
|
-
done: (id, note) => ({ action: "debt.done", id, ...(note === undefined ? {} : { note }) }),
|
|
28
|
-
drop: (id, note) => ({ action: "debt.drop", id, ...(note === undefined ? {} : { note }) }),
|
|
29
|
-
};
|
|
30
|
-
/** The batch lifecycle request shapes for the same verbs. */
|
|
31
|
-
const BATCH_LIFECYCLE = {
|
|
32
|
-
done: (ids, note) => ({ action: "debt.done", ids, ...(note === undefined ? {} : { note }) }),
|
|
33
|
-
drop: (ids, note) => ({ action: "debt.drop", ids, ...(note === undefined ? {} : { note }) }),
|
|
34
|
-
};
|
|
35
|
-
function debtOperations(world, route) {
|
|
36
|
-
if (route.kind === "forwarded") {
|
|
37
|
-
const { directory } = route;
|
|
38
|
-
return {
|
|
39
|
-
add: (values) => {
|
|
40
|
-
const { actor: _actor, signal, namespace: selected, ...request } = values;
|
|
41
|
-
return forwardDebt(directory, world, { action: "debt.add", input: { ...request, namespace: selected ?? [] } }, signal);
|
|
42
|
-
},
|
|
43
|
-
addDocument: (values) => forwardDebt(directory, world, { action: "debt.addDocument", input: { markdown: values.markdown, namespace: values.namespace ?? [] } }, values.signal),
|
|
44
|
-
update: (id, values) => {
|
|
45
|
-
const { signal, ...request } = values;
|
|
46
|
-
return forwardDebt(directory, world, { action: "debt.update", id, input: request }, signal);
|
|
47
|
-
},
|
|
48
|
-
lifecycle: (id, verb, note, signal) => forwardDebt(directory, world, SINGLE_LIFECYCLE[verb](id, note), signal),
|
|
49
|
-
batch: (verb, ids, note, signal) => forwardDebt(directory, world, BATCH_LIFECYCLE[verb](ids, note), signal),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
add: (values) => addDebt(world, values),
|
|
54
|
-
addDocument: (values) => addDebtDocument(world, values),
|
|
55
|
-
update: (id, values) => updateDebt(world, id, values),
|
|
56
|
-
lifecycle: (id, verb, note, signal) => lifecycleDebt(world, id, verb, signal, note),
|
|
57
|
-
batch: (verb, ids, note, signal) => batchDebts(world, verb, ids, signal, note),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
11
|
class DebtHandle {
|
|
61
12
|
id;
|
|
62
13
|
world;
|
|
63
|
-
|
|
64
|
-
constructor(id, world, operations) {
|
|
14
|
+
constructor(id, world) {
|
|
65
15
|
this.id = id;
|
|
66
16
|
this.world = world;
|
|
67
|
-
this.operations = operations;
|
|
68
17
|
}
|
|
69
18
|
async read() {
|
|
70
19
|
const facts = await readDebtDetail(this.world, this.id);
|
|
@@ -80,13 +29,13 @@ class DebtHandle {
|
|
|
80
29
|
: { kind: "accepted", value: node };
|
|
81
30
|
}
|
|
82
31
|
update(input) {
|
|
83
|
-
return this.
|
|
32
|
+
return updateDebt(this.world, this.id, updateInput(input));
|
|
84
33
|
}
|
|
85
34
|
lifecycle(verb, input) {
|
|
86
35
|
const value = record(input ?? {}, `${verb} input`);
|
|
87
36
|
closed(value, ["note", "signal"], `${verb} input`);
|
|
88
37
|
const note = text(value.note, "note");
|
|
89
|
-
return this.
|
|
38
|
+
return lifecycleDebt(this.world, this.id, verb, signal(value.signal), note);
|
|
90
39
|
}
|
|
91
40
|
done(input) {
|
|
92
41
|
return this.lifecycle("done", input);
|
|
@@ -98,19 +47,17 @@ class DebtHandle {
|
|
|
98
47
|
class DebtsHandle {
|
|
99
48
|
world;
|
|
100
49
|
root;
|
|
101
|
-
|
|
102
|
-
constructor(world, execution) {
|
|
50
|
+
constructor(world) {
|
|
103
51
|
this.world = world;
|
|
104
52
|
this.root = world;
|
|
105
|
-
this.operations = debtOperations(world, debtRoute(execution));
|
|
106
53
|
}
|
|
107
54
|
debt(input) {
|
|
108
55
|
const v = record(input, "debt input");
|
|
109
56
|
closed(v, ["id"], "debt input");
|
|
110
|
-
return new DebtHandle(id(v.id), this.world
|
|
57
|
+
return new DebtHandle(id(v.id), this.world);
|
|
111
58
|
}
|
|
112
59
|
add(input) {
|
|
113
|
-
return this.
|
|
60
|
+
return addDebt(this.world, addInput(input));
|
|
114
61
|
}
|
|
115
62
|
addDocument(input) {
|
|
116
63
|
const v = record(input, "addDocument input");
|
|
@@ -119,7 +66,7 @@ class DebtsHandle {
|
|
|
119
66
|
if (markdown === undefined)
|
|
120
67
|
throw new TypeError("markdown is required");
|
|
121
68
|
const ns = namespace(v.namespace), createdBy = actor(v.actor), abort = signal(v.signal);
|
|
122
|
-
return this.
|
|
69
|
+
return addDebtDocument(this.world, {
|
|
123
70
|
markdown,
|
|
124
71
|
...(ns === undefined ? {} : { namespace: ns }),
|
|
125
72
|
...(createdBy === undefined ? {} : { actor: createdBy }),
|
|
@@ -184,20 +131,13 @@ class DebtsHandle {
|
|
|
184
131
|
if (ids === undefined || ids.length === 0)
|
|
185
132
|
throw new TypeError("ids requires at least one DebtId");
|
|
186
133
|
const note = text(v.note, "note");
|
|
187
|
-
return this.
|
|
134
|
+
return batchDebts(this.world, verb, ids, signal(v.signal), note);
|
|
188
135
|
}
|
|
189
136
|
}
|
|
190
|
-
/**
|
|
191
|
-
* The one Debts composition. Public `of` fixes local execution; CLI and Body pass their captured
|
|
192
|
-
* internal channel through `debtsWithExecution` instead of a second constructor.
|
|
193
|
-
*/
|
|
194
|
-
export function debtsWithExecution(world, execution) {
|
|
195
|
-
if (typeof world !== "string")
|
|
196
|
-
throw new TypeError("Debts.of world must be a WorldRoot");
|
|
197
|
-
return new DebtsHandle(world, execution);
|
|
198
|
-
}
|
|
199
137
|
export const Debts = Object.freeze({
|
|
200
138
|
of(world) {
|
|
201
|
-
|
|
139
|
+
if (typeof world !== "string")
|
|
140
|
+
throw new TypeError("Debts.of world must be a WorldRoot");
|
|
141
|
+
return new DebtsHandle(world);
|
|
202
142
|
},
|
|
203
143
|
});
|
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
import type { DebtPriority, DebtState } from "./document.js";
|
|
1
|
+
import type { DebtDocument, DebtPriority, DebtState } from "./document.js";
|
|
2
2
|
import type { DebtId } from "./identity.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export type DebtView = DebtDocument & Readonly<{
|
|
4
|
+
namespace: readonly string[];
|
|
5
|
+
}>;
|
|
6
|
+
export type DebtCleanupFailure = Readonly<{
|
|
7
|
+
kind: "lock-release-failed";
|
|
8
|
+
diagnostics: readonly string[];
|
|
9
|
+
}>;
|
|
10
|
+
export type DebtRefusal = Readonly<{
|
|
11
|
+
kind: "debt-missing";
|
|
12
|
+
debtId: DebtId;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
kind: "invalid-lifecycle-transition";
|
|
15
|
+
debtId: DebtId;
|
|
16
|
+
state: DebtState;
|
|
17
|
+
verb: "done" | "drop";
|
|
18
|
+
}> | Readonly<{
|
|
19
|
+
kind: "invalid-graph";
|
|
20
|
+
diagnostic: string;
|
|
21
|
+
}> | Readonly<{
|
|
22
|
+
kind: "invalid-namespace-context";
|
|
23
|
+
path: string;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
kind: "relation-owned-by-other";
|
|
26
|
+
debtId: DebtId;
|
|
27
|
+
related: DebtId;
|
|
28
|
+
declaringDebt: DebtId;
|
|
29
|
+
}>;
|
|
30
|
+
export type DebtRetry = "busy" | "concurrent-modification";
|
|
31
|
+
export type DebtMutationResult = DebtOutcome<DebtView>;
|
|
32
|
+
export type DebtUpdateResult = DebtOutcome<Readonly<{
|
|
33
|
+
debt: DebtView;
|
|
34
|
+
documentDiff: string;
|
|
35
|
+
changedFields: readonly Readonly<{
|
|
36
|
+
field: string;
|
|
37
|
+
action: "added" | "replaced" | "cleared" | "changed" | "appended";
|
|
38
|
+
}>[];
|
|
39
|
+
}>>;
|
|
40
|
+
export type DebtBatchResult = Readonly<{
|
|
41
|
+
items: readonly Readonly<{
|
|
42
|
+
id: DebtId;
|
|
43
|
+
outcome: DebtMutationResult;
|
|
44
|
+
}>[];
|
|
45
|
+
}>;
|
|
5
46
|
export type DebtOutcome<A> = Readonly<{
|
|
6
47
|
kind: "accepted";
|
|
7
48
|
value: A;
|
|
@@ -2,9 +2,10 @@ import { z } from "zod";
|
|
|
2
2
|
import { decodeJournal, encodeEntry } from "../core/facts/codec.js";
|
|
3
3
|
import { AuthorityCorruptionError } from "../core/facts/errors.js";
|
|
4
4
|
import { foldJournal } from "../core/facts/fold.js";
|
|
5
|
-
import { GIT_FORMAT_BYTES, GIT_FORMAT_PATH, GIT_REF, updateGitTreeFromFrozenDirectories, updateRefsAtomically, writeBlob, writeStateCommit, } from "./repository.js";
|
|
6
|
-
import { contractJournalPath, contractJournalPaths, gitObjectIdForSnapshot, mintContractHead, mintSnapshotId, } from "./identity.js";
|
|
5
|
+
import { CANDIDATE_PIN_REF_NAMESPACE, GIT_FORMAT_BYTES, GIT_FORMAT_PATH, GIT_REF, readRef, updateGitTreeFromFrozenDirectories, updateRefsAtomically, writeBlob, writeStateCommit, } from "./repository.js";
|
|
6
|
+
import { contractJournalPath, contractJournalPaths, contractPhysicalName, gitObjectIdForSnapshot, mintContractHead, mintSnapshotId, } from "./identity.js";
|
|
7
7
|
import { validPath } from "./tree.js";
|
|
8
|
+
import { targetRef } from "./target.js";
|
|
8
9
|
export const publicationFailedSchema = z
|
|
9
10
|
.object({ kind: z.literal("publication-failed"), diagnostic: z.string() })
|
|
10
11
|
.strict();
|
|
@@ -98,7 +99,8 @@ async function buildOffer(repository, admission, appends, companions) {
|
|
|
98
99
|
}
|
|
99
100
|
return { changes, heads };
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
+
// eslint-disable-next-line max-params -- Publication keeps its seat-bound inputs explicit.
|
|
103
|
+
async function publishOffer(repository, admission, target, changes, assertions, owner) {
|
|
102
104
|
const { snapshot } = admission;
|
|
103
105
|
const gitTree = await updateGitTreeFromFrozenDirectories(repository, snapshot.tree, admission.treeDirectories, changes);
|
|
104
106
|
const gitCommit = mintSnapshotId(await writeStateCommit({
|
|
@@ -106,17 +108,27 @@ async function publishOffer(repository, admission, target, changes, assertions)
|
|
|
106
108
|
tree: gitTree,
|
|
107
109
|
parent: snapshot.commit,
|
|
108
110
|
}));
|
|
109
|
-
|
|
111
|
+
const pin = target !== null && typeof target.target !== "string"
|
|
112
|
+
? `${CANDIDATE_PIN_REF_NAMESPACE}/${contractPhysicalName(owner)}`
|
|
113
|
+
: undefined;
|
|
114
|
+
const previousPin = pin === undefined ? null : await readRef(repository, pin);
|
|
115
|
+
const crossWorktree = (target !== null && typeof target.target !== "string") ||
|
|
116
|
+
assertions.some((assertion) => assertion.ref.startsWith("worktrees/"));
|
|
117
|
+
const stable = crossWorktree ? { ...repository, effectiveCwd: repository.primaryWorktree } : repository;
|
|
118
|
+
return await updateRefsAtomically(stable, [
|
|
110
119
|
{ ref: GIT_REF, newOid: gitObjectIdForSnapshot(gitCommit), expectedOid: snapshot.commit },
|
|
111
120
|
...(target === null
|
|
112
121
|
? []
|
|
113
122
|
: [
|
|
114
123
|
{
|
|
115
|
-
ref: target.target,
|
|
124
|
+
ref: targetRef(target.target),
|
|
116
125
|
newOid: gitObjectIdForSnapshot(target.newOid),
|
|
117
126
|
expectedOid: gitObjectIdForSnapshot(target.expectedOid),
|
|
118
127
|
},
|
|
119
128
|
]),
|
|
129
|
+
...(pin === undefined || target === null
|
|
130
|
+
? []
|
|
131
|
+
: [{ ref: pin, newOid: gitObjectIdForSnapshot(target.newOid), expectedOid: previousPin }]),
|
|
120
132
|
], assertions);
|
|
121
133
|
}
|
|
122
134
|
export async function admit(repository, offer, admission, assertions = []) {
|
|
@@ -127,7 +139,7 @@ export async function admit(repository, offer, admission, assertions = []) {
|
|
|
127
139
|
const companions = assertCompanionStructure(offer.companions ?? [], appends);
|
|
128
140
|
const target = offer.target ?? null;
|
|
129
141
|
const attempt = await buildOffer(repository, admission, appends, companions);
|
|
130
|
-
const publication = await publishOffer(repository, admission, target, attempt.changes, assertions);
|
|
142
|
+
const publication = await publishOffer(repository, admission, target, attempt.changes, assertions, appends[0].contractId);
|
|
131
143
|
if (publication.kind === "published") {
|
|
132
144
|
return {
|
|
133
145
|
kind: "accepted",
|
|
@@ -11,23 +11,23 @@ export declare const integrationPreparationRefusalSchema: z.ZodUnion<readonly [z
|
|
|
11
11
|
kind: z.ZodLiteral<"integration-failed">;
|
|
12
12
|
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<ContractId, string>>;
|
|
13
13
|
reason: z.ZodEnum<{
|
|
14
|
+
conflict: "conflict";
|
|
14
15
|
"not-based-on-target": "not-based-on-target";
|
|
15
16
|
"unrelated-histories": "unrelated-histories";
|
|
16
|
-
conflict: "conflict";
|
|
17
17
|
}>;
|
|
18
18
|
targetHead: z.ZodPipe<z.ZodString, z.ZodTransform<SnapshotId, string>>;
|
|
19
19
|
conflictPaths: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
20
20
|
}, z.core.$strict>, z.ZodTransform<{
|
|
21
21
|
kind: "integration-failed";
|
|
22
22
|
contractId: ContractId;
|
|
23
|
-
reason: "not-based-on-target" | "unrelated-histories"
|
|
23
|
+
reason: "conflict" | "not-based-on-target" | "unrelated-histories";
|
|
24
24
|
targetHead: SnapshotId;
|
|
25
25
|
} & {
|
|
26
26
|
conflictPaths?: readonly string[];
|
|
27
27
|
}, {
|
|
28
28
|
kind: "integration-failed";
|
|
29
29
|
contractId: ContractId;
|
|
30
|
-
reason: "not-based-on-target" | "unrelated-histories"
|
|
30
|
+
reason: "conflict" | "not-based-on-target" | "unrelated-histories";
|
|
31
31
|
targetHead: SnapshotId;
|
|
32
32
|
conflictPaths?: readonly string[] | undefined;
|
|
33
33
|
}>>, z.ZodObject<{
|
|
@@ -57,7 +57,7 @@ export declare function materializeJudgedConflict(repository: GitRepository, wor
|
|
|
57
57
|
export declare function planIntegration(repository: GitRepository, input: IntegrationCoordinates, tender: IntegrationTender, requireBranchesToBeUpToDate: boolean): Promise<Preparation<IntegrationPlan, Readonly<{
|
|
58
58
|
kind: "target-missing";
|
|
59
59
|
contractId: ContractId;
|
|
60
|
-
}> | IntegrationPreparationRefusal>>;
|
|
60
|
+
}> | IntegrationPreparationRefusal | import("./target.js").TargetWorkspaceRefusal>>;
|
|
61
61
|
export declare const deliveryDiffScopeSchema: z.ZodObject<{
|
|
62
62
|
filesChanged: z.ZodNumber;
|
|
63
63
|
insertions: z.ZodNumber;
|