Skip to content

[P2] refactor: unify drift/diff/doctor/validate/posture/status-all on one comparison engine (fixes #182) #248

Description

@gfargo

Problem

Six inspection subsystems each answer "does reality match intent?" with a different notion of reality and intent, and they contradict each other: drift (sha256-of-echo, local-only), diff (normalized KV over SSH), doctor (working-dir labels over SSH), validate (source+printenv), posture (grep .env), status-all (local docker + a metrics file nothing writes).

Concrete contradictions: drift says CLEAN while diff shows pending changes; validate fails a var posture passes; doctor's two adjacent deploy-dir probes disagree (grep-from-file vs process env).

Proposal

Extract one comparison engine — fetch remote artifact (file/label/env) → normalize → diff against local git-resolved intent — which lib/diff.sh already ~80% is (pure, tested, SSH-thin). Re-point drift at it (giving drift real remote awareness and fixing all of #182), and keep drift's unique value (history + alerting + cron) as a thin layer. Migrate doctor/validate/posture onto the same normalize+diff core over time.

Acceptance

drift and diff agree on the same repo/host state; #182 sub-bugs resolved by construction; a single normalize function is unit-tested.


Filed from the 2026-07-03 full-codebase audit (docs/AUDIT-2026-07.md). Line numbers are against v0.29.1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: correctness / portability / refactoraudit-2026-07From the 2026-07 full-codebase auditrefactorStructural / tech-debt refactor

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions