Files
sencho/docs/docs.json
T
Anso 5bb4b01953 feat: auto-heal policies for unhealthy containers (#671)
* feat(db): add auto_heal_policies and auto_heal_history schema and CRUD

Adds two new SQLite tables (auto_heal_policies, auto_heal_history) to
DatabaseService.initSchema() and exposes CRUD methods: getAutoHealPolicies,
getAutoHealPolicy, addAutoHealPolicy, updateAutoHealPolicy,
deleteAutoHealPolicy, recordAutoHealHistory, getAutoHealHistory,
incrementConsecutiveFailures, resetConsecutiveFailures, setPolicyEnabled.
Also adds AutoHealPolicy and AutoHealHistoryEntry TypeScript interfaces.

* feat(events): track health-status duration and expose state accessors

- Add healthStatus and unhealthySince fields to InternalContainerState
- onHealthStatus now records unhealthySince timestamp on first transition
  to unhealthy, and clears it when the container recovers or restarts
- onStart resets both fields so a restarted container begins from 'starting'
- Add listContainerStates() and getContainerState() public accessors for
  use by the upcoming AutoHealService evaluator

* fix(auto-heal): key allowlist in updateAutoHealPolicy, cascade delete, extract ContainerHealthSnapshot

* feat: add AutoHealService evaluator singleton

Polls every 30 s, matches containers to enabled policies via Compose
labels, and restarts containers that have been unhealthy beyond the
configured threshold. Enforces cooldown, per-hour rate cap, and
recent-user-action suppression; auto-disables policies after repeated
consecutive failures. Also adds DockerEventManager.getService() accessor
required by the evaluator.

* fix(auto-heal): prune stale restartTimestamps, guard undefined policy id

- Prune restartTimestamps entries for containers no longer running after
  each container list fetch, preventing unbounded map growth from dead
  container IDs.
- Guard against policies with undefined id at the start of the per-policy
  loop; warn and skip rather than proceed with a non-null assertion.
- Extract handleAutoDisable private helper to bring executeHeal under 30
  lines and isolate the auto-disable side-effect sequence.
- Move ContainerInfo type to module scope.

* feat: add auto-heal API routes and wire AutoHealService lifecycle

Registers five REST endpoints under /api/auto-heal/policies (list, create,
patch, delete, history) with requirePaid + requireAdmin guards and Zod
validation. Wires AutoHealService.start()/stop() into the server startup
and graceful-shutdown blocks alongside MonitorService.

* test: add AutoHealService and DatabaseService auto-heal unit tests

- 15 unit tests for AutoHealService.shouldHeal covering all decision branches
  (healthy state, duration threshold, user-action suppression, cooldown,
  rate limiting, and correct skipReason values)
- 13 integration tests for DatabaseService auto-heal CRUD: policy round-trip,
  stack-name filter, partial update, cascade delete, history ordering/limit,
  consecutive failure counters, and setPolicyEnabled toggle

* fix: log AutoHealService shutdown errors consistently

* fix(api): requireAdmin-first guard order and try/catch on auto-heal routes

* feat(ui): add StackAutoHealSheet component

* feat(ui): add Auto-Heal context menu item to EditorLayout

* fix(ui): StackAutoHealSheet label, token, a11y, and useEffect fixes

- Rename 'All services in stack' to 'All services' in combobox options and placeholder
- Replace text-green-600 with text-success design token in actionColorClass
- Add htmlFor/id pairs to all four numeric form inputs for accessibility
- Inline fetch logic into useEffect, removing stale closure risk and eslint-disable comment
- Remove now-unused fetchPolicies and fetchServices standalone functions
- Update 'Auto-disable after' label to 'Auto-disable after (failures)' for clarity
- Add toast.error in policy fetch failure path; services fetch silently skips as before

* docs: add auto-heal-policies feature documentation

* test(e2e): add auto-heal policies CRUD spec

* fix(docs): correct auto-heal-policies nav position in docs.json
2026-04-17 22:45:06 -04:00

284 lines
8.4 KiB
JSON

{
"$schema": "https://mintlify.com/docs.json",
"theme": "mint",
"name": "Sencho",
"colors": {
"primary": "#00BEC7",
"light": "#007982",
"dark": "#00BEC7"
},
"logo": {
"light": "/images/logo/logo-light.png",
"dark": "/images/logo/logo-dark.png",
"href": "https://sencho.io"
},
"favicon": "/images/logo/favicon.ico",
"appearance": {
"default": "dark"
},
"fonts": {
"family": "Geist"
},
"background": {
"decoration": "gradient",
"color": {
"dark": "#090909"
}
},
"navbar": {
"links": [
{
"type": "github",
"href": "https://github.com/AnsoCode/Sencho"
}
],
"primary": {
"type": "button",
"label": "Get Started",
"href": "https://sencho.io/#pricing"
}
},
"footer": {
"socials": {
"github": "https://github.com/AnsoCode/Sencho"
},
"links": [
{
"header": "Product",
"items": [
{ "label": "Website", "href": "https://sencho.io" },
{ "label": "Pricing", "href": "https://sencho.io/#pricing" },
{ "label": "Changelog", "href": "https://github.com/AnsoCode/Sencho/releases" }
]
},
{
"header": "Community",
"items": [
{ "label": "GitHub", "href": "https://github.com/AnsoCode/Sencho" },
{ "label": "Contributing", "href": "https://github.com/AnsoCode/Sencho/blob/main/CONTRIBUTING.md" }
]
},
{
"header": "Legal",
"items": [
{ "label": "Terms of Service", "href": "https://sencho.io/terms" },
{ "label": "Privacy Policy", "href": "https://sencho.io/privacy" }
]
}
]
},
"api": {
"auth": {
"method": "bearer",
"name": "Authorization"
},
"playground": {
"display": "simple"
}
},
"navigation": {
"tabs": [
{
"tab": "Documentation",
"groups": [
{
"group": "Getting Started",
"pages": [
"getting-started/introduction",
"getting-started/quickstart",
"getting-started/configuration",
"getting-started/sso-quickstart"
]
},
{
"group": "Features",
"pages": [
"features/overview",
"features/dashboard",
"features/stack-management",
"features/editor",
"features/resources",
"features/app-store",
"features/global-observability",
"features/host-console",
"features/multi-node",
"features/pilot-agent",
"features/fleet-view",
"features/fleet-sync",
"features/remote-updates",
"features/stack-labels",
"features/alerts-notifications",
"features/notification-routing",
"features/webhooks",
"features/git-sources",
"features/rbac",
"features/atomic-deployments",
"features/fleet-backups",
"features/audit-log",
"features/api-tokens",
"features/private-registries",
"features/vulnerability-scanning",
"features/cve-suppressions",
"features/auto-update-policies",
"features/auto-heal-policies",
"features/scheduled-operations",
"features/sso",
"features/two-factor-authentication",
"features/licensing"
]
},
{
"group": "Reference",
"pages": [
"security",
"features/node-compatibility",
"reference/settings",
"reference/verifying-images",
"reference/contact",
"reference/security-advisories"
]
},
{
"group": "Operations",
"pages": [
"operations/troubleshooting",
"operations/backup",
"operations/upgrade",
"operations/self-hosting",
"operations/trivy-setup",
"operations/two-factor-admin"
]
}
]
},
{
"tab": "API Reference",
"openapi": "openapi.yaml",
"pages": [
"api-reference/overview",
{
"group": "Health & Meta",
"pages": [
"GET /api/health",
"GET /api/meta",
"POST /api/system/update"
]
},
{
"group": "Stacks",
"pages": [
"GET /api/stacks",
"POST /api/stacks",
"GET /api/stacks/{stackName}",
"PUT /api/stacks/{stackName}",
"DELETE /api/stacks/{stackName}",
"GET /api/stacks/{stackName}/envs",
"GET /api/stacks/{stackName}/env",
"PUT /api/stacks/{stackName}/env",
"GET /api/stacks/{stackName}/containers",
"GET /api/stacks/{stackName}/services",
"POST /api/stacks/{stackName}/deploy",
"POST /api/stacks/{stackName}/down",
"POST /api/stacks/{stackName}/start",
"POST /api/stacks/{stackName}/stop",
"POST /api/stacks/{stackName}/restart",
"POST /api/stacks/{stackName}/update",
"POST /api/stacks/{stackName}/rollback",
"GET /api/stacks/{stackName}/backup"
]
},
{
"group": "Containers",
"pages": [
"GET /api/containers",
"GET /api/containers/{id}/logs",
"POST /api/containers/{id}/start",
"POST /api/containers/{id}/stop",
"POST /api/containers/{id}/restart"
]
},
{
"group": "API Tokens",
"pages": [
"POST /api/api-tokens",
"GET /api/api-tokens",
"DELETE /api/api-tokens/{id}"
]
},
{
"group": "Webhooks",
"pages": [
"GET /api/webhooks",
"POST /api/webhooks",
"PUT /api/webhooks/{id}",
"DELETE /api/webhooks/{id}",
"GET /api/webhooks/{id}/history",
"POST /api/webhooks/{id}/trigger"
]
},
{
"group": "Nodes",
"pages": [
"GET /api/nodes",
"POST /api/nodes",
"GET /api/nodes/{id}",
"PUT /api/nodes/{id}",
"DELETE /api/nodes/{id}",
"POST /api/nodes/{id}/test",
"GET /api/nodes/{id}/meta"
]
},
{
"group": "Fleet",
"pages": [
"GET /api/fleet/overview",
"GET /api/fleet/node/{nodeId}/stacks",
"GET /api/fleet/node/{nodeId}/stacks/{stackName}/containers",
"GET /api/fleet/update-status",
"POST /api/fleet/nodes/{nodeId}/update",
"POST /api/fleet/update-all",
"POST /api/fleet/snapshots",
"GET /api/fleet/snapshots",
"GET /api/fleet/snapshots/{id}",
"POST /api/fleet/snapshots/{id}/restore",
"DELETE /api/fleet/snapshots/{id}"
]
},
{
"group": "Scheduled Tasks",
"pages": [
"GET /api/scheduled-tasks",
"POST /api/scheduled-tasks",
"GET /api/scheduled-tasks/{id}",
"PUT /api/scheduled-tasks/{id}",
"DELETE /api/scheduled-tasks/{id}",
"PATCH /api/scheduled-tasks/{id}/toggle",
"POST /api/scheduled-tasks/{id}/run",
"GET /api/scheduled-tasks/{id}/runs",
"GET /api/scheduled-tasks/{id}/runs/export"
]
},
{
"group": "Registries",
"pages": [
"GET /api/registries",
"POST /api/registries",
"PUT /api/registries/{id}",
"DELETE /api/registries/{id}",
"POST /api/registries/{id}/test"
]
},
{
"group": "Image Updates",
"pages": [
"GET /api/image-updates",
"POST /api/image-updates/refresh",
"GET /api/image-updates/status"
]
}
]
}
]
}
}