PtcRunner.Kernel.CandidateArtifact (PtcRunner v0.14.0)

Copy Markdown View Source

Publishes one model-authored candidate as {candidate.clj, descriptor.json}.

This is the trusted host step ComponentOverride deliberately excludes. A run emits source through channels it already has; an operator carries those bytes here. Nothing a run can influence reaches this module, which is what keeps the descriptor path unreachable from generated code.

Candidate source is treated as private unconditionally. It may have been extracted from a private result artifact, and a world-readable candidate would declassify private model output. Publication therefore reuses the same primitives as result publication: an exclusively created mode-0700 directory, files restricted to 0600 before any content is written, and ancestor ownership and permission checks. The exclusive directory create — not a rename — is the no-clobber guarantee, because POSIX rename may replace an existing empty destination directory.

Publication precedes gating: the gate re-acquires the application through the descriptor written here, so it evaluates exactly the bytes an operator would later promote. discard/1 removes the directory when the gate refuses, so a refused candidate leaves nothing behind.

Summary

Functions

The candidate filename a descriptor references.

The descriptor filename inside a published directory.

Removes a published directory after a refused gate, reporting any material residue.

Writes the candidate and its descriptor into a newly created directory.

Types

error()

@type error() ::
  :candidate_destination_exists
  | :candidate_cleanup_failed
  | :candidate_publication_failed
  | :candidate_source_too_large
  | :descriptor_too_large
  | :invalid_candidate_destination

published()

@type published() :: %{
  directory: binary(),
  candidate: binary(),
  descriptor: binary(),
  descriptor_bytes: non_neg_integer()
}

Functions

candidate_name()

@spec candidate_name() :: binary()

The candidate filename a descriptor references.

descriptor_name()

@spec descriptor_name() :: binary()

The descriptor filename inside a published directory.

discard(directory)

@spec discard(published() | binary()) :: :ok | {:error, :candidate_cleanup_failed}

Removes a published directory after a refused gate, reporting any material residue.

publish(directory, source, descriptor)

@spec publish(binary(), binary(), map()) :: {:ok, published()} | {:error, error()}

Writes the candidate and its descriptor into a newly created directory.

descriptor is the decoded descriptor map minus source_hash and path, both of which are derived here so the bytes hashed are the bytes written.