Port stability remediation from installed dist into source#2
Port stability remediation from installed dist into source#2yashwant86 wants to merge 1 commit intomainfrom
Conversation
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
Telegram Operational Health & Stabilityextensions/telegram/src/channel.ts, status-issues.ts, polling-session.ts, polling-session.test.ts |
Adds operational truth inspection for Telegram delivery, transport, route integrity, and session store state. Suppresses polling watchdog false restarts when gateway work is active. Reports health degradation when transport is reachable but delivery truth is unknown. |
Unified Session Route Resolversrc/routing/resolve-route.tssrc/routing/resolve-route.test.tssrc/config/sessions/session-key.tssrc/cron/isolated-agent/session-key.tssrc/gateway/http-utils.tssrc/tui/tui.tssrc/tui/tui-session-actions.ts |
Introduces resolveSessionRoute() with provenance tracking (provider, accountId, chatType, actor fingerprint) across all surfaces. Replaces legacy toAgentStoreSessionKey and canonicalizeMainSessionAlias calls. Normalizes scope, surface, and explicit routing flags for audit and diagnostics. |
Session Store Route Metadata & Self-Healingsrc/config/sessions/store-load.ts, types.ts, store.session-key-normalization.test.ts |
Adds route metadata and integrity state to session entries during load. Self-heals legacy heartbeat-main contradictions by removing Telegram origin from main sessions and normalizing surface to heartbeat. Derives route scope, surface, and actor fingerprint from session key and origin. |
Health Snapshot & Operational Issuessrc/commands/health.tssrc/commands/health.types.tssrc/commands/health.command.coverage.test.tssrc/commands/health.test.tssrc/plugin-sdk/status-helpers.tssrc/channels/plugins/types.core.ts |
Extends health snapshot with delivery truth, transport truth, route integrity, and session store integrity. Collects operational health issues (delivery unknown, route contradictory, mixed artifacts, degraded state). Reports health state as degraded when issues detected. |
Session Store Backup & Archive Pathssrc/config/sessions/store-maintenance.tssrc/config/sessions/store.tssrc/gateway/session-transcript-files.fs.ts |
Moves session store backups and transcript archives to dedicated artifact directories (agents/*/artifacts/session-store and session-transcripts) instead of inline .bak files. Adds resolveSessionMaintenanceRoot, resolveSessionStoreBackupDir, resolveSessionTranscriptArchiveDir helpers. |
Session Write Lock v2 Formatsrc/agents/session-write-lock.ts, session-write-lock.test.ts |
Upgrades lock file format to v2 with owner metadata (pid, hostname, cwd, starttime), lease tracking (leaseId, expiresAt, maxHoldMs), and canonical paths. Maintains backward compatibility by reading legacy pid field from root or owner object. |
Sent Message Cache Migrationextensions/telegram/src/sent-message-cache.ts, send.test-harness.ts |
Migrates sent-message cache from legacy store path to state directory (resolveStateDir/telegram/sent-messages.json). Automatically migrates existing cache via rename or copy+delete on cross-device filesystems. |
Overflow Compaction Token Synthesissrc/agents/pi-embedded-runner/run.ts, run.overflow-compaction.test.ts |
Synthesizes token counts for overflow compaction when providers omit observed overflow totals. Tracks token count source (observed vs synthetic) and forces recovery compaction when in-attempt compaction persists without observed count. |
Heartbeat Runner Session Resolutionsrc/infra/heartbeat-runner.ts |
Refactors heartbeat session resolution to use unified resolveBaseSessionKey helper. Simplifies logic by removing legacy toAgentStoreSessionKey and canonicalizeMainSessionAlias calls. |
Gateway Health Runtime Snapshotsrc/gateway/server.impl.tssrc/gateway/server/health-state.tssrc/gateway/server-methods/health.ts |
Passes runtime snapshot (channel accounts and their state) to health snapshot builder. Allows health checks to access live channel runtime state for operational truth inspection. |
Status Display & Formattingsrc/commands/channels/status.tssrc/commands/status.command-sections.tssrc/terminal/health-style.tssrc/tui/tui-event-handlers.test.tssrc/tui/tui-session-actions.test.ts |
Displays transport truth, delivery truth, route integrity, and session store integrity in status output. Adds degraded state styling. Updates test fixtures to use canonical main session key format (main instead of agent:main:main). |
Plugin SDK Exportssrc/plugin-sdk/gateway-runtime.ts, routing.ts |
Exports resolveSessionRoute, ResolvedSessionRoute, and gateway runtime helpers (getActiveEmbeddedRunCount, getActiveTaskCount, getTotalQueueSize) for plugin use. |
Sequence Diagram
sequenceDiagram
participant User
participant HealthCmd as Health Command
participant Inspector as Telegram Inspector
participant SessionStore as Session Store
participant HealthBuilder as Health Builder
participant Router as Route Resolver
User->>HealthCmd: Request health snapshot
HealthCmd->>Inspector: inspectTelegramOperationalStoreTruth()
Inspector->>SessionStore: Scan agents/*/sessions directories
Inspector->>SessionStore: Read sessions.json, check route integrity
Inspector-->>HealthCmd: Return routeIntegrity, sessionStoreIntegrity, contradictions
HealthCmd->>HealthBuilder: buildChannelAccountSnapshot()
HealthBuilder->>Router: resolveSessionRoute() for each session
Router-->>HealthBuilder: Return scope, surface, provenance, actorFingerprint
HealthBuilder-->>HealthCmd: Return snapshot with route metadata
HealthCmd->>HealthCmd: resolveOperationalHealthIssues()
alt Delivery unknown
HealthCmd->>HealthCmd: Add delivery_truth_unknown issue
end
alt Route contradictory
HealthCmd->>HealthCmd: Add route_integrity_contradictory issue
end
alt Mixed artifacts
HealthCmd->>HealthCmd: Add session_store_mixed_artifacts issue
end
HealthCmd-->>User: Return health summary with state=degraded if issues
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
| continue; | ||
| } | ||
| for (const dirEntry of dirEntries) { | ||
| if (dirEntry.isDirectory() || isTelegramSessionArtifactNoise(dirEntry.name)) { |
There was a problem hiding this comment.
OR condition counts every subdirectory as artifact noise
The condition dirEntry.isDirectory() || isTelegramSessionArtifactNoise(dirEntry.name) increments artifactNoise for all directories under sessions/, not just noise-named ones. Legitimate directories like artifacts/ (created by store-maintenance.ts) are counted as noise, inflating the counter and causing sessionStoreIntegrity to flip to "mixed-artifacts", which in turn triggers a session_store_mixed_artifacts health issue and makes the health snapshot report ok: false. The intent was likely to skip directories and only count noise-named files — change to if (!dirEntry.isFile()) continue; before the noise check, or use && !dirEntry.isDirectory() so only noise-named files are counted.
Split the condition: skip directories with continue, then check noise only for files:
for (const dirEntry of dirEntries) {
if (dirEntry.isDirectory()) continue;
if (isTelegramSessionArtifactNoise(dirEntry.name)) {
result.artifactNoise += 1;
}
}
Actionable Comments Posted: 1🧾 Coverage Summary✔️ Covered (41 files) |
|
/review --force |
Mirror of openclaw#67350
Summary by MergeMonkey