@telora/daemon 0.22.58 → 0.22.62

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.
Files changed (53) hide show
  1. package/build-info.json +2 -2
  2. package/dist/completion/state-cascade.d.ts.map +1 -1
  3. package/dist/completion/state-cascade.js +29 -4
  4. package/dist/completion/state-cascade.js.map +1 -1
  5. package/dist/directive/directive-executor.d.ts.map +1 -1
  6. package/dist/directive/directive-executor.js +1 -0
  7. package/dist/directive/directive-executor.js.map +1 -1
  8. package/dist/focus/focus-phase.d.ts.map +1 -1
  9. package/dist/focus/focus-phase.js +2 -1
  10. package/dist/focus/focus-phase.js.map +1 -1
  11. package/dist/focus/listener-spawn.d.ts +0 -44
  12. package/dist/focus/listener-spawn.d.ts.map +1 -1
  13. package/dist/focus/listener-spawn.js +61 -146
  14. package/dist/focus/listener-spawn.js.map +1 -1
  15. package/dist/focus-stage-lifecycle/planning-release.d.ts +3 -2
  16. package/dist/focus-stage-lifecycle/planning-release.d.ts.map +1 -1
  17. package/dist/focus-stage-lifecycle/planning-release.js +3 -2
  18. package/dist/focus-stage-lifecycle/planning-release.js.map +1 -1
  19. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts +5 -3
  20. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts.map +1 -1
  21. package/dist/focus-stage-lifecycle/wedge-watchdog.js +8 -5
  22. package/dist/focus-stage-lifecycle/wedge-watchdog.js.map +1 -1
  23. package/dist/queries/escalation-suppression.d.ts.map +1 -1
  24. package/dist/queries/escalation-suppression.js +2 -1
  25. package/dist/queries/escalation-suppression.js.map +1 -1
  26. package/dist/queries/focuses.d.ts +13 -0
  27. package/dist/queries/focuses.d.ts.map +1 -1
  28. package/dist/queries/focuses.js +18 -0
  29. package/dist/queries/focuses.js.map +1 -1
  30. package/dist/shell/control-state.d.ts +6 -5
  31. package/dist/shell/control-state.d.ts.map +1 -1
  32. package/dist/shell/control-state.js +6 -5
  33. package/dist/shell/control-state.js.map +1 -1
  34. package/dist/spawn/null-role-spawn.d.ts +109 -0
  35. package/dist/spawn/null-role-spawn.d.ts.map +1 -0
  36. package/dist/spawn/null-role-spawn.js +94 -0
  37. package/dist/spawn/null-role-spawn.js.map +1 -0
  38. package/dist/testing/fixtures/index.js +1 -1
  39. package/dist/types/session.d.ts.map +1 -1
  40. package/dist/types/session.js +1 -2
  41. package/dist/types/session.js.map +1 -1
  42. package/dist/verify/stall-detectors.d.ts.map +1 -1
  43. package/dist/verify/stall-detectors.js +2 -1
  44. package/dist/verify/stall-detectors.js.map +1 -1
  45. package/dist/verify/unreviewed-settle-detector.d.ts +73 -0
  46. package/dist/verify/unreviewed-settle-detector.d.ts.map +1 -0
  47. package/dist/verify/unreviewed-settle-detector.js +147 -0
  48. package/dist/verify/unreviewed-settle-detector.js.map +1 -0
  49. package/package.json +1 -1
  50. package/dist/spawn/review-role-fallback.d.ts +0 -141
  51. package/dist/spawn/review-role-fallback.d.ts.map +0 -1
  52. package/dist/spawn/review-role-fallback.js +0 -114
  53. package/dist/spawn/review-role-fallback.js.map +0 -1
@@ -1,141 +0,0 @@
1
- /**
2
- * Review-spawn reviewer-role fallback.
3
- *
4
- * When a coding team completes, the auto_terminate_focus_team() Postgres trigger
5
- * nulls product_focuses.assigned_agent_role_id -- correct team-lifecycle
6
- * shutdown (the Play/queue toggle cleared). But a review is a SECOND team that
7
- * must spawn AFTER that completion, and the pending review directive it left
8
- * behind still needs a role to spawn under. With assigned_agent_role_id null,
9
- * the listener's pending-spawn path used to skip the queued review directive
10
- * every poll, and the directive-executor suppressed re-firing (an equivalent
11
- * directive is "already queued") -- a review that can never spawn, spin-logging
12
- * until review_window_stalled escalates to a human at ~6h.
13
- *
14
- * This module holds the prevent-at-source decision: for a REVIEW directive with
15
- * a null role, resolve a layered reviewer-role fallback (the org's seeded
16
- * Developer role) and spawn. It mirrors nexus intake's resolveIntakeRoleLayered
17
- * (the org's seeded 'Developer' role is the zero-config fallback). The fallback
18
- * is scoped STRICTLY to review spawns: a null role on a CODING spawn is the
19
- * intended off-state and must NOT auto-spawn. Defense-in-depth: if even the
20
- * fallback resolves nothing, the caller clears the pending directive so it stops
21
- * spin-logging and lets the stall detector escalate promptly.
22
- */
23
- import type { AgentRole } from '../types/session.js';
24
- /**
25
- * Name of the org's auto-seeded, full-codebase agent role used as the reviewer
26
- * fallback. Every organization gets one on creation (migration
27
- * seed_default_agent_roles: 'Developer'). Mirrors nexus intake's
28
- * DEFAULT_INTAKE_ROLE_NAME so review-spawn and intake-spawn share the same
29
- * zero-config fallback identity.
30
- */
31
- export declare const DEFAULT_REVIEWER_ROLE_NAME = "Developer";
32
- /**
33
- * What to do with a pending spawn directive whose focus has a null
34
- * assigned_agent_role_id.
35
- *
36
- * - skip: a CODING directive (or no directive) -- the intended off-state
37
- * (Play/queue toggle cleared). Never auto-spawn.
38
- * - spawn: a REVIEW directive with a resolved fallback role -- spawn the
39
- * review team under it.
40
- * - clear: a REVIEW directive with NO resolvable fallback role -- drop the
41
- * directive so the stranded-review re-fire suppression cannot spin
42
- * forever; review_window_stalled remains the escalation path.
43
- */
44
- export type NullRoleSpawnDecision = {
45
- action: 'skip';
46
- } | {
47
- action: 'spawn';
48
- role: AgentRole;
49
- } | {
50
- action: 'clear';
51
- };
52
- /**
53
- * Resolve the org's seeded Developer role from an already-loaded roles
54
- * collection (the listener keeps every org agent role in memory). Returns the
55
- * first role named DEFAULT_REVIEWER_ROLE_NAME, or undefined when the org has no
56
- * seeded Developer role (the degenerate case the 'clear' decision handles).
57
- *
58
- * Pure and exported for unit testing.
59
- */
60
- export declare function resolveReviewerFallbackRole(roles: Iterable<AgentRole>): AgentRole | undefined;
61
- /**
62
- * Decide what to do with a null-role pending spawn directive.
63
- *
64
- * A null assigned_agent_role_id means one of THREE things, and they must be
65
- * told apart:
66
- *
67
- * - An OPERATOR STOP (product_focuses.operator_stopped_at is set): the human
68
- * pulled the Play toggle to halt the focus. This is authoritative and wins
69
- * over everything -- when `operatorStopped` is true we `skip` for EVERY
70
- * sessionType, review included, and regardless of `reopened`. The stop lever
71
- * must never become the trigger for the path it was meant to stop.
72
- * - A LIFECYCLE CLEAR of a FINISHED focus (operator_stopped_at null, work not
73
- * reopened): auto_terminate_focus_team() nulled the role at completion. Here
74
- * a review directive is a SECOND team that must spawn AFTER completion (spawn
75
- * under the fallback role, else clear); a coding directive is the intended
76
- * off-state and is skipped.
77
- * - A LIFECYCLE CLEAR whose work was REOPENED (operator_stopped_at null,
78
- * `reopened` true): a review sent completed work back, so the focus is NOT
79
- * finished -- a coding directive here is NOT the off-state. It must spawn
80
- * under the fallback role (else clear), the same treatment a review
81
- * directive gets, so the reopened work resumes instead of stranding on a
82
- * lifecycle-cleared focus. This is the fact `decideNullRoleSpawn` previously
83
- * lacked: a coding directive was classified by sessionType ALONE, collapsing
84
- * "finished" and "reopened" into one skip.
85
- *
86
- * With `operatorStopped` false AND `reopened` false the behaviour is
87
- * byte-identical to before either fact existed.
88
- *
89
- * Pure and exported for unit testing (peer of resolveReviewerFallbackRole).
90
- */
91
- export declare function decideNullRoleSpawn(input: {
92
- sessionType: 'coding' | 'review' | undefined;
93
- fallbackRole: AgentRole | undefined;
94
- /**
95
- * Whether an operator has stopped this focus (product_focuses.
96
- * operator_stopped_at is set). When true, no spawn happens for any
97
- * sessionType -- the operator's stop is authoritative.
98
- */
99
- operatorStopped: boolean;
100
- /**
101
- * Whether this lifecycle-cleared focus's work was REOPENED after the role was
102
- * cleared (e.g. a gaps_found review re-queued a delivery: a non-terminal
103
- * delivery now exists on a focus whose role auto_terminate_focus_team()
104
- * nulled). Only consulted for a non-review (coding/undefined) directive; a
105
- * review directive already spawns via the fallback. Defaults false, which
106
- * preserves the pre-reopened behaviour exactly. Ignored when
107
- * `operatorStopped` is true -- the stop always wins.
108
- */
109
- reopened?: boolean;
110
- }): NullRoleSpawnDecision;
111
- /**
112
- * Re-announce floor for the null-role "coding off-state" skip warning. The
113
- * warning is emitted on entry and then AT MOST once per this interval while the
114
- * block persists -- long enough that a stopped focus does not spin-log every
115
- * 30s poll, short enough that a block that persists keeps surfacing in the log
116
- * for as long as it lasts (instead of being announced once and then suppressed
117
- * forever, which made a genuinely stuck focus indistinguishable from a finished
118
- * one). 30 minutes.
119
- */
120
- export declare const NULL_ROLE_SKIP_REANNOUNCE_FLOOR_MS: number;
121
- /**
122
- * Rate-limited re-announce gate for the null-role "coding off-state" skip
123
- * warning. The listener holds a Map of focus id -> last-announce timestamp (ms)
124
- * for the current continuous blocked episode; this mutates it and returns
125
- * whether to emit the warning now:
126
- *
127
- * - focus never announced this episode -> record `nowMs` and return true
128
- * (warn on entry).
129
- * - last announced >= `floorMs` ago -> record `nowMs` and return true
130
- * (re-announce: the block persists, keep surfacing it).
131
- * - last announced < `floorMs` ago -> return false (suppress the per-poll
132
- * repeat between re-announcements).
133
- *
134
- * The listener removes the focus from the map when it resumes (role assigned,
135
- * directive cleared, or focus leaves the active set), so a later re-entry warns
136
- * immediately again. `nowMs`/`floorMs` are injectable so the decision is
137
- * deterministic under test. Pure w.r.t. its inputs (Map + clock in, boolean
138
- * out) and exported for unit testing without standing up the poll loop.
139
- */
140
- export declare function shouldWarnNullRoleSkip(lastAnnouncedAt: Map<string, number>, focusId: string, nowMs?: number, floorMs?: number): boolean;
141
- //# sourceMappingURL=review-role-fallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-role-fallback.d.ts","sourceRoot":"","sources":["../../src/spawn/review-role-fallback.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,cAAc,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAExB;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GACzB,SAAS,GAAG,SAAS,CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,WAAW,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC7C,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC;IACpC;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,qBAAqB,CAkBxB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,QAAc,CAAC;AAE9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,MAAmB,EAC1B,OAAO,GAAE,MAA2C,GACnD,OAAO,CAKT"}
@@ -1,114 +0,0 @@
1
- // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
- // Pinned by: packages/daemon/src/focus/listener-operator-stop-drop.test.ts,
3
- // packages/daemon/src/spawn/review-role-fallback.test.ts
4
- // PINNED-BY-END
5
- /**
6
- * Name of the org's auto-seeded, full-codebase agent role used as the reviewer
7
- * fallback. Every organization gets one on creation (migration
8
- * seed_default_agent_roles: 'Developer'). Mirrors nexus intake's
9
- * DEFAULT_INTAKE_ROLE_NAME so review-spawn and intake-spawn share the same
10
- * zero-config fallback identity.
11
- */
12
- export const DEFAULT_REVIEWER_ROLE_NAME = 'Developer';
13
- /**
14
- * Resolve the org's seeded Developer role from an already-loaded roles
15
- * collection (the listener keeps every org agent role in memory). Returns the
16
- * first role named DEFAULT_REVIEWER_ROLE_NAME, or undefined when the org has no
17
- * seeded Developer role (the degenerate case the 'clear' decision handles).
18
- *
19
- * Pure and exported for unit testing.
20
- */
21
- export function resolveReviewerFallbackRole(roles) {
22
- for (const role of roles) {
23
- if (role.name === DEFAULT_REVIEWER_ROLE_NAME)
24
- return role;
25
- }
26
- return undefined;
27
- }
28
- /**
29
- * Decide what to do with a null-role pending spawn directive.
30
- *
31
- * A null assigned_agent_role_id means one of THREE things, and they must be
32
- * told apart:
33
- *
34
- * - An OPERATOR STOP (product_focuses.operator_stopped_at is set): the human
35
- * pulled the Play toggle to halt the focus. This is authoritative and wins
36
- * over everything -- when `operatorStopped` is true we `skip` for EVERY
37
- * sessionType, review included, and regardless of `reopened`. The stop lever
38
- * must never become the trigger for the path it was meant to stop.
39
- * - A LIFECYCLE CLEAR of a FINISHED focus (operator_stopped_at null, work not
40
- * reopened): auto_terminate_focus_team() nulled the role at completion. Here
41
- * a review directive is a SECOND team that must spawn AFTER completion (spawn
42
- * under the fallback role, else clear); a coding directive is the intended
43
- * off-state and is skipped.
44
- * - A LIFECYCLE CLEAR whose work was REOPENED (operator_stopped_at null,
45
- * `reopened` true): a review sent completed work back, so the focus is NOT
46
- * finished -- a coding directive here is NOT the off-state. It must spawn
47
- * under the fallback role (else clear), the same treatment a review
48
- * directive gets, so the reopened work resumes instead of stranding on a
49
- * lifecycle-cleared focus. This is the fact `decideNullRoleSpawn` previously
50
- * lacked: a coding directive was classified by sessionType ALONE, collapsing
51
- * "finished" and "reopened" into one skip.
52
- *
53
- * With `operatorStopped` false AND `reopened` false the behaviour is
54
- * byte-identical to before either fact existed.
55
- *
56
- * Pure and exported for unit testing (peer of resolveReviewerFallbackRole).
57
- */
58
- export function decideNullRoleSpawn(input) {
59
- if (input.operatorStopped)
60
- return { action: 'skip' };
61
- // A review directive spawns the review team under the fallback (unchanged).
62
- if (input.sessionType === 'review') {
63
- return input.fallbackRole
64
- ? { action: 'spawn', role: input.fallbackRole }
65
- : { action: 'clear' };
66
- }
67
- // A coding/undefined directive on reopened work is NOT the off-state: spawn
68
- // the reopened work under the fallback (else clear), just like a review.
69
- if (input.reopened) {
70
- return input.fallbackRole
71
- ? { action: 'spawn', role: input.fallbackRole }
72
- : { action: 'clear' };
73
- }
74
- // A coding/undefined directive on a genuinely finished focus stays the
75
- // intended off-state.
76
- return { action: 'skip' };
77
- }
78
- /**
79
- * Re-announce floor for the null-role "coding off-state" skip warning. The
80
- * warning is emitted on entry and then AT MOST once per this interval while the
81
- * block persists -- long enough that a stopped focus does not spin-log every
82
- * 30s poll, short enough that a block that persists keeps surfacing in the log
83
- * for as long as it lasts (instead of being announced once and then suppressed
84
- * forever, which made a genuinely stuck focus indistinguishable from a finished
85
- * one). 30 minutes.
86
- */
87
- export const NULL_ROLE_SKIP_REANNOUNCE_FLOOR_MS = 30 * 60_000;
88
- /**
89
- * Rate-limited re-announce gate for the null-role "coding off-state" skip
90
- * warning. The listener holds a Map of focus id -> last-announce timestamp (ms)
91
- * for the current continuous blocked episode; this mutates it and returns
92
- * whether to emit the warning now:
93
- *
94
- * - focus never announced this episode -> record `nowMs` and return true
95
- * (warn on entry).
96
- * - last announced >= `floorMs` ago -> record `nowMs` and return true
97
- * (re-announce: the block persists, keep surfacing it).
98
- * - last announced < `floorMs` ago -> return false (suppress the per-poll
99
- * repeat between re-announcements).
100
- *
101
- * The listener removes the focus from the map when it resumes (role assigned,
102
- * directive cleared, or focus leaves the active set), so a later re-entry warns
103
- * immediately again. `nowMs`/`floorMs` are injectable so the decision is
104
- * deterministic under test. Pure w.r.t. its inputs (Map + clock in, boolean
105
- * out) and exported for unit testing without standing up the poll loop.
106
- */
107
- export function shouldWarnNullRoleSkip(lastAnnouncedAt, focusId, nowMs = Date.now(), floorMs = NULL_ROLE_SKIP_REANNOUNCE_FLOOR_MS) {
108
- const prev = lastAnnouncedAt.get(focusId);
109
- if (prev !== undefined && nowMs - prev < floorMs)
110
- return false;
111
- lastAnnouncedAt.set(focusId, nowMs);
112
- return true;
113
- }
114
- //# sourceMappingURL=review-role-fallback.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-role-fallback.js","sourceRoot":"","sources":["../../src/spawn/review-role-fallback.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,4EAA4E;AAC5E,2DAA2D;AAC3D,gBAAgB;AA2BhB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,CAAC;AAmBtD;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAA0B;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,0BAA0B;YAAE,OAAO,IAAI,CAAC;IAC5D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAmBnC;IACC,IAAI,KAAK,CAAC,eAAe;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACrD,4EAA4E;IAC5E,IAAI,KAAK,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,YAAY;YACvB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE;YAC/C,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,4EAA4E;IAC5E,yEAAyE;IACzE,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC,YAAY;YACvB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE;YAC/C,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,uEAAuE;IACvE,sBAAsB;IACtB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,GAAG,MAAM,CAAC;AAE9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAAoC,EACpC,OAAe,EACf,QAAgB,IAAI,CAAC,GAAG,EAAE,EAC1B,UAAkB,kCAAkC;IAEpD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,GAAG,OAAO;QAAE,OAAO,KAAK,CAAC;IAC/D,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC"}