@telora/daemon 0.17.36 → 0.17.42
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-info.json +5 -3
- package/dist/assembly-engine.d.ts +6 -0
- package/dist/assembly-engine.d.ts.map +1 -1
- package/dist/assembly-engine.js +19 -0
- package/dist/assembly-engine.js.map +1 -1
- package/dist/assembly-resolvers.d.ts +17 -8
- package/dist/assembly-resolvers.d.ts.map +1 -1
- package/dist/assembly-resolvers.js +19 -8
- package/dist/assembly-resolvers.js.map +1 -1
- package/dist/cli/session-state.d.ts +10 -0
- package/dist/cli/session-state.d.ts.map +1 -1
- package/dist/cli/session-state.js +31 -0
- package/dist/cli/session-state.js.map +1 -1
- package/dist/completion/completion-decision.d.ts +83 -0
- package/dist/completion/completion-decision.d.ts.map +1 -0
- package/dist/completion/completion-decision.js +48 -0
- package/dist/completion/completion-decision.js.map +1 -0
- package/dist/completion/event-escalations.d.ts +97 -0
- package/dist/completion/event-escalations.d.ts.map +1 -0
- package/dist/completion/event-escalations.js +213 -0
- package/dist/completion/event-escalations.js.map +1 -0
- package/dist/completion/event.d.ts +1 -72
- package/dist/completion/event.d.ts.map +1 -1
- package/dist/completion/event.js +148 -322
- package/dist/completion/event.js.map +1 -1
- package/dist/completion/exit-classification.d.ts +82 -0
- package/dist/completion/exit-classification.d.ts.map +1 -0
- package/dist/completion/exit-classification.js +61 -0
- package/dist/completion/exit-classification.js.map +1 -0
- package/dist/completion/index.d.ts +14 -5
- package/dist/completion/index.d.ts.map +1 -1
- package/dist/completion/index.js +14 -5
- package/dist/completion/index.js.map +1 -1
- package/dist/completion/merge-phase.d.ts +114 -0
- package/dist/completion/merge-phase.d.ts.map +1 -0
- package/dist/completion/merge-phase.js +198 -0
- package/dist/completion/merge-phase.js.map +1 -0
- package/dist/completion/review-exit-phase.d.ts +82 -0
- package/dist/completion/review-exit-phase.d.ts.map +1 -0
- package/dist/completion/review-exit-phase.js +228 -0
- package/dist/completion/review-exit-phase.js.map +1 -0
- package/dist/completion/status-advance-phase.d.ts +61 -0
- package/dist/completion/status-advance-phase.d.ts.map +1 -0
- package/dist/completion/status-advance-phase.js +182 -0
- package/dist/completion/status-advance-phase.js.map +1 -0
- package/dist/completion/team-completion.d.ts +28 -269
- package/dist/completion/team-completion.d.ts.map +1 -1
- package/dist/completion/team-completion.js +145 -676
- package/dist/completion/team-completion.js.map +1 -1
- package/dist/daemon-process.d.ts +18 -2
- package/dist/daemon-process.d.ts.map +1 -1
- package/dist/daemon-process.js +7 -2
- package/dist/daemon-process.js.map +1 -1
- package/dist/directive/close-loop-stage.d.ts +50 -0
- package/dist/directive/close-loop-stage.d.ts.map +1 -0
- package/dist/directive/close-loop-stage.js +196 -0
- package/dist/directive/close-loop-stage.js.map +1 -0
- package/dist/directive/directive-assembly.d.ts +33 -0
- package/dist/directive/directive-assembly.d.ts.map +1 -0
- package/dist/directive/directive-assembly.js +77 -0
- package/dist/directive/directive-assembly.js.map +1 -0
- package/dist/directive/directive-dispatch.d.ts +103 -0
- package/dist/directive/directive-dispatch.d.ts.map +1 -0
- package/dist/directive/directive-dispatch.js +279 -0
- package/dist/directive/directive-dispatch.js.map +1 -0
- package/dist/directive/phase-sync.d.ts +89 -0
- package/dist/directive/phase-sync.d.ts.map +1 -0
- package/dist/directive/phase-sync.js +173 -0
- package/dist/directive/phase-sync.js.map +1 -0
- package/dist/directive-executor.d.ts +21 -223
- package/dist/directive-executor.d.ts.map +1 -1
- package/dist/directive-executor.js +28 -687
- package/dist/directive-executor.js.map +1 -1
- package/dist/focus-engine.d.ts.map +1 -1
- package/dist/focus-engine.js +8 -0
- package/dist/focus-engine.js.map +1 -1
- package/dist/focus-executor.d.ts +29 -8
- package/dist/focus-executor.d.ts.map +1 -1
- package/dist/focus-executor.js +29 -10
- package/dist/focus-executor.js.map +1 -1
- package/dist/focus-stage-lifecycle.d.ts +7 -5
- package/dist/focus-stage-lifecycle.d.ts.map +1 -1
- package/dist/focus-stage-lifecycle.js +11 -6
- package/dist/focus-stage-lifecycle.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline-config.d.ts +13 -0
- package/dist/pipeline-config.d.ts.map +1 -1
- package/dist/pipeline-config.js +15 -0
- package/dist/pipeline-config.js.map +1 -1
- package/dist/resolvers/agent-escalations.d.ts +8 -1
- package/dist/resolvers/agent-escalations.d.ts.map +1 -1
- package/dist/resolvers/agent-escalations.js +25 -22
- package/dist/resolvers/agent-escalations.js.map +1 -1
- package/dist/resolvers/agent-session-summaries.d.ts +8 -1
- package/dist/resolvers/agent-session-summaries.d.ts.map +1 -1
- package/dist/resolvers/agent-session-summaries.js +21 -18
- package/dist/resolvers/agent-session-summaries.js.map +1 -1
- package/dist/resolvers/delivery-acceptance-criteria.d.ts +7 -1
- package/dist/resolvers/delivery-acceptance-criteria.d.ts.map +1 -1
- package/dist/resolvers/delivery-acceptance-criteria.js +14 -11
- package/dist/resolvers/delivery-acceptance-criteria.js.map +1 -1
- package/dist/resolvers/delivery-description.d.ts +7 -1
- package/dist/resolvers/delivery-description.d.ts.map +1 -1
- package/dist/resolvers/delivery-description.js +14 -11
- package/dist/resolvers/delivery-description.js.map +1 -1
- package/dist/resolvers/delivery-issues.d.ts +8 -1
- package/dist/resolvers/delivery-issues.d.ts.map +1 -1
- package/dist/resolvers/delivery-issues.js +51 -48
- package/dist/resolvers/delivery-issues.js.map +1 -1
- package/dist/resolvers/delivery-listing.d.ts +16 -1
- package/dist/resolvers/delivery-listing.d.ts.map +1 -1
- package/dist/resolvers/delivery-listing.js +36 -33
- package/dist/resolvers/delivery-listing.js.map +1 -1
- package/dist/resolvers/delivery-tech-context.d.ts +7 -1
- package/dist/resolvers/delivery-tech-context.d.ts.map +1 -1
- package/dist/resolvers/delivery-tech-context.js +14 -11
- package/dist/resolvers/delivery-tech-context.js.map +1 -1
- package/dist/resolvers/deployment-profile.d.ts +8 -1
- package/dist/resolvers/deployment-profile.d.ts.map +1 -1
- package/dist/resolvers/deployment-profile.js +20 -17
- package/dist/resolvers/deployment-profile.js.map +1 -1
- package/dist/resolvers/focus-anchoring-injections.d.ts +26 -1
- package/dist/resolvers/focus-anchoring-injections.d.ts.map +1 -1
- package/dist/resolvers/focus-anchoring-injections.js +91 -88
- package/dist/resolvers/focus-anchoring-injections.js.map +1 -1
- package/dist/resolvers/focus-context.d.ts +9 -1
- package/dist/resolvers/focus-context.d.ts.map +1 -1
- package/dist/resolvers/focus-context.js +38 -35
- package/dist/resolvers/focus-context.js.map +1 -1
- package/dist/resolvers/focus-injections.d.ts +13 -1
- package/dist/resolvers/focus-injections.d.ts.map +1 -1
- package/dist/resolvers/focus-injections.js +60 -57
- package/dist/resolvers/focus-injections.js.map +1 -1
- package/dist/resolvers/focus-last-review-report.d.ts +2 -1
- package/dist/resolvers/focus-last-review-report.d.ts.map +1 -1
- package/dist/resolvers/focus-last-review-report.js +33 -30
- package/dist/resolvers/focus-last-review-report.js.map +1 -1
- package/dist/resolvers/focus-reality-tree.d.ts +15 -1
- package/dist/resolvers/focus-reality-tree.d.ts.map +1 -1
- package/dist/resolvers/focus-reality-tree.js +35 -32
- package/dist/resolvers/focus-reality-tree.js.map +1 -1
- package/dist/resolvers/git-diff-against-base.d.ts +8 -1
- package/dist/resolvers/git-diff-against-base.d.ts.map +1 -1
- package/dist/resolvers/git-diff-against-base.js +33 -30
- package/dist/resolvers/git-diff-against-base.js.map +1 -1
- package/dist/resolvers/guards-evaluation-results.d.ts +7 -1
- package/dist/resolvers/guards-evaluation-results.d.ts.map +1 -1
- package/dist/resolvers/guards-evaluation-results.js +25 -22
- package/dist/resolvers/guards-evaluation-results.js.map +1 -1
- package/dist/resolvers/index.d.ts +22 -40
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +112 -41
- package/dist/resolvers/index.js.map +1 -1
- package/dist/resolvers/loop-context.d.ts +18 -1
- package/dist/resolvers/loop-context.d.ts.map +1 -1
- package/dist/resolvers/loop-context.js +21 -18
- package/dist/resolvers/loop-context.js.map +1 -1
- package/dist/resolvers/loop-delivery-index.d.ts +17 -1
- package/dist/resolvers/loop-delivery-index.d.ts.map +1 -1
- package/dist/resolvers/loop-delivery-index.js +51 -48
- package/dist/resolvers/loop-delivery-index.js.map +1 -1
- package/dist/resolvers/loop-documents.d.ts +9 -1
- package/dist/resolvers/loop-documents.d.ts.map +1 -1
- package/dist/resolvers/loop-documents.js +22 -19
- package/dist/resolvers/loop-documents.js.map +1 -1
- package/dist/resolvers/loop-expected-effects.d.ts +11 -1
- package/dist/resolvers/loop-expected-effects.d.ts.map +1 -1
- package/dist/resolvers/loop-expected-effects.js +53 -50
- package/dist/resolvers/loop-expected-effects.js.map +1 -1
- package/dist/resolvers/loop-frt-statement.d.ts +11 -1
- package/dist/resolvers/loop-frt-statement.d.ts.map +1 -1
- package/dist/resolvers/loop-frt-statement.js +28 -25
- package/dist/resolvers/loop-frt-statement.js.map +1 -1
- package/dist/resolvers/loop-injection.d.ts +10 -1
- package/dist/resolvers/loop-injection.d.ts.map +1 -1
- package/dist/resolvers/loop-injection.js +38 -35
- package/dist/resolvers/loop-injection.js.map +1 -1
- package/dist/resolvers/loop-persona.d.ts +20 -1
- package/dist/resolvers/loop-persona.d.ts.map +1 -1
- package/dist/resolvers/loop-persona.js +20 -17
- package/dist/resolvers/loop-persona.js.map +1 -1
- package/dist/resolvers/loop-questions.d.ts +8 -1
- package/dist/resolvers/loop-questions.d.ts.map +1 -1
- package/dist/resolvers/loop-questions.js +39 -36
- package/dist/resolvers/loop-questions.js.map +1 -1
- package/dist/resolvers/loop-upstream-udes.d.ts +11 -1
- package/dist/resolvers/loop-upstream-udes.d.ts.map +1 -1
- package/dist/resolvers/loop-upstream-udes.js +74 -71
- package/dist/resolvers/loop-upstream-udes.js.map +1 -1
- package/dist/resolvers/prd-context.d.ts +2 -0
- package/dist/resolvers/prd-context.d.ts.map +1 -1
- package/dist/resolvers/prd-context.js +16 -13
- package/dist/resolvers/prd-context.js.map +1 -1
- package/dist/resolvers/prd-persona.d.ts +2 -0
- package/dist/resolvers/prd-persona.d.ts.map +1 -1
- package/dist/resolvers/prd-persona.js +6 -3
- package/dist/resolvers/prd-persona.js.map +1 -1
- package/dist/resolvers/reality-metrics.d.ts +8 -1
- package/dist/resolvers/reality-metrics.d.ts.map +1 -1
- package/dist/resolvers/reality-metrics.js +73 -70
- package/dist/resolvers/reality-metrics.js.map +1 -1
- package/dist/resolvers/reality-projections.d.ts +7 -1
- package/dist/resolvers/reality-projections.d.ts.map +1 -1
- package/dist/resolvers/reality-projections.js +35 -32
- package/dist/resolvers/reality-projections.js.map +1 -1
- package/dist/resolvers/reality-tree-snapshot.d.ts +10 -1
- package/dist/resolvers/reality-tree-snapshot.d.ts.map +1 -1
- package/dist/resolvers/reality-tree-snapshot.js +34 -31
- package/dist/resolvers/reality-tree-snapshot.js.map +1 -1
- package/dist/resolvers/retired-injections.d.ts +10 -1
- package/dist/resolvers/retired-injections.d.ts.map +1 -1
- package/dist/resolvers/retired-injections.js +68 -65
- package/dist/resolvers/retired-injections.js.map +1 -1
- package/dist/resolvers/review-outcomes.d.ts +11 -1
- package/dist/resolvers/review-outcomes.d.ts.map +1 -1
- package/dist/resolvers/review-outcomes.js +27 -24
- package/dist/resolvers/review-outcomes.js.map +1 -1
- package/dist/resolvers/security-advisory.d.ts +2 -1
- package/dist/resolvers/security-advisory.d.ts.map +1 -1
- package/dist/resolvers/security-advisory.js +47 -44
- package/dist/resolvers/security-advisory.js.map +1 -1
- package/dist/resolvers/wiki-search.d.ts +8 -1
- package/dist/resolvers/wiki-search.d.ts.map +1 -1
- package/dist/resolvers/wiki-search.js +17 -14
- package/dist/resolvers/wiki-search.js.map +1 -1
- package/dist/resolvers/wiki-topic.d.ts +9 -1
- package/dist/resolvers/wiki-topic.d.ts.map +1 -1
- package/dist/resolvers/wiki-topic.js +21 -18
- package/dist/resolvers/wiki-topic.js.map +1 -1
- package/dist/resolvers/workflow-stages.d.ts +7 -1
- package/dist/resolvers/workflow-stages.d.ts.map +1 -1
- package/dist/resolvers/workflow-stages.js +20 -17
- package/dist/resolvers/workflow-stages.js.map +1 -1
- package/dist/self-update.d.ts +6 -0
- package/dist/self-update.d.ts.map +1 -1
- package/dist/self-update.js +6 -1
- package/dist/self-update.js.map +1 -1
- package/dist/spawner/index.d.ts +2 -1
- package/dist/spawner/index.d.ts.map +1 -1
- package/dist/spawner/index.js +2 -1
- package/dist/spawner/index.js.map +1 -1
- package/dist/spawner/spawn-team.d.ts +14 -52
- package/dist/spawner/spawn-team.d.ts.map +1 -1
- package/dist/spawner/spawn-team.js +14 -469
- package/dist/spawner/spawn-team.js.map +1 -1
- package/dist/staleness.d.ts +124 -0
- package/dist/staleness.d.ts.map +1 -0
- package/dist/staleness.js +215 -0
- package/dist/staleness.js.map +1 -0
- package/dist/state-cascade.d.ts +3 -2
- package/dist/state-cascade.d.ts.map +1 -1
- package/dist/state-cascade.js +7 -3
- package/dist/state-cascade.js.map +1 -1
- package/dist/types/focus.d.ts +5 -4
- package/dist/types/focus.d.ts.map +1 -1
- package/dist/types/session.d.ts +2 -3
- package/dist/types/session.d.ts.map +1 -1
- package/dist/unified-shell.d.ts.map +1 -1
- package/dist/unified-shell.js +21 -12
- package/dist/unified-shell.js.map +1 -1
- package/package.json +2 -2
- package/dist/session-lifecycle.d.ts +0 -78
- package/dist/session-lifecycle.d.ts.map +0 -1
- package/dist/session-lifecycle.js +0 -382
- package/dist/session-lifecycle.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase sync: stage detection for the directive edge-trigger.
|
|
3
|
+
*
|
|
4
|
+
* Decides which workflow stage a focus should be in (new lifecycle stage
|
|
5
|
+
* names take priority over the legacy delivery-aggregate phase derivation),
|
|
6
|
+
* synchronizes `product_focuses.current_workflow_stage_id` with that decision,
|
|
7
|
+
* detects stranded reviews that need a directive re-fire, and fires on_enter
|
|
8
|
+
* transition triggers. Extracted from directive-executor.ts; the executor
|
|
9
|
+
* re-exports the public surface so existing importers are unaffected.
|
|
10
|
+
*/
|
|
11
|
+
import { fetchFocusWorkflow, fetchFocusWorkflowWithTransitions, getFocusDeliveries, updateFocusWorkflowStage, } from '../queries/focuses.js';
|
|
12
|
+
import { fetchTransitionGuards } from '../queries/guards.js';
|
|
13
|
+
import { executeAdvanceLinkedInjections } from '../trigger-executor.js';
|
|
14
|
+
import { deriveFocusPhase } from '../focus-phase.js';
|
|
15
|
+
// ── Focus transition trigger execution ────────────────────────
|
|
16
|
+
/**
|
|
17
|
+
* Fire on_enter triggers for a focus stage transition.
|
|
18
|
+
*
|
|
19
|
+
* Looks up the workflow transition from lastStageId to currentStageId,
|
|
20
|
+
* fetches triggers on that transition, and executes on_enter triggers.
|
|
21
|
+
* Currently supports advance_linked_injections; other action types
|
|
22
|
+
* are logged and skipped.
|
|
23
|
+
*/
|
|
24
|
+
export async function fireFocusTransitionTriggers(focusId, lastStageId, currentStageId) {
|
|
25
|
+
if (!lastStageId)
|
|
26
|
+
return; // First time seeing this focus, no transition to fire
|
|
27
|
+
try {
|
|
28
|
+
// Find the transition between the two stages
|
|
29
|
+
const workflow = await fetchFocusWorkflowWithTransitions(focusId);
|
|
30
|
+
const transition = workflow.transitions?.find(t => t.from_stage_id === lastStageId && t.to_stage_id === currentStageId);
|
|
31
|
+
if (!transition)
|
|
32
|
+
return; // No transition found (possible for non-standard stage jumps)
|
|
33
|
+
// Fetch triggers on this transition
|
|
34
|
+
const resolved = await fetchTransitionGuards(transition.id);
|
|
35
|
+
const onEnterTriggers = resolved.triggers.filter(t => t.trigger_event === 'on_enter');
|
|
36
|
+
if (onEnterTriggers.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
for (const trigger of onEnterTriggers) {
|
|
39
|
+
try {
|
|
40
|
+
if (trigger.action_type === 'advance_linked_injections') {
|
|
41
|
+
await executeAdvanceLinkedInjections(focusId, trigger.action_config);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(`[directive-executor] Focus trigger "${trigger.name}" (${trigger.action_type}) ` +
|
|
45
|
+
`skipped -- not supported in focus context`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
console.warn(`[directive-executor] Failed to execute focus trigger "${trigger.name}":`, err.message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
console.warn(`[directive-executor] Failed to fire focus transition triggers for ${focusId.slice(0, 8)}:`, err.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// ── Phase sync ───────────────────────────────────────────────────
|
|
58
|
+
/**
|
|
59
|
+
* New focus workflow lifecycle stage names introduced by D1
|
|
60
|
+
* (20260513152817_focus_workflow_lifecycle_and_tree_closure.sql).
|
|
61
|
+
*
|
|
62
|
+
* When `product_focuses.stage` is one of these, the daemon takes the
|
|
63
|
+
* denormalized `focus.stage` as authoritative and maps it directly to the
|
|
64
|
+
* matching workflow_stages row — this is how the new lifecycle (verify ->
|
|
65
|
+
* review -> close_loop -> done) drives the daemon, rather than the legacy
|
|
66
|
+
* delivery-aggregate phase derivation. The legacy derivation is kept as a
|
|
67
|
+
* fallback for focuses still on the older
|
|
68
|
+
* kickoff/coding/verifying/reviewing/winding_down flow.
|
|
69
|
+
*/
|
|
70
|
+
const LIFECYCLE_STAGE_NAMES = new Set([
|
|
71
|
+
'queued',
|
|
72
|
+
'verify',
|
|
73
|
+
'review',
|
|
74
|
+
'close_loop',
|
|
75
|
+
'done',
|
|
76
|
+
]);
|
|
77
|
+
/**
|
|
78
|
+
* Decide which workflow stage name a focus should be in.
|
|
79
|
+
*
|
|
80
|
+
* Pure helper, exported for testing. The selection rule is:
|
|
81
|
+
* 1. If `focus.stage` is one of the new lifecycle stage names
|
|
82
|
+
* (`queued`/`verify`/`review`/`close_loop`/`done`), use it directly.
|
|
83
|
+
* The denormalized stage is the authoritative signal under the new
|
|
84
|
+
* workflow.
|
|
85
|
+
* 2. Otherwise, fall back to the legacy phase derived from the delivery
|
|
86
|
+
* aggregate (kickoff/coding/verifying/reviewing/winding_down/blocked).
|
|
87
|
+
*
|
|
88
|
+
* Note: `review_requested_at` is still read by the legacy derivation for
|
|
89
|
+
* back-compat -- but on the new lifecycle path the `review` stage transition
|
|
90
|
+
* is driven by writes to `product_focuses.stage`, not by writes to
|
|
91
|
+
* `review_requested_at`. This is the Issue 1 contract.
|
|
92
|
+
*/
|
|
93
|
+
export function resolveFocusStageName(input) {
|
|
94
|
+
if (input.focusStage && LIFECYCLE_STAGE_NAMES.has(input.focusStage)) {
|
|
95
|
+
return input.focusStage;
|
|
96
|
+
}
|
|
97
|
+
return deriveFocusPhase({
|
|
98
|
+
deliveries: input.deliveries,
|
|
99
|
+
reviewRequestedAt: input.reviewRequestedAt,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Stage names that represent the focus review window: 'reviewing' on the
|
|
104
|
+
* legacy delivery-aggregate phase derivation, 'review' on the new focus
|
|
105
|
+
* workflow lifecycle. Either means "a review is the gate to done".
|
|
106
|
+
*/
|
|
107
|
+
const REVIEW_STAGE_NAMES = new Set(['reviewing', 'review']);
|
|
108
|
+
/**
|
|
109
|
+
* Decide whether to re-fire a focus's review-stage directive even though the
|
|
110
|
+
* edge-trigger (lastProcessedStages) already marked the stage processed.
|
|
111
|
+
*
|
|
112
|
+
* The edge-trigger fires a stage directive exactly once per stage entry. For
|
|
113
|
+
* the review stage that is normally correct -- a clean review completes, clears
|
|
114
|
+
* review_requested_at, and the focus leaves the review phase. But if the review
|
|
115
|
+
* team never spawned or was killed (e.g. a lifecycle SIGTERM) before routing,
|
|
116
|
+
* the focus stays in the review stage with review_requested_at still set and the
|
|
117
|
+
* directive never re-fires: a silent stuck focus (the founding bug of this focus).
|
|
118
|
+
*
|
|
119
|
+
* A focus STILL in the review stage with review_requested_at set is provably
|
|
120
|
+
* stranded -- any completed review clears review_requested_at and moves the
|
|
121
|
+
* phase. So when no review team is running, re-firing the directive is the
|
|
122
|
+
* self-healing recovery: it respawns the review team. Once a team is running the
|
|
123
|
+
* active-team guard suppresses the re-fire, and a successful review auto-approves
|
|
124
|
+
* and leaves the stage -- so the re-fire is bounded, not a per-poll spin.
|
|
125
|
+
*
|
|
126
|
+
* Pure and exported for unit testing.
|
|
127
|
+
*/
|
|
128
|
+
export function shouldRefireStrandedReview(input) {
|
|
129
|
+
if (!input.stageName || !REVIEW_STAGE_NAMES.has(input.stageName))
|
|
130
|
+
return false;
|
|
131
|
+
if (!input.reviewRequestedAt)
|
|
132
|
+
return false;
|
|
133
|
+
if (input.hasActiveTeam)
|
|
134
|
+
return false;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Synchronize `product_focuses.current_workflow_stage_id` with the focus's
|
|
139
|
+
* authoritative stage. The authoritative stage is taken from `focus.stage`
|
|
140
|
+
* when it names one of the new lifecycle stages (Issue 1); otherwise the
|
|
141
|
+
* legacy delivery-aggregate phase derivation applies.
|
|
142
|
+
*
|
|
143
|
+
* Returns the stage ID the focus should be in (post-sync). Falls back to
|
|
144
|
+
* the recorded stage id on error so callers don't have to handle a third
|
|
145
|
+
* "unknown" state.
|
|
146
|
+
*/
|
|
147
|
+
export async function syncFocusPhase(focus) {
|
|
148
|
+
try {
|
|
149
|
+
const deliveries = await getFocusDeliveries(focus.focus_id);
|
|
150
|
+
const stageName = resolveFocusStageName({
|
|
151
|
+
focusStage: focus.stage ?? null,
|
|
152
|
+
deliveries: deliveries.map((d) => ({ executionStatus: d.executionStatus })),
|
|
153
|
+
reviewRequestedAt: focus.review_requested_at,
|
|
154
|
+
});
|
|
155
|
+
const workflow = await fetchFocusWorkflow(focus.focus_id);
|
|
156
|
+
const stage = workflow.stages.find((s) => s.name === stageName);
|
|
157
|
+
if (!stage) {
|
|
158
|
+
console.warn(`[directive-executor] No "${stageName}" stage in workflow for focus ` +
|
|
159
|
+
`${focus.focus_id.slice(0, 8)}; phase sync skipped.`);
|
|
160
|
+
return focus.current_workflow_stage_id;
|
|
161
|
+
}
|
|
162
|
+
if (stage.id !== focus.current_workflow_stage_id) {
|
|
163
|
+
await updateFocusWorkflowStage(focus.focus_id, stage.id);
|
|
164
|
+
console.log(`[directive-executor] Focus ${focus.focus_id.slice(0, 8)} stage -> ${stageName}`);
|
|
165
|
+
}
|
|
166
|
+
return stage.id;
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
console.warn(`[directive-executor] Phase sync failed for focus ${focus.focus_id.slice(0, 8)}:`, err.message);
|
|
170
|
+
return focus.current_workflow_stage_id;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=phase-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-sync.js","sourceRoot":"","sources":["../../src/directive/phase-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,iEAAiE;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAe,EACf,WAA+B,EAC/B,cAAsB;IAEtB,IAAI,CAAC,WAAW;QAAE,OAAO,CAAC,sDAAsD;IAEhF,IAAI,CAAC;QACH,6CAA6C;QAC7C,MAAM,QAAQ,GAAG,MAAM,iCAAiC,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,IAAI,CAC3C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,WAAW,IAAI,CA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StageDirective, DirectiveExecutionMode } from './types.js';
|
|
10
|
-
import { type AssemblyManifestEntry } from './assembly-engine.js';
|
|
11
|
-
import './assembly-resolvers.js';
|
|
12
|
-
import { type LineageSpec } from './session-lineage.js';
|
|
13
|
-
import { type CloseLoopDecision } from './close-loop-dispatcher.js';
|
|
14
|
-
import { createEscalation } from './queries/issues.js';
|
|
15
|
-
export { seedLastProcessedStage, getLastProcessedStages } from './directive/stage-tracker.js';
|
|
16
|
-
export { computeDirectiveHash, SPAWN_GUARD_WINDOW_MS, shouldSkipSpawnDirective, consumePendingSpawnDirective, __setPendingSpawnDirectiveForTesting, hasPendingSpawnDirective, getPendingSpawnDirective, getPendingSpawnFocusIds, shouldSuppressRefireForPendingSpawn, type PendingSpawnDirective, } from './directive/directive-queue.js';
|
|
17
|
-
/** Assembled directive content paired with its per-source attribution manifest. */
|
|
18
|
-
export interface AssembledDirective {
|
|
19
|
-
content: string;
|
|
20
|
-
manifest: AssemblyManifestEntry[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Assemble directive content from a StageDirective's recipe and prompt.
|
|
24
|
-
* Shared by both inject and spawn modes, and by focus-executor for
|
|
25
|
-
* initial spawn with a stage directive.
|
|
26
|
-
*/
|
|
27
|
-
export declare function assembleDirectiveContent(config: DaemonConfig, focusId: string, directive: StageDirective, worktreePath: string | null): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Assemble directive content AND return the assembly manifest (one entry per
|
|
30
|
-
* recipe source). The composed `content` is identical to
|
|
31
|
-
* assembleDirectiveContent; the manifest lets the spawn path persist what
|
|
32
|
-
* context was injected. The manifest covers ONLY the assembly recipe -- the
|
|
33
|
-
* static directive.prompt / tool guidance are not assembly sources.
|
|
34
|
-
*/
|
|
35
|
-
export declare function assembleDirectiveContentWithManifest(config: DaemonConfig, focusId: string, directive: StageDirective, worktreePath: string | null): Promise<AssembledDirective>;
|
|
36
|
-
/**
|
|
37
|
-
* Resolve the execution mode a directive should dispatch under.
|
|
38
|
-
*
|
|
39
|
-
* Pure + exported for testing. The rule:
|
|
40
|
-
* - A valid mode ('inject' | 'spawn') passes through unchanged.
|
|
41
|
-
* - A review-lineage directive whose execution is missing/invalid defaults
|
|
42
|
-
* to 'spawn'. Review always spawns a fresh team, so 'spawn' is the only
|
|
43
|
-
* sensible mode for that lineage; defaulting here self-heals malformed or
|
|
44
|
-
* seed-drifted review directives (e.g. the focus 'review' stage whose
|
|
45
|
-
* agent_directive lost its execution field -- see the backfill migration)
|
|
46
|
-
* so the review-spawn path can no longer be silently stranded.
|
|
47
|
-
* - Anything else is UNRESOLVABLE (returns null). The caller treats null as
|
|
48
|
-
* a fail-loud condition (throw -> escalate + loop trigger) rather than a
|
|
49
|
-
* silent no-op.
|
|
50
|
-
*
|
|
51
|
-
* Note: a review-lineage directive defaults to spawn even for a non-empty but
|
|
52
|
-
* unrecognized execution value -- review is always spawnable, so we self-heal
|
|
53
|
-
* rather than fail. Non-review lineages have no safe default and fail loud.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveDirectiveExecutionMode(execution: string | null | undefined, lineage: string): DirectiveExecutionMode | null;
|
|
56
|
-
/**
|
|
57
|
-
* Execute a stage directive for a focus.
|
|
58
|
-
*
|
|
59
|
-
* inject mode: sends /compact + assembled context + prompt to the active team's stdin.
|
|
60
|
-
* spawn mode: terminates the current team, assembles directive content, stores for respawn.
|
|
61
|
-
*
|
|
62
|
-
* When the directive's execution mode cannot be resolved to a valid mode
|
|
63
|
-
* (see resolveDirectiveExecutionMode), this THROWS instead of silently
|
|
64
|
-
* no-oping. The throw propagates through runDirectiveWithRetry in
|
|
65
|
-
* checkDirectives, which escalates and emits a loop trigger -- so a malformed
|
|
66
|
-
* directive surfaces a signal instead of stranding the focus.
|
|
67
|
-
*
|
|
68
|
-
* Exported for testing.
|
|
69
|
-
*/
|
|
70
|
-
export declare function executeDirective(config: DaemonConfig, focusId: string, directive: StageDirective, focusWorkflowStageId: string, stageName?: string): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Inject mode: send /compact + assembled context + prompt to the active team's stdin.
|
|
73
|
-
*/
|
|
74
|
-
export declare function executeInjectDirective(config: DaemonConfig, focusId: string, directive: StageDirective, sessionType?: 'coding' | 'review', spec?: LineageSpec): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Decide which workflow stage name a focus should be in.
|
|
77
|
-
*
|
|
78
|
-
* Pure helper, exported for testing. The selection rule is:
|
|
79
|
-
* 1. If `focus.stage` is one of the new lifecycle stage names
|
|
80
|
-
* (`queued`/`verify`/`review`/`close_loop`/`done`), use it directly.
|
|
81
|
-
* The denormalized stage is the authoritative signal under the new
|
|
82
|
-
* workflow.
|
|
83
|
-
* 2. Otherwise, fall back to the legacy phase derived from the delivery
|
|
84
|
-
* aggregate (kickoff/coding/verifying/reviewing/winding_down/blocked).
|
|
85
|
-
*
|
|
86
|
-
* Note: `review_requested_at` is still read by the legacy derivation for
|
|
87
|
-
* back-compat -- but on the new lifecycle path the `review` stage transition
|
|
88
|
-
* is driven by writes to `product_focuses.stage`, not by writes to
|
|
89
|
-
* `review_requested_at`. This is the Issue 1 contract.
|
|
90
|
-
*/
|
|
91
|
-
export declare function resolveFocusStageName(input: {
|
|
92
|
-
focusStage: string | null | undefined;
|
|
93
|
-
deliveries: Array<{
|
|
94
|
-
executionStatus: string | null;
|
|
95
|
-
}>;
|
|
96
|
-
reviewRequestedAt: string | null;
|
|
97
|
-
}): string;
|
|
98
|
-
/**
|
|
99
|
-
* Decide whether to re-fire a focus's review-stage directive even though the
|
|
100
|
-
* edge-trigger (lastProcessedStages) already marked the stage processed.
|
|
4
|
+
* "What happens when a stage changes" reads from here: checkDirectives
|
|
5
|
+
* (called from the daemon poll loop) walks active focuses, syncs each
|
|
6
|
+
* focus's workflow stage, and edge-triggers the stage's agent_directive.
|
|
7
|
+
* The real logic lives in focused modules under directive/:
|
|
101
8
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* directive
|
|
9
|
+
* - directive/phase-sync.ts stage detection + phase sync + transition triggers
|
|
10
|
+
* - directive/directive-assembly.ts assembly of directive content (recipe + prompt + tools)
|
|
11
|
+
* - directive/directive-dispatch.ts inject-to-stdin / spawn-queue execution + bounded retry
|
|
12
|
+
* - directive/close-loop-stage.ts close_loop stage dispatcher (bookkeeper + sweep)
|
|
13
|
+
* - directive/stage-tracker.ts lastProcessedStages map + accessors
|
|
14
|
+
* - directive/directive-queue.ts pendingSpawnDirectives map + identity/guard helpers
|
|
108
15
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* self-healing recovery: it respawns the review team. Once a team is running the
|
|
113
|
-
* active-team guard suppresses the re-fire, and a successful review auto-approves
|
|
114
|
-
* and leaves the stage -- so the re-fire is bounded, not a per-poll spin.
|
|
115
|
-
*
|
|
116
|
-
* Pure and exported for unit testing.
|
|
117
|
-
*/
|
|
118
|
-
export declare function shouldRefireStrandedReview(input: {
|
|
119
|
-
stageName: string | undefined;
|
|
120
|
-
reviewRequestedAt: string | null;
|
|
121
|
-
hasActiveTeam: boolean;
|
|
122
|
-
}): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Synchronize `product_focuses.current_workflow_stage_id` with the focus's
|
|
125
|
-
* authoritative stage. The authoritative stage is taken from `focus.stage`
|
|
126
|
-
* when it names one of the new lifecycle stages (Issue 1); otherwise the
|
|
127
|
-
* legacy delivery-aggregate phase derivation applies.
|
|
128
|
-
*
|
|
129
|
-
* Returns the stage ID the focus should be in (post-sync). Falls back to
|
|
130
|
-
* the recorded stage id on error so callers don't have to handle a third
|
|
131
|
-
* "unknown" state.
|
|
132
|
-
*/
|
|
133
|
-
export declare function syncFocusPhase(focus: {
|
|
134
|
-
focus_id: string;
|
|
135
|
-
current_workflow_stage_id: string | null;
|
|
136
|
-
review_requested_at: string | null;
|
|
137
|
-
/**
|
|
138
|
-
* Denormalized lifecycle stage from product_focuses.stage. Optional for
|
|
139
|
-
* back-compat with old API responses; absence is treated as "fall back to
|
|
140
|
-
* the legacy phase derivation".
|
|
141
|
-
*/
|
|
142
|
-
stage?: string | null;
|
|
143
|
-
}): Promise<string | null>;
|
|
144
|
-
/**
|
|
145
|
-
* Result of a bounded-retry attempt to run a directive. The retry is on
|
|
146
|
-
* ANY thrown error (assembly resolver throws, fetch failures, Supabase
|
|
147
|
-
* timeouts) -- broader than `withRetry` from daemon-core, which classifies
|
|
148
|
-
* by error type. Transient failures during directive execution are not
|
|
149
|
-
* always classified as network errors, but they're still worth retrying
|
|
150
|
-
* before treating as permanent.
|
|
16
|
+
* This module RE-EXPORTS the full prior public surface so existing importers
|
|
17
|
+
* (listener, focus-executor, spawner/spawn-team, completion/team-completion,
|
|
18
|
+
* tests) are unaffected.
|
|
151
19
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
export interface RunDirectiveOptions {
|
|
161
|
-
maxAttempts?: number;
|
|
162
|
-
baseDelayMs?: number;
|
|
163
|
-
label: string;
|
|
164
|
-
/** Sleep implementation -- override in tests to avoid real delays. */
|
|
165
|
-
sleep?: (ms: number) => Promise<void>;
|
|
166
|
-
/** Called once per failed attempt before the backoff sleep. */
|
|
167
|
-
onAttemptFailed?: (attempt: number, error: Error) => void;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Run a directive function with bounded retry and exponential backoff.
|
|
171
|
-
* Returns a result tuple instead of throwing so the caller can decide
|
|
172
|
-
* whether to escalate or continue.
|
|
173
|
-
*/
|
|
174
|
-
export declare function runDirectiveWithRetry(fn: () => Promise<void>, options: RunDirectiveOptions): Promise<DirectiveRunResult>;
|
|
175
|
-
/**
|
|
176
|
-
* Escalate when bounded retry of a stage directive is exhausted.
|
|
177
|
-
*
|
|
178
|
-
* Visible signal so operators can find which focus + stage failed and
|
|
179
|
-
* why, instead of a buried console.warn. Mirrors escalatePlanningFailure
|
|
180
|
-
* from focus-completion-event.ts.
|
|
181
|
-
*/
|
|
182
|
-
export declare function escalateDirectiveFailure(params: {
|
|
183
|
-
organizationId: string;
|
|
184
|
-
sessionId: string;
|
|
185
|
-
focusId: string;
|
|
186
|
-
focusName: string;
|
|
187
|
-
stageName: string | undefined;
|
|
188
|
-
error: Error;
|
|
189
|
-
attempts: number;
|
|
190
|
-
}, deps?: {
|
|
191
|
-
createEscalation: typeof createEscalation;
|
|
192
|
-
}): Promise<void>;
|
|
193
|
-
/** Test helper: clear the bookkeeper-spawned set. */
|
|
194
|
-
export declare function __resetCloseLoopStateForTesting(): void;
|
|
195
|
-
/**
|
|
196
|
-
* Inspect open escalations and return the set of injection ids that have
|
|
197
|
-
* an active `injection_unverified` escalation (status pending or
|
|
198
|
-
* in_review). Used by the close_loop dispatcher to classify "escalated"
|
|
199
|
-
* injections as terminal.
|
|
200
|
-
*
|
|
201
|
-
* The `metadata.injection_id` field is set by the bookkeeper persona when
|
|
202
|
-
* filing the escalation -- see the close_loop directive prompt.
|
|
203
|
-
*/
|
|
204
|
-
export declare function getOpenInjectionUnverifiedEscalationIds(): Promise<Set<string>>;
|
|
205
|
-
/**
|
|
206
|
-
* Dispatch the close_loop stage for one focus.
|
|
207
|
-
*
|
|
208
|
-
* Reads the focus's anchored deliveries + injection statuses + open
|
|
209
|
-
* escalations, then runs the pure `decideCloseLoop` to determine whether
|
|
210
|
-
* to short-circuit, spawn a bookkeeper, advance to done, or hold.
|
|
211
|
-
*
|
|
212
|
-
* Returns the decision so the caller (or a test) can log/assert.
|
|
213
|
-
*
|
|
214
|
-
* Idempotent across poll cycles -- the `closeLoopBookkeeperSpawned` set
|
|
215
|
-
* ensures the bookkeeper is spawned at most once per focus visit to
|
|
216
|
-
* close_loop. Tests reset this via `__resetCloseLoopStateForTesting`.
|
|
217
|
-
*/
|
|
218
|
-
export declare function dispatchCloseLoopStage(config: DaemonConfig, focus: {
|
|
219
|
-
focus_id: string;
|
|
220
|
-
focus_name: string;
|
|
221
|
-
}): Promise<CloseLoopDecision>;
|
|
222
|
-
/**
|
|
223
|
-
* Pure helper exported for tests: build the close_loop directive and verify
|
|
224
|
-
* it carries the expected assembly + model. The buildCloseLoopDirective
|
|
225
|
-
* function in close-loop-dispatcher.ts already does this; this is a
|
|
226
|
-
* dispatcher-side smoke export so the tests can grep through it.
|
|
227
|
-
*/
|
|
228
|
-
export declare function getCloseLoopDirectiveForTesting(): StageDirective;
|
|
20
|
+
import type { DaemonConfig } from './types.js';
|
|
21
|
+
export { seedLastProcessedStage, getLastProcessedStages } from './directive/stage-tracker.js';
|
|
22
|
+
export { computeDirectiveHash, SPAWN_GUARD_WINDOW_MS, shouldSkipSpawnDirective, consumePendingSpawnDirective, __setPendingSpawnDirectiveForTesting, hasPendingSpawnDirective, getPendingSpawnDirective, getPendingSpawnFocusIds, shouldSuppressRefireForPendingSpawn, type PendingSpawnDirective, } from './directive/directive-queue.js';
|
|
23
|
+
export { type AssembledDirective, assembleDirectiveContent, assembleDirectiveContentWithManifest, } from './directive/directive-assembly.js';
|
|
24
|
+
export { fireFocusTransitionTriggers, resolveFocusStageName, shouldRefireStrandedReview, syncFocusPhase, } from './directive/phase-sync.js';
|
|
25
|
+
export { resolveDirectiveExecutionMode, executeDirective, executeInjectDirective, type DirectiveRunResult, type RunDirectiveOptions, runDirectiveWithRetry, escalateDirectiveFailure, } from './directive/directive-dispatch.js';
|
|
26
|
+
export { __resetCloseLoopStateForTesting, getOpenInjectionUnverifiedEscalationIds, dispatchCloseLoopStage, getCloseLoopDirectiveForTesting, } from './directive/close-loop-stage.js';
|
|
229
27
|
/**
|
|
230
28
|
* Check all active focuses for stage changes with directives.
|
|
231
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directive-executor.d.ts","sourceRoot":"","sources":["../src/directive-executor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"directive-executor.d.ts","sourceRoot":"","sources":["../src/directive-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA+B/C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,oCAAoC,EACpC,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,mCAAmC,EACnC,KAAK,qBAAqB,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,oCAAoC,GACrC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,+BAA+B,EAC/B,uCAAuC,EACvC,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,iCAAiC,CAAC;AAIzC;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0LzE"}
|