@tacuchi/agent-workflow-cli 21.0.0 → 21.3.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 +3 -2
- package/dist/adapters/git-cli.js +12 -7
- package/dist/adapters/git-cli.js.map +1 -1
- package/dist/application/capability/compose.js +161 -0
- package/dist/application/capability/compose.js.map +1 -0
- package/dist/application/capability/descriptor-loader.js +109 -0
- package/dist/application/capability/descriptor-loader.js.map +1 -0
- package/dist/application/capability/design-handler.js +299 -0
- package/dist/application/capability/design-handler.js.map +1 -0
- package/dist/application/capability/dispatcher.js +312 -0
- package/dist/application/capability/dispatcher.js.map +1 -0
- package/dist/application/capability/durable-effect.js +220 -0
- package/dist/application/capability/durable-effect.js.map +1 -0
- package/dist/application/capability/installed-inventory.js +168 -0
- package/dist/application/capability/installed-inventory.js.map +1 -0
- package/dist/application/capability/readiness.js +204 -0
- package/dist/application/capability/readiness.js.map +1 -0
- package/dist/application/capability/resolution.js +264 -0
- package/dist/application/capability/resolution.js.map +1 -0
- package/dist/application/capability/wrapper.js +195 -0
- package/dist/application/capability/wrapper.js.map +1 -0
- package/dist/application/context/manifest.js +11 -5
- package/dist/application/context/manifest.js.map +1 -1
- package/dist/application/context/measure.js +5 -2
- package/dist/application/context/measure.js.map +1 -1
- package/dist/application/context/plan-service.js +6 -6
- package/dist/application/context/plan-service.js.map +1 -1
- package/dist/application/design/design-bundle-service.js +148 -0
- package/dist/application/design/design-bundle-service.js.map +1 -0
- package/dist/application/design/design-proposal-service.js +69 -0
- package/dist/application/design/design-proposal-service.js.map +1 -0
- package/dist/application/design/design-publish-service.js +275 -7
- package/dist/application/design/design-publish-service.js.map +1 -1
- package/dist/application/design/design-record-service.js +100 -0
- package/dist/application/design/design-record-service.js.map +1 -0
- package/dist/application/flow/advance.js +533 -0
- package/dist/application/flow/advance.js.map +1 -0
- package/dist/application/flow/flow-service.js +65 -0
- package/dist/application/flow/flow-service.js.map +1 -0
- package/dist/application/flow/run-projection.js +80 -0
- package/dist/application/flow/run-projection.js.map +1 -0
- package/dist/application/flow/run-state-service.js +107 -0
- package/dist/application/flow/run-state-service.js.map +1 -0
- package/dist/application/flow/submit.js +423 -0
- package/dist/application/flow/submit.js.map +1 -0
- package/dist/application/markdown.js +16 -2
- package/dist/application/markdown.js.map +1 -1
- package/dist/application/resume-service.js +23 -10
- package/dist/application/resume-service.js.map +1 -1
- package/dist/application/self/hooks-toml.js +137 -17
- package/dist/application/self/hooks-toml.js.map +1 -1
- package/dist/application/self/host-states.js +87 -1
- package/dist/application/self/host-states.js.map +1 -1
- package/dist/application/self/install-hooks.js +62 -6
- package/dist/application/self/install-hooks.js.map +1 -1
- package/dist/application/self/install-skill.js +37 -6
- package/dist/application/self/install-skill.js.map +1 -1
- package/dist/application/self/uninstall.js +21 -0
- package/dist/application/self/uninstall.js.map +1 -1
- package/dist/application/skills-resolver-service.js +8 -2
- package/dist/application/skills-resolver-service.js.map +1 -1
- package/dist/application/status-service.js +4 -1
- package/dist/application/status-service.js.map +1 -1
- package/dist/application/workline-index-service.js +15 -2
- package/dist/application/workline-index-service.js.map +1 -1
- package/dist/application/workspace-init-service.js +13 -1
- package/dist/application/workspace-init-service.js.map +1 -1
- package/dist/cli/commands/capability.js +182 -0
- package/dist/cli/commands/capability.js.map +1 -0
- package/dist/cli/commands/flow.js +71 -0
- package/dist/cli/commands/flow.js.map +1 -0
- package/dist/cli/commands/index.js +4 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/skills.js +55 -2
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/status.js +5 -0
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/help-groups.js +6 -0
- package/dist/cli/help-groups.js.map +1 -1
- package/dist/cli/parser.js +6 -0
- package/dist/cli/parser.js.map +1 -1
- package/dist/cli/tui/components/host-admin-section.js +14 -2
- package/dist/cli/tui/components/host-admin-section.js.map +1 -1
- package/dist/cli/tui/data/workflow-content.js +13 -1
- package/dist/cli/tui/data/workflow-content.js.map +1 -1
- package/dist/cli/tui/tabs/workflow-tab.js +8 -1
- package/dist/cli/tui/tabs/workflow-tab.js.map +1 -1
- package/dist/domain/capability/descriptor.js +553 -0
- package/dist/domain/capability/descriptor.js.map +1 -0
- package/dist/domain/capability/effects.js +90 -0
- package/dist/domain/capability/effects.js.map +1 -0
- package/dist/domain/capability/protocol.js +494 -0
- package/dist/domain/capability/protocol.js.map +1 -0
- package/dist/domain/contract-reader.js +84 -0
- package/dist/domain/contract-reader.js.map +1 -0
- package/dist/domain/design/adapter.js +161 -0
- package/dist/domain/design/adapter.js.map +1 -0
- package/dist/domain/design/artifact.js +148 -4
- package/dist/domain/design/artifact.js.map +1 -1
- package/dist/domain/design/capability.js +263 -4
- package/dist/domain/design/capability.js.map +1 -1
- package/dist/domain/design/direct.js +108 -0
- package/dist/domain/design/direct.js.map +1 -0
- package/dist/domain/design/external-send.js +65 -0
- package/dist/domain/design/external-send.js.map +1 -0
- package/dist/domain/design/maturity.js +71 -0
- package/dist/domain/design/maturity.js.map +1 -1
- package/dist/domain/design/offline.js +92 -0
- package/dist/domain/design/offline.js.map +1 -0
- package/dist/domain/design/profiles.js +212 -0
- package/dist/domain/design/profiles.js.map +1 -0
- package/dist/domain/design/proposal.js +234 -0
- package/dist/domain/design/proposal.js.map +1 -0
- package/dist/domain/design/render-bundle.js +0 -0
- package/dist/domain/design/render-bundle.js.map +1 -0
- package/dist/domain/design/rendition.js +472 -0
- package/dist/domain/design/rendition.js.map +1 -0
- package/dist/domain/design/sources.js +180 -0
- package/dist/domain/design/sources.js.map +1 -0
- package/dist/domain/design/validation.js +12 -68
- package/dist/domain/design/validation.js.map +1 -1
- package/dist/domain/design/visual-evidence.js +155 -0
- package/dist/domain/design/visual-evidence.js.map +1 -0
- package/dist/domain/flow/answer.js +459 -0
- package/dist/domain/flow/answer.js.map +1 -0
- package/dist/domain/flow/authority.js +2338 -0
- package/dist/domain/flow/authority.js.map +1 -0
- package/dist/domain/flow/authorization.js +62 -0
- package/dist/domain/flow/authorization.js.map +1 -0
- package/dist/domain/flow/directive.js +421 -0
- package/dist/domain/flow/directive.js.map +1 -0
- package/dist/domain/flow/rules.js +140 -0
- package/dist/domain/flow/rules.js.map +1 -0
- package/dist/domain/flow/run-state.js +317 -0
- package/dist/domain/flow/run-state.js.map +1 -0
- package/dist/domain/harnesses.js +124 -4
- package/dist/domain/harnesses.js.map +1 -1
- package/dist/domain/host-verification.js +8 -8
- package/dist/domain/skills.js +13 -14
- package/dist/domain/skills.js.map +1 -1
- package/dist/domain/structured-choice-stamp.js +106 -0
- package/dist/domain/structured-choice-stamp.js.map +1 -0
- package/package.json +1 -1
- package/skills/w/SKILL.md +5 -5
- package/skills/w/context/MANIFEST.json +42 -1
- package/skills/w/harness/HARNESS.md +30 -4
- package/skills/w/loops/CHASSIS.md +11 -20
- package/skills/w/loops/CODE-POLICIES.md +9 -15
- package/skills/w/loops/plan-exec-loop/LOOP.md +11 -13
- package/skills/w/loops/plan-new-loop/LOOP.md +6 -4
- package/skills/w/loops/plan-refine-loop/LOOP.md +5 -3
- package/skills/w/loops/quick-loop/LOOP.md +18 -26
- package/skills/w/loops/spec-refine-loop/LOOP.md +14 -18
- package/skills/w/modules/COMPACTION.md +2 -6
- package/skills/w/modules/DB-SCRIPTS-ONLY.md +2 -0
- package/skills/w/modules/DESIGN-REFERENCES.md +15 -11
- package/skills/w/modules/IDEATION-GATE.md +3 -3
- package/skills/w/modules/PLAN-EXECUTION-BATCHES.md +17 -36
- package/skills/w/modules/PLAN-INPUT.md +5 -3
- package/skills/w/modules/PLAN-REFINE-SPLIT.md +3 -1
- package/skills/w/modules/PLAN-SPLIT-GATE.md +7 -5
- package/skills/w/modules/PROMPT-CONTINUITY.md +3 -1
- package/skills/w/modules/SPEC-CHANGE-SHAPE.md +4 -4
- package/skills/w/roles/README.md +2 -0
- package/skills/w/roles/design/CONTRACT.md +80 -0
- package/skills/w/roles/design/ROLE.md +7 -0
- package/skills/w/schemas/capability-descriptor.schema.json +260 -0
- package/skills/w/schemas/design/design-render-bundle.v1.schema.json +191 -0
- package/skills/w/schemas/design/design-rendition.v1.schema.json +232 -0
- package/skills/w/schemas/design/ui-screen.v1.schema.json +29 -1
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One invocation exhausts every consecutive deterministic step it OWNS.
|
|
3
|
+
*
|
|
4
|
+
* The engine walks the journey from where the run left off and applies each
|
|
5
|
+
* transition that is both the CLI's authority (`cli`) and the CLI's property
|
|
6
|
+
* (`cli-owned`), one after another, without handing any of them back as work. It
|
|
7
|
+
* stops at the FIRST transition it cannot apply — a judgment, a preference, an
|
|
8
|
+
* effect nobody authorized, a blocker — or at the end of the journey, and returns
|
|
9
|
+
* that boundary as a directive.
|
|
10
|
+
*
|
|
11
|
+
* Authority is the axis that decides WHICH boundary: "is this derivable, or does
|
|
12
|
+
* it need a judgment, a preference, an invocation?". Ownership used to be a second
|
|
13
|
+
* axis answering "does this CLI decide it yet?", and a row that was derivable but
|
|
14
|
+
* still doctrine's came back as a `legacy` boundary naming the document about to
|
|
15
|
+
* decide it. That axis is closed: every row of every public journey is the CLI's,
|
|
16
|
+
* so ownership no longer routes anything — it fails closed. Both give way to one
|
|
17
|
+
* thing: an effect nobody authorized stops the advance whoever owns the rule.
|
|
18
|
+
*
|
|
19
|
+
* The trace of what it applied lives in the run state, with the authority each
|
|
20
|
+
* step moved under, so the advance is auditable after the fact instead of being a
|
|
21
|
+
* claim in a report.
|
|
22
|
+
*
|
|
23
|
+
* What "applying" means per transition is the business of each migrated tranche:
|
|
24
|
+
* here a transition advances the run's position and nothing else. That is why the
|
|
25
|
+
* registry — not this file — is where a new transition is added.
|
|
26
|
+
*/
|
|
27
|
+
import { DOCS_BOUNDARY, actionOf, alternativesOf, effectsOf, } from "../../domain/flow/authority.js";
|
|
28
|
+
import { authorizeTransition, effectApprovalDigest, } from "../../domain/flow/authorization.js";
|
|
29
|
+
import { PAUSE_LABEL, STOP_LABEL, buildFlowDirective, skippedStepOf, stepOf, } from "../../domain/flow/directive.js";
|
|
30
|
+
import { bindAction, docsBoundaryBreach, skipReason } from "../../domain/flow/rules.js";
|
|
31
|
+
import { MAX_BOUNDARY_ATTEMPTS, applyTransition, attemptsAt, checkAgainstJourney, positionDigest, skipTransition, withBoundary, withPendingAction, } from "../../domain/flow/run-state.js";
|
|
32
|
+
import { buildSemanticRequest, semanticDigest, } from "../semantic-operation/protocol.js";
|
|
33
|
+
import { sessionNumericCode } from "../session-resolver.js";
|
|
34
|
+
export function advanceFlowRun(input) {
|
|
35
|
+
const incoherent = checkAgainstJourney(input.state, input.journey);
|
|
36
|
+
if (incoherent !== null)
|
|
37
|
+
return { ok: false, failure: incoherent };
|
|
38
|
+
const walked = walk(input.state, input.journey);
|
|
39
|
+
let state = walked.state;
|
|
40
|
+
const appliedNow = [...(input.applied ?? []), ...walked.applied];
|
|
41
|
+
// The boundary and the pending action are written into the state BEFORE its seal
|
|
42
|
+
// is computed. Resolving first would seal a state that is about to be re-sealed,
|
|
43
|
+
// and the digest the directive advertises has to be the one the next answer will
|
|
44
|
+
// be checked against — otherwise every caller that trusted the directive would
|
|
45
|
+
// be told its answer is stale.
|
|
46
|
+
const stopped = input.journey[state.applied.length] ?? null;
|
|
47
|
+
state = withBoundary(state, stopped?.id ?? null);
|
|
48
|
+
// Only an EMITTED action is pending. Reading it back off the resolved boundary
|
|
49
|
+
// — instead of off the row — is what keeps the two honest: a delegated step
|
|
50
|
+
// whose effect is still unapproved stops at the authorization boundary, its
|
|
51
|
+
// invocation is not in the directive, and the state must not claim the run is
|
|
52
|
+
// waiting on something nobody was told to run.
|
|
53
|
+
const emitted = resolveBoundary(state, input.journey).action;
|
|
54
|
+
state = withPendingAction(state, emitted === null || stopped === null
|
|
55
|
+
? null
|
|
56
|
+
: { transition: stopped.id, digest: actionDigest(emitted) });
|
|
57
|
+
return directiveFor(state, resolveBoundary(state, input.journey), appliedNow);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Every consecutive transition the CLI owns AND can apply itself, in one go.
|
|
61
|
+
*
|
|
62
|
+
* The walk stops the moment authority changes hands, the moment the next
|
|
63
|
+
* transition would exercise an effect nobody authorized (advancing automatically
|
|
64
|
+
* never widens an authorization), the moment it reaches a step whose ownership the
|
|
65
|
+
* registry does not declare — or the moment the step is delegated.
|
|
66
|
+
*
|
|
67
|
+
* The last two stops are the same principle twice. Applying an unowned row would
|
|
68
|
+
* record as decided-by-the-CLI a step the registry never said it decides; applying
|
|
69
|
+
* a DELEGATED row would record as done a search, a seeding or a validation that
|
|
70
|
+
* nothing ran. Both would be the engine claiming something it cannot see, so both
|
|
71
|
+
* become boundaries: one blocked naming what is missing, the other naming its
|
|
72
|
+
* invocation and waiting for real output.
|
|
73
|
+
*
|
|
74
|
+
* A CONDITIONAL step is the one case that neither applies nor stops: the walk
|
|
75
|
+
* passes over it, records the omission with its cause, and keeps going whatever
|
|
76
|
+
* the step's authority would have been. That is checked first on purpose — a
|
|
77
|
+
* human boundary whose condition did not fire must never be emitted, or the
|
|
78
|
+
* migrated journey would ask a question the doctrine it replaces does not ask.
|
|
79
|
+
*/
|
|
80
|
+
function walk(from, journey) {
|
|
81
|
+
let state = from;
|
|
82
|
+
const applied = [];
|
|
83
|
+
for (let index = state.applied.length; index < journey.length; index += 1) {
|
|
84
|
+
const decision = journey[index];
|
|
85
|
+
if (decision === undefined)
|
|
86
|
+
break;
|
|
87
|
+
// A condition that did not fire, or a boundary this run has already tried as
|
|
88
|
+
// often as it may. Both pass over the step and both say why — the trace has
|
|
89
|
+
// to distinguish "never happened" from "was given up on".
|
|
90
|
+
const skipped = skipReason(decision, journey, state.observations) ?? exhaustionSkip(state, decision);
|
|
91
|
+
if (skipped !== null) {
|
|
92
|
+
state = skipTransition(state, decision.id);
|
|
93
|
+
applied.push(skippedStepOf(decision, skipped));
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (decision.authority !== "cli")
|
|
97
|
+
break;
|
|
98
|
+
if (!owned(decision))
|
|
99
|
+
break;
|
|
100
|
+
if (authorizeTransition(decision, state.authorizations).missing.length > 0)
|
|
101
|
+
break;
|
|
102
|
+
if (actionOf(decision) !== null)
|
|
103
|
+
break;
|
|
104
|
+
state = applyTransition(state, decision.id, effectsOf(decision));
|
|
105
|
+
applied.push(stepOf(decision));
|
|
106
|
+
}
|
|
107
|
+
return { state, applied };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The seal over the exact action emitted.
|
|
111
|
+
*
|
|
112
|
+
* Program, arguments, target, input and demanded evidence — change any of them and
|
|
113
|
+
* a result that quotes the old seal is answering about something else. Same reason
|
|
114
|
+
* `effectApprovalDigest` seals the classes being approved rather than the fact that
|
|
115
|
+
* an approval happened.
|
|
116
|
+
*/
|
|
117
|
+
export function actionDigest(action) {
|
|
118
|
+
return semanticDigest({
|
|
119
|
+
program: action.invocation.program,
|
|
120
|
+
args: [...action.invocation.args],
|
|
121
|
+
target: action.invocation.target,
|
|
122
|
+
input: action.invocation.input,
|
|
123
|
+
evidence: [...action.evidence],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/** The run's own coordinates, the only ones an invocation may reference. */
|
|
127
|
+
function runBinding(state) {
|
|
128
|
+
return { session: state.session, code: sessionNumericCode(state.session) ?? state.session };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The action as this run would emit it: bound to its session, or refused.
|
|
132
|
+
*
|
|
133
|
+
* Every reader goes through here — the seal, the directive and the check `submit`
|
|
134
|
+
* runs against the result — so the invocation that gets sealed is the invocation
|
|
135
|
+
* that gets shown and the one the result is compared against. Binding in one of
|
|
136
|
+
* the three and not the others is how a run ends up rejecting its own action.
|
|
137
|
+
*/
|
|
138
|
+
function emittedAction(state, stopped) {
|
|
139
|
+
const declared = stopped === null ? null : actionOf(stopped);
|
|
140
|
+
if (declared === null)
|
|
141
|
+
return { action: null, unbound: null, outside: null };
|
|
142
|
+
const bound = bindAction(declared, runBinding(state));
|
|
143
|
+
if (!bound.ok)
|
|
144
|
+
return { action: null, unbound: bound.unbound, outside: null };
|
|
145
|
+
// Checked on the BOUND form: a placeholder could resolve into a path, so
|
|
146
|
+
// validating the template would be validating something nobody runs.
|
|
147
|
+
const outside = docsBoundaryBreach(bound.action, state.flow);
|
|
148
|
+
return outside === null
|
|
149
|
+
? { action: bound.action, unbound: null, outside: null }
|
|
150
|
+
: { action: null, unbound: null, outside };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Why this boundary cannot be emitted at all — or `null` when it can.
|
|
154
|
+
*
|
|
155
|
+
* Four fail-closed causes, ordered by what the reader can do about them.
|
|
156
|
+
* Ownership answers first and is the one this tranche added: with the fallback
|
|
157
|
+
* retired there is no document to hand the step back to, so a transition the
|
|
158
|
+
* registry does not say the CLI owns stops the run naming itself instead of
|
|
159
|
+
* silently becoming prose somebody has to go read. An unbound placeholder and a
|
|
160
|
+
* `docs/` breach are defects OF THE REGISTRY too: the fix is a code change, and
|
|
161
|
+
* emitting either would print a command nobody can run or one that writes outside
|
|
162
|
+
* the lane its flow is allowed. Exhaustion is a defect of nothing — it is the run
|
|
163
|
+
* having asked the same thing as often as the chassis permits, and the answer is
|
|
164
|
+
* to take the gap somewhere a person can settle it rather than to ask a fourth
|
|
165
|
+
* time.
|
|
166
|
+
*/
|
|
167
|
+
function blockedCause(state, stopped, emitted) {
|
|
168
|
+
if (!owned(stopped)) {
|
|
169
|
+
return {
|
|
170
|
+
code: "FLOW_TRANSITION_UNOWNED",
|
|
171
|
+
message: `'${stopped.id}' no declara propiedad del CLI y ya no queda doctrina a la que devolverlo`,
|
|
172
|
+
action: "declarála en el registro de autoridad: desde el cierre de la migración toda transición de un recorrido público es 'cli-owned', y la ausencia es un error, no un fallback",
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (emitted.unbound !== null) {
|
|
176
|
+
return {
|
|
177
|
+
code: "FLOW_ACTION_UNBOUND",
|
|
178
|
+
message: `la acción de '${stopped.id}' referencia ${emitted.unbound} y esta corrida no puede resolverlo`,
|
|
179
|
+
action: "corregí la invocación del registro: una acción solo referencia las coordenadas de la corrida",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (emitted.outside !== null) {
|
|
183
|
+
return {
|
|
184
|
+
code: "FLOW_DOCS_BOUNDARY_CROSSED",
|
|
185
|
+
message: `la acción de '${stopped.id}' escribe en ${emitted.outside} y el flow '${state.flow}' no tiene esa carpeta permitida`,
|
|
186
|
+
action: `este recorrido solo escribe ${describeAllowance(state.flow)}: promover algo a otra carpeta de docs es un paso 'export-*' aparte, nunca un efecto del loop`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (exhausted(state, stopped)) {
|
|
190
|
+
// Two different situations wear the same code, and saying which one this is
|
|
191
|
+
// matters: one continues on the next advance, the other cannot. Reporting the
|
|
192
|
+
// stricter message for both would tell somebody their run is stuck when it is
|
|
193
|
+
// about to move on.
|
|
194
|
+
const degradable = exhaustionSkip(state, stopped) !== null;
|
|
195
|
+
return {
|
|
196
|
+
code: "FLOW_BOUNDARY_EXHAUSTED",
|
|
197
|
+
message: `'${stopped.id}' agotó sus ${MAX_BOUNDARY_ATTEMPTS} intentos: contestarlo otra vez sería el bucle que la regla evita`,
|
|
198
|
+
action: degradable
|
|
199
|
+
? `${DEGRADE_ACTION}; el próximo 'aw flow advance' lo pasa por alto dejando dicho por qué y sigue con el resto`
|
|
200
|
+
: `${DEGRADE_ACTION}, y resolvé este paso fuera de la corrida antes de seguir: saltearlo daría por aprobado un efecto que nadie aprobó, o por hecho algo que nada corrió`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
/** Where a gap goes when the loop stops re-firing it — the chassis' destination. */
|
|
206
|
+
const DEGRADE_ACTION = "degradá el gap en vez de reintentarlo: llevalo a '## Open questions' del documento del flow —o al BACKLOG de la sesión si el flow no tiene documento— declarando que ya se intentó";
|
|
207
|
+
/** Whether this run has already spent every attempt this boundary gets. */
|
|
208
|
+
function exhausted(state, decision) {
|
|
209
|
+
return attemptsAt(state, decision.id) >= MAX_BOUNDARY_ATTEMPTS;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether the registry says this CLI owns the step.
|
|
213
|
+
*
|
|
214
|
+
* The vocabulary has one member, so every row shipped in {@link FLOW_DECISIONS}
|
|
215
|
+
* answers `true` and the compiler is what keeps it that way. The check survives
|
|
216
|
+
* for the journeys this engine does NOT build itself: a caller hands `advanceFlow`
|
|
217
|
+
* a list of decisions, and reading a field is cheaper than trusting that whoever
|
|
218
|
+
* assembled it kept the invariant. The three places that ask are the walk, the
|
|
219
|
+
* blocked cause and the skip — one predicate, so they cannot disagree.
|
|
220
|
+
*/
|
|
221
|
+
function owned(decision) {
|
|
222
|
+
return decision.ownership === "cli-owned";
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Why an exhausted boundary is passed over — or `null` when it must not be.
|
|
226
|
+
*
|
|
227
|
+
* Degrading means what the chassis says it means: the gap stops being re-fired,
|
|
228
|
+
* it goes somewhere a person can settle it, and **the run goes on with the
|
|
229
|
+
* rest**. Blocking instead would be the dead end the rule exists to prevent — a
|
|
230
|
+
* boundary nobody can answer any more, on a run nobody can finish.
|
|
231
|
+
*
|
|
232
|
+
* Not every boundary may be passed over, and the exception is not a special
|
|
233
|
+
* case: a step that would EXERCISE something cannot be waved through. An
|
|
234
|
+
* authorization skipped is an effect nobody approved; a delegated step skipped
|
|
235
|
+
* is a search, a write or a check credited to nothing. Those stay blocked, and
|
|
236
|
+
* the block says so. What degrades is what only produces a verdict — a judgment
|
|
237
|
+
* or a preference — which is exactly the gap the doctrine degrades.
|
|
238
|
+
*/
|
|
239
|
+
function exhaustionSkip(state, decision) {
|
|
240
|
+
if (!exhausted(state, decision))
|
|
241
|
+
return null;
|
|
242
|
+
if (!owned(decision))
|
|
243
|
+
return null;
|
|
244
|
+
if (actionOf(decision) !== null)
|
|
245
|
+
return null;
|
|
246
|
+
if (authorizeTransition(decision, state.authorizations).missing.length > 0)
|
|
247
|
+
return null;
|
|
248
|
+
return `agotó sus ${MAX_BOUNDARY_ATTEMPTS} intentos: ${DEGRADE_ACTION}`;
|
|
249
|
+
}
|
|
250
|
+
/** The `docs/` folders a flow may write, said the way a person reads it. */
|
|
251
|
+
function describeAllowance(flow) {
|
|
252
|
+
const allowed = DOCS_BOUNDARY[flow];
|
|
253
|
+
return allowed.length === 0 ? "ninguna carpeta de docs" : allowed.join(" y ");
|
|
254
|
+
}
|
|
255
|
+
export function resolveBoundary(state, journey) {
|
|
256
|
+
const stopped = journey[state.applied.length] ?? null;
|
|
257
|
+
const pending = journey.slice(state.applied.length).map((decision) => decision.id);
|
|
258
|
+
if (stopped === null) {
|
|
259
|
+
return {
|
|
260
|
+
stopped: null,
|
|
261
|
+
kind: "final",
|
|
262
|
+
authorization: null,
|
|
263
|
+
request: null,
|
|
264
|
+
action: null,
|
|
265
|
+
choices: [],
|
|
266
|
+
pending,
|
|
267
|
+
seal: boundarySeal(state, null),
|
|
268
|
+
error: null,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const emitted = emittedAction(state, stopped);
|
|
272
|
+
// Computed for `cli` rows only, which is where every row that really writes or
|
|
273
|
+
// runs lives today (13 of them, all `cli`). The day a row with authority `agent`
|
|
274
|
+
// or `human` declares a non-self-authorizable effect, this condition is the
|
|
275
|
+
// thing to revisit — and the ORDER is the open question there: approving a write
|
|
276
|
+
// before the agent has produced what gets written is not obviously right, so
|
|
277
|
+
// whichever phase introduces such a row decides it instead of inheriting it.
|
|
278
|
+
const authorization = stopped.authority === "cli" ? authorizeTransition(stopped, state.authorizations) : null;
|
|
279
|
+
// A cause that blocks outranks all of it: the boundary that says "nothing can
|
|
280
|
+
// continue and here is why" is never worth degrading into a question nobody can
|
|
281
|
+
// answer.
|
|
282
|
+
const blocked = blockedCause(state, stopped, emitted);
|
|
283
|
+
const kind = blocked === null ? boundaryKind(stopped, (authorization?.missing.length ?? 0) > 0) : "blocked";
|
|
284
|
+
return {
|
|
285
|
+
stopped,
|
|
286
|
+
kind,
|
|
287
|
+
authorization,
|
|
288
|
+
request: kind === "semantic" ? boundaryRequest(stopped, state) : null,
|
|
289
|
+
action: kind === "execution" ? emitted.action : null,
|
|
290
|
+
choices: choicesFor(kind, stopped, authorization),
|
|
291
|
+
pending,
|
|
292
|
+
seal: boundarySeal(state, stopped),
|
|
293
|
+
error: blocked,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Which boundary a stopped transition is, in the one order that holds.
|
|
298
|
+
*
|
|
299
|
+
* An effect nobody authorized outranks everything: approving an effect is not
|
|
300
|
+
* deciding a step, and letting any other axis answer first would hand a writing
|
|
301
|
+
* transition onwards with its effects unapproved — the authorization gate bypassed
|
|
302
|
+
* by a field that has nothing to do with it. Then the mode: what remains is a
|
|
303
|
+
* judgment, an invocation to run, or a preference.
|
|
304
|
+
*
|
|
305
|
+
* Ownership used to sit in the middle of that order, turning a step the CLI did
|
|
306
|
+
* not decide into its own kind of boundary. It no longer answers here at all —
|
|
307
|
+
* {@link blockedCause} refuses such a transition before this function runs, which
|
|
308
|
+
* is the difference between "read this document and come back" and "this cannot
|
|
309
|
+
* advance, and here is why".
|
|
310
|
+
*/
|
|
311
|
+
function boundaryKind(stopped, unauthorized) {
|
|
312
|
+
if (unauthorized)
|
|
313
|
+
return "authorization";
|
|
314
|
+
if (stopped.authority === "agent")
|
|
315
|
+
return "semantic";
|
|
316
|
+
return actionOf(stopped) === null ? "human" : "execution";
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The seal of a boundary: the state it stands on, the transition it is about, and
|
|
320
|
+
* the action it names.
|
|
321
|
+
*
|
|
322
|
+
* Every boundary has one, not only the semantic ones — a human choice sent back
|
|
323
|
+
* against a state that moved is as stale as a semantic answer, and giving the two
|
|
324
|
+
* different staleness rules would leave the cheaper one unguarded. The semantic
|
|
325
|
+
* request's `input_digest` is computed over exactly this, so the two never differ.
|
|
326
|
+
*
|
|
327
|
+
* The action is inside the seal because a result is an assertion about a specific
|
|
328
|
+
* invocation: if the program, an argument, the target, the input or the demanded
|
|
329
|
+
* evidence changed, whatever came back answered a different question.
|
|
330
|
+
*/
|
|
331
|
+
export function boundarySeal(state, stopped) {
|
|
332
|
+
return semanticDigest(boundaryInputs(state, stopped));
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* What the seal is computed over — and what the semantic request declares as its
|
|
336
|
+
* own inputs, so the two digests are the same number by construction.
|
|
337
|
+
*
|
|
338
|
+
* Building them apart is how a system ends up with two staleness questions and a
|
|
339
|
+
* caller guessing which one it just answered.
|
|
340
|
+
*/
|
|
341
|
+
function boundaryInputs(state, stopped) {
|
|
342
|
+
const action = emittedAction(state, stopped).action;
|
|
343
|
+
return {
|
|
344
|
+
// The POSITION, not the whole file: a refused attempt is recorded in the
|
|
345
|
+
// state, and sealing it in would make the caller's own refusal come back as
|
|
346
|
+
// staleness on their next try. See `positionDigest`.
|
|
347
|
+
state: positionDigest(state),
|
|
348
|
+
transition: stopped?.id ?? null,
|
|
349
|
+
action: action === null ? null : actionDigest(action),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/** Build the directive for a resolved boundary. Shared by both verbs. */
|
|
353
|
+
export function directiveFor(state, resolved, appliedNow, overrides = {}) {
|
|
354
|
+
const boundary = resolved.stopped === null
|
|
355
|
+
? {
|
|
356
|
+
kind: "final",
|
|
357
|
+
transition: null,
|
|
358
|
+
authority: null,
|
|
359
|
+
ownership: null,
|
|
360
|
+
title: null,
|
|
361
|
+
document: null,
|
|
362
|
+
}
|
|
363
|
+
: {
|
|
364
|
+
kind: resolved.kind,
|
|
365
|
+
transition: resolved.stopped.id,
|
|
366
|
+
authority: resolved.stopped.authority,
|
|
367
|
+
ownership: resolved.stopped.ownership,
|
|
368
|
+
title: resolved.stopped.title,
|
|
369
|
+
document: resolved.stopped.document,
|
|
370
|
+
};
|
|
371
|
+
const planned = resolved.authorization?.planned ?? [];
|
|
372
|
+
const built = buildFlowDirective({
|
|
373
|
+
flow: state.flow,
|
|
374
|
+
session: state.session,
|
|
375
|
+
boundary,
|
|
376
|
+
outcome: overrides.outcome ?? (resolved.stopped === null ? "completed" : "needs_input"),
|
|
377
|
+
stateDigest: resolved.seal,
|
|
378
|
+
applied: appliedNow,
|
|
379
|
+
pending: resolved.pending,
|
|
380
|
+
request: resolved.request,
|
|
381
|
+
action: resolved.action,
|
|
382
|
+
choices: resolved.choices,
|
|
383
|
+
authorizations: state.authorizations,
|
|
384
|
+
// The cause of a block travels with the boundary that declares it: a
|
|
385
|
+
// `blocked` directive without its error is refused at construction.
|
|
386
|
+
error: resolved.error,
|
|
387
|
+
// The transition it stopped on is PLANNED even though nothing applied it: the
|
|
388
|
+
// person is being asked to approve those exact classes.
|
|
389
|
+
effects: {
|
|
390
|
+
planned: [...new Set([...state.effects.planned, ...planned])],
|
|
391
|
+
approved: state.effects.approved,
|
|
392
|
+
applied: state.effects.applied,
|
|
393
|
+
},
|
|
394
|
+
nextAction: overrides.nextAction ?? nextActionFor(boundary, resolved),
|
|
395
|
+
});
|
|
396
|
+
if (!built.ok)
|
|
397
|
+
return { ok: false, failure: built.failure };
|
|
398
|
+
return { ok: true, state, directive: built.directive };
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* The bounded request a semantic boundary carries.
|
|
402
|
+
*
|
|
403
|
+
* It reuses the existing `SemanticRequest` whole — contract, staleness seal,
|
|
404
|
+
* allowed destinations, limits and a visible `read_set` so the cost is auditable
|
|
405
|
+
* — instead of inventing a second envelope. A flow boundary asks for a judgment,
|
|
406
|
+
* not for files, which is why it declares no writable destination at all.
|
|
407
|
+
*/
|
|
408
|
+
export function boundaryRequest(decision, state) {
|
|
409
|
+
const vocabulary = decision.signals ?? [];
|
|
410
|
+
const taxonomy = vocabulary.length === 0
|
|
411
|
+
? "Esta frontera no admite señales: contestá en 'decisions' lo que el contrato pide."
|
|
412
|
+
: `Declarás en 'signals' solo las que observás, de este vocabulario cerrado: ${vocabulary.join(", ")}. Una señal fuera de él no avanza el recorrido. El umbral sobre las señales lo aplica el CLI, no vos.`;
|
|
413
|
+
return buildSemanticRequest({
|
|
414
|
+
operation: `flow.${decision.id}`,
|
|
415
|
+
inputs: boundaryInputs(state, decision),
|
|
416
|
+
contract: `${decision.title}. Devolvé un único objeto JSON con el 'input_digest' de esta frontera. ${taxonomy} El CLI valida la respuesta antes de aplicar ninguna transición: una respuesta ausente, inválida, ambigua, fuera de alcance o vencida no cambia el estado ni produce efectos.`,
|
|
417
|
+
inventory: { flow: state.flow, applied: state.applied, signals: vocabulary },
|
|
418
|
+
allowedDestinations: [],
|
|
419
|
+
limits: { max_artifacts: 0, max_artifact_bytes: 0 },
|
|
420
|
+
readSet: [decision.document],
|
|
421
|
+
readSetBytes: 0,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* The flow control, appended to every boundary that offers alternatives.
|
|
426
|
+
*
|
|
427
|
+
* BOTH halves, and the second one is what this phase added: the chassis' control
|
|
428
|
+
* is `Compactar | Cerrar`, and the engine only ever emitted `Cerrar` — so half
|
|
429
|
+
* the doctrine's own rule had no realization. Pausing under context pressure and
|
|
430
|
+
* stopping for good are different acts with different consequences, and a run
|
|
431
|
+
* that can only stop forces whoever is in it to choose between losing the thread
|
|
432
|
+
* and losing the work.
|
|
433
|
+
*
|
|
434
|
+
* Appended HERE and never by a row: a tranche must not be able to write a
|
|
435
|
+
* boundary nobody can walk away from or pause. Neither is recommended — the
|
|
436
|
+
* recommendation belongs to the content of the question, and nudging someone
|
|
437
|
+
* toward stopping or compacting would be the engine having an opinion about
|
|
438
|
+
* whether to keep going.
|
|
439
|
+
*/
|
|
440
|
+
export function flowControlChoices(stopping) {
|
|
441
|
+
return [
|
|
442
|
+
{
|
|
443
|
+
label: PAUSE_LABEL,
|
|
444
|
+
consequence: "se persiste el CHECKPOINT y la corrida retoma en esta misma frontera después de compactar el contexto",
|
|
445
|
+
recommended: false,
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
label: STOP_LABEL,
|
|
449
|
+
consequence: stopping ?? "el recorrido queda detenido acá, con su estado y su frontera persistidos",
|
|
450
|
+
recommended: false,
|
|
451
|
+
},
|
|
452
|
+
];
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* A human boundary: the alternatives the row declares, or the generic pair.
|
|
456
|
+
*
|
|
457
|
+
* A migrated tranche names its own options — the ones its doctrine used to
|
|
458
|
+
* enumerate — and the engine emits them verbatim, which is what makes the
|
|
459
|
+
* directed journey equivalent to the one it replaces instead of merely similar.
|
|
460
|
+
* Whatever the row says, the flow control is appended.
|
|
461
|
+
*/
|
|
462
|
+
function humanChoices(decision) {
|
|
463
|
+
const own = alternativesOf(decision);
|
|
464
|
+
const resolve = own === null
|
|
465
|
+
? [
|
|
466
|
+
{
|
|
467
|
+
label: "Resolver la frontera",
|
|
468
|
+
consequence: `decidís '${decision.title}' y el recorrido sigue desde ahí`,
|
|
469
|
+
recommended: true,
|
|
470
|
+
},
|
|
471
|
+
]
|
|
472
|
+
: own.map((choice) => ({ ...choice }));
|
|
473
|
+
return [...resolve, ...flowControlChoices()];
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* An authorization boundary names the effect and what approving it costs.
|
|
477
|
+
*
|
|
478
|
+
* The recommendation is NOT "approve": nobody may be nudged into widening an
|
|
479
|
+
* authorization, so the alternatives state both consequences and let the person
|
|
480
|
+
* decide.
|
|
481
|
+
*/
|
|
482
|
+
function authorizationChoices(decision, authorization) {
|
|
483
|
+
const missing = authorization.missing.join(", ");
|
|
484
|
+
return [
|
|
485
|
+
{
|
|
486
|
+
label: "Autorizar el efecto",
|
|
487
|
+
consequence: `'${decision.title}' ejerce ${missing} y el recorrido sigue; la autorización queda registrada en la corrida`,
|
|
488
|
+
recommended: true,
|
|
489
|
+
},
|
|
490
|
+
...flowControlChoices(`no se ejerce ${missing} y el recorrido queda detenido acá, sin nada aplicado`),
|
|
491
|
+
];
|
|
492
|
+
}
|
|
493
|
+
function choicesFor(kind, stopped, unauthorized) {
|
|
494
|
+
if (kind === "authorization" && unauthorized !== null) {
|
|
495
|
+
return authorizationChoices(stopped, unauthorized);
|
|
496
|
+
}
|
|
497
|
+
return kind === "human" ? humanChoices(stopped) : [];
|
|
498
|
+
}
|
|
499
|
+
function nextActionFor(boundary, resolved) {
|
|
500
|
+
const stopped = resolved.stopped;
|
|
501
|
+
if (stopped === null)
|
|
502
|
+
return "no queda trabajo pendiente en este recorrido";
|
|
503
|
+
const submit = "respondé con 'aw flow submit' sobre la frontera vigente";
|
|
504
|
+
switch (boundary.kind) {
|
|
505
|
+
case "semantic":
|
|
506
|
+
return `${submit}: ${stopped.title}`;
|
|
507
|
+
case "human":
|
|
508
|
+
return `${submit}: elegí una de las alternativas emitidas para '${stopped.title}'`;
|
|
509
|
+
case "authorization": {
|
|
510
|
+
// The digest travels in the action so nobody has to derive it: the approval
|
|
511
|
+
// seals the exact classes this boundary named, and naming them here is what
|
|
512
|
+
// makes the next step discoverable without a field parallel to the receipt.
|
|
513
|
+
const digest = effectApprovalDigest(stopped.id, resolved.authorization?.planned ?? []);
|
|
514
|
+
const missing = resolved.authorization?.missing.join(", ") ?? "el efecto";
|
|
515
|
+
return `${submit} con --approval ${digest}, autorizando ${missing} para '${stopped.title}'`;
|
|
516
|
+
}
|
|
517
|
+
case "execution": {
|
|
518
|
+
// The exact invocation, projected — not a description of it. Whoever
|
|
519
|
+
// executes should never have to reconstruct the command from prose, and the
|
|
520
|
+
// evidence is named in the same breath so "it ran" and "here is the output"
|
|
521
|
+
// arrive together or not at all.
|
|
522
|
+
const action = resolved.action;
|
|
523
|
+
const call = action === null
|
|
524
|
+
? stopped.id
|
|
525
|
+
: [action.invocation.program, ...action.invocation.args].join(" ");
|
|
526
|
+
const evidence = action?.evidence.join(", ") ?? "la evidencia exigida";
|
|
527
|
+
return `ejecutá '${call}' en ${action?.invocation.target ?? "el target declarado"} y ${submit} con su resultado real: outcome, la invocación que corriste y las validaciones ${evidence}. Una confirmación sin salida no aplica la transición`;
|
|
528
|
+
}
|
|
529
|
+
default:
|
|
530
|
+
return `resolvé el bloqueo de '${stopped.title}' y volvé a correr 'aw flow advance'`;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
//# sourceMappingURL=advance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advance.js","sourceRoot":"","sources":["../../../src/application/flow/advance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EACL,aAAa,EAGb,QAAQ,EACR,cAAc,EACd,SAAS,GACV,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAKL,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,MAAM,GACP,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEL,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,oBAAoB,EACpB,cAAc,GACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAoB5D,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,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,MAAM,mBAAmB,MAAM,iBAAiB,OAAO,UAAU,OAAO,CAAC,KAAK,GAAG,CAAC;QAC9F,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,qEAAqE;YACrE,4EAA4E;YAC5E,4EAA4E;YAC5E,iCAAiC;YACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC/B,MAAM,IAAI,GACR,MAAM,KAAK,IAAI;gBACb,CAAC,CAAC,OAAO,CAAC,EAAE;gBACZ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC;YACvE,OAAO,YAAY,IAAI,QAAQ,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,qBAAqB,MAAM,MAAM,kFAAkF,QAAQ,uDAAuD,CAAC;QACjP,CAAC;QACD;YACE,OAAO,0BAA0B,OAAO,CAAC,KAAK,sCAAsC,CAAC;IACzF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command's half: find the session, take the run's lock, advance, persist.
|
|
3
|
+
*
|
|
4
|
+
* Everything decision-shaped lives in the engine and the registry; what is here
|
|
5
|
+
* is the plumbing that makes the advance atomic and addressable — which session,
|
|
6
|
+
* which state, one write.
|
|
7
|
+
*/
|
|
8
|
+
import { journeyOfFlow } from "../../domain/flow/authority.js";
|
|
9
|
+
import { newRunState } from "../../domain/flow/run-state.js";
|
|
10
|
+
import { WORKLINE_FLOWS } from "../capability/compose.js";
|
|
11
|
+
import { resolveSessionTarget } from "../session-resolver.js";
|
|
12
|
+
import { advanceFlowRun } from "./advance.js";
|
|
13
|
+
import { applyUnderLock, locateRun } from "./run-state-service.js";
|
|
14
|
+
export async function advanceFlow(fs, paths, input) {
|
|
15
|
+
// A write path: a closed line is never advanced by accident, and nothing is
|
|
16
|
+
// chosen by recency — several active sessions with no association is ambiguous.
|
|
17
|
+
const resolution = await resolveSessionTarget(fs, paths, {
|
|
18
|
+
...(input.code !== undefined ? { code: input.code } : {}),
|
|
19
|
+
...(input.contextId !== undefined ? { contextId: input.contextId } : {}),
|
|
20
|
+
allowClosed: false,
|
|
21
|
+
bind: true,
|
|
22
|
+
});
|
|
23
|
+
if (resolution.outcome !== "resolved")
|
|
24
|
+
return { ok: false, session: resolution };
|
|
25
|
+
const session = resolution.session.folder;
|
|
26
|
+
const location = locateRun(paths, session);
|
|
27
|
+
const applied = await applyUnderLock(fs, location, (current) => {
|
|
28
|
+
const seeded = current ?? seed(input, session);
|
|
29
|
+
if ("failure" in seeded)
|
|
30
|
+
return { ok: false, failure: seeded.failure };
|
|
31
|
+
const advance = advanceFlowRun({
|
|
32
|
+
state: seeded,
|
|
33
|
+
journey: journeyOfFlow(seeded.flow),
|
|
34
|
+
});
|
|
35
|
+
if (!advance.ok)
|
|
36
|
+
return { ok: false, failure: advance.failure };
|
|
37
|
+
return { ok: true, state: advance.state, value: advance.directive };
|
|
38
|
+
}, { allowAbsent: input.adopt });
|
|
39
|
+
if (!applied.ok)
|
|
40
|
+
return { ok: false, failure: applied.failure };
|
|
41
|
+
return { ok: true, directive: applied.value };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The state a legacy session gets when it is adopted.
|
|
45
|
+
*
|
|
46
|
+
* Adoption needs the flow named explicitly: guessing it from the folder suffix
|
|
47
|
+
* would make the CLI infer the one thing the whole run hangs off, and a wrong
|
|
48
|
+
* guess would walk the wrong journey.
|
|
49
|
+
*/
|
|
50
|
+
function seed(input, session) {
|
|
51
|
+
const flow = input.flow;
|
|
52
|
+
if (flow === undefined || !WORKLINE_FLOWS.includes(flow)) {
|
|
53
|
+
return {
|
|
54
|
+
failure: {
|
|
55
|
+
code: "FLOW_ADOPTION_FLOW_MISSING",
|
|
56
|
+
message: flow === undefined
|
|
57
|
+
? "adoptar una sesión legacy exige nombrar su flow"
|
|
58
|
+
: `'${flow}' no es un flow de Workline`,
|
|
59
|
+
action: `pasá --flow con uno de: ${WORKLINE_FLOWS.join(", ")}`,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return newRunState(flow, session);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=flow-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-service.js","sourceRoot":"","sources":["../../../src/application/flow/flow-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAqB,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAqB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAA+B,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAgBnE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,EAAkB,EAClB,KAAmB,EACnB,KAAuB;IAEvB,4EAA4E;IAC5E,gFAAgF;IAChF,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,EAAE,EAAE,KAAK,EAAE;QACvD,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,WAAW,EAAE,KAAK;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