@telora/daemon 0.20.28 → 0.20.53
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/agent-state.d.ts +4 -6
- package/dist/agent-state.d.ts.map +1 -1
- package/dist/agent-state.js +4 -10
- package/dist/agent-state.js.map +1 -1
- package/dist/auto-update.d.ts +87 -0
- package/dist/auto-update.d.ts.map +1 -1
- package/dist/auto-update.js +142 -8
- package/dist/auto-update.js.map +1 -1
- package/dist/branch-status.d.ts +25 -3
- package/dist/branch-status.d.ts.map +1 -1
- package/dist/branch-status.js +130 -59
- package/dist/branch-status.js.map +1 -1
- package/dist/completion/completion-decision.d.ts +29 -3
- package/dist/completion/completion-decision.d.ts.map +1 -1
- package/dist/completion/completion-decision.js +15 -3
- package/dist/completion/completion-decision.js.map +1 -1
- package/dist/completion/event-entry-phases.d.ts +57 -0
- package/dist/completion/event-entry-phases.d.ts.map +1 -0
- package/dist/completion/event-entry-phases.js +205 -0
- package/dist/completion/event-entry-phases.js.map +1 -0
- package/dist/completion/event-phases.d.ts +14 -42
- package/dist/completion/event-phases.d.ts.map +1 -1
- package/dist/completion/event-phases.js +63 -190
- package/dist/completion/event-phases.js.map +1 -1
- package/dist/completion/event.d.ts +11 -1
- package/dist/completion/event.d.ts.map +1 -1
- package/dist/completion/event.js +5 -2
- package/dist/completion/event.js.map +1 -1
- package/dist/completion/index.d.ts +0 -3
- package/dist/completion/index.d.ts.map +1 -1
- package/dist/completion/index.js +0 -3
- package/dist/completion/index.js.map +1 -1
- package/dist/completion/review-exit-phase.d.ts +2 -1
- package/dist/completion/review-exit-phase.d.ts.map +1 -1
- package/dist/completion/review-exit-phase.js +41 -1
- package/dist/completion/review-exit-phase.js.map +1 -1
- package/dist/completion/status-advance-phase.d.ts +2 -0
- package/dist/completion/status-advance-phase.d.ts.map +1 -1
- package/dist/completion/status-advance-phase.js +14 -28
- package/dist/completion/status-advance-phase.js.map +1 -1
- package/dist/completion/team-completion.js +1 -1
- package/dist/completion/team-completion.js.map +1 -1
- package/dist/completion/terminated-work-reconcile.d.ts.map +1 -1
- package/dist/completion/terminated-work-reconcile.js +10 -0
- package/dist/completion/terminated-work-reconcile.js.map +1 -1
- package/dist/constants.d.ts +0 -8
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -8
- package/dist/constants.js.map +1 -1
- package/dist/delivery-close-actions.d.ts +39 -0
- package/dist/delivery-close-actions.d.ts.map +1 -0
- package/dist/delivery-close-actions.js +53 -0
- package/dist/delivery-close-actions.js.map +1 -0
- package/dist/delivery-lifecycle.d.ts +11 -0
- package/dist/delivery-lifecycle.d.ts.map +1 -1
- package/dist/delivery-lifecycle.js +13 -14
- package/dist/delivery-lifecycle.js.map +1 -1
- package/dist/delivery-reconciler.d.ts +18 -4
- package/dist/delivery-reconciler.d.ts.map +1 -1
- package/dist/delivery-reconciler.js +18 -4
- package/dist/delivery-reconciler.js.map +1 -1
- package/dist/directive-executor.d.ts +1 -1
- package/dist/directive-executor.js +1 -1
- package/dist/discovery-fetch.d.ts +76 -0
- package/dist/discovery-fetch.d.ts.map +1 -0
- package/dist/discovery-fetch.js +206 -0
- package/dist/discovery-fetch.js.map +1 -0
- package/dist/discovery-poll.d.ts +1 -51
- package/dist/discovery-poll.d.ts.map +1 -1
- package/dist/discovery-poll.js +10 -192
- package/dist/discovery-poll.js.map +1 -1
- package/dist/drain-teardown.d.ts +11 -6
- package/dist/drain-teardown.d.ts.map +1 -1
- package/dist/drain-teardown.js +3 -2
- package/dist/drain-teardown.js.map +1 -1
- package/dist/focus-branch-ahead.d.ts +42 -0
- package/dist/focus-branch-ahead.d.ts.map +1 -0
- package/dist/focus-branch-ahead.js +45 -0
- package/dist/focus-branch-ahead.js.map +1 -0
- package/dist/focus-engine.d.ts.map +1 -1
- package/dist/focus-engine.js +21 -43
- package/dist/focus-engine.js.map +1 -1
- package/dist/focus-executor.js +2 -2
- package/dist/focus-executor.js.map +1 -1
- package/dist/focus-lifecycle.d.ts.map +1 -1
- package/dist/focus-lifecycle.js +32 -3
- package/dist/focus-lifecycle.js.map +1 -1
- package/dist/focus-loop-registry.d.ts.map +1 -1
- package/dist/focus-loop-registry.js +27 -0
- package/dist/focus-loop-registry.js.map +1 -1
- package/dist/focus-loop.d.ts +34 -12
- package/dist/focus-loop.d.ts.map +1 -1
- package/dist/focus-loop.js +78 -15
- package/dist/focus-loop.js.map +1 -1
- package/dist/focus-merge.d.ts.map +1 -1
- package/dist/focus-merge.js +6 -1
- package/dist/focus-merge.js.map +1 -1
- package/dist/focus-phase.d.ts +18 -3
- package/dist/focus-phase.d.ts.map +1 -1
- package/dist/focus-phase.js +85 -31
- package/dist/focus-phase.js.map +1 -1
- package/dist/focus-prompt-builder.d.ts.map +1 -1
- package/dist/focus-prompt-builder.js +13 -1
- package/dist/focus-prompt-builder.js.map +1 -1
- package/dist/focus-provisioning.d.ts.map +1 -1
- package/dist/focus-provisioning.js +4 -0
- package/dist/focus-provisioning.js.map +1 -1
- package/dist/focus-stage-lifecycle/planning-release.d.ts +35 -17
- package/dist/focus-stage-lifecycle/planning-release.d.ts.map +1 -1
- package/dist/focus-stage-lifecycle/planning-release.js +53 -22
- package/dist/focus-stage-lifecycle/planning-release.js.map +1 -1
- package/dist/focus-worktree-state.d.ts +17 -6
- package/dist/focus-worktree-state.d.ts.map +1 -1
- package/dist/focus-worktree-state.js +21 -11
- package/dist/focus-worktree-state.js.map +1 -1
- package/dist/guard-engine.d.ts +1 -2
- package/dist/guard-engine.d.ts.map +1 -1
- package/dist/guard-engine.js +1 -2
- package/dist/guard-engine.js.map +1 -1
- package/dist/health-events.d.ts +10 -0
- package/dist/health-events.d.ts.map +1 -0
- package/dist/health-events.js +10 -0
- package/dist/health-events.js.map +1 -0
- package/dist/heartbeat.d.ts.map +1 -1
- package/dist/heartbeat.js +98 -21
- package/dist/heartbeat.js.map +1 -1
- package/dist/host-control/catalog.d.ts.map +1 -1
- package/dist/host-control/catalog.js +4 -1
- package/dist/host-control/catalog.js.map +1 -1
- package/dist/host-control/client.d.ts +3 -4
- package/dist/host-control/client.d.ts.map +1 -1
- package/dist/host-control/client.js +4 -5
- package/dist/host-control/client.js.map +1 -1
- package/dist/listener-auto-advance.d.ts +2 -1
- package/dist/listener-auto-advance.d.ts.map +1 -1
- package/dist/listener-auto-advance.js +36 -40
- package/dist/listener-auto-advance.js.map +1 -1
- package/dist/listener.d.ts +2 -7
- package/dist/listener.d.ts.map +1 -1
- package/dist/listener.js +11 -9
- package/dist/listener.js.map +1 -1
- package/dist/operator-hold.d.ts +66 -0
- package/dist/operator-hold.d.ts.map +1 -0
- package/dist/operator-hold.js +99 -0
- package/dist/operator-hold.js.map +1 -0
- package/dist/poll-trigger.d.ts +28 -0
- package/dist/poll-trigger.d.ts.map +1 -0
- package/dist/poll-trigger.js +31 -0
- package/dist/poll-trigger.js.map +1 -0
- package/dist/prompt-listing.d.ts +25 -0
- package/dist/prompt-listing.d.ts.map +1 -1
- package/dist/prompt-listing.js +67 -0
- package/dist/prompt-listing.js.map +1 -1
- package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
- package/dist/prompt-sections/execution-sections.js +24 -0
- package/dist/prompt-sections/execution-sections.js.map +1 -1
- package/dist/queries/context-lock-queries.d.ts.map +1 -1
- package/dist/queries/context-lock-queries.js +4 -1
- package/dist/queries/context-lock-queries.js.map +1 -1
- package/dist/queries/deliveries.d.ts +17 -0
- package/dist/queries/deliveries.d.ts.map +1 -1
- package/dist/queries/deliveries.js.map +1 -1
- package/dist/queries/issues.d.ts +98 -0
- package/dist/queries/issues.d.ts.map +1 -1
- package/dist/queries/issues.js +135 -0
- package/dist/queries/issues.js.map +1 -1
- package/dist/queries/schemas.d.ts +3 -3
- package/dist/security-scan-engine.d.ts +9 -1
- package/dist/security-scan-engine.d.ts.map +1 -1
- package/dist/security-scan-engine.js +25 -2
- package/dist/security-scan-engine.js.map +1 -1
- package/dist/spawn/worktree-session.d.ts.map +1 -1
- package/dist/spawn/worktree-session.js +2 -0
- package/dist/spawn/worktree-session.js.map +1 -1
- package/dist/spawner/index.d.ts +7 -9
- package/dist/spawner/index.d.ts.map +1 -1
- package/dist/spawner/index.js +13 -11
- package/dist/spawner/index.js.map +1 -1
- package/dist/spawner/lifecycle.d.ts +1 -18
- package/dist/spawner/lifecycle.d.ts.map +1 -1
- package/dist/spawner/lifecycle.js +1 -54
- package/dist/spawner/lifecycle.js.map +1 -1
- package/dist/spawner/liveness.d.ts +5 -14
- package/dist/spawner/liveness.d.ts.map +1 -1
- package/dist/spawner/liveness.js +5 -67
- package/dist/spawner/liveness.js.map +1 -1
- package/dist/spawner/state.d.ts +8 -20
- package/dist/spawner/state.d.ts.map +1 -1
- package/dist/spawner/state.js +8 -34
- package/dist/spawner/state.js.map +1 -1
- package/dist/staleness-sensor.d.ts +153 -0
- package/dist/staleness-sensor.d.ts.map +1 -0
- package/dist/staleness-sensor.js +308 -0
- package/dist/staleness-sensor.js.map +1 -0
- package/dist/types/focus.d.ts +9 -0
- package/dist/types/focus.d.ts.map +1 -1
- package/dist/types/session.d.ts +0 -44
- package/dist/types/session.d.ts.map +1 -1
- package/dist/unified-shell.d.ts.map +1 -1
- package/dist/unified-shell.js +19 -0
- package/dist/unified-shell.js.map +1 -1
- package/dist/verification-engine.d.ts +6 -4
- package/dist/verification-engine.d.ts.map +1 -1
- package/dist/verification-engine.js +9 -43
- package/dist/verification-engine.js.map +1 -1
- package/dist/verification-feedback.d.ts +42 -0
- package/dist/verification-feedback.d.ts.map +1 -1
- package/dist/verification-feedback.js +93 -0
- package/dist/verification-feedback.js.map +1 -1
- package/dist/version-check.d.ts +6 -0
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +1 -1
- package/dist/version-check.js.map +1 -1
- package/package.json +2 -3
- package/dist/completion/agent-completion.d.ts +0 -48
- package/dist/completion/agent-completion.d.ts.map +0 -1
- package/dist/completion/agent-completion.js +0 -205
- package/dist/completion/agent-completion.js.map +0 -1
- package/dist/delivery-guards.d.ts +0 -41
- package/dist/delivery-guards.d.ts.map +0 -1
- package/dist/delivery-guards.js +0 -200
- package/dist/delivery-guards.js.map +0 -1
- package/dist/spawner/spawn-team.d.ts +0 -20
- package/dist/spawner/spawn-team.d.ts.map +0 -1
- package/dist/spawner/spawn-team.js +0 -19
- package/dist/spawner/spawn-team.js.map +0 -1
- package/dist/spawner/timeout.d.ts +0 -32
- package/dist/spawner/timeout.d.ts.map +0 -1
- package/dist/spawner/timeout.js +0 -126
- package/dist/spawner/timeout.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/spawner/state.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/spawner/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAG;AAE7D,+DAA+D;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,mFAAmF;AACnF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,2EAA2E;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/spawner/state.js
CHANGED
|
@@ -1,49 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Spawner lifecycle/state re-export hub.
|
|
3
3
|
*
|
|
4
|
-
* The per-delivery spawn function (spawnAgentForDelivery)
|
|
5
|
-
*
|
|
4
|
+
* The per-delivery spawn function (spawnAgentForDelivery) and the legacy
|
|
5
|
+
* `runningAgents` fleet it fed were removed -- delivery-level execution is now
|
|
6
|
+
* handled by the focus-level team spawner, and the single `reapWorkerFleet`
|
|
7
|
+
* teardown covers every spawned process (see packages/daemon/CLAUDE.md).
|
|
6
8
|
*
|
|
7
|
-
* This module re-exports
|
|
8
|
-
*
|
|
9
|
+
* This module re-exports the spawn helpers and the shared process-liveness
|
|
10
|
+
* probe consumed by the rest of the daemon.
|
|
9
11
|
*
|
|
10
12
|
* Stream/process handling: ./stream-handlers.ts
|
|
11
13
|
* Lifecycle management: ./lifecycle.ts
|
|
12
14
|
*/
|
|
13
|
-
import { getRunningAgents as _getRunningAgents } from '../agent-state.js';
|
|
14
|
-
import { terminateAgent as _terminateAgent, terminateAllAgents as _terminateAllAgents, isAgentRunning as _isAgentRunning, getRunningAgentCount as _getRunningAgentCount, } from './lifecycle.js';
|
|
15
|
-
// Running agents map: shared via agent-state module
|
|
16
|
-
const runningAgents = _getRunningAgents();
|
|
17
15
|
/** No-op. The per-delivery spawn path was removed; governor is managed by team-spawner. */
|
|
18
16
|
export function initGovernor(_gov) { }
|
|
19
|
-
/**
|
|
20
|
-
* Get map of running agents.
|
|
21
|
-
* Re-exported from agent-state for backward compatibility.
|
|
22
|
-
*/
|
|
23
|
-
export function getRunningAgents() {
|
|
24
|
-
return runningAgents;
|
|
25
|
-
}
|
|
26
|
-
// ── Re-exports with module-level state bound ────────────────────────
|
|
27
|
-
/** Terminate a running agent. */
|
|
28
|
-
export function terminateAgent(sessionId) {
|
|
29
|
-
return _terminateAgent(sessionId, runningAgents);
|
|
30
|
-
}
|
|
31
|
-
/** Terminate all running agents. */
|
|
32
|
-
export function terminateAllAgents() {
|
|
33
|
-
_terminateAllAgents(runningAgents);
|
|
34
|
-
}
|
|
35
|
-
/** Check if an agent is running for a session. */
|
|
36
|
-
export function isAgentRunning(sessionId) {
|
|
37
|
-
return _isAgentRunning(sessionId, runningAgents);
|
|
38
|
-
}
|
|
39
|
-
/** Get count of running agents. */
|
|
40
|
-
export function getRunningAgentCount() {
|
|
41
|
-
return _getRunningAgentCount(runningAgents);
|
|
42
|
-
}
|
|
43
17
|
/** Re-export spawnResolutionAgent (no module state needed). */
|
|
44
18
|
export { spawnResolutionAgent } from './lifecycle.js';
|
|
45
19
|
/** Re-export spawnAuditAgent (one-shot audit assessor, no module state needed). */
|
|
46
20
|
export { spawnAuditAgent, buildAuditMetricRow } from './lifecycle.js';
|
|
47
|
-
/** Re-export
|
|
48
|
-
export { isProcessAlive
|
|
21
|
+
/** Re-export the shared process-liveness probe (used by the reap path). */
|
|
22
|
+
export { isProcessAlive } from './liveness.js';
|
|
49
23
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/spawner/state.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/spawner/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,2FAA2F;AAC3F,MAAM,UAAU,YAAY,CAAC,IAAsB,IAAS,CAAC;AAE7D,+DAA+D;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,mFAAmF;AACnF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGtE,2EAA2E;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propagation-staleness sensor (focus: "Propagation Staleness Is Invisible").
|
|
3
|
+
*
|
|
4
|
+
* The differential instrument this focus is named for: it computes
|
|
5
|
+
* newest-available MINUS actually-running for a tracked target. Its first (and
|
|
6
|
+
* directly observable) target is the running daemon vs the Gitea npm registry:
|
|
7
|
+
*
|
|
8
|
+
* running = ~/.telora/daemon.meta.json .version (this daemon's own build)
|
|
9
|
+
* newest = the warm version cache .latestVersion (Gitea registry dist-tags.latest,
|
|
10
|
+
* kept fresh by startVersionCacheRefreshLoop)
|
|
11
|
+
*
|
|
12
|
+
* CLOSING the gap, not reporting it. The daemon-version gap is machine-closable:
|
|
13
|
+
* the safe-seam auto-update controller (auto-update.ts) already installs a newer
|
|
14
|
+
* registry version at the next batch-safe idle seam. So when the gap is beyond
|
|
15
|
+
* threshold this sensor DEFERS to that closer -- it does NOT tell a human "the
|
|
16
|
+
* daemon is stale, restart it". Telling a human about a gap the machine is
|
|
17
|
+
* already closing converts machine signal into human chore, and firing on a
|
|
18
|
+
* healthy daemon that is merely deferring to its next safe seam is exactly the
|
|
19
|
+
* failure mode this focus exists to remove.
|
|
20
|
+
*
|
|
21
|
+
* A human is involved ONLY where the machine genuinely cannot act: auto-update
|
|
22
|
+
* is disabled for this daemon (installMode=npx, or --no-auto-update /
|
|
23
|
+
* TELORA_AUTO_UPDATE=0, reflected as autoUpdateEnabled=false in daemon.meta.json).
|
|
24
|
+
* The operator opted out of automation, so the machine cannot close the gap --
|
|
25
|
+
* and even then the deliverable is a READY ACTION handed over (the exact
|
|
26
|
+
* `npm install -g` command + restart), never an inbox item that merely says a
|
|
27
|
+
* gap exists. That handover auto-resolves once the running version catches up,
|
|
28
|
+
* and is retired immediately if auto-update is re-enabled (the machine reclaims
|
|
29
|
+
* closure).
|
|
30
|
+
*
|
|
31
|
+
* Every tick leaves a trace (delegated-to-auto-update / handed-over /
|
|
32
|
+
* back-in-sync / "measured, within threshold" / "UNMEASURED"), so an ABSENT
|
|
33
|
+
* trace positively means "measured and in sync" -- never "not measured". Wedged
|
|
34
|
+
* auto-update (enabled but not running) is made visible by the SEPARATE
|
|
35
|
+
* auto-update decision heartbeat (auto-update.ts): an absent [auto-update] trace
|
|
36
|
+
* identifies a controller that is not running. That is not re-derived here.
|
|
37
|
+
*
|
|
38
|
+
* Pure decision (computeDaemonVersionDifferential / decideStalenessAction) +
|
|
39
|
+
* injected IO, mirroring ci-sensor-loop.ts, so the loop is unit-testable without
|
|
40
|
+
* a live registry or DB. Registered in LOOP_REGISTRY under the opt-out guard
|
|
41
|
+
* TELORA_STALENESS_SENSOR_LOOP.
|
|
42
|
+
*
|
|
43
|
+
* The two infra-owned targets observed 2026-07-24 (npmjs mirror serving a stale
|
|
44
|
+
* version; Opus 5 seed merged-but-maybe-not-applied) are NOT computable from
|
|
45
|
+
* this repo (no prod DB access; infra alone publishes to npmjs). They are
|
|
46
|
+
* recorded, with their operator-facing close action, in
|
|
47
|
+
* docs/runbook-propagation-staleness-targets.md -- the sensor deliberately does
|
|
48
|
+
* NOT attempt those infra actions.
|
|
49
|
+
*
|
|
50
|
+
* @module staleness-sensor
|
|
51
|
+
*/
|
|
52
|
+
import type { DaemonConfig } from './types.js';
|
|
53
|
+
/**
|
|
54
|
+
* escalation_kind for a stale daemon that the machine CANNOT auto-close (auto-update
|
|
55
|
+
* disabled). Carries a ready action, not a bare "gap exists" notice.
|
|
56
|
+
*/
|
|
57
|
+
export declare const PROPAGATION_STALE_ESCALATION_KIND = "propagation_stale";
|
|
58
|
+
/** Stable target id for the daemon-vs-registry differential. */
|
|
59
|
+
export declare const DAEMON_VERSION_TARGET = "daemon-version";
|
|
60
|
+
/**
|
|
61
|
+
* Default patch-version distance that trips the signal. Any minor/major gap
|
|
62
|
+
* always trips regardless. A 1-2 patch gap is left quiet: auto-update closes it
|
|
63
|
+
* at the next idle seam, so signaling immediately would be noise. The observed
|
|
64
|
+
* failure (0.20.21 vs 0.20.28 = 7 patches) is well past this floor.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DEFAULT_STALENESS_PATCH_THRESHOLD = 3;
|
|
67
|
+
/** Component-wise magnitude of how far `running` is behind `newest` (clamped at 0). */
|
|
68
|
+
export interface VersionDistance {
|
|
69
|
+
major: number;
|
|
70
|
+
minor: number;
|
|
71
|
+
patch: number;
|
|
72
|
+
}
|
|
73
|
+
/** The computed newest-vs-running differential for a tracked target. */
|
|
74
|
+
export interface StalenessDifferential {
|
|
75
|
+
target: string;
|
|
76
|
+
running: string;
|
|
77
|
+
newest: string;
|
|
78
|
+
/** True when `newest` is strictly newer than `running`. */
|
|
79
|
+
behind: boolean;
|
|
80
|
+
distance: VersionDistance;
|
|
81
|
+
/** True when the gap exceeds the declared threshold (any minor/major, or >= patchThreshold patches). */
|
|
82
|
+
beyondThreshold: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Compute the daemon-vs-registry differential. Returns null when it cannot be
|
|
86
|
+
* MEASURED (either version missing) -- the caller must then emit an explicit
|
|
87
|
+
* "UNMEASURED" trace rather than staying silent, so silence always means "in
|
|
88
|
+
* sync", never "not measured".
|
|
89
|
+
*/
|
|
90
|
+
export declare function computeDaemonVersionDifferential(running: string | null, newest: string | null, patchThreshold?: number): StalenessDifferential | null;
|
|
91
|
+
/**
|
|
92
|
+
* What the sensor should do with the current differential.
|
|
93
|
+
* - `delegate` -- gap is beyond threshold and the machine closes it itself
|
|
94
|
+
* (auto-update enabled): defer to that closer, no human.
|
|
95
|
+
* - `hand-over` -- gap is beyond threshold but the machine cannot act
|
|
96
|
+
* (auto-update disabled): hand a human a ready action.
|
|
97
|
+
* - `resolve` -- an open handover exists but the machine is now closing the
|
|
98
|
+
* gap (back within threshold, OR auto-update re-enabled).
|
|
99
|
+
* - `none` -- nothing to do.
|
|
100
|
+
*/
|
|
101
|
+
export type StalenessAction = 'delegate' | 'hand-over' | 'resolve' | 'none';
|
|
102
|
+
/**
|
|
103
|
+
* Pure decision. The pivot is `canMachineClose`: when the auto-update controller
|
|
104
|
+
* owns closing the daemon-version gap, the sensor NEVER hands a human a report --
|
|
105
|
+
* it defers (and retires any stale handover). A human is handed a ready action
|
|
106
|
+
* ONLY when the machine genuinely cannot act. A null differential (unmeasurable)
|
|
107
|
+
* never acts -- it is handled as a trace by the tick.
|
|
108
|
+
*/
|
|
109
|
+
export declare function decideStalenessAction(diff: StalenessDifferential | null, hasOpen: boolean, canMachineClose: boolean): StalenessAction;
|
|
110
|
+
/** Injected IO for the sensor tick. Defaults reach for the real implementations. */
|
|
111
|
+
export interface StalenessSensorDeps {
|
|
112
|
+
readRunningVersion: () => string | null;
|
|
113
|
+
readNewestAvailable: () => string | null;
|
|
114
|
+
patchThreshold: number;
|
|
115
|
+
/**
|
|
116
|
+
* True when the auto-update controller can close the daemon-version gap itself.
|
|
117
|
+
* When true the sensor defers to that closer and never hands a human a report;
|
|
118
|
+
* when false the operator opted out and the machine genuinely cannot act.
|
|
119
|
+
*/
|
|
120
|
+
canMachineCloseGap: () => boolean;
|
|
121
|
+
hasOpenStalenessEscalation: () => Promise<boolean>;
|
|
122
|
+
/** Hand a human a READY ACTION when (and only when) the machine cannot act. */
|
|
123
|
+
handOverReadyAction: (params: {
|
|
124
|
+
organizationId: string;
|
|
125
|
+
productId: string;
|
|
126
|
+
diff: StalenessDifferential;
|
|
127
|
+
readyCommand: string;
|
|
128
|
+
}) => Promise<void>;
|
|
129
|
+
resolveStalenessEscalations: () => Promise<number>;
|
|
130
|
+
}
|
|
131
|
+
export interface StalenessSensorTickCounts {
|
|
132
|
+
/** True when the differential could be computed (both versions known). */
|
|
133
|
+
measured: boolean;
|
|
134
|
+
/** True when the daemon is behind the registry at all (any distance). */
|
|
135
|
+
behind: boolean;
|
|
136
|
+
/** True when the machine (auto-update) owns closing the measured gap this tick. */
|
|
137
|
+
delegatedToAutoUpdate: boolean;
|
|
138
|
+
/** Ready-action handovers filed -- only when the machine genuinely cannot act. */
|
|
139
|
+
handoversToOperator: number;
|
|
140
|
+
escalationsResolved: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* One propagation-staleness sensor tick. Computes the global daemon-vs-registry
|
|
144
|
+
* differential once (the running daemon has a single version). When the gap is
|
|
145
|
+
* beyond threshold the sensor DEFERS to the auto-update controller if that closer
|
|
146
|
+
* is active, and hands a human a ready action ONLY when it is not. Any handover
|
|
147
|
+
* is anchored to the first configured product for inbox visibility (the fact is
|
|
148
|
+
* process-global; all products share one org).
|
|
149
|
+
*
|
|
150
|
+
* Every path emits a trace so an absent signal means "measured and in sync".
|
|
151
|
+
*/
|
|
152
|
+
export declare function runStalenessSensorTick(config: DaemonConfig, deps?: StalenessSensorDeps): Promise<StalenessSensorTickCounts>;
|
|
153
|
+
//# sourceMappingURL=staleness-sensor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness-sensor.d.ts","sourceRoot":"","sources":["../src/staleness-sensor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAa/C;;;GAGG;AACH,eAAO,MAAM,iCAAiC,sBAAsB,CAAC;AAErE,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,wGAAwG;IACxG,eAAe,EAAE,OAAO,CAAC;CAC1B;AAcD;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,cAAc,GAAE,MAA0C,GACzD,qBAAqB,GAAG,IAAI,CAO9B;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,qBAAqB,GAAG,IAAI,EAClC,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,OAAO,GACvB,eAAe,CAcjB;AAgHD,oFAAoF;AACpF,MAAM,WAAW,mBAAmB;IAClC,kBAAkB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACxC,mBAAmB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,0BAA0B,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,+EAA+E;IAC/E,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAC5B,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,qBAAqB,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC;KACtB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,2BAA2B,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACpD;AAYD,MAAM,WAAW,yBAAyB;IACxC,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kFAAkF;IAClF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,YAAY,EACpB,IAAI,GAAE,mBAAiC,GACtC,OAAO,CAAC,yBAAyB,CAAC,CAyFpC"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propagation-staleness sensor (focus: "Propagation Staleness Is Invisible").
|
|
3
|
+
*
|
|
4
|
+
* The differential instrument this focus is named for: it computes
|
|
5
|
+
* newest-available MINUS actually-running for a tracked target. Its first (and
|
|
6
|
+
* directly observable) target is the running daemon vs the Gitea npm registry:
|
|
7
|
+
*
|
|
8
|
+
* running = ~/.telora/daemon.meta.json .version (this daemon's own build)
|
|
9
|
+
* newest = the warm version cache .latestVersion (Gitea registry dist-tags.latest,
|
|
10
|
+
* kept fresh by startVersionCacheRefreshLoop)
|
|
11
|
+
*
|
|
12
|
+
* CLOSING the gap, not reporting it. The daemon-version gap is machine-closable:
|
|
13
|
+
* the safe-seam auto-update controller (auto-update.ts) already installs a newer
|
|
14
|
+
* registry version at the next batch-safe idle seam. So when the gap is beyond
|
|
15
|
+
* threshold this sensor DEFERS to that closer -- it does NOT tell a human "the
|
|
16
|
+
* daemon is stale, restart it". Telling a human about a gap the machine is
|
|
17
|
+
* already closing converts machine signal into human chore, and firing on a
|
|
18
|
+
* healthy daemon that is merely deferring to its next safe seam is exactly the
|
|
19
|
+
* failure mode this focus exists to remove.
|
|
20
|
+
*
|
|
21
|
+
* A human is involved ONLY where the machine genuinely cannot act: auto-update
|
|
22
|
+
* is disabled for this daemon (installMode=npx, or --no-auto-update /
|
|
23
|
+
* TELORA_AUTO_UPDATE=0, reflected as autoUpdateEnabled=false in daemon.meta.json).
|
|
24
|
+
* The operator opted out of automation, so the machine cannot close the gap --
|
|
25
|
+
* and even then the deliverable is a READY ACTION handed over (the exact
|
|
26
|
+
* `npm install -g` command + restart), never an inbox item that merely says a
|
|
27
|
+
* gap exists. That handover auto-resolves once the running version catches up,
|
|
28
|
+
* and is retired immediately if auto-update is re-enabled (the machine reclaims
|
|
29
|
+
* closure).
|
|
30
|
+
*
|
|
31
|
+
* Every tick leaves a trace (delegated-to-auto-update / handed-over /
|
|
32
|
+
* back-in-sync / "measured, within threshold" / "UNMEASURED"), so an ABSENT
|
|
33
|
+
* trace positively means "measured and in sync" -- never "not measured". Wedged
|
|
34
|
+
* auto-update (enabled but not running) is made visible by the SEPARATE
|
|
35
|
+
* auto-update decision heartbeat (auto-update.ts): an absent [auto-update] trace
|
|
36
|
+
* identifies a controller that is not running. That is not re-derived here.
|
|
37
|
+
*
|
|
38
|
+
* Pure decision (computeDaemonVersionDifferential / decideStalenessAction) +
|
|
39
|
+
* injected IO, mirroring ci-sensor-loop.ts, so the loop is unit-testable without
|
|
40
|
+
* a live registry or DB. Registered in LOOP_REGISTRY under the opt-out guard
|
|
41
|
+
* TELORA_STALENESS_SENSOR_LOOP.
|
|
42
|
+
*
|
|
43
|
+
* The two infra-owned targets observed 2026-07-24 (npmjs mirror serving a stale
|
|
44
|
+
* version; Opus 5 seed merged-but-maybe-not-applied) are NOT computable from
|
|
45
|
+
* this repo (no prod DB access; infra alone publishes to npmjs). They are
|
|
46
|
+
* recorded, with their operator-facing close action, in
|
|
47
|
+
* docs/runbook-propagation-staleness-targets.md -- the sensor deliberately does
|
|
48
|
+
* NOT attempt those infra actions.
|
|
49
|
+
*
|
|
50
|
+
* @module staleness-sensor
|
|
51
|
+
*/
|
|
52
|
+
import { configForProduct } from './config.js';
|
|
53
|
+
import { readFreshVersionCache } from './staleness.js';
|
|
54
|
+
import { readDaemonMeta } from './daemon-process.js';
|
|
55
|
+
import { isNewerVersion, parseVersionCore } from './version-check.js';
|
|
56
|
+
import { createEscalation, markEscalationResolved } from './queries/issues.js';
|
|
57
|
+
import { callApi } from './queries/shared.js';
|
|
58
|
+
import { ESCALATION_REASONS, ESCALATION_DISPOSITIONS } from '@telora/daemon-core';
|
|
59
|
+
import { createLogger } from './log.js';
|
|
60
|
+
const log = createLogger({ module: 'staleness-sensor' });
|
|
61
|
+
/**
|
|
62
|
+
* escalation_kind for a stale daemon that the machine CANNOT auto-close (auto-update
|
|
63
|
+
* disabled). Carries a ready action, not a bare "gap exists" notice.
|
|
64
|
+
*/
|
|
65
|
+
export const PROPAGATION_STALE_ESCALATION_KIND = 'propagation_stale';
|
|
66
|
+
/** Stable target id for the daemon-vs-registry differential. */
|
|
67
|
+
export const DAEMON_VERSION_TARGET = 'daemon-version';
|
|
68
|
+
/**
|
|
69
|
+
* Default patch-version distance that trips the signal. Any minor/major gap
|
|
70
|
+
* always trips regardless. A 1-2 patch gap is left quiet: auto-update closes it
|
|
71
|
+
* at the next idle seam, so signaling immediately would be noise. The observed
|
|
72
|
+
* failure (0.20.21 vs 0.20.28 = 7 patches) is well past this floor.
|
|
73
|
+
*/
|
|
74
|
+
export const DEFAULT_STALENESS_PATCH_THRESHOLD = 3;
|
|
75
|
+
/** Component-wise (newest - running), clamped at 0 per component. */
|
|
76
|
+
function versionDistance(running, newest) {
|
|
77
|
+
const r = parseVersionCore(running);
|
|
78
|
+
const n = parseVersionCore(newest);
|
|
79
|
+
if (!r || !n)
|
|
80
|
+
return { major: 0, minor: 0, patch: 0 };
|
|
81
|
+
return {
|
|
82
|
+
major: Math.max(0, n[0] - r[0]),
|
|
83
|
+
minor: Math.max(0, n[1] - r[1]),
|
|
84
|
+
patch: Math.max(0, n[2] - r[2]),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compute the daemon-vs-registry differential. Returns null when it cannot be
|
|
89
|
+
* MEASURED (either version missing) -- the caller must then emit an explicit
|
|
90
|
+
* "UNMEASURED" trace rather than staying silent, so silence always means "in
|
|
91
|
+
* sync", never "not measured".
|
|
92
|
+
*/
|
|
93
|
+
export function computeDaemonVersionDifferential(running, newest, patchThreshold = DEFAULT_STALENESS_PATCH_THRESHOLD) {
|
|
94
|
+
if (!running || !newest)
|
|
95
|
+
return null;
|
|
96
|
+
const behind = isNewerVersion(newest, running);
|
|
97
|
+
const distance = versionDistance(running, newest);
|
|
98
|
+
const beyondThreshold = behind && (distance.major > 0 || distance.minor > 0 || distance.patch >= patchThreshold);
|
|
99
|
+
return { target: DAEMON_VERSION_TARGET, running, newest, behind, distance, beyondThreshold };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Pure decision. The pivot is `canMachineClose`: when the auto-update controller
|
|
103
|
+
* owns closing the daemon-version gap, the sensor NEVER hands a human a report --
|
|
104
|
+
* it defers (and retires any stale handover). A human is handed a ready action
|
|
105
|
+
* ONLY when the machine genuinely cannot act. A null differential (unmeasurable)
|
|
106
|
+
* never acts -- it is handled as a trace by the tick.
|
|
107
|
+
*/
|
|
108
|
+
export function decideStalenessAction(diff, hasOpen, canMachineClose) {
|
|
109
|
+
if (!diff)
|
|
110
|
+
return 'none';
|
|
111
|
+
if (diff.beyondThreshold) {
|
|
112
|
+
if (canMachineClose) {
|
|
113
|
+
// Auto-update closes this at the next safe seam. Defer to it. If a stale
|
|
114
|
+
// handover from a prior disabled period is still open, retire it -- the
|
|
115
|
+
// machine has reclaimed closure.
|
|
116
|
+
return hasOpen ? 'resolve' : 'delegate';
|
|
117
|
+
}
|
|
118
|
+
// Machine cannot act (auto-update off / npx). Hand over a ready action once.
|
|
119
|
+
return hasOpen ? 'none' : 'hand-over';
|
|
120
|
+
}
|
|
121
|
+
// Within threshold / in sync: retire any open handover, else stay quiet.
|
|
122
|
+
return hasOpen ? 'resolve' : 'none';
|
|
123
|
+
}
|
|
124
|
+
function formatDistance(d) {
|
|
125
|
+
return `${d.major}.${d.minor}.${d.patch}`;
|
|
126
|
+
}
|
|
127
|
+
/** The exact operator command that closes the gap when the machine cannot. */
|
|
128
|
+
function readyUpdateCommand(newest) {
|
|
129
|
+
return `npm install -g @telora/daemon@${newest} # then restart the daemon`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Whether the auto-update controller can close the daemon-version gap itself.
|
|
133
|
+
* Mirrors auto-update.ts's own disable conditions: npx-cache installs never
|
|
134
|
+
* update, and --no-auto-update / TELORA_AUTO_UPDATE=0 (surfaced as
|
|
135
|
+
* autoUpdateEnabled=false in daemon.meta.json) opt the operator out.
|
|
136
|
+
*
|
|
137
|
+
* Defaults to true (the closer is opt-out and runs by default) when meta is
|
|
138
|
+
* absent or the field is unstamped, so an unknown state never manufactures a
|
|
139
|
+
* spurious human handover.
|
|
140
|
+
*/
|
|
141
|
+
function defaultCanMachineCloseGap() {
|
|
142
|
+
const meta = readDaemonMeta();
|
|
143
|
+
if (!meta)
|
|
144
|
+
return true;
|
|
145
|
+
if (meta.installMode === 'npx')
|
|
146
|
+
return false;
|
|
147
|
+
return meta.autoUpdateEnabled !== false;
|
|
148
|
+
}
|
|
149
|
+
const OPEN_STATUSES = new Set(['pending', 'in_review']);
|
|
150
|
+
function isOpenPropagationStale(e) {
|
|
151
|
+
if (e.status && !OPEN_STATUSES.has(e.status))
|
|
152
|
+
return false;
|
|
153
|
+
return e.escalationKind === PROPAGATION_STALE_ESCALATION_KIND;
|
|
154
|
+
}
|
|
155
|
+
async function defaultHasOpenStalenessEscalation() {
|
|
156
|
+
const result = await callApi('escalation_list', {
|
|
157
|
+
fields: { statuses: ['pending', 'in_review'] },
|
|
158
|
+
limit: 500,
|
|
159
|
+
});
|
|
160
|
+
return (result.escalations ?? []).some(isOpenPropagationStale);
|
|
161
|
+
}
|
|
162
|
+
async function defaultResolveStalenessEscalations() {
|
|
163
|
+
const result = await callApi('escalation_list', {
|
|
164
|
+
fields: { statuses: ['pending', 'in_review'] },
|
|
165
|
+
limit: 500,
|
|
166
|
+
});
|
|
167
|
+
const open = (result.escalations ?? []).filter(isOpenPropagationStale);
|
|
168
|
+
let resolved = 0;
|
|
169
|
+
for (const e of open) {
|
|
170
|
+
try {
|
|
171
|
+
await markEscalationResolved(e.id, 'Auto-resolved by the daemon: the machine is closing the daemon-version gap ' +
|
|
172
|
+
'(back in sync, or auto-update re-enabled) -- no operator action needed.');
|
|
173
|
+
resolved++;
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
log.warn(`Failed to resolve propagation_stale escalation ${e.id}: ${err.message}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return resolved;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Hand a human a READY ACTION (not a gap report) for a stale daemon the machine
|
|
183
|
+
* cannot auto-close. The description leads with the exact command to run; the
|
|
184
|
+
* escalation exists to carry the action, not to announce that a gap exists.
|
|
185
|
+
*/
|
|
186
|
+
async function defaultHandOverReadyAction(params) {
|
|
187
|
+
const { diff, readyCommand } = params;
|
|
188
|
+
await createEscalation({
|
|
189
|
+
organizationId: params.organizationId,
|
|
190
|
+
issueId: null,
|
|
191
|
+
reasonType: ESCALATION_REASONS.ERROR_ENCOUNTERED,
|
|
192
|
+
disposition: ESCALATION_DISPOSITIONS.NEEDS_OPERATOR,
|
|
193
|
+
productId: params.productId,
|
|
194
|
+
escalationKind: PROPAGATION_STALE_ESCALATION_KIND,
|
|
195
|
+
description: `Ready action -- update this daemon:\n\n ${readyCommand}\n\n` +
|
|
196
|
+
`Auto-update is disabled on this daemon (running from an npx cache, or ` +
|
|
197
|
+
`--no-auto-update / TELORA_AUTO_UPDATE=0), so the machine cannot close the ` +
|
|
198
|
+
`daemon-version gap itself: running v${diff.running} while the Gitea registry ` +
|
|
199
|
+
`serves v${diff.newest} (behind by ${formatDistance(diff.distance)}). Running the ` +
|
|
200
|
+
`command above closes it. This resolves automatically once the running version ` +
|
|
201
|
+
`catches up, or if auto-update is re-enabled.`,
|
|
202
|
+
metadata: {
|
|
203
|
+
target: diff.target,
|
|
204
|
+
running_version: diff.running,
|
|
205
|
+
newest_version: diff.newest,
|
|
206
|
+
distance: diff.distance,
|
|
207
|
+
ready_command: readyCommand,
|
|
208
|
+
reason: 'auto_update_disabled',
|
|
209
|
+
product_id: params.productId,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const defaultDeps = {
|
|
214
|
+
readRunningVersion: () => readDaemonMeta()?.version ?? null,
|
|
215
|
+
readNewestAvailable: () => readFreshVersionCache()?.latestVersion ?? null,
|
|
216
|
+
patchThreshold: DEFAULT_STALENESS_PATCH_THRESHOLD,
|
|
217
|
+
canMachineCloseGap: defaultCanMachineCloseGap,
|
|
218
|
+
hasOpenStalenessEscalation: defaultHasOpenStalenessEscalation,
|
|
219
|
+
handOverReadyAction: defaultHandOverReadyAction,
|
|
220
|
+
resolveStalenessEscalations: defaultResolveStalenessEscalations,
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* One propagation-staleness sensor tick. Computes the global daemon-vs-registry
|
|
224
|
+
* differential once (the running daemon has a single version). When the gap is
|
|
225
|
+
* beyond threshold the sensor DEFERS to the auto-update controller if that closer
|
|
226
|
+
* is active, and hands a human a ready action ONLY when it is not. Any handover
|
|
227
|
+
* is anchored to the first configured product for inbox visibility (the fact is
|
|
228
|
+
* process-global; all products share one org).
|
|
229
|
+
*
|
|
230
|
+
* Every path emits a trace so an absent signal means "measured and in sync".
|
|
231
|
+
*/
|
|
232
|
+
export async function runStalenessSensorTick(config, deps = defaultDeps) {
|
|
233
|
+
const counts = {
|
|
234
|
+
measured: false,
|
|
235
|
+
behind: false,
|
|
236
|
+
delegatedToAutoUpdate: false,
|
|
237
|
+
handoversToOperator: 0,
|
|
238
|
+
escalationsResolved: 0,
|
|
239
|
+
};
|
|
240
|
+
try {
|
|
241
|
+
const running = deps.readRunningVersion();
|
|
242
|
+
const newest = deps.readNewestAvailable();
|
|
243
|
+
const diff = computeDaemonVersionDifferential(running, newest, deps.patchThreshold);
|
|
244
|
+
if (!diff) {
|
|
245
|
+
// Not measurable this tick -- must NOT be silent (silence means in-sync).
|
|
246
|
+
log.warn(`[staleness] daemon-version differential UNMEASURED ` +
|
|
247
|
+
`(running=${running ?? 'unknown'}, newest=${newest ?? 'unknown'}); ` +
|
|
248
|
+
`cannot compute the propagation gap -- the version cache may not be warm yet.`);
|
|
249
|
+
return counts;
|
|
250
|
+
}
|
|
251
|
+
counts.measured = true;
|
|
252
|
+
counts.behind = diff.behind;
|
|
253
|
+
const anchor = config.products[0];
|
|
254
|
+
if (!anchor) {
|
|
255
|
+
log.info(`[staleness] measured: running v${diff.running} vs newest v${diff.newest} ` +
|
|
256
|
+
`(${diff.behind ? `behind ${formatDistance(diff.distance)}` : 'in sync'}); ` +
|
|
257
|
+
`no product configured to anchor a handover.`);
|
|
258
|
+
return counts;
|
|
259
|
+
}
|
|
260
|
+
const pc = configForProduct(config, anchor);
|
|
261
|
+
const canMachineClose = deps.canMachineCloseGap();
|
|
262
|
+
const hasOpen = await deps.hasOpenStalenessEscalation();
|
|
263
|
+
const action = decideStalenessAction(diff, hasOpen, canMachineClose);
|
|
264
|
+
if (diff.beyondThreshold && canMachineClose) {
|
|
265
|
+
counts.delegatedToAutoUpdate = true;
|
|
266
|
+
}
|
|
267
|
+
if (action === 'hand-over') {
|
|
268
|
+
const readyCommand = readyUpdateCommand(diff.newest);
|
|
269
|
+
await deps.handOverReadyAction({
|
|
270
|
+
organizationId: pc.organizationId,
|
|
271
|
+
productId: pc.productId,
|
|
272
|
+
diff,
|
|
273
|
+
readyCommand,
|
|
274
|
+
});
|
|
275
|
+
counts.handoversToOperator++;
|
|
276
|
+
log.warn(`[staleness] daemon behind registry (running v${diff.running} < newest v${diff.newest}, ` +
|
|
277
|
+
`behind ${formatDistance(diff.distance)}) and auto-update is DISABLED -- the machine ` +
|
|
278
|
+
`cannot close it. Handed over ready action: ${readyCommand}`);
|
|
279
|
+
}
|
|
280
|
+
else if (action === 'delegate') {
|
|
281
|
+
log.info(`[staleness] daemon behind registry (running v${diff.running} < newest v${diff.newest}, ` +
|
|
282
|
+
`behind ${formatDistance(diff.distance)}); auto-update owns closure at the next safe ` +
|
|
283
|
+
`seam -- deferring, no operator action.`);
|
|
284
|
+
}
|
|
285
|
+
else if (action === 'resolve') {
|
|
286
|
+
counts.escalationsResolved += await deps.resolveStalenessEscalations();
|
|
287
|
+
log.info(diff.beyondThreshold
|
|
288
|
+
? `[staleness] auto-update re-enabled while behind (v${diff.running}); the machine now ` +
|
|
289
|
+
`owns closure -- retired the operator handover.`
|
|
290
|
+
: `[staleness] daemon back in sync with registry (v${diff.running}); ` +
|
|
291
|
+
`retired the operator handover.`);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
// Positive in-sync (or within-threshold) trace: silence must never mean
|
|
295
|
+
// "not measured". This is the heartbeat that makes an absent signal
|
|
296
|
+
// diagnostic.
|
|
297
|
+
log.info(`[staleness] measured: running v${diff.running} vs newest v${diff.newest} -- ` +
|
|
298
|
+
(diff.behind
|
|
299
|
+
? `behind by ${formatDistance(diff.distance)} (within threshold).`
|
|
300
|
+
: 'in sync.'));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
log.warn(`[staleness] tick failed: ${err.message}`);
|
|
305
|
+
}
|
|
306
|
+
return counts;
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=staleness-sensor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staleness-sensor.js","sourceRoot":"","sources":["../src/staleness-sensor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAGzD;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,mBAAmB,CAAC;AAErE,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBA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AqB;oBACtF,gDAAgD;gBAClD,CAAC,CAAC,mDAAmD,IAAI,CAAC,OAAO,KAAK;oBACpE,gCAAgC,CACrC,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,wEAAwE;YACxE,oEAAoE;YACpE,cAAc;YACd,GAAG,CAAC,IAAI,CACN,kCAAkC,IAAI,CAAC,OAAO,eAAe,IAAI,CAAC,MAAM,MAAM;gBAC5E,CAAC,IAAI,CAAC,MAAM;oBACV,CAAC,CAAC,aAAa,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB;oBAClE,CAAC,CAAC,UAAU,CAAC,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,4BAA6B,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types/focus.d.ts
CHANGED
|
@@ -61,6 +61,15 @@ export interface FocusWorktreeInfo {
|
|
|
61
61
|
branchName: string;
|
|
62
62
|
/** When the worktree was created. */
|
|
63
63
|
createdAt: Date;
|
|
64
|
+
/**
|
|
65
|
+
* Product that owns this worktree. The worktree map spans all products a
|
|
66
|
+
* multi-product daemon manages; consumers MUST scope by this id (and resolve
|
|
67
|
+
* git operations against `repoPath`) rather than the root config, which
|
|
68
|
+
* always mirrors products[0].
|
|
69
|
+
*/
|
|
70
|
+
productId: string;
|
|
71
|
+
/** Repository the worktree's branch lives in (the owning product's repoPath). */
|
|
72
|
+
repoPath: string;
|
|
64
73
|
}
|
|
65
74
|
/**
|
|
66
75
|
* Execution configuration for a focus team.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/types/focus.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAA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AAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
|
package/dist/types/session.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent session and role types.
|
|
3
3
|
*/
|
|
4
|
-
import type { Writable } from 'node:stream';
|
|
5
4
|
import type { WriteStream } from 'node:fs';
|
|
6
|
-
import type { AgentEventParser } from '@telora/daemon-core';
|
|
7
|
-
import type { Workflow } from './workflow.js';
|
|
8
5
|
export type AgentSessionStatus = 'starting' | 'running' | 'completed' | 'failed' | 'cancelled' | 'stopped' | 'escalated';
|
|
9
6
|
export type ExitCategory = 'error' | 'recovery_cleanup' | 'timeout' | 'user_stopped' | 'governor_denied' | 'internal' | 'work_complete' | 'deactivated' | 'handoff' | 'teardown';
|
|
10
7
|
/**
|
|
@@ -73,47 +70,6 @@ export interface AgentSessionPass {
|
|
|
73
70
|
files_modified: string[];
|
|
74
71
|
claude_session_id: string | null;
|
|
75
72
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Running agent process info
|
|
78
|
-
*/
|
|
79
|
-
export interface RunningAgent {
|
|
80
|
-
sessionId: string;
|
|
81
|
-
roleId: string;
|
|
82
|
-
roleName: string;
|
|
83
|
-
focusId: string;
|
|
84
|
-
deliveryId: string;
|
|
85
|
-
deliveryName: string;
|
|
86
|
-
/** Resolved workflow for this delivery (cached for session lifetime). */
|
|
87
|
-
workflow: Workflow;
|
|
88
|
-
branchName: string;
|
|
89
|
-
worktreePath: string;
|
|
90
|
-
/** Product repo path — used for worktree cleanup so multi-product agents clean up in the correct repo. */
|
|
91
|
-
repoPath: string;
|
|
92
|
-
pid: number;
|
|
93
|
-
startedAt: Date;
|
|
94
|
-
stdoutPath: string;
|
|
95
|
-
stderrPath: string;
|
|
96
|
-
/** Timer handle for the timeout kill. */
|
|
97
|
-
timeoutTimer?: ReturnType<typeof setTimeout>;
|
|
98
|
-
/** Timer handle for the 80% warning. */
|
|
99
|
-
warningTimer?: ReturnType<typeof setTimeout>;
|
|
100
|
-
/** Whether Agent Teams (in-process teammates) are enabled. */
|
|
101
|
-
enableTeams: boolean;
|
|
102
|
-
/** Reference to the process stdin stream. */
|
|
103
|
-
stdin: Writable;
|
|
104
|
-
/** Provider-neutral agent event parser instance. */
|
|
105
|
-
streamParser: AgentEventParser;
|
|
106
|
-
/** Engine session ID from stream output (for resume support). */
|
|
107
|
-
claudeSessionId?: string;
|
|
108
|
-
/** Current stream state for status reporting. */
|
|
109
|
-
streamState: 'starting' | 'active' | 'idle' | 'shutting_down';
|
|
110
|
-
/** Timestamp of last activity from the stream parser. */
|
|
111
|
-
lastActivityAt?: Date;
|
|
112
|
-
/** Number of active teammates (Agent Teams). */
|
|
113
|
-
activeTeammateCount?: number;
|
|
114
|
-
/** Names of active teammates for status reporting. */
|
|
115
|
-
activeTeammates?: string[];
|
|
116
|
-
}
|
|
117
73
|
/**
|
|
118
74
|
* Event payload for session status changes
|
|
119
75
|
*/
|