cloving 1.0.1 → 1.2.0
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 +251 -20
- package/assets/watch-fonts/fira-code-OFL.md +93 -0
- package/assets/watch-fonts/fira-code-latin-400-normal.woff2 +0 -0
- package/assets/watch-fonts/fira-code-latin-500-normal.woff2 +0 -0
- package/assets/watch-fonts/heebo-OFL.md +93 -0
- package/assets/watch-fonts/heebo-latin-500-normal.woff2 +0 -0
- package/assets/watch-fonts/heebo-latin-700-normal.woff2 +0 -0
- package/assets/watch-fonts/heebo-latin-800-normal.woff2 +0 -0
- package/assets/watch-fonts/manifest.json +112 -0
- package/assets/watch-fonts/space-grotesk-OFL.md +93 -0
- package/assets/watch-fonts/space-grotesk-latin-400-normal.woff2 +0 -0
- package/assets/watch-fonts/space-grotesk-latin-500-normal.woff2 +0 -0
- package/assets/watch-fonts/space-grotesk-latin-600-normal.woff2 +0 -0
- package/assets/watch-fonts/space-grotesk-latin-700-normal.woff2 +0 -0
- package/dist/src/authority/commands.d.ts +1 -0
- package/dist/src/authority/commands.js +33 -4
- package/dist/src/authority/dispatch-decision.d.ts +1 -0
- package/dist/src/authority/dispatch-decision.js +7 -4
- package/dist/src/authority/events.js +2 -2
- package/dist/src/authority/handoff-chain.d.ts +24 -0
- package/dist/src/authority/handoff-chain.js +46 -0
- package/dist/src/authority/reconciliation.d.ts +3 -0
- package/dist/src/authority/reconciliation.js +21 -5
- package/dist/src/authority/transitions.d.ts +1 -1
- package/dist/src/authority/transitions.js +5 -0
- package/dist/src/broker/actor/authority-queries.d.ts +4 -0
- package/dist/src/broker/actor/authority-queries.js +51 -2
- package/dist/src/broker/actor/authority-session.d.ts +2 -0
- package/dist/src/broker/actor/authority-session.js +3 -4
- package/dist/src/broker/actor/delivery-intents.d.ts +1 -0
- package/dist/src/broker/actor/effect-delivery.js +9 -0
- package/dist/src/broker/authority-admission.js +13 -5
- package/dist/src/chats/analysis-batches.d.ts +42 -0
- package/dist/src/chats/analysis-batches.js +97 -0
- package/dist/src/chats/analysis-checkpoint.d.ts +29 -0
- package/dist/src/chats/analysis-checkpoint.js +31 -0
- package/dist/src/chats/analysis-contract.d.ts +80 -0
- package/dist/src/chats/analysis-contract.js +16 -0
- package/dist/src/chats/analysis-data.d.ts +3 -0
- package/dist/src/chats/analysis-data.js +85 -0
- package/dist/src/chats/analysis-input.d.ts +18 -0
- package/dist/src/chats/analysis-input.js +97 -0
- package/dist/src/chats/analysis-links.d.ts +2 -0
- package/dist/src/chats/analysis-links.js +25 -0
- package/dist/src/chats/analysis-merge.d.ts +16 -0
- package/dist/src/chats/analysis-merge.js +134 -0
- package/dist/src/chats/analysis-prompt.d.ts +18 -0
- package/dist/src/chats/analysis-prompt.js +42 -0
- package/dist/src/chats/analysis-proposal.d.ts +4 -0
- package/dist/src/chats/analysis-proposal.js +41 -0
- package/dist/src/chats/analysis-provenance.d.ts +4 -0
- package/dist/src/chats/analysis-provenance.js +99 -0
- package/dist/src/chats/analysis-shape.d.ts +4 -0
- package/dist/src/chats/analysis-shape.js +235 -0
- package/dist/src/chats/analysis.d.ts +3 -0
- package/dist/src/chats/analysis.js +42 -0
- package/dist/src/chats/corpus-input.d.ts +5 -0
- package/dist/src/chats/corpus-input.js +288 -0
- package/dist/src/chats/destination.js +3 -1
- package/dist/src/chats/import.d.ts +8 -6
- package/dist/src/chats/import.js +195 -23
- package/dist/src/chats/input-file.d.ts +3 -0
- package/dist/src/chats/input-file.js +32 -0
- package/dist/src/chats/normalize.d.ts +11 -2
- package/dist/src/chats/normalize.js +18 -2
- package/dist/src/chats/previous-import.d.ts +5 -0
- package/dist/src/chats/previous-import.js +34 -0
- package/dist/src/chats/reader.d.ts +7 -1
- package/dist/src/chats/reader.js +46 -15
- package/dist/src/chats/redact-import.d.ts +14 -0
- package/dist/src/chats/redact-import.js +141 -0
- package/dist/src/chats/redaction.d.ts +41 -0
- package/dist/src/chats/redaction.js +161 -0
- package/dist/src/chats/reference-mapping.d.ts +16 -0
- package/dist/src/chats/reference-mapping.js +153 -0
- package/dist/src/chats/revision-input.d.ts +3 -0
- package/dist/src/chats/revision-input.js +180 -0
- package/dist/src/chats/revision.d.ts +48 -0
- package/dist/src/chats/revision.js +94 -0
- package/dist/src/chats/selection.d.ts +25 -0
- package/dist/src/chats/selection.js +109 -0
- package/dist/src/chats/source.d.ts +23 -0
- package/dist/src/chats/source.js +135 -0
- package/dist/src/chats/structure.d.ts +57 -0
- package/dist/src/chats/structure.js +216 -0
- package/dist/src/chats/workflow-generation-projection.d.ts +8 -0
- package/dist/src/chats/workflow-generation-projection.js +75 -0
- package/dist/src/chats/workflow-generation-source.d.ts +25 -0
- package/dist/src/chats/workflow-generation-source.js +124 -0
- package/dist/src/chats/workflow-generation-text.d.ts +23 -0
- package/dist/src/chats/workflow-generation-text.js +74 -0
- package/dist/src/chats/workflow-generation.d.ts +69 -0
- package/dist/src/chats/workflow-generation.js +142 -0
- package/dist/src/cli/arguments.d.ts +8 -0
- package/dist/src/cli/arguments.js +94 -13
- package/dist/src/cli/client.d.ts +1 -0
- package/dist/src/cli/client.js +38 -1
- package/dist/src/cli/commands.d.ts +3 -0
- package/dist/src/cli/commands.js +29 -11
- package/dist/src/cli/main.d.ts +2 -1
- package/dist/src/cli/main.js +61 -14
- package/dist/src/cli/render.d.ts +3 -0
- package/dist/src/cli/render.js +122 -7
- package/dist/src/cli/usage-render.d.ts +3 -0
- package/dist/src/cli/usage-render.js +28 -0
- package/dist/src/cli/usage.d.ts +3 -2
- package/dist/src/cli/usage.js +42 -7
- package/dist/src/cli/watch-actions.d.ts +10 -0
- package/dist/src/cli/watch-actions.js +58 -0
- package/dist/src/cli/watch-board-view.d.ts +44 -1
- package/dist/src/cli/watch-board-view.js +137 -18
- package/dist/src/cli/watch-board.d.ts +7 -1
- package/dist/src/cli/watch-board.js +48 -11
- package/dist/src/cli/watch-card-client.d.ts +1 -0
- package/dist/src/cli/watch-card-client.js +44 -0
- package/dist/src/cli/watch-card-forms.d.ts +2 -0
- package/dist/src/cli/watch-card-forms.js +33 -0
- package/dist/src/cli/watch-card-reply.d.ts +5 -0
- package/dist/src/cli/watch-card-reply.js +34 -0
- package/dist/src/cli/watch-card-view.d.ts +40 -0
- package/dist/src/cli/watch-card-view.js +86 -0
- package/dist/src/cli/watch-client.d.ts +1 -0
- package/dist/src/cli/watch-client.js +122 -0
- package/dist/src/cli/watch-model.d.ts +10 -4
- package/dist/src/cli/watch-model.js +61 -67
- package/dist/src/cli/watch-page.d.ts +1 -1
- package/dist/src/cli/watch-page.js +89 -86
- package/dist/src/cli/watch-phases.js +3 -3
- package/dist/src/cli/watch-pr-board.d.ts +3 -0
- package/dist/src/cli/watch-pr-board.js +26 -0
- package/dist/src/cli/watch-pr-command.d.ts +18 -0
- package/dist/src/cli/watch-pr-command.js +74 -0
- package/dist/src/cli/watch-pr-identity.d.ts +32 -0
- package/dist/src/cli/watch-pr-identity.js +87 -0
- package/dist/src/cli/watch-pr-observer.d.ts +20 -0
- package/dist/src/cli/watch-pr-observer.js +150 -0
- package/dist/src/cli/watch-pr-settings.d.ts +8 -0
- package/dist/src/cli/watch-pr-settings.js +47 -0
- package/dist/src/cli/watch-pull-request.d.ts +10 -0
- package/dist/src/cli/watch-pull-request.js +130 -0
- package/dist/src/cli/watch-reads.d.ts +7 -1
- package/dist/src/cli/watch-reads.js +44 -18
- package/dist/src/cli/watch-render.d.ts +29 -2
- package/dist/src/cli/watch-render.js +11 -3
- package/dist/src/cli/watch-run-input.d.ts +14 -0
- package/dist/src/cli/watch-run-input.js +49 -0
- package/dist/src/cli/watch-server.d.ts +3 -0
- package/dist/src/cli/watch-server.js +77 -8
- package/dist/src/cli/watch-start-view.d.ts +18 -0
- package/dist/src/cli/watch-start-view.js +77 -0
- package/dist/src/cli/watch-turn.d.ts +1 -0
- package/dist/src/cli/watch-turn.js +8 -3
- package/dist/src/cli/watch-usage.d.ts +6 -0
- package/dist/src/cli/watch-usage.js +65 -0
- package/dist/src/cli/watch-view.d.ts +22 -0
- package/dist/src/cli/watch-view.js +111 -19
- package/dist/src/cli.js +48 -6
- package/dist/src/daemon/analysis-launch.d.ts +5 -0
- package/dist/src/daemon/analysis-launch.js +81 -0
- package/dist/src/daemon/analysis-token.d.ts +6 -0
- package/dist/src/daemon/analysis-token.js +88 -0
- package/dist/src/daemon/analysis-worker.d.ts +20 -0
- package/dist/src/daemon/analysis-worker.js +271 -0
- package/dist/src/daemon/chats-batch-binding.d.ts +23 -0
- package/dist/src/daemon/chats-batch-binding.js +99 -0
- package/dist/src/daemon/chats-capture.d.ts +18 -0
- package/dist/src/daemon/chats-capture.js +194 -0
- package/dist/src/daemon/chats-checkpoints.d.ts +41 -0
- package/dist/src/daemon/chats-checkpoints.js +186 -0
- package/dist/src/daemon/chats-files.d.ts +42 -0
- package/dist/src/daemon/chats-files.js +252 -0
- package/dist/src/daemon/chats-follow-up.d.ts +38 -0
- package/dist/src/daemon/chats-follow-up.js +180 -0
- package/dist/src/daemon/chats-question.d.ts +15 -0
- package/dist/src/daemon/chats-question.js +93 -0
- package/dist/src/daemon/chats-worker.d.ts +13 -0
- package/dist/src/daemon/chats-worker.js +201 -0
- package/dist/src/daemon/claude-turn.d.ts +11 -0
- package/dist/src/daemon/claude-turn.js +96 -15
- package/dist/src/daemon/claude-worker.d.ts +2 -1
- package/dist/src/daemon/claude-worker.js +92 -45
- package/dist/src/daemon/codex-stream.js +16 -0
- package/dist/src/daemon/daemon.d.ts +8 -1
- package/dist/src/daemon/daemon.js +51 -14
- package/dist/src/daemon/delivery-router.js +6 -0
- package/dist/src/daemon/github-calls.d.ts +4 -0
- package/dist/src/daemon/github-calls.js +16 -7
- package/dist/src/daemon/github-ci.d.ts +6 -0
- package/dist/src/daemon/github-ci.js +170 -0
- package/dist/src/daemon/github-merge-call.d.ts +14 -0
- package/dist/src/daemon/github-merge-call.js +73 -0
- package/dist/src/daemon/github-merge.d.ts +3 -5
- package/dist/src/daemon/github-merge.js +52 -95
- package/dist/src/daemon/github-methods.d.ts +28 -0
- package/dist/src/daemon/github-methods.js +84 -16
- package/dist/src/daemon/github-operation.d.ts +2 -0
- package/dist/src/daemon/github-retry.d.ts +6 -0
- package/dist/src/daemon/github-retry.js +49 -0
- package/dist/src/daemon/github-ticket-status.d.ts +3 -0
- package/dist/src/daemon/github-ticket-status.js +294 -0
- package/dist/src/daemon/github-worker.js +2 -1
- package/dist/src/daemon/handoff-worker.d.ts +10 -0
- package/dist/src/daemon/handoff-worker.js +232 -0
- package/dist/src/daemon/issue-queue.d.ts +2 -0
- package/dist/src/daemon/issue-queue.js +186 -43
- package/dist/src/daemon/notify-journal.d.ts +18 -0
- package/dist/src/daemon/notify-journal.js +108 -0
- package/dist/src/daemon/notify-message.js +2 -1
- package/dist/src/daemon/notify.js +176 -37
- package/dist/src/daemon/operation-journal.d.ts +1 -0
- package/dist/src/daemon/operation-journal.js +4 -2
- package/dist/src/daemon/retrying-turn.d.ts +12 -0
- package/dist/src/daemon/retrying-turn.js +231 -0
- package/dist/src/daemon/ticket-dependency-waits.d.ts +18 -0
- package/dist/src/daemon/ticket-dependency-waits.js +60 -0
- package/dist/src/daemon/ticket-registration.d.ts +8 -4
- package/dist/src/daemon/ticket-registration.js +76 -22
- package/dist/src/daemon/ticket-source.d.ts +4 -1
- package/dist/src/daemon/ticket-source.js +8 -2
- package/dist/src/decision-visibility.d.ts +2 -0
- package/dist/src/decision-visibility.js +10 -0
- package/dist/src/execution-pin.d.ts +4 -0
- package/dist/src/execution-pin.js +23 -2
- package/dist/src/host/start-delivery.d.ts +2 -1
- package/dist/src/host/start-delivery.js +1 -1
- package/dist/src/host/step-bridge-host.d.ts +1 -0
- package/dist/src/host/step-bridge-host.js +16 -0
- package/dist/src/host/world-reconciliation.d.ts +3 -0
- package/dist/src/host/world-reconciliation.js +9 -0
- package/dist/src/host/world-runs.js +14 -1
- package/dist/src/issue-identity.d.ts +6 -0
- package/dist/src/issue-identity.js +23 -0
- package/dist/src/service/queue-runs.d.ts +3 -0
- package/dist/src/service/queue-runs.js +39 -0
- package/dist/src/service/registry.d.ts +8 -2
- package/dist/src/service/registry.js +20 -8
- package/dist/src/service/replies.d.ts +2 -0
- package/dist/src/service/run-handlers.js +54 -30
- package/dist/src/service/service.d.ts +3 -0
- package/dist/src/service/service.js +3 -1
- package/dist/src/service/submission-handler.d.ts +1 -0
- package/dist/src/service/submission-handler.js +92 -13
- package/dist/src/service/worker-totals.d.ts +3 -0
- package/dist/src/service/worker-totals.js +52 -0
- package/dist/src/step-bridge.d.ts +9 -0
- package/dist/src/steps/handoff.d.ts +2 -0
- package/dist/src/steps/handoff.js +13 -0
- package/dist/src/ticket-dependencies.d.ts +1 -0
- package/dist/src/ticket-dependencies.js +15 -0
- package/dist/src/ticket-status.d.ts +8 -0
- package/dist/src/ticket-status.js +48 -0
- package/dist/src/token-prices.d.ts +21 -0
- package/dist/src/token-prices.js +108 -0
- package/dist/src/worker-usage.d.ts +31 -0
- package/dist/src/worker-usage.js +44 -0
- package/dist/src/workflow-admission.d.ts +1 -0
- package/dist/src/workflow-candidate.d.ts +29 -0
- package/dist/src/workflow-candidate.js +60 -0
- package/dist/src/workflow-contracts.d.ts +4 -0
- package/dist/src/workflow-contracts.js +32 -5
- package/dist/src/workflow-declaration.d.ts +12 -1
- package/dist/src/workflow-declaration.js +71 -13
- package/dist/src/workflow-discovery.d.ts +18 -0
- package/dist/src/workflow-discovery.js +33 -0
- package/dist/src/workflow-refusals.d.ts +6 -0
- package/dist/src/workflow-refusals.js +39 -0
- package/dist/src/workflows.d.ts +3 -1
- package/dist/src/workflows.js +2 -0
- package/dist/tools/admit-workflow.d.ts +13 -0
- package/dist/tools/admit-workflow.js +94 -0
- package/dist/tools/self-host-processes.js +7 -2
- package/dist/tools/self-host-project.d.ts +17 -0
- package/dist/tools/self-host-project.js +177 -0
- package/dist/tools/self-host-workflows.d.ts +1 -1
- package/dist/tools/self-host-workflows.js +2 -2
- package/dist/tools/self-host.js +30 -84
- package/dist/tools/self-update-host.d.ts +7 -0
- package/dist/tools/self-update-host.js +48 -1
- package/dist/tools/self-update.d.ts +1 -0
- package/dist/tools/self-update.js +85 -13
- package/dist/tools/workflow-bundle-dependencies.d.ts +5 -0
- package/dist/tools/workflow-bundle-dependencies.js +93 -0
- package/dist/tools/workflow-bundles.d.ts +20 -0
- package/dist/tools/workflow-bundles.js +173 -0
- package/dist/tools/workflow-candidate-counts.d.ts +8 -0
- package/dist/tools/workflow-candidate-counts.js +251 -0
- package/dist/tools/workflow-candidate-program.d.ts +11 -0
- package/dist/tools/workflow-candidate-program.js +78 -0
- package/dist/tools/workflow-candidate-source.d.ts +6 -0
- package/dist/tools/workflow-candidate-source.js +107 -0
- package/dist/tools/workflow-candidate-syntax.d.ts +15 -0
- package/dist/tools/workflow-candidate-syntax.js +219 -0
- package/dist/tools/workflow-folder-capture.d.ts +17 -0
- package/dist/tools/workflow-folder-capture.js +216 -0
- package/dist/tools/workflow-folders.d.ts +33 -0
- package/dist/tools/workflow-folders.js +150 -0
- package/dist/tools/workflow-source-effects.d.ts +10 -0
- package/dist/tools/workflow-source-effects.js +213 -0
- package/dist/workflows/analyze-chats.d.ts +15 -0
- package/dist/workflows/analyze-chats.declaration.json +22 -0
- package/dist/workflows/analyze-chats.js +250 -0
- package/dist/workflows/develop-prd.js +71 -3
- package/dist/workflows/develop-ticket.d.ts +1 -7
- package/dist/workflows/develop-ticket.js +47 -141
- package/dist/workflows/issue-labels.d.ts +3 -1
- package/dist/workflows/issue-labels.js +34 -0
- package/dist/workflows/ticket-prompts.d.ts +35 -0
- package/dist/workflows/ticket-prompts.js +143 -0
- package/package.json +25 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isTicketStatus } from "../ticket-status.js";
|
|
1
2
|
import { gateContinuation } from "./gate-reduction.js";
|
|
2
|
-
import { isBlockedReason } from "../workflow-contracts.js";
|
|
3
|
+
import { isBlockedReason, isPromotionId } from "../workflow-contracts.js";
|
|
3
4
|
import { continues } from "./gates.js";
|
|
4
5
|
import { startOperation } from "./reduction.js";
|
|
5
6
|
import { terminal, } from "./transitions.js";
|
|
@@ -110,11 +111,26 @@ function moved(kind, observed) {
|
|
|
110
111
|
}
|
|
111
112
|
function completionOutcome(world) {
|
|
112
113
|
const { outcome, outcomeReason } = world;
|
|
113
|
-
if (outcome
|
|
114
|
+
if (outcome === "blocked")
|
|
115
|
+
return {
|
|
116
|
+
outcome,
|
|
117
|
+
...(isBlockedReason(outcomeReason) ? { outcomeReason } : {}),
|
|
118
|
+
};
|
|
119
|
+
if (outcome !== "handoff_requested")
|
|
114
120
|
return {};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
return {
|
|
122
|
+
outcome,
|
|
123
|
+
...(isBlockedReason(outcomeReason) ? { outcomeReason } : {}),
|
|
124
|
+
...(isPromotionId(world.promotionId)
|
|
125
|
+
? { promotionId: world.promotionId }
|
|
126
|
+
: {}),
|
|
127
|
+
...(world.issueUpdate === "failed"
|
|
128
|
+
? { issueUpdate: world.issueUpdate }
|
|
129
|
+
: {}),
|
|
130
|
+
...(isTicketStatus(world.ticketStatus)
|
|
131
|
+
? { ticketStatus: world.ticketStatus }
|
|
132
|
+
: {}),
|
|
133
|
+
};
|
|
118
134
|
}
|
|
119
135
|
function noted(observed, evidence) {
|
|
120
136
|
const { run, world, reason } = observed;
|
|
@@ -40,7 +40,7 @@ export interface AuthorityEvent {
|
|
|
40
40
|
readonly payload: Readonly<Record<string, string>>;
|
|
41
41
|
}
|
|
42
42
|
export declare const numberFields: readonly ["expectedRevision", "generation", "attempt", "limit", "effectLimit", "units", "recoveryLimit", "leaseGeneration", "sourceGeneration", "capacity"];
|
|
43
|
-
export declare const textFields: readonly ["workflow", "submission", "input", "resolver", "gateId", "gateKind", "subject", "prompt", "expiresAt", "decision", "answer", "condition", "reason", "evidence", "retryAt", "operationId", "receipt", "capabilities", "capability", "method", "target", "payload", "inputDigest", "resource", "transport", "source", "worker", "outcome", "outcomeReason", "result"];
|
|
43
|
+
export declare const textFields: readonly ["parentRunId", "chainId", "workflow", "submission", "input", "resolver", "gateId", "gateKind", "subject", "prompt", "expiresAt", "decision", "answer", "condition", "reason", "evidence", "retryAt", "operationId", "receipt", "capabilities", "capability", "method", "target", "payload", "inputDigest", "resource", "transport", "source", "worker", "outcome", "outcomeReason", "promotionId", "ticketStatus", "issueUpdate", "result"];
|
|
44
44
|
export type NumberField = (typeof numberFields)[number];
|
|
45
45
|
export type TextField = (typeof textFields)[number];
|
|
46
46
|
export type AuthorityCommand = {
|
|
@@ -31,6 +31,8 @@ export const numberFields = [
|
|
|
31
31
|
"capacity",
|
|
32
32
|
];
|
|
33
33
|
export const textFields = [
|
|
34
|
+
"parentRunId",
|
|
35
|
+
"chainId",
|
|
34
36
|
"workflow",
|
|
35
37
|
"submission",
|
|
36
38
|
"input",
|
|
@@ -60,6 +62,9 @@ export const textFields = [
|
|
|
60
62
|
"worker",
|
|
61
63
|
"outcome",
|
|
62
64
|
"outcomeReason",
|
|
65
|
+
"promotionId",
|
|
66
|
+
"ticketStatus",
|
|
67
|
+
"issueUpdate",
|
|
63
68
|
"result",
|
|
64
69
|
];
|
|
65
70
|
export const terminal = [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Database } from "solid-objects";
|
|
2
2
|
import type { AuthorityCommand, AuthorityEvent } from "../../authority/transitions.ts";
|
|
3
3
|
import { type SqlConnection } from "../../storage/domain-rows.ts";
|
|
4
|
+
import { type RunLinks, type RunOrigins } from "../../authority/handoff-chain.ts";
|
|
4
5
|
export interface CommandRecord {
|
|
5
6
|
readonly commandId: string;
|
|
6
7
|
readonly sequence: number;
|
|
@@ -28,6 +29,7 @@ export interface Sequences {
|
|
|
28
29
|
export interface CompletionCursor {
|
|
29
30
|
readonly runId: string;
|
|
30
31
|
readonly atOrBefore: number;
|
|
32
|
+
readonly terminal?: boolean;
|
|
31
33
|
}
|
|
32
34
|
export interface AuthorityQueries {
|
|
33
35
|
readonly document: (digest: string) => Promise<string | undefined>;
|
|
@@ -36,6 +38,8 @@ export interface AuthorityQueries {
|
|
|
36
38
|
readonly latestCompletion: (cursor: CompletionCursor) => Promise<PublishedEvent | undefined>;
|
|
37
39
|
readonly sequences: () => Promise<Sequences>;
|
|
38
40
|
readonly workflowIds: () => Promise<Readonly<Record<string, string>>>;
|
|
41
|
+
readonly runOrigins: () => Promise<RunOrigins>;
|
|
42
|
+
readonly runLinks: () => Promise<Readonly<Record<string, RunLinks>>>;
|
|
39
43
|
}
|
|
40
44
|
export type Read = <Value>(query: (connection: SqlConnection) => Promise<Value>) => Promise<Value>;
|
|
41
45
|
export declare function guardedRead(access: {
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { parseCommand } from "../../authority/commands.js";
|
|
2
2
|
import { documentBody } from "../../storage/decision-rows.js";
|
|
3
|
-
import { integer, latestSequence, text, } from "../../storage/domain-rows.js";
|
|
3
|
+
import { integer, optionalText, latestSequence, text, } from "../../storage/domain-rows.js";
|
|
4
4
|
import { storedEvents } from "../authority-restore.js";
|
|
5
5
|
import { documentDigest } from "../decision-restore.js";
|
|
6
|
+
import { runLinks, } from "../../authority/handoff-chain.js";
|
|
7
|
+
async function runOrigins(connection, cursor) {
|
|
8
|
+
const rows = await connection.all("SELECT run_id, json_extract(payload, '$.parentRunId') AS parent_run_id, coalesce(json_extract(payload, '$.chainId'), run_id) AS chain_id FROM events WHERE type = 'run.created' AND sequence > ? AND sequence <= ? ORDER BY sequence", [cursor.after, cursor.through]);
|
|
9
|
+
return Object.fromEntries(rows.map((row) => [
|
|
10
|
+
text(row, "run_id"),
|
|
11
|
+
{
|
|
12
|
+
parentRunId: optionalText(row, "parent_run_id"),
|
|
13
|
+
chainId: text(row, "chain_id"),
|
|
14
|
+
},
|
|
15
|
+
]));
|
|
16
|
+
}
|
|
6
17
|
async function receipt(connection, commandId) {
|
|
7
18
|
const row = await connection.get("SELECT c.request, c.sequence, e.run_id, e.recorded_at FROM commands c JOIN events e ON e.sequence = c.sequence WHERE c.command_id = ?", [commandId]);
|
|
8
19
|
if (row === undefined)
|
|
@@ -51,7 +62,10 @@ function publishedEvents(rows) {
|
|
|
51
62
|
}));
|
|
52
63
|
}
|
|
53
64
|
async function latestCompletion(connection, cursor) {
|
|
54
|
-
const
|
|
65
|
+
const types = cursor.terminal === true
|
|
66
|
+
? "type IN ('run.completed', 'run.failed', 'run.cancelled')"
|
|
67
|
+
: "type = 'run.completed'";
|
|
68
|
+
const row = await connection.get(`SELECT sequence, type, run_id, command_id, recorded_at, payload FROM events WHERE run_id = ? AND ${types} AND sequence <= ? ORDER BY sequence DESC LIMIT 1`, [cursor.runId, cursor.atOrBefore]);
|
|
55
69
|
return row === undefined ? undefined : publishedEvents([row])[0];
|
|
56
70
|
}
|
|
57
71
|
async function sequences(connection) {
|
|
@@ -66,6 +80,28 @@ async function workflowIds(connection) {
|
|
|
66
80
|
const rows = await connection.all("SELECT d.run_id, json_extract(s.body, '$.workflowId') AS workflow_id FROM run_details d JOIN documents s ON s.digest = d.submission WHERE json_valid(s.body) AND json_type(s.body, '$.workflowId') = 'text'");
|
|
67
81
|
return Object.fromEntries(rows.map((row) => [text(row, "run_id"), text(row, "workflow_id")]));
|
|
68
82
|
}
|
|
83
|
+
function cachedOrigins(read) {
|
|
84
|
+
let sequence = 0;
|
|
85
|
+
let origins = {};
|
|
86
|
+
let pending = Promise.resolve();
|
|
87
|
+
return () => {
|
|
88
|
+
const result = pending.then(() => read(async (connection) => {
|
|
89
|
+
const through = await latestSequence(connection);
|
|
90
|
+
if (through === sequence)
|
|
91
|
+
return origins;
|
|
92
|
+
const added = await runOrigins(connection, {
|
|
93
|
+
after: sequence,
|
|
94
|
+
through,
|
|
95
|
+
});
|
|
96
|
+
if (Object.keys(added).length > 0)
|
|
97
|
+
origins = { ...origins, ...added };
|
|
98
|
+
sequence = through;
|
|
99
|
+
return origins;
|
|
100
|
+
}));
|
|
101
|
+
pending = result.then(() => undefined, () => undefined);
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
69
105
|
export function guardedRead(access) {
|
|
70
106
|
const { reader, ready } = access;
|
|
71
107
|
return async (query) => {
|
|
@@ -74,6 +110,17 @@ export function guardedRead(access) {
|
|
|
74
110
|
};
|
|
75
111
|
}
|
|
76
112
|
export function authorityQueries(read) {
|
|
113
|
+
const origins = cachedOrigins(read);
|
|
114
|
+
let linkedOrigins;
|
|
115
|
+
let links = {};
|
|
116
|
+
const currentLinks = async () => {
|
|
117
|
+
const current = await origins();
|
|
118
|
+
if (current !== linkedOrigins) {
|
|
119
|
+
links = runLinks(current);
|
|
120
|
+
linkedOrigins = current;
|
|
121
|
+
}
|
|
122
|
+
return links;
|
|
123
|
+
};
|
|
77
124
|
return {
|
|
78
125
|
document: (digest) => read((connection) => documentBody(connection, digest)),
|
|
79
126
|
receipt: (commandId) => read((connection) => receipt(connection, commandId)),
|
|
@@ -81,5 +128,7 @@ export function authorityQueries(read) {
|
|
|
81
128
|
latestCompletion: (cursor) => read((connection) => latestCompletion(connection, cursor)),
|
|
82
129
|
sequences: () => read(sequences),
|
|
83
130
|
workflowIds: () => read(workflowIds),
|
|
131
|
+
runOrigins: origins,
|
|
132
|
+
runLinks: currentLinks,
|
|
84
133
|
};
|
|
85
134
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Database, JsonObject } from "solid-objects";
|
|
2
2
|
import { type AuthorityEvent, type EffectIntent } from "../../authority/reducer.ts";
|
|
3
|
+
import { type ProjectionSnapshot } from "../../storage/decision-snapshots.ts";
|
|
3
4
|
import type { AdmissionResult, ExecutionManifest } from "../../workflow-admission.ts";
|
|
4
5
|
import { type StoredState } from "../authority-restore.ts";
|
|
5
6
|
import { type SequenceChanges, type SequenceListener } from "./authority-changes.ts";
|
|
@@ -63,3 +64,4 @@ export interface SessionParts {
|
|
|
63
64
|
readonly subscribe: (listener: SequenceListener) => () => void;
|
|
64
65
|
}
|
|
65
66
|
export declare function authoritySession(parts: SessionParts): Authority;
|
|
67
|
+
export declare function operationRecords(snapshot: Pick<ProjectionSnapshot, "outbox" | "deliveries">): readonly OperationRecord[];
|
|
@@ -221,16 +221,15 @@ async function healthyReceipt(session, value) {
|
|
|
221
221
|
await refreshed(session);
|
|
222
222
|
return receipt;
|
|
223
223
|
}
|
|
224
|
-
function operationRecords(snapshot) {
|
|
224
|
+
export function operationRecords(snapshot) {
|
|
225
|
+
const deliveries = Map.groupBy(snapshot.deliveries, (row) => row.operationId);
|
|
225
226
|
return snapshot.outbox.map((row) => ({
|
|
226
227
|
operationId: row.operationId,
|
|
227
228
|
kind: intentKind(row.kind),
|
|
228
229
|
runId: row.runId,
|
|
229
230
|
createdSequence: row.createdSequence,
|
|
230
231
|
releasedSequence: row.releasedSequence,
|
|
231
|
-
deliveries:
|
|
232
|
-
.filter((delivery) => delivery.operationId === row.operationId)
|
|
233
|
-
.map(({ effectId, outcome, receipt, purpose, epoch }) => ({
|
|
232
|
+
deliveries: (deliveries.get(row.operationId) ?? []).map(({ effectId, outcome, receipt, purpose, epoch }) => ({
|
|
234
233
|
effectId,
|
|
235
234
|
outcome,
|
|
236
235
|
receipt,
|
|
@@ -51,6 +51,7 @@ export interface Delivery {
|
|
|
51
51
|
readonly worker?: string;
|
|
52
52
|
} | AdapterOutcome>;
|
|
53
53
|
readonly reconcile: (intent: DeliveryIntent, signal: AbortSignal) => Promise<AdapterOutcome>;
|
|
54
|
+
readonly retry?: Delivery["reconcile"];
|
|
54
55
|
readonly stop?: (intent: DeliveryIntent, signal: AbortSignal) => Promise<AdapterOutcome>;
|
|
55
56
|
}
|
|
56
57
|
export type AvailableManifest = (pinned: ExecutionManifest) => ExecutionManifest | undefined;
|
|
@@ -69,9 +69,16 @@ function decided(parts, attempt) {
|
|
|
69
69
|
}), {
|
|
70
70
|
intent: { ...intent, computedDigest: effectInputDigest(intent) },
|
|
71
71
|
now,
|
|
72
|
+
...(attempt.mode === undefined ? {} : { mode: attempt.mode }),
|
|
72
73
|
}));
|
|
73
74
|
}
|
|
74
75
|
const withheld = { kind: "withheld" };
|
|
76
|
+
async function retryEffect(parts, attempt) {
|
|
77
|
+
const retry = await decided(parts, { ...attempt, mode: "retry" });
|
|
78
|
+
return retry === "send"
|
|
79
|
+
? called(parts, { intent: attempt.intent, name: "retry" })
|
|
80
|
+
: attempt.known;
|
|
81
|
+
}
|
|
75
82
|
function unsent(decision) {
|
|
76
83
|
return decision === "stale" ? withheld : { kind: decision };
|
|
77
84
|
}
|
|
@@ -83,6 +90,8 @@ async function attempted(parts, attempt) {
|
|
|
83
90
|
if (intent.purpose === "stop")
|
|
84
91
|
return stopRequested(parts, intent);
|
|
85
92
|
const known = await called(parts, { intent, name: "reconcile" });
|
|
93
|
+
if (known.kind === "unknown" && parts.delivery.retry !== undefined)
|
|
94
|
+
return retryEffect(parts, { ...attempt, known });
|
|
86
95
|
if (known.kind !== "absent" || intent.purpose === "reconcile")
|
|
87
96
|
return known;
|
|
88
97
|
if (first !== "send")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseCommand } from "../authority/commands.js";
|
|
2
|
-
import { readExecutionManifest, resumePinned } from "../execution-pin.js";
|
|
2
|
+
import { executionCapabilities, readExecutionManifest, resumePinned, } from "../execution-pin.js";
|
|
3
3
|
import { effectInputDigest } from "./effect-restore.js";
|
|
4
4
|
import { workflowPin } from "./workflow-pin.js";
|
|
5
5
|
const admissible = { kind: "admissible", definitions: new Map() };
|
|
@@ -15,7 +15,7 @@ const admission = (command, context) => {
|
|
|
15
15
|
const pin = workflowPin(stored);
|
|
16
16
|
if (command.workflow !== pin)
|
|
17
17
|
return { kind: "rejected", reason: "workflow-pin-mismatch" };
|
|
18
|
-
const capabilities =
|
|
18
|
+
const capabilities = executionCapabilities(stored);
|
|
19
19
|
if ((command.capabilities ?? capabilities) !== capabilities)
|
|
20
20
|
return { kind: "rejected", reason: "capability-pin-mismatch" };
|
|
21
21
|
return { kind: "admissible", definitions: new Map([[pin, stored]]) };
|
|
@@ -40,9 +40,17 @@ const effectRequest = (command, context) => {
|
|
|
40
40
|
target: String(command.target),
|
|
41
41
|
payload: String(command.payload),
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (computed !== command.inputDigest)
|
|
44
|
+
return { kind: "rejected", reason: "input-digest-mismatch" };
|
|
45
|
+
if (command.capability !== "handoff")
|
|
46
|
+
return unpinned(command, context);
|
|
47
|
+
const pin = context.state.runs[command.runId]?.workflow ?? "";
|
|
48
|
+
const declaration = context.definitions.get(pin);
|
|
49
|
+
if (!declaration?.handoffs?.includes(String(command.target)))
|
|
50
|
+
return { kind: "rejected", reason: "handoff-not-declared" };
|
|
51
|
+
if (command.units !== 1 || command.method !== "run")
|
|
52
|
+
return { kind: "rejected", reason: "invalid-handoff-request" };
|
|
53
|
+
return unpinned(command, context);
|
|
46
54
|
};
|
|
47
55
|
const rules = {
|
|
48
56
|
"request-effect": effectRequest,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AnalysisResult } from "./analysis-contract.ts";
|
|
2
|
+
import { type AnalysisSnapshot } from "./analysis-input.ts";
|
|
3
|
+
import { type AnalysisBatchContext } from "./analysis-prompt.ts";
|
|
4
|
+
export interface AnalysisBatchPosition {
|
|
5
|
+
readonly nextRecordIndex: number;
|
|
6
|
+
readonly completedBatchCount: number;
|
|
7
|
+
readonly previousResult: AnalysisResult | null;
|
|
8
|
+
}
|
|
9
|
+
export interface AnalysisBatch {
|
|
10
|
+
readonly kind: "batch";
|
|
11
|
+
readonly batchIndex: number;
|
|
12
|
+
readonly firstRecordIndex: number;
|
|
13
|
+
readonly nextRecordIndex: number;
|
|
14
|
+
readonly totalRecords: number;
|
|
15
|
+
readonly snapshot: AnalysisSnapshot;
|
|
16
|
+
readonly prompt: string;
|
|
17
|
+
readonly launchBytes: number;
|
|
18
|
+
readonly adapterDocument: string;
|
|
19
|
+
readonly context: AnalysisBatchContext;
|
|
20
|
+
}
|
|
21
|
+
export type AnalysisBatchPreparation = AnalysisBatch | {
|
|
22
|
+
readonly kind: "refused";
|
|
23
|
+
readonly code: "analysis-input-refused" | "analysis-too-large" | "analysis-batch-limit";
|
|
24
|
+
};
|
|
25
|
+
export declare const analysisCaptureBytes = 52428800;
|
|
26
|
+
export declare function analysisBatchData(batch: AnalysisBatch, capture: {
|
|
27
|
+
readonly digest: string;
|
|
28
|
+
readonly snapshot?: AnalysisSnapshot;
|
|
29
|
+
}): {
|
|
30
|
+
snapshot: AnalysisSnapshot;
|
|
31
|
+
context?: never;
|
|
32
|
+
batch?: never;
|
|
33
|
+
} | {
|
|
34
|
+
snapshot: AnalysisSnapshot;
|
|
35
|
+
context: AnalysisBatchContext;
|
|
36
|
+
batch: {
|
|
37
|
+
batchIndex: number;
|
|
38
|
+
nextRecordIndex: number;
|
|
39
|
+
capturedDigest: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare function prepareAnalysisBatch(snapshot: AnalysisSnapshot, position: AnalysisBatchPosition): AnalysisBatchPreparation;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { analysisDocumentBytes, analysisEvidence, isAnalysisSnapshot, validAnalysisImportId, } from "./analysis-input.js";
|
|
2
|
+
import { analysisLaunchBytes, analysisPrompt, } from "./analysis-prompt.js";
|
|
3
|
+
export const analysisCaptureBytes = 52_428_800;
|
|
4
|
+
export function analysisBatchData(batch, capture) {
|
|
5
|
+
if (batch.batchIndex === 0 && batch.nextRecordIndex === batch.totalRecords)
|
|
6
|
+
return { snapshot: capture.snapshot ?? batch.snapshot };
|
|
7
|
+
return {
|
|
8
|
+
snapshot: batch.snapshot,
|
|
9
|
+
context: batch.context,
|
|
10
|
+
batch: {
|
|
11
|
+
batchIndex: batch.batchIndex,
|
|
12
|
+
nextRecordIndex: batch.nextRecordIndex,
|
|
13
|
+
capturedDigest: capture.digest,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function prepareAnalysisBatch(snapshot, position) {
|
|
18
|
+
if (!isAnalysisSnapshot(snapshot) ||
|
|
19
|
+
!validAnalysisImportId(snapshot.importId))
|
|
20
|
+
return { kind: "refused", code: "analysis-input-refused" };
|
|
21
|
+
if (Buffer.byteLength(snapshot.corpus) > analysisCaptureBytes ||
|
|
22
|
+
[snapshot.redaction, snapshot.structure].some((text) => Buffer.byteLength(text) > analysisDocumentBytes))
|
|
23
|
+
return { kind: "refused", code: "analysis-too-large" };
|
|
24
|
+
try {
|
|
25
|
+
return preparedBatch(snapshot, position);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { kind: "refused", code: "analysis-input-refused" };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function preparedBatch(snapshot, position) {
|
|
32
|
+
const lines = snapshot.corpus.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
33
|
+
if (![position.nextRecordIndex, position.completedBatchCount].every(Number.isSafeInteger) ||
|
|
34
|
+
position.nextRecordIndex < 0 ||
|
|
35
|
+
position.nextRecordIndex >= lines.length ||
|
|
36
|
+
position.completedBatchCount < 0 ||
|
|
37
|
+
position.completedBatchCount > 4)
|
|
38
|
+
return { kind: "refused", code: "analysis-input-refused" };
|
|
39
|
+
if (position.completedBatchCount === 4)
|
|
40
|
+
return { kind: "refused", code: "analysis-batch-limit" };
|
|
41
|
+
const structure = analysisEvidence(snapshot).structure;
|
|
42
|
+
let longest = {
|
|
43
|
+
kind: "refused",
|
|
44
|
+
code: "analysis-too-large",
|
|
45
|
+
};
|
|
46
|
+
for (let end = position.nextRecordIndex + 1; end <= lines.length; end++) {
|
|
47
|
+
const batch = batchOf(snapshot, { lines, position, end, structure });
|
|
48
|
+
if (Math.max(batch.launchBytes, Buffer.byteLength(batch.adapterDocument)) >
|
|
49
|
+
analysisDocumentBytes)
|
|
50
|
+
break;
|
|
51
|
+
longest = batch;
|
|
52
|
+
}
|
|
53
|
+
return longest;
|
|
54
|
+
}
|
|
55
|
+
function batchOf(snapshot, input) {
|
|
56
|
+
const { position, lines, end } = input;
|
|
57
|
+
const batchSnapshot = {
|
|
58
|
+
...snapshot,
|
|
59
|
+
corpus: lines.slice(position.nextRecordIndex, end).join(""),
|
|
60
|
+
structure: projectedStructure(snapshot.importId, input),
|
|
61
|
+
};
|
|
62
|
+
const context = {
|
|
63
|
+
batchIndex: position.completedBatchCount,
|
|
64
|
+
firstRecordIndex: position.nextRecordIndex,
|
|
65
|
+
previousResult: position.previousResult,
|
|
66
|
+
};
|
|
67
|
+
const prompt = analysisPrompt(batchSnapshot, context);
|
|
68
|
+
return {
|
|
69
|
+
kind: "batch",
|
|
70
|
+
batchIndex: context.batchIndex,
|
|
71
|
+
firstRecordIndex: context.firstRecordIndex,
|
|
72
|
+
nextRecordIndex: end,
|
|
73
|
+
totalRecords: lines.length,
|
|
74
|
+
snapshot: batchSnapshot,
|
|
75
|
+
prompt,
|
|
76
|
+
launchBytes: analysisLaunchBytes(prompt),
|
|
77
|
+
adapterDocument: JSON.stringify({ snapshot: batchSnapshot, context }),
|
|
78
|
+
context,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function projectedStructure(importId, input) {
|
|
82
|
+
const { structure, position, end } = input;
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
schemaVersion: 1,
|
|
85
|
+
importId,
|
|
86
|
+
historyCompleteness: structure.historyCompleteness,
|
|
87
|
+
occurrences: structure.occurrences.slice(position.nextRecordIndex, end),
|
|
88
|
+
conflictGroups: structure.conflictGroups
|
|
89
|
+
.map((group) => ({
|
|
90
|
+
uuid: group.uuid,
|
|
91
|
+
variants: group.variants
|
|
92
|
+
.map((variant) => variant.filter((reference) => reference.recordIndex < end))
|
|
93
|
+
.filter((variant) => variant.length > 0),
|
|
94
|
+
}))
|
|
95
|
+
.filter((group) => group.variants.length > 0),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AnalysisResult } from "./analysis-contract.ts";
|
|
2
|
+
export interface AnalysisCheckpoint {
|
|
3
|
+
readonly schemaVersion: 1;
|
|
4
|
+
readonly runId: string;
|
|
5
|
+
readonly importId: string;
|
|
6
|
+
readonly capturedDigest: string;
|
|
7
|
+
readonly batchIndex: number | null;
|
|
8
|
+
readonly status: "partial" | "complete";
|
|
9
|
+
readonly result: AnalysisResult | null;
|
|
10
|
+
readonly total: number;
|
|
11
|
+
readonly covered: number;
|
|
12
|
+
readonly uncovered: number;
|
|
13
|
+
readonly completedBatchCount: number;
|
|
14
|
+
readonly nextRecordIndex: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AnalysisCheckpointCapture {
|
|
17
|
+
readonly runId: string;
|
|
18
|
+
readonly importId: string;
|
|
19
|
+
readonly digest: string;
|
|
20
|
+
readonly totalRecords: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function initialAnalysisCheckpoint(capture: AnalysisCheckpointCapture): AnalysisCheckpoint;
|
|
23
|
+
export declare function batchAnalysisCheckpoint(capture: AnalysisCheckpointCapture, position: {
|
|
24
|
+
readonly batchIndex: number;
|
|
25
|
+
readonly nextRecordIndex: number;
|
|
26
|
+
readonly result: AnalysisResult;
|
|
27
|
+
}): AnalysisCheckpoint & {
|
|
28
|
+
readonly result: AnalysisResult;
|
|
29
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function initialAnalysisCheckpoint(capture) {
|
|
2
|
+
return {
|
|
3
|
+
schemaVersion: 1,
|
|
4
|
+
runId: capture.runId,
|
|
5
|
+
importId: capture.importId,
|
|
6
|
+
capturedDigest: capture.digest,
|
|
7
|
+
batchIndex: null,
|
|
8
|
+
status: "partial",
|
|
9
|
+
result: null,
|
|
10
|
+
total: capture.totalRecords,
|
|
11
|
+
covered: 0,
|
|
12
|
+
uncovered: capture.totalRecords,
|
|
13
|
+
completedBatchCount: 0,
|
|
14
|
+
nextRecordIndex: 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function batchAnalysisCheckpoint(capture, position) {
|
|
18
|
+
return {
|
|
19
|
+
...initialAnalysisCheckpoint(capture),
|
|
20
|
+
batchIndex: position.batchIndex,
|
|
21
|
+
status: position.nextRecordIndex === capture.totalRecords &&
|
|
22
|
+
position.result.openQuestion === undefined
|
|
23
|
+
? "complete"
|
|
24
|
+
: "partial",
|
|
25
|
+
result: position.result,
|
|
26
|
+
covered: position.nextRecordIndex,
|
|
27
|
+
uncovered: capture.totalRecords - position.nextRecordIndex,
|
|
28
|
+
completedBatchCount: position.batchIndex + 1,
|
|
29
|
+
nextRecordIndex: position.nextRecordIndex,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { MessageRecord } from "./normalize.ts";
|
|
2
|
+
import type { ImportStructure, OccurrenceReference } from "./structure.ts";
|
|
3
|
+
export declare const analysisCodes: readonly ["not-plain-data", "unknown-version", "invalid-shape", "unknown-kind", "unknown-decision-type", "invalid-question", "question-without-conflict", "missing-source", "unknown-source", "copy-only", "insufficient-repetition", "invalid-loop-limit", "gate-on-non-gate", "authority-field"];
|
|
4
|
+
export type AnalysisCode = (typeof analysisCodes)[number];
|
|
5
|
+
export type ClaimKind = "explicit-human-instruction" | "observed-repetition" | "assistant-claim" | "exception" | "rejected-approach" | "uncertain-inference";
|
|
6
|
+
export type StageActivity = "work" | "routine-repair" | "accidental-interruption" | "tool-imposed-confirmation";
|
|
7
|
+
export type DecisionType = "design-decision" | "configured-action-approval" | "factual-input";
|
|
8
|
+
export interface AnalysisItem {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AnalysisClaim extends AnalysisItem {
|
|
13
|
+
readonly kind: ClaimKind;
|
|
14
|
+
readonly sourceRefs: readonly OccurrenceReference[];
|
|
15
|
+
readonly counterevidenceRefs: readonly OccurrenceReference[];
|
|
16
|
+
}
|
|
17
|
+
export interface AnalysisStage extends AnalysisClaim {
|
|
18
|
+
readonly activity: StageActivity;
|
|
19
|
+
}
|
|
20
|
+
export interface AnalysisGate extends AnalysisClaim {
|
|
21
|
+
readonly stageId: string;
|
|
22
|
+
readonly type: DecisionType;
|
|
23
|
+
}
|
|
24
|
+
export interface AnalysisLoop extends AnalysisClaim {
|
|
25
|
+
readonly stageIds: readonly string[];
|
|
26
|
+
readonly maxIterations: number;
|
|
27
|
+
readonly exitCondition: string;
|
|
28
|
+
readonly exhaustedStoppingConditionId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface AnalysisBranch extends AnalysisItem {
|
|
31
|
+
readonly sourceStageId: string;
|
|
32
|
+
readonly condition: string;
|
|
33
|
+
readonly targetStageId: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AnalysisNonGate extends AnalysisItem {
|
|
36
|
+
readonly stageId: string;
|
|
37
|
+
readonly reason: Exclude<StageActivity, "work">;
|
|
38
|
+
}
|
|
39
|
+
export interface AnalysisProcess {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly scope: string;
|
|
43
|
+
readonly inputs: readonly AnalysisItem[];
|
|
44
|
+
readonly stages: readonly AnalysisStage[];
|
|
45
|
+
readonly branches: readonly AnalysisBranch[];
|
|
46
|
+
readonly loops: readonly AnalysisLoop[];
|
|
47
|
+
readonly artifacts: readonly AnalysisItem[];
|
|
48
|
+
readonly stoppingConditions: readonly AnalysisItem[];
|
|
49
|
+
readonly gates: readonly AnalysisGate[];
|
|
50
|
+
readonly nonGates: readonly AnalysisNonGate[];
|
|
51
|
+
}
|
|
52
|
+
export interface AnalysisCandidate {
|
|
53
|
+
readonly schemaVersion: 1;
|
|
54
|
+
readonly process: AnalysisProcess;
|
|
55
|
+
readonly openQuestion?: AnalysisQuestion;
|
|
56
|
+
}
|
|
57
|
+
export interface AnalysisQuestion {
|
|
58
|
+
readonly claimId: string;
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly sourceRefs: readonly OccurrenceReference[];
|
|
61
|
+
readonly choices: readonly AnalysisItem[];
|
|
62
|
+
}
|
|
63
|
+
export interface AnalysisEvidence {
|
|
64
|
+
readonly records: readonly MessageRecord[];
|
|
65
|
+
readonly structure: ImportStructure;
|
|
66
|
+
}
|
|
67
|
+
export interface AnalysisResult extends AnalysisCandidate {
|
|
68
|
+
readonly limitations: {
|
|
69
|
+
readonly historyCompleteness: "unknown";
|
|
70
|
+
readonly independentObservations: "not-established";
|
|
71
|
+
readonly conflictGroups: ImportStructure["conflictGroups"];
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export type AnalysisValidation = {
|
|
75
|
+
readonly accepted: true;
|
|
76
|
+
readonly result: AnalysisResult;
|
|
77
|
+
} | {
|
|
78
|
+
readonly accepted: false;
|
|
79
|
+
readonly codes: readonly AnalysisCode[];
|
|
80
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const analysisCodes = [
|
|
2
|
+
"not-plain-data",
|
|
3
|
+
"unknown-version",
|
|
4
|
+
"invalid-shape",
|
|
5
|
+
"unknown-kind",
|
|
6
|
+
"unknown-decision-type",
|
|
7
|
+
"invalid-question",
|
|
8
|
+
"question-without-conflict",
|
|
9
|
+
"missing-source",
|
|
10
|
+
"unknown-source",
|
|
11
|
+
"copy-only",
|
|
12
|
+
"insufficient-repetition",
|
|
13
|
+
"invalid-loop-limit",
|
|
14
|
+
"gate-on-non-gate",
|
|
15
|
+
"authority-field",
|
|
16
|
+
];
|