@astrosheep/keiyaku 4.6.3 → 4.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +47 -11
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/references/automation.md +2 -2
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +8 -9
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +37 -25
- package/build/src/akuma/akuma-observe.d.ts +18 -15
- package/build/src/akuma/akuma-observe.js +75 -16
- package/build/src/akuma/akuma-wait.d.ts +4 -3
- package/build/src/akuma/akuma-wait.js +75 -53
- package/build/src/akuma/akuma.d.ts +6 -4
- package/build/src/akuma/akuma.js +4 -0
- package/build/src/akuma/call-initial-tell.d.ts +2 -2
- package/build/src/akuma/call-initial-tell.js +1 -1
- package/build/src/akuma/call-request.d.ts +2 -2
- package/build/src/akuma/heart/index.d.ts +7 -2
- package/build/src/akuma/heart/index.js +50 -5
- package/build/src/akuma/heart/tells.d.ts +33 -2
- package/build/src/akuma/heart/tells.js +24 -18
- package/build/src/akuma/heart/timeline.d.ts +23 -1
- package/build/src/akuma/heart/timeline.js +28 -21
- package/build/src/akuma/projection.d.ts +10 -10
- package/build/src/akuma/providers/pi/index.js +72 -39
- package/build/src/akuma/selection-observation.d.ts +20 -20
- package/build/src/akuma-body.js +1 -0
- package/build/src/alias/index.d.ts +0 -1
- package/build/src/alias/index.js +0 -4
- package/build/src/body/amend.d.ts +0 -4
- package/build/src/body/amend.js +0 -3
- package/build/src/body/region.d.ts +0 -1
- package/build/src/body/region.js +0 -3
- package/build/src/body/verification.d.ts +0 -1
- package/build/src/cli/commands/akuma-grammar.js +23 -66
- package/build/src/cli/commands/akuma.js +17 -30
- package/build/src/cli/commands/contract-grammar.d.ts +14 -1
- package/build/src/cli/commands/contract-grammar.js +54 -21
- package/build/src/cli/commands/contract-help.d.ts +9 -8
- package/build/src/cli/commands/contract-help.js +14 -7
- package/build/src/cli/commands/contract.js +57 -117
- package/build/src/cli/commands/install.d.ts +5 -5
- package/build/src/cli/commands/install.js +1 -4
- package/build/src/cli/commands/task-grammar.js +10 -66
- package/build/src/cli/commands/task.d.ts +0 -1
- package/build/src/cli/commands/task.js +34 -53
- package/build/src/cli/coordinates.d.ts +1 -2
- package/build/src/cli/coordinates.js +1 -4
- package/build/src/cli/parse.d.ts +2 -3
- package/build/src/cli/parse.js +24 -66
- package/build/src/cli/render/akuma.d.ts +3 -16
- package/build/src/cli/render/akuma.js +1 -13
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/contract.js +34 -32
- package/build/src/cli/render/kanshi-akuma.d.ts +8 -2
- package/build/src/cli/render/kanshi-akuma.js +14 -7
- package/build/src/cli/render/kanshi.d.ts +3 -1
- package/build/src/cli/render/kanshi.js +44 -32
- package/build/src/cli/render/receipt.js +6 -1
- package/build/src/cli/render/task.d.ts +1 -1
- package/build/src/cli/render/task.js +3 -27
- package/build/src/cli/render/terminal.d.ts +6 -2
- package/build/src/cli/render/terminal.js +8 -2
- package/build/src/cli/runtime.js +3 -16
- package/build/src/cli/scan.d.ts +26 -0
- package/build/src/cli/scan.js +82 -0
- package/build/src/cli/streams.d.ts +5 -0
- package/build/src/cli/streams.js +11 -0
- package/build/src/contract-worktree.js +38 -21
- package/build/src/core/facts/codec.d.ts +1 -2
- package/build/src/core/facts/codec.js +5 -11
- package/build/src/core/facts/types.d.ts +16 -2
- package/build/src/core/facts/types.js +15 -0
- package/build/src/core/verbs/abandon.js +3 -9
- package/build/src/core/verbs/amend.js +2 -9
- package/build/src/core/verbs/arc.js +6 -13
- package/build/src/core/verbs/attestation.js +2 -9
- package/build/src/core/verbs/bind.js +2 -9
- package/build/src/core/verbs/deliver.js +2 -9
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +2 -9
- package/build/src/core/verbs/reintegrate.d.ts +1 -1
- package/build/src/core/verbs/reintegrate.js +2 -9
- package/build/src/dispatch/index.d.ts +2 -2
- package/build/src/dispatch/index.js +33 -11
- package/build/src/git/hooks.d.ts +2 -4
- package/build/src/git/hooks.js +0 -12
- package/build/src/git/integration.d.ts +5 -3
- package/build/src/git/integration.js +36 -25
- package/build/src/git/nuke.js +4 -4
- package/build/src/git/observe.d.ts +4 -4
- package/build/src/git/observe.js +5 -5
- package/build/src/git/process.d.ts +1 -4
- package/build/src/git/process.js +1 -11
- package/build/src/git/read-observation.js +1 -1
- package/build/src/git/reconcile.d.ts +1 -1
- package/build/src/git/reconcile.js +15 -13
- package/build/src/git/repository.d.ts +2 -6
- package/build/src/git/repository.js +18 -31
- package/build/src/git/scratch.d.ts +6 -6
- package/build/src/git/scratch.js +110 -46
- package/build/src/git/target-placement.d.ts +5 -5
- package/build/src/git/target-placement.js +18 -33
- package/build/src/git/tender.d.ts +6 -2
- package/build/src/git/tender.js +19 -12
- package/build/src/git/terminal-reconcile.js +24 -13
- package/build/src/git/terminal-seal.d.ts +2 -5
- package/build/src/git/terminal-seal.js +5 -3
- package/build/src/git/workspace.d.ts +17 -13
- package/build/src/git/workspace.js +58 -41
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/index.js +1 -1
- package/build/src/kanshi/read.d.ts +8 -1
- package/build/src/kanshi/read.js +72 -7
- package/build/src/kanshi/report.d.ts +12 -0
- package/build/src/library/akuma-creation.d.ts +4 -4
- package/build/src/library/bind.d.ts +1 -63
- package/build/src/library/bind.js +3 -9
- package/build/src/library/contract-creation.js +2 -30
- package/build/src/library/contract-execution.d.ts +0 -1
- package/build/src/library/contract-execution.js +9 -34
- package/build/src/library/contract-operations.d.ts +5 -1
- package/build/src/library/contract-operations.js +7 -3
- package/build/src/library/contract-types.d.ts +1 -1
- package/build/src/library/delivery.d.ts +91 -93
- package/build/src/library/delivery.js +2 -1
- package/build/src/library/input.d.ts +0 -2
- package/build/src/library/input.js +0 -4
- package/build/src/library/invocation.d.ts +0 -1
- package/build/src/library/invocation.js +3 -25
- package/build/src/library/outcome.d.ts +651 -602
- package/build/src/library/outcome.js +4 -4
- package/build/src/library/reconcile.d.ts +6 -0
- package/build/src/library/reconcile.js +31 -1
- package/build/src/library/repo.d.ts +0 -1
- package/build/src/library/selection.d.ts +1 -10
- package/build/src/library/selection.js +14 -15
- package/build/src/protocol/abandon.d.ts +1 -1
- package/build/src/protocol/abandon.js +3 -10
- package/build/src/protocol/amend.js +2 -5
- package/build/src/protocol/arc.d.ts +1 -1
- package/build/src/protocol/arc.js +2 -9
- package/build/src/protocol/attempt.d.ts +3 -20
- package/build/src/protocol/attempt.js +6 -5
- package/build/src/protocol/audit.d.ts +1 -0
- package/build/src/protocol/audit.js +10 -11
- package/build/src/protocol/completion.d.ts +129 -55
- package/build/src/protocol/completion.js +62 -73
- package/build/src/protocol/deliver.d.ts +7 -5
- package/build/src/protocol/deliver.js +74 -44
- package/build/src/protocol/execution-observation.d.ts +2 -4
- package/build/src/protocol/execution-observation.js +3 -7
- package/build/src/protocol/intent.d.ts +1 -1
- package/build/src/protocol/intent.js +1 -0
- package/build/src/protocol/operations.d.ts +24 -12
- package/build/src/protocol/operations.js +36 -15
- package/build/src/protocol/placement.d.ts +2 -1
- package/build/src/protocol/placement.js +21 -5
- package/build/src/protocol/progress.d.ts +1 -1
- package/build/src/protocol/read/status.js +58 -41
- package/build/src/protocol/reintegrate.d.ts +1 -1
- package/build/src/protocol/reintegrate.js +10 -19
- package/build/src/protocol/review.d.ts +3 -28
- package/build/src/protocol/review.js +10 -37
- package/build/src/protocol/run.d.ts +19 -7
- package/build/src/protocol/run.js +19 -9
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/holder.d.ts +2 -4
- package/build/src/settlement/holder.js +3 -6
- package/build/src/task/board.d.ts +6 -0
- package/build/src/task/board.js +30 -1
- package/build/src/task/catalog.js +1 -4
- package/build/src/task/compose.d.ts +0 -1
- package/build/src/task/compose.js +0 -1
- package/build/src/task/context.d.ts +0 -1
- package/build/src/task/context.js +0 -3
- package/build/src/task/created-observation.d.ts +5 -1
- package/build/src/task/created-observation.js +12 -5
- package/build/src/task/index.d.ts +1 -1
- package/build/src/task/index.js +7 -6
- package/build/src/task/input.d.ts +0 -6
- package/build/src/task/input.js +2 -14
- package/build/src/task/mutation.d.ts +3 -4
- package/build/src/task/mutation.js +11 -39
- package/build/src/task/operations.d.ts +2 -7
- package/build/src/task/operations.js +37 -49
- package/build/src/task/query.d.ts +0 -1
- package/build/src/task/query.js +1 -4
- package/build/src/task/store.d.ts +0 -2
- package/build/src/task/store.js +27 -11
- package/build/src/verification/declaration.js +3 -2
- package/build/src/verification/execution.d.ts +3 -2
- package/build/src/verification/execution.js +10 -6
- package/build/src/workspace-place.d.ts +0 -1
- package/build/src/workspace-place.js +0 -11
- package/package.json +7 -3
package/build/src/kanshi/read.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { withoutReportedChanges } from "../akuma/projection.js";
|
|
2
|
-
import {
|
|
2
|
+
import { observeAkumaRoster, readAkumaTimeline } from "../akuma/akuma.js";
|
|
3
3
|
import { readAliases } from "../alias/index.js";
|
|
4
4
|
import { decodeContractDocument } from "../body/decode.js";
|
|
5
5
|
import { assertRegionPattern } from "../body/region.js";
|
|
@@ -16,6 +16,7 @@ import { observeRecentTaskStatus, TaskAuthorityCorruptionError } from "../task/i
|
|
|
16
16
|
import { observeTaskBoard } from "../task/operations.js";
|
|
17
17
|
import { ROSTER_SNAPSHOT_ROWS, ROSTER_VISIBLE_ROWS } from "./roster.js";
|
|
18
18
|
import { selectKanshi, selectRegion } from "./select.js";
|
|
19
|
+
const WORLD_CONTRACT_ROWS = 10;
|
|
19
20
|
function diagnostic(error) {
|
|
20
21
|
let source;
|
|
21
22
|
if (error instanceof Error)
|
|
@@ -128,12 +129,12 @@ async function readBranch(repo) {
|
|
|
128
129
|
return null;
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
|
-
async function readContracts(observation, include) {
|
|
132
|
+
async function readContracts(observation, include, limit = WORLD_CONTRACT_ROWS) {
|
|
132
133
|
try {
|
|
133
134
|
return {
|
|
134
135
|
kind: "present",
|
|
135
136
|
value: include === undefined
|
|
136
|
-
? await readContractCatalogue(observation,
|
|
137
|
+
? await readContractCatalogue(observation, limit)
|
|
137
138
|
: await readContractBoard(observation, include),
|
|
138
139
|
};
|
|
139
140
|
}
|
|
@@ -282,11 +283,12 @@ async function claimedAssociatedContracts(observation, dispatches) {
|
|
|
282
283
|
}));
|
|
283
284
|
return claimed;
|
|
284
285
|
}
|
|
285
|
-
async function joinAkuma(path, observeContract, isContractClaimed, dispatches,
|
|
286
|
+
async function joinAkuma(path, observeContract, isContractClaimed, dispatches, input) {
|
|
287
|
+
const { aliases, limit = ROSTER_VISIBLE_ROWS } = input;
|
|
286
288
|
if (aliases.kind !== "present")
|
|
287
289
|
return aliases;
|
|
288
290
|
try {
|
|
289
|
-
const source = await
|
|
291
|
+
const source = await observeAkumaRoster(path, limit);
|
|
290
292
|
const aliasById = new Map();
|
|
291
293
|
for (const binding of aliases.value)
|
|
292
294
|
aliasById.set(binding.akuId, [...(aliasById.get(binding.akuId) ?? []), binding]);
|
|
@@ -355,7 +357,9 @@ async function observeWithoutRepo(world, region, observedAt, branch) {
|
|
|
355
357
|
const observeContract = contractEndpointObserver(contracts);
|
|
356
358
|
const tasks = world === null ? { kind: "absent" } : await readTasks(world, holders, observeContract);
|
|
357
359
|
const aliases = world === null ? { kind: "absent" } : await readAliasBindings(world);
|
|
358
|
-
const akuma = world === null
|
|
360
|
+
const akuma = world === null
|
|
361
|
+
? { kind: "absent" }
|
|
362
|
+
: await joinAkuma(world, observeContract, () => false, [], { aliases });
|
|
359
363
|
return {
|
|
360
364
|
report: {
|
|
361
365
|
root: world,
|
|
@@ -394,7 +398,7 @@ async function observeRepo(input) {
|
|
|
394
398
|
? { kind: "absent" }
|
|
395
399
|
: dispatches.kind === "failed"
|
|
396
400
|
? dispatches
|
|
397
|
-
: await joinAkuma(world, observeContract, (id) => claimed.has(id), dispatches.value, aliases);
|
|
401
|
+
: await joinAkuma(world, observeContract, (id) => claimed.has(id), dispatches.value, { aliases });
|
|
398
402
|
const assembled = {
|
|
399
403
|
root: world,
|
|
400
404
|
observedAt,
|
|
@@ -443,6 +447,67 @@ export async function observeKanshi(input) {
|
|
|
443
447
|
export async function kanshi(input) {
|
|
444
448
|
return (await observeKanshi(input)).report;
|
|
445
449
|
}
|
|
450
|
+
/** Category observations reuse owner rows without reading the Task board. */
|
|
451
|
+
async function observeAkumaCategory(world, repo, limit, observedAt) {
|
|
452
|
+
const report = (akuma) => ({
|
|
453
|
+
category: "akuma",
|
|
454
|
+
root: world,
|
|
455
|
+
observedAt,
|
|
456
|
+
akuma,
|
|
457
|
+
});
|
|
458
|
+
if (world === null)
|
|
459
|
+
return report({ kind: "absent" });
|
|
460
|
+
const composed = async (observation) => {
|
|
461
|
+
const aliases = await readAliasBindings(world);
|
|
462
|
+
if (aliases.kind !== "present")
|
|
463
|
+
return report(aliases);
|
|
464
|
+
if (observation === undefined)
|
|
465
|
+
return report(await joinAkuma(world, () => "unavailable", () => false, [], { aliases, limit }));
|
|
466
|
+
const dispatches = await readDispatches(observation);
|
|
467
|
+
if (dispatches.kind === "failed")
|
|
468
|
+
return report(dispatches);
|
|
469
|
+
const claimed = await claimedAssociatedContracts(observation, dispatches.value);
|
|
470
|
+
return report(await joinAkuma(world, () => "unavailable", (id) => claimed.has(id), dispatches.value, { aliases, limit }));
|
|
471
|
+
};
|
|
472
|
+
if (repo === undefined)
|
|
473
|
+
return await composed();
|
|
474
|
+
try {
|
|
475
|
+
return await withGitDecodeChannel(repo, (channel) => withGitReadObservation(repo, channel, composed));
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
return report({ kind: "failed", failure: { message: diagnostic(error) } });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
async function observeContractCategory(world, repo, limit, observedAt) {
|
|
482
|
+
const report = (contracts) => ({
|
|
483
|
+
category: "contract",
|
|
484
|
+
root: world,
|
|
485
|
+
observedAt,
|
|
486
|
+
contracts,
|
|
487
|
+
});
|
|
488
|
+
try {
|
|
489
|
+
return await withGitDecodeChannel(repo, (channel) => withGitReadObservation(repo, channel, async (observation) => {
|
|
490
|
+
const [contracts, holders] = await Promise.all([
|
|
491
|
+
readContracts(observation, undefined, limit),
|
|
492
|
+
readHolders(observation),
|
|
493
|
+
]);
|
|
494
|
+
return report(decorateContracts(contracts, holders));
|
|
495
|
+
}));
|
|
496
|
+
}
|
|
497
|
+
catch (error) {
|
|
498
|
+
return report({ kind: "failed", failure: { message: diagnostic(error) } });
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
export async function kanshiCategory(input) {
|
|
502
|
+
const observedAt = new Date().toISOString();
|
|
503
|
+
const { world, repo, category, limit = 10 } = input;
|
|
504
|
+
if (category === "contract") {
|
|
505
|
+
if (repo === undefined)
|
|
506
|
+
throw new TypeError("kanshi contract category requires a Repo");
|
|
507
|
+
return await observeContractCategory(world, scopeForRepo(repo), limit, observedAt);
|
|
508
|
+
}
|
|
509
|
+
return await observeAkumaCategory(world, repo === undefined ? undefined : scopeForRepo(repo), limit, observedAt);
|
|
510
|
+
}
|
|
446
511
|
async function attachSelectedIssue(observation, contracts, selected) {
|
|
447
512
|
if (contracts.kind !== "present")
|
|
448
513
|
return contracts;
|
|
@@ -100,4 +100,16 @@ export type KanshiReport = Readonly<{
|
|
|
100
100
|
akuma: Section<AkumaKanshiWorld>;
|
|
101
101
|
region?: Section<RegionRead>;
|
|
102
102
|
}>;
|
|
103
|
+
/** Internal category observation retains only the requested owner section. */
|
|
104
|
+
export type KanshiCategoryReport = Readonly<{
|
|
105
|
+
category: "akuma";
|
|
106
|
+
root: WorldRoot | null;
|
|
107
|
+
observedAt: string;
|
|
108
|
+
akuma: Section<AkumaKanshiWorld>;
|
|
109
|
+
}> | Readonly<{
|
|
110
|
+
category: "contract";
|
|
111
|
+
root: WorldRoot | null;
|
|
112
|
+
observedAt: string;
|
|
113
|
+
contracts: Section<ContractKanshiBoard>;
|
|
114
|
+
}>;
|
|
103
115
|
export type { CurrentPhysicalIssue };
|
|
@@ -15,8 +15,7 @@ import type { Settings } from "../settings.js";
|
|
|
15
15
|
import { type WorldRoot } from "../world.js";
|
|
16
16
|
import type { Keiyaku } from "./keiyaku.js";
|
|
17
17
|
import { type Repo } from "./repo.js";
|
|
18
|
-
|
|
19
|
-
export type IntegrationFailure = Readonly<{
|
|
18
|
+
type IntegrationFailure = Readonly<{
|
|
20
19
|
kind: "authority-corruption" | "infrastructure";
|
|
21
20
|
diagnostic: string;
|
|
22
21
|
}>;
|
|
@@ -30,7 +29,7 @@ export type DispatchStage = Readonly<{
|
|
|
30
29
|
kind: "failed";
|
|
31
30
|
failure: DispatchFailure | IntegrationFailure;
|
|
32
31
|
}>;
|
|
33
|
-
|
|
32
|
+
type AliasStage = Readonly<{
|
|
34
33
|
kind: "none";
|
|
35
34
|
}> | Readonly<{
|
|
36
35
|
kind: "aliased";
|
|
@@ -47,7 +46,7 @@ export type CallWaitHead = Readonly<{
|
|
|
47
46
|
dispatch: DispatchStage;
|
|
48
47
|
alias: AliasStage;
|
|
49
48
|
}>;
|
|
50
|
-
|
|
49
|
+
type CallWaitObserver = Readonly<{
|
|
51
50
|
admitted?: (tell: TellResult, id: AkumaStatus["id"], head: CallWaitHead) => void | Promise<void>;
|
|
52
51
|
observe?: AskObserver["observe"];
|
|
53
52
|
}>;
|
|
@@ -117,3 +116,4 @@ export declare function callAkumas(input: CallInput & Readonly<{
|
|
|
117
116
|
export declare function forkAkumas(input: ForkInput & Readonly<{
|
|
118
117
|
path: WorldRoot;
|
|
119
118
|
}>): Promise<ForkResult>;
|
|
119
|
+
export {};
|
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
import { decodeContractDocument } from "../body/decode.js";
|
|
2
2
|
import { type ActorId, type ContractId } from "../core/facts/types.js";
|
|
3
3
|
import type { GitDecodeChannel } from "../git/read-observation.js";
|
|
4
|
-
import {
|
|
4
|
+
import { type BindTargetSelection } from "../protocol/bind.js";
|
|
5
5
|
import { type IntentOutcome, type RepositoryScope } from "../protocol/operations.js";
|
|
6
6
|
import type { ProtocolProgress } from "../protocol/progress.js";
|
|
7
7
|
import type { TaskId } from "../task/identity.js";
|
|
8
|
-
import type { VerificationDeclarationPreparation } from "../verification/declaration.js";
|
|
9
8
|
import type { ForkSourceRefusal, OperationRefusals } from "./refusal.js";
|
|
10
|
-
type BindAttemptInput = Readonly<{
|
|
11
|
-
scope: RepositoryScope;
|
|
12
|
-
channel: GitDecodeChannel;
|
|
13
|
-
title: string;
|
|
14
|
-
terms: Parameters<typeof bindOperation>[0]["terms"];
|
|
15
|
-
verification: VerificationDeclarationPreparation;
|
|
16
|
-
workspace: "worktree";
|
|
17
|
-
targetSelection?: BindTargetSelection;
|
|
18
|
-
coordinates?: Readonly<{
|
|
19
|
-
start: import("../core/facts/types.js").SnapshotId;
|
|
20
|
-
}>;
|
|
21
|
-
source?: Parameters<typeof bindOperation>[0]["source"];
|
|
22
|
-
task?: TaskId;
|
|
23
|
-
progress?: ProtocolProgress;
|
|
24
|
-
actor?: ActorId;
|
|
25
|
-
}>;
|
|
26
|
-
export declare function admitBindWithAppointment(input: BindAttemptInput): Promise<IntentOutcome<Readonly<{
|
|
27
|
-
contractId: ContractId;
|
|
28
|
-
}>, {
|
|
29
|
-
kind: "contract-exists" | "invalid-after" | "unknown-prerequisite";
|
|
30
|
-
contractId: ContractId;
|
|
31
|
-
} | {
|
|
32
|
-
kind: "verification-declaration-invalid";
|
|
33
|
-
contractId?: ContractId | undefined;
|
|
34
|
-
} | {
|
|
35
|
-
kind: "fork-source-moved";
|
|
36
|
-
contractId: ContractId;
|
|
37
|
-
} | {
|
|
38
|
-
kind: "unborn-head" | "target-missing" | "invalid-target";
|
|
39
|
-
} | {
|
|
40
|
-
kind: "fork-source-missing" | "fork-source-unavailable";
|
|
41
|
-
contractId: ContractId;
|
|
42
|
-
}>>;
|
|
43
9
|
type ForkBindAdmission = Readonly<{
|
|
44
10
|
kind: "document";
|
|
45
11
|
document: ReturnType<typeof decodeContractDocument>;
|
|
@@ -62,34 +28,6 @@ export declare function admitForkBindWithAppointment(input: Readonly<{
|
|
|
62
28
|
kind: "refused";
|
|
63
29
|
refusal: ForkSourceRefusal;
|
|
64
30
|
}> | ForkBindAdmission>;
|
|
65
|
-
export declare function admitMarkdownBind(input: Readonly<{
|
|
66
|
-
scope: RepositoryScope;
|
|
67
|
-
channel: GitDecodeChannel;
|
|
68
|
-
title: string;
|
|
69
|
-
terms: Parameters<typeof bindOperation>[0]["terms"];
|
|
70
|
-
verification: VerificationDeclarationPreparation;
|
|
71
|
-
workspace: "worktree";
|
|
72
|
-
targetSelection?: BindTargetSelection;
|
|
73
|
-
task?: TaskId;
|
|
74
|
-
progress?: ProtocolProgress;
|
|
75
|
-
actor?: ActorId;
|
|
76
|
-
}>): Promise<IntentOutcome<Readonly<{
|
|
77
|
-
contractId: ContractId;
|
|
78
|
-
}>, {
|
|
79
|
-
kind: "contract-exists" | "invalid-after" | "unknown-prerequisite";
|
|
80
|
-
contractId: ContractId;
|
|
81
|
-
} | {
|
|
82
|
-
kind: "verification-declaration-invalid";
|
|
83
|
-
contractId?: ContractId | undefined;
|
|
84
|
-
} | {
|
|
85
|
-
kind: "fork-source-moved";
|
|
86
|
-
contractId: ContractId;
|
|
87
|
-
} | {
|
|
88
|
-
kind: "unborn-head" | "target-missing" | "invalid-target";
|
|
89
|
-
} | {
|
|
90
|
-
kind: "fork-source-missing" | "fork-source-unavailable";
|
|
91
|
-
contractId: ContractId;
|
|
92
|
-
}>>;
|
|
93
31
|
export declare function prepareMarkdownBind(input: Readonly<{
|
|
94
32
|
scope: RepositoryScope;
|
|
95
33
|
channel: GitDecodeChannel;
|
|
@@ -7,7 +7,7 @@ import { mintIdentitySegment } from "../identity/mint.js";
|
|
|
7
7
|
import { fitIdentityStemWords, normalizeIdentityStem } from "../identity/normalize.js";
|
|
8
8
|
import { bindOperation } from "../protocol/bind.js";
|
|
9
9
|
import { stateOperation } from "../protocol/operations.js";
|
|
10
|
-
import {
|
|
10
|
+
import { admitWithTaskHolderFence, claimTaskHolder } from "../settlement/holder.js";
|
|
11
11
|
import { KeiyakuError } from "./outcome.js";
|
|
12
12
|
import { contractTerms, documentDerivation } from "./input.js";
|
|
13
13
|
const CONTRACT_ID_CODE_POINTS = 32;
|
|
@@ -48,9 +48,6 @@ async function attemptCandidates(input) {
|
|
|
48
48
|
collision: (result) => result.kind === "refused" && result.refusal.kind === "contract-exists",
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
export async function admitBindWithAppointment(input) {
|
|
52
|
-
return await attemptCandidates(input);
|
|
53
|
-
}
|
|
54
51
|
/**
|
|
55
52
|
* A legally non-forkable source is an expected refusal; corrupt persisted authority for a source that
|
|
56
53
|
* does exist is exceptional and names that source Contract.
|
|
@@ -119,12 +116,9 @@ export async function admitForkBindWithAppointment(input) {
|
|
|
119
116
|
});
|
|
120
117
|
return { kind: "document", admission, document };
|
|
121
118
|
}
|
|
122
|
-
export async function admitMarkdownBind(input) {
|
|
123
|
-
return await admitBindWithAppointment(input);
|
|
124
|
-
}
|
|
125
119
|
export async function prepareMarkdownBind(input) {
|
|
126
120
|
const terms = contractTerms(input.document, input.gates, input.after);
|
|
127
|
-
const admitCandidate = () =>
|
|
121
|
+
const admitCandidate = () => attemptCandidates({
|
|
128
122
|
scope: input.scope,
|
|
129
123
|
channel: input.channel,
|
|
130
124
|
title: input.document.title,
|
|
@@ -136,6 +130,6 @@ export async function prepareMarkdownBind(input) {
|
|
|
136
130
|
...(input.actor === undefined ? {} : { actor: input.actor }),
|
|
137
131
|
...(input.progress === undefined ? {} : { progress: input.progress }),
|
|
138
132
|
});
|
|
139
|
-
const admission = input.task === undefined ? null : await
|
|
133
|
+
const admission = input.task === undefined ? null : await admitWithTaskHolderFence(input.scope, input.task, admitCandidate);
|
|
140
134
|
return { admission, result: admission === null ? await admitCandidate() : admission.result };
|
|
141
135
|
}
|
|
@@ -12,7 +12,7 @@ import { captureLocalContractComposition, derivedGates, derivedHooks, gateNames,
|
|
|
12
12
|
import { actorOption, normalizedList, requireInput, requireMarkdown, taskOption } from "./input.js";
|
|
13
13
|
import { InvocationAccumulator } from "./invocation.js";
|
|
14
14
|
import { project, validated } from "./outcome.js";
|
|
15
|
-
import {
|
|
15
|
+
import { reconcileAffectedContracts } from "./reconcile.js";
|
|
16
16
|
import { observeRegion } from "./region.js";
|
|
17
17
|
import { scopeForRepo } from "./repo.js";
|
|
18
18
|
function bindInput(input, composition) {
|
|
@@ -122,7 +122,7 @@ function bindValue(keiyaku, region, warnings, workspace, appointmentLag) {
|
|
|
122
122
|
// eslint-disable-next-line max-params -- Keep this local operation's custody, admission, and policy witnesses explicit.
|
|
123
123
|
async function bindComplete(accumulator, id, scope, channel, leading, hooks, value) {
|
|
124
124
|
retainAdmission(accumulator, id, leading, false);
|
|
125
|
-
await
|
|
125
|
+
await reconcileAffectedContracts(accumulator, id, scope, channel, hooks);
|
|
126
126
|
try {
|
|
127
127
|
const appointment = await readManagedWorktreeAppointment(scope, id);
|
|
128
128
|
if (appointment.kind === "appointed")
|
|
@@ -139,34 +139,6 @@ async function bindComplete(accumulator, id, scope, channel, leading, hooks, val
|
|
|
139
139
|
accumulator.extendConclusions(id, conclusions(built));
|
|
140
140
|
return built;
|
|
141
141
|
}
|
|
142
|
-
async function reconcileAll(accumulator, id, scope, channel, hooks) {
|
|
143
|
-
for (const contract of [...new Set([id, ...accumulator.snapshot().affected])]) {
|
|
144
|
-
try {
|
|
145
|
-
accumulator.observe({ kind: "stage", contractId: contract, stage: "reconciliation", state: "started" });
|
|
146
|
-
const report = await (async () => {
|
|
147
|
-
try {
|
|
148
|
-
return await completeReconcile({
|
|
149
|
-
scope,
|
|
150
|
-
channel,
|
|
151
|
-
contractId: contract,
|
|
152
|
-
hooks,
|
|
153
|
-
retryHooks: false,
|
|
154
|
-
progress: accumulator,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
accumulator.observe({ kind: "stage", contractId: contract, stage: "reconciliation", state: "finished" });
|
|
159
|
-
}
|
|
160
|
-
})();
|
|
161
|
-
void report;
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
if (!isOperationalStop(error, scope.signal))
|
|
165
|
-
throw error;
|
|
166
|
-
accumulator.recordStop(executionStop(contract, "reconciliation", error, scope.signal));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
142
|
// eslint-disable-next-line max-params -- Keep this local operation's custody, admission, and policy witnesses explicit.
|
|
171
143
|
async function markdownBind(prepared, document, hooks, scope, channel, accumulator, handle, omittedMarkdownTarget) {
|
|
172
144
|
const { task, target, actor, gates, after } = prepared;
|
|
@@ -25,7 +25,7 @@ import { deliveryForContract } from "./delivery.js";
|
|
|
25
25
|
import { actorOption, contractTerms, documentDerivation, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
|
|
26
26
|
import { InvocationAccumulator } from "./invocation.js";
|
|
27
27
|
import { KeiyakuError, errorCategory, project, validated, } from "./outcome.js";
|
|
28
|
-
import {
|
|
28
|
+
import { reconcileAffectedContracts } from "./reconcile.js";
|
|
29
29
|
import { observeChangedRegion } from "./region.js";
|
|
30
30
|
export class ContractExecution {
|
|
31
31
|
seat;
|
|
@@ -157,6 +157,7 @@ export class ContractExecution {
|
|
|
157
157
|
if (outcome.kind !== "accepted")
|
|
158
158
|
return expected(this.id, outcome);
|
|
159
159
|
leadingValue = outcome.value;
|
|
160
|
+
accumulator.extendConclusions(this.id, { leading: outcome.value.leading });
|
|
160
161
|
stage = "verification";
|
|
161
162
|
await advanceAndContinue(accumulator, scope, localChannel, this.id, this.composition, outcome, values.signal, "verification");
|
|
162
163
|
}
|
|
@@ -168,12 +169,13 @@ export class ContractExecution {
|
|
|
168
169
|
const retained = accumulator.conclusions(this.id) ?? {};
|
|
169
170
|
const value = { ...base, ...leadingValue, ...retained };
|
|
170
171
|
accumulator.recordConclusions(this.id, value);
|
|
171
|
-
await
|
|
172
|
+
await reconcileAffectedContracts(accumulator, this.id, scope, localChannel, hooks);
|
|
172
173
|
return acceptedOutcome("deliver", this.id, accumulator, deliveryForContract(this.scope, value));
|
|
173
174
|
}, values.signal, observer);
|
|
174
175
|
}
|
|
175
176
|
async review(input, options) {
|
|
176
|
-
const values = validated(() => requireInput(input, "review input", ["verdict", "summary", "signal"]));
|
|
177
|
+
const values = validated(() => requireInput(input, "review input", ["verdict", "summary", "actor", "signal"]));
|
|
178
|
+
const actor = validated(() => actorOption(values.actor));
|
|
177
179
|
const verdict = values.verdict;
|
|
178
180
|
if (verdict !== "satisfied" && verdict !== "unsatisfied")
|
|
179
181
|
throw new KeiyakuError("invalid-input", "verdict must be satisfied or unsatisfied", {
|
|
@@ -195,6 +197,7 @@ export class ContractExecution {
|
|
|
195
197
|
contractId: this.id,
|
|
196
198
|
verdict,
|
|
197
199
|
...(summary === undefined ? {} : { summary }),
|
|
200
|
+
...actor,
|
|
198
201
|
},
|
|
199
202
|
});
|
|
200
203
|
const hooks = derivedHooks(this.composition);
|
|
@@ -209,6 +212,7 @@ export class ContractExecution {
|
|
|
209
212
|
contractId: this.id,
|
|
210
213
|
progress: accumulator,
|
|
211
214
|
...(this.composition.actor === undefined ? {} : { actor: this.composition.actor }),
|
|
215
|
+
...actor,
|
|
212
216
|
...(signal === undefined ? {} : { signal }),
|
|
213
217
|
verdict,
|
|
214
218
|
...(summary === undefined ? {} : { summary }),
|
|
@@ -229,7 +233,7 @@ export class ContractExecution {
|
|
|
229
233
|
}
|
|
230
234
|
const retained = { ...value, ...accumulator.conclusions(this.id) };
|
|
231
235
|
accumulator.extendConclusions(this.id, retained);
|
|
232
|
-
await
|
|
236
|
+
await reconcileAffectedContracts(accumulator, this.id, scope, localChannel, hooks);
|
|
233
237
|
return acceptedOutcome("review", this.id, accumulator, retained);
|
|
234
238
|
}, signal, observer);
|
|
235
239
|
}
|
|
@@ -379,38 +383,9 @@ export class ContractExecution {
|
|
|
379
383
|
retainAdmission(accumulator, this.id, input.leading, input.verificationResidueRecorded);
|
|
380
384
|
const value = input.value(input.leading.value);
|
|
381
385
|
accumulator.extendConclusions(this.id, conclusions(value));
|
|
382
|
-
await
|
|
386
|
+
await reconcileAffectedContracts(accumulator, this.id, input.scope, input.channel, input.hooks);
|
|
383
387
|
return value;
|
|
384
388
|
}
|
|
385
|
-
async reconcileContracts(accumulator, scope, channel, hooks) {
|
|
386
|
-
for (const contract of [...new Set([this.id, ...accumulator.snapshot().affected])]) {
|
|
387
|
-
try {
|
|
388
|
-
scope.signal?.throwIfAborted();
|
|
389
|
-
accumulator.observe({ kind: "stage", contractId: contract, stage: "reconciliation", state: "started" });
|
|
390
|
-
const report = await (async () => {
|
|
391
|
-
try {
|
|
392
|
-
return await completeReconcile({
|
|
393
|
-
scope,
|
|
394
|
-
channel,
|
|
395
|
-
contractId: contract,
|
|
396
|
-
hooks,
|
|
397
|
-
retryHooks: false,
|
|
398
|
-
progress: accumulator,
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
finally {
|
|
402
|
-
accumulator.observe({ kind: "stage", contractId: contract, stage: "reconciliation", state: "finished" });
|
|
403
|
-
}
|
|
404
|
-
})();
|
|
405
|
-
void report;
|
|
406
|
-
}
|
|
407
|
-
catch (error) {
|
|
408
|
-
if (!isOperationalStop(error, scope.signal))
|
|
409
|
-
throw error;
|
|
410
|
-
accumulator.recordStop(executionStop(contract, "reconciliation", error, scope.signal));
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
389
|
}
|
|
415
390
|
function changedAmendTerms(before, after) {
|
|
416
391
|
return {
|
|
@@ -55,17 +55,20 @@ declare const reviewRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
|
55
55
|
unsatisfied: "unsatisfied";
|
|
56
56
|
}>;
|
|
57
57
|
summary: z.ZodOptional<z.ZodString>;
|
|
58
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
58
59
|
}, z.core.$strict>, z.ZodTransform<{
|
|
59
60
|
repoRoot: string;
|
|
60
61
|
contractId: import("../core/facts/types.js").ContractId;
|
|
61
62
|
verdict: "satisfied" | "unsatisfied";
|
|
62
63
|
summary?: string | undefined;
|
|
64
|
+
actor?: string | undefined;
|
|
63
65
|
action: "contract.review";
|
|
64
66
|
}, {
|
|
65
67
|
repoRoot: string;
|
|
66
68
|
contractId: import("../core/facts/types.js").ContractId;
|
|
67
69
|
verdict: "satisfied" | "unsatisfied";
|
|
68
70
|
summary?: string | undefined;
|
|
71
|
+
actor?: string | undefined;
|
|
69
72
|
}>>;
|
|
70
73
|
export type ContractRequest = z.infer<typeof auditRequestSchema> | z.infer<typeof deliverRequestSchema> | z.infer<typeof reviewRequestSchema>;
|
|
71
74
|
type DeliverRequest = Extract<ContractRequest, {
|
|
@@ -174,6 +177,7 @@ declare const contractServiceSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
174
177
|
path: z.ZodString;
|
|
175
178
|
}, z.core.$strict>;
|
|
176
179
|
identity: z.ZodObject<{
|
|
180
|
+
note: z.ZodOptional<z.ZodString>;
|
|
177
181
|
tenderSnapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
178
182
|
integration: z.ZodObject<{
|
|
179
183
|
predecessor: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
|
|
@@ -376,7 +380,7 @@ declare const contractServiceSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
376
380
|
contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").ContractId, string>>;
|
|
377
381
|
reviewFactId: z.ZodString;
|
|
378
382
|
}, z.core.$strict>]>;
|
|
379
|
-
|
|
383
|
+
type ContractService = z.infer<typeof contractServiceSchema>;
|
|
380
384
|
type ContractReference = ContractService | z.infer<typeof materializedHandoffReferenceSchema>;
|
|
381
385
|
export type ContractRequestPort = Readonly<{
|
|
382
386
|
audit(input: AuditRequest & Readonly<{
|
|
@@ -4,7 +4,7 @@ import { AkumaBodyRequestError, requestBodyCommand } from "../akuma/request-rend
|
|
|
4
4
|
import { eraseRequestCommand, } from "../akuma/request-wire.js";
|
|
5
5
|
import { auditReportSchema } from "../protocol/audit.js";
|
|
6
6
|
import { materializedConflictSchema } from "../protocol/deliver.js";
|
|
7
|
-
import {
|
|
7
|
+
import { observationSchema, observeExecution } from "../protocol/execution-observation.js";
|
|
8
8
|
import { contractIdSchema } from "../protocol/operations.js";
|
|
9
9
|
import { deliveryValueSchema } from "./delivery.js";
|
|
10
10
|
import { InvocationAccumulator } from "./invocation.js";
|
|
@@ -27,7 +27,11 @@ const deliverRequestSchema = contractRequestBaseSchema
|
|
|
27
27
|
})
|
|
28
28
|
.transform((request) => ({ action: "contract.deliver", ...request }));
|
|
29
29
|
const reviewRequestSchema = contractRequestBaseSchema
|
|
30
|
-
.extend({
|
|
30
|
+
.extend({
|
|
31
|
+
verdict: z.enum(["satisfied", "unsatisfied"]),
|
|
32
|
+
summary: nonblankStringSchema.optional(),
|
|
33
|
+
actor: z.string().optional(),
|
|
34
|
+
})
|
|
31
35
|
.transform((request) => ({ action: "contract.review", ...request }));
|
|
32
36
|
const auditServiceSchema = z
|
|
33
37
|
.object({
|
|
@@ -250,7 +254,7 @@ export async function requestForwardedContractLive(input) {
|
|
|
250
254
|
value: input.request,
|
|
251
255
|
onProgress: (value) => {
|
|
252
256
|
try {
|
|
253
|
-
observeExecution(input.observe,
|
|
257
|
+
observeExecution(input.observe, observationSchema.parse(value));
|
|
254
258
|
}
|
|
255
259
|
catch {
|
|
256
260
|
observeExecution(input.observe, { kind: "progress-dropped", count: 1 });
|
|
@@ -72,7 +72,7 @@ export type KeiyakuSelectInput = Readonly<{
|
|
|
72
72
|
repo: Repo;
|
|
73
73
|
id: ContractId;
|
|
74
74
|
}>;
|
|
75
|
-
export type ReviewInput = Readonly<{
|
|
75
|
+
export type ReviewInput = ActorOptions & Readonly<{
|
|
76
76
|
verdict: AttestationData["verdict"];
|
|
77
77
|
summary?: string;
|
|
78
78
|
signal?: AbortSignal;
|