@telora/daemon 0.21.134 → 0.21.144
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 +2 -2
- package/dist/audit/audit-hooks.d.ts +15 -6
- package/dist/audit/audit-hooks.d.ts.map +1 -1
- package/dist/audit/audit-hooks.js +56 -28
- package/dist/audit/audit-hooks.js.map +1 -1
- package/dist/ci/ci-escalation.js +1 -1
- package/dist/ci/ci-escalation.js.map +1 -1
- package/dist/ci/ci-sensor-loop.d.ts +24 -0
- package/dist/ci/ci-sensor-loop.d.ts.map +1 -1
- package/dist/ci/ci-sensor-loop.js +35 -9
- package/dist/ci/ci-sensor-loop.js.map +1 -1
- package/dist/cli/connect/config-write.d.ts +87 -0
- package/dist/cli/connect/config-write.d.ts.map +1 -0
- package/dist/cli/connect/config-write.js +255 -0
- package/dist/cli/connect/config-write.js.map +1 -0
- package/dist/cli/connect/registration.d.ts +76 -0
- package/dist/cli/connect/registration.d.ts.map +1 -0
- package/dist/cli/connect/registration.js +207 -0
- package/dist/cli/connect/registration.js.map +1 -0
- package/dist/cli/connect.d.ts +3 -141
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +9 -441
- package/dist/cli/connect.js.map +1 -1
- package/dist/completion/coverage-stabilized.d.ts +1 -1
- package/dist/completion/coverage-stabilized.d.ts.map +1 -1
- package/dist/completion/coverage-stabilized.js +1 -1
- package/dist/completion/coverage-stabilized.js.map +1 -1
- package/dist/completion/escalation-provenance.d.ts +2 -1
- package/dist/completion/escalation-provenance.d.ts.map +1 -1
- package/dist/completion/escalation-provenance.js +2 -1
- package/dist/completion/escalation-provenance.js.map +1 -1
- package/dist/completion/escalations.js +1 -1
- package/dist/completion/escalations.js.map +1 -1
- package/dist/completion/event-escalations.d.ts +1 -1
- package/dist/completion/event-escalations.d.ts.map +1 -1
- package/dist/completion/event-escalations.js +1 -1
- package/dist/completion/event-escalations.js.map +1 -1
- package/dist/completion/event.d.ts +1 -1
- package/dist/completion/event.d.ts.map +1 -1
- package/dist/completion/event.js +2 -2
- package/dist/completion/event.js.map +1 -1
- package/dist/completion/machine-remediable-demotion.d.ts +1 -1
- package/dist/completion/machine-remediable-demotion.d.ts.map +1 -1
- package/dist/completion/machine-remediable-demotion.js +2 -1
- package/dist/completion/machine-remediable-demotion.js.map +1 -1
- package/dist/completion/read-only-pristine.d.ts +1 -1
- package/dist/completion/read-only-pristine.d.ts.map +1 -1
- package/dist/completion/read-only-pristine.js +1 -1
- package/dist/completion/read-only-pristine.js.map +1 -1
- package/dist/completion/review-exit-escalations.d.ts +1 -1
- package/dist/completion/review-exit-escalations.d.ts.map +1 -1
- package/dist/completion/review-exit-phase.d.ts +5 -2
- package/dist/completion/review-exit-phase.d.ts.map +1 -1
- package/dist/completion/review-exit-phase.js +5 -2
- package/dist/completion/review-exit-phase.js.map +1 -1
- package/dist/completion/state-cascade.js +1 -1
- package/dist/completion/state-cascade.js.map +1 -1
- package/dist/completion/status-advance-phase.d.ts.map +1 -1
- package/dist/completion/status-advance-phase.js +2 -1
- package/dist/completion/status-advance-phase.js.map +1 -1
- package/dist/completion/team-lifecycle.d.ts.map +1 -1
- package/dist/completion/team-lifecycle.js +2 -1
- package/dist/completion/team-lifecycle.js.map +1 -1
- package/dist/delivery/delivery-advance-block.d.ts +1 -1
- package/dist/delivery/delivery-advance-block.d.ts.map +1 -1
- package/dist/delivery/delivery-advance-block.js +1 -1
- package/dist/delivery/delivery-advance-block.js.map +1 -1
- package/dist/delivery/delivery-lifecycle.js +1 -1
- package/dist/delivery/delivery-lifecycle.js.map +1 -1
- package/dist/delivery/delivery-merge-ops.js +1 -1
- package/dist/delivery/delivery-merge-ops.js.map +1 -1
- package/dist/delivery/delivery-reconciler-shadow.d.ts +1 -1
- package/dist/delivery/delivery-reconciler-shadow.d.ts.map +1 -1
- package/dist/delivery/delivery-reconciler-shadow.js +1 -1
- package/dist/delivery/delivery-reconciler-shadow.js.map +1 -1
- package/dist/delivery/operator-hold.d.ts +1 -1
- package/dist/delivery/operator-hold.d.ts.map +1 -1
- package/dist/delivery/paused-revival.d.ts.map +1 -1
- package/dist/delivery/paused-revival.js +2 -1
- package/dist/delivery/paused-revival.js.map +1 -1
- package/dist/directive/directive-dispatch.d.ts +1 -1
- package/dist/directive/directive-dispatch.d.ts.map +1 -1
- package/dist/directive/directive-dispatch.js +1 -1
- package/dist/directive/directive-dispatch.js.map +1 -1
- package/dist/directive/directive-executor.js +1 -1
- package/dist/directive/directive-executor.js.map +1 -1
- package/dist/drift/staleness-sensor.js +1 -1
- package/dist/drift/staleness-sensor.js.map +1 -1
- package/dist/focus/focus-engine.js +3 -2
- package/dist/focus/focus-engine.js.map +1 -1
- package/dist/focus/focus-lifecycle.d.ts.map +1 -1
- package/dist/focus/focus-lifecycle.js +2 -1
- package/dist/focus/focus-lifecycle.js.map +1 -1
- package/dist/focus/focus-respawn-guard.d.ts +1 -1
- package/dist/focus/focus-respawn-guard.d.ts.map +1 -1
- package/dist/focus/focus-respawn-guard.js +1 -1
- package/dist/focus/focus-respawn-guard.js.map +1 -1
- package/dist/focus/listener-auto-advance.d.ts +4 -45
- package/dist/focus/listener-auto-advance.d.ts.map +1 -1
- package/dist/focus/listener-auto-advance.js +5 -238
- package/dist/focus/listener-auto-advance.js.map +1 -1
- package/dist/focus/listener-spawn.d.ts +62 -0
- package/dist/focus/listener-spawn.d.ts.map +1 -0
- package/dist/focus/listener-spawn.js +418 -0
- package/dist/focus/listener-spawn.js.map +1 -0
- package/dist/focus/listener-state.d.ts +57 -0
- package/dist/focus/listener-state.d.ts.map +1 -0
- package/dist/focus/listener-state.js +63 -0
- package/dist/focus/listener-state.js.map +1 -0
- package/dist/focus/listener.d.ts +0 -58
- package/dist/focus/listener.d.ts.map +1 -1
- package/dist/focus/listener.js +25 -453
- package/dist/focus/listener.js.map +1 -1
- package/dist/focus/verify-open-issues.d.ts +62 -0
- package/dist/focus/verify-open-issues.d.ts.map +1 -0
- package/dist/focus/verify-open-issues.js +265 -0
- package/dist/focus/verify-open-issues.js.map +1 -0
- package/dist/focus-stage-lifecycle/index.d.ts +1 -1
- package/dist/focus-stage-lifecycle/index.d.ts.map +1 -1
- package/dist/focus-stage-lifecycle/index.js +1 -1
- package/dist/focus-stage-lifecycle/index.js.map +1 -1
- package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts +1 -1
- package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts.map +1 -1
- package/dist/focus-stage-lifecycle/wedge-watchdog.js +1 -1
- package/dist/focus-stage-lifecycle/wedge-watchdog.js.map +1 -1
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.d.ts.map +1 -1
- package/dist/git/index.js +2 -0
- package/dist/git/index.js.map +1 -1
- package/dist/git/merge-strategies.d.ts +80 -0
- package/dist/git/merge-strategies.d.ts.map +1 -0
- package/dist/git/merge-strategies.js +218 -0
- package/dist/git/merge-strategies.js.map +1 -0
- package/dist/git/merge-to-main.d.ts +76 -0
- package/dist/git/merge-to-main.d.ts.map +1 -0
- package/dist/git/merge-to-main.js +256 -0
- package/dist/git/merge-to-main.js.map +1 -0
- package/dist/git/merge.d.ts +27 -81
- package/dist/git/merge.d.ts.map +1 -1
- package/dist/git/merge.js +4 -448
- package/dist/git/merge.js.map +1 -1
- package/dist/git/state-detector.js +1 -1
- package/dist/git/state-detector.js.map +1 -1
- package/dist/loops/engine.js +1 -1
- package/dist/loops/engine.js.map +1 -1
- package/dist/merge/focus-merge.d.ts +1 -1
- package/dist/merge/focus-merge.d.ts.map +1 -1
- package/dist/merge/focus-merge.js +1 -1
- package/dist/merge/focus-merge.js.map +1 -1
- package/dist/merge/merge-back-loop.d.ts +1 -1
- package/dist/merge/merge-back-loop.d.ts.map +1 -1
- package/dist/merge/merge-back-loop.js +2 -2
- package/dist/merge/merge-back-loop.js.map +1 -1
- package/dist/merge/merge-detector.js +1 -1
- package/dist/merge/merge-detector.js.map +1 -1
- package/dist/nexus/return.js +1 -1
- package/dist/nexus/return.js.map +1 -1
- package/dist/prd/controller-shared.d.ts +223 -0
- package/dist/prd/controller-shared.d.ts.map +1 -0
- package/dist/prd/controller-shared.js +77 -0
- package/dist/prd/controller-shared.js.map +1 -0
- package/dist/prd/controller.d.ts +5 -256
- package/dist/prd/controller.d.ts.map +1 -1
- package/dist/prd/controller.js +9 -166
- package/dist/prd/controller.js.map +1 -1
- package/dist/prd/done-sweep.d.ts +55 -0
- package/dist/prd/done-sweep.d.ts.map +1 -0
- package/dist/prd/done-sweep.js +112 -0
- package/dist/prd/done-sweep.js.map +1 -0
- package/dist/prompt-sections/execution-sections.d.ts +1 -1
- package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
- package/dist/prompt-sections/execution-sections.js +12 -2
- package/dist/prompt-sections/execution-sections.js.map +1 -1
- package/dist/prompt-sections/shared.d.ts +1 -1
- package/dist/prompt-sections/shared.d.ts.map +1 -1
- package/dist/queries/agent-resolvable-promotion.d.ts +1 -1
- package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -1
- package/dist/queries/agent-resolvable-promotion.js +2 -1
- package/dist/queries/agent-resolvable-promotion.js.map +1 -1
- package/dist/queries/deliveries.d.ts +0 -195
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js +1 -83
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/escalation-consumption.d.ts +120 -0
- package/dist/queries/escalation-consumption.d.ts.map +1 -0
- package/dist/queries/escalation-consumption.js +143 -0
- package/dist/queries/escalation-consumption.js.map +1 -0
- package/dist/queries/escalation-dispositions.d.ts +19 -0
- package/dist/queries/escalation-dispositions.d.ts.map +1 -0
- package/dist/queries/escalation-dispositions.js +18 -0
- package/dist/queries/escalation-dispositions.js.map +1 -0
- package/dist/queries/escalation-suppression.d.ts +1 -1
- package/dist/queries/escalation-suppression.d.ts.map +1 -1
- package/dist/queries/escalation-suppression.js +1 -1
- package/dist/queries/escalation-suppression.js.map +1 -1
- package/dist/queries/escalations.d.ts +343 -0
- package/dist/queries/escalations.d.ts.map +1 -0
- package/dist/queries/escalations.js +493 -0
- package/dist/queries/escalations.js.map +1 -0
- package/dist/queries/focus-discovery.d.ts +204 -0
- package/dist/queries/focus-discovery.d.ts.map +1 -0
- package/dist/queries/focus-discovery.js +92 -0
- package/dist/queries/focus-discovery.js.map +1 -0
- package/dist/queries/index.d.ts +4 -2
- package/dist/queries/index.d.ts.map +1 -1
- package/dist/queries/index.js +4 -2
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/issues.d.ts +8 -436
- package/dist/queries/issues.d.ts.map +1 -1
- package/dist/queries/issues.js +7 -615
- package/dist/queries/issues.js.map +1 -1
- package/dist/resolvers/agent-escalations.d.ts +20 -0
- package/dist/resolvers/agent-escalations.d.ts.map +1 -1
- package/dist/resolvers/agent-escalations.js +40 -10
- package/dist/resolvers/agent-escalations.js.map +1 -1
- package/dist/resolvers/index.d.ts +2 -2
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +1 -1
- package/dist/resolvers/index.js.map +1 -1
- package/dist/resolvers/shared/git-diff.d.ts +99 -18
- package/dist/resolvers/shared/git-diff.d.ts.map +1 -1
- package/dist/resolvers/shared/git-diff.js +98 -27
- package/dist/resolvers/shared/git-diff.js.map +1 -1
- package/dist/shell/control-state.d.ts +1 -1
- package/dist/shell/control-state.d.ts.map +1 -1
- package/dist/shell/control-state.js +1 -1
- package/dist/shell/control-state.js.map +1 -1
- package/dist/shell/crash-recovery.d.ts +1 -1
- package/dist/shell/crash-recovery.d.ts.map +1 -1
- package/dist/shell/crash-recovery.js +2 -2
- package/dist/shell/crash-recovery.js.map +1 -1
- package/dist/shell/install-probe-tick.d.ts +1 -1
- package/dist/shell/install-probe-tick.d.ts.map +1 -1
- package/dist/shell/install-probe-tick.js +1 -1
- package/dist/shell/install-probe-tick.js.map +1 -1
- package/dist/shell/unified-shell.js +1 -1
- package/dist/shell/unified-shell.js.map +1 -1
- package/dist/spawn/model-routing.d.ts +1 -1
- package/dist/spawn/model-routing.d.ts.map +1 -1
- package/dist/spawn/model-routing.js +1 -1
- package/dist/spawn/model-routing.js.map +1 -1
- package/dist/spawn/prompt-assembly.d.ts +1 -1
- package/dist/spawn/prompt-assembly.d.ts.map +1 -1
- package/dist/spawn/prompt-assembly.js +1 -1
- package/dist/spawn/prompt-assembly.js.map +1 -1
- package/dist/spawn/spawn-decision.js +1 -1
- package/dist/spawn/spawn-decision.js.map +1 -1
- package/dist/spawn/worktree-session.d.ts +1 -1
- package/dist/spawn/worktree-session.d.ts.map +1 -1
- package/dist/spawn/worktree-session.js +1 -1
- package/dist/spawn/worktree-session.js.map +1 -1
- package/dist/templates/claude-md.d.ts +1 -1
- package/dist/templates/claude-md.d.ts.map +1 -1
- package/dist/templates/claude-md.js +12 -0
- package/dist/templates/claude-md.js.map +1 -1
- package/dist/verify/verification-default-on.d.ts +1 -1
- package/dist/verify/verification-default-on.d.ts.map +1 -1
- package/dist/verify/verification-deps.d.ts +1 -1
- package/dist/verify/verification-deps.d.ts.map +1 -1
- package/dist/verify/verification-engine.d.ts.map +1 -1
- package/dist/verify/verification-engine.js +20 -12
- package/dist/verify/verification-engine.js.map +1 -1
- package/dist/worktree/provision.js +1 -1
- package/dist/worktree/provision.js.map +1 -1
- package/dist/worktree/scratch-guard.d.ts.map +1 -1
- package/dist/worktree/scratch-guard.js +23 -2
- package/dist/worktree/scratch-guard.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared PRD-controller types + pure helpers.
|
|
3
|
+
*
|
|
4
|
+
* The PrdControllerDeps injection interface, the tick result shapes, the pure
|
|
5
|
+
* completion/arm-role helpers, and the done-sweep constants. Split out of
|
|
6
|
+
* prd/controller.ts (file-size limit) as the LEAF of the controller family so
|
|
7
|
+
* prd/done-sweep.ts and prd/controller.ts can both depend on these without a
|
|
8
|
+
* cycle (this module imports neither).
|
|
9
|
+
*/
|
|
10
|
+
import type { Prd, PrtNode, PrtEdge, Pathway } from '../queries/prd.js';
|
|
11
|
+
import type { FileEscalationInput } from '../completion/escalations.js';
|
|
12
|
+
import type { StewardJudgmentInput, StewardDecision } from './steward.js';
|
|
13
|
+
/**
|
|
14
|
+
* Steward cadence: the minimum interval between proactive steward monitoring
|
|
15
|
+
* runs for a Played PRD -- the "runs on a cadence" path of the AC. 15 minutes
|
|
16
|
+
* is substantially less frequent than the 60s controller tick (satisfies "not
|
|
17
|
+
* every tick") without making the cortex unresponsive to gradual drift.
|
|
18
|
+
* Exported so tests can inject a zero-ms cadence to force an immediate run.
|
|
19
|
+
*/
|
|
20
|
+
export declare const STEWARD_CADENCE_MS: number;
|
|
21
|
+
/**
|
|
22
|
+
* Stable machine reason for the "done-PRD completion-limbo sweep keeps failing"
|
|
23
|
+
* signal: the per-product one-shot sweep hit DONE_SWEEP_MAX_ATTEMPTS consecutive
|
|
24
|
+
* incomplete passes and was abandoned (product marked swept) so a persistently
|
|
25
|
+
* failing done PRD does not pin the product to a per-tick loadDonePrds re-list.
|
|
26
|
+
*/
|
|
27
|
+
export declare const PRD_DONE_SWEEP_ABANDONED = "prd_done_sweep_abandoned";
|
|
28
|
+
/**
|
|
29
|
+
* Consecutive incomplete done-sweep passes tolerated for a product before the
|
|
30
|
+
* sweep is abandoned and escalated. A merely-non-completable focus is skipped
|
|
31
|
+
* (not a failure), so this trips only on a genuine persistent error (unreadable
|
|
32
|
+
* PRT graph, finalize that keeps rejecting) -- bounding the retry instead of
|
|
33
|
+
* re-listing the growing done set every tick forever.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DONE_SWEEP_MAX_ATTEMPTS = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the arm role for a PRD from the PRD ROW -- the per-entity "Play"
|
|
38
|
+
* signal (prds.assigned_agent_role_id), or null if the PRD is paused.
|
|
39
|
+
*
|
|
40
|
+
* This is the ONLY source: the global TELORA_PRD_ARM_ROLE_ID env var has been
|
|
41
|
+
* removed outright (it was the out-of-band toggle behind the One Screen RTS
|
|
42
|
+
* silent stall). Play/pause is data on the PRD row, set via telora_prd update.
|
|
43
|
+
* Pure + exported so the row-reads-not-env contract is unit-testable.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveArmRoleIdFromPrd(prd: Prd): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Compute the set of focus ids whose delivery work is COMPLETE -- at least one
|
|
48
|
+
* delivery exists AND every delivery is in execution_status 'done'. PURE.
|
|
49
|
+
*
|
|
50
|
+
* This is the completion bridge's signal: a focus is "done" when all its
|
|
51
|
+
* deliveries have passed the verify gate (each against its own worktree). The
|
|
52
|
+
* controller uses it to clear the obstacle an overcome remedies, advancing the
|
|
53
|
+
* frontier without shelling out to build/test a shared checkout. A focus with
|
|
54
|
+
* zero deliveries (freshly materialized, never run) is NOT complete.
|
|
55
|
+
*/
|
|
56
|
+
export declare function computeCompletedFocusIds(deliveries: Array<{
|
|
57
|
+
focusId: string;
|
|
58
|
+
executionStatus: string;
|
|
59
|
+
}>): Set<string>;
|
|
60
|
+
export interface PrdControllerDeps {
|
|
61
|
+
loadPrtGraph: (prdId: string) => Promise<{
|
|
62
|
+
nodes: PrtNode[];
|
|
63
|
+
edges: PrtEdge[];
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Load a single focus's deliveries (focusId + executionStatus), feeding the
|
|
67
|
+
* completion bridge. Called once per overcome focus on the tree. Injected so
|
|
68
|
+
* tests need not hit the API.
|
|
69
|
+
*/
|
|
70
|
+
loadFocusDeliveries: (focusId: string) => Promise<Array<{
|
|
71
|
+
focusId: string;
|
|
72
|
+
executionStatus: string;
|
|
73
|
+
}>>;
|
|
74
|
+
markNodeCleared: (nodeId: string) => Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Finalize a completed frontier focus to status=complete via the sanctioned
|
|
77
|
+
* PRD-path crossing (prd_frontier_focus_finalize). Called by the completion
|
|
78
|
+
* bridge when an overcome's focus has finished all its delivery work, so the
|
|
79
|
+
* focus reaches a terminal state instead of sitting status=active/role=null.
|
|
80
|
+
* Optional so existing callers/tests that do not exercise the completion
|
|
81
|
+
* bridge need not supply it; defaulted in `defaultDeps`.
|
|
82
|
+
*/
|
|
83
|
+
finalizeFrontierFocus?: (focusId: string) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Drop the in-memory pending-spawn directive for a finalized focus, ending the
|
|
86
|
+
* listener's "no assigned_agent_role_id; skipping spawn" loop. Returns whether
|
|
87
|
+
* a directive was present. Optional (mirrors finalizeFrontierFocus);
|
|
88
|
+
* defaulted in `defaultDeps`.
|
|
89
|
+
*/
|
|
90
|
+
clearPendingSpawnDirective?: (focusId: string) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Process-lifetime set of focus ids the completion-limbo self-heal has already
|
|
93
|
+
* finalized, so an already-cleared overcome whose focus is complete-by-
|
|
94
|
+
* deliveries is converged exactly ONCE rather than re-finalized every tick.
|
|
95
|
+
* Optional: when absent the self-heal branch is disabled and the controller
|
|
96
|
+
* keeps its prior finalize-only-on-fresh-clear behavior (back-compat for
|
|
97
|
+
* callers/tests that do not exercise limbo recovery). Defaulted in defaultDeps.
|
|
98
|
+
*/
|
|
99
|
+
selfHealedFocusIds?: Set<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Process-lifetime set of product ids whose one-shot done-PRD limbo sweep has
|
|
102
|
+
* completed, so loadDonePrds runs at most once per product per process.
|
|
103
|
+
* Optional: when absent the done-PRD sweep in runPrdControllerTickAll is
|
|
104
|
+
* skipped entirely (back-compat). Defaulted in defaultDeps.
|
|
105
|
+
*/
|
|
106
|
+
doneSweepDoneProducts?: Set<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Per-product consecutive-incomplete-pass counter for the done-PRD sweep, so a
|
|
109
|
+
* persistent failure is abandoned + escalated after DONE_SWEEP_MAX_ATTEMPTS
|
|
110
|
+
* instead of re-listing every tick. Optional: when absent the sweep retries an
|
|
111
|
+
* incomplete pass indefinitely (prior behavior). Defaulted in defaultDeps.
|
|
112
|
+
*/
|
|
113
|
+
doneSweepAttempts?: Map<string, number>;
|
|
114
|
+
/**
|
|
115
|
+
* List a product's active PRDs (the controller's per-tick working set).
|
|
116
|
+
* Injected so runPrdControllerTickAll is testable without the API; defaults to
|
|
117
|
+
* the live loadActivePrds query in defaultDeps.
|
|
118
|
+
*/
|
|
119
|
+
loadActivePrds?: (productId: string) => Promise<Prd[]>;
|
|
120
|
+
/**
|
|
121
|
+
* List a product's done PRDs (feeds the one-shot done-PRD limbo sweep).
|
|
122
|
+
* Injected so the sweep is testable without the API; defaults to the live
|
|
123
|
+
* loadDonePrds query in defaultDeps.
|
|
124
|
+
*/
|
|
125
|
+
loadDonePrds?: (productId: string) => Promise<Prd[]>;
|
|
126
|
+
materializeOvercome: (nodeId: string) => Promise<{
|
|
127
|
+
focusId: string;
|
|
128
|
+
}>;
|
|
129
|
+
armFocus: (focusId: string, agentRoleId: string) => Promise<void>;
|
|
130
|
+
markPrdDone: (prdId: string) => Promise<void>;
|
|
131
|
+
resolveArmRoleId: (prd: Prd) => Promise<string | null>;
|
|
132
|
+
loadPathways: (prdId: string) => Promise<Pathway[]>;
|
|
133
|
+
commitPathway: (prdId: string, pathwayId: string) => Promise<void>;
|
|
134
|
+
fileEscalation: (input: FileEscalationInput) => Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* DB-backed dedup check: is there already an OPEN (pending/in_review) PRD
|
|
137
|
+
* machine escalation of the given `kind` (machine_discriminator) for this PRD?
|
|
138
|
+
* When it returns true, the cadence-reachable escalation paths skip filing a
|
|
139
|
+
* duplicate so even a genuinely warranted, persistent condition yields exactly
|
|
140
|
+
* ONE open row per (PRD, kind) instead of a per-cadence-tick flood. Keyed by
|
|
141
|
+
* kind so BOTH the steward divergence path
|
|
142
|
+
* ('prd_divergence_steward_escalation') and the reflex no-surviving-path
|
|
143
|
+
* fallback ('prd_divergence_no_surviving_path') share the guard -- the latter
|
|
144
|
+
* has the identical un-deduped storm structure. DB-backed so the dedup survives
|
|
145
|
+
* a daemon restart (unlike the process-lifetime no-role Set). Optional so
|
|
146
|
+
* existing callers/tests need not supply it; defaulted in defaultDeps. When
|
|
147
|
+
* absent, no dedup is applied (prior behavior preserved for callers that opt
|
|
148
|
+
* out).
|
|
149
|
+
*/
|
|
150
|
+
hasOpenPrdEscalation?: (prdId: string, kind: string) => Promise<boolean>;
|
|
151
|
+
/**
|
|
152
|
+
* The CORTEX: on divergence of a Played PRD, the steward decides re-capture
|
|
153
|
+
* vs escalate (overriding the deterministic selectSurvivingPath). Returns null
|
|
154
|
+
* to fall back to the deterministic reflex. Optional so existing callers/tests
|
|
155
|
+
* without a steward keep the deterministic behavior; defaulted in defaultDeps.
|
|
156
|
+
*/
|
|
157
|
+
runStewardJudgment?: (input: StewardJudgmentInput) => Promise<StewardDecision | null>;
|
|
158
|
+
/** Org scope used when filing a no-surviving-path escalation. */
|
|
159
|
+
organizationId: string;
|
|
160
|
+
worktreeDir: string;
|
|
161
|
+
/**
|
|
162
|
+
* Per-PRD last-steward-run map for cadence tracking. Defaults to the module
|
|
163
|
+
* singleton. Tests inject a fresh Map to assert cadence behavior without
|
|
164
|
+
* depending on real elapsed time.
|
|
165
|
+
*/
|
|
166
|
+
stewardLastRun?: Map<string, number>;
|
|
167
|
+
/**
|
|
168
|
+
* Cadence period in ms. Defaults to STEWARD_CADENCE_MS. Tests inject 0 to
|
|
169
|
+
* force an immediate cadence run, or a large value to suppress it.
|
|
170
|
+
*/
|
|
171
|
+
stewardCadenceMs?: number;
|
|
172
|
+
}
|
|
173
|
+
export interface PrdControllerTickResult {
|
|
174
|
+
obstaclesEvaluated: number;
|
|
175
|
+
obstaclesCleared: number;
|
|
176
|
+
materialized: number;
|
|
177
|
+
armed: number;
|
|
178
|
+
skippedNoRole: number;
|
|
179
|
+
/**
|
|
180
|
+
* Completed frontier foci finalized to status=complete this tick (with their
|
|
181
|
+
* pending spawn directive cleared). The autonomous-completion counterpart to
|
|
182
|
+
* `materialized` -- frontier foci that reached a terminal state.
|
|
183
|
+
*/
|
|
184
|
+
focusesFinalized: number;
|
|
185
|
+
prdDone: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* True when this tick computed a live frontier for an active PRD that could
|
|
188
|
+
* NOT be armed because prds.assigned_agent_role_id is null (PRD authored but
|
|
189
|
+
* not yet Played). A VALID WAITING STATE -- not an error: the controller skips
|
|
190
|
+
* arming silently and the daemon log warns; no escalation is filed. Mirrors
|
|
191
|
+
* `skippedNoRole > 0` so the `prdsBlockedNoRole` aggregate stays meaningful.
|
|
192
|
+
*/
|
|
193
|
+
frontierBlockedNoRole: boolean;
|
|
194
|
+
/** True when this tick detected one or more divergence signals. */
|
|
195
|
+
diverged: boolean;
|
|
196
|
+
/** True when realign re-pointed the committed pathway (re-capture). */
|
|
197
|
+
pathSwitched: boolean;
|
|
198
|
+
/** True when divergence had no surviving path and a human was escalated. */
|
|
199
|
+
escalated: boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface PrdControllerTickAllResult {
|
|
202
|
+
obstaclesEvaluated: number;
|
|
203
|
+
obstaclesCleared: number;
|
|
204
|
+
materialized: number;
|
|
205
|
+
armed: number;
|
|
206
|
+
skippedNoRole: number;
|
|
207
|
+
/** Completed frontier foci finalized to status=complete this pass. */
|
|
208
|
+
focusesFinalized: number;
|
|
209
|
+
prdsDone: number;
|
|
210
|
+
/**
|
|
211
|
+
* PRDs in the authored-but-unplayed waiting state this pass: an active
|
|
212
|
+
* frontier with no arm role (assigned_agent_role_id null). Surfaced via the
|
|
213
|
+
* daemon log, never an escalation.
|
|
214
|
+
*/
|
|
215
|
+
prdsBlockedNoRole: number;
|
|
216
|
+
/** PRDs that detected divergence this pass. */
|
|
217
|
+
prdsDiverged: number;
|
|
218
|
+
/** PRDs whose committed pathway was re-pointed (re-capture). */
|
|
219
|
+
prdsPathSwitched: number;
|
|
220
|
+
/** PRDs escalated to a human for lack of a surviving path. */
|
|
221
|
+
prdsEscalated: number;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=controller-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-shared.d.ts","sourceRoot":"","sources":["../../src/prd/controller-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,GAAG,CAAC,MAAM,CAAC,CAoBb;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAAC,KAAK,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;IACjF;;;;OAIG;IACH,mBAAmB,EAAE,CACnB,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAClE,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,0BAA0B,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1D;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACrD,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACpD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzE;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IACtF,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,YAAY,EAAE,OAAO,CAAC;IACtB,4EAA4E;IAC5E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared PRD-controller types + pure helpers.
|
|
3
|
+
*
|
|
4
|
+
* The PrdControllerDeps injection interface, the tick result shapes, the pure
|
|
5
|
+
* completion/arm-role helpers, and the done-sweep constants. Split out of
|
|
6
|
+
* prd/controller.ts (file-size limit) as the LEAF of the controller family so
|
|
7
|
+
* prd/done-sweep.ts and prd/controller.ts can both depend on these without a
|
|
8
|
+
* cycle (this module imports neither).
|
|
9
|
+
*/
|
|
10
|
+
import { DELIVERY_STATUS } from '@telora/daemon-core';
|
|
11
|
+
/**
|
|
12
|
+
* Steward cadence: the minimum interval between proactive steward monitoring
|
|
13
|
+
* runs for a Played PRD -- the "runs on a cadence" path of the AC. 15 minutes
|
|
14
|
+
* is substantially less frequent than the 60s controller tick (satisfies "not
|
|
15
|
+
* every tick") without making the cortex unresponsive to gradual drift.
|
|
16
|
+
* Exported so tests can inject a zero-ms cadence to force an immediate run.
|
|
17
|
+
*/
|
|
18
|
+
export const STEWARD_CADENCE_MS = 15 * 60 * 1000;
|
|
19
|
+
/**
|
|
20
|
+
* Stable machine reason for the "done-PRD completion-limbo sweep keeps failing"
|
|
21
|
+
* signal: the per-product one-shot sweep hit DONE_SWEEP_MAX_ATTEMPTS consecutive
|
|
22
|
+
* incomplete passes and was abandoned (product marked swept) so a persistently
|
|
23
|
+
* failing done PRD does not pin the product to a per-tick loadDonePrds re-list.
|
|
24
|
+
*/
|
|
25
|
+
export const PRD_DONE_SWEEP_ABANDONED = 'prd_done_sweep_abandoned';
|
|
26
|
+
/**
|
|
27
|
+
* Consecutive incomplete done-sweep passes tolerated for a product before the
|
|
28
|
+
* sweep is abandoned and escalated. A merely-non-completable focus is skipped
|
|
29
|
+
* (not a failure), so this trips only on a genuine persistent error (unreadable
|
|
30
|
+
* PRT graph, finalize that keeps rejecting) -- bounding the retry instead of
|
|
31
|
+
* re-listing the growing done set every tick forever.
|
|
32
|
+
*/
|
|
33
|
+
export const DONE_SWEEP_MAX_ATTEMPTS = 3;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the arm role for a PRD from the PRD ROW -- the per-entity "Play"
|
|
36
|
+
* signal (prds.assigned_agent_role_id), or null if the PRD is paused.
|
|
37
|
+
*
|
|
38
|
+
* This is the ONLY source: the global TELORA_PRD_ARM_ROLE_ID env var has been
|
|
39
|
+
* removed outright (it was the out-of-band toggle behind the One Screen RTS
|
|
40
|
+
* silent stall). Play/pause is data on the PRD row, set via telora_prd update.
|
|
41
|
+
* Pure + exported so the row-reads-not-env contract is unit-testable.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveArmRoleIdFromPrd(prd) {
|
|
44
|
+
return prd.assignedAgentRoleId ?? null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compute the set of focus ids whose delivery work is COMPLETE -- at least one
|
|
48
|
+
* delivery exists AND every delivery is in execution_status 'done'. PURE.
|
|
49
|
+
*
|
|
50
|
+
* This is the completion bridge's signal: a focus is "done" when all its
|
|
51
|
+
* deliveries have passed the verify gate (each against its own worktree). The
|
|
52
|
+
* controller uses it to clear the obstacle an overcome remedies, advancing the
|
|
53
|
+
* frontier without shelling out to build/test a shared checkout. A focus with
|
|
54
|
+
* zero deliveries (freshly materialized, never run) is NOT complete.
|
|
55
|
+
*/
|
|
56
|
+
export function computeCompletedFocusIds(deliveries) {
|
|
57
|
+
const byFocus = new Map();
|
|
58
|
+
for (const d of deliveries) {
|
|
59
|
+
if (!d.focusId) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const acc = byFocus.get(d.focusId) ?? { total: 0, done: 0 };
|
|
63
|
+
acc.total += 1;
|
|
64
|
+
if (d.executionStatus === DELIVERY_STATUS.DONE) {
|
|
65
|
+
acc.done += 1;
|
|
66
|
+
}
|
|
67
|
+
byFocus.set(d.focusId, acc);
|
|
68
|
+
}
|
|
69
|
+
const complete = new Set();
|
|
70
|
+
for (const [focusId, { total, done }] of byFocus) {
|
|
71
|
+
if (total > 0 && done === total) {
|
|
72
|
+
complete.add(focusId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return complete;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=controller-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-shared.js","sourceRoot":"","sources":["../../src/prd/controller-shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC9C,OAAO,GAAG,CAAC,mBAAmB,IAAI,IAAI,CAAC;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAA+D;IAE/D,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2C,CAAC;IACnE,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QACD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC;QACf,IAAI,CAAC,CAAC,eAAe,KAAK,eAAe,CAAC,IAAI,EAAE,CAAC;YAC/C,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;QACjD,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YAChC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/prd/controller.d.ts
CHANGED
|
@@ -15,266 +15,15 @@
|
|
|
15
15
|
* Foci -> Delivery -> Issue executor.
|
|
16
16
|
*/
|
|
17
17
|
import type { DaemonConfig } from '../types/index.js';
|
|
18
|
-
import { type Prd
|
|
18
|
+
import { type Prd } from '../queries/prd.js';
|
|
19
19
|
import { computePrtFrontier } from './frontier.js';
|
|
20
20
|
import { isPathwayViable } from './viability.js';
|
|
21
|
-
import { type
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* runs for a Played PRD -- the "runs on a cadence" path of the AC. 15 minutes
|
|
26
|
-
* is substantially less frequent than the 60s controller tick (satisfies "not
|
|
27
|
-
* every tick") without making the cortex unresponsive to gradual drift.
|
|
28
|
-
* Exported so tests can inject a zero-ms cadence to force an immediate run.
|
|
29
|
-
*/
|
|
30
|
-
export declare const STEWARD_CADENCE_MS: number;
|
|
31
|
-
/**
|
|
32
|
-
* Stable machine reason for the "done-PRD completion-limbo sweep keeps failing"
|
|
33
|
-
* signal: the per-product one-shot sweep hit DONE_SWEEP_MAX_ATTEMPTS consecutive
|
|
34
|
-
* incomplete passes and was abandoned (product marked swept) so a persistently
|
|
35
|
-
* failing done PRD does not pin the product to a per-tick loadDonePrds re-list.
|
|
36
|
-
*/
|
|
37
|
-
export declare const PRD_DONE_SWEEP_ABANDONED = "prd_done_sweep_abandoned";
|
|
38
|
-
/**
|
|
39
|
-
* Consecutive incomplete done-sweep passes tolerated for a product before the
|
|
40
|
-
* sweep is abandoned and escalated. A merely-non-completable focus is skipped
|
|
41
|
-
* (not a failure), so this trips only on a genuine persistent error (unreadable
|
|
42
|
-
* PRT graph, finalize that keeps rejecting) -- bounding the retry instead of
|
|
43
|
-
* re-listing the growing done set every tick forever.
|
|
44
|
-
*/
|
|
45
|
-
export declare const DONE_SWEEP_MAX_ATTEMPTS = 3;
|
|
46
|
-
/**
|
|
47
|
-
* Resolve the arm role for a PRD from the PRD ROW -- the per-entity "Play"
|
|
48
|
-
* signal (prds.assigned_agent_role_id), or null if the PRD is paused.
|
|
49
|
-
*
|
|
50
|
-
* This is the ONLY source: the global TELORA_PRD_ARM_ROLE_ID env var has been
|
|
51
|
-
* removed outright (it was the out-of-band toggle behind the One Screen RTS
|
|
52
|
-
* silent stall). Play/pause is data on the PRD row, set via telora_prd update.
|
|
53
|
-
* Pure + exported so the row-reads-not-env contract is unit-testable.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveArmRoleIdFromPrd(prd: Prd): string | null;
|
|
21
|
+
import { type PrdControllerDeps, type PrdControllerTickResult, type PrdControllerTickAllResult } from './controller-shared.js';
|
|
22
|
+
export { STEWARD_CADENCE_MS, PRD_DONE_SWEEP_ABANDONED, DONE_SWEEP_MAX_ATTEMPTS, resolveArmRoleIdFromPrd, computeCompletedFocusIds, } from './controller-shared.js';
|
|
23
|
+
export type { PrdControllerDeps, PrdControllerTickResult, PrdControllerTickAllResult, } from './controller-shared.js';
|
|
24
|
+
export { selfHealDonePrdFoci, runDonePrdSweepForProduct } from './done-sweep.js';
|
|
56
25
|
export { computePrtFrontier };
|
|
57
26
|
export { isPathwayViable };
|
|
58
|
-
/**
|
|
59
|
-
* Compute the set of focus ids whose delivery work is COMPLETE -- at least one
|
|
60
|
-
* delivery exists AND every delivery is in execution_status 'done'. PURE.
|
|
61
|
-
*
|
|
62
|
-
* This is the completion bridge's signal: a focus is "done" when all its
|
|
63
|
-
* deliveries have passed the verify gate (each against its own worktree). The
|
|
64
|
-
* controller uses it to clear the obstacle an overcome remedies, advancing the
|
|
65
|
-
* frontier without shelling out to build/test a shared checkout. A focus with
|
|
66
|
-
* zero deliveries (freshly materialized, never run) is NOT complete.
|
|
67
|
-
*/
|
|
68
|
-
export declare function computeCompletedFocusIds(deliveries: Array<{
|
|
69
|
-
focusId: string;
|
|
70
|
-
executionStatus: string;
|
|
71
|
-
}>): Set<string>;
|
|
72
|
-
export interface PrdControllerDeps {
|
|
73
|
-
loadPrtGraph: (prdId: string) => Promise<{
|
|
74
|
-
nodes: PrtNode[];
|
|
75
|
-
edges: PrtEdge[];
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Load a single focus's deliveries (focusId + executionStatus), feeding the
|
|
79
|
-
* completion bridge. Called once per overcome focus on the tree. Injected so
|
|
80
|
-
* tests need not hit the API.
|
|
81
|
-
*/
|
|
82
|
-
loadFocusDeliveries: (focusId: string) => Promise<Array<{
|
|
83
|
-
focusId: string;
|
|
84
|
-
executionStatus: string;
|
|
85
|
-
}>>;
|
|
86
|
-
markNodeCleared: (nodeId: string) => Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Finalize a completed frontier focus to status=complete via the sanctioned
|
|
89
|
-
* PRD-path crossing (prd_frontier_focus_finalize). Called by the completion
|
|
90
|
-
* bridge when an overcome's focus has finished all its delivery work, so the
|
|
91
|
-
* focus reaches a terminal state instead of sitting status=active/role=null.
|
|
92
|
-
* Optional so existing callers/tests that do not exercise the completion
|
|
93
|
-
* bridge need not supply it; defaulted in `defaultDeps`.
|
|
94
|
-
*/
|
|
95
|
-
finalizeFrontierFocus?: (focusId: string) => Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* Drop the in-memory pending-spawn directive for a finalized focus, ending the
|
|
98
|
-
* listener's "no assigned_agent_role_id; skipping spawn" loop. Returns whether
|
|
99
|
-
* a directive was present. Optional (mirrors finalizeFrontierFocus);
|
|
100
|
-
* defaulted in `defaultDeps`.
|
|
101
|
-
*/
|
|
102
|
-
clearPendingSpawnDirective?: (focusId: string) => boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Process-lifetime set of focus ids the completion-limbo self-heal has already
|
|
105
|
-
* finalized, so an already-cleared overcome whose focus is complete-by-
|
|
106
|
-
* deliveries is converged exactly ONCE rather than re-finalized every tick.
|
|
107
|
-
* Optional: when absent the self-heal branch is disabled and the controller
|
|
108
|
-
* keeps its prior finalize-only-on-fresh-clear behavior (back-compat for
|
|
109
|
-
* callers/tests that do not exercise limbo recovery). Defaulted in defaultDeps.
|
|
110
|
-
*/
|
|
111
|
-
selfHealedFocusIds?: Set<string>;
|
|
112
|
-
/**
|
|
113
|
-
* Process-lifetime set of product ids whose one-shot done-PRD limbo sweep has
|
|
114
|
-
* completed, so loadDonePrds runs at most once per product per process.
|
|
115
|
-
* Optional: when absent the done-PRD sweep in runPrdControllerTickAll is
|
|
116
|
-
* skipped entirely (back-compat). Defaulted in defaultDeps.
|
|
117
|
-
*/
|
|
118
|
-
doneSweepDoneProducts?: Set<string>;
|
|
119
|
-
/**
|
|
120
|
-
* Per-product consecutive-incomplete-pass counter for the done-PRD sweep, so a
|
|
121
|
-
* persistent failure is abandoned + escalated after DONE_SWEEP_MAX_ATTEMPTS
|
|
122
|
-
* instead of re-listing every tick. Optional: when absent the sweep retries an
|
|
123
|
-
* incomplete pass indefinitely (prior behavior). Defaulted in defaultDeps.
|
|
124
|
-
*/
|
|
125
|
-
doneSweepAttempts?: Map<string, number>;
|
|
126
|
-
/**
|
|
127
|
-
* List a product's active PRDs (the controller's per-tick working set).
|
|
128
|
-
* Injected so runPrdControllerTickAll is testable without the API; defaults to
|
|
129
|
-
* the live loadActivePrds query in defaultDeps.
|
|
130
|
-
*/
|
|
131
|
-
loadActivePrds?: (productId: string) => Promise<Prd[]>;
|
|
132
|
-
/**
|
|
133
|
-
* List a product's done PRDs (feeds the one-shot done-PRD limbo sweep).
|
|
134
|
-
* Injected so the sweep is testable without the API; defaults to the live
|
|
135
|
-
* loadDonePrds query in defaultDeps.
|
|
136
|
-
*/
|
|
137
|
-
loadDonePrds?: (productId: string) => Promise<Prd[]>;
|
|
138
|
-
materializeOvercome: (nodeId: string) => Promise<{
|
|
139
|
-
focusId: string;
|
|
140
|
-
}>;
|
|
141
|
-
armFocus: (focusId: string, agentRoleId: string) => Promise<void>;
|
|
142
|
-
markPrdDone: (prdId: string) => Promise<void>;
|
|
143
|
-
resolveArmRoleId: (prd: Prd) => Promise<string | null>;
|
|
144
|
-
loadPathways: (prdId: string) => Promise<Pathway[]>;
|
|
145
|
-
commitPathway: (prdId: string, pathwayId: string) => Promise<void>;
|
|
146
|
-
fileEscalation: (input: FileEscalationInput) => Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* DB-backed dedup check: is there already an OPEN (pending/in_review) PRD
|
|
149
|
-
* machine escalation of the given `kind` (machine_discriminator) for this PRD?
|
|
150
|
-
* When it returns true, the cadence-reachable escalation paths skip filing a
|
|
151
|
-
* duplicate so even a genuinely warranted, persistent condition yields exactly
|
|
152
|
-
* ONE open row per (PRD, kind) instead of a per-cadence-tick flood. Keyed by
|
|
153
|
-
* kind so BOTH the steward divergence path
|
|
154
|
-
* ('prd_divergence_steward_escalation') and the reflex no-surviving-path
|
|
155
|
-
* fallback ('prd_divergence_no_surviving_path') share the guard -- the latter
|
|
156
|
-
* has the identical un-deduped storm structure. DB-backed so the dedup survives
|
|
157
|
-
* a daemon restart (unlike the process-lifetime no-role Set). Optional so
|
|
158
|
-
* existing callers/tests need not supply it; defaulted in defaultDeps. When
|
|
159
|
-
* absent, no dedup is applied (prior behavior preserved for callers that opt
|
|
160
|
-
* out).
|
|
161
|
-
*/
|
|
162
|
-
hasOpenPrdEscalation?: (prdId: string, kind: string) => Promise<boolean>;
|
|
163
|
-
/**
|
|
164
|
-
* The CORTEX: on divergence of a Played PRD, the steward decides re-capture
|
|
165
|
-
* vs escalate (overriding the deterministic selectSurvivingPath). Returns null
|
|
166
|
-
* to fall back to the deterministic reflex. Optional so existing callers/tests
|
|
167
|
-
* without a steward keep the deterministic behavior; defaulted in defaultDeps.
|
|
168
|
-
*/
|
|
169
|
-
runStewardJudgment?: (input: StewardJudgmentInput) => Promise<StewardDecision | null>;
|
|
170
|
-
/** Org scope used when filing a no-surviving-path escalation. */
|
|
171
|
-
organizationId: string;
|
|
172
|
-
worktreeDir: string;
|
|
173
|
-
/**
|
|
174
|
-
* Per-PRD last-steward-run map for cadence tracking. Defaults to the module
|
|
175
|
-
* singleton. Tests inject a fresh Map to assert cadence behavior without
|
|
176
|
-
* depending on real elapsed time.
|
|
177
|
-
*/
|
|
178
|
-
stewardLastRun?: Map<string, number>;
|
|
179
|
-
/**
|
|
180
|
-
* Cadence period in ms. Defaults to STEWARD_CADENCE_MS. Tests inject 0 to
|
|
181
|
-
* force an immediate cadence run, or a large value to suppress it.
|
|
182
|
-
*/
|
|
183
|
-
stewardCadenceMs?: number;
|
|
184
|
-
}
|
|
185
|
-
export interface PrdControllerTickResult {
|
|
186
|
-
obstaclesEvaluated: number;
|
|
187
|
-
obstaclesCleared: number;
|
|
188
|
-
materialized: number;
|
|
189
|
-
armed: number;
|
|
190
|
-
skippedNoRole: number;
|
|
191
|
-
/**
|
|
192
|
-
* Completed frontier foci finalized to status=complete this tick (with their
|
|
193
|
-
* pending spawn directive cleared). The autonomous-completion counterpart to
|
|
194
|
-
* `materialized` -- frontier foci that reached a terminal state.
|
|
195
|
-
*/
|
|
196
|
-
focusesFinalized: number;
|
|
197
|
-
prdDone: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* True when this tick computed a live frontier for an active PRD that could
|
|
200
|
-
* NOT be armed because prds.assigned_agent_role_id is null (PRD authored but
|
|
201
|
-
* not yet Played). A VALID WAITING STATE -- not an error: the controller skips
|
|
202
|
-
* arming silently and the daemon log warns; no escalation is filed. Mirrors
|
|
203
|
-
* `skippedNoRole > 0` so the `prdsBlockedNoRole` aggregate stays meaningful.
|
|
204
|
-
*/
|
|
205
|
-
frontierBlockedNoRole: boolean;
|
|
206
|
-
/** True when this tick detected one or more divergence signals. */
|
|
207
|
-
diverged: boolean;
|
|
208
|
-
/** True when realign re-pointed the committed pathway (re-capture). */
|
|
209
|
-
pathSwitched: boolean;
|
|
210
|
-
/** True when divergence had no surviving path and a human was escalated. */
|
|
211
|
-
escalated: boolean;
|
|
212
|
-
}
|
|
213
27
|
export declare function runPrdControllerTick(prd: Prd, deps: PrdControllerDeps): Promise<PrdControllerTickResult>;
|
|
214
|
-
export interface PrdControllerTickAllResult {
|
|
215
|
-
obstaclesEvaluated: number;
|
|
216
|
-
obstaclesCleared: number;
|
|
217
|
-
materialized: number;
|
|
218
|
-
armed: number;
|
|
219
|
-
skippedNoRole: number;
|
|
220
|
-
/** Completed frontier foci finalized to status=complete this pass. */
|
|
221
|
-
focusesFinalized: number;
|
|
222
|
-
prdsDone: number;
|
|
223
|
-
/**
|
|
224
|
-
* PRDs in the authored-but-unplayed waiting state this pass: an active
|
|
225
|
-
* frontier with no arm role (assigned_agent_role_id null). Surfaced via the
|
|
226
|
-
* daemon log, never an escalation.
|
|
227
|
-
*/
|
|
228
|
-
prdsBlockedNoRole: number;
|
|
229
|
-
/** PRDs that detected divergence this pass. */
|
|
230
|
-
prdsDiverged: number;
|
|
231
|
-
/** PRDs whose committed pathway was re-pointed (re-capture). */
|
|
232
|
-
prdsPathSwitched: number;
|
|
233
|
-
/** PRDs escalated to a human for lack of a surviving path. */
|
|
234
|
-
prdsEscalated: number;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Done-PRD completion-limbo self-heal for a SINGLE done PRD.
|
|
238
|
-
*
|
|
239
|
-
* The per-tick self-heal in runPrdControllerTick only sees a PRD while it is
|
|
240
|
-
* ACTIVE (loadActivePrds filters status='active'), so it converges stranded
|
|
241
|
-
* foci on or before the done-transition. A PRD that ALREADY reached done under
|
|
242
|
-
* an earlier daemon -- before that self-heal existed -- is never re-ticked, so
|
|
243
|
-
* any focus it materialized that is complete-by-deliveries yet still
|
|
244
|
-
* status=active stays stranded forever, needing a one-off operator data fix.
|
|
245
|
-
*
|
|
246
|
-
* This converges those without an operator: finalize ANY materialized
|
|
247
|
-
* (overcome-anchored) focus of the done PRD that is complete-by-deliveries but
|
|
248
|
-
* not yet terminal. Bounded to once per focus per process via selfHealedFocusIds
|
|
249
|
-
* (shared with the active-tick self-heal so the two paths never double-finalize
|
|
250
|
-
* the same focus). A focus that is NOT complete-by-deliveries (zero deliveries,
|
|
251
|
-
* or only non-done terminal deliveries) is simply skipped -- it was never
|
|
252
|
-
* finalizable. finalizeFrontierFocus is idempotent + overcome-anchor-scoped
|
|
253
|
-
* server-side, so the human-owned focus.status invariant stays intact for
|
|
254
|
-
* non-PRD foci. Disabled (no-op) when selfHealedFocusIds is absent, matching the
|
|
255
|
-
* active-tick self-heal's back-compat gate.
|
|
256
|
-
*/
|
|
257
|
-
export declare function selfHealDonePrdFoci(prd: Prd, deps: PrdControllerDeps): Promise<{
|
|
258
|
-
focusesFinalized: number;
|
|
259
|
-
}>;
|
|
260
|
-
/**
|
|
261
|
-
* One-shot done-PRD limbo sweep for a single product: list the product's done
|
|
262
|
-
* PRDs and self-heal each one's stranded complete-by-deliveries foci.
|
|
263
|
-
*
|
|
264
|
-
* Returns `complete=true` only when the list succeeded AND every per-PRD
|
|
265
|
-
* self-heal succeeded, so the caller records the product as swept and never
|
|
266
|
-
* re-lists. A list failure or any per-PRD failure returns `complete=false` so
|
|
267
|
-
* the next tick retries (the selfHealedFocusIds ledger keeps the retry from
|
|
268
|
-
* re-finalizing foci already converged). A focus merely skipped for not being
|
|
269
|
-
* complete-by-deliveries is NOT a failure -- it does not block completion, so a
|
|
270
|
-
* done PRD whose focus can never complete does not pin the product to perpetual
|
|
271
|
-
* re-reads.
|
|
272
|
-
*
|
|
273
|
-
* No-op (complete=true) when the sweep is disabled (no selfHealedFocusIds dep).
|
|
274
|
-
*/
|
|
275
|
-
export declare function runDonePrdSweepForProduct(productId: string, deps: PrdControllerDeps): Promise<{
|
|
276
|
-
focusesFinalized: number;
|
|
277
|
-
complete: boolean;
|
|
278
|
-
}>;
|
|
279
28
|
export declare function runPrdControllerTickAll(config: DaemonConfig, deps?: Partial<PrdControllerDeps>): Promise<PrdControllerTickAllResult>;
|
|
280
29
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/prd/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/prd/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAWL,KAAK,GAAG,EACT,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAcjD,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAsDjF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAM9B,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,uBAAuB,CAAC,CAuWlC;AAuDD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAChC,OAAO,CAAC,0BAA0B,CAAC,CAkIrC"}
|