Skip to content

Add listArtifacts() plugin contract + state-pipeline integration #51

Closed

Description

@lex00

The existing describeResources() plugin contract is entity-keyed: "given a chant entity, return its runtime state." It works for AWS, Temporal, K8s, GCP, Azure — every lexicon whose chant entities have a 1:1 cloud equivalent.

The remaining lexicons (helm, docker, flyway, slurm) emit authoring primitives (chart files, compose files, migration scripts, sbatch jobs) that don't have entity-level runtime state. The right query shape for them is context-keyed: "given an environment, list the artifacts that exist there."

This issue introduces the second contract and wires it through the state pipeline. Per-lexicon implementations follow in #52–#55.

Proposed contract

// In packages/core/src/lexicon.ts
listArtifacts?(options: {
  environment: string;
  // No entityNames/entities — this is a context-scan, not an entity lookup.
  // Implementations may still read the entities map if it helps (e.g. Flyway
  // discovers which envs to query) — passed via the same shape as
  // describeResources for consistency.
  entities: Map<string, { entityType: string; props: Record<string, unknown> }>;
}): Promise<Record<string, ArtifactMetadata>>;

interface ArtifactMetadata {
  type: string;         // e.g. "Helm::Release", "Docker::Container"
  physicalId: string;   // server-side identifier
  status: string;
  lastUpdated?: string;
  attributes?: Record<string, unknown>;
}

The shape is identical to ResourceMetadata; the conceptual difference is whether the lexicon implements describeResources (entity-keyed lookup) or listArtifacts (context scan). A lexicon may implement both if it has both shapes, but most implement one or the other.

State pipeline integration

  • StateSnapshot (packages/core/src/state/types.ts) gains an optional artifacts?: Record<string, ArtifactMetadata> field alongside resources.
  • takeSnapshot() (packages/core/src/state/snapshot.ts) calls both describeResources() and listArtifacts() per plugin and merges into the snapshot.
  • diffLive() (packages/core/src/state/live-diff.ts) handles the artifact case — no declared axis; only observedThen vs observedNow. New result categories: artifactsAdded, artifactsRemoved, artifactsChanged, artifactsUnchanged.
  • runStateDiffLive (packages/core/src/cli/handlers/state.ts) renders artifacts in their own section (ARTIFACTS ADDED / REMOVED / CHANGED). Headers must be added to DRIFT_HEADERS in lexicons/temporal/src/op/activities/state.ts so WatchOp's drift detection scans for them.

Tasks

  • Add ArtifactMetadata type alongside ResourceMetadata in packages/core/src/lexicon.ts
  • Add listArtifacts?() to LexiconPlugin in the same file
  • Extend StateSnapshot with optional artifacts field
  • Update takeSnapshot() to invoke both methods per plugin and merge results into the snapshot file
  • Update sensitive-data check in validateResources (or a new validateArtifacts) to also scan artifact attributes
  • Update diffLive() to handle the artifact-only case (no declared comparison) — emit a separate LiveArtifactDiff or extend LiveDiffResult
  • Update runStateDiffLive rendering with an ARTIFACTS section per lexicon
  • Add new section headers to DRIFT_HEADERS in lexicons/temporal/src/op/activities/state.ts so WatchOp catches artifact changes
  • Extend mockPlugin (packages/test-utils/src/mock-plugin.ts) with a listArtifacts? option matching the existing describeResources? pattern
  • Add a staticListArtifacts(...) helper alongside staticDescribeResources(...) for test ergonomics
  • Tests covering the pipeline:
    • takeSnapshot calls both methods when both are implemented
    • takeSnapshot calls only listArtifacts when only that's implemented
    • diffLive artifacts case: added, removed, changed, unchanged
    • handler renders the artifacts section
    • WatchOp's stateDiff activity treats artifact section headers as drift

Done when

  • LexiconPlugin.listArtifacts() exists and is documented with JSDoc
  • state snapshot <env> writes artifacts to the snapshot file alongside resources
  • state diff --live renders an artifacts section per lexicon
  • Mock plugin factory supports listArtifacts exactly like it supports describeResources
  • All new tests pass; existing 1645+ tests still pass

Out of scope

Parent

Splits #50.

Activity

  1. added a commit that references this issue on May 10, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions