posture

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package posture builds the live `protocol.PostureDeps.Counters` and `protocol.PostureDeps.Metrics` seams over the real runtime subsystems.

Why this package exists (§17.6 F3)

The Phase 72f posture surface takes a `Counters` and a `Metrics` callback. The `harbor dev` / `harbor console` boot path and the `harbortest/devstack` test-fixture assembler BOTH need to wire those callbacks to live state — not to an empty `types.RuntimeCounters{}` / `types.MetricsSnapshot{}` stub. A stub passes a fabricated-seam integration test while production returns all-zero; that is exactly the test↔production divergence CLAUDE.md §17.6 forbids. This package is the single shared implementation both call sites consume so the fixture cannot drift from production.

Counters reads the task registry's per-identity running / background task counts, the session registry's active-session count, and (when supplied) the MCP registry's healthy-server count. EventsPerSecond stays zero — the runtime exposes no bus-rate meter at V1; reporting zero for a counter the runtime genuinely cannot measure is honest, not a silent degradation of a known value.

Metrics projects the Phase 56 telemetry.MetricsRegistry's bus-fed counter snapshot onto the Protocol-shaped `types.MetricsSnapshot`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountersProvider

func CountersProvider(taskReg tasks.TaskRegistry, lister sessions.SessionLister, mcpReg *mcpdrv.Registry) func(context.Context, identity.Identity) types.RuntimeCounters

CountersProvider returns a `protocol.PostureDeps.Counters` seam that reads live runtime state. taskReg supplies the running / background task counts for the caller's session; lister supplies the active-session count scoped to the requested identity's tenant; mcpReg supplies the healthy-MCP-connection count (server-wide, not per-identity — MCP servers are a runtime-shared resource).

The returned func never panics: a registry read error degrades that one counter to its zero value while the others still report — a posture read is a best-effort observability snapshot, never a load-bearing control path. A genuinely missing dependency (a nil taskReg / lister / mcpReg) is a wiring bug the caller must catch at boot, so CountersProvider returns a func that simply reports zeros for the missing subsystem rather than nil-panicking on first request.

Round-5 walkthrough fix: pre-fix the MCP counter was hard-coded zero (Phase 73i shipped before Phase 83w F6 wired the MCP registry into the Console-facing surface). With the registry now reachable from the dev boot path, threading it into CountersProvider makes the Overview page's MCP CONNECTIONS pillar honest — it reports the actual count of `state == Online` servers, not a placeholder zero.

func DriversFromConfig

func DriversFromConfig(cfg *config.Config) []types.SubsystemDriver

DriversFromConfig builds the Phase 72f `runtime.drivers` seam — the configured driver name per persistence-shaped subsystem. Never the DSN (CLAUDE.md §7) — the driver name only.

Like HealthFromConfig, this is the single shared implementation both the production boot path and the devstack fixture assembler consume.

func HealthFromConfig

func HealthFromConfig(cfg *config.Config) []types.SubsystemHealth

HealthFromConfig builds the Phase 72f `runtime.health` seam from the resolved config. The in-process dev / devstack assembly is fully wired by the time the posture surface is constructed, so every persistence-shaped subsystem reports `ready`.

This is the single shared implementation consumed by BOTH the `harbor dev` / `harbor console` boot path and the `harbortest/devstack` fixture assembler — neither hand-rolls its own copy, so the fixture cannot drift from production (CLAUDE.md §17.6; D-132 / Wave 13 NIT cleanup).

func MetricsProvider

func MetricsProvider(reg *telemetry.MetricsRegistry, log *slog.Logger) func(context.Context) types.MetricsSnapshot

MetricsProvider returns a `protocol.PostureDeps.Metrics` seam that projects the Phase 56 telemetry.MetricsRegistry's live counter snapshot onto the Protocol-shaped `types.MetricsSnapshot`.

A registry Snapshot failure is logged at Warn and degrades to an empty (but non-nil) snapshot — a metrics read failure must not fail the whole posture request, but it is never silent (CLAUDE.md §13: the failure is surfaced in the log, not swallowed).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL