@b00dea/cockpit 0.0.0-stage → 0.1.1
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/CHANGELOG.md +474 -0
- package/LICENSE +21 -0
- package/README.md +25 -2
- package/bin/cockpit.mjs +33 -0
- package/cockpit.schema.json +2644 -0
- package/dist/autonomy.d.ts +45 -0
- package/dist/autonomy.js +173 -0
- package/dist/bounded-read.d.ts +14 -0
- package/dist/bounded-read.js +42 -0
- package/dist/browser/commands.d.ts +117 -0
- package/dist/browser/commands.js +453 -0
- package/dist/browser/package-paths.d.ts +1 -0
- package/dist/browser/package-paths.js +6 -0
- package/dist/browser/proxy.d.ts +22 -0
- package/dist/browser/proxy.js +37 -0
- package/dist/browser/runtime.d.ts +118 -0
- package/dist/browser/runtime.js +186 -0
- package/dist/browser/surfaces.d.ts +141 -0
- package/dist/browser/surfaces.js +561 -0
- package/dist/browser/ui-gate.d.ts +15 -0
- package/dist/browser/ui-gate.js +18 -0
- package/dist/canonical-json.d.ts +2 -0
- package/dist/canonical-json.js +5 -0
- package/dist/cli-guard.d.ts +5 -0
- package/dist/cli-guard.js +71 -0
- package/dist/cli-main.d.ts +176 -0
- package/dist/cli-main.js +1584 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +16 -0
- package/dist/command-table.d.ts +121 -0
- package/dist/command-table.js +664 -0
- package/dist/config/load.d.ts +183 -0
- package/dist/config/load.js +367 -0
- package/dist/config/sibling-toml.d.ts +48 -0
- package/dist/config/sibling-toml.js +160 -0
- package/dist/config/surface-tools-toml.d.ts +9 -0
- package/dist/config/surface-tools-toml.js +37 -0
- package/dist/config/unconfirmed-toml.d.ts +9 -0
- package/dist/config/unconfirmed-toml.js +29 -0
- package/dist/config/verified-write.d.ts +43 -0
- package/dist/config/verified-write.js +89 -0
- package/dist/diagnostics.d.ts +26 -0
- package/dist/diagnostics.js +344 -0
- package/dist/docs/check.d.ts +16 -0
- package/dist/docs/check.js +197 -0
- package/dist/docs/decision-record.d.ts +34 -0
- package/dist/docs/decision-record.js +135 -0
- package/dist/docs/decisions.d.ts +16 -0
- package/dist/docs/decisions.js +103 -0
- package/dist/docs/markdown.d.ts +36 -0
- package/dist/docs/markdown.js +88 -0
- package/dist/docs/references.d.ts +32 -0
- package/dist/docs/references.js +148 -0
- package/dist/emit.d.ts +22 -0
- package/dist/emit.js +43 -0
- package/dist/entrypoint-kinds.d.ts +3 -0
- package/dist/entrypoint-kinds.js +11 -0
- package/dist/environment/application/confirm.d.ts +35 -0
- package/dist/environment/application/confirm.js +122 -0
- package/dist/environment/application/destructive.d.ts +6 -0
- package/dist/environment/application/destructive.js +429 -0
- package/dist/environment/application/doctor.d.ts +94 -0
- package/dist/environment/application/doctor.js +247 -0
- package/dist/environment/application/guard.d.ts +49 -0
- package/dist/environment/application/guard.js +677 -0
- package/dist/environment/application/health.d.ts +143 -0
- package/dist/environment/application/health.js +385 -0
- package/dist/environment/application/lifecycle-context.d.ts +235 -0
- package/dist/environment/application/lifecycle-context.js +154 -0
- package/dist/environment/application/lifecycle-state.d.ts +25 -0
- package/dist/environment/application/lifecycle-state.js +202 -0
- package/dist/environment/application/lifecycle.d.ts +18 -0
- package/dist/environment/application/lifecycle.js +737 -0
- package/dist/environment/application/logs.d.ts +45 -0
- package/dist/environment/application/logs.js +127 -0
- package/dist/environment/application/services.d.ts +60 -0
- package/dist/environment/application/services.js +89 -0
- package/dist/environment/application/setup.d.ts +129 -0
- package/dist/environment/application/setup.js +741 -0
- package/dist/environment/application/shared.d.ts +11 -0
- package/dist/environment/application/shared.js +61 -0
- package/dist/environment/application/siblings.d.ts +43 -0
- package/dist/environment/application/siblings.js +269 -0
- package/dist/environment/claims.d.ts +389 -0
- package/dist/environment/claims.js +1701 -0
- package/dist/environment/codex-hook-trust.d.ts +11 -0
- package/dist/environment/codex-hook-trust.js +185 -0
- package/dist/environment/compose-environment.d.ts +1 -0
- package/dist/environment/compose-environment.js +6 -0
- package/dist/environment/compose-ownership.d.ts +21 -0
- package/dist/environment/compose-ownership.js +117 -0
- package/dist/environment/compose-topology.d.ts +125 -0
- package/dist/environment/compose-topology.js +490 -0
- package/dist/environment/contract.d.ts +522 -0
- package/dist/environment/contract.js +794 -0
- package/dist/environment/declaration.d.ts +14 -0
- package/dist/environment/declaration.js +39 -0
- package/dist/environment/destructive-composition.d.ts +29 -0
- package/dist/environment/destructive-composition.js +333 -0
- package/dist/environment/docker-daemon.d.ts +30 -0
- package/dist/environment/docker-daemon.js +78 -0
- package/dist/environment/docker-endpoint.d.ts +10 -0
- package/dist/environment/docker-endpoint.js +19 -0
- package/dist/environment/env-schema-observation.d.ts +46 -0
- package/dist/environment/env-schema-observation.js +241 -0
- package/dist/environment/evidence.d.ts +136 -0
- package/dist/environment/evidence.js +437 -0
- package/dist/environment/executable.d.ts +38 -0
- package/dist/environment/executable.js +190 -0
- package/dist/environment/generated-application/authorities.d.ts +5 -0
- package/dist/environment/generated-application/authorities.js +61 -0
- package/dist/environment/generated-application/bootstrap-skill.d.ts +16 -0
- package/dist/environment/generated-application/bootstrap-skill.js +328 -0
- package/dist/environment/generated-application/check.d.ts +13 -0
- package/dist/environment/generated-application/check.js +191 -0
- package/dist/environment/generated-application/custom-surface.d.ts +26 -0
- package/dist/environment/generated-application/custom-surface.js +289 -0
- package/dist/environment/generated-application/prepare.d.ts +29 -0
- package/dist/environment/generated-application/prepare.js +278 -0
- package/dist/environment/generated-application/publication.d.ts +33 -0
- package/dist/environment/generated-application/publication.js +547 -0
- package/dist/environment/generated-application/shared.d.ts +492 -0
- package/dist/environment/generated-application/shared.js +354 -0
- package/dist/environment/generated-application/surface-observation.d.ts +4 -0
- package/dist/environment/generated-application/surface-observation.js +69 -0
- package/dist/environment/generated-application/surface-outputs.d.ts +71 -0
- package/dist/environment/generated-application/surface-outputs.js +400 -0
- package/dist/environment/generated-application/surfaces.d.ts +3 -0
- package/dist/environment/generated-application/surfaces.js +704 -0
- package/dist/environment/generated-application/sync.d.ts +6 -0
- package/dist/environment/generated-application/sync.js +124 -0
- package/dist/environment/git-observation.d.ts +202 -0
- package/dist/environment/git-observation.js +553 -0
- package/dist/environment/health-composition.d.ts +12 -0
- package/dist/environment/health-composition.js +645 -0
- package/dist/environment/host-observation.d.ts +56 -0
- package/dist/environment/host-observation.js +52 -0
- package/dist/environment/identity.d.ts +48 -0
- package/dist/environment/identity.js +85 -0
- package/dist/environment/init-application.d.ts +333 -0
- package/dist/environment/init-application.js +726 -0
- package/dist/environment/install-policy-observation.d.ts +71 -0
- package/dist/environment/install-policy-observation.js +284 -0
- package/dist/environment/install-policy.d.ts +48 -0
- package/dist/environment/install-policy.js +96 -0
- package/dist/environment/instance.d.ts +33 -0
- package/dist/environment/instance.js +122 -0
- package/dist/environment/instruction-pointer.d.ts +19 -0
- package/dist/environment/instruction-pointer.js +144 -0
- package/dist/environment/lifecycle-composition.d.ts +31 -0
- package/dist/environment/lifecycle-composition.js +742 -0
- package/dist/environment/lifecycle-stage.d.ts +120 -0
- package/dist/environment/lifecycle-stage.js +408 -0
- package/dist/environment/lifecycle.d.ts +75 -0
- package/dist/environment/lifecycle.js +354 -0
- package/dist/environment/logs.d.ts +132 -0
- package/dist/environment/logs.js +519 -0
- package/dist/environment/map-limit.d.ts +2 -0
- package/dist/environment/map-limit.js +13 -0
- package/dist/environment/mcp-observation.d.ts +9 -0
- package/dist/environment/mcp-observation.js +46 -0
- package/dist/environment/observations.d.ts +46 -0
- package/dist/environment/observations.js +346 -0
- package/dist/environment/operator-application.d.ts +79 -0
- package/dist/environment/operator-application.js +197 -0
- package/dist/environment/ports.d.ts +182 -0
- package/dist/environment/ports.js +1205 -0
- package/dist/environment/posture-observation.d.ts +68 -0
- package/dist/environment/posture-observation.js +253 -0
- package/dist/environment/presence.d.ts +4 -0
- package/dist/environment/presence.js +26 -0
- package/dist/environment/read-composition.d.ts +32 -0
- package/dist/environment/read-composition.js +397 -0
- package/dist/environment/readiness-composition.d.ts +57 -0
- package/dist/environment/readiness-composition.js +151 -0
- package/dist/environment/reclaim.d.ts +370 -0
- package/dist/environment/reclaim.js +1940 -0
- package/dist/environment/repository-identity.d.ts +13 -0
- package/dist/environment/repository-identity.js +108 -0
- package/dist/environment/runtime-measurement-record.d.ts +38 -0
- package/dist/environment/runtime-measurement-record.js +111 -0
- package/dist/environment/runtime-measurement.d.ts +27 -0
- package/dist/environment/runtime-measurement.js +224 -0
- package/dist/environment/runtime-probe-residue.d.ts +43 -0
- package/dist/environment/runtime-probe-residue.js +148 -0
- package/dist/environment/runtime-probe.d.ts +72 -0
- package/dist/environment/runtime-probe.js +725 -0
- package/dist/environment/runtime.d.ts +551 -0
- package/dist/environment/runtime.js +2405 -0
- package/dist/environment/seed.d.ts +16 -0
- package/dist/environment/seed.js +43 -0
- package/dist/environment/selftest-application.d.ts +86 -0
- package/dist/environment/selftest-application.js +713 -0
- package/dist/environment/sensitive.d.ts +3 -0
- package/dist/environment/sensitive.js +48 -0
- package/dist/environment/served-checkout-grants.d.ts +53 -0
- package/dist/environment/served-checkout-grants.js +182 -0
- package/dist/environment/setup-observation.d.ts +62 -0
- package/dist/environment/setup-observation.js +1473 -0
- package/dist/environment/setup.d.ts +43 -0
- package/dist/environment/setup.js +176 -0
- package/dist/environment/sibling-checkouts.d.ts +119 -0
- package/dist/environment/sibling-checkouts.js +254 -0
- package/dist/environment/sibling-instructions.d.ts +33 -0
- package/dist/environment/sibling-instructions.js +224 -0
- package/dist/environment/sibling-observation.d.ts +27 -0
- package/dist/environment/sibling-observation.js +45 -0
- package/dist/environment/sibling-pull.d.ts +23 -0
- package/dist/environment/sibling-pull.js +95 -0
- package/dist/environment/sibling-registration.d.ts +45 -0
- package/dist/environment/sibling-registration.js +538 -0
- package/dist/environment/stack-inputs.d.ts +18 -0
- package/dist/environment/stack-inputs.js +210 -0
- package/dist/environment/stack-inventory-prune.d.ts +31 -0
- package/dist/environment/stack-inventory-prune.js +129 -0
- package/dist/environment/stack-inventory-report.d.ts +44 -0
- package/dist/environment/stack-inventory-report.js +78 -0
- package/dist/environment/stack-inventory.d.ts +94 -0
- package/dist/environment/stack-inventory.js +418 -0
- package/dist/environment/state.d.ts +410 -0
- package/dist/environment/state.js +2153 -0
- package/dist/environment/templates.d.ts +140 -0
- package/dist/environment/templates.js +685 -0
- package/dist/environment/tool-registration.d.ts +9 -0
- package/dist/environment/tool-registration.js +92 -0
- package/dist/environment/upgrade-application.d.ts +19 -0
- package/dist/environment/upgrade-application.js +175 -0
- package/dist/environment-exec/execute.d.ts +105 -0
- package/dist/environment-exec/execute.js +1179 -0
- package/dist/environment-exec/libexec-program.d.ts +6 -0
- package/dist/environment-exec/libexec-program.js +22 -0
- package/dist/environment-exec/verified-digest.d.ts +4 -0
- package/dist/environment-exec/verified-digest.js +16 -0
- package/dist/exact-keys.d.ts +7 -0
- package/dist/exact-keys.js +15 -0
- package/dist/fix-catalogue.d.ts +32 -0
- package/dist/fix-catalogue.js +60 -0
- package/dist/freshness.d.ts +29 -0
- package/dist/freshness.js +75 -0
- package/dist/generated-environment/adopt.d.ts +16 -0
- package/dist/generated-environment/adopt.js +271 -0
- package/dist/generated-environment/command.d.ts +47 -0
- package/dist/generated-environment/command.js +75 -0
- package/dist/generated-environment/transaction.d.ts +186 -0
- package/dist/generated-environment/transaction.js +1770 -0
- package/dist/grading/evaluate.d.ts +71 -0
- package/dist/grading/evaluate.js +403 -0
- package/dist/grading/grade.d.ts +33 -0
- package/dist/grading/grade.js +57 -0
- package/dist/guards/answer-confirmation.d.ts +41 -0
- package/dist/guards/answer-confirmation.js +109 -0
- package/dist/guards/evaluator.d.ts +130 -0
- package/dist/guards/evaluator.js +1258 -0
- package/dist/guards/harness-adapter.d.ts +17 -0
- package/dist/guards/harness-adapter.js +57 -0
- package/dist/guards/host.d.ts +8 -0
- package/dist/guards/host.js +10 -0
- package/dist/guards/invocation-parser.d.ts +66 -0
- package/dist/guards/invocation-parser.js +595 -0
- package/dist/guards/local-identity.d.ts +44 -0
- package/dist/guards/local-identity.js +129 -0
- package/dist/guards/policy-change.d.ts +43 -0
- package/dist/guards/policy-change.js +159 -0
- package/dist/guards/policy-pin.d.ts +13 -0
- package/dist/guards/policy-pin.js +177 -0
- package/dist/guards/protected-locations.d.ts +62 -0
- package/dist/guards/protected-locations.js +461 -0
- package/dist/guards/read-only.d.ts +37 -0
- package/dist/guards/read-only.js +315 -0
- package/dist/init/command.d.ts +41 -0
- package/dist/init/command.js +330 -0
- package/dist/init/derive.d.ts +53 -0
- package/dist/init/derive.js +819 -0
- package/dist/init/draft.d.ts +140 -0
- package/dist/init/draft.js +1228 -0
- package/dist/init/render.d.ts +47 -0
- package/dist/init/render.js +104 -0
- package/dist/init/scaffold.d.ts +53 -0
- package/dist/init/scaffold.js +121 -0
- package/dist/invocation.d.ts +13 -0
- package/dist/invocation.js +20 -0
- package/dist/package-metadata.d.ts +9 -0
- package/dist/package-metadata.js +19 -0
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.js +88 -0
- package/dist/references/named.d.ts +24 -0
- package/dist/references/named.js +27 -0
- package/dist/refusal.d.ts +15 -0
- package/dist/refusal.js +7 -0
- package/dist/registry-derivation.d.ts +31 -0
- package/dist/registry-derivation.js +32 -0
- package/dist/registry-resolve/command.d.ts +47 -0
- package/dist/registry-resolve/command.js +226 -0
- package/dist/registry-resolve/registry.d.ts +68 -0
- package/dist/registry-resolve/registry.js +292 -0
- package/dist/registry-resolve/render-shell.d.ts +18 -0
- package/dist/registry-resolve/render-shell.js +36 -0
- package/dist/repair.d.ts +29 -0
- package/dist/repair.js +8 -0
- package/dist/repository-path.d.ts +9 -0
- package/dist/repository-path.js +16 -0
- package/dist/schema-json.d.ts +1 -0
- package/dist/schema-json.js +177 -0
- package/dist/schema.d.ts +1289 -0
- package/dist/schema.js +985 -0
- package/dist/setup/command.d.ts +4 -0
- package/dist/setup/command.js +4 -0
- package/dist/sha256.d.ts +1 -0
- package/dist/sha256.js +4 -0
- package/dist/surfaces/adoption.d.ts +41 -0
- package/dist/surfaces/adoption.js +217 -0
- package/dist/surfaces/consumer-instructions.d.ts +20 -0
- package/dist/surfaces/consumer-instructions.js +43 -0
- package/dist/surfaces/contract.d.ts +42 -0
- package/dist/surfaces/contract.js +169 -0
- package/dist/surfaces/core-declarations.d.ts +24 -0
- package/dist/surfaces/core-declarations.js +79 -0
- package/dist/surfaces/development-markers.d.ts +1 -0
- package/dist/surfaces/development-markers.js +18 -0
- package/dist/surfaces/generator-adapter.d.ts +71 -0
- package/dist/surfaces/generator-adapter.js +809 -0
- package/dist/surfaces/harness-registry.d.ts +260 -0
- package/dist/surfaces/harness-registry.js +146 -0
- package/dist/surfaces/mcp.d.ts +145 -0
- package/dist/surfaces/mcp.js +349 -0
- package/dist/surfaces/merge.d.ts +30 -0
- package/dist/surfaces/merge.js +105 -0
- package/dist/surfaces/ownership.d.ts +190 -0
- package/dist/surfaces/ownership.js +795 -0
- package/dist/surfaces/projection.d.ts +136 -0
- package/dist/surfaces/projection.js +716 -0
- package/dist/surfaces/render.d.ts +79 -0
- package/dist/surfaces/render.js +636 -0
- package/dist/surfaces/restrictions.d.ts +130 -0
- package/dist/surfaces/restrictions.js +447 -0
- package/dist/surfaces/selftest.d.ts +162 -0
- package/dist/surfaces/selftest.js +393 -0
- package/dist/surfaces/skill-contract.d.ts +85 -0
- package/dist/surfaces/skill-contract.js +449 -0
- package/dist/surfaces/sync.d.ts +57 -0
- package/dist/surfaces/sync.js +164 -0
- package/dist/team-metadata.d.ts +41 -0
- package/dist/team-metadata.js +513 -0
- package/dist/testing/gates.d.ts +91 -0
- package/dist/testing/gates.js +182 -0
- package/dist/testing/hooks.d.ts +59 -0
- package/dist/testing/hooks.js +139 -0
- package/dist/testing/test-protection.d.ts +34 -0
- package/dist/testing/test-protection.js +137 -0
- package/dist/testing/verdict.d.ts +29 -0
- package/dist/testing/verdict.js +62 -0
- package/dist/testing/weakening.d.ts +15 -0
- package/dist/testing/weakening.js +30 -0
- package/dist/work-orders/application-closure.d.ts +7 -0
- package/dist/work-orders/application-closure.js +76 -0
- package/dist/work-orders/application-context.d.ts +162 -0
- package/dist/work-orders/application-context.js +137 -0
- package/dist/work-orders/application-decisions.d.ts +27 -0
- package/dist/work-orders/application-decisions.js +121 -0
- package/dist/work-orders/application-grading.d.ts +11 -0
- package/dist/work-orders/application-grading.js +212 -0
- package/dist/work-orders/application.d.ts +6 -0
- package/dist/work-orders/application.js +223 -0
- package/dist/work-orders/composition.d.ts +101 -0
- package/dist/work-orders/composition.js +1202 -0
- package/dist/work-orders/contract.d.ts +77 -0
- package/dist/work-orders/contract.js +140 -0
- package/dist/work-orders/decisions.d.ts +23 -0
- package/dist/work-orders/decisions.js +55 -0
- package/dist/work-orders/store.d.ts +207 -0
- package/dist/work-orders/store.js +291 -0
- package/docs/README.md +68 -0
- package/docs/architecture.md +136 -0
- package/docs/capability-matrix.md +58 -0
- package/docs/cli-reference.md +807 -0
- package/docs/command-list.md +62 -0
- package/docs/compose-patterns.md +99 -0
- package/docs/concepts.md +173 -0
- package/docs/configuration-essentials.md +177 -0
- package/docs/configuration-reference.md +636 -0
- package/docs/docs-check.md +76 -0
- package/docs/environment.md +948 -0
- package/docs/extending.md +43 -0
- package/docs/faq.md +113 -0
- package/docs/getting-started.md +692 -0
- package/docs/harness-surfaces.md +500 -0
- package/docs/joining-a-team.md +76 -0
- package/docs/release-policy.md +49 -0
- package/docs/safety-and-autonomy.md +463 -0
- package/docs/troubleshooting.md +382 -0
- package/docs/tutorial.md +171 -0
- package/docs/work-and-browser.md +420 -0
- package/libexec/browser-operation.cjs +270 -0
- package/libexec/fence-marker.cjs +101 -0
- package/libexec/fence-marker.d.cts +24 -0
- package/libexec/fenced-group-runner.cjs +77 -0
- package/libexec/fenced-supervisor.cjs +137 -0
- package/libexec/generated-filesystem.cjs +731 -0
- package/libexec/install-filesystem.cjs +225 -0
- package/libexec/rulesync-generator.NOTICE.md +1112 -0
- package/libexec/rulesync-generator.cjs +743 -0
- package/libexec/surface-generator-worker.cjs +266 -0
- package/libexec/surface-output-reader.cjs +99 -0
- package/libexec/surface-scratch-cleanup.cjs +14 -0
- package/libexec/validate-harness-evidence.d.mts +183 -0
- package/libexec/validate-harness-evidence.mjs +1312 -0
- package/package.json +74 -4
- package/surfaces/README.md +33 -0
- package/surfaces/agents/evaluator.agent.md +76 -0
- package/surfaces/guards/bash-guard.sh +48 -0
- package/surfaces/guards/claude.adapter.json +25 -0
- package/surfaces/guards/codex.adapter.json +24 -0
- package/surfaces/guards/opencode.adapter.json +25 -0
- package/surfaces/references/browser.md +63 -0
- package/surfaces/references/test-data-and-personas.md +84 -0
- package/surfaces/references/testing-tiers.md +11 -0
- package/surfaces/skills/cockpit-browser.skill.md +59 -0
- package/surfaces/skills/cockpit-explain.skill.md +32 -0
- package/surfaces/skills/cockpit-fix.skill.md +37 -0
- package/surfaces/skills/cockpit-setup.skill.md +39 -0
- package/surfaces/skills/cockpit-work.skill.md +34 -0
- package/surfaces/skills/collection.json +5 -0
- package/surfaces/skills/procedures/explain.md +66 -0
- package/surfaces/skills/procedures/fix.md +95 -0
- package/surfaces/skills/procedures/setup.md +452 -0
- package/surfaces/skills/procedures/work.md +134 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type EnvironmentDiagnostic } from '../contract.js';
|
|
2
|
+
import type { EvaluatorTool } from '../../schema.js';
|
|
3
|
+
import type { SkippedStateNamespace } from '../state.js';
|
|
4
|
+
import { type GeneratedEnvironmentCurrentness } from '../generated-application/shared.js';
|
|
5
|
+
import type { McpServer } from '../../surfaces/mcp.js';
|
|
6
|
+
import { type ReadinessReport } from '../../readiness.js';
|
|
7
|
+
import type { ReleaseFreshness } from '../../freshness.js';
|
|
8
|
+
import { proposeGeneratedEnvironmentRepair } from '../../repair.js';
|
|
9
|
+
import type { ActiveSurfaceOverride, SurfaceUpgradeFinding } from '../../surfaces/merge.js';
|
|
10
|
+
import { type DoctorCheck, type PreflightEvaluation } from '../observations.js';
|
|
11
|
+
import { type ComparisonRemoteEvaluation, type ObservationCommandAdapters } from './health.js';
|
|
12
|
+
export interface DoctorCommandInput {
|
|
13
|
+
readonly configPath: string;
|
|
14
|
+
}
|
|
15
|
+
interface DoctorSurfaceOverrideInspectionComplete {
|
|
16
|
+
readonly kind: 'complete';
|
|
17
|
+
readonly activeOverrides: readonly ActiveSurfaceOverride[];
|
|
18
|
+
readonly changedOverrideOriginals: readonly SurfaceUpgradeFinding[];
|
|
19
|
+
}
|
|
20
|
+
interface DoctorSurfaceOverrideInspectionUnavailable {
|
|
21
|
+
readonly kind: 'unavailable';
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
}
|
|
25
|
+
interface DoctorSurfaceOverrideInspectionRefusal {
|
|
26
|
+
readonly kind: 'refusal';
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
}
|
|
30
|
+
export type DoctorSurfaceOverrideInspection = DoctorSurfaceOverrideInspectionComplete | DoctorSurfaceOverrideInspectionUnavailable | DoctorSurfaceOverrideInspectionRefusal;
|
|
31
|
+
export interface DoctorCommandAdapters extends ObservationCommandAdapters {
|
|
32
|
+
readonly inspectSurfaceOverrides?: (configPath: string) => Promise<DoctorSurfaceOverrideInspection>;
|
|
33
|
+
readonly discoverReleaseFreshness?: () => Promise<ReleaseFreshness>;
|
|
34
|
+
/** Warnings when an agent tool on this machine would skip the generated guard hook. */
|
|
35
|
+
readonly inspectHookTrust?: () => Promise<readonly EnvironmentDiagnostic[]>;
|
|
36
|
+
/** A warning when work orders exist but their independent evaluator cannot run on this machine. */
|
|
37
|
+
readonly inspectEvaluator?: (evaluators: readonly EvaluatorTool[]) => Promise<readonly EnvironmentDiagnostic[]>;
|
|
38
|
+
/** Warnings about what each approved MCP server needs before a tool can start it; never starts one. */
|
|
39
|
+
readonly inspectMcpStartup?: (servers: readonly McpServer[]) => Promise<readonly EnvironmentDiagnostic[]>;
|
|
40
|
+
/** Warnings about prerequisites the stack checks do not cover: the local install, sibling remotes, committed secrets. */
|
|
41
|
+
readonly inspectReadiness?: () => Promise<readonly EnvironmentDiagnostic[]>;
|
|
42
|
+
/** Other cockpits' state namespaces this version skipped, or why the inventory could not be read; read after load has selected this cockpit's state root. */
|
|
43
|
+
/** Warnings about stacks on this machine that no checkout can reach, read after load has selected this cockpit's state root. */
|
|
44
|
+
readonly inspectStacks?: () => Promise<readonly EnvironmentDiagnostic[]>;
|
|
45
|
+
readonly readUnreadableState?: () => Promise<Readonly<{
|
|
46
|
+
kind: 'complete';
|
|
47
|
+
skipped: readonly SkippedStateNamespace[];
|
|
48
|
+
}> | Readonly<{
|
|
49
|
+
kind: 'refusal';
|
|
50
|
+
diagnostics: readonly EnvironmentDiagnostic[];
|
|
51
|
+
}>>;
|
|
52
|
+
}
|
|
53
|
+
interface DoctorFreshness {
|
|
54
|
+
readonly local: Readonly<{
|
|
55
|
+
kind: GeneratedEnvironmentCurrentness['outcome']['kind'];
|
|
56
|
+
status: number;
|
|
57
|
+
diagnostics: GeneratedEnvironmentCurrentness['outcome']['diagnostics'];
|
|
58
|
+
}>;
|
|
59
|
+
readonly changes: GeneratedEnvironmentCurrentness['changes'];
|
|
60
|
+
readonly storedProducer: GeneratedEnvironmentCurrentness['storedProducer'];
|
|
61
|
+
readonly installedProducer: GeneratedEnvironmentCurrentness['currentProducer'];
|
|
62
|
+
readonly release: ReleaseFreshness;
|
|
63
|
+
readonly repair?: ReturnType<typeof proposeGeneratedEnvironmentRepair>;
|
|
64
|
+
}
|
|
65
|
+
interface DoctorDeclaration {
|
|
66
|
+
readonly subject: 'runtime' | 'reset-volumes' | 'seed' | 'docs';
|
|
67
|
+
readonly state: 'declared' | 'not-declared';
|
|
68
|
+
readonly source: string;
|
|
69
|
+
readonly reason: string;
|
|
70
|
+
}
|
|
71
|
+
interface ApplicationDoctorEvaluation {
|
|
72
|
+
readonly verdict: PreflightEvaluation['verdict'];
|
|
73
|
+
readonly checks: readonly DoctorCheck[];
|
|
74
|
+
readonly comparisons: readonly ComparisonRemoteEvaluation[];
|
|
75
|
+
readonly surfaceOverrides: DoctorSurfaceOverrideInspection;
|
|
76
|
+
readonly freshness: DoctorFreshness;
|
|
77
|
+
/** What the configuration declares, read from cockpit.toml alone; empty when it does not load. */
|
|
78
|
+
readonly declarations: readonly DoctorDeclaration[];
|
|
79
|
+
/** The reported diagnostics grouped under the prerequisites cockpit depends on; absent when cockpit.toml does not load. */
|
|
80
|
+
readonly readiness?: ReadinessReport;
|
|
81
|
+
}
|
|
82
|
+
type DoctorCommandResult = Readonly<{
|
|
83
|
+
kind: 'complete';
|
|
84
|
+
status: 0;
|
|
85
|
+
diagnostics: readonly EnvironmentDiagnostic[];
|
|
86
|
+
result: ApplicationDoctorEvaluation;
|
|
87
|
+
}> | Readonly<{
|
|
88
|
+
kind: 'refusal';
|
|
89
|
+
status: 2;
|
|
90
|
+
diagnostics: readonly EnvironmentDiagnostic[];
|
|
91
|
+
result: ApplicationDoctorEvaluation;
|
|
92
|
+
}>;
|
|
93
|
+
export declare function runDoctor(input: DoctorCommandInput, adapters: DoctorCommandAdapters): Promise<DoctorCommandResult>;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { dirname, join, resolve } from 'node:path';
|
|
2
|
+
import { ENVIRONMENT_CODES, errorCause, snapshotJson } from '../contract.js';
|
|
3
|
+
import { effectivePolicy, policyWeakening, policyWeakeningDiagnostic, readRecordedPolicy } from '../../autonomy.js';
|
|
4
|
+
import { prepareGeneratedEnvironmentCurrentness } from '../generated-application/check.js';
|
|
5
|
+
import {} from '../generated-application/shared.js';
|
|
6
|
+
import { declaredRuntime, declaresNothingToRun } from '../declaration.js';
|
|
7
|
+
import { readinessReport } from '../../readiness.js';
|
|
8
|
+
import { proposeGeneratedEnvironmentRepair } from '../../repair.js';
|
|
9
|
+
import { SURFACE_FEATURES } from '../../surfaces/contract.js';
|
|
10
|
+
import { loadCockpitConfig, evaluatorTools } from '../../config/load.js';
|
|
11
|
+
import { projectDoctor } from '../observations.js';
|
|
12
|
+
import { applicationDiagnostic, evaluateApplicationHealth, healthDiagnostics, issueHealthObservationSource, prepareHealthObservation, } from './health.js';
|
|
13
|
+
import { ownDataValues } from './shared.js';
|
|
14
|
+
import { cockpitCommand } from '../../fix-catalogue.js';
|
|
15
|
+
import { unconfirmedFix } from '../../guards/answer-confirmation.js';
|
|
16
|
+
import { unreadableStateWarning } from './lifecycle-state.js';
|
|
17
|
+
// What reset and up do to product data rests on these declarations; doctor names an absent one
|
|
18
|
+
// instead of letting it read as a passed check.
|
|
19
|
+
async function doctorDeclarations(loading) {
|
|
20
|
+
const loaded = await loading;
|
|
21
|
+
if (loaded.kind !== 'complete')
|
|
22
|
+
return [];
|
|
23
|
+
const environment = loaded.result.config.environment;
|
|
24
|
+
const runtime = declaredRuntime(environment) === 'compose';
|
|
25
|
+
const absent = runtime ? 'not declared in cockpit.toml' : 'no runtime environment is declared';
|
|
26
|
+
const row = (subject, declared, source, reason) => ({ subject, state: declared ? 'declared' : 'not-declared', source, reason: declared ? reason : absent });
|
|
27
|
+
return [
|
|
28
|
+
row('runtime', runtime, 'environment.compose_files', runtime ? 'cockpit runs the declared Compose files'
|
|
29
|
+
: 'environment.compose_files is not declared; runtime commands refuse'),
|
|
30
|
+
row('reset-volumes', environment.resettable_volumes.length > 0, 'environment.resettable_volumes', 'reset may delete and recreate these volumes'),
|
|
31
|
+
row('seed', environment.seed !== undefined, 'environment.seed', 'up runs the seed when a resettable volume is new'),
|
|
32
|
+
// Docs rot is not environment health, so doctor names the check rather than running it.
|
|
33
|
+
...loaded.result.config.docs === undefined ? [] : [{ subject: 'docs', state: 'declared', source: 'docs',
|
|
34
|
+
reason: `docs check reads the declared living documents and decision records; doctor does not run it: ${cockpitCommand('docs check', { config: loaded.result.source.path })}` }],
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
// The guard denies agent commands that reach these hosts. Two empty lists deny nothing, and that
|
|
38
|
+
// looks exactly like a guard that is working, so doctor says so. A declared runtime is the signal
|
|
39
|
+
// that hosted environments exist. Both keys
|
|
40
|
+
// written as empty lists, as init records an explicit "none", is a decision and is not warned about.
|
|
41
|
+
async function doctorGuardHostDiagnostics(loading) {
|
|
42
|
+
const loaded = await loading;
|
|
43
|
+
if (loaded.kind !== 'complete')
|
|
44
|
+
return [];
|
|
45
|
+
const { environment, guards } = loaded.result.config;
|
|
46
|
+
if (declaredRuntime(environment) === 'none' || loaded.result.guardHostsStated
|
|
47
|
+
|| guards.hosted_db_hosts.length > 0 || guards.vendor_endpoint_hosts.length > 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return [{
|
|
51
|
+
severity: 'warning',
|
|
52
|
+
// A literal, so the diagnostic inventory captures the fix beside the code.
|
|
53
|
+
code: 'GUARD_HOSTS_UNDECLARED',
|
|
54
|
+
message: 'guards.hosted_db_hosts and guards.vendor_endpoint_hosts are both empty, so the guard denies no agent command by host even though this cockpit declares a runtime',
|
|
55
|
+
target: 'guards',
|
|
56
|
+
fix: 'list the database and live vendor API hosts of every non-local environment (production, staging, shared) under [guards] in cockpit.toml, then run npx --no cockpit sync --config <your cockpit.toml>; if no such environment exists, record that by writing hosted_db_hosts = [] and vendor_endpoint_hosts = [] under [guards]',
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
// A product with no declared gate gives test-run nothing to run, so no work in it can be graded PASS;
|
|
60
|
+
// a docs-only cockpit has no product to test and stays quiet.
|
|
61
|
+
async function doctorEvaluatorDiagnostics(loading, adapters) {
|
|
62
|
+
const loaded = await loading;
|
|
63
|
+
return loaded.kind === 'complete' && adapters.inspectEvaluator ? adapters.inspectEvaluator(evaluatorTools(loaded.result.config)) : [];
|
|
64
|
+
}
|
|
65
|
+
async function doctorTestingGateDiagnostics(loading) {
|
|
66
|
+
const loaded = await loading;
|
|
67
|
+
if (loaded.kind !== 'complete' || loaded.result.config.testing || declaredRuntime(loaded.result.config.environment) === 'none') {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return [{
|
|
71
|
+
severity: 'warning',
|
|
72
|
+
// A literal, so the diagnostic inventory captures the fix beside the code.
|
|
73
|
+
code: 'TESTING_GATE_UNDECLARED',
|
|
74
|
+
message: 'cockpit.toml declares no [testing] gate, so test-run has nothing to run and no work in this product can be graded PASS',
|
|
75
|
+
target: 'testing',
|
|
76
|
+
fix: 'declare the product test commands as [testing] stages with a targeted and a full gate in cockpit.toml, then run npx --no cockpit sync --config <your cockpit.toml>',
|
|
77
|
+
}];
|
|
78
|
+
}
|
|
79
|
+
// init records answers no person stated under `unconfirmed`. They look exactly like stated values
|
|
80
|
+
// in the file, so doctor keeps naming them until each is confirmed: by the observation that verifies
|
|
81
|
+
// it, or by a person where it is a trust decision or no observation settles it.
|
|
82
|
+
async function doctorUnconfirmedDiagnostics(loading) {
|
|
83
|
+
const loaded = await loading;
|
|
84
|
+
if (loaded.kind !== 'complete' || !loaded.result.config.unconfirmed)
|
|
85
|
+
return [];
|
|
86
|
+
return [{
|
|
87
|
+
severity: 'warning',
|
|
88
|
+
// A literal, so the diagnostic inventory captures the fix beside the code.
|
|
89
|
+
code: 'DECLARATION_UNCONFIRMED',
|
|
90
|
+
message: `${loaded.result.config.unconfirmed.join(', ')} in cockpit.toml were chosen by the setup agent or by no one named, not stated by a person, so they may not describe this product`,
|
|
91
|
+
target: 'unconfirmed',
|
|
92
|
+
fix: unconfirmedFix(loaded.result.config.unconfirmed),
|
|
93
|
+
}];
|
|
94
|
+
}
|
|
95
|
+
// The same weakening `check` fails on: a policy cockpit.toml sets below the one the last sync recorded
|
|
96
|
+
// is not in force, and doctor is where an agent looks first.
|
|
97
|
+
async function doctorPolicyDiagnostics(loading) {
|
|
98
|
+
const loaded = await loading;
|
|
99
|
+
if (loaded.kind !== 'complete')
|
|
100
|
+
return [];
|
|
101
|
+
const recorded = await readRecordedPolicy(dirname(loaded.result.source.path));
|
|
102
|
+
const weakened = recorded ? policyWeakening(recorded, effectivePolicy(loaded.result.config)) : [];
|
|
103
|
+
return weakened.length ? [{ ...policyWeakeningDiagnostic(weakened), severity: 'warning' }] : [];
|
|
104
|
+
}
|
|
105
|
+
const unavailableSurfaceOverrideInspection = Object.freeze({
|
|
106
|
+
kind: 'unavailable',
|
|
107
|
+
code: 'SURFACE_OVERRIDE_INSPECTION_UNAVAILABLE',
|
|
108
|
+
reason: 'authenticated generated surface override inspection is unavailable',
|
|
109
|
+
});
|
|
110
|
+
async function inspectDoctorSurfaceOverrides(configPath, adapters) {
|
|
111
|
+
if (!adapters.inspectSurfaceOverrides)
|
|
112
|
+
return unavailableSurfaceOverrideInspection;
|
|
113
|
+
try {
|
|
114
|
+
const inspection = await adapters.inspectSurfaceOverrides(configPath);
|
|
115
|
+
const captured = snapshotJson(inspection);
|
|
116
|
+
const record = ownDataValues(captured, ['kind'], ['activeOverrides', 'changedOverrideOriginals', 'code', 'reason']);
|
|
117
|
+
const sha256 = /^[a-f0-9]{64}$/;
|
|
118
|
+
const activeOverride = (value) => {
|
|
119
|
+
const row = ownDataValues(value, ['name', 'feature', 'originalSha256', 'recordedSha256', 'overlaySource']);
|
|
120
|
+
return row !== undefined
|
|
121
|
+
&& typeof row.name === 'string' && row.name.length > 0
|
|
122
|
+
&& typeof row.feature === 'string' && SURFACE_FEATURES.includes(row.feature)
|
|
123
|
+
&& typeof row.originalSha256 === 'string' && sha256.test(row.originalSha256)
|
|
124
|
+
&& typeof row.recordedSha256 === 'string' && sha256.test(row.recordedSha256)
|
|
125
|
+
&& typeof row.overlaySource === 'string' && row.overlaySource.length > 0;
|
|
126
|
+
};
|
|
127
|
+
const changedOriginal = (value) => {
|
|
128
|
+
const row = ownDataValues(value, ['code', 'name', 'recordedSha256', 'currentSha256', 'overlaySource']);
|
|
129
|
+
return row !== undefined && row.code === 'OVERRIDDEN_CORE_CHANGED'
|
|
130
|
+
&& typeof row.name === 'string' && row.name.length > 0
|
|
131
|
+
&& typeof row.recordedSha256 === 'string' && sha256.test(row.recordedSha256)
|
|
132
|
+
&& typeof row.currentSha256 === 'string' && sha256.test(row.currentSha256)
|
|
133
|
+
&& typeof row.overlaySource === 'string' && row.overlaySource.length > 0;
|
|
134
|
+
};
|
|
135
|
+
const complete = record?.kind === 'complete'
|
|
136
|
+
&& Reflect.ownKeys(record).length === 3
|
|
137
|
+
&& Array.isArray(record.activeOverrides) && record.activeOverrides.every(activeOverride)
|
|
138
|
+
&& Array.isArray(record.changedOverrideOriginals) && record.changedOverrideOriginals.every(changedOriginal);
|
|
139
|
+
const unavailableOrRefusal = (record?.kind === 'unavailable' || record?.kind === 'refusal')
|
|
140
|
+
&& Reflect.ownKeys(record).length === 3
|
|
141
|
+
&& typeof record.code === 'string' && record.code.length > 0
|
|
142
|
+
&& typeof record.reason === 'string' && record.reason.length > 0;
|
|
143
|
+
if (!complete && !unavailableOrRefusal) {
|
|
144
|
+
return {
|
|
145
|
+
kind: 'refusal',
|
|
146
|
+
code: 'SURFACE_OVERRIDE_INSPECTION_INVALID',
|
|
147
|
+
reason: 'surface override inspection returned invalid evidence',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return captured;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
return { ...unavailableSurfaceOverrideInspection,
|
|
154
|
+
reason: `${unavailableSurfaceOverrideInspection.reason}: ${errorCause(error)}` };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function unavailableDoctor(code, message, surfaceOverrides, freshness, declarations, forwarded) {
|
|
158
|
+
return {
|
|
159
|
+
kind: 'complete', status: 0,
|
|
160
|
+
diagnostics: forwarded ?? [applicationDiagnostic(code, message, 'preflight')],
|
|
161
|
+
result: {
|
|
162
|
+
verdict: 'unavailable', checks: [], comparisons: [], surfaceOverrides, freshness, declarations,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export async function runDoctor(input, adapters) {
|
|
167
|
+
const config = loadCockpitConfig(input.configPath);
|
|
168
|
+
// Codex hook trust is advice for a Codex user; a cockpit that does not list Codex gets none.
|
|
169
|
+
const hookTrustFindings = async () => {
|
|
170
|
+
const loaded = await config;
|
|
171
|
+
return loaded.kind === 'complete' && loaded.result.config.surfaces.tools.includes('codexcli')
|
|
172
|
+
? adapters.inspectHookTrust?.() ?? [] : [];
|
|
173
|
+
};
|
|
174
|
+
const currentness = prepareGeneratedEnvironmentCurrentness(input);
|
|
175
|
+
const mcpStartup = async () => adapters.inspectMcpStartup?.((await currentness).mcpServers) ?? [];
|
|
176
|
+
// The machine-wide state reads are independent of the configuration checks, so they run beside them.
|
|
177
|
+
const statePending = adapters.readUnreadableState?.();
|
|
178
|
+
const stacksPending = adapters.inspectStacks?.();
|
|
179
|
+
const [outcome, guardHosts, unconfirmed, policyWeakened, testingGate, hookTrust, evaluator, readinessWarnings, servedSiblings, mcp] = await Promise.all([doctorHealth(input, adapters, config, currentness),
|
|
180
|
+
doctorGuardHostDiagnostics(config), doctorUnconfirmedDiagnostics(config), doctorPolicyDiagnostics(config), doctorTestingGateDiagnostics(config), hookTrustFindings(),
|
|
181
|
+
doctorEvaluatorDiagnostics(config, adapters), adapters.inspectReadiness?.() ?? [], config.then(async (loaded) => adapters.inspectServedSiblings?.(loaded.kind === 'complete' ? loaded : undefined) ?? []), mcpStartup()]);
|
|
182
|
+
const stateInventory = await statePending;
|
|
183
|
+
const unreadableState = stateInventory?.kind === 'refusal'
|
|
184
|
+
// An inventory that cannot be read, such as one another command holds locked, is no clean one.
|
|
185
|
+
? stateInventory.diagnostics.map((diagnostic) => ({ ...diagnostic, severity: 'warning',
|
|
186
|
+
message: `doctor could not read this machine's cockpit state, so it did not check for other cockpits' state this version cannot read: ${diagnostic.message}` }))
|
|
187
|
+
: [unreadableStateWarning(stateInventory?.skipped ?? [])].filter((warning) => warning !== undefined);
|
|
188
|
+
const orphanedStacks = await stacksPending ?? [];
|
|
189
|
+
const warnings = [...unconfirmed, ...policyWeakened, ...guardHosts, ...testingGate, ...hookTrust, ...evaluator, ...readinessWarnings, ...servedSiblings, ...mcp, ...unreadableState, ...orphanedStacks];
|
|
190
|
+
const reported = warnings.length === 0 ? outcome
|
|
191
|
+
: { ...outcome, diagnostics: [...outcome.diagnostics, ...warnings] };
|
|
192
|
+
// Doctor reports on a configuration; without one there is nothing to report on, and a zero
|
|
193
|
+
// exit would let `doctor && ...` proceed past a missing or unparseable cockpit.toml.
|
|
194
|
+
const loaded = await config;
|
|
195
|
+
if (loaded.kind === 'complete') {
|
|
196
|
+
const state = declaresNothingToRun(loaded.result.config.environment) ? 'surfaces-only' : 'runtime';
|
|
197
|
+
return { ...reported, result: { ...reported.result,
|
|
198
|
+
readiness: readinessReport(state, reported.diagnostics, loaded.result.config.surfaces.tools) } };
|
|
199
|
+
}
|
|
200
|
+
const forwarded = new Set(reported.diagnostics.map(({ code, target }) => `${code}\0${target}`));
|
|
201
|
+
return {
|
|
202
|
+
...reported, kind: 'refusal', status: 2,
|
|
203
|
+
diagnostics: [...loaded.diagnostics.filter(({ code, target }) => !forwarded.has(`${code}\0${target}`)), ...reported.diagnostics],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async function doctorHealth(input, adapters, config, currentness) {
|
|
207
|
+
const surfaceOverrides = inspectDoctorSurfaceOverrides(input.configPath, adapters);
|
|
208
|
+
const declarations = doctorDeclarations(config);
|
|
209
|
+
const freshness = Promise.all([
|
|
210
|
+
currentness,
|
|
211
|
+
adapters.discoverReleaseFreshness?.() ?? Promise.resolve({ kind: 'unknown', reason: 'release discovery is not bound' }),
|
|
212
|
+
]).then(([currentness, release]) => ({
|
|
213
|
+
local: { kind: currentness.outcome.kind, status: currentness.outcome.status, diagnostics: currentness.outcome.diagnostics },
|
|
214
|
+
changes: currentness.changes, storedProducer: currentness.storedProducer,
|
|
215
|
+
installedProducer: currentness.currentProducer, release, repair: proposeGeneratedEnvironmentRepair(currentness),
|
|
216
|
+
}));
|
|
217
|
+
let health;
|
|
218
|
+
let doctor;
|
|
219
|
+
// A producer that refused says why, also when the observation is lost to a throw afterwards.
|
|
220
|
+
let refused;
|
|
221
|
+
try {
|
|
222
|
+
const source = await adapters.load(input, issueHealthObservationSource, (diagnostics) => { refused = diagnostics; return undefined; }, 'doctor');
|
|
223
|
+
if (!source) {
|
|
224
|
+
return unavailableDoctor(ENVIRONMENT_CODES.LIFECYCLE_EVIDENCE_INVALID, 'doctor observation source is unavailable', await surfaceOverrides, await freshness, await declarations, refused);
|
|
225
|
+
}
|
|
226
|
+
const observed = prepareHealthObservation(input, source);
|
|
227
|
+
if (!observed) {
|
|
228
|
+
return unavailableDoctor(ENVIRONMENT_CODES.LIFECYCLE_EVIDENCE_INVALID, 'doctor requires authenticated steady lifecycle evidence', await surfaceOverrides, await freshness, await declarations);
|
|
229
|
+
}
|
|
230
|
+
health = await evaluateApplicationHealth(observed, adapters);
|
|
231
|
+
doctor = projectDoctor(health.preflight);
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
return unavailableDoctor(ENVIRONMENT_CODES.LIFECYCLE_EVIDENCE_INVALID, `doctor requires authentic observation and lifecycle evidence: ${errorCause(error)}`, await surfaceOverrides, await freshness, await declarations, refused);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
kind: 'complete', status: 0, diagnostics: healthDiagnostics(health),
|
|
238
|
+
result: {
|
|
239
|
+
verdict: health.verdict,
|
|
240
|
+
checks: doctor.checks,
|
|
241
|
+
comparisons: health.comparisons,
|
|
242
|
+
surfaceOverrides: await surfaceOverrides,
|
|
243
|
+
freshness: await freshness,
|
|
244
|
+
declarations: await declarations,
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ExecuteProbeOutcome } from '../../environment-exec/execute.js';
|
|
2
|
+
import { type EnvironmentCommandOutcome, type ExecutionStep } from '../contract.js';
|
|
3
|
+
import { type GuardDecision, type GuardEvaluationPolicy } from '../../guards/evaluator.js';
|
|
4
|
+
import { type GuardSurfaceTarget } from '../../surfaces/harness-registry.js';
|
|
5
|
+
import { type FixContext } from '../../fix-catalogue.js';
|
|
6
|
+
import { observeSetupCheckout, type SetupCheckoutObservation } from '../setup-observation.js';
|
|
7
|
+
import { loadCockpitConfig, type LoadedConfigProjection } from '../../config/load.js';
|
|
8
|
+
import { type SiblingCheckoutRecordRead } from '../sibling-checkouts.js';
|
|
9
|
+
export interface GuardEvaluationApplicationInput {
|
|
10
|
+
readonly identity: unknown;
|
|
11
|
+
/** The checkout the invoked guard script resolved from its own location. */
|
|
12
|
+
readonly guardRoot: string;
|
|
13
|
+
readonly payload: unknown;
|
|
14
|
+
readonly harness: GuardSurfaceTarget;
|
|
15
|
+
readonly cwd: string;
|
|
16
|
+
readonly askIsDeny?: boolean;
|
|
17
|
+
readonly ripgrepConfigActive?: boolean;
|
|
18
|
+
/** The harness's command search path, whose directories inside the allowed roots the guard protects. */
|
|
19
|
+
readonly searchPath?: string;
|
|
20
|
+
}
|
|
21
|
+
interface GuardEvaluationApplicationAdapters {
|
|
22
|
+
readonly loadConfig: typeof loadCockpitConfig;
|
|
23
|
+
readonly observeCheckout: typeof observeSetupCheckout;
|
|
24
|
+
readonly resolveGit: () => Promise<import('../executable.js').ExecutableResolution>;
|
|
25
|
+
/** Needed only by a compose-first cockpit, whose service list is read from its Compose files. */
|
|
26
|
+
readonly resolveDocker?: () => Promise<import('../executable.js').ExecutableResolution>;
|
|
27
|
+
readonly execute?: (step: ExecutionStep) => Promise<ExecuteProbeOutcome>;
|
|
28
|
+
}
|
|
29
|
+
interface GuardEvaluationApplicationResult {
|
|
30
|
+
readonly decision: GuardDecision;
|
|
31
|
+
readonly diagnostics: readonly import('../contract.js').Diagnostic[];
|
|
32
|
+
readonly fixContext?: FixContext;
|
|
33
|
+
}
|
|
34
|
+
/** Installed bytes are authority only while their source, roots and publication still match. */
|
|
35
|
+
export declare function runGuardEvaluationApplication(input: GuardEvaluationApplicationInput, adapters: GuardEvaluationApplicationAdapters): Promise<GuardEvaluationApplicationResult>;
|
|
36
|
+
interface PreparedGuardEvaluationPolicy {
|
|
37
|
+
readonly policy: GuardEvaluationPolicy;
|
|
38
|
+
}
|
|
39
|
+
interface GuardEvaluationPolicyInput {
|
|
40
|
+
readonly configuration: LoadedConfigProjection;
|
|
41
|
+
readonly checkout: SetupCheckoutObservation;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Source projections share authenticated authority; installed consumption is admitted separately.
|
|
45
|
+
* `siblingCheckouts` is the configuration directory's sibling checkout record, when the caller
|
|
46
|
+
* started reading it already; it is read here otherwise.
|
|
47
|
+
*/
|
|
48
|
+
export declare function prepareGuardEvaluationPolicy(input: GuardEvaluationPolicyInput, siblingCheckouts?: Promise<SiblingCheckoutRecordRead>): Promise<EnvironmentCommandOutcome<PreparedGuardEvaluationPolicy>>;
|
|
49
|
+
export {};
|